}
break;
case SOURCE_SMS:
{
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_SMS);
s2.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_LOWER_SMS); lstSources.addItem(SOURCE_SMS, s1, SOURCE_NAME_SMS,
IDI_SMS, IDI_SMS_DIM, s2, cs->getWinSyncSourceConfig(SOURCE_NAME_SMS));
}
break;
}
}
// Initialize the main logo only if it's build that doesn't have the note and briefcase
if (!isNote && !isBriefcase) {
lstSources.calculateMainLogoPosition();
}
lstSources.refreshSourcePanes();
lstSources.Invalidate();
EnableSyncButton(isSyncEnabled());
}void CuiDlg::SelectSource(int index, bool question){
if(index < 0)
return;
try {
CString s1, s2;
bool refreshPane = false; int id = lstSources.indexToId(index);
string sourceName = lstSources.getSourceName(id);
if (lstSources.isEnabledItem(id)) {
lstSources.setState(id, ITEM_STATE_TO_SYNC);
setFirstSourceToSync(id);
lstSources.refreshSourcePane(id);
string command("manual ");
command += sourceName;
StartSync(CString(command.c_str())); } else {
int retMsgBox = IDYES;
if (question) {
// ask if to enable source
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_TEXT_ENABLE_SYNC_FOR);
s1 += " ";
s1 += lstSources.getItemName(id);
s2.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_TEXT_ITEMS_LOWER);
s2 += "?";
s1 += s2; retMsgBox = TimedMessageBox(GetSafeHwnd(), s1, getLocalizationUtils()->getLocalizationString(IDS_FUNAMBOL_ALERT),
MB_YESNO | MB_ICONQUESTION | MB_SETFOREGROUND, 10 * 1000);
} if(retMsgBox == IDYES){
refreshPane = true;
getRegConfig()->getWinSyncSourceConfig(sourceName.c_str())->setIsEnabled(true);
getRegConfig()->setDirty(getDirtyFlagBySourceName(sourceName));
getRegConfig()->saveDirty();
}
}
if(refreshPane){
lstSources.refreshSourcePane(id);
EnableSyncButton(isSyncEnabled());
} }
catch(...) {
LOG.error("uiDlg: error while selecting source");
} lstSources.UpdateWindow(); }void CuiDlg::StartSync(CString param){
CString s1; int check = checkStartSync();
int ret; setSyncCanceled(false); // check credentials
ClientSettings* cs = getRegConfig();
CString user;
CString password;
user = cs->getAccessConfig().getUsername();
password = cs->getAccessConfig().getPassword(); if(user.IsEmpty() || password.IsEmpty()){
HwndFunctions::closePreviousMsgBox();
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_ERROR_ENTER_CREDENTIALS);
TimedMessageBox(GetSafeHwnd(), s1, getLocalizationUtils()->getLocalizationString(IDS_FUNAMBOL_ALERT), MB_OK | MB_ICONHAND, INFINITE);
OnStartsyncEnded(0,0); // signal sync ended
OnMenuComm();
return; // we return from this so we don't lock the panes
}
else
if (!isServerConfigured()) {
HwndFunctions::closePreviousMsgBox();
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_TEXT_SET_FUNAMBOL_URL);
TimedMessageBox(GetSafeHwnd(), s1, getLocalizationUtils()->getLocalizationString(IDS_FUNAMBOL_ALERT), MB_OK | MB_ICONHAND, INFINITE);
OnStartsyncEnded(0,0); // signal sync ended
OnMenuComm();
return; // we return from this so we don't lock the panes } else if(check == 0) {
// maybe the user deleted the mail account
// so we refresh the mail and if there is no source to be synced, we return
if(! isSyncEnabled())
return; // no sync will be performed ret = startProgram(SYNCAPP, param); // start sync process
if ( (ret == 0) || (ret == -5) ) {
HwndFunctions::closePreviousMsgBox();
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_TEXT_STARTSYNC_NOT_FOUND);
TimedMessageBox(GetSafeHwnd(), s1,getLocalizationUtils()->getLocalizationString(IDS_FUNAMBOL_ALERT), MB_OK | MB_ICONHAND, INFINITE);
OnStartsyncEnded(0,0); // signal sync ended
return; // we return from this so we don't lock the panes
} else {
dlgCommandBar.nToolBarId = IDM_STOP;
if(!SHCreateMenuBar(&dlgCommandBar)){
TRACE(_T("Cannot create command bar!"));
return ;
}
}
}; lstSources.SetItemState(-1, LVIS_SELECTED, LVIF_STATE);
// lock panes so they cannot be selected
lockPanes();
}void CuiDlg::lockPanes(){
lstSources.lockList();
}void CuiDlg::unlockPanes(){
lstSources.unlockList();
}BOOL CuiDlg::PreTranslateMessage(MSG* pMsg){#if defined(WIN32_PLATFORM_PSPC)
// This msg is received to close the plugin from some task-manager applications
// like "X-Button" (included in HTC Touch).
if(pMsg->message == WM_COMMAND) {
if (pMsg->wParam == 0x0001) {
OnClose();
return TRUE;
}
}
#endif#ifdef WIN32_PLATFORM_WFSP
// only for smartphone, it allows to use the back key to move to the desktop even if the
// sync is going on
if (HIWORD(pMsg->lParam) == VK_TBACK) {
return CDialog::PreTranslateMessage(pMsg);
}
if (pMsg->message == WM_KEYDOWN || pMsg->message == WM_KEYDOWN) {
if (pMsg->wParam == VK_TBACK || pMsg->wParam == VK_ESCAPE) {
return CDialog::PreTranslateMessage(pMsg);
}
}
#endif bool bProcessed =false;
if( ((pMsg->message == WM_KEYDOWN) || (pMsg->message == WM_KEYUP) ||
((pMsg->message == WM_LBUTTONDOWN) && (pMsg->hwnd == lstSources.GetSafeHwnd())) ) // click in source list
&& (lstSources.getIsLocked()) ){
bProcessed = true;
return TRUE;
}; if(pMsg->message == WM_KEYDOWN){
if(pMsg->wParam == VK_RETURN){
bProcessed = true;
SelectSource(lstSources.GetNextItem(-1, LVNI_SELECTED));
}
};
if(bProcessed)
return TRUE;
else
return CDialog::PreTranslateMessage(pMsg);
}void CuiDlg::CancelSync(){
OnMenuStop();
}/**
* This method is called by the maincpp at the end of the sync. It needs to set the
* status of the sync source in order to have the right value for the refresh pane
*/
//
LRESULT CuiDlg::OnMsgSourceState(WPARAM wParam, LPARAM lParam) {
lstSources.setSyncSourceState(wParam, lParam);
return 0;
}void CuiDlg::setFirstSourceToSync() { setFirstSourceId(lstSources.getFirstEnabledSource());
}LRESULT CuiDlg::OnMsgEndingSource(WPARAM, LPARAM) {
// sync source ended event
CString s1;
lastItem = currentItem;
currentItem = 0; if(sourceEnds & (int)pow(2.0, currentSource)) {
// done receiving
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_DONE_RECEIVING);
lstSources.setText(currentSource, s1);
} else {
// done sending
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_DONE_SENDING);
lstSources.setText(currentSource, s1);
// set the bit for the current source to know that for it we have received a Sync Source Ended event
sourceEnds |= (int) pow(2.0, currentSource);
}
lstSources.setIsSyncing(currentSource, false);
return 0;
}//
LRESULT CuiDlg::OnMsgConnecting(WPARAM, LPARAM){ CString s1;
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_CONNECTING);
int first = getFirstSourceId();
if(first == -1){
setFirstSourceToSync();
} // check if we have a valid first source
if(first != -1){
lstSources.SetCurSelItem(lstSources.idToIndex(first));
lstSources.setText(first, s1);
lstSources.startAnim(first);
currentSource = first;
}
return 0;
}// 'Ending...' sync message
LRESULT CuiDlg::OnMsgEndingSync(WPARAM, LPARAM) { CString s1;
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_ENDING);
lstSources.setText(currentSource, s1);
lstSources.startAnim(currentSource);
return 0;
}
void CuiDlg::OnTimer(UINT_PTR nIDEvent)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值 OnSyncAll();
CDialog::OnTimer(nIDEvent);
}
break;
case SOURCE_SMS:
{
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_SMS);
s2.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_LOWER_SMS); lstSources.addItem(SOURCE_SMS, s1, SOURCE_NAME_SMS,
IDI_SMS, IDI_SMS_DIM, s2, cs->getWinSyncSourceConfig(SOURCE_NAME_SMS));
}
break;
}
}
// Initialize the main logo only if it's build that doesn't have the note and briefcase
if (!isNote && !isBriefcase) {
lstSources.calculateMainLogoPosition();
}
lstSources.refreshSourcePanes();
lstSources.Invalidate();
EnableSyncButton(isSyncEnabled());
}void CuiDlg::SelectSource(int index, bool question){
if(index < 0)
return;
try {
CString s1, s2;
bool refreshPane = false; int id = lstSources.indexToId(index);
string sourceName = lstSources.getSourceName(id);
if (lstSources.isEnabledItem(id)) {
lstSources.setState(id, ITEM_STATE_TO_SYNC);
setFirstSourceToSync(id);
lstSources.refreshSourcePane(id);
string command("manual ");
command += sourceName;
StartSync(CString(command.c_str())); } else {
int retMsgBox = IDYES;
if (question) {
// ask if to enable source
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_TEXT_ENABLE_SYNC_FOR);
s1 += " ";
s1 += lstSources.getItemName(id);
s2.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_TEXT_ITEMS_LOWER);
s2 += "?";
s1 += s2; retMsgBox = TimedMessageBox(GetSafeHwnd(), s1, getLocalizationUtils()->getLocalizationString(IDS_FUNAMBOL_ALERT),
MB_YESNO | MB_ICONQUESTION | MB_SETFOREGROUND, 10 * 1000);
} if(retMsgBox == IDYES){
refreshPane = true;
getRegConfig()->getWinSyncSourceConfig(sourceName.c_str())->setIsEnabled(true);
getRegConfig()->setDirty(getDirtyFlagBySourceName(sourceName));
getRegConfig()->saveDirty();
}
}
if(refreshPane){
lstSources.refreshSourcePane(id);
EnableSyncButton(isSyncEnabled());
} }
catch(...) {
LOG.error("uiDlg: error while selecting source");
} lstSources.UpdateWindow(); }void CuiDlg::StartSync(CString param){
CString s1; int check = checkStartSync();
int ret; setSyncCanceled(false); // check credentials
ClientSettings* cs = getRegConfig();
CString user;
CString password;
user = cs->getAccessConfig().getUsername();
password = cs->getAccessConfig().getPassword(); if(user.IsEmpty() || password.IsEmpty()){
HwndFunctions::closePreviousMsgBox();
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_ERROR_ENTER_CREDENTIALS);
TimedMessageBox(GetSafeHwnd(), s1, getLocalizationUtils()->getLocalizationString(IDS_FUNAMBOL_ALERT), MB_OK | MB_ICONHAND, INFINITE);
OnStartsyncEnded(0,0); // signal sync ended
OnMenuComm();
return; // we return from this so we don't lock the panes
}
else
if (!isServerConfigured()) {
HwndFunctions::closePreviousMsgBox();
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_TEXT_SET_FUNAMBOL_URL);
TimedMessageBox(GetSafeHwnd(), s1, getLocalizationUtils()->getLocalizationString(IDS_FUNAMBOL_ALERT), MB_OK | MB_ICONHAND, INFINITE);
OnStartsyncEnded(0,0); // signal sync ended
OnMenuComm();
return; // we return from this so we don't lock the panes } else if(check == 0) {
// maybe the user deleted the mail account
// so we refresh the mail and if there is no source to be synced, we return
if(! isSyncEnabled())
return; // no sync will be performed ret = startProgram(SYNCAPP, param); // start sync process
if ( (ret == 0) || (ret == -5) ) {
HwndFunctions::closePreviousMsgBox();
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_TEXT_STARTSYNC_NOT_FOUND);
TimedMessageBox(GetSafeHwnd(), s1,getLocalizationUtils()->getLocalizationString(IDS_FUNAMBOL_ALERT), MB_OK | MB_ICONHAND, INFINITE);
OnStartsyncEnded(0,0); // signal sync ended
return; // we return from this so we don't lock the panes
} else {
dlgCommandBar.nToolBarId = IDM_STOP;
if(!SHCreateMenuBar(&dlgCommandBar)){
TRACE(_T("Cannot create command bar!"));
return ;
}
}
}; lstSources.SetItemState(-1, LVIS_SELECTED, LVIF_STATE);
// lock panes so they cannot be selected
lockPanes();
}void CuiDlg::lockPanes(){
lstSources.lockList();
}void CuiDlg::unlockPanes(){
lstSources.unlockList();
}BOOL CuiDlg::PreTranslateMessage(MSG* pMsg){#if defined(WIN32_PLATFORM_PSPC)
// This msg is received to close the plugin from some task-manager applications
// like "X-Button" (included in HTC Touch).
if(pMsg->message == WM_COMMAND) {
if (pMsg->wParam == 0x0001) {
OnClose();
return TRUE;
}
}
#endif#ifdef WIN32_PLATFORM_WFSP
// only for smartphone, it allows to use the back key to move to the desktop even if the
// sync is going on
if (HIWORD(pMsg->lParam) == VK_TBACK) {
return CDialog::PreTranslateMessage(pMsg);
}
if (pMsg->message == WM_KEYDOWN || pMsg->message == WM_KEYDOWN) {
if (pMsg->wParam == VK_TBACK || pMsg->wParam == VK_ESCAPE) {
return CDialog::PreTranslateMessage(pMsg);
}
}
#endif bool bProcessed =false;
if( ((pMsg->message == WM_KEYDOWN) || (pMsg->message == WM_KEYUP) ||
((pMsg->message == WM_LBUTTONDOWN) && (pMsg->hwnd == lstSources.GetSafeHwnd())) ) // click in source list
&& (lstSources.getIsLocked()) ){
bProcessed = true;
return TRUE;
}; if(pMsg->message == WM_KEYDOWN){
if(pMsg->wParam == VK_RETURN){
bProcessed = true;
SelectSource(lstSources.GetNextItem(-1, LVNI_SELECTED));
}
};
if(bProcessed)
return TRUE;
else
return CDialog::PreTranslateMessage(pMsg);
}void CuiDlg::CancelSync(){
OnMenuStop();
}/**
* This method is called by the maincpp at the end of the sync. It needs to set the
* status of the sync source in order to have the right value for the refresh pane
*/
//
LRESULT CuiDlg::OnMsgSourceState(WPARAM wParam, LPARAM lParam) {
lstSources.setSyncSourceState(wParam, lParam);
return 0;
}void CuiDlg::setFirstSourceToSync() { setFirstSourceId(lstSources.getFirstEnabledSource());
}LRESULT CuiDlg::OnMsgEndingSource(WPARAM, LPARAM) {
// sync source ended event
CString s1;
lastItem = currentItem;
currentItem = 0; if(sourceEnds & (int)pow(2.0, currentSource)) {
// done receiving
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_DONE_RECEIVING);
lstSources.setText(currentSource, s1);
} else {
// done sending
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_DONE_SENDING);
lstSources.setText(currentSource, s1);
// set the bit for the current source to know that for it we have received a Sync Source Ended event
sourceEnds |= (int) pow(2.0, currentSource);
}
lstSources.setIsSyncing(currentSource, false);
return 0;
}//
LRESULT CuiDlg::OnMsgConnecting(WPARAM, LPARAM){ CString s1;
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_CONNECTING);
int first = getFirstSourceId();
if(first == -1){
setFirstSourceToSync();
} // check if we have a valid first source
if(first != -1){
lstSources.SetCurSelItem(lstSources.idToIndex(first));
lstSources.setText(first, s1);
lstSources.startAnim(first);
currentSource = first;
}
return 0;
}// 'Ending...' sync message
LRESULT CuiDlg::OnMsgEndingSync(WPARAM, LPARAM) { CString s1;
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_ENDING);
lstSources.setText(currentSource, s1);
lstSources.startAnim(currentSource);
return 0;
}
void CuiDlg::OnTimer(UINT_PTR nIDEvent)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值 OnSyncAll();
CDialog::OnTimer(nIDEvent);
}
这样看代码你还不如把工程发给我们调一下......