⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 calldetailsdialog.cpp

📁 一个WinCE6。0下的IP phone的源代码
💻 CPP
📖 第 1 页 / 共 4 页
字号:

exit:
    if (pPoom)
    {
        delete pPoom;
    }
    if (FAILED(hr))
    {
        return S_FALSE;
    }
    return hr;
}


/*------------------------------------------------------------------------------
    CallDetailsDialog_t::Refresh
    
    Refreshes the items in the display
    
    Returns (HRESULT): indicating success or failure
------------------------------------------------------------------------------*/
HRESULT CallDetailsDialog_t::Refresh()
{
    HRESULT hr = S_OK;
    
    ExchangeClientRequestStatus ecrs = e_ecrsPending;

    //
    //  Clear all the previous results.
    //    
    SendMessage(m_Listbox, LB_RESETCONTENT, 0, 0);

    //
    //we need to determine the default information to add. 
    //
    // The first item in the list must be the free busy display item
    // otherwise the name has to go first
    //  
    if (m_cpFreeBusyRequest != NULL)
    {
        m_cpFreeBusyRequest->GetStatus(&ecrs);
    }
    
    if (m_cpCallRecord != NULL || ecrs == e_ecrsSucceeded)
    {
        hr = AddFreeBusyDisplayItem();
    }

    if (m_cpContact != NULL)
    {
        hr = AddContactDisplayItems();
    }

    if (m_cpGalInfo != NULL)
    {
        hr = AddGalDisplayItems();
    }

    return hr;
}


/*------------------------------------------------------------------------------
    CallDetailsDialog_t::AddFreeBusyDisplayItem
    
    Adds the appropriate FreeBusy display item to the list
    (if we have call information adds that as well)
    
    Returns (HRESULT): indicating success or failure
------------------------------------------------------------------------------*/
HRESULT CallDetailsDialog_t::AddFreeBusyDisplayItem()
{
    CFreeBusyDisplayItem *pItem = NULL;    
    HRESULT               hr    = S_OK;
   
    CComPtr<IUnknown>                           cpUnk;
    CComPtr<IExchangeClientDataItemArray>       cpData;
    CComPtr<IExchangeClientFreeBusyInformation> cpFBInfo;
    ExchangeClientRequestStatus ecrs = e_ecrsPending;


    WCHAR FreeBusyData[MAX_PATH] = L"";
    WCHAR FriendlyName[MAX_PATH] = L"";

    ce::auto_bstr Name;

    //create the appropriate displayitem
    if (m_cpCallRecord == NULL)
    {
        pItem = new CFreeBusyDisplayItem();
    }
    else
    {
        pItem = new CFreeBusyCallRecordDisplayItem(m_cpCallRecord);
    }
    
    if (!pItem)
    {
        hr = E_OUTOFMEMORY;
    }

    //Try to get the name from the call record (it has precedence since
    //friendlyname is speed dial name as well)
    if (m_cpCallRecord != NULL)
    {
        m_cpCallRecord->get_FriendlyName(&Name);
        if (Name && Name[0])
        {
            StringCchCopy(
                FriendlyName, 
                _countof(FriendlyName),
                Name
                );            
        }
    }

    //Maybe add free busy information (if it exists)
    if (m_cpFreeBusyRequest != NULL)
    {
        m_cpFreeBusyRequest->GetStatus(&ecrs);
    }
    
    if (ecrs == e_ecrsSucceeded)
    {
        if (SUCCEEDED(hr))
        {
            //Now get the free busy information and insert the FB item
            hr = m_cpFreeBusyRequest->GetDataItemArray(&cpData);
        }
        
        if (SUCCEEDED(hr))
        {
            //Get the 2nd item (because the first is "all contacts")
            hr = cpData->GetItemAt(1, &cpUnk);
        }

        if (SUCCEEDED(hr))
        {
            //get the right interface
            hr = cpUnk->QueryInterface(
                IID_IExchangeClientFreeBusyInformation, 
                (void**)&cpFBInfo
                );
        }

        if (SUCCEEDED(hr))
        {
            //Get the Free busy status
            hr = cpFBInfo->GetFreeBusyData(
                FreeBusyData, 
                _countof(FreeBusyData)
                );
        }

        if (SUCCEEDED(hr) && !FreeBusyData[0])
        {
            //Generate all "Unknown" FB data
            for (INT i = 0; i < _countof(FreeBusyData); i++)
            {
                FreeBusyData[i] = L'4';
            }
            FreeBusyData[_countof(FreeBusyData)-1] = 0;
        }

        //if we don't have a disp name yet, get it from FB info
        if (SUCCEEDED(hr) && !FriendlyName[0])
        {
            hr = cpFBInfo->GetDisplayName(
                FriendlyName, 
                _countof(FriendlyName)
                );
        }

        if (SUCCEEDED(hr))
        {
            //set the fb info
            hr = pItem->SetFreeBusyStatus(
                FreeBusyData, 
                &m_FreeBusyStartTime                
                );
        }
    }    

    //
    // ensure that !someone! has set the displayname
    //
    if (!FriendlyName[0])
    {
        //
        //  Use "Unknown Caller" from the resource file as the name.
        //
        hr = pItem->SetDisplayName(
            CommonUtilities_t::LoadString(GlobalData_t::s_ModuleInstance, IDS_LABEL_UNKNOWN_CALLER)
            );
    }
    else
    {
        //set the displayname
        hr = pItem->SetDisplayName(
            FriendlyName
            );
    }
    
    if (SUCCEEDED(hr))
    {
        hr = m_Listbox.AddItem(
            0,
            pItem
            );
    }
    
    //cleanup
    if (FAILED(hr) && pItem)
    {
        delete pItem;
    }
    return hr;
}

