From 78c0815c4118fe24ab78cce2dc48a6232dcd824a Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 2 Jun 2012 20:55:18 +0000 Subject: - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@270 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/SecureIM/commonheaders.cpp | 10 +- plugins/SecureIM/crypt_check.cpp | 78 ++++++------- plugins/SecureIM/crypt_dll.cpp | 20 ++-- plugins/SecureIM/crypt_icons.cpp | 32 +++--- plugins/SecureIM/crypt_lists.cpp | 46 ++++---- plugins/SecureIM/crypt_metacontacts.cpp | 6 +- plugins/SecureIM/crypt_misc.cpp | 16 +-- plugins/SecureIM/crypt_popups.cpp | 4 +- plugins/SecureIM/loadicons.cpp | 2 +- plugins/SecureIM/main.cpp | 14 +-- plugins/SecureIM/mmi.cpp | 8 +- plugins/SecureIM/options.cpp | 156 ++++++++++++------------- plugins/SecureIM/splitmsg.cpp | 14 +-- plugins/SecureIM/svcs_clist.cpp | 42 +++---- plugins/SecureIM/svcs_menu.cpp | 12 +- plugins/SecureIM/svcs_popup.cpp | 4 +- plugins/SecureIM/svcs_proto.cpp | 194 ++++++++++++++++---------------- plugins/SecureIM/svcs_rsa.cpp | 22 ++-- plugins/SecureIM/svcs_srmm.cpp | 6 +- 19 files changed, 343 insertions(+), 343 deletions(-) (limited to 'plugins/SecureIM') diff --git a/plugins/SecureIM/commonheaders.cpp b/plugins/SecureIM/commonheaders.cpp index 11ff4af8e3..1200861828 100644 --- a/plugins/SecureIM/commonheaders.cpp +++ b/plugins/SecureIM/commonheaders.cpp @@ -45,7 +45,7 @@ LPSTR myDBGetString(HANDLE hContact,const char *szModule,const char *szSetting) DBVARIANT dbv; dbv.type = DBVT_ASCIIZ; DBGetContactSetting(hContact,szModule,szSetting,&dbv); - if( dbv.pszVal && (dbv.type==DBVT_ASCIIZ || dbv.type==DBVT_UTF8 || dbv.type==DBVT_WCHAR) ) + if ( dbv.pszVal && (dbv.type==DBVT_ASCIIZ || dbv.type==DBVT_UTF8 || dbv.type==DBVT_WCHAR) ) val = mir_strdup(dbv.pszVal); DBFreeVariant(&dbv); return val; @@ -54,7 +54,7 @@ LPSTR myDBGetString(HANDLE hContact,const char *szModule,const char *szSetting) LPSTR myDBGetStringDecode(HANDLE hContact,const char *szModule,const char *szSetting) { char *val = myDBGetString(hContact,szModule,szSetting); - if(!val) return NULL; + if (!val) return NULL; size_t len = strlen(val)+64; char *buf = (LPSTR)mir_alloc(len); strncpy(buf,val,len); mir_free(val); @@ -172,14 +172,14 @@ int ca2u=0; LPSTR TranslateU( LPCSTR lpText ) { int i; for(i=0;iinspecting; } @@ -25,12 +25,12 @@ BYTE isContactSecured(HANDLE hContact) { if (!clist_cnt) return 0; BYTE r=0; - if( isProtoMetaContacts(hContact) ) + if ( isProtoMetaContacts(hContact) ) hContact = getMostOnline(hContact); // возьмем тот, через который пойдет сообщение for(int j=0;jinspecting ) break; + if ( clist[j].hContact == hContact ) { + if ( !clist[j].proto->inspecting ) break; DBVARIANT dbv; r=clist[j].mode; switch(r) { @@ -39,12 +39,12 @@ BYTE isContactSecured(HANDLE hContact) { break; case MODE_PGP: DBGetContactSetting(hContact,szModuleName,"pgp",&dbv); - if( dbv.type!=0 ) r|=SECURED; + if ( dbv.type!=0 ) r|=SECURED; DBFreeVariant(&dbv); break; case MODE_GPG: DBGetContactSetting(hContact,szModuleName,"gpg",&dbv); - if( dbv.type!=0 ) r|=SECURED; + if ( dbv.type!=0 ) r|=SECURED; DBFreeVariant(&dbv); break; case MODE_RSAAES: @@ -63,12 +63,12 @@ BYTE isContactSecured(HANDLE hContact) { BOOL isClientMiranda(pUinKey ptr, BOOL emptyMirverAsMiranda) { - if( !bMCD ) return true; - if( !ptr->proto->inspecting ) return false; + if ( !bMCD ) return true; + if ( !ptr->proto->inspecting ) return false; BOOL isMiranda = true; LPSTR mirver = myDBGetString(ptr->hContact,ptr->proto->name,"MirVer"); - if( mirver ) { + if ( mirver ) { isMiranda = (emptyMirverAsMiranda && !*mirver) || (strstr(mirver,"Miranda")!=NULL); mir_free(mirver); } @@ -78,11 +78,11 @@ BOOL isClientMiranda(pUinKey ptr, BOOL emptyMirverAsMiranda) { BOOL isClientMiranda(HANDLE hContact, BOOL emptyMirverAsMiranda) { - if( !bMCD ) return true; - if( !clist_cnt ) return false; + if ( !bMCD ) return true; + if ( !clist_cnt ) return false; for(int j=0;jinspecting ) break; + if ( clist[j].hContact == hContact ) { + if ( !clist[j].proto->inspecting ) break; return strstr(clist[j].proto->name,"IRC")!=NULL || strstr(clist[j].proto->name,"WinPopup")!=NULL || strstr(clist[j].proto->name,"VyChat")!=NULL; @@ -107,12 +107,12 @@ BOOL isProtoSmallPackets(HANDLE hContact) { BOOL isContactInvisible(HANDLE hContact) { - if( !DBGetContactSettingByte(hContact,"CList","Hidden",0) ) { - if( !clist_cnt ) return false; + if ( !DBGetContactSettingByte(hContact,"CList","Hidden",0) ) { + if ( !clist_cnt ) return false; for(int j=0;jinspecting ) return false; - if( clist[j].waitForExchange ) return false; + if ( clist[j].hContact == hContact ) { + if ( !clist[j].proto->inspecting ) return false; + if ( clist[j].waitForExchange ) return false; switch( (int)DBGetContactSettingWord(hContact,clist[j].proto->name,"ApparentMode",0) ) { case 0: return (CallProtoService(clist[j].proto->name,PS_GETSTATUS,0,0)==ID_STATUS_INVISIBLE); @@ -139,8 +139,8 @@ BOOL isContactNewPG(HANDLE hContact) { if (!clist_cnt) return false; for(int j=0;jinspecting ) break; - if( !clist[j].cntx ) break; + if ( !clist[j].proto->inspecting ) break; + if ( !clist[j].cntx ) break; return (clist[j].features & CPP_FEATURES_NEWPG) != 0; } } @@ -150,12 +150,12 @@ BOOL isContactNewPG(HANDLE hContact) { BOOL isContactPGP(HANDLE hContact) { - if(!bPGPloaded || (!bPGPkeyrings && !bPGPprivkey)) return false; + if (!bPGPloaded || (!bPGPkeyrings && !bPGPprivkey)) return false; if (!clist_cnt) return false; for(int j=0;jinspecting ) break; - if( clist[j].mode!=MODE_PGP ) break; + if ( !clist[j].proto->inspecting ) break; + if ( clist[j].mode!=MODE_PGP ) break; DBVARIANT dbv; DBGetContactSetting(hContact,szModuleName,"pgp",&dbv); BOOL r=(dbv.type!=0); @@ -169,12 +169,12 @@ BOOL isContactPGP(HANDLE hContact) { BOOL isContactGPG(HANDLE hContact) { - if(!bGPGloaded || !bGPGkeyrings) return false; + if (!bGPGloaded || !bGPGkeyrings) return false; if (!clist_cnt) return false; for(int j=0;jinspecting ) break; - if( clist[j].mode!=MODE_GPG ) break; + if ( !clist[j].proto->inspecting ) break; + if ( clist[j].mode!=MODE_GPG ) break; DBVARIANT dbv; DBGetContactSetting(hContact,szModuleName,"gpg",&dbv); BOOL r=(dbv.type!=0); @@ -191,8 +191,8 @@ BOOL isContactRSAAES(HANDLE hContact) { if (!clist_cnt) return false; for(int j=0;jinspecting ) break; - if( clist[j].mode!=MODE_RSAAES ) break; + if ( !clist[j].proto->inspecting ) break; + if ( clist[j].mode!=MODE_RSAAES ) break; return true; } } @@ -205,8 +205,8 @@ BOOL isContactRSA(HANDLE hContact) { if (!clist_cnt) return false; for(int j=0;jinspecting ) break; - if( clist[j].mode!=MODE_RSA ) break; + if ( !clist[j].proto->inspecting ) break; + if ( clist[j].mode!=MODE_RSA ) break; return true; } } @@ -218,8 +218,8 @@ BOOL isChatRoom(HANDLE hContact) { if (!clist_cnt) return false; for(int j=0;jinspecting ) break; + if ( clist[j].hContact == hContact ) { + if ( !clist[j].proto->inspecting ) break; return (DBGetContactSettingByte(hContact,clist[j].proto->name,"ChatRoom",0)!=0); } } @@ -234,15 +234,15 @@ BOOL isFileExist(LPCSTR filename) { BOOL isSecureIM(pUinKey ptr, BOOL emptyMirverAsSecureIM) { - if( !bAIP ) return false; - if( !ptr->proto->inspecting ) return false; + if ( !bAIP ) return false; + if ( !ptr->proto->inspecting ) return false; BOOL isSecureIM = false; - if( bNOL && DBGetContactSettingByte(ptr->hContact,"CList","NotOnList",0) ) { + if ( bNOL && DBGetContactSettingByte(ptr->hContact,"CList","NotOnList",0) ) { return false; } LPSTR mirver = myDBGetString(ptr->hContact,ptr->proto->name,"MirVer"); - if( mirver ) { + if ( mirver ) { isSecureIM = (emptyMirverAsSecureIM && !*mirver) || (strstr(mirver,"SecureIM")!=NULL) || (strstr(mirver,"secureim")!=NULL); mir_free(mirver); } @@ -252,8 +252,8 @@ BOOL isSecureIM(pUinKey ptr, BOOL emptyMirverAsSecureIM) { BOOL isSecureIM(HANDLE hContact, BOOL emptyMirverAsSecureIM) { - if( !bAIP ) return false; - if( !clist_cnt ) return false; + if ( !bAIP ) return false; + if ( !clist_cnt ) return false; for(int j=0;jcntx ) + if ( !ptr->cntx ) ptr->cntx = cpp_create_context(isProtoSmallPackets(ptr->hContact)?CPP_MODE_BASE64:0); char *tmp = myDBGetString(ptr->hContact,szModuleName,"PSK"); @@ -46,10 +46,10 @@ int InitKeyB(pUinKey ptr,LPCSTR key) { #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("InitKeyB: %s", key); #endif - if(!ptr->cntx) + if (!ptr->cntx) ptr->cntx = cpp_create_context(isProtoSmallPackets(ptr->hContact)?CPP_MODE_BASE64:0); - if(!cpp_keyp(ptr->cntx)) { + if (!cpp_keyp(ptr->cntx)) { char *tmp = myDBGetString(ptr->hContact,szModuleName,"PSK"); if(tmp) { cpp_init_keyp(ptr->cntx,tmp); // make pre-shared key from password @@ -67,7 +67,7 @@ int InitKeyB(pUinKey ptr,LPCSTR key) { // store KeyX into context void InitKeyX(pUinKey ptr,BYTE *key) { - if(!ptr->cntx) + if (!ptr->cntx) ptr->cntx = cpp_create_context(isProtoSmallPackets(ptr->hContact)?CPP_MODE_BASE64:0); cpp_set_keyx(ptr->cntx,key); @@ -78,7 +78,7 @@ void InitKeyX(pUinKey ptr,BYTE *key) { BOOL CalculateKeyX(pUinKey ptr,HANDLE hContact) { int agr = cpp_calc_keyx(ptr->cntx); - if( agr ) { + if ( agr ) { // do this only if key exchanged is ok // we use a 192bit key int keysize = cpp_size_keyx(); @@ -137,10 +137,10 @@ LPSTR encodeMsg(pUinKey ptr, LPARAM lParam) { LPSTR szNewMsg = NULL; LPSTR szOldMsg = (LPSTR) pccsd->lParam; - if( pccsd->wParam & PREF_UTF ) + if ( pccsd->wParam & PREF_UTF ) szNewMsg = encrypt(ptr,cpp_encodeU(ptr->cntx,szOldMsg)); else - if( pccsd->wParam & PREF_UNICODE ) + if ( pccsd->wParam & PREF_UNICODE ) szNewMsg = encrypt(ptr,cpp_encodeW(ptr->cntx,(LPWSTR)(szOldMsg+strlen(szOldMsg)+1))); else szNewMsg = encrypt(ptr,cpp_encodeA(ptr->cntx,szOldMsg)); @@ -181,7 +181,7 @@ LPSTR decodeMsg(pUinKey ptr, LPARAM lParam, LPSTR szEncMsg) { } else { ptr->decoded=true; - if( ppre->flags & PREF_UTF ) { // Ґб«Ё Їа®в®Є®« Ї®¤¤Ґа¦Ёў Ґв utf8 - в®Ј¤  ®вЇа ў«пҐ¬ ў utf8 + if ( ppre->flags & PREF_UTF ) { // Ґб«Ё Їа®в®Є®« Ї®¤¤Ґа¦Ёў Ґв utf8 - в®Ј¤  ®вЇа ў«пҐ¬ ў utf8 int olen = (int)strlen(szOldMsg)+1; szNewMsg = (LPSTR) mir_alloc(olen); memcpy(szNewMsg,szOldMsg,olen); @@ -212,7 +212,7 @@ BOOL LoadKeyPGP(pUinKey ptr) { else if(mode==1) { LPSTR key = myDBGetStringDecode(ptr->hContact,szModuleName,"pgp"); - if( key ) { + if ( key ) { pgp_set_key(ptr->cntx,key); mir_free(key); return 1; @@ -225,7 +225,7 @@ BOOL LoadKeyPGP(pUinKey ptr) { BOOL LoadKeyGPG(pUinKey ptr) { LPSTR key = myDBGetString(ptr->hContact,szModuleName,"gpg"); - if( key ) { + if ( key ) { gpg_set_keyid(ptr->cntx,key); mir_free(key); return 2; diff --git a/plugins/SecureIM/crypt_icons.cpp b/plugins/SecureIM/crypt_icons.cpp index 97f86b43f8..5c3d21023d 100644 --- a/plugins/SecureIM/crypt_icons.cpp +++ b/plugins/SecureIM/crypt_icons.cpp @@ -17,9 +17,9 @@ HICON mode2icon(int mode,int type) { int m=mode&0x0f,s=(mode&SECURED)>>4,i; // разобрали на части - режим и состояние HICON icon; - if( icons_cache ) { + if ( icons_cache ) { for(i=0;i>4; // разобрали на части - режим и состояние - if( mode==-1 || (!s && !bASI && m!=MODE_PGP && m!=MODE_GPG) ) { + if ( mode==-1 || (!s && !bASI && m!=MODE_PGP && m!=MODE_GPG) ) { return g_IEC[0]; // вернем пустое место } int i=1+m*IEC_CNT+IEC_CL_DIS+s; - if( g_IEC[i].hImage==(HANDLE)-1 ) { + if ( g_IEC[i].hImage==(HANDLE)-1 ) { /* g_hIEC[i] = mode2icon(mode,1); g_IEC[i].hImage = (HANDLE) CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)g_hIEC[i], (LPARAM)0);*/ HICON icon = mode2icon(mode,1); @@ -78,22 +78,22 @@ IconExtraColumn mode2iec(int mode) { void ShowStatusIcon(HANDLE hContact,int mode) { HANDLE hMC = getMetaContact(hContact); - if( bADV || g_hCLIcon ) { // обновить иконки в clist - if( mode!= -1 ) { + if ( bADV || g_hCLIcon ) { // обновить иконки в clist + if ( mode!= -1 ) { IconExtraColumn iec=mode2iec(mode); - if( g_hCLIcon ) { + if ( g_hCLIcon ) { ExtraIcon_SetIcon(g_hCLIcon, hContact, iec.hImage); - if( hMC ) + if ( hMC ) ExtraIcon_SetIcon(g_hCLIcon, hMC, iec.hImage); } else { CallService(MS_CLIST_EXTRA_SET_ICON, (WPARAM)hContact, (LPARAM)&iec); - if( hMC ) + if ( hMC ) CallService(MS_CLIST_EXTRA_SET_ICON, (WPARAM)hMC, (LPARAM)&iec); } } } - if( ServiceExists(MS_MSG_MODIFYICON) ) { // обновить иконки в srmm + if ( ServiceExists(MS_MSG_MODIFYICON) ) { // обновить иконки в srmm StatusIconData sid; memset(&sid,0,sizeof(sid)); sid.cbSize = sizeof(sid); @@ -101,10 +101,10 @@ void ShowStatusIcon(HANDLE hContact,int mode) { for(int i=MODE_NATIVE; iszName); - if( szNames ) { - if( proto[j].name ) { + if ( szNames ) { + if ( proto[j].name ) { char tmp[128]; strcpy(tmp,proto[j].name); strcat(tmp,":"); LPSTR szName = strstr(szNames,tmp); - if( szName ) { + if ( szName ) { szName = strchr(szName,':'); - if( szName ) { + if ( szName ) { proto[j].inspecting = (*++szName == '1'); szName = strchr(szName,':'); - if( szName ) { + if ( szName ) { proto[j].split_on = atoi(++szName); proto[j].tsplit_on = proto[j].split_on; szName = strchr(szName,':'); - if( szName ) { + if ( szName ) { proto[j].split_off = atoi(++szName); proto[j].tsplit_off = proto[j].split_off; } } @@ -86,9 +86,9 @@ void MoveToFirstInFilterList(HANDLE hContact) { for(i=0;;i++) { mir_itoa(i,str,10); - if( DBGetContactSettingString(hContact,"_Filter",str,&dbv) ) break; - if( !strcmp(szModuleName,dbv.pszVal) ) { // нашли мой модуль - if( i==0 ) return; + if ( DBGetContactSettingString(hContact,"_Filter",str,&dbv) ) break; + if ( !strcmp(szModuleName,dbv.pszVal) ) { // нашли мой модуль + if ( i==0 ) return; DBGetContactSettingString(hContact,"_Filter","0",&dbv); DBWriteContactSettingString(hContact,"_Filter","0",szModuleName); DBWriteContactSettingString(hContact,"_Filter",str,dbv.pszVal); @@ -108,14 +108,14 @@ void MoveToLastInFilterList(HANDLE hContact) { for(i=0;;i++) { mir_itoa(i,str,10); - if( DBGetContactSettingString(hContact,"_Filter",str,&dbv) ) break; - if( !strcmp(szModuleName,dbv.pszVal) ) { // нашли мой модуль + if ( DBGetContactSettingString(hContact,"_Filter",str,&dbv) ) break; + if ( !strcmp(szModuleName,dbv.pszVal) ) { // нашли мой модуль j=i; } mir_free(dbv.pszVal); } i--; - if( j==i ) return; + if ( j==i ) return; mir_itoa(i,end,10); mir_itoa(j,str,10); DBGetContactSettingString(hContact,"_Filter",end,&dbv); @@ -137,7 +137,7 @@ pUinKey addContact(HANDLE hContact) { CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)szModuleName); MoveToLastInFilterList(hContact); for(j=0;jname, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); - if( uID==(LPSTR)CALLSERVICE_NOTFOUND ) uID = 0; // Billy_Bons - if( uID && DBGetContactSetting(hContact, ptr->name, uID, &dbv_uniqueid)==0 ) { + if ( uID==(LPSTR)CALLSERVICE_NOTFOUND ) uID = 0; // Billy_Bons + if ( uID && DBGetContactSetting(hContact, ptr->name, uID, &dbv_uniqueid)==0 ) { if (dbv_uniqueid.type == DBVT_WORD) sprintf(szUIN, "%u [%s]", dbv_uniqueid.wVal, ptr->name); else @@ -316,7 +316,7 @@ void getContactUinA(HANDLE hContact, LPSTR szUIN) { void getContactUin(HANDLE hContact, LPSTR szUIN) { getContactUinA(hContact, szUIN); - if( bCoreUnicode && *szUIN ) { + if ( bCoreUnicode && *szUIN ) { LPWSTR tmp = mir_a2u(szUIN); wcscpy((LPWSTR)szUIN, tmp); mir_free(tmp); diff --git a/plugins/SecureIM/crypt_metacontacts.cpp b/plugins/SecureIM/crypt_metacontacts.cpp index 5a24c6c9cb..f36c7e4dd3 100644 --- a/plugins/SecureIM/crypt_metacontacts.cpp +++ b/plugins/SecureIM/crypt_metacontacts.cpp @@ -4,7 +4,7 @@ BOOL isProtoMetaContacts(HANDLE hContact) { if(bMetaContacts) { LPSTR proto = (LPSTR)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - if( proto && strcmp(proto,"MetaContacts")==0 ) { + if ( proto && strcmp(proto,"MetaContacts")==0 ) { return true; } } @@ -47,10 +47,10 @@ void DeinitMetaContact(HANDLE hContact) { HANDLE hMetaContact = isProtoMetaContacts(hContact) ? hContact : getMetaContact(hContact); - if( hMetaContact ) { + if ( hMetaContact ) { for(int i=0;ihContact); delete tParam; - if( !ptr ) return 0; + if ( !ptr ) return 0; for(int i=0;iwaitForExchange != 1 ) break; + if ( ptr->waitForExchange != 1 ) break; } // for #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("sttWaitForExchange: %d",ptr->waitForExchange); #endif // if keyexchange failed or timeout - if( ptr->waitForExchange==1 || ptr->waitForExchange==3 ) { // Їа®вге«® - ®вЇа ў«пҐ¬ ­Ґ§ иЁда®ў ­­®, Ґб«Ё ­ ¤® - if( ptr->msgQueue && msgbox1(0,sim104,szModuleName,MB_YESNO|MB_ICONQUESTION)==IDYES ) { + if ( ptr->waitForExchange==1 || ptr->waitForExchange==3 ) { // Їа®вге«® - ®вЇа ў«пҐ¬ ­Ґ§ иЁда®ў ­­®, Ґб«Ё ­ ¤® + if ( ptr->msgQueue && msgbox1(0,sim104,szModuleName,MB_YESNO|MB_ICONQUESTION)==IDYES ) { EnterCriticalSection(&localQueueMutex); ptr->sendQueue = true; pWM ptrMessage = ptr->msgQueue; @@ -76,7 +76,7 @@ unsigned __stdcall sttWaitForExchange( LPVOID param ) { ShowStatusIconNotify(ptr->hContact); } else - if( ptr->waitForExchange==2 ) { // ¤®б« вм ®зҐаҐ¤м зҐаҐ§ гбв ­®ў«Ґ­­®Ґ ᮥ¤Ё­Ґ­ЁҐ + if ( ptr->waitForExchange==2 ) { // ¤®б« вм ®зҐаҐ¤м зҐаҐ§ гбв ­®ў«Ґ­­®Ґ ᮥ¤Ё­Ґ­ЁҐ EnterCriticalSection(&localQueueMutex); // we need to resend last send back message with new crypto Key pWM ptrMessage = ptr->msgQueue; @@ -96,7 +96,7 @@ unsigned __stdcall sttWaitForExchange( LPVOID param ) { LeaveCriticalSection(&localQueueMutex); } else - if( ptr->waitForExchange==0 ) { // ®зЁбвЁвм ®зҐаҐ¤м + if ( ptr->waitForExchange==0 ) { // ®зЁбвЁвм ®зҐаҐ¤м EnterCriticalSection(&localQueueMutex); // we need to resend last send back message with new crypto Key pWM ptrMessage = ptr->msgQueue; @@ -119,11 +119,11 @@ void waitForExchange(pUinKey ptr, int flag) { case 0: // бЎа®бЁвм case 2: // ¤®б« вм иЁда®ў ­® case 3: // ¤®б« вм ­ҐиЁда®ў ­® - if( ptr->waitForExchange ) + if ( ptr->waitForExchange ) ptr->waitForExchange = flag; break; case 1: // § ЇгбвЁвм - if( ptr->waitForExchange ) + if ( ptr->waitForExchange ) break; ptr->waitForExchange = 1; // § ЇгбЄ Ґ¬ ван¤ diff --git a/plugins/SecureIM/crypt_popups.cpp b/plugins/SecureIM/crypt_popups.cpp index 768423e765..836a68efc1 100644 --- a/plugins/SecureIM/crypt_popups.cpp +++ b/plugins/SecureIM/crypt_popups.cpp @@ -24,7 +24,7 @@ void showPopUp(LPCSTR lpzText,HANDLE hContact,HICON hIcon, UINT type) { //type=1 session colors //type=2 SR colors - if(!bPopupExists) return; + if (!bPopupExists) return; //hContact = A_VALID_HANDLE_YOU_GOT_FROM_SOMEWHERE; COLORREF colorBackKey = RGB(230,230,255); @@ -71,7 +71,7 @@ void showPopUp(LPCSTR lpzText,HANDLE hContact,HICON hIcon, UINT type) { DBFreeVariant(&dbv_timeout); } - if( bCoreUnicode && bPopupUnicode ) { + if ( bCoreUnicode && bPopupUnicode ) { POPUPDATAW ppd = {0}; ppd.lchContact = hContact; //Be sure to use a GOOD handle, since this will not be checked. diff --git a/plugins/SecureIM/loadicons.cpp b/plugins/SecureIM/loadicons.cpp index 1b9d4735bd..ec6d0ae17e 100644 --- a/plugins/SecureIM/loadicons.cpp +++ b/plugins/SecureIM/loadicons.cpp @@ -46,7 +46,7 @@ void InitIcons(void) { HINSTANCE hNewIconInst = NULL; - if( g_hFolders ) { + if ( g_hFolders ) { LPSTR pathname = (LPSTR) alloca(MAX_PATH); FoldersGetCustomPathEx(g_hFolders, pathname, MAX_PATH, "icons\\", "secureim_icons.dll"); if (hNewIconInst == NULL) diff --git a/plugins/SecureIM/main.cpp b/plugins/SecureIM/main.cpp index 7e29f0d352..926f68512a 100644 --- a/plugins/SecureIM/main.cpp +++ b/plugins/SecureIM/main.cpp @@ -131,7 +131,7 @@ int __cdecl Load(PLUGINLINK *link) { iCoreVersion = CallService(MS_SYSTEM_GETVERSION,0,0); // load crypo++ dll - if( !loadlib() ) { + if ( !loadlib() ) { msgbox1(0,sim107,szModuleName,MB_OK|MB_ICONSTOP); return 1; } @@ -190,7 +190,7 @@ int __cdecl onModulesLoaded(WPARAM wParam,LPARAM lParam) { bPopupUnicode = ServiceExists(MS_POPUP_ADDPOPUPW)!=0; g_hFolders = FoldersRegisterCustomPath(szModuleName, "Icons", MIRANDA_PATH"\\icons"); - if( g_hFolders==(HANDLE)CALLSERVICE_NOTFOUND ) g_hFolders = 0; + if ( g_hFolders==(HANDLE)CALLSERVICE_NOTFOUND ) g_hFolders = 0; InitIcons(); GetFlags(); @@ -204,13 +204,13 @@ int __cdecl onModulesLoaded(WPARAM wParam,LPARAM lParam) { DBVARIANT dbv; dbv.type = DBVT_BLOB; - if( DBGetContactSetting(0,szModuleName,"rsa_priv",&dbv) == 0 ) { + if ( DBGetContactSetting(0,szModuleName,"rsa_priv",&dbv) == 0 ) { exp->rsa_set_keypair(CPP_MODE_RSA_4096,dbv.pbVal,dbv.cpbVal); DBFreeVariant(&dbv); rsa_4096=1; } else - if( DBGetContactSetting(0,szModuleName,"rsa_priv_4096",&dbv) == 0 ) { + if ( DBGetContactSetting(0,szModuleName,"rsa_priv_4096",&dbv) == 0 ) { exp->rsa_set_keypair(CPP_MODE_RSA_4096|CPP_MODE_RSA_BER,dbv.pbVal,dbv.cpbVal); DBFreeVariant(&dbv); @@ -241,7 +241,7 @@ int __cdecl onModulesLoaded(WPARAM wParam,LPARAM lParam) { rsa_4096=1; } - if( !rsa_4096 ) { + if ( !rsa_4096 ) { unsigned int tID; CloseHandle( (HANDLE) _beginthreadex(NULL, 0, sttGenerateRSA, NULL, 0, &tID) ); } @@ -384,7 +384,7 @@ int __cdecl onModulesLoaded(WPARAM wParam,LPARAM lParam) { AddHookFunction(ME_CLIST_PREBUILDCONTACTMENU, onRebuildContactMenu); // g_hMC = HookEvent(ME_MC_SUBCONTACTSCHANGED, onMC); - if( ServiceExists(MS_EXTRAICON_REGISTER) ) { + if ( ServiceExists(MS_EXTRAICON_REGISTER) ) { g_hCLIcon = ExtraIcon_Register(szModuleName, Translate("SecureIM status"), "sim_cm_est", onExtraImageListRebuilding, onExtraImageApplying); @@ -433,7 +433,7 @@ int __cdecl onModulesLoaded(WPARAM wParam,LPARAM lParam) { Sent_NetLog("create PGP/GPG menu"); #endif HICON icon; - if( bPGPloaded ) { + if ( bPGPloaded ) { icon=mode2icon(MODE_PGP|SECURED,2); g_hMenu[6] = AddMenuItem(sim306,110006,icon,MODULENAME"/PGP_SET",0); icon=mode2icon(MODE_PGP,2); diff --git a/plugins/SecureIM/mmi.cpp b/plugins/SecureIM/mmi.cpp index 17195563e1..2269d76a51 100644 --- a/plugins/SecureIM/mmi.cpp +++ b/plugins/SecureIM/mmi.cpp @@ -75,8 +75,8 @@ LPSTR to_hex(PBYTE bin, int len) { SAFE_FREE(m_hex); m_hex = (LPSTR) mir_alloc(len*3+1); LPSTR m_ptr = m_hex; - for( int i=0; iutf8decode(szUtfMsg); LPSTR szMsg = mir_u2a(wszMsg); - if( bCoreUnicode ) { + if ( bCoreUnicode ) { flags |= PREF_UNICODE; int olen = (int)wcslen((LPWSTR)wszMsg)+1; int nlen = olen*(sizeof(WCHAR)+1); diff --git a/plugins/SecureIM/options.cpp b/plugins/SecureIM/options.cpp index 17123e1e69..fa61e021b4 100644 --- a/plugins/SecureIM/options.cpp +++ b/plugins/SecureIM/options.cpp @@ -9,15 +9,15 @@ const char *szAdvancedIcons[] = {"None", "Email", "Protocol", "SMS", "Advanced 1 BOOL hasKey(pUinKey ptr) { BOOL ret = 0; - if( ptr->mode==MODE_NATIVE ) { + if ( ptr->mode==MODE_NATIVE ) { LPSTR str = myDBGetString(ptr->hContact,szModuleName,"PSK"); ret = (str!=NULL); SAFE_FREE(str); } else - if( ptr->mode==MODE_RSAAES ) { + if ( ptr->mode==MODE_RSAAES ) { DBVARIANT dbv; dbv.type = DBVT_BLOB; - if( DBGetContactSetting(ptr->hContact,szModuleName,"rsa_pub",&dbv) == 0 ) { + if ( DBGetContactSetting(ptr->hContact,szModuleName,"rsa_pub",&dbv) == 0 ) { ret = 1; DBFreeVariant(&dbv); } @@ -27,7 +27,7 @@ BOOL hasKey(pUinKey ptr) { void TC_InsertItem(HWND hwnd, WPARAM wparam, TCITEM *tci) { - if( bCoreUnicode ) { + if ( bCoreUnicode ) { LPWSTR tmp = mir_a2u(tci->pszText); tci->pszText = (LPSTR)TranslateW(tmp); SNDMSG(hwnd, TCM_INSERTITEMW, wparam, (LPARAM)tci); @@ -41,7 +41,7 @@ void TC_InsertItem(HWND hwnd, WPARAM wparam, TCITEM *tci) { static void LV_InsertColumn(HWND hwnd, WPARAM wparam, LVCOLUMN *lvc) { - if( bCoreUnicode ) { + if ( bCoreUnicode ) { LPWSTR tmp = mir_a2u(lvc->pszText); lvc->pszText = (LPSTR)TranslateW(tmp); SNDMSG(hwnd, LVM_INSERTCOLUMNW, wparam, (LPARAM)lvc); @@ -60,9 +60,9 @@ int LV_InsertItem(HWND hwnd, LVITEM *lvi) { int LV_InsertItemA(HWND hwnd, LVITEM *lvi) { - if( bCoreUnicode ) lvi->pszText = (LPSTR) mir_a2u(lvi->pszText); + if ( bCoreUnicode ) lvi->pszText = (LPSTR) mir_a2u(lvi->pszText); int ret = LV_InsertItem(hwnd, lvi); - if( bCoreUnicode ) mir_free(lvi->pszText); + if ( bCoreUnicode ) mir_free(lvi->pszText); return ret; } @@ -76,9 +76,9 @@ void LV_SetItemText(HWND hwnd, WPARAM wparam, int subitem, LPSTR text) { void LV_SetItemTextA(HWND hwnd, WPARAM wparam, int subitem, LPSTR text) { - if( bCoreUnicode ) text = (LPSTR) mir_a2u(text); + if ( bCoreUnicode ) text = (LPSTR) mir_a2u(text); LV_SetItemText(hwnd, wparam, subitem, text); - if( bCoreUnicode ) mir_free(text); + if ( bCoreUnicode ) mir_free(text); } @@ -88,7 +88,7 @@ void LV_GetItemTextA(HWND hwnd, WPARAM wparam, int iSubItem, LPSTR text, int cch lvi.cchTextMax = cchTextMax; lvi.pszText = text; SNDMSG(hwnd, bCoreUnicode ? LVM_GETITEMTEXTW : LVM_GETITEMTEXTA, wparam, (LPARAM)&lvi); - if( bCoreUnicode ) { + if ( bCoreUnicode ) { lvi.pszText = mir_u2a((LPWSTR)text); strcpy(text, lvi.pszText); mir_free(lvi.pszText); @@ -147,7 +147,7 @@ INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara break; case PSM_CHANGED: // used so tabs dont have to call SendMessage(GetParent(GetParent(hwnd)), PSM_CHANGED, 0, 0); - if(!iInit) + if (!iInit) SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); break; @@ -166,14 +166,14 @@ INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara } break;*/ case ID_UPDATE_PLIST: { - if( !bPGP ) break; + if ( !bPGP ) break; tci.mask = TCIF_PARAM; TabCtrl_GetItem(GetDlgItem(hwnd,IDC_OPTIONSTAB),2,&tci); SendMessage((HWND)tci.lParam,WM_COMMAND,ID_UPDATE_CLIST,0); } break; case ID_UPDATE_GLIST: { - if( !bGPG ) break; + if ( !bGPG ) break; tci.mask = TCIF_PARAM; TabCtrl_GetItem(GetDlgItem(hwnd,IDC_OPTIONSTAB),3,&tci); SendMessage((HWND)tci.lParam,WM_COMMAND,ID_UPDATE_GLIST,0); @@ -288,7 +288,7 @@ INT_PTR CALLBACK DlgProcOptionsGeneral(HWND hDlg, UINT wMsg, WPARAM wParam, LPAR break; case WM_PAINT: { - if(!iInit) + if (!iInit) InvalidateRect(hDlg,NULL,FALSE); } // WM_PAINT break; @@ -361,14 +361,14 @@ INT_PTR CALLBACK DlgProcOptionsGeneral(HWND hDlg, UINT wMsg, WPARAM wParam, LPAR idx = ListView_GetSelectionMark(hLV); ptr = (pUinKey) getListViewParam(hLV,idx); if(ptr) { - if( !ptr->keyLoaded ) { + if ( !ptr->keyLoaded ) { createRSAcntx(ptr); loadRSAkey(ptr); } - if( ptr->keyLoaded ) { + if ( ptr->keyLoaded ) { LPSTR buffer = (LPSTR) alloca(RSASIZE); exp->rsa_export_pubkey(ptr->cntx,buffer); - if( !SaveExportRSAKeyDlg(hDlg,buffer,0) ) + if ( !SaveExportRSAKeyDlg(hDlg,buffer,0) ) msgbox(hDlg,sim114,szModuleName,MB_OK|MB_ICONEXCLAMATION); } } @@ -382,8 +382,8 @@ INT_PTR CALLBACK DlgProcOptionsGeneral(HWND hDlg, UINT wMsg, WPARAM wParam, LPAR if(ptr) { createRSAcntx(ptr); LPSTR pub = (LPSTR) alloca(RSASIZE); - if( !LoadImportRSAKeyDlg(hDlg,pub,0) ) return TRUE; - if( exp->rsa_import_pubkey(ptr->cntx,pub) ) { + if ( !LoadImportRSAKeyDlg(hDlg,pub,0) ) return TRUE; + if ( exp->rsa_import_pubkey(ptr->cntx,pub) ) { int len; exp->rsa_get_pubkey(ptr->cntx,(PBYTE)pub,&len); @@ -413,7 +413,7 @@ INT_PTR CALLBACK DlgProcOptionsGeneral(HWND hDlg, UINT wMsg, WPARAM wParam, LPAR break; case IDC_RESET: { - if(!iInit) + if (!iInit) ResetGeneralDlg(hDlg); } break; @@ -448,7 +448,7 @@ INT_PTR CALLBACK DlgProcOptionsGeneral(HWND hDlg, UINT wMsg, WPARAM wParam, LPAR default: return FALSE; } - if(!iInit) + if (!iInit) SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); } // WM_COMMAND break; @@ -475,9 +475,9 @@ INT_PTR CALLBACK DlgProcOptionsGeneral(HWND hDlg, UINT wMsg, WPARAM wParam, LPAR ptr = (pUinKey) getListViewParam(hLV,idx); if (ptr) { ptr->tmode++; - if( !bPGP && ptr->tmode==MODE_PGP ) ptr->tmode++; - if( !bGPG && ptr->tmode==MODE_GPG ) ptr->tmode++; - if( ptr->tmode>=MODE_CNT ) ptr->tmode=MODE_NATIVE; + if ( !bPGP && ptr->tmode==MODE_PGP ) ptr->tmode++; + if ( !bGPG && ptr->tmode==MODE_GPG ) ptr->tmode++; + if ( ptr->tmode>=MODE_CNT ) ptr->tmode=MODE_NATIVE; setListViewMode(hLV,idx,ptr->tmode); setListViewIcon(hLV,idx,ptr); SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); @@ -501,7 +501,7 @@ INT_PTR CALLBACK DlgProcOptionsGeneral(HWND hDlg, UINT wMsg, WPARAM wParam, LPAR if (ptr) { POINT p; GetCursorPos(&p); HMENU hMenu = NULL; - if( ptr->tmode==MODE_NATIVE || ptr->tmode==MODE_RSAAES ) { + if ( ptr->tmode==MODE_NATIVE || ptr->tmode==MODE_RSAAES ) { switch( lpLV->iSubItem ) { case 2: // mode hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDM_CLIST2)); @@ -518,23 +518,23 @@ INT_PTR CALLBACK DlgProcOptionsGeneral(HWND hDlg, UINT wMsg, WPARAM wParam, LPAR break; } CheckMenuItem(hMenu, ID_DISABLED+ptr->tstatus, MF_CHECKED ); - if( ptr->tmode==MODE_NATIVE ) { - if( !hasKey(ptr) ) EnableMenuItem(hMenu, ID_DELPSK, MF_GRAYED ); + if ( ptr->tmode==MODE_NATIVE ) { + if ( !hasKey(ptr) ) EnableMenuItem(hMenu, ID_DELPSK, MF_GRAYED ); } else - if( ptr->tmode==MODE_RSAAES ) { - if( !hasKey(ptr) ) { + if ( ptr->tmode==MODE_RSAAES ) { + if ( !hasKey(ptr) ) { EnableMenuItem(hMenu, ID_EXPPUBL, MF_GRAYED ); EnableMenuItem(hMenu, ID_DELPUBL, MF_GRAYED ); } } } - if( !hMenu ) + if ( !hMenu ) hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDM_CLIST2)); CallService(MS_LANGPACK_TRANSLATEMENU, (WPARAM)hMenu, 0); CheckMenuItem(hMenu, ID_SIM_NATIVE+ptr->tmode, MF_CHECKED ); - if( !bPGP ) EnableMenuItem(hMenu, ID_SIM_PGP, MF_GRAYED ); - if( !bGPG ) EnableMenuItem(hMenu, ID_SIM_GPG, MF_GRAYED ); + if ( !bPGP ) EnableMenuItem(hMenu, ID_SIM_PGP, MF_GRAYED ); + if ( !bGPG ) EnableMenuItem(hMenu, ID_SIM_GPG, MF_GRAYED ); // CheckMenuItem(hMenu, ID_ENCRYPTION, MF_BYCOMMAND ); TrackPopupMenu(GetSubMenu(hMenu, 0), TPM_LEFTALIGN | TPM_TOPALIGN, p.x, p.y, 0, hDlg, 0); DestroyMenu(hMenu); @@ -591,7 +591,7 @@ INT_PTR CALLBACK DlgProcOptionsProto(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM break; case WM_PAINT: { - if(!iInit) + if (!iInit) InvalidateRect(hDlg,NULL,FALSE); } // WM_PAINT break; @@ -607,29 +607,29 @@ INT_PTR CALLBACK DlgProcOptionsProto(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM case IDC_RSA_EXP: { LPSTR pub = (LPSTR) alloca(RSASIZE); exp->rsa_export_keypair(CPP_MODE_RSA,NULL,pub,NULL); - if( !SaveExportRSAKeyDlg(hDlg,pub,0) ) + if ( !SaveExportRSAKeyDlg(hDlg,pub,0) ) msgbox(hDlg,sim114,szModuleName,MB_OK|MB_ICONEXCLAMATION); return TRUE; } break; case IDC_RSA_EXPPRIV: { LPSTR passphrase = (LPSTR) alloca(RSASIZE); int res = DialogBoxParam(g_hInst,MAKEINTRESOURCE(IDD_PASSPHRASE),NULL,(DLGPROC)DlgProcSetPassphrase,(LPARAM)passphrase); - if( res==IDOK ) { + if ( res==IDOK ) { LPSTR priv = (LPSTR) alloca(RSASIZE); exp->rsa_export_keypair(CPP_MODE_RSA,priv,NULL,passphrase); - if( !SaveExportRSAKeyDlg(hDlg,priv,1) ) + if ( !SaveExportRSAKeyDlg(hDlg,priv,1) ) msgbox(hDlg,sim112,szModuleName,MB_OK|MB_ICONEXCLAMATION); } return TRUE; } break; case IDC_RSA_IMPPRIV: { LPSTR priv = (LPSTR) alloca(RSASIZE); - if( !LoadImportRSAKeyDlg(hDlg,priv,1) ) return TRUE; + if ( !LoadImportRSAKeyDlg(hDlg,priv,1) ) return TRUE; // LPSTR passphrase = (LPSTR) alloca(RSASIZE); int res = DialogBoxParam(g_hInst,MAKEINTRESOURCE(IDD_PASSPHRASE),NULL,(DLGPROC)DlgProcSetPassphrase,(LPARAM)passphrase); - if( res==IDOK ) { - if( !exp->rsa_import_keypair(CPP_MODE_RSA,priv,passphrase) ) { + if ( res==IDOK ) { + if ( !exp->rsa_import_keypair(CPP_MODE_RSA,priv,passphrase) ) { msgbox(hDlg,sim113,szModuleName,MB_OK|MB_ICONEXCLAMATION); } else { @@ -641,9 +641,9 @@ INT_PTR CALLBACK DlgProcOptionsProto(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM } break; case IDC_SPLITON: case IDC_SPLITOFF: { - if( HIWORD(wParam) == EN_CHANGE ) { + if ( HIWORD(wParam) == EN_CHANGE ) { idx = ListView_GetSelectionMark(hLV); - if( idx == -1 ) break; + if ( idx == -1 ) break; idx = (int) getListViewParam(hLV,idx); switch(LOWORD(wParam)) { case IDC_SPLITON: @@ -656,7 +656,7 @@ INT_PTR CALLBACK DlgProcOptionsProto(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM break; } } - if(!iInit) + if (!iInit) SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); } break; } @@ -682,7 +682,7 @@ INT_PTR CALLBACK DlgProcOptionsProto(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM case IDC_PROTO: { if (((LPNMHDR)lParam)->code == (UINT)NM_CLICK) { idx = (int) getListViewParam(hLV,LPNMLISTVIEW(lParam)->iItem); - if( idx == -1 ) break; + if ( idx == -1 ) break; EnableWindow(GetDlgItem(hDlg,IDC_SPLITON), true); EnableWindow(GetDlgItem(hDlg,IDC_SPLITOFF), true); mir_itoa(proto[idx].tsplit_on,buf,10); SetDlgItemText(hDlg,IDC_SPLITON,buf); @@ -757,7 +757,7 @@ INT_PTR CALLBACK DlgProcOptionsPGP(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM l break; case WM_PAINT: { - if(!iInit) + if (!iInit) InvalidateRect(hDlg,NULL,FALSE); } // WM_PAINT break; @@ -787,7 +787,7 @@ INT_PTR CALLBACK DlgProcOptionsPGP(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM l break; case IDC_LOAD_PRIVKEY: { char KeyPath[MAX_PATH]; KeyPath[0]='\0'; - if(ShowSelectKeyDlg(hDlg,KeyPath)){ + if(ShowSelectKeyDlg(hDlg,KeyPath)) { char *priv = LoadKeys(KeyPath,true); if(priv) { DBWriteContactSettingString(0,szModuleName,"tpgpPrivKey",priv); @@ -809,7 +809,7 @@ INT_PTR CALLBACK DlgProcOptionsPGP(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM l default: break; } - if(!iInit) + if (!iInit) SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); } break; @@ -909,7 +909,7 @@ INT_PTR CALLBACK DlgProcOptionsGPG(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM l break; case WM_PAINT: { - if(!iInit) + if (!iInit) InvalidateRect(hDlg,NULL,FALSE); } // WM_PAINT break; @@ -918,7 +918,7 @@ INT_PTR CALLBACK DlgProcOptionsGPG(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM l switch(LOWORD(wParam)) { /* case IDC_LOAD_PRIVKEY: { char KeyPath[MAX_PATH] = {0}; - if(ShowSelectKeyDlg(hDlg,KeyPath)){ + if(ShowSelectKeyDlg(hDlg,KeyPath)) { char *priv = LoadKeys(KeyPath,true); if(priv) { DBWriteContactSettingString(0,szModuleName,"tpgpPrivKey",priv); @@ -972,7 +972,7 @@ INT_PTR CALLBACK DlgProcOptionsGPG(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM l default: break; } - if(!iInit) + if (!iInit) SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); } break; @@ -995,7 +995,7 @@ INT_PTR CALLBACK DlgProcOptionsGPG(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM l if(LPNMLISTVIEW(lParam)->iSubItem == 3) { idx = LPNMLISTVIEW(lParam)->iItem; ptr = (pUinKey) getListViewParam(hLV,idx); - if( !ptr ) break; + if ( !ptr ) break; ptr->tgpgMode++; ptr->tgpgMode&=1; LV_SetItemTextA(hLV, LPNMLISTVIEW(lParam)->iItem, LPNMLISTVIEW(lParam)->iSubItem, (ptr->tgpgMode)?Translate(sim228):Translate(sim229)); SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); @@ -1032,7 +1032,7 @@ BOOL CALLBACK DlgProcSetPSK(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) { case WM_INITDIALOG: { TranslateDialogDefault(hDlg); SendDlgItemMessage(hDlg,IDC_EDIT1,EM_LIMITTEXT,PSKSIZE-1,0); - if( bCoreUnicode ) SetDlgItemTextW(hDlg,IDC_EDIT2,(LPWSTR)lParam); + if ( bCoreUnicode ) SetDlgItemTextW(hDlg,IDC_EDIT2,(LPWSTR)lParam); else SetDlgItemTextA(hDlg,IDC_EDIT2,(LPCSTR)lParam); buffer = (LPSTR)lParam; return (TRUE); @@ -1132,7 +1132,7 @@ void RefreshGeneralDlg(HWND hDlg, BOOL iInit) { SendMessage(GetDlgItem(hDlg,IDC_MCM),BM_SETCHECK,(bMCM)?BST_CHECKED:BST_UNCHECKED,0L); /* // CList_classic - if(!ServiceExists(MS_CLIST_ADDSUBGROUPMENUITEM)) { + if (!ServiceExists(MS_CLIST_ADDSUBGROUPMENUITEM)) { EnableWindow(GetDlgItem(hDlg,IDC_ASI),FALSE); for(i=2;itmode = ptr->mode; ptr->tstatus = ptr->status; } @@ -1181,7 +1181,7 @@ void RefreshGeneralDlg(HWND hDlg, BOOL iInit) { setListViewMode(hLV, itemNum, ptr->tmode); setListViewStatus(hLV, itemNum, ptr->tstatus); - if( ptr->mode==MODE_NATIVE ) setListViewPSK(hLV, itemNum, hasKey(ptr)); + if ( ptr->mode==MODE_NATIVE ) setListViewPSK(hLV, itemNum, hasKey(ptr)); else setListViewPUB(hLV, itemNum, hasKey(ptr)); setListViewIcon(hLV, itemNum, ptr); } @@ -1337,7 +1337,7 @@ void RefreshGPGDlg(HWND hDlg, BOOL iInit) { pUinKey ptr = getUinKey(hContact); if (ptr && ptr->mode==MODE_GPG && isSecureProtocol(hContact) /*&& !getMetaContact(hContact)*/ && !isChatRoom(hContact)) { - if( iInit ) { + if ( iInit ) { ptr->tgpgMode = ptr->gpgMode; } @@ -1402,7 +1402,7 @@ void ResetGeneralDlg(HWND hDlg) { if (isSecureProtocol(hContact) /*&& !getMetaContact(hContact)*/ && !isChatRoom(hContact)) { pUinKey ptr = getUinKey(hContact); - if(!ptr) continue; + if (!ptr) continue; ptr->tmode=MODE_NATIVE; ptr->tstatus=STATUS_ENABLED; @@ -1420,7 +1420,7 @@ void ResetGeneralDlg(HWND hDlg) { setListViewMode(hLV, itemNum, ptr->tmode); setListViewStatus(hLV, itemNum, ptr->tstatus); - if( ptr->mode==MODE_NATIVE ) setListViewPSK(hLV, itemNum, 0); + if ( ptr->mode==MODE_NATIVE ) setListViewPSK(hLV, itemNum, 0); else setListViewPUB(hLV, itemNum, 0); setListViewIcon(hLV, itemNum, ptr); } @@ -1492,18 +1492,18 @@ void ApplyGeneralSettings(HWND hDlg) { i = ListView_GetNextItem(hLV,(UINT)-1,LVNI_ALL); while(i!=-1) { pUinKey ptr = (pUinKey)getListViewParam(hLV,i); - if( !ptr ) continue; - if( ptr->mode!=ptr->tmode ) { + if ( !ptr ) continue; + if ( ptr->mode!=ptr->tmode ) { ptr->mode = ptr->tmode; DBWriteContactSettingByte(ptr->hContact, szModuleName, "mode", ptr->mode); } - if( ptr->status!=ptr->tstatus ) { + if ( ptr->status!=ptr->tstatus ) { ptr->status = ptr->tstatus; if(ptr->status==STATUS_ENABLED) DBDeleteContactSetting(ptr->hContact, szModuleName, "StatusID"); else DBWriteContactSettingByte(ptr->hContact, szModuleName, "StatusID", ptr->status); } - if( ptr->mode==MODE_NATIVE ) { - if( getListViewPSK(hLV,i) ) { + if ( ptr->mode==MODE_NATIVE ) { + if ( getListViewPSK(hLV,i) ) { LPSTR tmp = myDBGetString(ptr->hContact,szModuleName,"tPSK"); DBWriteContactSettingString(ptr->hContact, szModuleName, "PSK", tmp); mir_free(tmp); @@ -1514,8 +1514,8 @@ void ApplyGeneralSettings(HWND hDlg) { DBDeleteContactSetting(ptr->hContact, szModuleName, "tPSK"); } else - if( ptr->mode==MODE_RSAAES ) { - if( !getListViewPUB(hLV,i) ) { + if ( ptr->mode==MODE_RSAAES ) { + if ( !getListViewPUB(hLV,i) ) { DBDeleteContactSetting(ptr->hContact, szModuleName, "rsa_pub"); } } @@ -1591,10 +1591,10 @@ void ApplyGPGSettings(HWND hDlg) { int i = ListView_GetNextItem(hLV,(UINT)-1,LVNI_ALL); while(i!=-1) { pUinKey ptr = (pUinKey)getListViewParam(hLV,i); - if( !ptr ) continue; - if( ptr->gpgMode != ptr->tgpgMode ) { + if ( !ptr ) continue; + if ( ptr->gpgMode != ptr->tgpgMode ) { ptr->gpgMode = ptr->tgpgMode; - if( ptr->gpgMode ) DBWriteContactSettingByte(ptr->hContact,szModuleName,"gpgANSI",1); + if ( ptr->gpgMode ) DBWriteContactSettingByte(ptr->hContact,szModuleName,"gpgANSI",1); else DBDeleteContactSetting(ptr->hContact,szModuleName,"gpgANSI"); } @@ -1686,18 +1686,18 @@ void setListViewPUB(HWND hLV, UINT iItem, UINT iStatus) { LV_SetItemTextA(hLV, iItem, 4, str); LPSTR sha = NULL; - if( iStatus ) { + if ( iStatus ) { DBVARIANT dbv; dbv.type = DBVT_BLOB; pUinKey ptr = (pUinKey) getListViewParam(hLV, iItem); - if( DBGetContactSetting(ptr->hContact,szModuleName,"rsa_pub",&dbv) == 0 ) { + if ( DBGetContactSetting(ptr->hContact,szModuleName,"rsa_pub",&dbv) == 0 ) { int len; exp->rsa_get_hash((PBYTE)dbv.pbVal,dbv.cpbVal,(PBYTE)str,&len); sha = mir_strdup(to_hex((PBYTE)str,len)); DBFreeVariant(&dbv); } } - if( sha ) { + if ( sha ) { LV_SetItemTextA(hLV, iItem, 5, sha); mir_free(sha); } @@ -1785,7 +1785,7 @@ void ListView_Sort(HWND hLV, LPARAM lParamSort) { // restore sort column sprintf(t,"os%02x",(UINT)lParamSort&0xF0); - if((lParamSort&0x0F)==0) { + if ((lParamSort&0x0F)==0) { lParamSort=(int)DBGetContactSettingByte(0, szModuleName, t, lParamSort+1); } DBWriteContactSettingByte(0, szModuleName, t, (BYTE)lParamSort); @@ -1823,7 +1823,7 @@ LPCSTR publ_end = "-----END PGP PUBLIC KEY BLOCK-----"; LPSTR LoadKeys(LPCSTR file,BOOL priv) { FILE *f=fopen(file,"r"); - if(!f) return NULL; + if (!f) return NULL; fseek(f,0,SEEK_END); int flen = ftell(f); @@ -1842,7 +1842,7 @@ LPSTR LoadKeys(LPCSTR file,BOOL priv) { LPSTR keys = (LPSTR)mir_alloc(flen+1); int i=0; BOOL b=false; while(fgets(keys+i,128,f)) { - if(!b && strncmp(keys+i,beg,strlen(beg))==0) { + if (!b && strncmp(keys+i,beg,strlen(beg))==0) { b=true; } else @@ -1869,7 +1869,7 @@ LPSTR LoadKeys(LPCSTR file,BOOL priv) { BOOL SaveExportRSAKeyDlg(HWND hParent, LPSTR key, BOOL priv) { char szFile[MAX_PATH] = "rsa_pub.asc"; - if( priv ) strcpy(szFile,"rsa_priv.asc"); + if ( priv ) strcpy(szFile,"rsa_priv.asc"); OPENFILENAME ofn; memset(&ofn, 0, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); @@ -1882,7 +1882,7 @@ BOOL SaveExportRSAKeyDlg(HWND hParent, LPSTR key, BOOL priv) if (!GetSaveFileName(&ofn)) return FALSE; FILE *f=fopen(szFile,"wb"); - if( !f ) return FALSE; + if ( !f ) return FALSE; fwrite(key,strlen(key),1,f); fclose(f); @@ -1893,7 +1893,7 @@ BOOL SaveExportRSAKeyDlg(HWND hParent, LPSTR key, BOOL priv) BOOL LoadImportRSAKeyDlg(HWND hParent, LPSTR key, BOOL priv) { char szFile[MAX_PATH] = "rsa_pub.asc"; - if( priv ) strcpy(szFile,"rsa_priv.asc"); + if ( priv ) strcpy(szFile,"rsa_priv.asc"); OPENFILENAME ofn; memset(&ofn, 0, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); @@ -1906,7 +1906,7 @@ BOOL LoadImportRSAKeyDlg(HWND hParent, LPSTR key, BOOL priv) if (!GetOpenFileName(&ofn)) return FALSE; FILE *f=fopen(szFile,"rb"); - if( !f ) return FALSE; + if ( !f ) return FALSE; fseek(f,0,SEEK_END); int flen = ftell(f); if(flen>RSASIZE) { fclose(f); return FALSE; } diff --git a/plugins/SecureIM/splitmsg.cpp b/plugins/SecureIM/splitmsg.cpp index 45c2da17e2..ca4f0635cf 100644 --- a/plugins/SecureIM/splitmsg.cpp +++ b/plugins/SecureIM/splitmsg.cpp @@ -42,7 +42,7 @@ LPSTR combineMessage(pUinKey ptr, LPSTR szMsg) { sscanf(szMsg,"%4X%2X%2X",&msg_id,&part_num,&part_all); // pPM ppm = NULL, pm = ptr->msgPart; - if( !ptr->msgPart ) { + if ( !ptr->msgPart ) { pm = ptr->msgPart = new partitionMessage; memset(pm,0,sizeof(partitionMessage)); pm->id = msg_id; @@ -51,10 +51,10 @@ LPSTR combineMessage(pUinKey ptr, LPSTR szMsg) { } else while(pm) { - if( pm->id == msg_id ) break; + if ( pm->id == msg_id ) break; ppm = pm; pm = pm->nextMessage; } - if(!pm) { // nothing to found + if (!pm) { // nothing to found pm = ppm->nextMessage = new partitionMessage; memset(pm,0,sizeof(partitionMessage)); pm->id = msg_id; @@ -67,14 +67,14 @@ LPSTR combineMessage(pUinKey ptr, LPSTR szMsg) { Sent_NetLog("combine: save part: %s",pm->message[part_num]); #endif int len=0,i; - for( i=0; imessage[i]==NULL) break; len+=(int)strlen(pm->message[i]); } - if( i==part_all ) { // combine message + if ( i==part_all ) { // combine message SAFE_FREE(ptr->tmp); ptr->tmp = (LPSTR) mir_alloc(len+1); *(ptr->tmp)='\0'; - for( i=0; itmp,pm->message[i]); delete pm->message[i]; } @@ -102,7 +102,7 @@ int splitMessageSend(pUinKey ptr, LPSTR szMsg) { int ret; int len = (int)strlen(szMsg); int par = (getContactStatus(ptr->hContact)==ID_STATUS_OFFLINE)?ptr->proto->split_off:ptr->proto->split_on; - if( par && len>par ) { + if ( par && len>par ) { LPSTR msg = splitMsg(szMsg,par); LPSTR buf = msg; while( *buf ) { diff --git a/plugins/SecureIM/svcs_clist.cpp b/plugins/SecureIM/svcs_clist.cpp index 4d70edb2bc..359e273562 100644 --- a/plugins/SecureIM/svcs_clist.cpp +++ b/plugins/SecureIM/svcs_clist.cpp @@ -5,16 +5,16 @@ int __cdecl onContactSettingChanged(WPARAM wParam,LPARAM lParam) { HANDLE hContact = (HANDLE)wParam; DBCONTACTWRITESETTING *cws=(DBCONTACTWRITESETTING*)lParam; - if(!hContact || strcmp(cws->szSetting,"Status")) return 0; + if (!hContact || strcmp(cws->szSetting,"Status")) return 0; pUinKey ptr = getUinKey(hContact); int stat = getContactStatus(hContact); - if(!ptr || stat==-1) return 0; + if (!ptr || stat==-1) return 0; // HANDLE hMetaContact = getMetaContact(hContact); // if(hMetaContact) { // ptr = getUinKey(hMetaContact); -// if(!ptr) return 0; +// if (!ptr) return 0; // } if (stat==ID_STATUS_OFFLINE) { // go offline @@ -49,7 +49,7 @@ int __cdecl onContactSettingChanged(WPARAM wParam,LPARAM lParam) { } } else { // go not offline -// if(!hMetaContact) { // is contact or metacontact (not subcontact) +// if (!hMetaContact) { // is contact or metacontact (not subcontact) if (ptr->offlineKey) { cpp_reset_context(ptr->cntx); ptr->offlineKey = false; @@ -82,7 +82,7 @@ int __cdecl onExtraImageListRebuilding(WPARAM, LPARAM) { #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("onExtraImageListRebuilding"); #endif - if( (bADV || g_hCLIcon) && ServiceExists(MS_CLIST_EXTRA_ADD_ICON) ) { + if ( (bADV || g_hCLIcon) && ServiceExists(MS_CLIST_EXTRA_ADD_ICON) ) { RefreshContactListIcons(); } return 0; @@ -91,9 +91,9 @@ int __cdecl onExtraImageListRebuilding(WPARAM, LPARAM) { int __cdecl onExtraImageApplying(WPARAM wParam, LPARAM) { - if( (bADV || g_hCLIcon) && ServiceExists(MS_CLIST_EXTRA_SET_ICON) && isSecureProtocol((HANDLE)wParam) ) { + if ( (bADV || g_hCLIcon) && ServiceExists(MS_CLIST_EXTRA_SET_ICON) && isSecureProtocol((HANDLE)wParam) ) { IconExtraColumn iec = mode2iec(isContactSecured((HANDLE)wParam)); - if( g_hCLIcon ) { + if ( g_hCLIcon ) { ExtraIcon_SetIcon(g_hCLIcon, (HANDLE)wParam, iec.hImage); } else { @@ -111,7 +111,7 @@ int __cdecl onRebuildContactMenu(WPARAM wParam,LPARAM lParam) { #endif HANDLE hContact = (HANDLE)wParam; BOOL bMC = isProtoMetaContacts(hContact); - if( bMC ) hContact = getMostOnline(hContact); // возьмем тот, через который пойдет сообщение + if ( bMC ) hContact = getMostOnline(hContact); // возьмем тот, через который пойдет сообщение pUinKey ptr = getUinKey(hContact); int i; @@ -122,11 +122,11 @@ int __cdecl onRebuildContactMenu(WPARAM wParam,LPARAM lParam) { ShowStatusIconNotify(hContact); // check offline/online - if(!ptr) { + if (!ptr) { // hide menu bars mi.flags = CMIM_FLAGS | CMIF_NOTOFFLINE | CMIF_HIDDEN; for(i=0;imode==MODE_NATIVE || ptr->mode==MODE_RSAAES) ) { // Native/RSAAES mi.flags = CMIM_FLAGS | CMIF_NOTOFFLINE | CMIM_ICON; - if( !isSecured ) { + if ( !isSecured ) { // create secureim connection mi.hIcon = mode2icon(ptr->mode|SECURED,2); CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)g_hMenu[0],(LPARAM)&mi); @@ -166,7 +166,7 @@ int __cdecl onRebuildContactMenu(WPARAM wParam,LPARAM lParam) { CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)g_hMenu[1],(LPARAM)&mi); } // set status menu - if( bSCM && !bMC && + if ( bSCM && !bMC && ( !isSecured || ptr->mode==MODE_PGP || ptr->mode==MODE_GPG ) ) { mi.flags = CMIM_FLAGS | CMIM_NAME | CMIM_ICON; @@ -182,24 +182,24 @@ int __cdecl onRebuildContactMenu(WPARAM wParam,LPARAM lParam) { } } else - if( isSecureProto && !isChat && (ptr->mode==MODE_PGP || ptr->mode==MODE_GPG) ) { + if ( isSecureProto && !isChat && (ptr->mode==MODE_PGP || ptr->mode==MODE_GPG) ) { // PGP, GPG - if( ptr->mode==MODE_PGP && bPGPloaded ) { - if((bPGPkeyrings || bPGPprivkey) && !isGPG) { + if ( ptr->mode==MODE_PGP && bPGPloaded ) { + if ((bPGPkeyrings || bPGPprivkey) && !isGPG) { mi.flags = CMIM_FLAGS; CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)g_hMenu[isPGP+6],(LPARAM)&mi); } } - if( ptr->mode==MODE_GPG && bGPGloaded ) { + if ( ptr->mode==MODE_GPG && bGPGloaded ) { if(bGPGkeyrings && !isPGP) { mi.flags = CMIM_FLAGS; CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)g_hMenu[isGPG+8],(LPARAM)&mi); } } } - if( isSecureProto && !isChat && isMiranda ) { + if ( isSecureProto && !isChat && isMiranda ) { // set mode menu - if( bMCM && !bMC && + if ( bMCM && !bMC && ( !isSecured || ptr->mode==MODE_PGP || ptr->mode==MODE_GPG ) ) { mi.flags = CMIM_FLAGS | CMIM_NAME | CMIM_ICON; @@ -209,8 +209,8 @@ int __cdecl onRebuildContactMenu(WPARAM wParam,LPARAM lParam) { mi.flags = CMIM_FLAGS | CMIM_ICON; for(i=0;imode!=MODE_PGP && !bPGP ) continue; - if( i==MODE_GPG && ptr->mode!=MODE_GPG && !bGPG ) continue; + if ( i==MODE_PGP && ptr->mode!=MODE_PGP && !bPGP ) continue; + if ( i==MODE_GPG && ptr->mode!=MODE_GPG && !bGPG ) continue; mi.hIcon = (i == ptr->mode) ? g_hICO[ICO_ST_ENA] : NULL; CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)g_hMenu[11+i],(LPARAM)&mi); } diff --git a/plugins/SecureIM/svcs_menu.cpp b/plugins/SecureIM/svcs_menu.cpp index 95b08dd5a0..310d367e1b 100644 --- a/plugins/SecureIM/svcs_menu.cpp +++ b/plugins/SecureIM/svcs_menu.cpp @@ -12,7 +12,7 @@ INT_PTR __cdecl Service_CreateIM(WPARAM wParam,LPARAM lParam){ CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)wParam, (LPARAM)szModuleName); // WPARAM flags = 0; // HANDLE hMetaContact = getMetaContact((HANDLE)wParam); -// if( hMetaContact ) { +// if ( hMetaContact ) { // wParam = (WPARAM)hMetaContact; // flags = PREF_METANODB; // } @@ -24,7 +24,7 @@ INT_PTR __cdecl Service_CreateIM(WPARAM wParam,LPARAM lParam){ INT_PTR __cdecl Service_DisableIM(WPARAM wParam,LPARAM lParam) { // WPARAM flags = 0; // HANDLE hMetaContact = getMetaContact((HANDLE)wParam); -// if( hMetaContact ) { +// if ( hMetaContact ) { // wParam = (WPARAM)hMetaContact; // flags = PREF_METANODB; // } @@ -111,7 +111,7 @@ INT_PTR __cdecl Service_PGPsetKey(WPARAM wParam, LPARAM lParam) { else if(bPGPprivkey) { char KeyPath[MAX_PATH]; KeyPath[0]='\0'; - if(ShowSelectKeyDlg(0,KeyPath)){ + if(ShowSelectKeyDlg(0,KeyPath)) { char *publ = LoadKeys(KeyPath,false); if(publ) { DBDeleteContactSetting((HANDLE)wParam,szModuleName,"pgp"); @@ -178,18 +178,18 @@ INT_PTR __cdecl Service_Mode(WPARAM wParam, LPARAM lParam) { switch(--lParam) { case MODE_NATIVE: case MODE_RSAAES: - if( isContactSecured((HANDLE)wParam)&SECURED ) { + if ( isContactSecured((HANDLE)wParam)&SECURED ) { msgbox(NULL, sim111, szModuleName, MB_OK); return 0; } - if( lParam!=MODE_NATIVE && ptr->status>STATUS_ENABLED ) { + if ( lParam!=MODE_NATIVE && ptr->status>STATUS_ENABLED ) { Service_Status(wParam,STATUS_ENABLED+1); } case MODE_PGP: case MODE_GPG: // нужно много проверок и отключение активного контекста если необходимо if(ptr) { - if( ptr->cntx ) { + if ( ptr->cntx ) { cpp_delete_context(ptr->cntx); ptr->cntx = 0; ptr->keyLoaded = 0; diff --git a/plugins/SecureIM/svcs_popup.cpp b/plugins/SecureIM/svcs_popup.cpp index 6c0f97a1a3..bb1eb88355 100644 --- a/plugins/SecureIM/svcs_popup.cpp +++ b/plugins/SecureIM/svcs_popup.cpp @@ -31,7 +31,7 @@ void showPopupMsg(HANDLE hContact, LPCSTR lpzText, HICON hIcon, int type) { // 6 - msg sent // - if(!bPopupExists) return; + if (!bPopupExists) return; char nback[32]; mir_snprintf(nback,sizeof(nback),"popup%dback", $type); char ntext[32]; mir_snprintf(ntext,sizeof(ntext),"popup%dtext", $type); @@ -41,7 +41,7 @@ void showPopupMsg(HANDLE hContact, LPCSTR lpzText, HICON hIcon, int type) { COLORREF colorText = (COLORREF)DBGetContactSettingDword(0,szModuleName,ntext,(DWORD)RGB(0,0,0)); int timeout = (int)DBGetContactSettingWord(0,szModuleName,ntime,0); - if( bCoreUnicode && bPopupUnicode ) { + if ( bCoreUnicode && bPopupUnicode ) { POPUPDATAW ppd; memset(&ppd,0,sizeof(POPUPDATAW)); ppd.lchContact = hContact; diff --git a/plugins/SecureIM/svcs_proto.cpp b/plugins/SecureIM/svcs_proto.cpp index e6e538c60a..a69d7d720d 100644 --- a/plugins/SecureIM/svcs_proto.cpp +++ b/plugins/SecureIM/svcs_proto.cpp @@ -7,7 +7,7 @@ int getSecureSig(LPCSTR szMsg, LPSTR *szPlainMsg=NULL) { for(int i=0;signs[i].len;i++) { if (memcmp(szMsg,signs[i].sig,signs[i].len)==0) { /* for(int i=strlen(szMsg)-1;i;i--) { - if( szMsg[i] == '\x0D' || szMsg[i] == '\x0A' ) + if ( szMsg[i] == '\x0D' || szMsg[i] == '\x0A' ) ((LPSTR)szMsg)[i] = '\0'; else break; @@ -56,7 +56,7 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) { #endif // cut rtf tags - if( pRtfconvString && memcmp(szEncMsg,"{\\rtf1",6)==0 ) { + if ( pRtfconvString && memcmp(szEncMsg,"{\\rtf1",6)==0 ) { SAFE_FREE(szUnrtfMsg); int len = (int)strlen(szEncMsg)+1; LPWSTR szTemp = (LPWSTR)mir_alloc(len*sizeof(WCHAR)); @@ -66,7 +66,7 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) { rtfconvA(szEncMsg,szTemp); len = (int)wcslen(szTemp)-1; while(len) { - if( szTemp[len] == 0x0D || szTemp[len] == 0x0A ) + if ( szTemp[len] == 0x0D || szTemp[len] == 0x0A ) szTemp[len] = 0; else break; @@ -87,12 +87,12 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) { BOOL bGPG = isContactGPG(pccsd->hContact); // HANDLE hMetaContact = getMetaContact(pccsd->hContact); -// if( hMetaContact ) { +// if ( hMetaContact ) { // ptr = getUinKey(hMetaContact); // } // pass any unchanged message - if( !ptr || + if ( !ptr || ssig==SiG_GAME || !isSecureProtocol(pccsd->hContact) || (isProtoMetaContacts(pccsd->hContact) && (pccsd->wParam & PREF_SIMNOMETA)) || @@ -106,7 +106,7 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) { } // drop message: fake, unsigned or from invisible contacts - if( isContactInvisible(pccsd->hContact) || ssig==SiG_FAKE ) { + if ( isContactInvisible(pccsd->hContact) || ssig==SiG_FAKE ) { #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("onRecvMsg: drop unhandled (contact invisible or hidden)"); #endif @@ -114,7 +114,7 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) { } // receive non-secure message in secure mode - if( ssig==SiG_NONE && !ptr->msgSplitted ) { + if ( ssig==SiG_NONE && !ptr->msgSplitted ) { #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("onRecvMsg: non-secure message"); #endif @@ -132,11 +132,11 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) { } // received non-pgp secure message from disabled contact - if( ssig!=SiG_PGPM && !bPGP && !bGPG && ptr->status==STATUS_DISABLED ) { + if ( ssig!=SiG_PGPM && !bPGP && !bGPG && ptr->status==STATUS_DISABLED ) { #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("onRecvMsg: message from disabled"); #endif - if( ptr->mode==MODE_NATIVE ) { + if ( ptr->mode==MODE_NATIVE ) { // tell to the other side that we have the plugin disabled with him pccsd->wParam |= PREF_METANODB; pccsd->lParam = (LPARAM) SIG_DISA; @@ -155,7 +155,7 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) { } // combine message splitted by protocol (no tags) - if( ssig==SiG_NONE && ptr->msgSplitted ) { + if ( ssig==SiG_NONE && ptr->msgSplitted ) { #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("onRecvMsg: combine untagged splitted message"); #endif @@ -171,15 +171,15 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) { } // combine message splitted by secureim (with tags) - if( ssig==SiG_SECP || ssig==SiG_PART ) { + if ( ssig==SiG_SECP || ssig==SiG_PART ) { LPSTR msg = combineMessage(ptr,szEncMsg); - if( !msg ) return 1; + if ( !msg ) return 1; szEncMsg = ppre->szMessage = msg; ssig = getSecureSig(msg,&szEncMsg); } // decrypt PGP/GPG message - if( ssig==SiG_PGPM && + if ( ssig==SiG_PGPM && ((bPGPloaded && (bPGPkeyrings || bPGPprivkey))|| (bGPGloaded && bGPGkeyrings)) ) { @@ -187,25 +187,25 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) { Sent_NetLog("onRecvMsg: PGP/GPG message"); #endif szEncMsg = ppre->szMessage; - if( !ptr->cntx ) { + if ( !ptr->cntx ) { ptr->cntx = cpp_create_context(((bGPGloaded && bGPGkeyrings)?CPP_MODE_GPG:CPP_MODE_PGP) | ((DBGetContactSettingByte(pccsd->hContact,szModuleName,"gpgANSI",0))?CPP_MODE_GPG_ANSI:0)); ptr->keyLoaded = 0; } - if(!strstr(szEncMsg,"-----END PGP MESSAGE-----")) + if (!strstr(szEncMsg,"-----END PGP MESSAGE-----")) return 1; // no end tag, don't display it ... LPSTR szNewMsg = NULL; LPSTR szOldMsg = NULL; - if(!ptr->keyLoaded && bPGPloaded) ptr->keyLoaded = LoadKeyPGP(ptr); - if(!ptr->keyLoaded && bGPGloaded) ptr->keyLoaded = LoadKeyGPG(ptr); + if (!ptr->keyLoaded && bPGPloaded) ptr->keyLoaded = LoadKeyPGP(ptr); + if (!ptr->keyLoaded && bGPGloaded) ptr->keyLoaded = LoadKeyGPG(ptr); if(ptr->keyLoaded==1) szOldMsg = pgp_decode(ptr->cntx, szEncMsg); else if(ptr->keyLoaded==2) szOldMsg = gpg_decode(ptr->cntx, szEncMsg); - if(!szOldMsg) { // error while decrypting message, send error + if (!szOldMsg) { // error while decrypting message, send error SAFE_FREE(ptr->msgSplitted); ppre->flags &= ~(PREF_UNICODE|PREF_UTF); pccsd->wParam &= ~(PREF_UNICODE|PREF_UTF); @@ -214,7 +214,7 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) { } // receive encrypted message in non-encrypted mode - if(!isContactPGP(pccsd->hContact) && !isContactGPG(pccsd->hContact)) { + if (!isContactPGP(pccsd->hContact) && !isContactGPG(pccsd->hContact)) { szNewMsg = m_ustrcat(TranslateU(sim403),szOldMsg); szOldMsg = szNewMsg; } @@ -242,18 +242,18 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) { #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("onRecvMsg: RSA/AES message"); #endif - if( ptr->mode==MODE_NATIVE ) { + if ( ptr->mode==MODE_NATIVE ) { ptr->mode = MODE_RSAAES; deleteRSAcntx(ptr); DBWriteContactSettingByte(ptr->hContact, szModuleName, "mode", ptr->mode); } createRSAcntx(ptr); loadRSAkey(ptr); - if( exp->rsa_get_state(ptr->cntx)==0 ) + if ( exp->rsa_get_state(ptr->cntx)==0 ) showPopUpKR(ptr->hContact); LPSTR szOldMsg = exp->rsa_recv(ptr->cntx,szEncMsg); - if( !szOldMsg ) return 1; // don't display it ... + if ( !szOldMsg ) return 1; // don't display it ... LPSTR szNewMsg = utf8_to_miranda(szOldMsg,ppre->flags); pccsd->wParam = ppre->flags; ppre->szMessage = szNewMsg; @@ -271,10 +271,10 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) { #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("onRecvMsg: Native SiG_ENON message"); #endif - if( cpp_keyx(ptr->cntx) ) { + if ( cpp_keyx(ptr->cntx) ) { // decrypting message szPlainMsg = decodeMsg(ptr,lParam,szEncMsg); - if(!ptr->decoded) { + if (!ptr->decoded) { mir_free(szPlainMsg); SAFE_FREE(ptr->msgSplitted); ptr->msgSplitted=mir_strdup(szEncMsg); @@ -322,7 +322,7 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) { DBVARIANT dbv; dbv.type = DBVT_BLOB; - if( DBGetContactSetting(ptr->hContact,szModuleName,"offlineKey",&dbv) == 0 ) { + if ( DBGetContactSetting(ptr->hContact,szModuleName,"offlineKey",&dbv) == 0 ) { // if valid key is succefully retrieved ptr->offlineKey = true; InitKeyX(ptr,dbv.pbVal); @@ -377,7 +377,7 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) { case SiG_KEYR: // key3 message case SiG_KEYA: // keyA message case SiG_KEYB: { // keyB message - if( ptr->mode==MODE_RSAAES ) { + if ( ptr->mode==MODE_RSAAES ) { ptr->mode = MODE_NATIVE; cpp_delete_context(ptr->cntx); ptr->cntx = 0; @@ -392,12 +392,12 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) { // receive KeyB from user; showPopUpKR(ptr->hContact); - if( ptr->cntx && cpp_keyb(ptr->cntx) ) { + if ( ptr->cntx && cpp_keyb(ptr->cntx) ) { // reinit key exchange if an old key from user is found cpp_reset_context(ptr->cntx); } - if( InitKeyB(ptr,szEncMsg)!=CPP_ERROR_NONE ) { + if ( InitKeyB(ptr,szEncMsg)!=CPP_ERROR_NONE ) { #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("onRecvMsg: SiG_KEYR InitKeyB error"); #endif @@ -416,7 +416,7 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) { } // other side support RSA mode ? - if( ptr->features & CPP_FEATURES_RSA ) { + if ( ptr->features & CPP_FEATURES_RSA ) { // switch to RSAAES mode ptr->mode = MODE_RSAAES; DBWriteContactSettingByte(ptr->hContact, szModuleName, "mode", ptr->mode); @@ -431,7 +431,7 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) { } // other side support new key format ? - if( ptr->features & CPP_FEATURES_NEWPG ) { + if ( ptr->features & CPP_FEATURES_NEWPG ) { cpp_reset_context(ptr->cntx); LPSTR keyToSend = InitKeyA(ptr,CPP_FEATURES_NEWPG|KEY_A_SIG); // calculate NEW public and private key @@ -450,7 +450,7 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) { } // auto send my public key to keyB user if not done before - if( !cpp_keya(ptr->cntx) ) { + if ( !cpp_keya(ptr->cntx) ) { LPSTR keyToSend = InitKeyA(ptr,0); // calculate public and private key #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("onRecvMsg: Sending KEYA %s", keyToSend); @@ -510,7 +510,7 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) { showPopUpKR(ptr->hContact); // clear all and send DISA if received KeyB, and not exist KeyA or error on InitKeyB - if(!cpp_keya(ptr->cntx) || InitKeyB(ptr,szEncMsg)!=CPP_ERROR_NONE) { + if (!cpp_keya(ptr->cntx) || InitKeyB(ptr,szEncMsg)!=CPP_ERROR_NONE) { #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("onRecvMsg: SiG_KEYB InitKeyB error"); #endif @@ -534,7 +534,7 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) { /* common part (CalcKeyX & SendQueue) */ // calculate KeyX - if( cpp_keya(ptr->cntx) && cpp_keyb(ptr->cntx) && !cpp_keyx(ptr->cntx) ) + if ( cpp_keya(ptr->cntx) && cpp_keyb(ptr->cntx) && !cpp_keyx(ptr->cntx) ) CalculateKeyX(ptr,ptr->hContact); ShowStatusIconNotify(ptr->hContact); @@ -550,7 +550,7 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) { } //switch // receive message - if( cpp_keyx(ptr->cntx) && (ssig==SiG_ENON||ssig==SiG_ENOF) ) { + if ( cpp_keyx(ptr->cntx) && (ssig==SiG_ENON||ssig==SiG_ENOF) ) { #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("onRecvMsg: message received"); #endif @@ -568,10 +568,10 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) { // SendMsgW handler INT_PTR __cdecl onSendMsgW(WPARAM wParam, LPARAM lParam) { - if(!lParam) return 0; + if (!lParam) return 0; CCSDATA *ccs = (CCSDATA *) lParam; - if( !(ccs->wParam & PREF_UTF) ) + if ( !(ccs->wParam & PREF_UTF) ) ccs->wParam |= PREF_UNICODE; return onSendMsg(wParam, lParam); @@ -587,7 +587,7 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) { int stat = getContactStatus(pccsd->hContact); // HANDLE hMetaContact = getMetaContact(pccsd->hContact); -// if( hMetaContact ) { +// if ( hMetaContact ) { // ptr = getUinKey(hMetaContact); // } #if defined(_DEBUG) || defined(NETLIB_LOG) @@ -611,12 +611,12 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) { // // PGP/GPG mode // - if( ptr->mode==MODE_PGP || ptr->mode==MODE_GPG ) { + if ( ptr->mode==MODE_PGP || ptr->mode==MODE_GPG ) { #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("onSendMsg: PGP|GPG mode"); #endif // если можно зашифровать - шифруем - if( isContactPGP(ptr->hContact) || isContactGPG(ptr->hContact) ) { + if ( isContactPGP(ptr->hContact) || isContactGPG(ptr->hContact) ) { /* if(stat==ID_STATUS_OFFLINE) { if (msgbox1(0,sim110,szModuleName,MB_YESNO|MB_ICONQUESTION)==IDNO) { @@ -626,25 +626,25 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) { return CallService(MS_PROTO_CHAINSEND, wParam, lParam); } */ - if( !ptr->cntx ) { + if ( !ptr->cntx ) { ptr->cntx = cpp_create_context((isContactGPG(ptr->hContact)?CPP_MODE_GPG:CPP_MODE_PGP) | ((DBGetContactSettingByte(ptr->hContact,szModuleName,"gpgANSI",0))?CPP_MODE_GPG_ANSI:0)); ptr->keyLoaded = 0; } - if( !ptr->keyLoaded && bPGPloaded ) ptr->keyLoaded = LoadKeyPGP(ptr); - if( !ptr->keyLoaded && bGPGloaded ) ptr->keyLoaded = LoadKeyGPG(ptr); - if( !ptr->keyLoaded ) return returnError(pccsd->hContact,Translate(sim108)); + if ( !ptr->keyLoaded && bPGPloaded ) ptr->keyLoaded = LoadKeyPGP(ptr); + if ( !ptr->keyLoaded && bGPGloaded ) ptr->keyLoaded = LoadKeyGPG(ptr); + if ( !ptr->keyLoaded ) return returnError(pccsd->hContact,Translate(sim108)); LPSTR szNewMsg = NULL; LPSTR szUtfMsg = miranda_to_utf8((LPCSTR)pccsd->lParam,pccsd->wParam); - if( ptr->keyLoaded == 1 ) { // PGP + if ( ptr->keyLoaded == 1 ) { // PGP szNewMsg = pgp_encode(ptr->cntx,szUtfMsg); } else - if( ptr->keyLoaded == 2 ) { // GPG + if ( ptr->keyLoaded == 2 ) { // GPG szNewMsg = gpg_encode(ptr->cntx,szUtfMsg); } mir_free(szUtfMsg); - if( !szNewMsg ) { + if ( !szNewMsg ) { return returnError(pccsd->hContact,Translate(sim109)); } @@ -667,22 +667,22 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) { // // RSA/AES mode // - if( ptr->mode==MODE_RSAAES ) { + if ( ptr->mode==MODE_RSAAES ) { #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("onSendMsg: RSA/AES mode"); #endif // contact is offline if ( stat==ID_STATUS_OFFLINE ) { - if( ptr->cntx ) { - if( exp->rsa_get_state(ptr->cntx)!=0 ) { + if ( ptr->cntx ) { + if ( exp->rsa_get_state(ptr->cntx)!=0 ) { resetRSAcntx(ptr); } } else { createRSAcntx(ptr); } - if( !bSOM || (!isClientMiranda(ptr,1) && !isSecureIM(ptr,1)) || !loadRSAkey(ptr) ) { - if( ssig==SiG_NONE ) { + if ( !bSOM || (!isClientMiranda(ptr,1) && !isSecureIM(ptr,1)) || !loadRSAkey(ptr) ) { + if ( ssig==SiG_NONE ) { // просто шлем незашифрованное в оффлайн return CallService(MS_PROTO_CHAINSEND, wParam, lParam); } @@ -699,12 +699,12 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) { return returnNoError(pccsd->hContact); } // SecureIM connection with this contact is disabled - if( stid==STATUS_DISABLED ) { - if( ptr->cntx ) { + if ( stid==STATUS_DISABLED ) { + if ( ptr->cntx ) { exp->rsa_disabled(ptr->cntx); deleteRSAcntx(ptr); } - if( ssig==SiG_NONE ) { + if ( ssig==SiG_NONE ) { // просто шлем незашифрованное return CallService(MS_PROTO_CHAINSEND, wParam, lParam); } @@ -712,8 +712,8 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) { return returnNoError(pccsd->hContact); } // разорвать соединение - if( ssig==SiG_DEIN ) { - if( ptr->cntx ) { + if ( ssig==SiG_DEIN ) { + if ( ptr->cntx ) { exp->rsa_disconnect(ptr->cntx); deleteRSAcntx(ptr); } @@ -721,7 +721,7 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) { return returnNoError(pccsd->hContact); } // соединение установлено - if( ptr->cntx && exp->rsa_get_state(ptr->cntx)==7 ) { + if ( ptr->cntx && exp->rsa_get_state(ptr->cntx)==7 ) { LPSTR szUtfMsg = miranda_to_utf8((LPCSTR)pccsd->lParam,pccsd->wParam); exp->rsa_send(ptr->cntx,szUtfMsg); mir_free(szUtfMsg); @@ -729,7 +729,7 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) { return returnNoError(pccsd->hContact); } // просто сообщение (без тэгов, нет контекста и работают AIP & NOL) - if( ssig==SiG_NONE && isSecureIM(ptr->hContact) ) { + if ( ssig==SiG_NONE && isSecureIM(ptr->hContact) ) { // добавим его в очередь addMsg2Queue(ptr, pccsd->wParam, (LPSTR)pccsd->lParam); // запускаем процесс установки соединения @@ -738,7 +738,7 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) { waitForExchange(ptr); } // установить соединение - if( ssig==SiG_INIT ) { + if ( ssig==SiG_INIT ) { createRSAcntx(ptr); loadRSAkey(ptr); exp->rsa_connect(ptr->cntx); @@ -758,12 +758,12 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) { #endif // SecureIM connection with this contact is disabled - if( stid==STATUS_DISABLED ) { + if ( stid==STATUS_DISABLED ) { #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("onSendMsg: message for Disabled"); #endif // if user try initialize connection - if( ssig==SiG_INIT ) { + if ( ssig==SiG_INIT ) { // secure IM is disabled ... return returnError(pccsd->hContact,Translate(sim105)); } @@ -785,17 +785,17 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) { } // contact is offline - if( stat==ID_STATUS_OFFLINE ) { + if ( stat==ID_STATUS_OFFLINE ) { #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("onSendMsg: message for offline"); #endif - if( ssig==SiG_INIT && cpp_keyx(ptr->cntx) ) { + if ( ssig==SiG_INIT && cpp_keyx(ptr->cntx) ) { // reinit key exchange cpp_reset_context(ptr->cntx); } - if( !bSOM ) { - if( ssig!=SiG_NONE ) { + if ( !bSOM ) { + if ( ssig!=SiG_NONE ) { return returnNoError(pccsd->hContact); } // exit and send unencrypted message @@ -803,10 +803,10 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) { } BOOL isMiranda = isClientMiranda(ptr->hContact); - if( stid==STATUS_ALWAYSTRY && isMiranda ) { // always try && Miranda + if ( stid==STATUS_ALWAYSTRY && isMiranda ) { // always try && Miranda // set key for offline user DBVARIANT dbv; dbv.type = DBVT_BLOB; - if( DBGetContactSettingDword(ptr->hContact, szModuleName, "offlineKeyTimeout", 0) > gettime() && + if ( DBGetContactSettingDword(ptr->hContact, szModuleName, "offlineKeyTimeout", 0) > gettime() && DBGetContactSetting(ptr->hContact, szModuleName, "offlineKey", &dbv) == 0 ) { // if valid key is succefully retrieved @@ -829,7 +829,7 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) { int res=msgbox1(0,"User is offline now, Do you want to send your message ?\nIt will be unencrypted !","Can't Send Encrypted Message !",MB_YESNO); if (res==IDNO) return 1; }*/ - if( ssig!=SiG_NONE ) { + if ( ssig!=SiG_NONE ) { return returnNoError(pccsd->hContact); } // exit and send unencrypted message @@ -842,7 +842,7 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) { Sent_NetLog("onSendMsg: message for online"); #endif // contact is online and we use an offline key -> reset offline key - if( ptr->offlineKey ) { + if ( ptr->offlineKey ) { cpp_reset_context(ptr->cntx); ptr->offlineKey = false; ShowStatusIconNotify(ptr->hContact); @@ -850,7 +850,7 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) { } // if init is called from contact menu list reinit secure im connection - if( ssig==SiG_INIT ) { + if ( ssig==SiG_INIT ) { #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("onSendMsg: SiG_INIT"); #endif @@ -858,7 +858,7 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) { } // if deinit is called from contact menu list deinit secure im connection - if( ssig==SiG_DEIN ) { + if ( ssig==SiG_DEIN ) { #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("onSendMsg: SiG_DEIN"); #endif @@ -875,17 +875,17 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) { return returnNoError(pccsd->hContact); } - if( cpp_keya(ptr->cntx) && cpp_keyb(ptr->cntx) && !cpp_keyx(ptr->cntx) ) + if ( cpp_keya(ptr->cntx) && cpp_keyb(ptr->cntx) && !cpp_keyx(ptr->cntx) ) CalculateKeyX(ptr,ptr->hContact); ShowStatusIconNotify(pccsd->hContact); // if cryptokey exist - if( cpp_keyx(ptr->cntx) ) { + if ( cpp_keyx(ptr->cntx) ) { #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("onSendMsg: cryptokey exist"); #endif -/* if( !hMetaContact && isProtoMetaContacts(pccsd->hContact) && (DBGetContactSettingByte(NULL, "MetaContacts", "SubcontactHistory", 1) == 1)) { +/* if ( !hMetaContact && isProtoMetaContacts(pccsd->hContact) && (DBGetContactSettingByte(NULL, "MetaContacts", "SubcontactHistory", 1) == 1)) { // add sent event to subcontact DBEVENTINFO dbei; HANDLE hC = getMostOnline(pccsd->hContact); ZeroMemory(&dbei, sizeof(dbei)); @@ -926,11 +926,11 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) { Sent_NetLog("onSendMsg: cryptokey not exist, try establishe connection"); #endif // send KeyA if init || always_try || waitkey || always_if_possible - if( ssig==SiG_INIT || (stid==STATUS_ALWAYSTRY && isClientMiranda(ptr->hContact)) || isSecureIM(ptr->hContact) || ptr->waitForExchange ) { + if ( ssig==SiG_INIT || (stid==STATUS_ALWAYSTRY && isClientMiranda(ptr->hContact)) || isSecureIM(ptr->hContact) || ptr->waitForExchange ) { if (ssig==SiG_NONE) { addMsg2Queue(ptr, pccsd->wParam, (LPSTR)pccsd->lParam); } - if( !ptr->waitForExchange ) { + if ( !ptr->waitForExchange ) { // init || always_try || always_if_possible LPSTR keyToSend = InitKeyA(ptr,0); // calculate public and private key & fill KeyA #if defined(_DEBUG) || defined(NETLIB_LOG) @@ -967,7 +967,7 @@ INT_PTR __cdecl onSendFile(WPARAM wParam, LPARAM lParam) { pUinKey ptr = getUinKey(pccsd->hContact); if (!ptr || !bSFT) return CallService(PSS_FILE, wParam, lParam); - if( isContactSecured(pccsd->hContact)&SECURED ) { + if ( isContactSecured(pccsd->hContact)&SECURED ) { char **file=(char **)pccsd->lParam; if(file_idx==100) file_idx=0; @@ -977,7 +977,7 @@ INT_PTR __cdecl onSendFile(WPARAM wParam, LPARAM lParam) { if (strstr(file[i],".AESHELL")) continue; char *name = strrchr(file[i],'\\'); - if( !name ) name = file[i]; + if ( !name ) name = file[i]; else name++; char *file_out = (char*) mir_alloc(TEMP_SIZE+strlen(name)+20); @@ -987,7 +987,7 @@ INT_PTR __cdecl onSendFile(WPARAM wParam, LPARAM lParam) { sprintf(buf,"%s\n%s",Translate(sim011),file[i]); showPopUp(buf,NULL,g_hPOP[POP_PU_MSS],2); - if( ptr->mode==MODE_RSAAES ) { + if ( ptr->mode==MODE_RSAAES ) { exp->rsa_encrypt_file(ptr->cntx,file[i],file_out); } else { @@ -997,13 +997,13 @@ INT_PTR __cdecl onSendFile(WPARAM wParam, LPARAM lParam) { mir_free(file[i]); file[i]=file_out; } - if( ptr->fileSend ) { // очистим сохраненный список + if ( ptr->fileSend ) { // очистим сохраненный список for(int j=0;ptr->fileSend[j];j++) { mir_free(ptr->fileSend[j]); } SAFE_FREE(ptr->fileSend); } - if( i ) { // скопируем новый список + if ( i ) { // скопируем новый список ptr->fileSend = (char **) mir_alloc(sizeof(char*)*(i+1)); for(i=0;file[i];i++) { ptr->fileSend[i] = mir_strdup(file[i]); @@ -1042,35 +1042,35 @@ int __cdecl onProtoAck(WPARAM wParam,LPARAM lParam) { pUinKey ptr = getUinKey(ack->hContact); if (!ptr || (f && (f->flags & PFTS_SENDING) && !bSFT)) return 0; - if( isContactSecured(ack->hContact)&SECURED ) { + if ( isContactSecured(ack->hContact)&SECURED ) { switch(ack->result) { // case ACKRESULT_FILERESUME: case ACKRESULT_DATA: { - if( !( f->flags & PFTS_SENDING )) { + if ( !( f->flags & PFTS_SENDING )) { ptr->finFileRecv = (f->currentFileSize == f->currentFileProgress); - if( !ptr->lastFileRecv ) ptr->lastFileRecv = mir_strdup(f->szCurrentFile); + if ( !ptr->lastFileRecv ) ptr->lastFileRecv = mir_strdup(f->szCurrentFile); } else - if( f->flags & PFTS_SENDING ) { + if ( f->flags & PFTS_SENDING ) { ptr->finFileSend = (f->currentFileSize == f->currentFileProgress); - if( !ptr->lastFileSend ) ptr->lastFileSend = mir_strdup(f->szCurrentFile); + if ( !ptr->lastFileSend ) ptr->lastFileSend = mir_strdup(f->szCurrentFile); } } break; // case ACKRESULT_INITIALISING: case ACKRESULT_DENIED: case ACKRESULT_FAILED: { - if( ptr->lastFileRecv ) { + if ( ptr->lastFileRecv ) { if (strstr(ptr->lastFileRecv,".AESHELL")) mir_unlink(ptr->lastFileRecv); SAFE_FREE(ptr->lastFileRecv); } - if( ptr->lastFileSend ) { + if ( ptr->lastFileSend ) { if (strstr(ptr->lastFileSend,".AESHELL")) mir_unlink(ptr->lastFileSend); SAFE_FREE(ptr->lastFileSend); } - if( ptr->fileSend ) { + if ( ptr->fileSend ) { char **file=ptr->fileSend; for(int j=0;file[j];j++) { - if( strstr(file[j],".AESHELL") ) mir_unlink(file[j]); + if ( strstr(file[j],".AESHELL") ) mir_unlink(file[j]); mir_free(file[j]); } SAFE_FREE(ptr->fileSend); @@ -1079,14 +1079,14 @@ int __cdecl onProtoAck(WPARAM wParam,LPARAM lParam) { } break; case ACKRESULT_NEXTFILE: case ACKRESULT_SUCCESS: { - if( ptr->finFileRecv && ptr->lastFileRecv ) { - if( strstr(ptr->lastFileRecv,".AESHELL") ) { + if ( ptr->finFileRecv && ptr->lastFileRecv ) { + if ( strstr(ptr->lastFileRecv,".AESHELL") ) { char buf[MAX_PATH]; LPSTR file_out=mir_strdup(ptr->lastFileRecv); LPSTR pos=strrchr(file_out,'.'); //find last . if (pos) *pos='\0'; //remove AESHELL from name - if( isFileExist(file_out) ) { + if ( isFileExist(file_out) ) { buf[0]='\0'; LPSTR p=strrchr(file_out,'.'); LPSTR x=strrchr(file_out,'\\'); @@ -1096,14 +1096,14 @@ int __cdecl onProtoAck(WPARAM wParam,LPARAM lParam) { } for(int i=1;i<10000;i++) { sprintf(pos," (%d)%s",i,buf); - if( !isFileExist(file_out) ) break; + if ( !isFileExist(file_out) ) break; } } sprintf(buf,"%s\n%s",Translate(sim012),file_out); showPopUp(buf,NULL,g_hPOP[POP_PU_MSR],2); - if( ptr->mode==MODE_RSAAES ) { + if ( ptr->mode==MODE_RSAAES ) { exp->rsa_decrypt_file(ptr->cntx,ptr->lastFileRecv,file_out); } else { @@ -1115,8 +1115,8 @@ int __cdecl onProtoAck(WPARAM wParam,LPARAM lParam) { SAFE_FREE(ptr->lastFileRecv); ptr->finFileRecv = false; } - if( ptr->finFileSend && ptr->lastFileSend ) { - if( strstr(ptr->lastFileSend,".AESHELL") ) mir_unlink(ptr->lastFileSend); + if ( ptr->finFileSend && ptr->lastFileSend ) { + if ( strstr(ptr->lastFileSend,".AESHELL") ) mir_unlink(ptr->lastFileSend); SAFE_FREE(ptr->lastFileSend); ptr->finFileSend = false; } diff --git a/plugins/SecureIM/svcs_rsa.cpp b/plugins/SecureIM/svcs_rsa.cpp index d38de67455..e72221dc91 100644 --- a/plugins/SecureIM/svcs_rsa.cpp +++ b/plugins/SecureIM/svcs_rsa.cpp @@ -12,7 +12,7 @@ BOOL rsa_4096=0; int __cdecl rsa_inject(HANDLE context, LPCSTR msg) { - pUinKey ptr = getUinCtx(context); if(!ptr) return 0; + pUinKey ptr = getUinCtx(context); if (!ptr) return 0; #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("rsa_inject: '%s'", msg); #endif @@ -31,7 +31,7 @@ int __cdecl rsa_inject(HANDLE context, LPCSTR msg) { int __cdecl rsa_check_pub(HANDLE context, PBYTE pub, int pubLen, PBYTE sig, int sigLen) { int v=0, k=0; - pUinKey ptr = getUinCtx(context); if(!ptr) return 0; + pUinKey ptr = getUinCtx(context); if (!ptr) return 0; LPSTR cnm = (LPSTR) mir_alloc(NAMSIZE); getContactNameA(ptr->hContact,cnm); LPSTR uin = (LPSTR) mir_alloc(KEYSIZE); getContactUinA(ptr->hContact,uin); LPSTR msg = (LPSTR) mir_alloc(MSGSIZE); @@ -42,15 +42,15 @@ int __cdecl rsa_check_pub(HANDLE context, PBYTE pub, int pubLen, PBYTE sig, int #endif DBVARIANT dbv; dbv.type = DBVT_BLOB; - if( DBGetContactSetting(ptr->hContact,szModuleName,"rsa_pub",&dbv) == 0 ) { + if ( DBGetContactSetting(ptr->hContact,szModuleName,"rsa_pub",&dbv) == 0 ) { k = 1; PBYTE buf = (PBYTE) alloca(sigLen); int len; exp->rsa_get_hash((PBYTE)dbv.pbVal,dbv.cpbVal,(PBYTE)buf,&len); sha_old = mir_strdup(to_hex(buf,len)); DBFreeVariant(&dbv); } - if( bAAK ) { - if( k ) mir_snprintf(msg,MSGSIZE,Translate(sim523),cnm,uin,sha,sha_old); + if ( bAAK ) { + if ( k ) mir_snprintf(msg,MSGSIZE,Translate(sim523),cnm,uin,sha,sha_old); else mir_snprintf(msg,MSGSIZE,Translate(sim521),cnm,uin,sha); showPopUpKRmsg(ptr->hContact,msg); HistoryLog(ptr->hContact,msg); @@ -60,7 +60,7 @@ int __cdecl rsa_check_pub(HANDLE context, PBYTE pub, int pubLen, PBYTE sig, int #endif } else { - if( k ) mir_snprintf(msg,MSGSIZE,Translate(sim522),cnm,sha,sha_old); + if ( k ) mir_snprintf(msg,MSGSIZE,Translate(sim522),cnm,sha,sha_old); else mir_snprintf(msg,MSGSIZE,Translate(sim520),cnm,sha); v = (msgbox(0,msg,szModuleName,MB_YESNO|MB_ICONQUESTION)==IDYES); #if defined(_DEBUG) || defined(NETLIB_LOG) @@ -87,7 +87,7 @@ int __cdecl rsa_check_pub(HANDLE context, PBYTE pub, int pubLen, PBYTE sig, int void __cdecl rsa_notify(HANDLE context, int state) { - pUinKey ptr = getUinCtx(context); if(!ptr) return; + pUinKey ptr = getUinCtx(context); if (!ptr) return; LPCSTR msg=NULL; #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("rsa_notify: 0x%x", state); @@ -182,10 +182,10 @@ unsigned __stdcall sttGenerateRSA( LPVOID param ) { // загружает паблик-ключ в RSA контекст BYTE loadRSAkey(pUinKey ptr) { - if( !ptr->keyLoaded ) { + if ( !ptr->keyLoaded ) { DBVARIANT dbv; dbv.type = DBVT_BLOB; - if( DBGetContactSetting(ptr->hContact,szModuleName,"rsa_pub",&dbv) == 0 ) { + if ( DBGetContactSetting(ptr->hContact,szModuleName,"rsa_pub",&dbv) == 0 ) { ptr->keyLoaded = exp->rsa_set_pubkey(ptr->cntx,dbv.pbVal,dbv.cpbVal); #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("loadRSAkey %d", ptr->keyLoaded); @@ -198,7 +198,7 @@ BYTE loadRSAkey(pUinKey ptr) { // создает RSA контекст void createRSAcntx(pUinKey ptr) { - if( !ptr->cntx ) { + if ( !ptr->cntx ) { ptr->cntx = cpp_create_context(CPP_MODE_RSA); ptr->keyLoaded = 0; } @@ -207,7 +207,7 @@ void createRSAcntx(pUinKey ptr) { // пересоздает RSA контекст void resetRSAcntx(pUinKey ptr) { - if( ptr->cntx ) { + if ( ptr->cntx ) { cpp_delete_context(ptr->cntx); ptr->cntx = cpp_create_context(CPP_MODE_RSA); ptr->keyLoaded = 0; diff --git a/plugins/SecureIM/svcs_srmm.cpp b/plugins/SecureIM/svcs_srmm.cpp index c187ff7b56..ea7b8be780 100644 --- a/plugins/SecureIM/svcs_srmm.cpp +++ b/plugins/SecureIM/svcs_srmm.cpp @@ -13,11 +13,11 @@ int __cdecl onWindowEvent(WPARAM wParam, LPARAM lParam) { int __cdecl onIconPressed(WPARAM wParam, LPARAM lParam) { HANDLE hContact = (HANDLE)wParam; - if( isProtoMetaContacts(hContact) ) + if ( isProtoMetaContacts(hContact) ) hContact = getMostOnline(hContact); // возьмем тот, через который пойдет сообщение StatusIconClickData *sicd = (StatusIconClickData *)lParam; - if( strcmp(sicd->szModule, szModuleName) != 0 || + if ( strcmp(sicd->szModule, szModuleName) != 0 || !isSecureProtocol(hContact) ) return 0; // not our event BOOL isPGP = isContactPGP(hContact); @@ -25,7 +25,7 @@ int __cdecl onIconPressed(WPARAM wParam, LPARAM lParam) { BOOL isSecured = isContactSecured(hContact)&SECURED; BOOL isChat = isChatRoom(hContact); - if( !isPGP && !isGPG && !isChat ) { + if ( !isPGP && !isGPG && !isChat ) { if(isSecured) Service_DisableIM(wParam,0); else Service_CreateIM(wParam,0); } -- cgit v1.2.3