From d6e05cc3bca53565d9ca65377ab8b0b6190774b3 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 19 Nov 2013 18:01:14 +0000 Subject: preparing to the transparent cyphering: end of MS_DB_CRYPT_ENCODESTRING/MS_DB_CRYPT_DECODESTRING git-svn-id: http://svn.miranda-ng.org/main/trunk@6938 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Exchange/src/MirandaExchange.cpp | 46 +- plugins/Exchange/src/MirandaExchange.h | 2 +- plugins/Exchange/src/dlg_handlers.cpp | 706 ++++++++++++------------------- plugins/Exchange/src/emails.cpp | 212 +++------- 4 files changed, 365 insertions(+), 601 deletions(-) (limited to 'plugins/Exchange/src') diff --git a/plugins/Exchange/src/MirandaExchange.cpp b/plugins/Exchange/src/MirandaExchange.cpp index fcca1f5c1c..9c2dabe005 100644 --- a/plugins/Exchange/src/MirandaExchange.cpp +++ b/plugins/Exchange/src/MirandaExchange.cpp @@ -59,23 +59,23 @@ HRESULT HrMAPIFindDefaultMsgStore( // RETURNS: return code // Get the list of available message stores from MAPI hrT = MAPICALL(lplhSession)->GetMsgStoresTable( 0, &lpTable); - if(!FAILED(hrT)) + if (!FAILED(hrT)) { // Get the row count for the message recipient table hrT = MAPICALL(lpTable)->GetRowCount(0, &cRows); - if(!FAILED(hrT)) + if (!FAILED(hrT)) { // Set the columns to return hrT = MAPICALL(lpTable)->SetColumns((LPSPropTagArray)&rgPropTagArray, 0); - if(!FAILED(hrT)) + if (!FAILED(hrT)) { // Go to the beginning of the recipient table for the envelope hrT = MAPICALL(lpTable)->SeekRow( BOOKMARK_BEGINNING, 0, NULL); - if(!FAILED(hrT)) + if (!FAILED(hrT)) { // Read all the rows of the table hrT = MAPICALL(lpTable)->QueryRows( cRows, 0, &lpRows); - if(SUCCEEDED(hrT) && (lpRows != NULL) && (lpRows->cRows == 0)) + if (SUCCEEDED(hrT) && (lpRows != NULL) && (lpRows->cRows == 0)) { FreeProws(lpRows); lpRows = NULL; @@ -86,18 +86,18 @@ HRESULT HrMAPIFindDefaultMsgStore( // RETURNS: return code } } - if( !FAILED(hrT) ) + if ( !FAILED(hrT) ) { bool bGetOut = false; for(i = 0; (i < cRows) && (!bGetOut); i++) { - if(lpRows->aRow[i].lpProps[0].Value.b == TRUE) + if (lpRows->aRow[i].lpProps[0].Value.b == TRUE) { cbeid = lpRows->aRow[i].lpProps[1].Value.bin.cb; sc = MAPIAllocateBuffer(cbeid, (void **)&lpeid); - if(FAILED(sc)) + if (FAILED(sc)) { cbeid = 0; lpeid = NULL; @@ -113,7 +113,7 @@ HRESULT HrMAPIFindDefaultMsgStore( // RETURNS: return code } } - if(lpRows != NULL) + if (lpRows != NULL) { FreeProws(lpRows); } @@ -228,7 +228,7 @@ CMirandaExchange::~CMirandaExchange() m_lpMDB = NULL; } - if( NULL!= m_lpMAPISession ) + if ( NULL!= m_lpMAPISession ) { m_lpMAPISession->Logoff(NULL,NULL,NULL); UlRelease(m_lpMAPISession ); @@ -448,12 +448,12 @@ HRESULT CMirandaExchange::InitializeAndLogin( LPCTSTR szUsername, LPCTSTR szPass LPMDB lpMDB = NULL; MAPIINIT_0 mapiInit = { MAPI_INIT_VERSION , MAPI_MULTITHREAD_NOTIFICATIONS }; - if( !m_bNoInitAgain) { + if ( !m_bNoInitAgain) { m_bNoInitAgain = true; hr = MAPIInitialize( &mapiInit) ; } - if( SUCCEEDED(hr)) { + if ( SUCCEEDED(hr)) { TCHAR szPIDandName[128]; TCHAR szPID[20]; @@ -694,7 +694,7 @@ HRESULT CMirandaExchange::LogOFF() m_lpMDB = NULL; } - if( NULL!= m_lpMAPISession ) + if ( NULL!= m_lpMAPISession ) { m_lpMAPISession->Logoff( NULL, NULL, NULL ); m_lpMAPISession->Release(); @@ -788,7 +788,7 @@ HRESULT CMirandaExchange::CheckInFolder( LPMAPIFOLDER lpFolder ) CMAPIInterface lpMessageTable; hr = lpFolder->GetContentsTable( 0, &lpMessageTable ); - if( HR_FAILED( hr ) ) + if ( HR_FAILED( hr ) ) { return -1; } @@ -808,7 +808,7 @@ HRESULT CMirandaExchange::CheckInFolder( LPMAPIFOLDER lpFolder ) ////////////////////////////////////////////////////////////////////////// - if( HR_FAILED( hr ) ) + if ( HR_FAILED( hr ) ) { return -1; } @@ -823,21 +823,21 @@ HRESULT CMirandaExchange::CheckInFolder( LPMAPIFOLDER lpFolder ) if ( !(lpRowsR->aRow[ i ].lpProps[ 1 ].Value.l & MSGFLAG_READ) ) { - if( !FAILED(lpRowsR->aRow[i].lpProps[2].Value.err) ) + if ( !FAILED(lpRowsR->aRow[i].lpProps[2].Value.err) ) { szSenderName = lpRowsR->aRow[i].lpProps[2].Value.lpszW; } if ( NULL == szSenderName) { - if( !FAILED(lpRowsR->aRow[i].lpProps[3].Value.err)) + if ( !FAILED(lpRowsR->aRow[i].lpProps[3].Value.err)) { szSenderName = lpRowsR->aRow[i].lpProps[3].Value.lpszW; } } - if( !FAILED(lpRowsR->aRow[i].lpProps[4].Value.err) ) + if ( !FAILED(lpRowsR->aRow[i].lpProps[4].Value.err) ) { szSubject = lpRowsR->aRow[i].lpProps[4].Value.lpszW; } @@ -887,7 +887,7 @@ HRESULT CMirandaExchange::CheckInFolder( LPMAPIFOLDER lpFolder ) lpRowProp = lpRow->aRow[i].lpProps; CMAPIInterface lpSubFolder = NULL; hr = CallOpenEntry( m_lpMDB, NULL, NULL, NULL, lpRowProp[IENTRYID].Value.bin.cb, (LPENTRYID)lpRowProp[IENTRYID].Value.bin.lpb, MAPI_BEST_ACCESS, NULL, (LPUNKNOWN*)&lpSubFolder ); - if( !FAILED(hr) ) + if ( !FAILED(hr) ) { hr = CheckInFolder( lpSubFolder ); //if (FAILED(hr) ){//Log("failed checkinfolder for %s\n",lpRowProp[IDISPNAME].Value.lpszA );} @@ -917,7 +917,7 @@ HRESULT CMirandaExchange::OpenTheMessage( LPTSTR szEntryID ) DWORD dwLength = 512 ; DWORD dwType = REG_SZ; - if( RegOpenKeyEx(HKEY_CLASSES_ROOT, + if ( RegOpenKeyEx(HKEY_CLASSES_ROOT, _T("mailto\\shell\\open\\command"), 0, KEY_ALL_ACCESS | KEY_EXECUTE | KEY_QUERY_VALUE , @@ -927,7 +927,7 @@ HRESULT CMirandaExchange::OpenTheMessage( LPTSTR szEntryID ) LONG lResult = RegQueryValueEx( hTheKey, NULL, NULL, (LPDWORD)&dwType, (LPBYTE)szRegValue, &dwLength); RegCloseKey( hTheKey ); - if( lResult != ERROR_SUCCESS ) + if ( lResult != ERROR_SUCCESS ) { hRes = E_FAIL; } @@ -936,7 +936,7 @@ HRESULT CMirandaExchange::OpenTheMessage( LPTSTR szEntryID ) TCHAR* szTheEnd = _tcsstr( szRegValue,_T(".EXE") ); - if( NULL != szTheEnd ) + if ( NULL != szTheEnd ) { szRegValue[ _tcslen(szRegValue) - _tcslen(szTheEnd) +5 ] = _T('\0'); _tcscat( szRegValue, _T(" /recycle") ); @@ -951,7 +951,7 @@ HRESULT CMirandaExchange::OpenTheMessage( LPTSTR szEntryID ) si.dwFlags = STARTF_USESHOWWINDOW; si.wShowWindow = SW_SHOWNORMAL; - if( CreateProcess ( NULL, + if ( CreateProcess ( NULL, szRegValue, NULL, NULL, diff --git a/plugins/Exchange/src/MirandaExchange.h b/plugins/Exchange/src/MirandaExchange.h index 17edac4a92..9644e69fdb 100644 --- a/plugins/Exchange/src/MirandaExchange.h +++ b/plugins/Exchange/src/MirandaExchange.h @@ -175,7 +175,7 @@ public: // DESTRUCTOR logs off of the MAPI session and releases the session handle. ~CMAPISession() { - if( m_ptr) + if ( m_ptr) m_ptr->Logoff( 0L, 0L, 0L); } }; diff --git a/plugins/Exchange/src/dlg_handlers.cpp b/plugins/Exchange/src/dlg_handlers.cpp index 9a8095eba6..631febea78 100644 --- a/plugins/Exchange/src/dlg_handlers.cpp +++ b/plugins/Exchange/src/dlg_handlers.cpp @@ -30,182 +30,117 @@ INT_PTR CALLBACK DlgProcOptions(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara { static int bInitializing; //true when dialog is being created - switch (msg) + switch (msg) { + case WM_INITDIALOG: + TranslateDialogDefault(hWnd); { - case WM_INITDIALOG: - { - TCHAR buffer[4096]; - char apassword[1024]; - long port; - long interval; - int bCheck; - int portCheck; - int retries; - bInitializing = 1; - DBVARIANT dbv = {0}; - - - dbv.type = DBVT_ASCIIZ; - - TranslateDialogDefault(hWnd); - - bCheck = db_get_b(NULL, ModuleName, "Check", 1); - GetStringFromDatabase("Username", _T(""), buffer, sizeof(buffer)); - SetWindowText(GetDlgItem(hWnd, IDC_USER_EDIT), buffer); - GetStringFromDatabase("Password", _T(""), buffer, sizeof(buffer)); - strcpy(apassword,mir_t2a(buffer)); - CallService(MS_DB_CRYPT_DECODESTRING, sizeof(apassword), (LPARAM) apassword); - SetWindowText(GetDlgItem(hWnd, IDC_PASSWORD_EDIT), mir_a2t(apassword)); - GetStringFromDatabase("Server", _T(""), buffer, sizeof(buffer)); - SetWindowText(GetDlgItem(hWnd, IDC_SERVER_EDIT), buffer); - - port = db_get_dw(NULL, ModuleName, "Port", EXCHANGE_PORT); - //_itoa(port, buffer, 10); - //SetWindowText(GetDlgItem(hWnd, IDC_PORT_EDIT), buffer); - SetDlgItemInt(hWnd,IDC_PORT_EDIT,port,FALSE); - - interval = db_get_dw(NULL, ModuleName, "Interval", DEFAULT_INTERVAL); - //_itoa(interval, buffer, 10); - //SetWindowText(GetDlgItem(hWnd, IDC_INTERVAL_EDIT), buffer); - SetDlgItemInt(hWnd,IDC_INTERVAL_EDIT,interval,FALSE); - - CheckDlgButton(hWnd, IDC_RECONNECT, (db_get_b(NULL, ModuleName, "Reconnect", 0)) ? BST_CHECKED : BST_UNCHECKED); - - interval = db_get_dw(NULL, ModuleName, "ReconnectInterval", DEFAULT_RECONNECT_INTERVAL); - //_itoa(interval, buffer, 10); - //SetWindowText(GetDlgItem(hWnd, IDC_RECONNECT_INTERVAL), buffer); - SetDlgItemInt(hWnd,IDC_RECONNECT_INTERVAL,interval,FALSE); - CheckDlgButton(hWnd, IDC_USE_POPUPS, (BOOL) db_get_b(NULL, ModuleName, "UsePopups", 0) ? BST_CHECKED : BST_UNCHECKED); - EnableWindow(GetDlgItem(hWnd, IDC_USE_POPUPS), ServiceExists(MS_POPUP_ADDPOPUP)); //disable the popups checkbox if no popup module is present - - CheckDlgButton(hWnd, IDC_CHECK_EMAILS, (bCheck) ? BST_CHECKED : BST_UNCHECKED); - EnableWindow(GetDlgItem(hWnd, IDC_INTERVAL_EDIT), bCheck); - - portCheck = (BOOL) db_get_b(NULL, ModuleName, "UsePortCheck", 1); - CheckDlgButton(hWnd, IDC_USE_PORTCHECK, (portCheck) ? BST_CHECKED : BST_UNCHECKED); - EnableWindow(GetDlgItem(hWnd, IDC_PORT_EDIT), portCheck); - - //_itoa(db_get_b(NULL, ModuleName, "MaxRetries", MAX_EXCHANGE_CONNECT_RETRIES), buffer, 10); - //SetWindowText(GetDlgItem(hWnd, IDC_MAX_RETRIES), buffer); - retries=db_get_b(NULL, ModuleName, "MaxRetries", MAX_EXCHANGE_CONNECT_RETRIES); - SetDlgItemInt(hWnd,IDC_MAX_RETRIES,retries,FALSE); - - EnableWindow(GetDlgItem(hWnd, IDC_RECONNECT_INTERVAL), IsDlgButtonChecked(hWnd, IDC_RECONNECT)); - - bInitializing = 0; - - return TRUE; - } - - case WM_COMMAND: - { - switch (LOWORD(wParam)) - { - case IDC_USER_EDIT: - case IDC_PASSWORD_EDIT: - case IDC_SERVER_EDIT: - case IDC_PORT_EDIT: - case IDC_INTERVAL_EDIT: - case IDC_RECONNECT_INTERVAL: - case IDC_MAX_RETRIES: - { - if ((!bInitializing) && (HIWORD(wParam) == EN_CHANGE))// || (HIWORD(wParam) == CBN_SELENDOK)) - { - SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); - } - - break; - } - case IDC_USE_POPUPS: - case IDC_CHECK_EMAILS: - case IDC_RECONNECT: - case IDC_USE_PORTCHECK: - { - int portCheck = IsDlgButtonChecked(hWnd, IDC_USE_PORTCHECK); - SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); - - EnableWindow(GetDlgItem(hWnd, IDC_INTERVAL_EDIT), IsDlgButtonChecked(hWnd, IDC_CHECK_EMAILS)); - EnableWindow(GetDlgItem(hWnd, IDC_RECONNECT_INTERVAL), IsDlgButtonChecked(hWnd, IDC_RECONNECT)); - EnableWindow(GetDlgItem(hWnd, IDC_PORT_EDIT), portCheck); - //EnableWindow(GetDlgItem(hWnd, IDC_MAX_RETRIES), portCheck); - - break; - } - } - - break; - } - - case WM_NOTIFY: - { - switch(((LPNMHDR)lParam)->idFrom) - { - case 0: - { - switch (((LPNMHDR)lParam)->code) - { - case PSN_APPLY: - { - TCHAR buffer[4096]; - char apassword[1024]; - long port = 0; - long interval = DEFAULT_INTERVAL; - int bCheck = IsDlgButtonChecked(hWnd, IDC_CHECK_EMAILS); - int retries = MAX_EXCHANGE_CONNECT_RETRIES; - - db_set_b(NULL, ModuleName, "Check", bCheck); - GetWindowText(GetDlgItem(hWnd, IDC_USER_EDIT), buffer, sizeof(buffer)); - db_set_ts(NULL, ModuleName, "Username", buffer); - GetWindowText(GetDlgItem(hWnd, IDC_PASSWORD_EDIT), buffer, sizeof(buffer)); - strcpy(apassword,mir_t2a(buffer)); - - CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(apassword), (LPARAM) apassword); - - db_set_ts(NULL, ModuleName, "Password", mir_a2t(apassword)); - - GetWindowText(GetDlgItem(hWnd, IDC_SERVER_EDIT), buffer, sizeof(buffer)); - db_set_ts(NULL, ModuleName, "Server", buffer); - GetWindowText(GetDlgItem(hWnd, IDC_PORT_EDIT), buffer, sizeof(buffer)); - //port = atoi(buffer); - //db_set_dw(NULL, ModuleName, "Port", port); - db_set_dw(NULL, ModuleName, "Port", GetDlgItemInt(hWnd,IDC_PORT_EDIT,NULL,FALSE)); - - //GetWindowText(GetDlgItem(hWnd, IDC_INTERVAL_EDIT), buffer, sizeof(buffer)); - //interval = atoi(buffer); - interval=GetDlgItemInt(hWnd,IDC_INTERVAL_EDIT,NULL,FALSE); - db_set_dw(NULL, ModuleName, "Interval", interval); - - db_set_b(NULL, ModuleName, "Reconnect", IsDlgButtonChecked(hWnd, IDC_RECONNECT)); - - GetWindowText(GetDlgItem(hWnd, IDC_RECONNECT_INTERVAL), buffer, sizeof(buffer)); - //interval = atoi(buffer); - interval=GetDlgItemInt(hWnd,IDC_RECONNECT_INTERVAL,NULL,FALSE); - db_set_dw(NULL, ModuleName, "ReconnectInterval", interval); - - db_set_b(NULL, ModuleName, "UsePopups", IsDlgButtonChecked(hWnd, IDC_USE_POPUPS)); - db_set_b(NULL, ModuleName, "UsePortCheck", IsDlgButtonChecked(hWnd, IDC_USE_PORTCHECK)); - - //GetWindowText(GetDlgItem(hWnd, IDC_MAX_RETRIES), buffer, sizeof(buffer)); - //retries = atoi(buffer); - retries=GetDlgItemInt(hWnd,IDC_MAX_RETRIES,NULL,FALSE); - db_set_b(NULL, ModuleName, "MaxRetries", retries); - - - exchangeServer.Reconnect(); //login info may be changed - UpdateTimers(); //interval might get changed - - break; - } - } - - break; - } - } - - break; + bInitializing = 1; + DBVARIANT dbv = {0}; + dbv.type = DBVT_ASCIIZ; + + int bCheck = db_get_b(NULL, ModuleName, "Check", 1); + + TCHAR buffer[4096]; + GetStringFromDatabase("Username", _T(""), buffer, SIZEOF(buffer)); + SetWindowText(GetDlgItem(hWnd, IDC_USER_EDIT), buffer); + + GetStringFromDatabase("Password", _T(""), buffer, SIZEOF(buffer)); + SetWindowText(GetDlgItem(hWnd, IDC_PASSWORD_EDIT), buffer); + + GetStringFromDatabase("Server", _T(""), buffer, sizeof(buffer)); + SetWindowText(GetDlgItem(hWnd, IDC_SERVER_EDIT), buffer); + + SetDlgItemInt(hWnd, IDC_PORT_EDIT, db_get_dw(NULL, ModuleName, "Port", EXCHANGE_PORT), FALSE); + + SetDlgItemInt(hWnd, IDC_INTERVAL_EDIT, db_get_dw(NULL, ModuleName, "Interval", DEFAULT_INTERVAL), FALSE); + + CheckDlgButton(hWnd, IDC_RECONNECT, (db_get_b(NULL, ModuleName, "Reconnect", 0)) ? BST_CHECKED : BST_UNCHECKED); + + SetDlgItemInt(hWnd, IDC_RECONNECT_INTERVAL, db_get_dw(NULL, ModuleName, "ReconnectInterval", DEFAULT_RECONNECT_INTERVAL), FALSE); + CheckDlgButton(hWnd, IDC_USE_POPUPS, (BOOL) db_get_b(NULL, ModuleName, "UsePopups", 0) ? BST_CHECKED : BST_UNCHECKED); + EnableWindow(GetDlgItem(hWnd, IDC_USE_POPUPS), ServiceExists(MS_POPUP_ADDPOPUP)); //disable the popups checkbox if no popup module is present + + CheckDlgButton(hWnd, IDC_CHECK_EMAILS, (bCheck) ? BST_CHECKED : BST_UNCHECKED); + EnableWindow(GetDlgItem(hWnd, IDC_INTERVAL_EDIT), bCheck); + + int portCheck = db_get_b(NULL, ModuleName, "UsePortCheck", 1); + CheckDlgButton(hWnd, IDC_USE_PORTCHECK, (portCheck) ? BST_CHECKED : BST_UNCHECKED); + EnableWindow(GetDlgItem(hWnd, IDC_PORT_EDIT), portCheck); + + int retries = db_get_b(NULL, ModuleName, "MaxRetries", MAX_EXCHANGE_CONNECT_RETRIES); + SetDlgItemInt(hWnd,IDC_MAX_RETRIES,retries,FALSE); + + EnableWindow(GetDlgItem(hWnd, IDC_RECONNECT_INTERVAL), IsDlgButtonChecked(hWnd, IDC_RECONNECT)); + + bInitializing = 0; + } + return TRUE; + + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDC_USER_EDIT: + case IDC_PASSWORD_EDIT: + case IDC_SERVER_EDIT: + case IDC_PORT_EDIT: + case IDC_INTERVAL_EDIT: + case IDC_RECONNECT_INTERVAL: + case IDC_MAX_RETRIES: + if ((!bInitializing) && (HIWORD(wParam) == EN_CHANGE))// || (HIWORD(wParam) == CBN_SELENDOK)) + SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); + break; + + case IDC_USE_POPUPS: + case IDC_CHECK_EMAILS: + case IDC_RECONNECT: + case IDC_USE_PORTCHECK: + int portCheck = IsDlgButtonChecked(hWnd, IDC_USE_PORTCHECK); + SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); + + EnableWindow(GetDlgItem(hWnd, IDC_INTERVAL_EDIT), IsDlgButtonChecked(hWnd, IDC_CHECK_EMAILS)); + EnableWindow(GetDlgItem(hWnd, IDC_RECONNECT_INTERVAL), IsDlgButtonChecked(hWnd, IDC_RECONNECT)); + EnableWindow(GetDlgItem(hWnd, IDC_PORT_EDIT), portCheck); + break; + } + break; + + case WM_NOTIFY: + switch(((LPNMHDR)lParam)->idFrom) { + case 0: + switch (((LPNMHDR)lParam)->code) { + case PSN_APPLY: + db_set_b(NULL, ModuleName, "Check", IsDlgButtonChecked(hWnd, IDC_CHECK_EMAILS)); + + TCHAR buffer[4096]; + GetWindowText(GetDlgItem(hWnd, IDC_USER_EDIT), buffer, SIZEOF(buffer)); + db_set_ts(NULL, ModuleName, "Username", buffer); + + GetWindowText(GetDlgItem(hWnd, IDC_PASSWORD_EDIT), buffer, SIZEOF(buffer)); + db_set_ts(NULL, ModuleName, "Password", buffer); + + GetWindowText(GetDlgItem(hWnd, IDC_SERVER_EDIT), buffer, SIZEOF(buffer)); + db_set_ts(NULL, ModuleName, "Server", buffer); + + GetWindowText(GetDlgItem(hWnd, IDC_PORT_EDIT), buffer, SIZEOF(buffer)); + db_set_dw(NULL, ModuleName, "Port", GetDlgItemInt(hWnd,IDC_PORT_EDIT,NULL,FALSE)); + + db_set_dw(NULL, ModuleName, "Interval", GetDlgItemInt(hWnd,IDC_INTERVAL_EDIT,NULL,FALSE)); + db_set_dw(NULL, ModuleName, "ReconnectInterval", GetDlgItemInt(hWnd,IDC_RECONNECT_INTERVAL,NULL,FALSE)); + + db_set_b(NULL, ModuleName, "Reconnect", IsDlgButtonChecked(hWnd, IDC_RECONNECT)); + + db_set_b(NULL, ModuleName, "UsePopups", IsDlgButtonChecked(hWnd, IDC_USE_POPUPS)); + db_set_b(NULL, ModuleName, "UsePortCheck", IsDlgButtonChecked(hWnd, IDC_USE_PORTCHECK)); + + db_set_b(NULL, ModuleName, "MaxRetries", GetDlgItemInt(hWnd,IDC_MAX_RETRIES,NULL,FALSE)); + + exchangeServer.Reconnect(); //login info may be changed + UpdateTimers(); //interval might get changed } + } + + break; } - + return 0; } @@ -219,276 +154,195 @@ void AddAnchorWindowToDeferList(HDWP &hdWnds, HWND window, RECT *rParent, WINDOW int CALLBACK ListSubclassProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { - switch (msg) - { - case WM_KEYUP: - { - if (wParam == VK_ESCAPE) - { - SendMessage(GetParent(hWnd), WM_CLOSE, 0, 0); - } - - break; - } - - case WM_SYSKEYDOWN: - { - if (wParam == 'X') - { - SendMessage(GetParent(hWnd), WM_CLOSE, 0, 0); - } - - break; - } - - case WM_LBUTTONDBLCLK: - { - int count = ListView_GetItemCount(hWnd); - for (int i = 0; i < count; i++) - { - if (ListView_GetItemState(hWnd, i, LVIS_SELECTED)) - { - TCHAR emailID[4096]; //uhh - ListView_GetItemText(hWnd, i, 2, emailID, sizeof(emailID)); - exchangeServer.OpenMessage(emailID); - } - } - - break; - } + switch (msg) { + case WM_KEYUP: + if (wParam == VK_ESCAPE) + SendMessage(GetParent(hWnd), WM_CLOSE, 0, 0); + + break; + + case WM_SYSKEYDOWN: + if (wParam == 'X') + SendMessage(GetParent(hWnd), WM_CLOSE, 0, 0); + + break; + + case WM_LBUTTONDBLCLK: + int count = ListView_GetItemCount(hWnd); + for (int i = 0; i < count; i++) { + if (ListView_GetItemState(hWnd, i, LVIS_SELECTED)) { + TCHAR emailID[4096]; //uhh + ListView_GetItemText(hWnd, i, 2, emailID, sizeof(emailID)); + exchangeServer.OpenMessage(emailID); + } } - + break; + } + return CallWindowProc(OldListProc, hWnd, msg, wParam, lParam); } INT_PTR CALLBACK DlgProcEmails(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { - switch (msg) + switch (msg) { + case WM_INITDIALOG: + TranslateDialogDefault(hWnd); { - case WM_INITDIALOG: - { - TranslateDialogDefault(hWnd); - - SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM) hiMailIcon); - - LVCOLUMN col = {0}; - HWND hList = GetDlgItem(hWnd, IDC_EMAILS_LIST); - OldListProc = (WNDPROC) SetWindowLong(hList, GWLP_WNDPROC, (LONG) ListSubclassProc); - ListView_SetExtendedListViewStyle(hList, LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES); - col.mask = LVCF_TEXT | LVCF_WIDTH; - col.cx = 100; - col.pszText = TranslateT("Entry ID"); - col.cchTextMax = _tcslen(col.pszText) + 1; - ListView_InsertColumn(hList, 0, &col); - col.pszText = TranslateT("Subject"); - col.cx = 300; - col.cchTextMax = _tcslen(col.pszText) + 1; - ListView_InsertColumn(hList, 0, &col); - col.cx = 200; - col.iSubItem = 1; - col.pszText = TranslateT("Sender"); - col.cchTextMax = _tcslen(col.pszText) + 1; - ListView_InsertColumn(hList, 0, &col); - - return TRUE; - } - - case WM_DESTROY: - { - hEmailsDlg = NULL; - - break; - } - - case WM_CLOSE: - { - //ShowWindow(hWnd, SW_HIDE); - DestroyWindow(hWnd); //close the window - no need to keep it in memory - //SavePosition(hWnd); - - break; - } - - case EXM_UPDATE_EMAILS: - { - HWND hList = GetDlgItem(hWnd, IDC_EMAILS_LIST); - ListView_DeleteAllItems(hList); - int count = GetWindowLong(hWnd, GWLP_USERDATA); + SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM)hiMailIcon); + + LVCOLUMN col = {0}; + HWND hList = GetDlgItem(hWnd, IDC_EMAILS_LIST); + OldListProc = (WNDPROC) SetWindowLong(hList, GWLP_WNDPROC, (LONG) ListSubclassProc); + ListView_SetExtendedListViewStyle(hList, LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES); + col.mask = LVCF_TEXT | LVCF_WIDTH; + col.cx = 100; + col.pszText = TranslateT("Entry ID"); + col.cchTextMax = (int)_tcslen(col.pszText) + 1; + ListView_InsertColumn(hList, 0, &col); + col.pszText = TranslateT("Subject"); + col.cx = 300; + col.cchTextMax = (int)_tcslen(col.pszText) + 1; + ListView_InsertColumn(hList, 0, &col); + col.cx = 200; + col.iSubItem = 1; + col.pszText = TranslateT("Sender"); + col.cchTextMax = (int)_tcslen(col.pszText) + 1; + ListView_InsertColumn(hList, 0, &col); + } + return TRUE; + + case WM_DESTROY: + hEmailsDlg = NULL; + break; + + case WM_CLOSE: + DestroyWindow(hWnd); //close the window - no need to keep it in memory + break; + + case EXM_UPDATE_EMAILS: + { + HWND hList = GetDlgItem(hWnd, IDC_EMAILS_LIST); + ListView_DeleteAllItems(hList); + int count = GetWindowLong(hWnd, GWLP_USERDATA); + LVITEM item = {0}; + TEmailHeader email = {0}; + email.cbSize = sizeof(TEmailHeader); + TCHAR sender[1024] = _T(""); + TCHAR subject[1024] = _T(""); + //char buffer[4096]; + email.cSender = sizeof(sender); + email.cSubject = sizeof(subject); + email.szSender = sender; + email.szSubject = subject; + item.mask = LVIF_TEXT; + + for (int i = 0; i < count; i++) + { + exchangeServer.GetEmailHeader(i, &email); + item.iItem = i; + item.iSubItem = 0; + item.pszText = email.szSender; + ListView_InsertItem(hList, &item); + ListView_SetItemText(hList, i, 1, email.szSubject); + ListView_SetItemText(hList, i, 2, mir_a2t(email.emailID)); + } + SetFocus(hList); + } + break; + + case WM_SHOWWINDOW: + if (wParam) + SendMessage(hWnd, EXM_UPDATE_EMAILS, 0, 0); + break; + + case WM_KEYUP: + if (wParam == VK_ESCAPE) + SendMessage(hWnd, WM_CLOSE, 0, 0); + break; + + case WM_SYSKEYDOWN: + if (wParam == 'X') + SendMessage(hWnd, WM_CLOSE, 0, 0); + break; + + case WM_WINDOWPOSCHANGING: + { + HDWP hdWnds = BeginDeferWindowPos(3); + RECT rParent; + WINDOWPOS *wndPos = (WINDOWPOS *) lParam; + + if ((!wndPos) || (wndPos->flags & SWP_NOSIZE)) + break; + + GetWindowRect(hWnd, &rParent); + if (wndPos->cx < MIN_EMAILS_WIDTH) + wndPos->cx = MIN_EMAILS_WIDTH; + if (wndPos->cy < MIN_EMAILS_HEIGHT) + wndPos->cy = MIN_EMAILS_HEIGHT; + + AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_EMAILS_LIST), &rParent, wndPos, ANCHOR_ALL); + AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_CLOSE), &rParent, wndPos, ANCHOR_BOTTOM | ANCHOR_RIGHT); + AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_MARK_READ), &rParent, wndPos, ANCHOR_BOTTOM | ANCHOR_LEFT); + + EndDeferWindowPos(hdWnds); + } + break; + + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDC_CLOSE: + SendMessage(hWnd, WM_CLOSE, 0, 0); + break; + + case IDC_MARK_READ: + HWND hList = GetDlgItem(hWnd, IDC_EMAILS_LIST); + int count = ListView_GetItemCount(hList); + for (int i = 0; i < count; i++) { + if (ListView_GetCheckState(hList, i)) { + TCHAR emailID[2048]; //uhh ohh LVITEM item = {0}; - TEmailHeader email = {0}; - email.cbSize = sizeof(TEmailHeader); - TCHAR sender[1024] = _T(""); - TCHAR subject[1024] = _T(""); - //char buffer[4096]; - email.cSender = sizeof(sender); - email.cSubject = sizeof(subject); - email.szSender = sender; - email.szSubject = subject; + item.iItem = i; item.mask = LVIF_TEXT; - - for (int i = 0; i < count; i++) - { - exchangeServer.GetEmailHeader(i, &email); - item.iItem = i; - item.iSubItem = 0; - item.pszText = email.szSender; - ListView_InsertItem(hList, &item); - ListView_SetItemText(hList, i, 1, email.szSubject); - ListView_SetItemText(hList, i, 2, mir_a2t(email.emailID)); - } - SetFocus(hList); - - break; - } - - case WM_SHOWWINDOW: - { - if (wParam) - { - SendMessage(hWnd, EXM_UPDATE_EMAILS, 0, 0); - } - - break; - } - - case WM_KEYUP: - { - if (wParam == VK_ESCAPE) - { - SendMessage(hWnd, WM_CLOSE, 0, 0); - } - - break; + item.iSubItem = 2; + item.cchTextMax = sizeof(emailID); + item.pszText = emailID; + ListView_GetItem(hList, &item); + exchangeServer.MarkEmailAsRead(emailID); } - - case WM_SYSKEYDOWN: - { - if (wParam == 'X') - { - SendMessage(hWnd, WM_CLOSE, 0, 0); - } - - break; - } - - case WM_WINDOWPOSCHANGING: - { - HDWP hdWnds = BeginDeferWindowPos(3); - RECT rParent; - WINDOWPOS *wndPos = (WINDOWPOS *) lParam; - - if ((!wndPos) || (wndPos->flags & SWP_NOSIZE)) - { - break; - } - GetWindowRect(hWnd, &rParent); - if (wndPos->cx < MIN_EMAILS_WIDTH) - { - wndPos->cx = MIN_EMAILS_WIDTH; - } - if (wndPos->cy < MIN_EMAILS_HEIGHT) - { - wndPos->cy = MIN_EMAILS_HEIGHT; - } - AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_EMAILS_LIST), &rParent, wndPos, ANCHOR_ALL); - AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_CLOSE), &rParent, wndPos, ANCHOR_BOTTOM | ANCHOR_RIGHT); - AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_MARK_READ), &rParent, wndPos, ANCHOR_BOTTOM | ANCHOR_LEFT); - - EndDeferWindowPos(hdWnds); - - break; - } - - case WM_COMMAND: - { - switch (LOWORD(wParam)) - { - case IDC_CLOSE: - { - SendMessage(hWnd, WM_CLOSE, 0, 0); - //HWND hList = GetDlgItem(hWnd, IDC_EMAILS_LIST); - //ListView_SetItemState(hList, -1, LVIS_SELECTED, LVIS_SELECTED); - //SetFocus(hList); - - break; - } - - case IDC_MARK_READ: - { - HWND hList = GetDlgItem(hWnd, IDC_EMAILS_LIST); - int count = ListView_GetItemCount(hList); - for (int i = 0; i < count; i++) - { - if (ListView_GetCheckState(hList, i)) - { - //char sender[1024]; //nooo - TCHAR emailID[2048]; //uhh ohh - LVITEM item = {0}; - item.iItem = i; - item.mask = LVIF_TEXT; - //item.pszText = sender; - //item.cchTextMax = sizeof(sender); - //ListView_GetItem(hList, &item); - - item.iSubItem = 2; - item.cchTextMax = sizeof(emailID); - item.pszText = emailID; - ListView_GetItem(hList, &item); - exchangeServer.MarkEmailAsRead(emailID); - } - } - count = exchangeServer.GetUnreadEmailsCount(); - if (count > 0) - { - SetWindowLong(hWnd, GWLP_USERDATA, count); - SendMessage(hWnd, EXM_UPDATE_EMAILS, 0, 0); - } - else{ - SendMessage(hWnd, WM_CLOSE, 0, 0); - } - - break; - } - } - - break; - } - default: - - break; + } + count = exchangeServer.GetUnreadEmailsCount(); + if (count > 0) + { + SetWindowLong(hWnd, GWLP_USERDATA, count); + SendMessage(hWnd, EXM_UPDATE_EMAILS, 0, 0); + } + else SendMessage(hWnd, WM_CLOSE, 0, 0); } + break; + } + return 0; } LRESULT CALLBACK DlgProcPopup(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { - switch (msg) - { - case WM_COMMAND: - { - switch (HIWORD(wParam)) - { - case STN_CLICKED: - { - //HWND hParent = FindWindow(MIRANDACLASS, NULL); - //CreateDialog(hInstance, MAKEINTRESOURCE(IDD_EMAILS), hParent, DlgProcEmails); - int count = (int) PUGetPluginData(hWnd); - ShowEmailsWindow(count); - PUDeletePopup(hWnd); - - break; - } - } - - break; - } - case WM_CONTEXTMENU: - { - PUDeletePopup(hWnd); - - break; - } + switch (msg) { + case WM_COMMAND: + switch (HIWORD(wParam)) { + case STN_CLICKED: + { + int count = (int) PUGetPluginData(hWnd); + ShowEmailsWindow(count); + PUDeletePopup(hWnd); + break; + } } + break; + + case WM_CONTEXTMENU: + PUDeletePopup(hWnd); + break; + } return DefWindowProc(hWnd, msg, wParam, lParam); } \ No newline at end of file diff --git a/plugins/Exchange/src/emails.cpp b/plugins/Exchange/src/emails.cpp index 39dfa6d86a..25261a4ea2 100644 --- a/plugins/Exchange/src/emails.cpp +++ b/plugins/Exchange/src/emails.cpp @@ -35,60 +35,43 @@ CExchangeServer::~CExchangeServer() int CExchangeServer::Connect(int bForceConnect) { int maxRetries = db_get_b(NULL, ModuleName, "MaxRetries", MAX_EXCHANGE_CONNECT_RETRIES); - if (bForceConnect) - { + if (bForceConnect) { bTryConnect = 1; cConnections = 0; } - if (cConnections >= maxRetries) - { + if (cConnections >= maxRetries) { bTryConnect = 0; cConnections = 0; _popupUtil("Maximum number of retries reached.\nPlugin will stop trying to connect automatically."); } + if (bTryConnect) - { cConnections++; - } - if ((bTryConnect) && !IsServerAvailable()) - { + if ((bTryConnect) && !IsServerAvailable()) { bTryConnect = 0; _popupUtil("Server not available"); } - if ((!IsConnected()) && (bTryConnect)) - { - TCHAR user[1024]; //lovely - TCHAR password[1024]; //i know - char apassword[1024]; - TCHAR server[1024]; - int port; - - GetStringFromDatabase("Username", _T(""), user, _countof(user)); - if (ServiceExists(MS_UTILS_REPLACEVARS)) - { - TCHAR *tmpUser = Utils_ReplaceVarsT(user); - - _tcsncpy(user, tmpUser, _countof(user)); - mir_free(tmpUser); - } - - GetStringFromDatabase("Password", _T(""), password, _countof(password)); - strcpy(apassword,mir_t2a(password)); - CallService(MS_DB_CRYPT_DECODESTRING, sizeof(apassword), (LPARAM) apassword); - _tcsncpy(password,mir_a2t(apassword),_countof(password)); - GetStringFromDatabase("Server", _T(""), server, _countof(server)); - port = db_get_dw(NULL, ModuleName, "Port", EXCHANGE_PORT); - if (_tcslen(server) > 0) //only connect if there's a server to connect to - { - return DoConnect(user, password, server, port); - } - else { - _popupUtil("Server is not configured..."); - } - } + if ( !IsConnected() && bTryConnect) { + TCHAR user[1024]; //lovely + TCHAR password[1024]; //i know + TCHAR server[1024]; + + GetStringFromDatabase("Username", _T(""), user, _countof(user)); + if (ServiceExists(MS_UTILS_REPLACEVARS)) + _tcsncpy_s(user, _countof(user), VARST(user), _TRUNCATE); + + GetStringFromDatabase("Password", _T(""), password, _countof(password)); + GetStringFromDatabase("Server", _T(""), server, _countof(server)); + + int port = db_get_dw(NULL, ModuleName, "Port", EXCHANGE_PORT); + if (_tcslen(server) > 0) //only connect if there's a server to connect to + return DoConnect(user, password, server, port); + + _popupUtil("Server is not configured..."); + } return -1; //0 on success, != 0 otherwise } @@ -151,44 +134,37 @@ void InitSocketAddr(sockaddr_in *addrServer, char *szServer) hp = gethostbyname(szServer); addrServer->sin_family = AF_INET; if (hp == NULL) - { addrServer->sin_addr.s_addr = inet_addr(szServer); - } - else{ + else memcpy(&(addrServer->sin_addr), hp->h_addr, hp->h_length); - } + int port = db_get_dw(NULL, ModuleName, "Port", EXCHANGE_PORT); addrServer->sin_port = htons(port); } int CExchangeServer::IsServerAvailable() { - int check = db_get_b(NULL, ModuleName, "UsePortCheck", 1); - if (check) - { - SOCKET sServer = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - if (sServer == INVALID_SOCKET) - { - return 0; //server is not available - } - TCHAR szServer[1024]; - GetStringFromDatabase("Server", _T(""), szServer, sizeof(szServer)); - sockaddr_in addrServer; - InitSocketAddr(&addrServer, mir_t2a(szServer)); - int res = connect(sServer, (sockaddr *) &addrServer, sizeof(addrServer)); - int bAvailable = 0; - if (!res) - {//if connected then close smtp connection by sending a quit message - bAvailable = 1; - char message[] = "quit\n"; - res = send(sServer, message, strlen(message), 0); - } - res = closesocket(sServer); //close the socket - return bAvailable; - } - else{ - return 1; //if we're not using port check assume the server is available. + if (!db_get_b(NULL, ModuleName, "UsePortCheck", 1)) + return 1; + + SOCKET sServer = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + if (sServer == INVALID_SOCKET) + return 0; //server is not available + + TCHAR szServer[1024]; + GetStringFromDatabase("Server", _T(""), szServer, sizeof(szServer)); + sockaddr_in addrServer; + InitSocketAddr(&addrServer, mir_t2a(szServer)); + int res = connect(sServer, (sockaddr *) &addrServer, sizeof(addrServer)); + int bAvailable = 0; + if (!res) { + // if connected then close smtp connection by sending a quit message + bAvailable = 1; + char message[] = "quit\n"; + send(sServer, message, strlen(message), 0); } + res = closesocket(sServer); //close the socket + return bAvailable; } int CExchangeServer::GetUnreadEmailsCount() @@ -220,42 +196,29 @@ int CExchangeServer::GetUnreadEmailsCount() int CExchangeServer::GetEmailHeader(int iUnreadEmail, TEmailHeader *emailInfo) { if (!IsConnected()) - { - //Connect(); return -1; - } + if (emailInfo->cbSize != sizeof(TEmailHeader)) - { return -1; - } #ifndef NO_EXCHANGE_TEST - if(NULL!=m_HeadersKeeper[iUnreadEmail]) - { + if (NULL != m_HeadersKeeper[iUnreadEmail]) { TCHAR* szSender = m_HeadersKeeper[iUnreadEmail]->m_szSender; TCHAR* szSubject = m_HeadersKeeper[iUnreadEmail]->m_szSubject; - if( NULL == szSender) - { + if (NULL == szSender) szSender = _T(""); - } - if( NULL == szSubject) - { + if (NULL == szSubject) szSubject = _T(""); - } emailInfo->szSender = szSender; emailInfo->szSubject = szSubject; emailInfo->emailID = (NULL!=m_HeadersKeeper[iUnreadEmail]->m_szEntryID)?m_HeadersKeeper[iUnreadEmail]->m_szEntryID:""; } - else { - return -1; - } - - + else return -1; #else emailInfo->szSender = ""; emailInfo->szSubject = ""; @@ -268,9 +231,7 @@ int CExchangeServer::GetEmailHeader(int iUnreadEmail, TEmailHeader *emailInfo) int CExchangeServer::MarkEmailAsRead(TCHAR *emailID) { if (!IsConnected()) - { return -1; - } #ifndef NO_EXCHANGE_TEST MarkAsRead( emailID ); @@ -282,87 +243,50 @@ int CExchangeServer::MarkEmailAsRead(TCHAR *emailID) int CExchangeServer::OpenMessage(TCHAR *emailID) { if (!IsConnected()) - { return -1; - } #ifndef NO_EXCHANGE_TEST OpenTheMessage( emailID ); #endif - return 0; } int CExchangeServer::Check(int bNoEmailsNotify) { - int count = -1; - if (IsConnected()) - { - count = GetUnreadEmailsCount(); - - if (count==-1) - { + if (IsConnected()) { + count = GetUnreadEmailsCount(); + if (count == -1) { Reconnect(); if (IsConnected()) - { count = GetUnreadEmailsCount(); - } - else { + else return -1; - } } - } else { Reconnect(); if (IsConnected()) - { count = GetUnreadEmailsCount(); - } - else { + else return -1; - } if (count==-1) - { return -1; - } } - if( ( (count > 0) || ((bNoEmailsNotify) && (count >= 0)) )&& (count!=-1)) - { + if (((count > 0) || ((bNoEmailsNotify) && (count >= 0))) && (count != -1)) { TCHAR buffer[1024]; if (count != 1) - { mir_sntprintf(buffer,_countof(buffer), TranslateT("You have %d unread emails..."), count); - } - else { + else mir_sntprintf(buffer, _countof(buffer),TranslateT("You have one unread email...")); - } ShowMessage(buffer, count); - /*int i; - TEmailHeader emailInfo = {0}; - char sender[1024]; - char subject[1024]; - emailInfo.cbSize = sizeof(emailInfo); - emailInfo.szSender = sender; - emailInfo.szSubject = subject; - emailInfo.cSender = sizeof(sender); - emailInfo.cSubject = sizeof(subject); - for (i = 0; i < count; i++) - { - GetEmailHeader(i, &emailInfo); - sprintf(buffer, "Unread email #%d:\nSender :%s\nSubject :%s", i + 1, sender, subject); - ShowMessage(buffer); - }*/ } if (count==-1) - { _popupUtil("Cannot connect to Exchange server..."); - } return count; } @@ -371,14 +295,9 @@ int ShowMessage(TCHAR *message, int cUnreadEmails) { int usePopups = ServiceExists(MS_POPUP_ADDPOPUP) ? db_get_b(NULL, ModuleName, "UsePopups", 0) : 0; if (usePopups) - { return ShowPopupMessage(TranslateT("Exchange email"), message, cUnreadEmails); - } - else{ - return ShowMessageBoxMessage(TranslateT("Do you want to see the email headers?"), message, cUnreadEmails); - } - - return 0; + + return ShowMessageBoxMessage(TranslateT("Do you want to see the email headers?"), message, cUnreadEmails); } int ShowPopupMessage(TCHAR *title, TCHAR *message, int cUnreadEmails) @@ -398,30 +317,21 @@ int ShowPopupMessage(TCHAR *title, TCHAR *message, int cUnreadEmails) int ShowMessageBoxMessage(TCHAR *title, TCHAR *message, int cUnreadEmails) { if (MessageBox(0, message, title, MB_YESNO) == IDYES) - { ShowEmailsWindow(cUnreadEmails); - } - return 0; } int ShowEmailsWindow(int cUnreadEmails) { - if (cUnreadEmails > 0) //show window only if there are unread emails - { + if (cUnreadEmails > 0) { //show window only if there are unread emails if (!hEmailsDlg) - { hEmailsDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_EMAILS), NULL, DlgProcEmails); - } SetWindowLong(hEmailsDlg, GWLP_USERDATA, cUnreadEmails); if (IsWindowVisible(hEmailsDlg)) - { SendMessage(hEmailsDlg, EXM_UPDATE_EMAILS, 0, 0); - } - else { + else ShowWindow(hEmailsDlg, SW_SHOW); - } } return 0; -} \ No newline at end of file +} -- cgit v1.2.3