/*------------------------------------------------------------------------------
    CallDetailsDialog_t::AddGalDisplayItems
    
    Add the GAL items to the display
    
    Returns (HRESULT): indicating success or failure
------------------------------------------------------------------------------*/
HRESULT CallDetailsDialog_t::AddGalDisplayItems()
{
    if (m_cpGalInfo == NULL)
    {
        //
        //  assert that we are at least *searching* the gal
        //
        ASSERT(m_cpGalRequest != NULL);
        return S_FALSE;
    }

    WCHAR                    Buffer[MAX_PATH] = L"";
    HRESULT                  hr               = S_OK;
    CLabeledInfoDisplayItem *pItem            = NULL;
 
    //
    //if there are any items in the list, we can assume that the NAME was already
    //added (either by contacts or free busy). In that case, we don't want to add the
    //name again
    //
    INT idxStart = ((m_Listbox.GetCount() > 0) ? 1 : 0);
    
    for (INT i = idxStart; i < _countof(sc_GalEntries); i++)
    {
        pItem = NULL;

        //if we are duplicating info from contacts - SKIP this 
        //entry
        if (m_cpContact != NULL)
        {
            //If contacts AND gal exist, then EMAIL address must exist for 
            //both
            if (sc_GalEntries[i].Cookie == GalEmailAddress)
            {
                continue;
            }

            //GAL phone number is the same as contact work phone number
            if (sc_GalEntries[i].Cookie == GalPhoneNumber)
            {
                ce::auto_bstr BusinessPhoneNumber;
                hr = m_cpContact->get_BusinessTelephoneNumber(&BusinessPhoneNumber);
                if (SUCCEEDED(hr) && BusinessPhoneNumber && BusinessPhoneNumber[0])
                {
                    continue;
                }
            }
        }

        //Get the data
        hr = (m_cpGalInfo->*(sc_GalEntries[i].GetPropertyFn))(
                Buffer, 
                _countof(Buffer)
                );

        if (FAILED(hr) || !Buffer[0])
        {
            continue;
        }

        //
        //  Don't check for error, continue with the next item in case of an error.
        //        
        CallDetailsDialog_t::CreateDetailDisplayItems (
            sc_GalEntries[i].Label,
            Buffer,
            sc_GalEntries[i].Cookie,
            sc_GalEntries[i].SupportMultipleLines
            );
    }
    
    return hr;    
}


/*------------------------------------------------------------------------------
    CallDetailsDialog_t::CreateDetailDisplayItems 
    
    Helper function that creates POOM contact/GAL display items.
    
    Returns (HRESULT): indicating success or failure
------------------------------------------------------------------------------*/
HRESULT 
CallDetailsDialog_t::CreateDetailDisplayItems (
    UINT                 Label,
    const WCHAR*         pBuffer,
    DetailStateCookies_e Cookie,
    BOOL                 SupportMultipleLines
    )
{

    HRESULT                  hr    = S_OK;
    CLabeledInfoDisplayItem* pItem = NULL;

    //
    //  There is no data to add, so continue.
    //
    if (pBuffer == NULL || !pBuffer[0])
    {
        return S_FALSE;
    }

    pItem = new CLabeledInfoDisplayItem();
    if (pItem == NULL)
    {
        hr = E_OUTOFMEMORY;
        goto exit;
    }
    
    //
    //  Create the Label.
    //
    hr = pItem->SetLabel(
        CommonUtilities_t::LoadString(GlobalData_t::s_ModuleInstance, Label)
        );
    if(FAILED(hr))
    {
        goto exit;
    }
    
    //
    //  Add the Data.
    //
    hr = pItem->SetDataString(
        pBuffer
        );
    if(FAILED(hr))
    {
        goto exit;
    }
    
    //
    //  Add cookie.
    //
    hr = pItem->SetCookie(
        Cookie
        );
    if(FAILED(hr))
    {
        goto exit;
    }
    
    //
    //  Enable multiple line display.
    //
    hr = pItem->SetMultipleLines(
        SupportMultipleLines
        ); 
    if(FAILED(hr))
    {
        goto exit;
    }
    
    //
    //  Add the item to the list box.
    //    
    hr = m_Listbox.AddItem(
        -1,
        pItem
        );

    exit:
    if (FAILED(hr) && pItem)
    {
        delete pItem;
    }
    return hr;
}

/*------------------------------------------------------------------------------
    CallDetailsDialog_t::AddContactDisplayItems
    
    Add the contact information to the display
    
    Returns (HRESULT): indicating success or failure
------------------------------------------------------------------------------*/
HRESULT CallDetailsDialog_t::AddContactDisplayItems()
{
    if (m_cpContact == NULL)
    {
        return S_FALSE;
    }
    
    CLabeledInfoDisplayItem* pItem              = NULL;
    WCHAR                    Buffer[MAX_PATH]   = L"";
    HRESULT                  hr                 = S_OK;
    ce::auto_bstr            Value;
    
    //
    //  Add all the contacts items except the address ones.
    //
    for (INT i = 0; i < _countof(sc_ContactsEntries); i++)
    {
        pItem = NULL;
        hr = (m_cpContact->*(sc_ContactsEntries[i].GetPropertyFn))(
            &Value
            );
        
        if (FAILED(hr) || Value == NULL || Value[0] == 0)
        {
            continue;
        }

        StringCchCopy(
            Buffer, 
            _countof(Buffer),
            Value
            );

        //
        //  Handle the special case for the Contact email address.
        //
        WCHAR* pBuffer = Buffer;
        if (sc_ContactsEntries[i].Cookie == ContactEmailAddr)
        {
            FormatContactsEmailAddress(
                &pBuffer, 
                Buffer
                );            
        }

        //

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -