📄 gallistdialog.cpp
字号:
//
if (piRequest != m_cpExchangeRequest)
{
return E_POINTER;
}
if (Status == e_ecrsCancelled)
{
//either we are shutting down or a setting has changed!
DialogScreen_t::Exit();
return S_OK;
}
if (Status != e_ecrsSucceeded)
{
ShowProgressStatusMessage(Status);
return S_OK;
}
//
// Now display the contact/gal details.
//
return DisplayGALContacts();
}
/*------------------------------------------------------------------------------
GalListDialog_t::ShowProgressStatusMessage
Display different status messages based on the request status returned by
the exchange client.
------------------------------------------------------------------------------*/
HRESULT
GalListDialog_t::ShowProgressStatusMessage(
ExchangeClientRequestStatus Status
)
{
UINT StringId = 0;
UINT PopupError = 0;
switch (Status)
{
case e_ecrsPending:
StringId = IDS_STATUS_EXCHANGE_WAITING;
break;
case e_ecrsInProgress:
case e_ecrsSending:
StringId = IDS_STATUS_EXCHANGE_SENDINGREQUEST;
break;
case e_ecrsBypassingOWAPage:
StringId = IDS_STATUS_EXCHANGE_LOGGINGIN;
break;
case e_ecrsFailedToBypassAuthPage:
case e_ecrsNoCredentials:
StringId = IDS_ERROR_EXCHANGE_INVALIDCREDS;
PopupError = IDS_ERROR_POPUP_EXCHANGE_NOCREDS;
m_ErrorMenuId = IDMB_UPDATEPASSWORD;
break;
case e_ecrsOutOfMemory:
StringId = IDS_ERROR_POPUP_CONTACTS_OOM;
PopupError = IDS_ERROR_POPUP_CONTACTS_OOM;
m_ErrorMenuId = IDMB_MSGBOX_ERROR;
break;
case e_ecrsParseFailed:
StringId = IDS_ERROR_EXCHANGE_INVALIDDATA;
break;
case e_ecrsHttpFailure:
case e_ecrsFailedToSend:
StringId = IDS_ERROR_EXCHANGE_SERVERERROR;
PopupError = IDS_ERROR_POPUP_EXCHANGE_CANTCONNECT;
m_ErrorMenuId = IDMB_YESNOTRYAGAIN;
break;
default:
ASSERT(FALSE);
return S_FALSE;
}
ASSERT(StringId);
STATUS_HEADER_PARAMETERS Params = {0};
Params.Cookie = 100;
Params.Instance = GlobalData_t::s_ModuleInstance;
Params.Priority = shpDefault;
Params.secTimeout = INFINITE;
Params.ResourceId = StringId;
SendMessage(
m_StatusRegion,
WM_STATUSHEADER_ADDSTATUSNOTIFICATION,
sizeof(Params),
(LPARAM)&Params
);
//is there a popup error?
if (PopupError)
{
ShowError(
PopupError,
m_ErrorMenuId,
(m_ErrorMenuId == IDMB_MSGBOX_ERROR) ? true : false
);
}
return S_OK;
}
/*------------------------------------------------------------------------------
GalListDialog_t::OnEditControlUpdate
This function handles text inputs to the edit control.
Sets a timer that initialtes an exchange query.
------------------------------------------------------------------------------*/
HRESULT
GalListDialog_t::OnEditControlUpdate (
void
)
{
m_RefreshNeeded = true;
//
// Read the query string from the search edit control.
//
IVoIPDisplayItem* pVoipDisplayItem = m_Listbox.GetItem(0);
if (pVoipDisplayItem == NULL)
{
ASSERT (FALSE);
return E_POINTER;
}
WCHAR Buffer[MAX_PATH];
HRESULT hr = pVoipDisplayItem->GetText(
Buffer,
_countof(Buffer)
);
if (FAILED (hr))
{
return hr;
}
if (!m_QueryValue.assign(Buffer))
{
return E_OUTOFMEMORY;
}
//
// Check if Backspace button is needed.
//
m_MenuBar.ShowMenuButton(
IDC_BACKSPACE,
(m_QueryValue[0] != 0)
);
//
// If the query text is empty, then clear the results.
//
if (m_QueryValue[0] == 0 && m_Listbox.GetCount() > 1)
{
//
// Clear the results.
//
ClearSearchResults ();
//
// Update the status.
//
UpdateStatus ();
return S_OK;
}
//
// Update the timer that starts the exchange query upon expirty.
//
return UpdateTimer ();
}
/*------------------------------------------------------------------------------
GalListDialog_t::UpdateTimer
If the timer is already set then it is disables and a new timer is created.
------------------------------------------------------------------------------*/
HRESULT
GalListDialog_t::UpdateTimer (
void
)
{
//
// If the timer is set, then it means a character was entered within timeout period.
//
if (m_GalQueryTimerId != 0)
{
if(KillTimer(m_Dialog, m_GalQueryTimerId) == FALSE)
{
ASSERT(FALSE);
}
m_GalQueryTimerId = 0;
}
//
// Add a timer to wait for c_WaitThreshold. If no input is given after the timeout, an exchange query is initiated.
//
m_GalQueryTimerId = SetTimer(
m_Dialog,
sc_GalRequestTimer,
sc_WaitThreshold,
NULL
);
return (m_GalQueryTimerId == 0) ? CommonUtilities_t::GetErrorFromWin32() : S_OK;
}
/*------------------------------------------------------------------------------
GalListDialog_t::OnListBoxSelectionChange
This function handles when an item is selected in the List box.
Sets a dial/details buttons when one of the entries is selected.
------------------------------------------------------------------------------*/
HRESULT
GalListDialog_t::OnListBoxSelectionChange (
void
)
{
//
// Decide the proper buttons that are needed for this selection.
//
UINT MenuId = 0;
if (m_Listbox.GetCurSel() == 0)
{
MenuId = IDMB_GALCONTACTLIST;
}
else
{
MenuId = IDMB_CONTACTSITEM;
}
//
// Display the correct set of buttons if needed.
//
if (MenuId != m_CurrentMenuId)
{
HRESULT hr = m_MenuBar.SetMenu(
GlobalData_t::s_ModuleInstance,
MenuId
);
if (SUCCEEDED(hr))
{
m_CurrentMenuId = MenuId;
}
return hr;
}
return S_OK;
}
/*------------------------------------------------------------------------------
GalListDialog_t::OnTimerExpires
This function is called when Timer expires.
Reads the search string from the edit box and initiates an exchange query.
------------------------------------------------------------------------------*/
HRESULT
GalListDialog_t::OnTimer(
UINT TimerID
)
{
if (TimerID == 0 || TimerID != m_GalQueryTimerId)
{
return E_FAIL;
}
//
// Disable the timer.
//
if (KillTimer(m_Dialog, m_GalQueryTimerId) == FALSE)
{
COMMON_DEBUGMSG(ZONE_PHINFO_WARNING, (L"Unable to kill the GAL query timer."));
ASSERT(FALSE);
}
m_GalQueryTimerId = 0;
//
// Initiate an Exchange query.
//
return CreateExchangeRequest();
}
/*------------------------------------------------------------------------------
GalListDialog_t::OnDial
Place a call in the phone app with the number specified in the
GAL record we selected.
------------------------------------------------------------------------------*/
HRESULT
GalListDialog_t::OnDial(
void
)
{
HRESULT hr = S_OK;
CComPtr<IExchangeClientGALSearchInformation> cpGAL;
PH_MAKEPHONECALL_PARAMETERS Parameters = {0};
hr = GetSelectedGAL (&cpGAL);
if (FAILED(hr))
{
ASSERT(FALSE);
return hr;
}
//
// Get the phone number.
//
Parameters.StructSize = sizeof(Parameters);
hr = cpGAL->GetPhoneNumber (
Parameters.DestAddress,
_countof(Parameters.DestAddress)
);
if (FAILED(hr))
{
return hr;
}
//
// Get the display name, ignore errors.
//
cpGAL->GetDisplayName(
Parameters.CalledParty,
_countof(Parameters.CalledParty)
);
hr = PHMakePhoneCall(&Parameters);
if (FAILED(hr))
{
COMMON_DEBUGMSG(ZONE_PHINFO_ERROR, (L"Failed to make a phone call. hr = 0x%x, Phone Number = %s", hr, Parameters.DestAddress));
}
return hr;
}
HRESULT
GalListDialog_t::CreateDialogScreen(
void
)
{
m_CurrentMenuId = IDMB_GALCONTACTLIST;
HRESULT hr = DialogScreen_t::CreateDialogScreen(
PHINFO_GAL_CONTACT_LIST_SCREEN_ID,
m_CurrentMenuId,
CommonUtilities_t::LoadString(GlobalData_t::s_ModuleInstance, IDS_TITLE_GAL),
L""
);
if (FAILED(hr))
{
return hr;
}
//
// There is no text in the filter edit box, so don't show the backspace button.
//
m_MenuBar.ShowMenuButton(
IDC_BACKSPACE,
false
);
AddSearchInputListBox ();
return UpdateStatus ();
}
/*------------------------------------------------------------------------------
GalListDialog_t::UpdateSearchInputListBoxTitle
This function updates the title on Search edit box.
------------------------------------------------------------------------------*/
HRESULT
GalListDialog_t::UpdateSearchInputListBoxTitle (
UINT TitleResourceId
)
{
const WCHAR* pSearchTitle = CommonUtilities_t::LoadString (
GlobalData_t::s_ModuleInstance,
TitleResourceId
);
IVoIPDisplayItem* pVoipDisplayItem = m_Listbox.GetItem(0);
if(pVoipDisplayItem == NULL)
{
return E_FAIL;
}
IVoIPLabeledEditDisplayItem* pSearchEditDisplayItem;
HRESULT hr = pVoipDisplayItem->QueryInterface (
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -