From 3b247d07d6bae82efdc5d0f61213b8605345cb6c Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 12 Feb 2014 15:27:33 +0000 Subject: fixes for the MCONTACTs, stored in the database git-svn-id: http://svn.miranda-ng.org/main/trunk@8111 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/YAMN/src/browser/badconnect.cpp | 127 +++++++++++++------------------ plugins/YAMN/src/proto/pop3/pop3comm.cpp | 6 +- plugins/YAMN/src/proto/pop3/pop3opt.cpp | 2 +- plugins/YAMN/src/services.cpp | 12 +-- 4 files changed, 65 insertions(+), 82 deletions(-) (limited to 'plugins/YAMN') diff --git a/plugins/YAMN/src/browser/badconnect.cpp b/plugins/YAMN/src/browser/badconnect.cpp index 3c91453bab..f113392917 100644 --- a/plugins/YAMN/src/browser/badconnect.cpp +++ b/plugins/YAMN/src/browser/badconnect.cpp @@ -14,76 +14,62 @@ LRESULT CALLBACK BadConnectPopupProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam) { DWORD PluginParam; - switch(msg) - { - case WM_COMMAND: - if ((HIWORD(wParam)==STN_CLICKED) && (CallService(MS_POPUP_GETPLUGINDATA,(WPARAM)hWnd,(LPARAM)&PluginParam))) //if clicked and it's new mail popup window - { - PROCESS_INFORMATION pi; - STARTUPINFOW si; - HACCOUNT ActualAccount; - - ZeroMemory(&si,sizeof(si)); - si.cb=sizeof(si); - ActualAccount=(HACCOUNT)CallService(MS_POPUP_GETCONTACT,(WPARAM)hWnd,0); + switch(msg) { + case WM_COMMAND: + // if clicked and it's new mail popup window + if ((HIWORD(wParam)==STN_CLICKED) && (CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd, (LPARAM)&PluginParam))) { + PROCESS_INFORMATION pi; + STARTUPINFOW si; + ZeroMemory(&si,sizeof(si)); + si.cb=sizeof(si); + HACCOUNT ActualAccount = (HACCOUNT)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd, 0); #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"PopupProc:LEFTCLICK:ActualAccountSO-read wait\n"); + DebugLog(SynchroFile,"PopupProc:LEFTCLICK:ActualAccountSO-read wait\n"); #endif - if (WAIT_OBJECT_0==WaitToReadFcn(ActualAccount->AccountAccessSO)) - { + if (WAIT_OBJECT_0==WaitToReadFcn(ActualAccount->AccountAccessSO)) { #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"PopupProc:LEFTCLICK:ActualAccountSO-read enter\n"); + DebugLog(SynchroFile,"PopupProc:LEFTCLICK:ActualAccountSO-read enter\n"); #endif - if (ActualAccount->BadConnectN.App != NULL) - { - WCHAR *Command; + if (ActualAccount->BadConnectN.App != NULL) { + WCHAR *Command; + if (ActualAccount->BadConnectN.AppParam != NULL) + Command = new WCHAR[wcslen(ActualAccount->BadConnectN.App)+wcslen(ActualAccount->BadConnectN.AppParam)+6]; + else + Command = new WCHAR[wcslen(ActualAccount->BadConnectN.App)+6]; + + if (Command != NULL) { + lstrcpyW(Command,L"\""); + lstrcatW(Command,ActualAccount->BadConnectN.App); + lstrcatW(Command,L"\" "); if (ActualAccount->BadConnectN.AppParam != NULL) - Command=new WCHAR[wcslen(ActualAccount->BadConnectN.App)+wcslen(ActualAccount->BadConnectN.AppParam)+6]; - else - Command=new WCHAR[wcslen(ActualAccount->BadConnectN.App)+6]; - - if (Command != NULL) - { - lstrcpyW(Command,L"\""); - lstrcatW(Command,ActualAccount->BadConnectN.App); - lstrcatW(Command,L"\" "); - if (ActualAccount->BadConnectN.AppParam != NULL) - lstrcatW(Command,ActualAccount->BadConnectN.AppParam); - CreateProcessW(NULL,Command,NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,&si,&pi); - delete[] Command; - } + lstrcatW(Command,ActualAccount->BadConnectN.AppParam); + CreateProcessW(NULL,Command,NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,&si,&pi); + delete[] Command; } -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"PopupProc:LEFTCLICK:ActualAccountSO-read done\n"); -#endif - ReadDoneFcn(ActualAccount->AccountAccessSO); } #ifdef DEBUG_SYNCHRO - else - DebugLog(SynchroFile,"PopupProc:LEFTCLICK:ActualAccountSO-read enter failed\n"); + DebugLog(SynchroFile,"PopupProc:LEFTCLICK:ActualAccountSO-read done\n"); #endif - SendMessage(hWnd,UM_DESTROYPOPUP,0,0); + ReadDoneFcn(ActualAccount->AccountAccessSO); } - break; - case UM_FREEPLUGINDATA: - //Here we'd free our own data, if we had it. - return FALSE; - case UM_INITPOPUP: - //This is the equivalent to WM_INITDIALOG you'd get if you were the maker of dialog popups. - break; - case WM_CONTEXTMENU: +#ifdef DEBUG_SYNCHRO + else + DebugLog(SynchroFile,"PopupProc:LEFTCLICK:ActualAccountSO-read enter failed\n"); +#endif SendMessage(hWnd,UM_DESTROYPOPUP,0,0); - break; - case WM_NOTIFY: -/* switch(((LPNMHDR)lParam)->code) - { - case NM_CLICK: - { - } - } - break; -*/ default: - break; + } + break; + + case UM_FREEPLUGINDATA: + //Here we'd free our own data, if we had it. + return FALSE; + + case UM_INITPOPUP: + //This is the equivalent to WM_INITDIALOG you'd get if you were the maker of dialog popups. + break; + case WM_CONTEXTMENU: + SendMessage(hWnd,UM_DESTROYPOPUP,0,0); + break; } return DefWindowProc(hWnd,msg,wParam,lParam); } @@ -125,22 +111,19 @@ INT_PTR CALLBACK DlgProcYAMNBadConnection(HWND hDlg,UINT msg,WPARAM wParam,LPARA ShowMsg=ActualAccount->BadConnectN.Flags & YAMN_ACC_MSG; ShowIco=ActualAccount->BadConnectN.Flags & YAMN_ACC_ICO; - if (ShowPopup) - { - BadConnectPopup.lchContact=(MCONTACT)ActualAccount; - BadConnectPopup.lchIcon=g_LoadIconEx(3); - BadConnectPopup.colorBack=ActualAccount->BadConnectN.Flags & YAMN_ACC_POPC ? ActualAccount->BadConnectN.PopupB : GetSysColor(COLOR_BTNFACE); - BadConnectPopup.colorText=ActualAccount->BadConnectN.Flags & YAMN_ACC_POPC ? ActualAccount->BadConnectN.PopupT : GetSysColor(COLOR_WINDOWTEXT); - BadConnectPopup.iSeconds=ActualAccount->BadConnectN.PopupTime; + if (ShowPopup) { + BadConnectPopup.lchIcon = g_LoadIconEx(3); + BadConnectPopup.colorBack = ActualAccount->BadConnectN.Flags & YAMN_ACC_POPC ? ActualAccount->BadConnectN.PopupB : GetSysColor(COLOR_BTNFACE); + BadConnectPopup.colorText = ActualAccount->BadConnectN.Flags & YAMN_ACC_POPC ? ActualAccount->BadConnectN.PopupT : GetSysColor(COLOR_WINDOWTEXT); + BadConnectPopup.iSeconds = ActualAccount->BadConnectN.PopupTime; - BadConnectPopup.PluginWindowProc=BadConnectPopupProc; - BadConnectPopup.PluginData=0; //it's bad connect popup - lstrcpyn(BadConnectPopup.lptzContactName,_A2T(ActualAccount->Name),SIZEOF(BadConnectPopup.lptzContactName)); + BadConnectPopup.PluginWindowProc = BadConnectPopupProc; + BadConnectPopup.PluginData = ActualAccount; + lstrcpyn(BadConnectPopup.lptzContactName, _A2T(ActualAccount->Name), SIZEOF(BadConnectPopup.lptzContactName)); } - if (ActualAccount->Plugin->Fcn != NULL && ActualAccount->Plugin->Fcn->GetErrorStringWFcnPtr != NULL) - { - Message1W=ActualAccount->Plugin->Fcn->GetErrorStringWFcnPtr(ErrorCode); + if (ActualAccount->Plugin->Fcn != NULL && ActualAccount->Plugin->Fcn->GetErrorStringWFcnPtr != NULL) { + Message1W = ActualAccount->Plugin->Fcn->GetErrorStringWFcnPtr(ErrorCode); SetDlgItemText(hDlg,IDC_STATICMSG,Message1W); lstrcpyn(BadConnectPopup.lptzText,Message1W,sizeof(BadConnectPopup.lptzText)); if (ShowPopup) diff --git a/plugins/YAMN/src/proto/pop3/pop3comm.cpp b/plugins/YAMN/src/proto/pop3/pop3comm.cpp index 16de87d686..b05e3ad1ff 100644 --- a/plugins/YAMN/src/proto/pop3/pop3comm.cpp +++ b/plugins/YAMN/src/proto/pop3/pop3comm.cpp @@ -292,10 +292,10 @@ int RegisterPOP3Plugin(WPARAM,LPARAM) } } - if (Finder->hContact == NULL && (Finder->Flags & YAMN_ACC_ENA) && (Finder->NewMailN.Flags & YAMN_ACC_CONT)) { + if (!Finder->hContact && (Finder->Flags & YAMN_ACC_ENA) && (Finder->NewMailN.Flags & YAMN_ACC_CONT)) { //No account contact found, have to create one - Finder->hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0); - CallService(MS_PROTO_ADDTOCONTACT,(WPARAM)Finder->hContact,(LPARAM)YAMN_DBMODULE); + Finder->hContact = CallService(MS_DB_CONTACT_ADD, 0, 0); + CallService(MS_PROTO_ADDTOCONTACT, Finder->hContact, (LPARAM)YAMN_DBMODULE); db_set_s(Finder->hContact,YAMN_DBMODULE,"Id",Finder->Name); db_set_s(Finder->hContact,YAMN_DBMODULE,"Nick",Finder->Name); db_set_s(Finder->hContact,"Protocol","p",YAMN_DBMODULE); diff --git a/plugins/YAMN/src/proto/pop3/pop3opt.cpp b/plugins/YAMN/src/proto/pop3/pop3opt.cpp index b1e330b882..4d50672604 100644 --- a/plugins/YAMN/src/proto/pop3/pop3opt.cpp +++ b/plugins/YAMN/src/proto/pop3/pop3opt.cpp @@ -904,7 +904,7 @@ INT_PTR CALLBACK DlgProcPOP3AccOpt(HWND hDlg,UINT msg,WPARAM wParam,LPARAM lPara DlgSetItemTextT(hDlg, IDC_STTIMELEFT, TranslateT("Please wait while no account is in use.")); if (ActualAccount->hContact != NULL) - CallService(MS_DB_CONTACT_DELETE,(WPARAM)(HANDLE) ActualAccount->hContact, 0); + CallService(MS_DB_CONTACT_DELETE, ActualAccount->hContact, 0); CallService(MS_YAMN_DELETEACCOUNT,(WPARAM)POP3Plugin,(LPARAM)ActualAccount); diff --git a/plugins/YAMN/src/services.cpp b/plugins/YAMN/src/services.cpp index f0b7fa348f..399424fd0f 100644 --- a/plugins/YAMN/src/services.cpp +++ b/plugins/YAMN/src/services.cpp @@ -166,14 +166,14 @@ static INT_PTR AccountMailCheck(WPARAM wParam, LPARAM lParam) return 0; } -static INT_PTR ContactMailCheck(WPARAM wParam, LPARAM lParam) +static INT_PTR ContactMailCheck(WPARAM hContact, LPARAM lParam) { - char *szProto = GetContactProto(wParam); + char *szProto = GetContactProto(hContact); if ( lstrcmpA(szProto, YAMN_DBMODULE)) return 0; DBVARIANT dbv; - if ( db_get((MCONTACT) wParam, YAMN_DBMODULE, "Id", &dbv)) + if ( db_get(hContact, YAMN_DBMODULE, "Id", &dbv)) return 0; HACCOUNT ActualAccount = (HACCOUNT) CallService(MS_YAMN_FINDACCOUNTBYNAME, (WPARAM)POP3Plugin, (LPARAM)dbv.pszVal); @@ -235,7 +235,7 @@ void MainMenuAccountClicked(WPARAM wParam, LPARAM lParam) if ( db_get(wParam, YAMN_DBMODULE, "Id", &dbv)) return; - HACCOUNT ActualAccount = (HACCOUNT) CallService(MS_YAMN_FINDACCOUNTBYNAME, (WPARAM)POP3Plugin, (LPARAM)dbv.pszVal); + HACCOUNT ActualAccount = (HACCOUNT)CallService(MS_YAMN_FINDACCOUNTBYNAME, (WPARAM)POP3Plugin, (LPARAM)dbv.pszVal); if (ActualAccount != NULL) { #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile, "Service_ContactDoubleclicked:ActualAccountSO-read wait\n"); @@ -244,7 +244,7 @@ void MainMenuAccountClicked(WPARAM wParam, LPARAM lParam) #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile, "Service_ContactDoubleclicked:ActualAccountSO-read enter\n"); #endif - YAMN_MAILBROWSERPARAM Param = {(HANDLE)0, ActualAccount, ActualAccount->NewMailN.Flags, ActualAccount->NoNewMailN.Flags, 0}; + YAMN_MAILBROWSERPARAM Param = { 0, ActualAccount, ActualAccount->NewMailN.Flags, ActualAccount->NoNewMailN.Flags, 0 }; Param.nnflags = Param.nnflags | YAMN_ACC_MSG; //show mails in account even no new mail in account Param.nnflags = Param.nnflags & ~YAMN_ACC_POP; @@ -252,7 +252,7 @@ void MainMenuAccountClicked(WPARAM wParam, LPARAM lParam) Param.nflags = Param.nflags | YAMN_ACC_MSG; //show mails in account even no new mail in account Param.nflags = Param.nflags & ~YAMN_ACC_POP; - RunMailBrowserSvc((WPARAM)&Param, (LPARAM)YAMN_MAILBROWSERVERSION); + RunMailBrowserSvc((WPARAM)&Param, YAMN_MAILBROWSERVERSION); #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile, "Service_ContactDoubleclicked:ActualAccountSO-read done\n"); -- cgit v1.2.3