advisesink.cpp
来自「funambol windows mobile plugin source co」· C++ 代码 · 共 589 行 · 第 1/2 页
CPP
589 行
}
SPropValue* msgprops = NULL;
ULONG cmsgValue = 0;
hr = globalpmsg->GetProps ((LPSPropTagArray)&Columns, MAPI_UNICODE, &cmsgValue,
&msgprops);
if (msgprops[ePR_MSG_STATUS].ulPropTag == PR_MSG_STATUS) {
messageStatus = msgprops[ePR_MSG_STATUS].Value.ul;
}
SPropValue rgprops[1] = {0};
ULONG cProps = 0;
rgprops[cProps].ulPropTag = PR_MSG_STATUS;
if (flagToUpdate == 1) {
messageStatus = messageStatus ^ MSGSTATUS_REMOTE_DOWNLOAD;
}
//if (flagToUpdate == 2) {
// messageStatus = messageStatus ^ MSGSTATUS_REMOTE_DOWNLOAD_ATTACH; //
//}
rgprops[cProps].Value.ul = messageStatus;
++cProps;
hr = globalpmsg->SetProps(cProps, rgprops, NULL);
FuncExit:
if (globalpmsg) {
globalpmsg->Release();
globalpmsg = NULL;
}
if (globalpSession) {
globalpSession->Release();
globalpSession = NULL;
}
return NULL;
}
STDMETHODIMP_(ULONG) CAdviseSink::OnNotify (ULONG cNotify, LPNOTIFICATION lpNotifications) {
HRESULT hRes = S_OK;
int flagUpdate = 0;
try {
for (ULONG i=0 ; i<cNotify ; i++)
{
hRes = S_OK;
if (fnevObjectModified == lpNotifications[i].ulEventType) {
bool status = false;
// understood the status is changed. TAKE CARE OF the lpPropTagArray[0].cValues
for (unsigned int k = 0; k < lpNotifications[i].info.obj.lpPropTagArray[0].cValues; k++) {
if (lpNotifications[i].info.obj.lpPropTagArray[0].aulPropTag[0] == PR_MSG_STATUS) {
status = true;
}
}
if (status) {
//MessageBox (NULL, TEXT("Please wait: downloading message in progress. Click OK to stop"),
// TEXT("Funambol alert"),
// MB_SETFOREGROUND | MB_ICONINFORMATION | MB_OK);
SBinary sbEntry;
sbEntry.cb = lpNotifications[i].info.statobj.cbEntryID;
sbEntry.lpb = (LPBYTE)lpNotifications[i].info.statobj.lpEntryID;
/*
g_sbEntry.cb = lpNotifications[i].info.statobj.cbEntryID;
g_sbEntry.lpb = (LPBYTE)lpNotifications[i].info.statobj.lpEntryID;
if (isMarkedToDownload(g_sbEntry)) {
*/
if ((flagUpdate = isMarkedToDownload(sbEntry)) > 0) {
// it returns something like /AAAAAG8TAAECAAAAAQAAA==
wchar_t* s = convertIdToWideChar(sbEntry);
wchar_t command[255];
wsprintf(command, TEXT("inclusive mail,%s"), s);
//unsigned long pid = startcmd(SYNCAPP, command);
int pid = startProgram(SYNCAPP, command); // start sync process
if (pid) {
if (flagUpdate == 1)
updateFlagMail(sbEntry, flagUpdate);
/*
HWND wnd = GetForegroundWindow();
SetForegroundWindow(wnd);
int ret = MessageBox (NULL, TEXT("Please wait: downloading message in progress. Click OK to stop"),
TEXT("Funambol alert"),
MB_SETFOREGROUND | MB_ICONINFORMATION | MB_OK);
if (ret == IDOK) {
stopSync();
updateFlagMail(sbEntry);
}
CloseHandle(wnd);
*/
}
//if (pid) {
// SetStatusTextOut(IDS_STRING_SYNC_IN_PROGRESS);
//}
/*
if (pid) {
wnd = GetForegroundWindow();
//if(hMainWindow == NULL)
::SendMessage(hMainWindow, WM_CLOSE, NULL, NULL);
::SendMessage(hwndMarshaller, WM_CLOSE, NULL, NULL);
createBubble(NULL);
//if(hwndMarshaller == NULL)
createMarshaller(NULL);
ShowWindow(hMainWindow, SW_HIDE);
ShowWindow(hwndMarshaller, SW_HIDE);
menubarVisible = FALSE;
ZeroMemory(&dlgCommandBar, sizeof(SHMENUBARINFO));
dlgCommandBar.cbSize = sizeof(SHMENUBARINFO);
dlgCommandBar.hwndParent = hMainWindow; // parent window
dlgCommandBar.dwFlags = SHCMBF_HMENU;
dlgCommandBar.nToolBarId = IDR_MENU_STOP;
dlgCommandBar.hInstRes = GetModuleHandle(TEXT("syncmltransport.dll"));
dlgCommandBar.nBmpId = 0;
dlgCommandBar.cBmpImages = 0;
if(!SHCreateMenuBar(&dlgCommandBar)){
return FALSE;
}
else
{
SetForegroundWindow(hMainWindow);
SetForegroundWindow(dlgCommandBar.hwndMB);
//SetCursor(LoadCursor(NULL, IDC_WAIT));
menubarVisible = TRUE;
};
SetTimer(hMainWindow, 1, TIMER_DELAY, NULL);
//int ret = MessageBox (wnd, TEXT("Please wait: downloading message in progress. Click OK to stop"),
// TEXT("Funambol alert"),
// MB_APPLMODAL | MB_SETFOREGROUND | MB_ICONINFORMATION | MB_OK);
//
//if (ret == IDOK) {
// stopSync();
// updateFlagMail(g_sbEntry);
//
//}
}
*/
if (s) {delete [] s;}
}
}
}
if (fnevNewMail == lpNotifications[i].ulEventType) {}
if (fnevObjectDeleted == lpNotifications[i].ulEventType) {}
if (fnevObjectCopied == lpNotifications[i].ulEventType){}
if (fnevObjectMoved == lpNotifications[i].ulEventType){}
if (fnevObjectCreated == lpNotifications[i].ulEventType){}
else if (fnevTableModified == lpNotifications[i].ulEventType) {
switch(lpNotifications[i].info.tab.ulTableEvent)
{
case(TABLE_ERROR):
case(TABLE_CHANGED):
case(TABLE_RELOAD):
LOG.debug("TABLE_RELOAD MAIL advise");
break;
case(TABLE_ROW_ADDED):
LOG.debug("TABLE_ROW_ADDED MAIL advise");
break;
case(TABLE_ROW_DELETED):
LOG.debug("TABLE_ROW_DELETED MAIL advise");
break;
case(TABLE_ROW_MODIFIED):
LOG.debug("TABLE_ROW_MODIFIED MAIL advise");
break;
}
}
}
if (globalpmsg) {
globalpmsg->Release();
globalpmsg = NULL;
}
if (globalpSession) {
globalpSession->Release();
globalpSession = NULL;
}
}
catch(...) {
LOG.error("Advisesink error");
}
return 0;
}
/*
// handling messages for window holding the menubar
long CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg) {
case WM_DESTROY:
case WM_CLOSE:
case WM_QUIT:
//PostQuitMessage(0);
return 0;
case WM_COMMAND:
switch(LOWORD(wParam)) {
case 6:
case ID_SYNC_STOP:
menubarVisible = FALSE;
KillTimer(hMainWindow,1);
stopSync();
updateFlagMail(g_sbEntry);
//SetCursor(LoadCursor(NULL, IDC_ARROW));
//::EnableWindow(wnd, TRUE);
ShowWindow(hMainWindow, SW_HIDE);
::SendMessage(dlgCommandBar.hwndMB, WM_CLOSE, NULL, NULL);
::SendMessage(hMainWindow, WM_CLOSE, NULL, NULL);
//SetForegroundWindow(wnd);
//::SetFocus(wnd);
::SendMessage(wnd, WM_PAINT, NULL, NULL);
::SendMessage(wnd, WM_ACTIVATE, NULL, WA_ACTIVE);
//hMainWindow = NULL;
break;
}; // end wm_command
case WM_TIMER:
if(menubarVisible){
if( (GetForegroundWindow() == wnd) && (dlgCommandBar.hwndMB != NULL)){
SetForegroundWindow(hMainWindow);
SetForegroundWindow(dlgCommandBar.hwndMB);
};
}
else{
//SetForegroundWindow(wnd);
//SetFocus(wnd);
::SendMessage(wnd, WM_PAINT, NULL, NULL);
::SendMessage(wnd, WM_ACTIVATE, NULL, WA_ACTIVE);
}
break;
}
return DefWindowProc(hWnd,msg,wParam,lParam);
}
// handling messages from startsync
long CALLBACK WndProcMarshaller(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
int ret = 0;
switch(msg) {
case WM_DESTROY:
case WM_CLOSE:
case WM_QUIT:
//PostQuitMessage(0);
return 0;
case WM_COMMAND:
switch(LOWORD(wParam)) {
// sync end msg received from startsync
case 6:
menubarVisible = FALSE;
KillTimer(hMainWindow,1);
ShowWindow(hMainWindow, SW_HIDE);
updateFlagMail(g_sbEntry);
//SetCursor(LoadCursor(NULL, IDC_ARROW));
//::EnableWindow(wnd, TRUE);
::SendMessage(dlgCommandBar.hwndMB, WM_CLOSE, NULL, NULL);
::SendMessage(hMainWindow, WM_CLOSE, NULL, NULL);
SetForegroundWindow(wnd);
::SetFocus(wnd);
::SendMessage(wnd, WM_PAINT, NULL, NULL);
//hMainWindow = NULL;
break;
};// end wm_command
case WM_TIMER:
break;
}
return DefWindowProc(hWnd,msg,wParam,lParam);
}
*/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?