📄 calldetailsdialog.cpp
字号:
// Don't check for error, continue with the next item in case of an error.
//
CreateDetailDisplayItems (
sc_ContactsEntries[i].Label,
pBuffer,
sc_ContactsEntries[i].Cookie,
sc_ContactsEntries[i].SupportMultipleLines
);
}
//
// Add all the address items.
//
for (INT i = 0; i < _countof(sc_ContactsAddressEntries); i++)
{
pItem = NULL;
hr = GetContactAddress(
&Value,
sc_ContactsAddressEntries[i].Cookie
);
if (FAILED(hr) || Value == NULL || Value[0] == 0)
{
continue;
}
StringCchCopy(
Buffer,
_countof(Buffer),
Value
);
//
// Don't check for error, continue with the next item in case of an error.
//
CreateDetailDisplayItems (
sc_ContactsAddressEntries[i].Label,
Buffer,
sc_ContactsAddressEntries[i].Cookie,
TRUE
);
}
return hr;
}
/*------------------------------------------------------------------------------
CallDetailsDialog_t::GetContactAddress(
Reads the contact address
------------------------------------------------------------------------------*/
HRESULT
CallDetailsDialog_t::GetContactAddress(
BSTR* Buffer,
DetailStateCookies_e AddressType
)
{
if (Buffer == NULL)
{
return E_POINTER;
}
*Buffer = NULL;
//
// Choose the set of get_* properties to call for reading Home/Office address.
//
uint PropertyCount;
const pfnGetContactProperty* pContactPropertyList = NULL;
switch (AddressType)
{
case ContactHomeAddr:
pContactPropertyList = sc_ContactsHomeAddressProperties;
PropertyCount = _countof (sc_ContactsHomeAddressProperties);
break;
case ContactWorkAddr:
pContactPropertyList = sc_ContactsOfficeAddressProperties;
PropertyCount = _countof (sc_ContactsOfficeAddressProperties);
break;
default:
return E_INVALIDARG;
}
HRESULT hr;
ce::wistring CopyOfString;
for (int i = 0; i < PropertyCount; i++)
{
ce::auto_bstr Value;
hr = (m_cpContact->*(pContactPropertyList[i]))(
&Value
);
if (FAILED(hr) || Value == NULL || Value[0] == 0)
{
continue;
}
//
// Apprend the string and a new line.
//
if (!CopyOfString.append(Value))
{
return E_POINTER;
}
if (!CopyOfString.append(L"\n"))
{
return E_POINTER;
}
}
if (CopyOfString.empty() == TRUE)
{
return S_OK;
}
*Buffer = SysAllocString(CopyOfString.get_buffer());
if (*Buffer == NULL)
{
return E_POINTER;
}
return S_OK;
}
/*------------------------------------------------------------------------------
CallDetailsDialog_t::StartChildRequests
If we have some contact information, start a GAL search.
If we have Gal information, start a FB search
Returns (HRESULT): indicating success or failure
------------------------------------------------------------------------------*/
HRESULT CallDetailsDialog_t::StartChildRequests()
{
HRESULT hr = S_FALSE;
if (m_cpGalInfo != NULL)
{
hr = StartFreeBusyRequest();
}
else
{
hr = StartGalRequest();
}
return hr;
}
/*------------------------------------------------------------------------------
CallDetailsDialog_t::StartFreeBusyRequest
Start a free busy request based on GAL information
Returns (HRESULT): indicating success or failure
------------------------------------------------------------------------------*/
HRESULT CallDetailsDialog_t::StartFreeBusyRequest()
{
WCHAR EmailAddress[MAX_PATH] = L"";
FreeBusyCriteria FreeBusyRequestCriteria = {0};
SYSTEMTIME TimeNow = {0};
CComPtr<IExchangeClient> cpExchangeClient;
HRESULT hr = S_OK;
//check that we have not already started the request (on re-entering the state)
if (m_cpFreeBusyRequest != NULL)
{
return S_FALSE;
}
hr = PhInfoGlobalData_t::pPhInfoApp->GetExchangeClient(
&cpExchangeClient
);
if(FAILED(hr))
{
ASSERT(FALSE);
COMMON_DEBUGMSG(ZONE_PHINFO_ERROR, (L"Unable to get Exchange client. hr = 0x%x", hr));
return hr;
}
GetLocalTime(&TimeNow);
TimeNow.wMilliseconds = 0;
TimeNow.wSecond = 0;
TimeNow.wMinute = 0;
IncrementTime(&m_FreeBusyStartTime, &TimeNow, -3); // 3 hours backwards
if (SUCCEEDED(hr))
{
hr = m_cpGalInfo->GetSMTPAddress(
EmailAddress,
_countof(EmailAddress)
);
}
//search based on the SMTP email address from GAL
if (SUCCEEDED(hr))
{
FreeBusyRequestCriteria.wszAlias = EmailAddress;
FreeBusyRequestCriteria.pstStart = &m_FreeBusyStartTime;
hr = cpExchangeClient->RequestFreeBusyData(
&FreeBusyRequestCriteria,
&m_cpFreeBusyRequest
);
}
return hr;
}
/*------------------------------------------------------------------------------
CallDetailsDialog_t::StartGalRequest
If we have a matching contact, try to look them up in the GAL for more information
Returns (HRESULT): indicating success or failure
------------------------------------------------------------------------------*/
HRESULT CallDetailsDialog_t::StartGalRequest()
{
GALSearchCriteria criteria = {0};
WCHAR Email[MAX_PATH] = L"";
WCHAR* pEmail = NULL;
WCHAR* pAt = NULL;
HRESULT hr = S_OK;
CComPtr<IExchangeClient> cpExchangeClient;
//ensure we have a matching contact and that we don't already have the info
if (m_cpContact == NULL || m_cpGalRequest != NULL)
{
return S_FALSE;
}
hr = PhInfoGlobalData_t::pPhInfoApp->GetExchangeClient(
&cpExchangeClient
);
if (FAILED(hr))
{
ASSERT(FALSE);
COMMON_DEBUGMSG(ZONE_PHINFO_ERROR, (L"Unable to get Exchange client. hr = 0x%x", hr));
return hr;
}
ce::auto_bstr EmailAddress;
hr = m_cpContact->get_Email1Address(
&EmailAddress
);
if (FAILED(hr) || (EmailAddress == NULL) || (EmailAddress[0] == 0))
{
return hr;
}
StringCchCopy(
Email,
_countof(Email),
EmailAddress
);
FormatContactsEmailAddress(&pEmail, Email);
pAt = wcschr(Email, L'@');
if (!pAt)
{
return S_FALSE;
}
//null-terminate the alias substring
*pAt = 0;
//strip off the leading quotation added by exchange
criteria.wszAlias = (Email[0] == L'\"') ? Email+1 : Email;
hr = cpExchangeClient->RequestGALSearch(
&criteria,
&m_cpGalRequest
);
return hr;
}
BOOL
CallDetailsDialog_t::HookProc(
HWND hwnd,
UINT Message,
WPARAM wParam,
LPARAM lParam
)
{
switch (Message)
{
case WM_EXCHANGE_QUERY_COMPLETED:
return SUCCEEDED(OnExchangeQueryCompleted ((IExchangeClientRequest*)lParam, (ExchangeClientRequestStatus)wParam));
case WM_COMMAND:
return SUCCEEDED(OnCommand (wParam));
}
return FALSE;
}
/*------------------------------------------------------------------------------
CallDetailsDialog_t::OnCommand
Handles WM_COMMAND message
Returns (HRESULT): indicating success or failure
------------------------------------------------------------------------------*/
HRESULT
CallDetailsDialog_t::OnCommand (
WPARAM wParam
)
{
switch (LOWORD(wParam))
{
case IDOK:
//
// Go back to the previous screen.
//
return PhInfoGlobalData_t::pPhInfoApp->GoBackToPreviousScreen ();
case IDC_ADDSPEEDDIAL:
return OnAddToSpeedDial();
case IDC_DIAL:
return OnDial();
}
return E_FAIL;
}
/*------------------------------------------------------------------------------
CallDetailsDialog_t::OnExchangeQueryCompleted
Handles WM_EXCHANGE_QUERY_COMPLETED message from InfoApp.
Parameters:
piRequest: The request being updated
ecrs: The new status
Returns (HRESULT): indicating success or failure
------------------------------------------------------------------------------*/
HRESULT
CallDetailsDialog_t::OnExchangeQueryCompleted(
IExchangeClientRequest* piRequest,
ExchangeClientRequestStatus ecrs
)
{
HRESULT hr = S_FALSE;
if (ecrs != e_ecrsSucceeded)
{
return S_FALSE;
}
//if this is one of the requests we care about, update the
//request status
if (m_cpFreeBusyRequest == piRequest)
{
hr = OnFreeBusyRequestSucceeded();
}
else if (m_cpGalRequest == piRequest)
{
hr = OnGalRequestSucceeded();
}
return hr;
}
/*------------------------------------------------------------------------------
CallDetailsDialog_t::OnGalRequestSucceeded
Handles our GAL request succeeding - we should add the GAL information
and kick off a FB search
Returns (HRESULT): indicating success or failure
------------------------------------------------------------------------------*/
HRESULT CallDetailsDialog_t::OnGalRequestSucceeded()
{
CComPtr<IExchangeClientDataItemArray> cpData;
CComPtr<IUnknown> cpUnk;
CComPtr<IExchangeClientGALSearchInformation> cpGalInfo;
HRESULT hr = S_OK;
UINT Items = 0;
WCHAR ContactEmail[MAX_PATH] = L"";
WCHAR GalEmail [MAX_PATH] = L"";
WCHAR *pContactEmail = NULL;
WCHAR *pDomainContact = NULL;
WCHAR *pDomainGal = NULL;
ce::auto_bstr EmailAddress;
hr = m_cpContact->get_Email1Address(
&EmailAddress
);
if (FAILED(hr) || (EmailAddress == NULL) || (EmailAddress[0] == 0))
{
return hr;
}
StringCchCopy(
ContactEmail,
_countof(ContactEmail),
EmailAddress
);
//account for the possible quotation adding by contacts surrounding the address
pContactEmail = ContactEmail;
if (ContactEmail[0] == L'\"')
{
WCHAR *pwchEndQuote = NULL;
pContactEmail = ContactEmail+1;
pwchEndQuote = wcschr(pContactEmail, L'\"');
if (pwchEndQuote)
*pwchEndQuote = 0;
}
//First verify that the email addresses match (both by ALIAS and SERVER.COM)
if (! ConvertEmailAddressToAliasAndDomain(
pContactEmail,
&pDomainContact
))
{
return S_FALSE;
}
hr = m_cpGalRequest->GetDataItemArray(&cpData);
if (FAILED(hr))
{
return hr;
}
hr = cpData->GetItemCount(&Items);
if (FAILED(hr))
{
return hr;
}
for (INT i = 0; i < Items; i++)
{
cpUnk = NULL;
cpGalInfo = NULL;
hr = cpData->GetItemAt(i, &cpUnk);
if (FAILED(hr))
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -