?? uidlg.cpp
字號(hào):
resetCurrentItem = true;
totalItems = 0;
lastItem = 0;
sourceEnds = 0;
sourceBegins = 0;
firstSourceId = -1;
nMailsToSync = 0;
lstSources.SetItemState(lstSources.GetCurSelItem(), 0, LVIS_FOCUSED);
//refreshRecoveredSources();
unlockPanes();
// for the case of scheduled sync when the user is in a config window
if(!isInSettings){
refreshSourcePanes();
}
if(! bSyncCanceled) // TODO: is this necessary?
lstSources.setStateToAll(ITEM_STATE_OK);
return 0;
}
LRESULT CuiDlg::OnStartingSync(WPARAM wParam, LPARAM lParam)
{
CString s2;
if(!isInSettings){
HwndFunctions::closePreviousMsgBox();
CreateMenuBar(IDM_STOP);
#if defined WIN32_PLATFORM_WFSP
#if (_WIN32_WCE < 0x500)
CreateMenuBar(IDR_MENUBAR_STOP);
#endif
#endif
}
lockPanes();
bSyncStarted = true;
//getRegConfig()->saveDirty();
// received start sync message, we check if startsync.exe has given the first source to be synced
// if wParam !=0, then in lParam we have the id of the 1st source
if(wParam != 0){
firstSourceId = (int)lParam;
}
return 0;
}
void CuiDlg::OnMenuAbout()
{
CAbout wndAbout;
isInSettings = true;
INT_PTR result = wndAbout.DoModal();
isInSettings = false;
if(bSyncStarted){
CreateMenuBar(IDM_STOP);
}
}
void CuiDlg::OnMenuStop()
{
// because the sync is possibly being canceled in EndAppQuery, we set bSyncCanceled to true before calling it
bSyncCanceled = true;
int ret = EndAppQuery(GetSafeHwnd());
// If startsync was not running simulate the message.
// 1 - sync not running
// 0 - user choosed to stop the sync, we need to call OnStartsyncEnded
// to reset the controls
if(ret== 0) {
bSyncCanceled = true;
refreshCanceledState();
OnStartsyncEnded(NULL, (LPARAM) -20 ); // nothing to show...
}
else if (ret== 1){
bSyncCanceled = true;
refreshCanceledState();
OnStartsyncEnded(NULL, (LPARAM) -6 );
}
else{
bSyncCanceled = false;
}
}
void CuiDlg::OnMenuPush()
{
CPushSettings wndPushSettings;
isInSettings = true;
INT_PTR result;
result = wndPushSettings.DoModal();
isInSettings = false;
if(bSyncStarted){
CreateMenuBar(IDM_STOP);
}
}
void CuiDlg::OnMenuSync()
{
CSyncSettings wndSyncSettings;
isInSettings = true;
INT_PTR result = wndSyncSettings.DoModal();
isInSettings = false;
refreshSourcePanes();
}
LRESULT CuiDlg::OnStartingSource(WPARAM wParam, LPARAM lParam)
{
CString s1,s2;
if (!lstSources.getIsLocked()){
lockPanes();
}
lstSources.stopAnim(currentSource);
currentSource = lParam;
if(! (sourceBegins & (int)pow(2.0, currentSource)) ){
// set the bit for the current source to know that for it we have received a Sync Source Ended event
sourceBegins |= (int) pow(2.0, currentSource);
CString msg;
msg.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_CHECKING);
msg+=" ";
switch(lParam)
{
case SOURCE_MAIL:
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_LOWER_MAIL); break;
case SOURCE_CALENDAR:
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_LOWER_CALENDAR); break;
//s1=getStringLang(IDS_LOWER_CALENDAR); break;
case SOURCE_CONTACTS:
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_LOWER_CONTACTS); break;
case SOURCE_TASKS:
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_LOWER_TASKS); break;
case SOURCE_BRIEFCASE:
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_LOWER_FILES); break;
case SOURCE_NOTES:
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_LOWER_NOTES); break;
default:
s1 = "";
}
msg+=s1;
lstSources.setText(lParam, msg);
};
// if source fails without sending a message that it has finished
// then we send it ourselves
if(lstSources.getIsSyncing(currentSource)){
OnMsgEndingSource(NULL, NULL);
}
// if the source fails without sending 'Starting' message
//s1 = lstSources.getText(currentSource);
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_CONNECTING); s2 = "("; s2+=s1; s2+= ")";
s1 = lstSources.getText(firstSourceId);
if(s1.Compare(s2) == 0){
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_FAILED);
lstSources.setText(firstSourceId, s1);
}
//currentSource = lParam;
currentItem = 0;
lstSources.stopAnim(firstSourceId);
lstSources.setIsSyncing(currentSource, true);
lstSources.SetCurSelItem(lstSources.idToIndex(currentSource));
lstSources.startAnim(currentSource);
return 0;
}
// not a WM_APP message handler
void CuiDlg::OnMsgItemSynced(WPARAM wParam, LPARAM lParam, bool fromClient)
{
int source=-1;
CString msg("");
CString s1;
if(!bSyncStarted)
return;
currentItem++;
if( (wParam > 0) && (currentSource != wParam) ) // extra check
{
resetCurrentItem = true;
lastItem = 0;
};
if( fromClient ){
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_SENDING);
msg+=s1; msg+=" ";
}
else{
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_RECEIVING);
msg+=s1; msg+=" ";
}
source = wParam;
currentSource = source;
if(currentSource == SOURCE_MAIL){
totalItems = nMailsToSync;
};
if( (!resetCurrentItem) && (lParam != 0) ) // the server sent more valid noc's for the same source
currentItem =lastItem+lParam;
switch(source)
{
case SOURCE_MAIL:
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_LOWER_MAIL); break;
case SOURCE_CALENDAR:
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_LOWER_CALENDAR); break;
case SOURCE_CONTACTS:
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_LOWER_CONTACT); break;
case SOURCE_TASKS:
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_LOWER_TASK); break;
case SOURCE_BRIEFCASE:
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_LOWER_FILE); break;
case SOURCE_NOTES:
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_LOWER_NOTE); break;
default:
s1 = "";
}
msg+=s1;
if(msg == "")
goto finally;
msg+=" ";
char* v = ltow(currentItem);
msg+=v;
delete [] v; v = NULL;
if( (totalItems != -1) && (currentItem <= totalItems))
{
msg+="/";
char* v = ltow(totalItems);
msg+=v;
delete [] v; v = NULL;
}
lstSources.setText(source, msg);
finally:
return;
}
LRESULT CuiDlg::OnMsgItemSyncedFromServer( WPARAM wParam, LPARAM lParam)
{
OnMsgItemSynced(wParam,lParam, false);
return 0;
}
LRESULT CuiDlg::OnMsgItemSyncedFromClient( WPARAM wParam, LPARAM lParam)
{
OnMsgItemSynced(wParam, lParam, true);
return 0;
}
// TODO: remove unused code
LRESULT CuiDlg::OnMsgTotalItems(WPARAM wParam, LPARAM lParam)
{
CString msg;
CString s1;
bool changeLabel = false;
int sourceNumber = wParam;
totalItems = lParam;
msg.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_RECEIVING); msg+=" ";
#if 0
if ( (sourceNumber != -1) && (sourceNumber > 0) ) // wParam > 0, then the modifs are from server
{
if (sourceNumber != currentSource) // a new source from server
{
// begin a new source from server, update the progress bar for the previous source
changeLabel = true;
if((currentItem < ITEMS_FROM_SERVER) && (currentItem > 0) && (totalItems == -1))
{
/* syncSourceTotalServerItems supplied -1, so if the number of synced
items is less than ITEMS_FROM_SERVER, step the remaining of the progressbar for
(ITEMS_FROM_SERVER - currentItem-1) items
*/
currentItem = 0;
lastItem = 0;
};
totalItems = lParam;
resetCurrentItem = true;
lastItem = 0;
currentItem = 0;
currentSource = sourceNumber;
}
else
{
/*
wParam == currentSource, one of more syncSourceTotalServerItems events for
the same source, or there is only one source to be synced
(lastSource == -1) for sources from client
(lastSource > 0) for sources from server, here lastSource is the source code
*/
if(lastSource < 0) // (wParam>0) && (lastSource<0) => first source from server
{
resetCurrentItem = true;
totalItems = lParam;
lastItem = 0;
currentItem = 0;
changeLabel = true;
}
else
{
resetCurrentItem = false;
lastItem = currentItem;
}
};
} //if wParam < 0
else if(wParam == -1)
{
totalItems = lParam; // source from client, total items are ok
}
#endif
switch(sourceNumber)
{
case SOURCE_MAIL:
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_LOWER_MAIL); break;
case SOURCE_CALENDAR:
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_LOWER_CALENDAR); break;
case SOURCE_CONTACTS:
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_LOWER_CONTACTS); break;
case SOURCE_TASKS:
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_LOWER_TASKS); break;
case SOURCE_BRIEFCASE:
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_LOWER_NOTES); break;
case SOURCE_NOTES:
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_LOWER_FILES); break;
default:
s1 = "";
}
msg+=s1;
if( (msg!="") && changeLabel) // !
{
SetDlgItemText(IDC_MAIN_MSG,msg);
lstSources.setText(wParam, msg);
if(lstSources.GetNextItem(-1, LVNI_SELECTED ) != wParam)
lstSources.SetItemState(wParam, LVIS_SELECTED, LVIF_STATE);
}
if(wParam == SOURCE_MAIL){
nMailsToSync+=totalItems;
}
return 0;
}
void CuiDlg::CreateMenuBar(const int id){
ZeroMemory(&dlgCommandBar, sizeof(SHMENUBARINFO));
dlgCommandBar.cbSize = sizeof(SHMENUBARINFO);
dlgCommandBar.hwndParent = this->GetSafeHwnd();
dlgCommandBar.dwFlags = SHCMBF_HMENU;
dlgCommandBar.nToolBarId = id;
dlgCommandBar.hInstRes = getLocalizationUtils()->getLocaleResource();
dlgCommandBar.nBmpId = 0;
dlgCommandBar.cBmpImages = 0;
if(!SHCreateMenuBar(&dlgCommandBar)){
TRACE(_T("Cannot create command bar!\n\n"));
}
}
void CuiDlg::OnOK()
{
this->ShowWindow(SW_MINIMIZE);
}
bool isServerConfigured() {
ClientSettings* cs = getRegConfig();
CString s1;
s1 = cs->getAccessConfig().getSyncURL();
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -