From 62ab18a9fda2f19c08ae63a14c7a262ca62f0cce Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 8 Jul 2014 15:49:18 +0000 Subject: code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@9732 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/SecureIM/secureim_10.vcxproj | 1 - plugins/SecureIM/secureim_10.vcxproj.filters | 3 - plugins/SecureIM/secureim_12.vcxproj | 1 - plugins/SecureIM/secureim_12.vcxproj.filters | 3 - plugins/SecureIM/src/commonheaders.cpp | 57 +- plugins/SecureIM/src/crypt.h | 5 - plugins/SecureIM/src/crypt_check.cpp | 20 +- plugins/SecureIM/src/crypt_dll.cpp | 117 ++-- plugins/SecureIM/src/crypt_icons.cpp | 24 +- plugins/SecureIM/src/crypt_lists.cpp | 73 ++- plugins/SecureIM/src/crypt_metacontacts.cpp | 29 - plugins/SecureIM/src/crypt_misc.cpp | 21 +- plugins/SecureIM/src/crypt_popups.cpp | 38 +- plugins/SecureIM/src/dbevent.cpp | 6 +- plugins/SecureIM/src/gettime.cpp | 6 +- plugins/SecureIM/src/images.cpp | 151 ++--- plugins/SecureIM/src/language.cpp | 3 - plugins/SecureIM/src/loadicons.cpp | 50 +- plugins/SecureIM/src/loadlib.cpp | 124 ++-- plugins/SecureIM/src/main.cpp | 154 +++-- plugins/SecureIM/src/mmi.cpp | 142 ++--- plugins/SecureIM/src/options.cpp | 910 +++++++++++++-------------- plugins/SecureIM/src/popupOptions.cpp | 66 +- plugins/SecureIM/src/rtfconv.cpp | 58 +- plugins/SecureIM/src/splitmsg.cpp | 88 ++- plugins/SecureIM/src/svcs_clist.cpp | 51 +- plugins/SecureIM/src/svcs_menu.cpp | 63 +- plugins/SecureIM/src/svcs_proto.cpp | 300 +++++---- plugins/SecureIM/src/svcs_rsa.cpp | 97 ++- plugins/SecureIM/src/svcs_srmm.cpp | 24 +- 30 files changed, 1269 insertions(+), 1416 deletions(-) delete mode 100644 plugins/SecureIM/src/crypt_metacontacts.cpp (limited to 'plugins') diff --git a/plugins/SecureIM/secureim_10.vcxproj b/plugins/SecureIM/secureim_10.vcxproj index d2c59bc198..156bf385bd 100644 --- a/plugins/SecureIM/secureim_10.vcxproj +++ b/plugins/SecureIM/secureim_10.vcxproj @@ -218,7 +218,6 @@ - diff --git a/plugins/SecureIM/secureim_10.vcxproj.filters b/plugins/SecureIM/secureim_10.vcxproj.filters index 1c91709e99..ececb6efdf 100644 --- a/plugins/SecureIM/secureim_10.vcxproj.filters +++ b/plugins/SecureIM/secureim_10.vcxproj.filters @@ -36,9 +36,6 @@ Source Files - - Source Files - Source Files diff --git a/plugins/SecureIM/secureim_12.vcxproj b/plugins/SecureIM/secureim_12.vcxproj index 8c40e832fb..e158f71170 100644 --- a/plugins/SecureIM/secureim_12.vcxproj +++ b/plugins/SecureIM/secureim_12.vcxproj @@ -221,7 +221,6 @@ - diff --git a/plugins/SecureIM/secureim_12.vcxproj.filters b/plugins/SecureIM/secureim_12.vcxproj.filters index 1c91709e99..ececb6efdf 100644 --- a/plugins/SecureIM/secureim_12.vcxproj.filters +++ b/plugins/SecureIM/secureim_12.vcxproj.filters @@ -36,9 +36,6 @@ Source Files - - Source Files - Source Files diff --git a/plugins/SecureIM/src/commonheaders.cpp b/plugins/SecureIM/src/commonheaders.cpp index 459c34a3b9..ce80378c5c 100644 --- a/plugins/SecureIM/src/commonheaders.cpp +++ b/plugins/SecureIM/src/commonheaders.cpp @@ -8,11 +8,11 @@ int TEMP_SIZE = 0; HANDLE g_hEvent[2], g_hCLIcon, g_hFolders = 0; HGENMENU g_hMenu[15]; -int iService=0; -int iHook=0; +int iService = 0; +int iHook = 0; -HICON g_hICO[ICO_CNT], g_hPOP[POP_CNT], g_hIEC[1+IEC_CNT*MODE_CNT] = {0}; -HANDLE g_IEC[1+IEC_CNT*MODE_CNT]; +HICON g_hICO[ICO_CNT], g_hPOP[POP_CNT], g_hIEC[1 + IEC_CNT*MODE_CNT] = { 0 }; +HANDLE g_IEC[1 + IEC_CNT*MODE_CNT]; int iBmpDepth; BOOL bPopupExists = false; @@ -34,25 +34,25 @@ PLUGININFOEX pluginInfoEx = { __AUTHORWEB, UNICODE_AWARE, // {1B2A39E5-E2F6-494D-958D-1808FD110DD5} - {0x1B2A39E5, 0xE2F6, 0x494D, {0x95, 0x8D, 0x18, 0x08, 0xFD, 0x11, 0x0D, 0xD5}} + { 0x1B2A39E5, 0xE2F6, 0x494D, { 0x95, 0x8D, 0x18, 0x08, 0xFD, 0x11, 0x0D, 0xD5 } } }; -LPSTR myDBGetStringDecode(MCONTACT hContact,const char *szModule,const char *szSetting) +LPSTR myDBGetStringDecode(MCONTACT hContact, const char *szModule, const char *szSetting) { - char *val = db_get_sa(hContact,szModule,szSetting); + char *val = db_get_sa(hContact, szModule, szSetting); if (!val) return NULL; - size_t len = strlen(val)+64; + size_t len = strlen(val) + 64; char *buf = (LPSTR)mir_alloc(len); - strncpy(buf,val,len); mir_free(val); + strncpy(buf, val, len); mir_free(val); return buf; } -int myDBWriteStringEncode(MCONTACT hContact,const char *szModule,const char *szSetting,const char *val) +int myDBWriteStringEncode(MCONTACT hContact, const char *szModule, const char *szSetting, const char *val) { - int len = (int)strlen(val)+64; + int len = (int)strlen(val) + 64; char *buf = (LPSTR)alloca(len); - strncpy(buf,val,len); - int ret = db_set_s(hContact,szModule,szSetting,buf); + strncpy(buf, val, len); + int ret = db_set_s(hContact, szModule, szSetting, buf); return ret; } @@ -88,26 +88,23 @@ int msgbox(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType) { LPWSTR lpwText = mir_a2u(lpText); LPWSTR lpwCaption = mir_a2u(lpCaption); - int r = MessageBoxW(hWnd,TranslateW(lpwText),TranslateW(lpwCaption),uType); + int r = MessageBoxW(hWnd, TranslateW(lpwText), TranslateW(lpwCaption), uType); mir_free(lpwCaption); mir_free(lpwText); return r; } -void CopyToClipboard(HWND hwnd,LPSTR msg) +void CopyToClipboard(HWND hwnd, LPSTR msg) { - HGLOBAL hglbCopy; - LPSTR lpstrCopy; - - hglbCopy = GlobalAlloc(GMEM_MOVEABLE, lstrlenA(msg)+1); - lpstrCopy = (LPSTR)GlobalLock(hglbCopy); - lstrcpyA(lpstrCopy, msg); - GlobalUnlock(hglbCopy); + HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE, lstrlenA(msg) + 1); + LPSTR lpstrCopy = (LPSTR)GlobalLock(hglbCopy); + lstrcpyA(lpstrCopy, msg); + GlobalUnlock(hglbCopy); OpenClipboard(NULL); - EmptyClipboard(); - SetClipboardData(CF_TEXT, hglbCopy); - CloseClipboard(); + EmptyClipboard(); + SetClipboardData(CF_TEXT, hglbCopy); + CloseClipboard(); } HANDLE hNetlibUser; @@ -128,15 +125,13 @@ void DeinitNetlib() CallService(MS_NETLIB_CLOSEHANDLE, (WPARAM)hNetlibUser, 0); } -int Sent_NetLog(const char *fmt,...) +int Sent_NetLog(const char *fmt, ...) { va_list va; char szText[1024]; - va_start(va,fmt); - mir_vsnprintf(szText,sizeof(szText),fmt,va); + va_start(va, fmt); + mir_vsnprintf(szText, sizeof(szText), fmt, va); va_end(va); - return CallService(MS_NETLIB_LOG,(WPARAM)hNetlibUser,(LPARAM)szText); + return CallService(MS_NETLIB_LOG, (WPARAM)hNetlibUser, (LPARAM)szText); } - -// EOF diff --git a/plugins/SecureIM/src/crypt.h b/plugins/SecureIM/src/crypt.h index 7b68e027f5..684f7c96c7 100644 --- a/plugins/SecureIM/src/crypt.h +++ b/plugins/SecureIM/src/crypt.h @@ -143,11 +143,6 @@ void showPopupKR(MCONTACT); void showPopupSM(MCONTACT); void showPopupRM(MCONTACT); -// crypt_meta.cpp -BOOL isProtoMetaContacts(MCONTACT); -BOOL isDefaultSubContact(MCONTACT); -void DeinitMetaContact(MCONTACT); - // crypt_dll.cpp LPSTR InitKeyA(pUinKey, int); int InitKeyB(pUinKey, LPCSTR); diff --git a/plugins/SecureIM/src/crypt_check.cpp b/plugins/SecureIM/src/crypt_check.cpp index 941e279220..e2d8ef27b9 100644 --- a/plugins/SecureIM/src/crypt_check.cpp +++ b/plugins/SecureIM/src/crypt_check.cpp @@ -23,7 +23,7 @@ BYTE isContactSecured(MCONTACT hContact) // нужна проверка на Offline и в этом случае другие статусы if (!arClist.getCount()) return 0; - if (isProtoMetaContacts(hContact)) + if (db_mc_isMeta(hContact)) hContact = db_mc_getMostOnline(hContact); // возьмем тот, через который пойдет сообщение pUinKey p = findUinKey(hContact); @@ -32,7 +32,7 @@ BYTE isContactSecured(MCONTACT hContact) BYTE res = p->mode; DBVARIANT dbv; - switch(p->mode) { + switch (p->mode) { case MODE_NATIVE: if (cpp_keyx(p->cntx) != 0) res |= SECURED; break; @@ -68,9 +68,9 @@ bool isClientMiranda(pUinKey ptr, BOOL emptyMirverAsMiranda) if (!ptr->proto->inspecting) return false; bool isMiranda = true; - LPSTR mirver = db_get_sa(ptr->hContact,ptr->proto->name,"MirVer"); + LPSTR mirver = db_get_sa(ptr->hContact, ptr->proto->name, "MirVer"); if (mirver) { - isMiranda = (emptyMirverAsMiranda && !*mirver) || (strstr(mirver,"Miranda") != NULL); + isMiranda = (emptyMirverAsMiranda && !*mirver) || (strstr(mirver, "Miranda") != NULL); mir_free(mirver); } return isMiranda; @@ -91,19 +91,19 @@ bool isProtoSmallPackets(MCONTACT hContact) if (!p || !p->proto || !p->proto->inspecting) return false; - return strstr(p->proto->name,"IRC") != NULL || strstr(p->proto->name,"WinPopup") != NULL || strstr(p->proto->name,"VyChat") != NULL; + return strstr(p->proto->name, "IRC") != NULL || strstr(p->proto->name, "WinPopup") != NULL || strstr(p->proto->name, "VyChat") != NULL; } bool isContactInvisible(MCONTACT hContact) { if (db_get_b(hContact, "CList", "Hidden", 0)) return true; - + pUinKey p = findUinKey(hContact); if (!p || p->waitForExchange || !p->proto || !p->proto->inspecting) return false; - switch(db_get_w(hContact, p->proto->name, "ApparentMode", 0)) { + switch (db_get_w(hContact, p->proto->name, "ApparentMode", 0)) { case 0: return CallProtoService(p->proto->name, PS_GETSTATUS, 0, 0) == ID_STATUS_INVISIBLE; case ID_STATUS_ONLINE: @@ -197,9 +197,9 @@ bool isSecureIM(pUinKey ptr, BOOL emptyMirverAsSecureIM) return false; bool isSecureIM = false; - LPSTR mirver = db_get_sa(ptr->hContact,ptr->proto->name,"MirVer"); + LPSTR mirver = db_get_sa(ptr->hContact, ptr->proto->name, "MirVer"); if (mirver) { - isSecureIM = (emptyMirverAsSecureIM && !*mirver) || (strstr(mirver,"SecureIM") != NULL) || (strstr(mirver,"secureim") != NULL); + isSecureIM = (emptyMirverAsSecureIM && !*mirver) || (strstr(mirver, "SecureIM") != NULL) || (strstr(mirver, "secureim") != NULL); mir_free(mirver); } return isSecureIM; @@ -212,5 +212,3 @@ bool isSecureIM(MCONTACT hContact, BOOL emptyMirverAsSecureIM) pUinKey p = findUinKey(hContact); return (p) ? isSecureIM(p, emptyMirverAsSecureIM) : false; } - -// EOF diff --git a/plugins/SecureIM/src/crypt_dll.cpp b/plugins/SecureIM/src/crypt_dll.cpp index 67a03a609c..9390367d93 100644 --- a/plugins/SecureIM/src/crypt_dll.cpp +++ b/plugins/SecureIM/src/crypt_dll.cpp @@ -1,24 +1,24 @@ #include "commonheaders.h" // generate KeyA pair and return public key -LPSTR InitKeyA(pUinKey ptr,int features) +LPSTR InitKeyA(pUinKey ptr, int features) { Sent_NetLog("InitKeyA: %04x", features); - if (!ptr->cntx ) - ptr->cntx = cpp_create_context(isProtoSmallPackets(ptr->hContact)?CPP_MODE_BASE64:0); + if (!ptr->cntx) + ptr->cntx = cpp_create_context(isProtoSmallPackets(ptr->hContact) ? CPP_MODE_BASE64 : 0); - char *tmp = db_get_sa(ptr->hContact,MODULENAME,"PSK"); + char *tmp = db_get_sa(ptr->hContact, MODULENAME, "PSK"); if (tmp) { - cpp_init_keyp(ptr->cntx,tmp); // make pre-shared key from password + cpp_init_keyp(ptr->cntx, tmp); // make pre-shared key from password mir_free(tmp); } - LPSTR pub_text = cpp_init_keya(ptr->cntx,features); // calculate public and private key & fill KeyA + LPSTR pub_text = cpp_init_keya(ptr->cntx, features); // calculate public and private key & fill KeyA LPSTR keysig; - if (features&CPP_FEATURES_NEWPG) { - if (features&KEY_B_SIG) + if (features & CPP_FEATURES_NEWPG) { + if (features & KEY_B_SIG) keysig = (LPSTR)SIG_KEYB; else keysig = (LPSTR)SIG_KEYA; @@ -31,31 +31,31 @@ LPSTR InitKeyA(pUinKey ptr,int features) int slen = (int)strlen(keysig); int tlen = (int)strlen(pub_text); - LPSTR keyToSend = (LPSTR) mir_alloc(slen+tlen+1); + LPSTR keyToSend = (LPSTR)mir_alloc(slen + tlen + 1); - memcpy(keyToSend,keysig,slen); - memcpy(keyToSend+slen,pub_text,tlen+1); + memcpy(keyToSend, keysig, slen); + memcpy(keyToSend + slen, pub_text, tlen + 1); return keyToSend; } // store KeyB into context -int InitKeyB(pUinKey ptr,LPCSTR key) +int InitKeyB(pUinKey ptr, LPCSTR key) { Sent_NetLog("InitKeyB: %s", key); if (!ptr->cntx) - ptr->cntx = cpp_create_context(isProtoSmallPackets(ptr->hContact)?CPP_MODE_BASE64:0); + ptr->cntx = cpp_create_context(isProtoSmallPackets(ptr->hContact) ? CPP_MODE_BASE64 : 0); if (!cpp_keyp(ptr->cntx)) { - char *tmp = db_get_sa(ptr->hContact,MODULENAME,"PSK"); + char *tmp = db_get_sa(ptr->hContact, MODULENAME, "PSK"); if (tmp) { - cpp_init_keyp(ptr->cntx,tmp); // make pre-shared key from password - mir_free(tmp); + cpp_init_keyp(ptr->cntx, tmp); // make pre-shared key from password + mir_free(tmp); } } - cpp_init_keyb(ptr->cntx,key); + cpp_init_keyb(ptr->cntx, key); ptr->features = cpp_get_features(ptr->cntx); return cpp_get_error(ptr->cntx); @@ -63,41 +63,40 @@ int InitKeyB(pUinKey ptr,LPCSTR key) // store KeyX into context -void InitKeyX(pUinKey ptr,BYTE *key) +void InitKeyX(pUinKey ptr, BYTE *key) { if (!ptr->cntx) - ptr->cntx = cpp_create_context(isProtoSmallPackets(ptr->hContact)?CPP_MODE_BASE64:0); + ptr->cntx = cpp_create_context(isProtoSmallPackets(ptr->hContact) ? CPP_MODE_BASE64 : 0); - cpp_set_keyx(ptr->cntx,key); + cpp_set_keyx(ptr->cntx, key); } // calculate secret key -BOOL CalculateKeyX(pUinKey ptr,MCONTACT hContact) +BOOL CalculateKeyX(pUinKey ptr, MCONTACT hContact) { int agr = cpp_calc_keyx(ptr->cntx); if (agr) { // do this only if key exchanged is ok // we use a 192bit key int keysize = cpp_size_keyx(); - PBYTE buffer = (PBYTE) alloca(keysize); // buffer for hash + PBYTE buffer = (PBYTE)alloca(keysize); // buffer for hash // store key - cpp_get_keyx(ptr->cntx,buffer); + cpp_get_keyx(ptr->cntx, buffer); // store key in database db_set_blob(hContact, MODULENAME, "offlineKey", buffer, keysize); // store timeout of key in database (2 days) - db_set_dw(hContact, MODULENAME, "offlineKeyTimeout", gettime()+(60*60*24*db_get_w(0,MODULENAME,"okt",2))); + db_set_dw(hContact, MODULENAME, "offlineKeyTimeout", gettime() + (60 * 60 * 24 * db_get_w(0, MODULENAME, "okt", 2))); // key exchange is finished showPopupEC(ptr->hContact); } - else { - // agree value problem - showPopup(sim002,hContact,g_hPOP[POP_PU_DIS],0); - } + else // agree value problem + showPopup(sim002, hContact, g_hPOP[POP_PU_DIS], 0); + return agr != 0; } @@ -105,14 +104,14 @@ BOOL CalculateKeyX(pUinKey ptr,MCONTACT hContact) // encrypt message LPSTR encrypt(pUinKey ptr, LPCSTR szEncMsg) { - LPSTR szSig = (LPSTR) (ptr->offlineKey?SIG_ENOF:SIG_ENON); + LPSTR szSig = (LPSTR)(ptr->offlineKey ? SIG_ENOF : SIG_ENON); int slen = (int)strlen(szSig); int clen = (int)strlen(szEncMsg); - LPSTR szMsg = (LPSTR) mir_alloc(clen+slen+1); + LPSTR szMsg = (LPSTR)mir_alloc(clen + slen + 1); memcpy(szMsg, szSig, slen); - memcpy(szMsg+slen, szEncMsg, clen+1); + memcpy(szMsg + slen, szEncMsg, clen + 1); return szMsg; } @@ -123,14 +122,14 @@ LPSTR encodeMsg(pUinKey ptr, LPARAM lParam) { CCSDATA *pccsd = (CCSDATA *)lParam; LPSTR szNewMsg = NULL; - LPSTR szOldMsg = (LPSTR) pccsd->lParam; + LPSTR szOldMsg = (LPSTR)pccsd->lParam; - if (pccsd->wParam & PREF_UTF ) - szNewMsg = encrypt(ptr,cpp_encodeU(ptr->cntx,szOldMsg)); - else if (pccsd->wParam & PREF_UNICODE ) - szNewMsg = encrypt(ptr,cpp_encodeW(ptr->cntx,(LPWSTR)(szOldMsg+strlen(szOldMsg)+1))); + if (pccsd->wParam & PREF_UTF) + szNewMsg = encrypt(ptr, cpp_encodeU(ptr->cntx, szOldMsg)); + else 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)); + szNewMsg = encrypt(ptr, cpp_encodeA(ptr->cntx, szOldMsg)); pccsd->wParam &= ~PREF_UNICODE; return szNewMsg; @@ -144,11 +143,11 @@ LPSTR decodeMsg(pUinKey ptr, LPARAM lParam, LPSTR szEncMsg) PROTORECVEVENT *ppre = (PROTORECVEVENT *)pccsd->lParam; LPSTR szNewMsg = NULL; - LPSTR szOldMsg = (ppre->flags&PREF_UTF)?cpp_decodeU(ptr->cntx,szEncMsg):cpp_decode(ptr->cntx,szEncMsg); + LPSTR szOldMsg = (ppre->flags&PREF_UTF) ? cpp_decodeU(ptr->cntx, szEncMsg) : cpp_decode(ptr->cntx, szEncMsg); if (szOldMsg == NULL) { ptr->decoded = false; - switch(cpp_get_error(ptr->cntx)) { + switch (cpp_get_error(ptr->cntx)) { case CPP_ERROR_BAD_LEN: szNewMsg = mir_strdup(Translate(sim102)); break; @@ -156,24 +155,24 @@ LPSTR decodeMsg(pUinKey ptr, LPARAM lParam, LPSTR szEncMsg) szNewMsg = mir_strdup(Translate(sim103)); break; default: - ptr->decoded=true; + ptr->decoded = true; szNewMsg = mir_strdup(Translate(sim101)); break; } - ppre->flags &= ~(PREF_UNICODE|PREF_UTF); - pccsd->wParam &= ~(PREF_UNICODE|PREF_UTF); + ppre->flags &= ~(PREF_UNICODE | PREF_UTF); + pccsd->wParam &= ~(PREF_UNICODE | PREF_UTF); } else { - ptr->decoded=true; - if (ppre->flags & PREF_UTF) { // Ґб«Ё Їа®в®Є®« Ї®¤¤Ґа¦Ёў Ґв utf8 - в®Ј¤  ®вЇа ў«пҐ¬ ў utf8 - int olen = (int)strlen(szOldMsg)+1; - szNewMsg = (LPSTR) mir_alloc(olen); - memcpy(szNewMsg,szOldMsg,olen); + ptr->decoded = true; + if (ppre->flags & PREF_UTF) { + int olen = (int)strlen(szOldMsg) + 1; + szNewMsg = (LPSTR)mir_alloc(olen); + memcpy(szNewMsg, szOldMsg, olen); } else { - int olen = ((int)strlen(szOldMsg)+1)*(sizeof(WCHAR)+1); - szNewMsg = (LPSTR) mir_alloc(olen); - memcpy(szNewMsg,szOldMsg,olen); + int olen = ((int)strlen(szOldMsg) + 1)*(sizeof(WCHAR) + 1); + szNewMsg = (LPSTR)mir_alloc(olen); + memcpy(szNewMsg, szOldMsg, olen); ppre->flags |= PREF_UNICODE; pccsd->wParam |= PREF_UNICODE; } @@ -185,19 +184,19 @@ LPSTR decodeMsg(pUinKey ptr, LPARAM lParam, LPSTR szEncMsg) BOOL LoadKeyPGP(pUinKey ptr) { - int mode = db_get_b(ptr->hContact,MODULENAME,"pgp_mode",255); + int mode = db_get_b(ptr->hContact, MODULENAME, "pgp_mode", 255); if (mode == 0) { DBVARIANT dbv; - db_get(ptr->hContact,MODULENAME,"pgp",&dbv); - BOOL r=(dbv.type == DBVT_BLOB); - if (r) pgp_set_keyid(ptr->cntx,(PVOID)dbv.pbVal); + db_get(ptr->hContact, MODULENAME, "pgp", &dbv); + BOOL r = (dbv.type == DBVT_BLOB); + if (r) pgp_set_keyid(ptr->cntx, (PVOID)dbv.pbVal); db_free(&dbv); return r; } if (mode == 1) { - LPSTR key = db_get_sa(ptr->hContact,MODULENAME,"pgp"); + LPSTR key = db_get_sa(ptr->hContact, MODULENAME, "pgp"); if (key) { - pgp_set_key(ptr->cntx,key); + pgp_set_key(ptr->cntx, key); mir_free(key); return 1; } @@ -207,13 +206,11 @@ BOOL LoadKeyPGP(pUinKey ptr) BOOL LoadKeyGPG(pUinKey ptr) { - LPSTR key = db_get_sa(ptr->hContact,MODULENAME,"gpg"); + LPSTR key = db_get_sa(ptr->hContact, MODULENAME, "gpg"); if (key) { - gpg_set_keyid(ptr->cntx,key); + gpg_set_keyid(ptr->cntx, key); mir_free(key); return 2; } return 0; } - -// EOF diff --git a/plugins/SecureIM/src/crypt_icons.cpp b/plugins/SecureIM/src/crypt_icons.cpp index 97c3631523..704b2a8254 100644 --- a/plugins/SecureIM/src/crypt_icons.cpp +++ b/plugins/SecureIM/src/crypt_icons.cpp @@ -16,24 +16,24 @@ OBJLIST arIcoList(10); // преобразует mode в HICON который НЕ НУЖНО разрушать в конце static ICON_CACHE& getCacheItem(int mode, int type) { - int m = mode & 0x0f, s = (mode & SECURED)>>4, i; // разобрали на части - режим и состояние + int m = mode & 0x0f, s = (mode & SECURED) >> 4, i; // разобрали на части - режим и состояние HICON icon; - for (i=0; i < arIcoList.getCount(); i++) - if (arIcoList[i].mode == ((type<<8) | mode)) + for (i = 0; i < arIcoList.getCount(); i++) + if (arIcoList[i].mode == ((type << 8) | mode)) return arIcoList[i]; i = s; - switch(type) { - case 1: i += IEC_CL_DIS; break; - case 2: i += ICO_CM_DIS; break; - case 3: i += ICO_MW_DIS; break; + switch (type) { + case 1: i += IEC_CL_DIS; break; + case 2: i += ICO_CM_DIS; break; + case 3: i += ICO_MW_DIS; break; } if (type == 1) - icon = BindOverlayIcon(g_hIEC[i], g_hICO[ICO_OV_NAT+m]); + icon = BindOverlayIcon(g_hIEC[i], g_hICO[ICO_OV_NAT + m]); else - icon = BindOverlayIcon(g_hICO[i], g_hICO[ICO_OV_NAT+m]); + icon = BindOverlayIcon(g_hICO[i], g_hICO[ICO_OV_NAT + m]); ICON_CACHE *p = new ICON_CACHE; p->icon = icon; @@ -101,17 +101,15 @@ void ShowStatusIconNotify(MCONTACT hContact) { BYTE mode = isContactSecured(hContact); NotifyEventHooks(g_hEvent[(mode&SECURED) != 0], hContact, 0); - ShowStatusIcon(hContact,mode); + ShowStatusIcon(hContact, mode); } void RefreshContactListIcons(void) { - for (int i=0; i < arIcoList.getCount(); i++) + for (int i = 0; i < arIcoList.getCount(); i++) arIcoList[i].hCLIcon = 0; for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) if (isSecureProtocol(hContact)) ShowStatusIcon(hContact); } - -// EOF diff --git a/plugins/SecureIM/src/crypt_lists.cpp b/plugins/SecureIM/src/crypt_lists.cpp index ab44379d45..64de3c3fc1 100644 --- a/plugins/SecureIM/src/crypt_lists.cpp +++ b/plugins/SecureIM/src/crypt_lists.cpp @@ -5,41 +5,41 @@ LIST arClist(100, LIST::FTSortFunc(NumericKeySortT)); void loadSupportedProtocols() { - LPSTR szNames = db_get_sa(0,MODULENAME,"protos"); - if (szNames && strchr(szNames,':') == NULL) { - LPSTR tmp = (LPSTR) mir_alloc(2048); int j=0; - for (int i=0; szNames[i]; i++) { + LPSTR szNames = db_get_sa(0, MODULENAME, "protos"); + if (szNames && strchr(szNames, ':') == NULL) { + LPSTR tmp = (LPSTR)mir_alloc(2048); int j = 0; + for (int i = 0; szNames[i]; i++) { if (szNames[i] == ';') - memcpy((PVOID)(tmp+j),(PVOID)":1:0:0",6); j+=6; + memcpy((PVOID)(tmp + j), (PVOID)":1:0:0", 6); j += 6; tmp[j++] = szNames[i]; } tmp[j] = '\0'; SAFE_FREE(szNames); szNames = tmp; - db_set_s(0,MODULENAME,"protos",szNames); + db_set_s(0, MODULENAME, "protos", szNames); } int numberOfProtocols; PROTOACCOUNT **protos; ProtoEnumAccounts(&numberOfProtocols, &protos); - for (int i=0; i < numberOfProtocols; i++) { + for (int i = 0; i < numberOfProtocols; i++) { if (!protos[i]->szModuleName || !CallProtoService(protos[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0)) continue; SupPro *p = (SupPro*)mir_calloc(sizeof(SupPro)); p->name = mir_strdup(protos[i]->szModuleName); if (szNames && p->name) { - char tmp[128]; strcpy(tmp, p->name); strcat(tmp,":"); + char tmp[128]; strcpy(tmp, p->name); strcat(tmp, ":"); LPSTR szName = strstr(szNames, tmp); if (szName) { - szName = strchr(szName,':'); + szName = strchr(szName, ':'); if (szName) { p->inspecting = (*++szName == '1'); - szName = strchr(szName,':'); + szName = strchr(szName, ':'); if (szName) { p->split_on = atoi(++szName); p->tsplit_on = p->split_on; - szName = strchr(szName,':'); + szName = strchr(szName, ':'); if (szName) p->split_off = atoi(++szName); p->tsplit_off = p->split_off; } @@ -54,7 +54,7 @@ void loadSupportedProtocols() void freeSupportedProtocols() { - for (int j=0; j < arProto.getCount(); j++) { + for (int j = 0; j < arProto.getCount(); j++) { mir_free(arProto[j]->name); mir_free(arProto[j]); } @@ -64,10 +64,10 @@ void freeSupportedProtocols() pSupPro getSupPro(MCONTACT hContact) { - for (int j=0; j < arProto.getCount(); j++) + for (int j = 0; j < arProto.getCount(); j++) if (CallService(MS_PROTO_ISPROTOONCONTACT, hContact, (LPARAM)arProto[j]->name)) return arProto[j]; - + return NULL; } @@ -75,7 +75,7 @@ pSupPro getSupPro(MCONTACT hContact) pUinKey addContact(MCONTACT hContact) { if (hContact == NULL) return NULL; - + pSupPro proto = getSupPro(hContact); if (proto == NULL) return NULL; @@ -125,7 +125,7 @@ void loadContactList() // free list of secureIM users void freeContactList() { - for (int j=0; j < arClist.getCount(); j++) { + for (int j = 0; j < arClist.getCount(); j++) { pUinKey p = arClist[j]; cpp_delete_context(p->cntx); p->cntx = 0; mir_free(p->tmp); @@ -151,34 +151,34 @@ pUinKey getUinKey(MCONTACT hContact) pUinKey getUinCtx(HANDLE cntx) { - for (int j=0; j < arClist.getCount(); j++) + for (int j = 0; j < arClist.getCount(); j++) if (arClist[j]->cntx == cntx) return arClist[j]; - + return NULL; } // add message to user queue for send later -void addMsg2Queue(pUinKey ptr,WPARAM wParam,LPSTR szMsg) +void addMsg2Queue(pUinKey ptr, WPARAM wParam, LPSTR szMsg) { - Sent_NetLog("addMsg2Queue: msg: -----\n%s\n-----\n",szMsg); + Sent_NetLog("addMsg2Queue: msg: -----\n%s\n-----\n", szMsg); pWM ptrMessage; EnterCriticalSection(&localQueueMutex); - if (ptr->msgQueue == NULL){ + if (ptr->msgQueue == NULL) { // create new - ptr->msgQueue = (pWM) mir_alloc(sizeof(struct waitingMessage)); + ptr->msgQueue = (pWM)mir_alloc(sizeof(struct waitingMessage)); ptrMessage = ptr->msgQueue; } else { // add to list ptrMessage = ptr->msgQueue; - while (ptrMessage->nextMessage) { + while (ptrMessage->nextMessage) ptrMessage = ptrMessage->nextMessage; - } - ptrMessage->nextMessage = (pWM) mir_alloc(sizeof(struct waitingMessage)); + + ptrMessage->nextMessage = (pWM)mir_alloc(sizeof(struct waitingMessage)); ptrMessage = ptrMessage->nextMessage; } @@ -186,20 +186,19 @@ void addMsg2Queue(pUinKey ptr,WPARAM wParam,LPSTR szMsg) ptrMessage->nextMessage = NULL; if (wParam & PREF_UNICODE) { - int slen = (int)strlen(szMsg)+1; - int wlen = (int)wcslen((wchar_t *)(szMsg+slen))+1; - ptrMessage->Message = (LPSTR) mir_alloc(slen+wlen*sizeof(WCHAR)); - memcpy(ptrMessage->Message,szMsg,slen+wlen*sizeof(WCHAR)); - } - else{ - ptrMessage->Message = mir_strdup(szMsg); + int slen = (int)strlen(szMsg) + 1; + int wlen = (int)wcslen((wchar_t *)(szMsg + slen)) + 1; + ptrMessage->Message = (LPSTR)mir_alloc(slen + wlen*sizeof(WCHAR)); + memcpy(ptrMessage->Message, szMsg, slen + wlen*sizeof(WCHAR)); } + else ptrMessage->Message = mir_strdup(szMsg); LeaveCriticalSection(&localQueueMutex); } -void getContactNameA(MCONTACT hContact, LPSTR szName) { - strcpy(szName,(LPCSTR)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,hContact,0)); +void getContactNameA(MCONTACT hContact, LPSTR szName) +{ + strcpy(szName, (LPCSTR)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, 0)); } void getContactName(MCONTACT hContact, LPSTR szName) @@ -216,8 +215,8 @@ void getContactUinA(MCONTACT hContact, LPSTR szUIN) return; DBVARIANT dbv_uniqueid; - LPSTR uID = (LPSTR) CallProtoService(ptr->name, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); - if (uID == (LPSTR)CALLSERVICE_NOTFOUND ) uID = 0; // Billy_Bons + LPSTR uID = (LPSTR)CallProtoService(ptr->name, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); + if (uID == (LPSTR)CALLSERVICE_NOTFOUND) uID = 0; // Billy_Bons if (uID && db_get(hContact, ptr->name, uID, &dbv_uniqueid) == 0) { if (dbv_uniqueid.type == DBVT_WORD) sprintf(szUIN, "%u [%s]", dbv_uniqueid.wVal, ptr->name); //!!!!!!!!!!! @@ -242,5 +241,3 @@ void getContactUin(MCONTACT hContact, LPSTR szUIN) mir_free(tmp); } } - -// EOF diff --git a/plugins/SecureIM/src/crypt_metacontacts.cpp b/plugins/SecureIM/src/crypt_metacontacts.cpp deleted file mode 100644 index 54d3ffd797..0000000000 --- a/plugins/SecureIM/src/crypt_metacontacts.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "commonheaders.h" - -BOOL isProtoMetaContacts(MCONTACT hContact) -{ - LPSTR proto = GetContactProto(hContact); - if (proto && !strcmp(proto, META_PROTO)) - return true; - return false; -} - -BOOL isDefaultSubContact(MCONTACT hContact) -{ - return db_mc_getDefault(db_mc_getMeta(hContact)) == hContact; -} - -// remove all secureim connections on subcontacts -void DeinitMetaContact(MCONTACT hContact) -{ - MCONTACT hMetaContact = isProtoMetaContacts(hContact) ? hContact : db_mc_getMeta(hContact); - if (hMetaContact) { - for (int i=0; i < db_mc_getSubCount(hMetaContact); i++) { - MCONTACT hSubContact = db_mc_getSub(hMetaContact, i); - if (hSubContact && (isContactSecured(hSubContact)&SECURED)) - CallContactService(hSubContact,PSS_MESSAGE, PREF_METANODB, (LPARAM)SIG_DEIN); - } - } -} - -// EOF diff --git a/plugins/SecureIM/src/crypt_misc.cpp b/plugins/SecureIM/src/crypt_misc.cpp index 4a6b774adb..4c51d678cf 100644 --- a/plugins/SecureIM/src/crypt_misc.cpp +++ b/plugins/SecureIM/src/crypt_misc.cpp @@ -7,25 +7,25 @@ static void sttWaitForExchange(LPVOID param) if (!ptr) return; - for (int i=0; i < db_get_w(0, MODULENAME, "ket", 10)*10; i++) { + for (int i = 0; i < db_get_w(0, MODULENAME, "ket", 10) * 10; i++) { Sleep(100); if (ptr->waitForExchange != 1) break; } - Sent_NetLog("sttWaitForExchange: %d",ptr->waitForExchange); + Sent_NetLog("sttWaitForExchange: %d", ptr->waitForExchange); // if keyexchange failed or timeout if (ptr->waitForExchange == 1 || ptr->waitForExchange == 3) { // протухло - отправляем незашифрованно, если надо - if (ptr->msgQueue && msgbox1(0,sim104,MODULENAME,MB_YESNO|MB_ICONQUESTION) == IDYES) { + if (ptr->msgQueue && msgbox1(0, sim104, MODULENAME, MB_YESNO | MB_ICONQUESTION) == IDYES) { EnterCriticalSection(&localQueueMutex); ptr->sendQueue = true; pWM ptrMessage = ptr->msgQueue; - while(ptrMessage) { - Sent_NetLog("Sent (unencrypted) message from queue: %s",ptrMessage->Message); + while (ptrMessage) { + Sent_NetLog("Sent (unencrypted) message from queue: %s", ptrMessage->Message); // send unencrypted messages - CallContactService(ptr->hContact,PSS_MESSAGE,(WPARAM)ptrMessage->wParam|PREF_METANODB,(LPARAM)ptrMessage->Message); + CallContactService(ptr->hContact, PSS_MESSAGE, (WPARAM)ptrMessage->wParam | PREF_METANODB, (LPARAM)ptrMessage->Message); mir_free(ptrMessage->Message); pWM tmp = ptrMessage; ptrMessage = ptrMessage->nextMessage; @@ -43,10 +43,10 @@ static void sttWaitForExchange(LPVOID param) // we need to resend last send back message with new crypto Key pWM ptrMessage = ptr->msgQueue; while (ptrMessage) { - Sent_NetLog("Sent (encrypted) message from queue: %s",ptrMessage->Message); + Sent_NetLog("Sent (encrypted) message from queue: %s", ptrMessage->Message); // send unencrypted messages - CallContactService(ptr->hContact,PSS_MESSAGE,(WPARAM)ptrMessage->wParam|PREF_METANODB,(LPARAM)ptrMessage->Message); + CallContactService(ptr->hContact, PSS_MESSAGE, (WPARAM)ptrMessage->wParam | PREF_METANODB, (LPARAM)ptrMessage->Message); mir_free(ptrMessage->Message); pWM tmp = ptrMessage; ptrMessage = ptrMessage->nextMessage; @@ -74,7 +74,7 @@ static void sttWaitForExchange(LPVOID param) // set wait flag and run thread void waitForExchange(pUinKey ptr, int flag) { - switch(flag) { + switch (flag) { case 0: // reset case 2: // send secure case 3: // send unsecure @@ -90,6 +90,3 @@ void waitForExchange(pUinKey ptr, int flag) break; } } - - -// EOF diff --git a/plugins/SecureIM/src/crypt_popups.cpp b/plugins/SecureIM/src/crypt_popups.cpp index 1d368b22ca..a3c3a48016 100644 --- a/plugins/SecureIM/src/crypt_popups.cpp +++ b/plugins/SecureIM/src/crypt_popups.cpp @@ -1,47 +1,47 @@ #include "commonheaders.h" -void showPopup(LPCSTR lpzText,MCONTACT hContact,HICON hIcon, UINT type) -{ - //type=0 key colors - //type=1 session colors - //type=2 SR colors +// type=0 key colors +// type=1 session colors +// type=2 SR colors +void showPopup(LPCSTR lpzText, MCONTACT hContact, HICON hIcon, UINT type) +{ if (!bPopupExists) return; COLORREF colorBack, colorText; - int timeout=0; + int timeout = 0; DBVARIANT dbv; if (type == 0) { - colorBack = db_get_dw(0, MODULENAME, "colorKeyb", RGB(230,230,255)); - colorText = db_get_dw(0, MODULENAME, "colorKeyt", RGB(0,0,0)); + colorBack = db_get_dw(0, MODULENAME, "colorKeyb", RGB(230, 230, 255)); + colorText = db_get_dw(0, MODULENAME, "colorKeyt", RGB(0, 0, 0)); if (!db_get_s(0, MODULENAME, "timeoutKey", &dbv)) { timeout = atoi(dbv.pszVal); db_free(&dbv); } } else if (type == 1) { - colorBack = db_get_dw(0, MODULENAME, "colorSecb", RGB(255,255,200)); - colorText = db_get_dw(0, MODULENAME, "colorSect", RGB(0,0,0)); - if (!db_get_s(0, MODULENAME, "timeoutSec" ,&dbv)) { + colorBack = db_get_dw(0, MODULENAME, "colorSecb", RGB(255, 255, 200)); + colorText = db_get_dw(0, MODULENAME, "colorSect", RGB(0, 0, 0)); + if (!db_get_s(0, MODULENAME, "timeoutSec", &dbv)) { timeout = atoi(dbv.pszVal); db_free(&dbv); } } else if (type >= 2) { - colorBack = db_get_dw(0, MODULENAME, "colorSRb", RGB(200,255,200)); - colorText = db_get_dw(0, MODULENAME, "colorSRt", RGB(0,0,0)); + colorBack = db_get_dw(0, MODULENAME, "colorSRb", RGB(200, 255, 200)); + colorText = db_get_dw(0, MODULENAME, "colorSRt", RGB(0, 0, 0)); if (!db_get_s(0, MODULENAME, "timeoutSR", &dbv)) { timeout = atoi(dbv.pszVal); db_free(&dbv); } } - POPUPDATAW ppd = {0}; + POPUPDATAW ppd = { 0 }; ppd.lchContact = hContact; //Be sure to use a GOOD handle, since this will not be checked. ppd.lchIcon = hIcon; - LPWSTR lpwzContactName = (LPWSTR)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,hContact,GSMDF_UNICODE); + LPWSTR lpwzContactName = (LPWSTR)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GSMDF_UNICODE); wcscpy(ppd.lpwzContactName, lpwzContactName); LPWSTR lpwzText = mir_a2u(lpzText); wcscpy(ppd.lpwzText, TranslateW(lpwzText)); @@ -52,7 +52,7 @@ void showPopup(LPCSTR lpzText,MCONTACT hContact,HICON hIcon, UINT type) PUAddPopupW(&ppd); } -void showPopupDCmsg(MCONTACT hContact,LPCSTR msg) +void showPopupDCmsg(MCONTACT hContact, LPCSTR msg) { if (db_get_b(0, MODULENAME, "dc", 1)) showPopup(msg, hContact, g_hPOP[POP_PU_DIS], 1); @@ -72,11 +72,11 @@ void showPopupEC(MCONTACT hContact) void showPopupKS(MCONTACT hContact) { - if (db_get_b(0, MODULENAME, "ks",1)) + if (db_get_b(0, MODULENAME, "ks", 1)) showPopup(sim007, hContact, g_hPOP[POP_PU_PRC], 0); } -void showPopupKRmsg(MCONTACT hContact,LPCSTR msg) +void showPopupKRmsg(MCONTACT hContact, LPCSTR msg) { if (db_get_b(0, MODULENAME, "kr", 1)) showPopup(msg, hContact, g_hPOP[POP_PU_PRC], 0); @@ -101,5 +101,3 @@ void showPopupRM(MCONTACT hContact) showPopup(sim010, hContact, g_hPOP[POP_PU_MSR], 2); SkinPlaySound("IncomingSecureMessage"); } - -// EOF diff --git a/plugins/SecureIM/src/dbevent.cpp b/plugins/SecureIM/src/dbevent.cpp index 5e38811d98..ae51a29c6a 100644 --- a/plugins/SecureIM/src/dbevent.cpp +++ b/plugins/SecureIM/src/dbevent.cpp @@ -1,17 +1,13 @@ #include "commonheaders.h" - void HistoryLog(MCONTACT hContact, LPCSTR szText) { DBEVENTINFO dbei = { sizeof(dbei) }; dbei.szModule = GetContactProto(hContact); - dbei.flags = DBEF_SENT|DBEF_READ; + dbei.flags = DBEF_SENT | DBEF_READ; dbei.timestamp = time(NULL); dbei.eventType = EVENTTYPE_MESSAGE; dbei.cbBlob = (int)strlen(szText) + 1; dbei.pBlob = (PBYTE)szText; db_event_add(0, &dbei); } - - -// EOF diff --git a/plugins/SecureIM/src/gettime.cpp b/plugins/SecureIM/src/gettime.cpp index 76ec52ede8..4da5fe98c8 100644 --- a/plugins/SecureIM/src/gettime.cpp +++ b/plugins/SecureIM/src/gettime.cpp @@ -9,9 +9,9 @@ const static ULONGLONG ix_epoch = 116444736000000000; DWORD gettime(void) { - ULONGLONG diff_100_nsec; - union { + union + { FILETIME f; ULARGE_INTEGER u; } now; @@ -22,5 +22,3 @@ DWORD gettime(void) return (DWORD)(diff_100_nsec / div_100_nsec); } - -// EOF diff --git a/plugins/SecureIM/src/images.cpp b/plugins/SecureIM/src/images.cpp index abecbb5ab8..c3a0fbdde3 100644 --- a/plugins/SecureIM/src/images.cpp +++ b/plugins/SecureIM/src/images.cpp @@ -1,38 +1,30 @@ #include "commonheaders.h" - void HalfBitmap32Alpha(HBITMAP hBitmap) { BITMAP bmp; - DWORD dwLen; - BYTE *p; - int x, y; - GetObject(hBitmap, sizeof(bmp), &bmp); - if (bmp.bmBitsPixel != 32) return; - dwLen = bmp.bmWidth * bmp.bmHeight * (bmp.bmBitsPixel / 8); - p = (BYTE *)malloc(dwLen); + DWORD dwLen = bmp.bmWidth * bmp.bmHeight * (bmp.bmBitsPixel / 8); + BYTE *p = (BYTE *)malloc(dwLen); if (p == NULL) return; memset(p, 0, dwLen); GetBitmapBits(hBitmap, dwLen, p); - for (y = 0; y < bmp.bmHeight; ++y) { - BYTE *px = p + bmp.bmWidth * 4 * y; + for (int y = 0; y < bmp.bmHeight; ++y) { + BYTE *px = p + bmp.bmWidth * 4 * y; - for (x = 0; x < bmp.bmWidth; ++x) - { - px[3]>>=1; + for (int x = 0; x < bmp.bmWidth; ++x) { + px[3] >>= 1; px += 4; } } SetBitmapBits(hBitmap, dwLen, p); - free(p); } @@ -41,16 +33,12 @@ void HalfBitmap32Alpha(HBITMAP hBitmap) void MakeBmpTransparent(HBITMAP hBitmap) { BITMAP bmp; - DWORD dwLen; - BYTE *p; - GetObject(hBitmap, sizeof(bmp), &bmp); - if (bmp.bmBitsPixel != 32) return; - dwLen = bmp.bmWidth * bmp.bmHeight * (bmp.bmBitsPixel / 8); - p = (BYTE *)malloc(dwLen); + DWORD dwLen = bmp.bmWidth * bmp.bmHeight * (bmp.bmBitsPixel / 8); + BYTE *p = (BYTE *)malloc(dwLen); if (p == NULL) return; @@ -60,7 +48,6 @@ void MakeBmpTransparent(HBITMAP hBitmap) free(p); } - // Correct alpha from bitmaps loaded without it (it cames with 0 and should be 255) void CorrectBitmap32Alpha(HBITMAP hBitmap, BOOL force) { @@ -85,16 +72,13 @@ void CorrectBitmap32Alpha(HBITMAP hBitmap, BOOL force) fixIt = TRUE; for (y = 0; fixIt && y < bmp.bmHeight; ++y) { - BYTE *px = p + bmp.bmWidth * 4 * y; + BYTE *px = p + bmp.bmWidth * 4 * y; - for (x = 0; fixIt && x < bmp.bmWidth; ++x) - { - if (px[3] != 0 && !force) - { + for (x = 0; fixIt && x < bmp.bmWidth; ++x) { + if (px[3] != 0 && !force) { fixIt = FALSE; } - else - { + else { if (px[0] != 0 || px[1] != 0 || px[2] != 0) px[3] = 255; } @@ -112,7 +96,7 @@ void CorrectBitmap32Alpha(HBITMAP hBitmap, BOOL force) HBITMAP CopyBitmapTo32(HBITMAP hBitmap) { - BITMAPINFO RGB32BitsBITMAPINFO; + BITMAPINFO RGB32BitsBITMAPINFO; BYTE * ptPixels; HBITMAP hDirectBitmap; @@ -135,23 +119,22 @@ HBITMAP CopyBitmapTo32(HBITMAP hBitmap) RGB32BitsBITMAPINFO.bmiHeader.biPlanes = 1; RGB32BitsBITMAPINFO.bmiHeader.biBitCount = 32; - hDirectBitmap = CreateDIBSection(NULL, - (BITMAPINFO *)&RGB32BitsBITMAPINFO, - DIB_RGB_COLORS, - (void **)&ptPixels, - NULL, 0); + hDirectBitmap = CreateDIBSection(NULL, + (BITMAPINFO *)&RGB32BitsBITMAPINFO, + DIB_RGB_COLORS, + (void **)&ptPixels, + NULL, 0); // Copy data - if (bmp.bmBitsPixel != 32) - { + if (bmp.bmBitsPixel != 32) { HDC hdcOrig, hdcDest; HBITMAP oldOrig, oldDest; - + hdcOrig = CreateCompatibleDC(NULL); - oldOrig = (HBITMAP) SelectObject(hdcOrig, hBitmap); + oldOrig = (HBITMAP)SelectObject(hdcOrig, hBitmap); hdcDest = CreateCompatibleDC(NULL); - oldDest = (HBITMAP) SelectObject(hdcDest, hDirectBitmap); + oldDest = (HBITMAP)SelectObject(hdcDest, hDirectBitmap); BitBlt(hdcDest, 0, 0, bmp.bmWidth, bmp.bmHeight, hdcOrig, 0, 0, SRCCOPY); @@ -163,8 +146,7 @@ HBITMAP CopyBitmapTo32(HBITMAP hBitmap) // Set alpha CorrectBitmap32Alpha(hDirectBitmap, FALSE); } - else - { + else { GetBitmapBits(hBitmap, dwLen, p); SetBitmapBits(hDirectBitmap, dwLen, p); } @@ -177,29 +159,29 @@ HBITMAP CopyBitmapTo32(HBITMAP hBitmap) HBITMAP CreateBitmap32(int cx, int cy) { - BITMAPINFO RGB32BitsBITMAPINFO; + BITMAPINFO RGB32BitsBITMAPINFO; UINT * ptPixels; HBITMAP DirectBitmap; - ZeroMemory(&RGB32BitsBITMAPINFO,sizeof(BITMAPINFO)); - RGB32BitsBITMAPINFO.bmiHeader.biSize=sizeof(BITMAPINFOHEADER); - RGB32BitsBITMAPINFO.bmiHeader.biWidth=cx;//bm.bmWidth; - RGB32BitsBITMAPINFO.bmiHeader.biHeight=cy;//bm.bmHeight; - RGB32BitsBITMAPINFO.bmiHeader.biPlanes=1; - RGB32BitsBITMAPINFO.bmiHeader.biBitCount=32; - - DirectBitmap = CreateDIBSection(NULL, - (BITMAPINFO *)&RGB32BitsBITMAPINFO, - DIB_RGB_COLORS, - (void **)&ptPixels, - NULL, 0); + ZeroMemory(&RGB32BitsBITMAPINFO, sizeof(BITMAPINFO)); + RGB32BitsBITMAPINFO.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + RGB32BitsBITMAPINFO.bmiHeader.biWidth = cx;//bm.bmWidth; + RGB32BitsBITMAPINFO.bmiHeader.biHeight = cy;//bm.bmHeight; + RGB32BitsBITMAPINFO.bmiHeader.biPlanes = 1; + RGB32BitsBITMAPINFO.bmiHeader.biBitCount = 32; + + DirectBitmap = CreateDIBSection(NULL, + (BITMAPINFO *)&RGB32BitsBITMAPINFO, + DIB_RGB_COLORS, + (void **)&ptPixels, + NULL, 0); return DirectBitmap; } BOOL MakeBitmap32(HBITMAP *hBitmap) { - BITMAP bmp; + BITMAP bmp; GetObject(*hBitmap, sizeof(bmp), &bmp); @@ -208,12 +190,11 @@ BOOL MakeBitmap32(HBITMAP *hBitmap) HBITMAP hBmpTmp = CopyBitmapTo32(*hBitmap); DeleteObject(*hBitmap); *hBitmap = hBmpTmp; - } + } return TRUE; } - #define GET_PIXEL(__P__, __X__, __Y__)(__P__ + width * 4 * (__Y__) + 4 * (__X__)) BOOL MakeGrayscale(HBITMAP *hBitmap) @@ -221,62 +202,56 @@ BOOL MakeGrayscale(HBITMAP *hBitmap) BYTE *p = NULL; BYTE *p1; DWORD dwLen; - int width, height, x, y; - BITMAP bmp; + int width, height, x, y; + BITMAP bmp; GetObject(*hBitmap, sizeof(bmp), &bmp); - width = bmp.bmWidth; + width = bmp.bmWidth; height = bmp.bmHeight; dwLen = width * height * 4; p = (BYTE *)malloc(dwLen); - if (p == NULL) - { + if (p == NULL) { return FALSE; } - if (bmp.bmBitsPixel != 32) - { + if (bmp.bmBitsPixel != 32) { // Convert to 32 bpp HBITMAP hBmpTmp = CopyBitmapTo32(*hBitmap); DeleteObject(*hBitmap); *hBitmap = hBmpTmp; - } + } GetBitmapBits(*hBitmap, dwLen, p); // Make grayscale - for (y = 0 ; y < height ; y++) - { - for (x = 0 ; x < width ; x++) - { + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { p1 = GET_PIXEL(p, x, y); p1[0] = p1[1] = p1[2] = (p1[0] + p1[1] + p1[2]) / 3; } } - dwLen = SetBitmapBits(*hBitmap, dwLen, p); - free(p); + dwLen = SetBitmapBits(*hBitmap, dwLen, p); + free(p); return TRUE; } - HICON MakeHalfAlphaIcon(HICON SourceIcon) { - ICONINFO TargetIconInfo; - BITMAP TargetBitmapInfo; - HICON TargetIcon, TempIcon; + HICON TempIcon = CopyIcon(SourceIcon); - TempIcon = CopyIcon(SourceIcon); + ICONINFO TargetIconInfo; if (!GetIconInfo(TempIcon, &TargetIconInfo)) return NULL; + BITMAP TargetBitmapInfo; if (!GetObject(TargetIconInfo.hbmColor, sizeof(BITMAP), &TargetBitmapInfo)) return NULL; MakeBitmap32(&TargetIconInfo.hbmColor); HalfBitmap32Alpha(TargetIconInfo.hbmColor); - TargetIcon = CreateIconIndirect(&TargetIconInfo); + HICON TargetIcon = CreateIconIndirect(&TargetIconInfo); DestroyIcon(TempIcon); DeleteObject(TargetIconInfo.hbmColor); @@ -284,33 +259,32 @@ HICON MakeHalfAlphaIcon(HICON SourceIcon) return TargetIcon; } - HICON MakeGrayscaleIcon(HICON SourceIcon) { + HICON TempIcon = CopyIcon(SourceIcon); + ICONINFO TargetIconInfo; BITMAP TargetBitmapInfo; - HICON TargetIcon, TempIcon; - - TempIcon = CopyIcon(SourceIcon); - if (! GetIconInfo(TempIcon, &TargetIconInfo) || GetObject(TargetIconInfo.hbmColor, sizeof(BITMAP), &TargetBitmapInfo) == 0) return NULL; + if (!GetIconInfo(TempIcon, &TargetIconInfo) || GetObject(TargetIconInfo.hbmColor, sizeof(BITMAP), &TargetBitmapInfo) == 0) + return NULL; MakeGrayscale(&TargetIconInfo.hbmColor); - TargetIcon = CreateIconIndirect(&TargetIconInfo); + HICON TargetIcon = CreateIconIndirect(&TargetIconInfo); DestroyIcon(TempIcon); return TargetIcon; } -HICON BindOverlayIcon(HICON SourceIcon,HICON OverlayIcon) +HICON BindOverlayIcon(HICON SourceIcon, HICON OverlayIcon) { ICONINFO OverlayIconInfo, TargetIconInfo; BITMAP OverlayBitmapInfo, TargetBitmapInfo; HBITMAP OldOverlayBitmap, OldTargetBitmap; HICON TargetIcon, TempIcon; HDC OverlayDC, TargetDC; - BLENDFUNCTION bf = {0,0,255,1}; + BLENDFUNCTION bf = { 0, 0, 255, 1 }; TempIcon = CopyIcon(SourceIcon); if (!GetIconInfo(TempIcon, &TargetIconInfo)) @@ -330,13 +304,13 @@ HICON BindOverlayIcon(HICON SourceIcon,HICON OverlayIcon) OldOverlayBitmap = (HBITMAP)SelectObject(OverlayDC, OverlayIconInfo.hbmColor); AlphaBlend(TargetDC, 0, 0, TargetBitmapInfo.bmWidth, TargetBitmapInfo.bmHeight, - OverlayDC, 0, 0, OverlayBitmapInfo.bmWidth, OverlayBitmapInfo.bmHeight, bf); + OverlayDC, 0, 0, OverlayBitmapInfo.bmWidth, OverlayBitmapInfo.bmHeight, bf); SelectObject(TargetDC, TargetIconInfo.hbmMask); SelectObject(OverlayDC, OverlayIconInfo.hbmMask); BitBlt(TargetDC, 0, 0, TargetBitmapInfo.bmWidth, TargetBitmapInfo.bmHeight, - OverlayDC, 0, 0, SRCCOPY); + OverlayDC, 0, 0, SRCCOPY); TargetIcon = CreateIconIndirect(&TargetIconInfo); DestroyIcon(TempIcon); @@ -353,6 +327,3 @@ HICON BindOverlayIcon(HICON SourceIcon,HICON OverlayIcon) return TargetIcon; } - - -// EOF diff --git a/plugins/SecureIM/src/language.cpp b/plugins/SecureIM/src/language.cpp index 1e7e282327..6e59f9a084 100644 --- a/plugins/SecureIM/src/language.cpp +++ b/plugins/SecureIM/src/language.cpp @@ -99,6 +99,3 @@ LPCSTR sim520 = LPGEN("SecureIM received RSA Public Key from \"%s\"\n\nSHA1: %s\ LPCSTR sim521 = LPGEN("SecureIM auto accepted RSA Public key from: %s uin: %s SHA1: %s"); LPCSTR sim522 = LPGEN("SecureIM received NEW RSA Public Key from \"%s\"\n\nNew SHA1: %s\n\nOld SHA1: %s\n\nDo you Replace this Key?"); LPCSTR sim523 = LPGEN("SecureIM auto accepted NEW RSA Public key from: %s uin: %s New SHA1: %s Old SHA1: %s"); - - -// EOF diff --git a/plugins/SecureIM/src/loadicons.cpp b/plugins/SecureIM/src/loadicons.cpp index 85998e1128..ff4d1d876a 100644 --- a/plugins/SecureIM/src/loadicons.cpp +++ b/plugins/SecureIM/src/loadicons.cpp @@ -12,34 +12,34 @@ struct static icons[] = { // Contact List - {IDI_CL_DIS, TBL_IEC, IEC_CL_DIS, MODULENAME"/"LPGEN("Contact List"), "sim_cl_dis", LPGEN("Connection Disabled")}, - {IDI_CL_EST, TBL_IEC, IEC_CL_EST, MODULENAME"/"LPGEN("Contact List"), "sim_cl_est", LPGEN("Connection Established")}, + { IDI_CL_DIS, TBL_IEC, IEC_CL_DIS, MODULENAME"/"LPGEN("Contact List"), "sim_cl_dis", LPGEN("Connection Disabled") }, + { IDI_CL_EST, TBL_IEC, IEC_CL_EST, MODULENAME"/"LPGEN("Contact List"), "sim_cl_est", LPGEN("Connection Established") }, // Contact Menu - {IDI_CM_DIS, TBL_ICO, ICO_CM_DIS, MODULENAME"/"LPGEN("Contact Menu"), "sim_cm_dis", LPGEN("Disable Secure Connection")}, - {IDI_CM_EST, TBL_ICO, ICO_CM_EST, MODULENAME"/"LPGEN("Contact Menu"), "sim_cm_est", LPGEN("Establish Secure Connection")}, + { IDI_CM_DIS, TBL_ICO, ICO_CM_DIS, MODULENAME"/"LPGEN("Contact Menu"), "sim_cm_dis", LPGEN("Disable Secure Connection") }, + { IDI_CM_EST, TBL_ICO, ICO_CM_EST, MODULENAME"/"LPGEN("Contact Menu"), "sim_cm_est", LPGEN("Establish Secure Connection") }, // Message Window - {IDI_MW_DIS, TBL_ICO, ICO_MW_DIS, MODULENAME"/"LPGEN("Message Window"), "sim_mw_dis", LPGEN("Connection Disabled")}, - {IDI_MW_EST, TBL_ICO, ICO_MW_EST, MODULENAME"/"LPGEN("Message Window"), "sim_mw_est", LPGEN("Connection Established")}, + { IDI_MW_DIS, TBL_ICO, ICO_MW_DIS, MODULENAME"/"LPGEN("Message Window"), "sim_mw_dis", LPGEN("Connection Disabled") }, + { IDI_MW_EST, TBL_ICO, ICO_MW_EST, MODULENAME"/"LPGEN("Message Window"), "sim_mw_est", LPGEN("Connection Established") }, // popup's - {IDI_PU_DIS, TBL_POP, POP_PU_DIS, MODULENAME"/"LPGEN("Popups"), "sim_pu_dis", LPGEN("Secure Connection Disabled")}, - {IDI_PU_EST, TBL_POP, POP_PU_EST, MODULENAME"/"LPGEN("Popups"), "sim_pu_est", LPGEN("Secure Connection Established")}, - {IDI_PU_PRC, TBL_POP, POP_PU_PRC, MODULENAME"/"LPGEN("Popups"), "sim_pu_prc", LPGEN("Secure Connection In Process")}, - {IDI_PU_MSG, TBL_POP, POP_PU_MSR, MODULENAME"/"LPGEN("Popups"), "sim_pu_msr", LPGEN("Recv Secured Message")}, - {IDI_PU_MSG, TBL_POP, POP_PU_MSS, MODULENAME"/"LPGEN("Popups"), "sim_pu_mss", LPGEN("Sent Secured Message")}, + { IDI_PU_DIS, TBL_POP, POP_PU_DIS, MODULENAME"/"LPGEN("Popups"), "sim_pu_dis", LPGEN("Secure Connection Disabled") }, + { IDI_PU_EST, TBL_POP, POP_PU_EST, MODULENAME"/"LPGEN("Popups"), "sim_pu_est", LPGEN("Secure Connection Established") }, + { IDI_PU_PRC, TBL_POP, POP_PU_PRC, MODULENAME"/"LPGEN("Popups"), "sim_pu_prc", LPGEN("Secure Connection In Process") }, + { IDI_PU_MSG, TBL_POP, POP_PU_MSR, MODULENAME"/"LPGEN("Popups"), "sim_pu_msr", LPGEN("Recv Secured Message") }, + { IDI_PU_MSG, TBL_POP, POP_PU_MSS, MODULENAME"/"LPGEN("Popups"), "sim_pu_mss", LPGEN("Sent Secured Message") }, // statuses - {IDI_ST_DIS, TBL_ICO, ICO_ST_DIS, MODULENAME"/"LPGEN("Menu State"), "sim_st_dis", LPGEN("Disabled")}, - {IDI_ST_ENA, TBL_ICO, ICO_ST_ENA, MODULENAME"/"LPGEN("Menu State"), "sim_st_ena", LPGEN("Enabled")}, - {IDI_ST_TRY, TBL_ICO, ICO_ST_TRY, MODULENAME"/"LPGEN("Menu State"), "sim_st_try", LPGEN("Always Try")}, + { IDI_ST_DIS, TBL_ICO, ICO_ST_DIS, MODULENAME"/"LPGEN("Menu State"), "sim_st_dis", LPGEN("Disabled") }, + { IDI_ST_ENA, TBL_ICO, ICO_ST_ENA, MODULENAME"/"LPGEN("Menu State"), "sim_st_ena", LPGEN("Enabled") }, + { IDI_ST_TRY, TBL_ICO, ICO_ST_TRY, MODULENAME"/"LPGEN("Menu State"), "sim_st_try", LPGEN("Always Try") }, // overlay - {IDI_OV_NAT, TBL_ICO, ICO_OV_NAT, MODULENAME"/"LPGEN("Overlays"), "sim_ov_nat", LPGEN("Native mode")}, - {IDI_OV_PGP, TBL_ICO, ICO_OV_PGP, MODULENAME"/"LPGEN("Overlays"), "sim_ov_pgp", LPGEN("PGP mode")}, - {IDI_OV_GPG, TBL_ICO, ICO_OV_GPG, MODULENAME"/"LPGEN("Overlays"), "sim_ov_gpg", LPGEN("GPG mode")}, - {IDI_OV_RSA, TBL_ICO, ICO_OV_RSA, MODULENAME"/"LPGEN("Overlays"), "sim_ov_rsa", LPGEN("RSA/AES mode")}, + { IDI_OV_NAT, TBL_ICO, ICO_OV_NAT, MODULENAME"/"LPGEN("Overlays"), "sim_ov_nat", LPGEN("Native mode") }, + { IDI_OV_PGP, TBL_ICO, ICO_OV_PGP, MODULENAME"/"LPGEN("Overlays"), "sim_ov_pgp", LPGEN("PGP mode") }, + { IDI_OV_GPG, TBL_ICO, ICO_OV_GPG, MODULENAME"/"LPGEN("Overlays"), "sim_ov_gpg", LPGEN("GPG mode") }, + { IDI_OV_RSA, TBL_ICO, ICO_OV_RSA, MODULENAME"/"LPGEN("Overlays"), "sim_ov_rsa", LPGEN("RSA/AES mode") }, }; HINSTANCE LoadIconsPack(const char* szIconsPack) @@ -48,9 +48,9 @@ HINSTANCE LoadIconsPack(const char* szIconsPack) if (hNewIconInst != NULL) { for (int i = ID_FIRSTICON; i <= ID_LASTICON; i++) if (LoadIcon(hNewIconInst, MAKEINTRESOURCE(i)) == NULL) { - FreeLibrary(hNewIconInst); - hNewIconInst = NULL; - break; + FreeLibrary(hNewIconInst); + hNewIconInst = NULL; + break; } } return hNewIconInst; @@ -58,7 +58,7 @@ HINSTANCE LoadIconsPack(const char* szIconsPack) int ReloadIcons(WPARAM wParam, LPARAM lParam) { - for (int i=0; i < SIZEOF(icons); i++) { + for (int i = 0; i < SIZEOF(icons); i++) { HICON hIcon = Skin_GetIcon(icons[i].name); if (icons[i].tbl == TBL_IEC) g_hIEC[icons[i].idx] = hIcon; @@ -100,13 +100,13 @@ void InitIcons(void) sid.pszSection = "SecureIM"; sid.ptszDefaultFile = tszPath; - for (int i=0; i < SIZEOF(icons); i++) { + for (int i = 0; i < SIZEOF(icons); i++) { sid.pszSection = icons[i].section; sid.pszName = icons[i].name; sid.pszDescription = icons[i].text; sid.iDefaultIndex = -icons[i].key; HANDLE hIcolib = Skin_AddIcon(&sid); - + HICON hIcon = Skin_GetIconByHandle(hIcolib); if (icons[i].tbl == TBL_IEC) g_hIEC[icons[i].idx] = hIcon; @@ -118,5 +118,3 @@ void InitIcons(void) HookEvent(ME_SKIN2_ICONSCHANGED, ReloadIcons); } - -// EOF diff --git a/plugins/SecureIM/src/loadlib.cpp b/plugins/SecureIM/src/loadlib.cpp index ac75e5c172..7ecb9ef0dc 100644 --- a/plugins/SecureIM/src/loadlib.cpp +++ b/plugins/SecureIM/src/loadlib.cpp @@ -2,75 +2,73 @@ CRYPTOPP_INFO cpp; -BOOL loadlib(void) { - +BOOL loadlib(void) +{ HMODULE h = LoadLibraryA("plugins/cryptopp.dll"); if (h == NULL) { h = LoadLibraryA("cryptopp.dll"); - if (h == NULL ) return 0; + if (h == NULL) return 0; } - - cpp.cc = (_cpp_create_context) GetProcAddress(h, "cpp_create_context"); - cpp.dc = (_cpp_delete_context) GetProcAddress(h, "cpp_delete_context"); - cpp.rc = (_cpp_reset_context) GetProcAddress(h, "cpp_reset_context"); - cpp.ika = (_cpp_init_keya) GetProcAddress(h, "cpp_init_keya"); - cpp.ikb = (_cpp_init_keyb) GetProcAddress(h, "cpp_init_keyb"); - cpp.ckx = (_cpp_calc_keyx) GetProcAddress(h, "cpp_calc_keyx"); - cpp.ikp = (_cpp_init_keyp) GetProcAddress(h, "cpp_init_keyp"); - cpp.ea = (_cpp_encodeA) GetProcAddress(h, "cpp_encodeA"); - cpp.ew = (_cpp_encodeW) GetProcAddress(h, "cpp_encodeW"); - cpp.eu = (_cpp_encodeU) GetProcAddress(h, "cpp_encodeU"); - cpp.daw = (_cpp_decode) GetProcAddress(h, "cpp_decode"); - cpp.du = (_cpp_decodeU) GetProcAddress(h, "cpp_decodeU"); - cpp.ef = (_cpp_encrypt_file) GetProcAddress(h, "cpp_encrypt_file"); - cpp.df = (_cpp_decrypt_file) GetProcAddress(h, "cpp_decrypt_file"); - cpp.gf = (_cpp_get_features) GetProcAddress(h, "cpp_get_features"); - cpp.ge = (_cpp_get_error) GetProcAddress(h, "cpp_get_error"); - cpp.gv = (_cpp_get_version) GetProcAddress(h, "cpp_get_version"); - cpp.kxs = (_cpp_size_keyx) GetProcAddress(h, "cpp_size_keyx"); - cpp.gkx = (_cpp_get_keyx) GetProcAddress(h, "cpp_get_keyx"); - cpp.skx = (_cpp_set_keyx) GetProcAddress(h, "cpp_set_keyx"); - cpp.kps = (_cpp_size_keyp) GetProcAddress(h, "cpp_size_keyp"); - cpp.gkp = (_cpp_get_keyp) GetProcAddress(h, "cpp_get_keyp"); - cpp.skp = (_cpp_set_keyp) GetProcAddress(h, "cpp_set_keyp"); - cpp.ka = (_cpp_keya) GetProcAddress(h, "cpp_keya"); - cpp.kb = (_cpp_keyb) GetProcAddress(h, "cpp_keyb"); - cpp.kx = (_cpp_keyx) GetProcAddress(h, "cpp_keyx"); - cpp.kp = (_cpp_keyp) GetProcAddress(h, "cpp_keyp"); - cpp.pgp_i = (_pgp_init ) GetProcAddress(h, "pgp_init"); - cpp.pgp_d = (_pgp_done ) GetProcAddress(h, "pgp_done"); - cpp.pgp_ok = (_pgp_open_keyrings ) GetProcAddress(h, "pgp_open_keyrings"); - cpp.pgp_ck = (_pgp_close_keyrings ) GetProcAddress(h, "pgp_close_keyrings"); - cpp.pgp_gv = (_pgp_get_version ) GetProcAddress(h, "pgp_get_version"); - cpp.pgp_ge = (_pgp_get_error ) GetProcAddress(h, "pgp_get_error"); - cpp.pgp_spk = (_pgp_set_priv_key ) GetProcAddress(h, "pgp_set_priv_key"); - cpp.pgp_sk = (_pgp_set_key ) GetProcAddress(h, "pgp_set_key"); - cpp.pgp_ski = (_pgp_set_keyid ) GetProcAddress(h, "pgp_set_keyid"); - cpp.pgp_szki = (_pgp_size_keyid ) GetProcAddress(h, "pgp_size_keyid"); - cpp.pgp_slki = (_pgp_select_keyid ) GetProcAddress(h, "pgp_select_keyid"); - cpp.pgp_eu = (_pgp_encode ) GetProcAddress(h, "pgp_encode"); - cpp.pgp_de = (_pgp_decode ) GetProcAddress(h, "pgp_decode"); + cpp.cc = (_cpp_create_context)GetProcAddress(h, "cpp_create_context"); + cpp.dc = (_cpp_delete_context)GetProcAddress(h, "cpp_delete_context"); + cpp.rc = (_cpp_reset_context)GetProcAddress(h, "cpp_reset_context"); + cpp.ika = (_cpp_init_keya)GetProcAddress(h, "cpp_init_keya"); + cpp.ikb = (_cpp_init_keyb)GetProcAddress(h, "cpp_init_keyb"); + cpp.ckx = (_cpp_calc_keyx)GetProcAddress(h, "cpp_calc_keyx"); + cpp.ikp = (_cpp_init_keyp)GetProcAddress(h, "cpp_init_keyp"); + cpp.ea = (_cpp_encodeA)GetProcAddress(h, "cpp_encodeA"); + cpp.ew = (_cpp_encodeW)GetProcAddress(h, "cpp_encodeW"); + cpp.eu = (_cpp_encodeU)GetProcAddress(h, "cpp_encodeU"); + cpp.daw = (_cpp_decode)GetProcAddress(h, "cpp_decode"); + cpp.du = (_cpp_decodeU)GetProcAddress(h, "cpp_decodeU"); + cpp.ef = (_cpp_encrypt_file)GetProcAddress(h, "cpp_encrypt_file"); + cpp.df = (_cpp_decrypt_file)GetProcAddress(h, "cpp_decrypt_file"); + cpp.gf = (_cpp_get_features)GetProcAddress(h, "cpp_get_features"); + cpp.ge = (_cpp_get_error)GetProcAddress(h, "cpp_get_error"); + cpp.gv = (_cpp_get_version)GetProcAddress(h, "cpp_get_version"); + cpp.kxs = (_cpp_size_keyx)GetProcAddress(h, "cpp_size_keyx"); + cpp.gkx = (_cpp_get_keyx)GetProcAddress(h, "cpp_get_keyx"); + cpp.skx = (_cpp_set_keyx)GetProcAddress(h, "cpp_set_keyx"); + cpp.kps = (_cpp_size_keyp)GetProcAddress(h, "cpp_size_keyp"); + cpp.gkp = (_cpp_get_keyp)GetProcAddress(h, "cpp_get_keyp"); + cpp.skp = (_cpp_set_keyp)GetProcAddress(h, "cpp_set_keyp"); + cpp.ka = (_cpp_keya)GetProcAddress(h, "cpp_keya"); + cpp.kb = (_cpp_keyb)GetProcAddress(h, "cpp_keyb"); + cpp.kx = (_cpp_keyx)GetProcAddress(h, "cpp_keyx"); + cpp.kp = (_cpp_keyp)GetProcAddress(h, "cpp_keyp"); - cpp.gpg_i = (_gpg_init ) GetProcAddress(h, "gpg_init"); - cpp.gpg_d = (_gpg_done ) GetProcAddress(h, "gpg_done"); - cpp.gpg_ok = (_gpg_open_keyrings ) GetProcAddress(h, "gpg_open_keyrings"); - cpp.gpg_ck = (_gpg_close_keyrings ) GetProcAddress(h, "gpg_close_keyrings"); - cpp.gpg_sl = (_gpg_set_log ) GetProcAddress(h, "gpg_set_log"); - cpp.gpg_st = (_gpg_set_tmp ) GetProcAddress(h, "gpg_set_tmp"); - cpp.gpg_ge = (_gpg_get_error ) GetProcAddress(h, "gpg_get_error"); - cpp.gpg_ski = (_gpg_set_keyid ) GetProcAddress(h, "gpg_set_keyid"); - cpp.gpg_szki = (_gpg_size_keyid ) GetProcAddress(h, "gpg_size_keyid"); - cpp.gpg_slki = (_gpg_select_keyid ) GetProcAddress(h, "gpg_select_keyid"); - cpp.gpg_eu = (_gpg_encode ) GetProcAddress(h, "gpg_encode"); - cpp.gpg_de = (_gpg_decode ) GetProcAddress(h, "gpg_decode"); - cpp.gpg_gph = (_gpg_get_passphrases ) GetProcAddress(h, "gpg_get_passphrases"); - cpp.gpg_sph = (_gpg_set_passphrases ) GetProcAddress(h, "gpg_set_passphrases"); + cpp.pgp_i = (_pgp_init)GetProcAddress(h, "pgp_init"); + cpp.pgp_d = (_pgp_done)GetProcAddress(h, "pgp_done"); + cpp.pgp_ok = (_pgp_open_keyrings)GetProcAddress(h, "pgp_open_keyrings"); + cpp.pgp_ck = (_pgp_close_keyrings)GetProcAddress(h, "pgp_close_keyrings"); + cpp.pgp_gv = (_pgp_get_version)GetProcAddress(h, "pgp_get_version"); + cpp.pgp_ge = (_pgp_get_error)GetProcAddress(h, "pgp_get_error"); + cpp.pgp_spk = (_pgp_set_priv_key)GetProcAddress(h, "pgp_set_priv_key"); + cpp.pgp_sk = (_pgp_set_key)GetProcAddress(h, "pgp_set_key"); + cpp.pgp_ski = (_pgp_set_keyid)GetProcAddress(h, "pgp_set_keyid"); + cpp.pgp_szki = (_pgp_size_keyid)GetProcAddress(h, "pgp_size_keyid"); + cpp.pgp_slki = (_pgp_select_keyid)GetProcAddress(h, "pgp_select_keyid"); + cpp.pgp_eu = (_pgp_encode)GetProcAddress(h, "pgp_encode"); + cpp.pgp_de = (_pgp_decode)GetProcAddress(h, "pgp_decode"); - cpp.rsa_i = (_rsa_init) GetProcAddress(h, "rsa_init"); - cpp.rsa_d = (_rsa_done) GetProcAddress(h, "rsa_done"); + cpp.gpg_i = (_gpg_init)GetProcAddress(h, "gpg_init"); + cpp.gpg_d = (_gpg_done)GetProcAddress(h, "gpg_done"); + cpp.gpg_ok = (_gpg_open_keyrings)GetProcAddress(h, "gpg_open_keyrings"); + cpp.gpg_ck = (_gpg_close_keyrings)GetProcAddress(h, "gpg_close_keyrings"); + cpp.gpg_sl = (_gpg_set_log)GetProcAddress(h, "gpg_set_log"); + cpp.gpg_st = (_gpg_set_tmp)GetProcAddress(h, "gpg_set_tmp"); + cpp.gpg_ge = (_gpg_get_error)GetProcAddress(h, "gpg_get_error"); + cpp.gpg_ski = (_gpg_set_keyid)GetProcAddress(h, "gpg_set_keyid"); + cpp.gpg_szki = (_gpg_size_keyid)GetProcAddress(h, "gpg_size_keyid"); + cpp.gpg_slki = (_gpg_select_keyid)GetProcAddress(h, "gpg_select_keyid"); + cpp.gpg_eu = (_gpg_encode)GetProcAddress(h, "gpg_encode"); + cpp.gpg_de = (_gpg_decode)GetProcAddress(h, "gpg_decode"); + cpp.gpg_gph = (_gpg_get_passphrases)GetProcAddress(h, "gpg_get_passphrases"); + cpp.gpg_sph = (_gpg_set_passphrases)GetProcAddress(h, "gpg_set_passphrases"); - return (cpp_get_version()>=0x01000403); -} + cpp.rsa_i = (_rsa_init)GetProcAddress(h, "rsa_init"); + cpp.rsa_d = (_rsa_done)GetProcAddress(h, "rsa_done"); -// EOF + return (cpp_get_version() >= 0x01000403); +} diff --git a/plugins/SecureIM/src/main.cpp b/plugins/SecureIM/src/main.cpp index 0b144fe738..22d7d44e6a 100644 --- a/plugins/SecureIM/src/main.cpp +++ b/plugins/SecureIM/src/main.cpp @@ -17,7 +17,7 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda return &pluginInfoEx; } -HGENMENU AddMenuItem(LPCSTR name,int pos,HICON hicon,LPCSTR service,int flags=0,WPARAM wParam=0) +HGENMENU AddMenuItem(LPCSTR name, int pos, HICON hicon, LPCSTR service, int flags = 0, WPARAM wParam = 0) { CLISTMENUITEM mi = { sizeof(mi) }; mi.flags = flags | CMIF_HIDDEN; @@ -29,7 +29,7 @@ HGENMENU AddMenuItem(LPCSTR name,int pos,HICON hicon,LPCSTR service,int flags=0, return Menu_AddContactMenuItem(&mi); } -HGENMENU AddSubItem(HANDLE rootid,LPCSTR name,int pos,int poppos,LPCSTR service,WPARAM wParam=0) +HGENMENU AddSubItem(HANDLE rootid, LPCSTR name, int pos, int poppos, LPCSTR service, WPARAM wParam = 0) { CLISTMENUITEM mi = { sizeof(mi) }; mi.flags = CMIF_CHILDPOPUP | CMIF_HIDDEN; @@ -49,23 +49,23 @@ extern "C" __declspec(dllexport) int __cdecl Load(void) InitializeCriticalSection(&localQueueMutex); char temp[MAX_PATH]; - GetTempPath(sizeof(temp),temp); - GetLongPathName(temp,TEMP,sizeof(TEMP)); + GetTempPath(sizeof(temp), temp); + GetLongPathName(temp, TEMP, sizeof(TEMP)); TEMP_SIZE = (int)strlen(TEMP); - if (TEMP[TEMP_SIZE-1] == '\\') { + if (TEMP[TEMP_SIZE - 1] == '\\') { TEMP_SIZE--; - TEMP[TEMP_SIZE]='\0'; + TEMP[TEMP_SIZE] = '\0'; } // check for support TrueColor Icons BOOL bIsComCtl6 = FALSE; HMODULE hComCtlDll = LoadLibrary(_T("comctl32.dll")); if (hComCtlDll) { - typedef HRESULT (CALLBACK *PFNDLLGETVERSION)(DLLVERSIONINFO*); - PFNDLLGETVERSION pfnDllGetVersion = (PFNDLLGETVERSION) GetProcAddress(hComCtlDll,"DllGetVersion"); + typedef HRESULT(CALLBACK *PFNDLLGETVERSION)(DLLVERSIONINFO*); + PFNDLLGETVERSION pfnDllGetVersion = (PFNDLLGETVERSION)GetProcAddress(hComCtlDll, "DllGetVersion"); if (pfnDllGetVersion) { DLLVERSIONINFO dvi; - memset(&dvi,0,sizeof(dvi)); + memset(&dvi, 0, sizeof(dvi)); dvi.cbSize = sizeof(dvi); HRESULT hRes = (*pfnDllGetVersion)(&dvi); if (SUCCEEDED(hRes) && dvi.dwMajorVersion >= 6) { @@ -77,11 +77,11 @@ extern "C" __declspec(dllexport) int __cdecl Load(void) if (bIsComCtl6) iBmpDepth = ILC_COLOR32 | ILC_MASK; // 32-bit images are supported else iBmpDepth = ILC_COLOR24 | ILC_MASK; - iCoreVersion = CallService(MS_SYSTEM_GETVERSION,0,0); + iCoreVersion = CallService(MS_SYSTEM_GETVERSION, 0, 0); // load crypo++ dll if (!loadlib()) { - msgbox1(0,sim107,MODULENAME,MB_OK|MB_ICONSTOP); + msgbox1(0, sim107, MODULENAME, MB_OK | MB_ICONSTOP); return 1; } @@ -102,20 +102,20 @@ extern "C" __declspec(dllexport) int __cdecl Load(void) g_hEvent[0] = CreateHookableEvent(MODULENAME"/Disabled"); g_hEvent[1] = CreateHookableEvent(MODULENAME"/Established"); - CreateServiceFunction(MODULENAME"/IsContactSecured",Service_IsContactSecured); - CreateServiceFunction(MODULENAME"/SIM_EST",Service_CreateIM); - CreateServiceFunction(MODULENAME"/SIM_DIS",Service_DisableIM); - CreateServiceFunction(MODULENAME"/SIM_ST_DIS",Service_StatusDis); - CreateServiceFunction(MODULENAME"/SIM_ST_ENA",Service_StatusEna); - CreateServiceFunction(MODULENAME"/SIM_ST_TRY",Service_StatusTry); - CreateServiceFunction(MODULENAME"/PGP_SET",Service_PGPsetKey); - CreateServiceFunction(MODULENAME"/PGP_DEL",Service_PGPdelKey); - CreateServiceFunction(MODULENAME"/GPG_SET",Service_GPGsetKey); - CreateServiceFunction(MODULENAME"/GPG_DEL",Service_GPGdelKey); - CreateServiceFunction(MODULENAME"/MODE_NAT",Service_ModeNative); - CreateServiceFunction(MODULENAME"/MODE_PGP",Service_ModePGP); - CreateServiceFunction(MODULENAME"/MODE_GPG",Service_ModeGPG); - CreateServiceFunction(MODULENAME"/MODE_RSA",Service_ModeRSAAES); + CreateServiceFunction(MODULENAME"/IsContactSecured", Service_IsContactSecured); + CreateServiceFunction(MODULENAME"/SIM_EST", Service_CreateIM); + CreateServiceFunction(MODULENAME"/SIM_DIS", Service_DisableIM); + CreateServiceFunction(MODULENAME"/SIM_ST_DIS", Service_StatusDis); + CreateServiceFunction(MODULENAME"/SIM_ST_ENA", Service_StatusEna); + CreateServiceFunction(MODULENAME"/SIM_ST_TRY", Service_StatusTry); + CreateServiceFunction(MODULENAME"/PGP_SET", Service_PGPsetKey); + CreateServiceFunction(MODULENAME"/PGP_DEL", Service_PGPdelKey); + CreateServiceFunction(MODULENAME"/GPG_SET", Service_GPGsetKey); + CreateServiceFunction(MODULENAME"/GPG_DEL", Service_GPGdelKey); + CreateServiceFunction(MODULENAME"/MODE_NAT", Service_ModeNative); + CreateServiceFunction(MODULENAME"/MODE_PGP", Service_ModePGP); + CreateServiceFunction(MODULENAME"/MODE_GPG", Service_ModeGPG); + CreateServiceFunction(MODULENAME"/MODE_RSA", Service_ModeRSAAES); return 0; } @@ -148,19 +148,19 @@ int onModulesLoaded(WPARAM, LPARAM) DBVARIANT dbv; dbv.type = DBVT_BLOB; - if (db_get(0,MODULENAME,"rsa_priv",&dbv) == 0) { - exp->rsa_set_keypair(CPP_MODE_RSA_4096,dbv.pbVal,dbv.cpbVal); + if (db_get(0, MODULENAME, "rsa_priv", &dbv) == 0) { + exp->rsa_set_keypair(CPP_MODE_RSA_4096, dbv.pbVal, dbv.cpbVal); db_free(&dbv); - rsa_4096=1; + rsa_4096 = 1; } - else if (db_get(0,MODULENAME,"rsa_priv_4096",&dbv) == 0) { - exp->rsa_set_keypair(CPP_MODE_RSA_4096|CPP_MODE_RSA_BER,dbv.pbVal,dbv.cpbVal); + else if (db_get(0, MODULENAME, "rsa_priv_4096", &dbv) == 0) { + exp->rsa_set_keypair(CPP_MODE_RSA_4096 | CPP_MODE_RSA_BER, dbv.pbVal, dbv.cpbVal); db_free(&dbv); char priv_key[4096]; int priv_len; char pub_key[4096]; int pub_len; - exp->rsa_get_keypair(CPP_MODE_RSA_4096,(PBYTE)&priv_key,&priv_len,(PBYTE)&pub_key,&pub_len); + exp->rsa_get_keypair(CPP_MODE_RSA_4096, (PBYTE)&priv_key, &priv_len, (PBYTE)&pub_key, &pub_len); db_set_blob(NULL, MODULENAME, "rsa_priv", priv_key, priv_len); db_set_blob(NULL, MODULENAME, "rsa_pub", &pub_key, pub_len); db_unset(NULL, MODULENAME, "rsa_priv_2048"); @@ -171,15 +171,15 @@ int onModulesLoaded(WPARAM, LPARAM) if (!rsa_4096) mir_forkthread(sttGenerateRSA, NULL); - exp->rsa_set_timeout( db_get_w(0,MODULENAME,"ket",10)); + exp->rsa_set_timeout(db_get_w(0, MODULENAME, "ket", 10)); Sent_NetLog("pgp_init"); bPGP = db_get_b(0, MODULENAME, "pgp", 0); if (bPGP) { //PGP bPGPloaded = pgp_init(); - bUseKeyrings = db_get_b(0,MODULENAME,"ukr",1); - LPSTR priv = db_get_sa(0,MODULENAME,"pgpPrivKey"); + bUseKeyrings = db_get_b(0, MODULENAME, "ukr", 1); + LPSTR priv = db_get_sa(0, MODULENAME, "pgpPrivKey"); if (priv) { bPGPprivkey = true; if (bPGPloaded) @@ -188,25 +188,25 @@ int onModulesLoaded(WPARAM, LPARAM) } if (bPGPloaded && bUseKeyrings) { char PubRingPath[MAX_PATH], SecRingPath[MAX_PATH]; - PubRingPath[0]='\0'; SecRingPath[0]='\0'; - if (pgp_get_version()<0x02000000) { // 6xx - bPGPkeyrings = pgp_open_keyrings(PubRingPath,SecRingPath); + PubRingPath[0] = '\0'; SecRingPath[0] = '\0'; + if (pgp_get_version() < 0x02000000) { // 6xx + bPGPkeyrings = pgp_open_keyrings(PubRingPath, SecRingPath); } else { - LPSTR tmp = db_get_sa(0,MODULENAME,"pgpPubRing"); + LPSTR tmp = db_get_sa(0, MODULENAME, "pgpPubRing"); if (tmp) { - strncpy(PubRingPath,tmp,sizeof(PubRingPath)); + strncpy(PubRingPath, tmp, sizeof(PubRingPath)); mir_free(tmp); } - if (tmp = db_get_sa(0,MODULENAME,"pgpSecRing")) { - strncpy(SecRingPath,tmp,sizeof(SecRingPath)); + if (tmp = db_get_sa(0, MODULENAME, "pgpSecRing")) { + strncpy(SecRingPath, tmp, sizeof(SecRingPath)); mir_free(tmp); } if (PubRingPath[0] && SecRingPath[0]) { - bPGPkeyrings = pgp_open_keyrings(PubRingPath,SecRingPath); + bPGPkeyrings = pgp_open_keyrings(PubRingPath, SecRingPath); if (bPGPkeyrings) { - db_set_s(0,MODULENAME,"pgpPubRing",PubRingPath); - db_set_s(0,MODULENAME,"pgpSecRing",SecRingPath); + db_set_s(0, MODULENAME, "pgpPubRing", PubRingPath); + db_set_s(0, MODULENAME, "pgpSecRing", SecRingPath); } else { db_unset(0, MODULENAME, "pgpPubRing"); @@ -224,45 +224,45 @@ int onModulesLoaded(WPARAM, LPARAM) bGPGloaded = gpg_init(); char gpgexec[MAX_PATH], gpghome[MAX_PATH]; - gpgexec[0]='\0'; gpghome[0]='\0'; + gpgexec[0] = '\0'; gpghome[0] = '\0'; - LPSTR tmp = db_get_sa(0,MODULENAME,"gpgExec"); + LPSTR tmp = db_get_sa(0, MODULENAME, "gpgExec"); if (tmp) { - strncpy(gpgexec,tmp,sizeof(gpgexec)); + strncpy(gpgexec, tmp, sizeof(gpgexec)); mir_free(tmp); } - if (tmp = db_get_sa(0,MODULENAME,"gpgHome")) { - strncpy(gpghome,tmp,sizeof(gpghome)); + if (tmp = db_get_sa(0, MODULENAME, "gpgHome")) { + strncpy(gpghome, tmp, sizeof(gpghome)); mir_free(tmp); } - if (db_get_b(0, MODULENAME, "gpgLogFlag",0)) { - if (tmp = db_get_sa(0,MODULENAME,"gpgLog")) { + if (db_get_b(0, MODULENAME, "gpgLogFlag", 0)) { + if (tmp = db_get_sa(0, MODULENAME, "gpgLog")) { gpg_set_log(tmp); mir_free(tmp); } } - if (db_get_b(0, MODULENAME, "gpgTmpFlag",0)) { - if (tmp = db_get_sa(0,MODULENAME,"gpgTmp")) { + if (db_get_b(0, MODULENAME, "gpgTmpFlag", 0)) { + if (tmp = db_get_sa(0, MODULENAME, "gpgTmp")) { gpg_set_tmp(tmp); mir_free(tmp); } } - bGPGkeyrings = gpg_open_keyrings(gpgexec,gpghome); + bGPGkeyrings = gpg_open_keyrings(gpgexec, gpghome); if (bGPGkeyrings) { - db_set_s(0,MODULENAME,"gpgExec",gpgexec); - db_set_s(0,MODULENAME,"gpgHome",gpghome); + db_set_s(0, MODULENAME, "gpgExec", gpgexec); + db_set_s(0, MODULENAME, "gpgHome", gpghome); } else { db_unset(0, MODULENAME, "gpgExec"); db_unset(0, MODULENAME, "gpgHome"); } - bSavePass = db_get_b(0,MODULENAME,"gpgSaveFlag",0); + bSavePass = db_get_b(0, MODULENAME, "gpgSaveFlag", 0); if (bSavePass) { - if (tmp = db_get_sa(0,MODULENAME,"gpgSave")) { + if (tmp = db_get_sa(0, MODULENAME, "gpgSave")) { gpg_set_passphrases(tmp); mir_free(tmp); } @@ -273,11 +273,11 @@ int onModulesLoaded(WPARAM, LPARAM) loadContactList(); // add new skin sound - SkinAddNewSound("IncomingSecureMessage",LPGEN("Incoming Secure Message"),"Sounds\\iSecureMessage.wav"); - SkinAddNewSound("OutgoingSecureMessage",LPGEN("Outgoing Secure Message"),"Sounds\\oSecureMessage.wav"); + SkinAddNewSound("IncomingSecureMessage", LPGEN("Incoming Secure Message"), "Sounds\\iSecureMessage.wav"); + SkinAddNewSound("OutgoingSecureMessage", LPGEN("Outgoing Secure Message"), "Sounds\\oSecureMessage.wav"); // init extra icons - for (int i=0; i < SIZEOF(g_IEC); i++) + for (int i = 0; i < SIZEOF(g_IEC); i++) g_IEC[i] = (HANDLE)-1; HookEvent(ME_CLIST_PREBUILDCONTACTMENU, onRebuildContactMenu); @@ -316,28 +316,28 @@ int onModulesLoaded(WPARAM, LPARAM) } if (bPGPloaded) { - g_hMenu[6] = AddMenuItem(sim306, 110006, mode2icon(MODE_PGP|SECURED,2), MODULENAME"/PGP_SET", 0); - g_hMenu[7] = AddMenuItem(sim307, 110007, mode2icon(MODE_PGP,2), MODULENAME"/PGP_DEL", 0); + g_hMenu[6] = AddMenuItem(sim306, 110006, mode2icon(MODE_PGP | SECURED, 2), MODULENAME"/PGP_SET", 0); + g_hMenu[7] = AddMenuItem(sim307, 110007, mode2icon(MODE_PGP, 2), MODULENAME"/PGP_DEL", 0); } if (bGPGloaded) { - g_hMenu[8] = AddMenuItem(sim308, 110008, mode2icon(MODE_GPG|SECURED,2), MODULENAME"/GPG_SET", 0); - g_hMenu[9] = AddMenuItem(sim309, 110009, mode2icon(MODE_GPG,2), MODULENAME"/GPG_DEL", 0); + g_hMenu[8] = AddMenuItem(sim308, 110008, mode2icon(MODE_GPG | SECURED, 2), MODULENAME"/GPG_SET", 0); + g_hMenu[9] = AddMenuItem(sim309, 110009, mode2icon(MODE_GPG, 2), MODULENAME"/GPG_DEL", 0); } if (ServiceExists(MS_CLIST_MENUBUILDSUBGROUP)) { - g_hMenu[10] = AddMenuItem(sim311[0],110010,NULL,NULL,CMIF_ROOTPOPUP); - g_hMenu[11] = AddSubItem(g_hMenu[10],sim231[0],110011,110010,MODULENAME"/MODE_NAT"); - g_hMenu[12] = AddSubItem(g_hMenu[10],sim231[1],110012,110010,MODULENAME"/MODE_PGP"); - g_hMenu[13] = AddSubItem(g_hMenu[10],sim231[2],110013,110010,MODULENAME"/MODE_GPG"); - g_hMenu[14] = AddSubItem(g_hMenu[10],sim231[3],110014,110010,MODULENAME"/MODE_RSA"); + g_hMenu[10] = AddMenuItem(sim311[0], 110010, NULL, NULL, CMIF_ROOTPOPUP); + g_hMenu[11] = AddSubItem(g_hMenu[10], sim231[0], 110011, 110010, MODULENAME"/MODE_NAT"); + g_hMenu[12] = AddSubItem(g_hMenu[10], sim231[1], 110012, 110010, MODULENAME"/MODE_PGP"); + g_hMenu[13] = AddSubItem(g_hMenu[10], sim231[2], 110013, 110010, MODULENAME"/MODE_GPG"); + g_hMenu[14] = AddSubItem(g_hMenu[10], sim231[3], 110014, 110010, MODULENAME"/MODE_RSA"); } else { g_hMenu[10] = 0; - g_hMenu[11] = AddMenuItem(sim231[0],110011,NULL,MODULENAME"/MODE_NAT"); - g_hMenu[12] = AddMenuItem(sim231[1],110012,NULL,MODULENAME"/MODE_PGP"); - g_hMenu[13] = AddMenuItem(sim231[2],110013,NULL,MODULENAME"/MODE_GPG"); - g_hMenu[14] = AddMenuItem(sim231[3],110014,NULL,MODULENAME"/MODE_RSA"); + g_hMenu[11] = AddMenuItem(sim231[0], 110011, NULL, MODULENAME"/MODE_NAT"); + g_hMenu[12] = AddMenuItem(sim231[1], 110012, NULL, MODULENAME"/MODE_PGP"); + g_hMenu[13] = AddMenuItem(sim231[2], 110013, NULL, MODULENAME"/MODE_GPG"); + g_hMenu[14] = AddMenuItem(sim231[3], 110014, NULL, MODULENAME"/MODE_RSA"); } InitSRMMIcons(); @@ -348,10 +348,10 @@ int onShutdown(WPARAM, LPARAM) { if (bSavePass) { LPSTR tmp = gpg_get_passphrases(); - db_set_s(0,MODULENAME,"gpgSave",tmp); + db_set_s(0, MODULENAME, "gpgSave", tmp); LocalFree(tmp); } - else db_unset(0,MODULENAME,"gpgSave"); + else db_unset(0, MODULENAME, "gpgSave"); if (bPGPloaded) pgp_done(); if (bGPGloaded) gpg_done(); @@ -366,5 +366,3 @@ int onShutdown(WPARAM, LPARAM) DeinitNetlib(); return 0; } - -// EOF diff --git a/plugins/SecureIM/src/mmi.cpp b/plugins/SecureIM/src/mmi.cpp index 4a6b06bbe4..6f9875f604 100644 --- a/plugins/SecureIM/src/mmi.cpp +++ b/plugins/SecureIM/src/mmi.cpp @@ -1,150 +1,142 @@ #include "commonheaders.h" - -void *operator new(size_t sz) { - return mir_alloc(sz); +void *operator new(size_t sz) +{ + return mir_calloc(sz); } - -void *operator new[](size_t size) { +void *operator new[](size_t size) +{ return operator new(size); } - -void operator delete(void *p) { +void operator delete(void *p) +{ mir_free(p); } - -void operator delete[](void * p) { +void operator delete[](void *p) +{ operator delete(p); } - // ANSIzUCS2z + ANSIzUCS2z = ANSIzUCS2z -char *m_wwstrcat(LPCSTR strA, LPCSTR strB) { +char* m_wwstrcat(LPCSTR strA, LPCSTR strB) +{ int lenA = (int)strlen(strA); int lenB = (int)strlen(strB); - LPSTR str = (LPSTR)mir_alloc((lenA+lenB+1)*(sizeof(WCHAR)+1)); - memcpy(str, strA, lenA); - memcpy(str+lenA, strB, lenB+1); - memcpy(str+lenA+lenB+1, strA+lenA+1, lenA*sizeof(WCHAR)); - memcpy(str+lenA+lenB+1+lenA*sizeof(WCHAR), strB+lenB+1, (lenB+1)*sizeof(WCHAR)); + LPSTR str = (LPSTR)mir_alloc((lenA + lenB + 1)*(sizeof(WCHAR) + 1)); + memcpy(str, strA, lenA); + memcpy(str + lenA, strB, lenB + 1); + memcpy(str + lenA + lenB + 1, strA + lenA + 1, lenA*sizeof(WCHAR)); + memcpy(str + lenA + lenB + 1 + lenA*sizeof(WCHAR), strB + lenB + 1, (lenB + 1)*sizeof(WCHAR)); return str; } - // ANSIz + ANSIzUCS2z = ANSIzUCS2z -char *m_awstrcat(LPCSTR strA, LPCSTR strB) { +char* m_awstrcat(LPCSTR strA, LPCSTR strB) +{ int lenA = (int)strlen(strA); - LPSTR tmpA = (LPSTR)mir_alloc((lenA+1)*(sizeof(WCHAR)+1)); + LPSTR tmpA = (LPSTR)mir_alloc((lenA + 1)*(sizeof(WCHAR) + 1)); strcpy(tmpA, strA); - MultiByteToWideChar(CP_ACP, 0, strA, -1, (LPWSTR)(tmpA+lenA+1), (lenA+1)*sizeof(WCHAR)); + MultiByteToWideChar(CP_ACP, 0, strA, -1, (LPWSTR)(tmpA + lenA + 1), (lenA + 1)*sizeof(WCHAR)); LPSTR str = m_wwstrcat(tmpA, strB); mir_free(tmpA); return str; } - // ANSIz + ANSIz = ANSIzUCS2z -char *m_aastrcat(LPCSTR strA, LPCSTR strB) { +char* m_aastrcat(LPCSTR strA, LPCSTR strB) +{ int lenA = (int)strlen(strA); int lenB = (int)strlen(strB); - LPSTR str = (LPSTR)mir_alloc((lenA+lenB+1)*(sizeof(WCHAR)+1)); - strcpy(str,strA); - strcat(str,strB); - MultiByteToWideChar(CP_ACP, 0, str, -1, (LPWSTR)(str+lenA+lenB+1), (lenA+lenB+1)*sizeof(WCHAR)); + LPSTR str = (LPSTR)mir_alloc((lenA + lenB + 1)*(sizeof(WCHAR) + 1)); + strcpy(str, strA); + strcat(str, strB); + MultiByteToWideChar(CP_ACP, 0, str, -1, (LPWSTR)(str + lenA + lenB + 1), (lenA + lenB + 1)*sizeof(WCHAR)); return str; } - LPSTR m_string = NULL; // ANSIz + ANSIz = ANSIz -char *m_ustrcat(LPCSTR strA, LPCSTR strB) { +char* m_ustrcat(LPCSTR strA, LPCSTR strB) +{ SAFE_FREE(m_string); - m_string = (LPSTR) mir_alloc(strlen(strA)+strlen(strB)+1); - strcpy(m_string,strA); strcat(m_string,strB); + m_string = (LPSTR)mir_alloc(strlen(strA) + strlen(strB) + 1); + strcpy(m_string, strA); strcat(m_string, strB); return m_string; } - LPSTR m_hex = NULL; -LPSTR to_hex(PBYTE bin, int len) { +LPSTR to_hex(PBYTE bin, int len) +{ SAFE_FREE(m_hex); - m_hex = (LPSTR) mir_alloc(len*3+1); + m_hex = (LPSTR)mir_alloc(len * 3 + 1); LPSTR m_ptr = m_hex; - for ( int i=0; iutf8decode(szUtfMsg); LPSTR szMsg = mir_u2a(wszMsg); - flags |= PREF_UNICODE; - int olen = (int)wcslen((LPWSTR)wszMsg)+1; - int nlen = olen*(sizeof(WCHAR)+1); - szNewMsg = (LPSTR) mir_alloc(nlen); - memcpy(szNewMsg,szMsg,olen); - memcpy(szNewMsg+olen,wszMsg,olen*sizeof(WCHAR)); - mir_free(szMsg); + flags |= PREF_UNICODE; + int olen = (int)wcslen((LPWSTR)wszMsg) + 1; + int nlen = olen*(sizeof(WCHAR) + 1); + szNewMsg = (LPSTR)mir_alloc(nlen); + memcpy(szNewMsg, szMsg, olen); + memcpy(szNewMsg + olen, wszMsg, olen*sizeof(WCHAR)); + mir_free(szMsg); } else { flags &= ~PREF_UNICODE; flags |= PREF_UTF; - szNewMsg = (LPSTR) mir_strdup(szUtfMsg); + szNewMsg = (LPSTR)mir_strdup(szUtfMsg); } return szNewMsg; } - -// ЇаҐ®Ўа §гҐ¬ ⥪бв Ё§ д®а¬ в  ¬Ёа ­¤л ў зЁбвл© UTF8 -LPSTR miranda_to_utf8(LPCSTR szMirMsg, DWORD flags) { +// преобразуем текст из формата миранды в чистый UTF8 +LPSTR miranda_to_utf8(LPCSTR szMirMsg, DWORD flags) +{ LPSTR szNewMsg; - if (flags & PREF_UTF) { - szNewMsg = (LPSTR) szMirMsg; - } - else - if (flags & PREF_UNICODE) { - szNewMsg = exp->utf8encode((LPCWSTR)(szMirMsg+strlen(szMirMsg)+1)); - } + if (flags & PREF_UTF) + szNewMsg = (LPSTR)szMirMsg; + else if (flags & PREF_UNICODE) + szNewMsg = exp->utf8encode((LPCWSTR)(szMirMsg + strlen(szMirMsg) + 1)); else { LPWSTR wszMirMsg = mir_a2u(szMirMsg); - szNewMsg = exp->utf8encode((LPCWSTR)wszMirMsg); + szNewMsg = exp->utf8encode(wszMirMsg); mir_free(wszMirMsg); } return mir_strdup(szNewMsg); } - - -// EOF diff --git a/plugins/SecureIM/src/options.cpp b/plugins/SecureIM/src/options.cpp index 219aad76c9..fbf31470ed 100644 --- a/plugins/SecureIM/src/options.cpp +++ b/plugins/SecureIM/src/options.cpp @@ -9,13 +9,13 @@ BOOL hasKey(pUinKey ptr) { BOOL ret = 0; if (ptr->mode == MODE_NATIVE) { - LPSTR str = db_get_sa(ptr->hContact,MODULENAME,"PSK"); + LPSTR str = db_get_sa(ptr->hContact, MODULENAME, "PSK"); ret = (str != NULL); SAFE_FREE(str); } else if (ptr->mode == MODE_RSAAES) { DBVARIANT dbv; dbv.type = DBVT_BLOB; - if (db_get(ptr->hContact,MODULENAME,"rsa_pub",&dbv) == 0) { + if (db_get(ptr->hContact, MODULENAME, "rsa_pub", &dbv) == 0) { ret = 1; db_free(&dbv); } @@ -46,7 +46,7 @@ int LV_InsertItem(HWND hwnd, LVITEM *lvi) int LV_InsertItemA(HWND hwnd, LVITEM *lvi) { - lvi->pszText = (LPSTR) mir_a2u(lvi->pszText); + lvi->pszText = (LPSTR)mir_a2u(lvi->pszText); int ret = LV_InsertItem(hwnd, lvi); mir_free(lvi->pszText); return ret; @@ -54,7 +54,7 @@ int LV_InsertItemA(HWND hwnd, LVITEM *lvi) void LV_SetItemText(HWND hwnd, WPARAM wparam, int subitem, LPSTR text) { - LV_ITEM lvi; memset(&lvi,0,sizeof(lvi)); + LV_ITEM lvi; memset(&lvi, 0, sizeof(lvi)); lvi.iSubItem = subitem; lvi.pszText = text; SNDMSG(hwnd, LVM_SETITEMTEXTW, wparam, (LPARAM)&lvi); @@ -62,14 +62,14 @@ void LV_SetItemText(HWND hwnd, WPARAM wparam, int subitem, LPSTR text) void LV_SetItemTextA(HWND hwnd, WPARAM wparam, int subitem, LPSTR text) { - text = (LPSTR) mir_a2u(text); + text = (LPSTR)mir_a2u(text); LV_SetItemText(hwnd, wparam, subitem, text); mir_free(text); } void LV_GetItemTextA(HWND hwnd, WPARAM wparam, int iSubItem, LPSTR text, int cchTextMax) { - LV_ITEM lvi; memset(&lvi,0,sizeof(lvi)); + LV_ITEM lvi; memset(&lvi, 0, sizeof(lvi)); lvi.iSubItem = iSubItem; lvi.cchTextMax = cchTextMax; lvi.pszText = text; @@ -88,43 +88,41 @@ INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara static int iInit = TRUE; TCITEM tci; - switch(msg) { + switch (msg) { case WM_INITDIALOG: - { - iInit = TRUE; - tci.mask = TCIF_PARAM|TCIF_TEXT; - - tci.lParam = (LPARAM)CreateDialog(g_hInst,MAKEINTRESOURCE(IDD_TAB_GENERAL),hwnd,DlgProcOptionsGeneral); - tci.pszText = (LPSTR)sim201; - TC_InsertItem(GetDlgItem(hwnd, IDC_OPTIONSTAB), 0, &tci); + iInit = TRUE; + tci.mask = TCIF_PARAM | TCIF_TEXT; + + tci.lParam = (LPARAM)CreateDialog(g_hInst, MAKEINTRESOURCE(IDD_TAB_GENERAL), hwnd, DlgProcOptionsGeneral); + tci.pszText = (LPSTR)sim201; + TC_InsertItem(GetDlgItem(hwnd, IDC_OPTIONSTAB), 0, &tci); + EnableThemeDialogTexture((HWND)tci.lParam, ETDT_ENABLETAB); + + tci.lParam = (LPARAM)CreateDialog(g_hInst, MAKEINTRESOURCE(IDD_TAB_PROTO), hwnd, DlgProcOptionsProto); + tci.pszText = (LPSTR)sim202; + TC_InsertItem(GetDlgItem(hwnd, IDC_OPTIONSTAB), 2, &tci); + EnableThemeDialogTexture((HWND)tci.lParam, ETDT_ENABLETAB); + ShowWindow((HWND)tci.lParam, SW_HIDE); + + if (bPGP && bPGPloaded) { + tci.lParam = (LPARAM)CreateDialog(g_hInst, MAKEINTRESOURCE(IDD_TAB_PGP), hwnd, DlgProcOptionsPGP); + tci.pszText = (LPSTR)sim214; + TC_InsertItem(GetDlgItem(hwnd, IDC_OPTIONSTAB), 3, &tci); EnableThemeDialogTexture((HWND)tci.lParam, ETDT_ENABLETAB); + ShowWindow((HWND)tci.lParam, SW_HIDE); + } - tci.lParam = (LPARAM)CreateDialog(g_hInst,MAKEINTRESOURCE(IDD_TAB_PROTO),hwnd,DlgProcOptionsProto); - tci.pszText = (LPSTR)sim202; - TC_InsertItem(GetDlgItem(hwnd, IDC_OPTIONSTAB), 2, &tci); + if (bGPG && bGPGloaded) { + tci.lParam = (LPARAM)CreateDialog(g_hInst, MAKEINTRESOURCE(IDD_TAB_GPG), hwnd, DlgProcOptionsGPG); + tci.pszText = (LPSTR)sim226; + TC_InsertItem(GetDlgItem(hwnd, IDC_OPTIONSTAB), 4, &tci); EnableThemeDialogTexture((HWND)tci.lParam, ETDT_ENABLETAB); ShowWindow((HWND)tci.lParam, SW_HIDE); - - if (bPGP && bPGPloaded) { - tci.lParam = (LPARAM)CreateDialog(g_hInst,MAKEINTRESOURCE(IDD_TAB_PGP),hwnd,DlgProcOptionsPGP); - tci.pszText = (LPSTR)sim214; - TC_InsertItem(GetDlgItem(hwnd, IDC_OPTIONSTAB), 3, &tci); - EnableThemeDialogTexture((HWND)tci.lParam, ETDT_ENABLETAB); - ShowWindow((HWND)tci.lParam, SW_HIDE); - } - - if (bGPG && bGPGloaded) { - tci.lParam = (LPARAM)CreateDialog(g_hInst,MAKEINTRESOURCE(IDD_TAB_GPG),hwnd,DlgProcOptionsGPG); - tci.pszText = (LPSTR)sim226; - TC_InsertItem(GetDlgItem(hwnd, IDC_OPTIONSTAB), 4, &tci); - EnableThemeDialogTexture((HWND)tci.lParam, ETDT_ENABLETAB); - ShowWindow((HWND)tci.lParam, SW_HIDE); - } - - // add more tabs here if needed - // activate the final tab - iInit = FALSE; } + + // add more tabs here if needed + // activate the final tab + iInit = FALSE; return TRUE; case PSM_CHANGED: // used so tabs dont have to call SendMessage(GetParent(GetParent(hwnd)), PSM_CHANGED, 0, 0); @@ -133,39 +131,39 @@ INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara break; case WM_COMMAND: - switch(LOWORD(wParam)) { + switch (LOWORD(wParam)) { case ID_UPDATE_CLIST: tci.mask = TCIF_PARAM; - TabCtrl_GetItem(GetDlgItem(hwnd,IDC_OPTIONSTAB),0,&tci); - SendMessage((HWND)tci.lParam,WM_COMMAND,ID_UPDATE_CLIST,0); + TabCtrl_GetItem(GetDlgItem(hwnd, IDC_OPTIONSTAB), 0, &tci); + SendMessage((HWND)tci.lParam, WM_COMMAND, ID_UPDATE_CLIST, 0); 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); + 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); + TabCtrl_GetItem(GetDlgItem(hwnd, IDC_OPTIONSTAB), 3, &tci); + SendMessage((HWND)tci.lParam, WM_COMMAND, ID_UPDATE_GLIST, 0); break; } break; case WM_NOTIFY: - switch(((LPNMHDR)lParam)->idFrom) { + switch (((LPNMHDR)lParam)->idFrom) { case 0: switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: tci.mask = TCIF_PARAM; - int cnt = TabCtrl_GetItemCount(GetDlgItem(hwnd,IDC_OPTIONSTAB)); - for (int i=0;icode) { case TCN_SELCHANGING: tci.mask = TCIF_PARAM; - TabCtrl_GetItem(GetDlgItem(hwnd,IDC_OPTIONSTAB),TabCtrl_GetCurSel(GetDlgItem(hwnd,IDC_OPTIONSTAB)),&tci); - ShowWindow((HWND)tci.lParam,SW_HIDE); + TabCtrl_GetItem(GetDlgItem(hwnd, IDC_OPTIONSTAB), TabCtrl_GetCurSel(GetDlgItem(hwnd, IDC_OPTIONSTAB)), &tci); + ShowWindow((HWND)tci.lParam, SW_HIDE); break; case TCN_SELCHANGE: tci.mask = TCIF_PARAM; - TabCtrl_GetItem(GetDlgItem(hwnd,IDC_OPTIONSTAB),TabCtrl_GetCurSel(GetDlgItem(hwnd,IDC_OPTIONSTAB)),&tci); - ShowWindow((HWND)tci.lParam,SW_SHOW); + TabCtrl_GetItem(GetDlgItem(hwnd, IDC_OPTIONSTAB), TabCtrl_GetCurSel(GetDlgItem(hwnd, IDC_OPTIONSTAB)), &tci); + ShowWindow((HWND)tci.lParam, SW_SHOW); break; } } @@ -197,9 +195,9 @@ INT_PTR CALLBACK DlgProcOptionsGeneral(HWND hDlg, UINT wMsg, WPARAM wParam, LPAR { static int iInit = TRUE; static HIMAGELIST hLarge, hSmall; - int i,idx; pUinKey ptr; + int i, idx; pUinKey ptr; - HWND hLV = GetDlgItem(hDlg,IDC_STD_USERLIST); + HWND hLV = GetDlgItem(hDlg, IDC_STD_USERLIST); switch (wMsg) { case WM_INITDIALOG: @@ -210,7 +208,7 @@ INT_PTR CALLBACK DlgProcOptionsGeneral(HWND hDlg, UINT wMsg, WPARAM wParam, LPAR hLarge = ImageList_Create(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), iBmpDepth, 1, 1); hSmall = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), iBmpDepth, 1, 1); - for (i=0; i < ICO_CNT; i++) { + for (i = 0; i < ICO_CNT; i++) { ImageList_AddIcon(hSmall, g_hICO[i]); ImageList_AddIcon(hLarge, g_hICO[i]); } @@ -224,7 +222,7 @@ INT_PTR CALLBACK DlgProcOptionsGeneral(HWND hDlg, UINT wMsg, WPARAM wParam, LPAR LVCOLUMN lvc; lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; lvc.fmt = LVCFMT_LEFT; - for (i=0; szColHdr[i]; i++) { + for (i = 0; szColHdr[i]; i++) { lvc.iSubItem = i; lvc.pszText = (LPSTR)szColHdr[i]; lvc.cx = iColWidth[i]; @@ -232,7 +230,7 @@ INT_PTR CALLBACK DlgProcOptionsGeneral(HWND hDlg, UINT wMsg, WPARAM wParam, LPAR } } - RefreshGeneralDlg(hDlg,TRUE); + RefreshGeneralDlg(hDlg, TRUE); EnableWindow(hLV, true); iInit = FALSE; @@ -245,20 +243,20 @@ INT_PTR CALLBACK DlgProcOptionsGeneral(HWND hDlg, UINT wMsg, WPARAM wParam, LPAR case WM_PAINT: if (!iInit) - InvalidateRect(hDlg,NULL,FALSE); + InvalidateRect(hDlg, NULL, FALSE); break; case WM_COMMAND: - switch(LOWORD(wParam)) { + switch (LOWORD(wParam)) { case ID_ALWAYS: case ID_ENABLED: case ID_DISABLED: idx = ListView_GetSelectionMark(hLV); - ptr = (pUinKey) getListViewParam(hLV,idx); + ptr = (pUinKey)getListViewParam(hLV, idx); if (ptr) { - ptr->tstatus = LOWORD(wParam)-ID_DISABLED; - setListViewStatus(hLV,idx,ptr->tstatus); - setListViewIcon(hLV,idx,ptr); + ptr->tstatus = LOWORD(wParam) - ID_DISABLED; + setListViewStatus(hLV, idx, ptr->tstatus); + setListViewIcon(hLV, idx, ptr); } break; @@ -268,77 +266,77 @@ INT_PTR CALLBACK DlgProcOptionsGeneral(HWND hDlg, UINT wMsg, WPARAM wParam, LPAR case ID_SIM_RSAAES: case ID_SIM_RSA: idx = ListView_GetSelectionMark(hLV); - ptr = (pUinKey) getListViewParam(hLV,idx); + ptr = (pUinKey)getListViewParam(hLV, idx); if (ptr) { - ptr->tmode = LOWORD(wParam)-ID_SIM_NATIVE; - setListViewMode(hLV,idx,ptr->tmode); - setListViewIcon(hLV,idx,ptr); + ptr->tmode = LOWORD(wParam) - ID_SIM_NATIVE; + setListViewMode(hLV, idx, ptr->tmode); + setListViewIcon(hLV, idx, ptr); } break; case ID_SETPSK: idx = ListView_GetSelectionMark(hLV); - ptr = (pUinKey) getListViewParam(hLV,idx); + ptr = (pUinKey)getListViewParam(hLV, idx); if (ptr) { - LPSTR buffer = (LPSTR)alloca(PSKSIZE+1); + LPSTR buffer = (LPSTR)alloca(PSKSIZE + 1); getContactName(ptr->hContact, buffer); - int res = DialogBoxParam(g_hInst,MAKEINTRESOURCE(IDD_PSK),NULL,DlgProcSetPSK,(LPARAM)buffer); + int res = DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_PSK), NULL, DlgProcSetPSK, (LPARAM)buffer); if (res == IDOK) { - setListViewPSK(hLV,idx,1); - db_set_s(ptr->hContact,MODULENAME,"tPSK",buffer); + setListViewPSK(hLV, idx, 1); + db_set_s(ptr->hContact, MODULENAME, "tPSK", buffer); } } break; case ID_DELPSK: idx = ListView_GetSelectionMark(hLV); - ptr = (pUinKey) getListViewParam(hLV,idx); + ptr = (pUinKey)getListViewParam(hLV, idx); if (ptr) { - setListViewPSK(hLV,idx,0); + setListViewPSK(hLV, idx, 0); db_unset(ptr->hContact, MODULENAME, "tPSK"); } break; case ID_DELPUBL: idx = ListView_GetSelectionMark(hLV); - ptr = (pUinKey) getListViewParam(hLV,idx); + ptr = (pUinKey)getListViewParam(hLV, idx); if (ptr) { - setListViewPUB(hLV,idx,0); + setListViewPUB(hLV, idx, 0); } break; case ID_EXPPUBL: idx = ListView_GetSelectionMark(hLV); - ptr = (pUinKey) getListViewParam(hLV,idx); + ptr = (pUinKey)getListViewParam(hLV, idx); if (ptr) { if (!ptr->keyLoaded) { createRSAcntx(ptr); loadRSAkey(ptr); } if (ptr->keyLoaded) { - LPSTR buffer = (LPSTR) alloca(RSASIZE); - exp->rsa_export_pubkey(ptr->cntx,buffer); - if (!SaveExportRSAKeyDlg(hDlg,buffer,0)) - msgbox(hDlg,sim114,MODULENAME,MB_OK|MB_ICONEXCLAMATION); + LPSTR buffer = (LPSTR)alloca(RSASIZE); + exp->rsa_export_pubkey(ptr->cntx, buffer); + if (!SaveExportRSAKeyDlg(hDlg, buffer, 0)) + msgbox(hDlg, sim114, MODULENAME, MB_OK | MB_ICONEXCLAMATION); } } return TRUE; case ID_IMPPUBL: idx = ListView_GetSelectionMark(hLV); - ptr = (pUinKey) getListViewParam(hLV,idx); + ptr = (pUinKey)getListViewParam(hLV, idx); if (ptr) { createRSAcntx(ptr); - LPSTR pub = (LPSTR) alloca(RSASIZE); - if (!LoadImportRSAKeyDlg(hDlg,pub,0)) return TRUE; - if (exp->rsa_import_pubkey(ptr->cntx,pub)) { + LPSTR pub = (LPSTR)alloca(RSASIZE); + 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); db_set_blob(ptr->hContact, MODULENAME, "rsa_pub", pub, len); - setListViewPUB(hLV,idx,1); + setListViewPUB(hLV, idx, 1); } - else msgbox(hDlg,sim115,MODULENAME,MB_OK|MB_ICONEXCLAMATION); + else msgbox(hDlg, sim115, MODULENAME, MB_OK | MB_ICONEXCLAMATION); } return TRUE; @@ -387,7 +385,7 @@ INT_PTR CALLBACK DlgProcOptionsGeneral(HWND hDlg, UINT wMsg, WPARAM wParam, LPAR break; case WM_NOTIFY: - switch(((LPNMHDR)lParam)->idFrom) { + switch (((LPNMHDR)lParam)->idFrom) { case 0: if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY) { iInit = TRUE; @@ -398,82 +396,82 @@ INT_PTR CALLBACK DlgProcOptionsGeneral(HWND hDlg, UINT wMsg, WPARAM wParam, LPAR break; case IDC_STD_USERLIST: - switch(((LPNMHDR)lParam)->code) { + switch (((LPNMHDR)lParam)->code) { case NM_DBLCLK: if (LPNMLISTVIEW(lParam)->iSubItem == 2) { idx = LPNMLISTVIEW(lParam)->iItem; - ptr = (pUinKey) getListViewParam(hLV,idx); + 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; - setListViewMode(hLV,idx,ptr->tmode); - setListViewIcon(hLV,idx,ptr); + 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); } } if (LPNMLISTVIEW(lParam)->iSubItem == 3) { idx = LPNMLISTVIEW(lParam)->iItem; - ptr = (pUinKey) getListViewParam(hLV,idx); + ptr = (pUinKey)getListViewParam(hLV, idx); if (ptr) { - ptr->tstatus++; if (ptr->tstatus>(ptr->tmode == MODE_RSAAES?1:2)) ptr->tstatus=0; - setListViewStatus(hLV,idx,ptr->tstatus); - setListViewIcon(hLV,idx,ptr); + ptr->tstatus++; if (ptr->tstatus > (ptr->tmode == MODE_RSAAES ? 1 : 2)) ptr->tstatus = 0; + setListViewStatus(hLV, idx, ptr->tstatus); + setListViewIcon(hLV, idx, ptr); SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); } } break; case NM_RCLICK: - { - LPNMLISTVIEW lpLV = (LPNMLISTVIEW)lParam; - ptr = (pUinKey) getListViewParam(hLV,lpLV->iItem); - if (ptr) { - POINT p; GetCursorPos(&p); - HMENU hMenu = NULL; - if (ptr->tmode == MODE_NATIVE || ptr->tmode == MODE_RSAAES) { - switch( lpLV->iSubItem) { - case 2: // mode - hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDM_CLIST2)); - break; - case 3: // status - hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE((ptr->tmode == MODE_NATIVE)?IDM_CLIST01:IDM_CLIST11)); - break; - case 4: // PSK/PUB - case 5: // SHA1 - hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE((ptr->tmode == MODE_NATIVE)?IDM_CLIST02:IDM_CLIST12)); - break; - default: // full menu - hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE((ptr->tmode == MODE_NATIVE)?IDM_CLIST0:IDM_CLIST1)); - break; - } - CheckMenuItem(hMenu, ID_DISABLED+ptr->tstatus, MF_CHECKED ); - if (ptr->tmode == MODE_NATIVE) { - if (!hasKey(ptr)) EnableMenuItem(hMenu, ID_DELPSK, MF_GRAYED ); - } - else if (ptr->tmode == MODE_RSAAES) { - if (!hasKey(ptr)) { - EnableMenuItem(hMenu, ID_EXPPUBL, MF_GRAYED ); - EnableMenuItem(hMenu, ID_DELPUBL, MF_GRAYED ); - } + { + LPNMLISTVIEW lpLV = (LPNMLISTVIEW)lParam; + ptr = (pUinKey)getListViewParam(hLV, lpLV->iItem); + if (ptr) { + POINT p; GetCursorPos(&p); + HMENU hMenu = NULL; + if (ptr->tmode == MODE_NATIVE || ptr->tmode == MODE_RSAAES) { + switch (lpLV->iSubItem) { + case 2: // mode + hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDM_CLIST2)); + break; + case 3: // status + hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE((ptr->tmode == MODE_NATIVE) ? IDM_CLIST01 : IDM_CLIST11)); + break; + case 4: // PSK/PUB + case 5: // SHA1 + hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE((ptr->tmode == MODE_NATIVE) ? IDM_CLIST02 : IDM_CLIST12)); + break; + default: // full menu + hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE((ptr->tmode == MODE_NATIVE) ? IDM_CLIST0 : IDM_CLIST1)); + break; + } + CheckMenuItem(hMenu, ID_DISABLED + ptr->tstatus, MF_CHECKED); + if (ptr->tmode == MODE_NATIVE) { + if (!hasKey(ptr)) EnableMenuItem(hMenu, ID_DELPSK, MF_GRAYED); + } + else if (ptr->tmode == MODE_RSAAES) { + if (!hasKey(ptr)) { + EnableMenuItem(hMenu, ID_EXPPUBL, MF_GRAYED); + EnableMenuItem(hMenu, ID_DELPUBL, MF_GRAYED); } } - if (!hMenu ) - hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDM_CLIST2)); - TranslateMenu(hMenu); - 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 ); - TrackPopupMenu(GetSubMenu(hMenu, 0), TPM_LEFTALIGN | TPM_TOPALIGN, p.x, p.y, 0, hDlg, 0); - DestroyMenu(hMenu); } + if (!hMenu) + hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDM_CLIST2)); + TranslateMenu(hMenu); + 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); + TrackPopupMenu(GetSubMenu(hMenu, 0), TPM_LEFTALIGN | TPM_TOPALIGN, p.x, p.y, 0, hDlg, 0); + DestroyMenu(hMenu); } + } break; case LVN_COLUMNCLICK: bChangeSortOrder = true; - ListView_Sort(hLV,(LPARAM)(LPNMLISTVIEW(lParam)->iSubItem+0x01)); + ListView_Sort(hLV, (LPARAM)(LPNMLISTVIEW(lParam)->iSubItem + 0x01)); bChangeSortOrder = false; } break; @@ -489,7 +487,7 @@ INT_PTR CALLBACK DlgProcOptionsProto(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM char buf[32]; int idx; - HWND hLV = GetDlgItem(hDlg,IDC_PROTO); + HWND hLV = GetDlgItem(hDlg, IDC_PROTO); switch (wMsg) { case WM_INITDIALOG: @@ -513,54 +511,54 @@ INT_PTR CALLBACK DlgProcOptionsProto(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM case WM_PAINT: if (!iInit) - InvalidateRect(hDlg,NULL,FALSE); + InvalidateRect(hDlg, NULL, FALSE); break; case WM_COMMAND: - switch(LOWORD(wParam)) { + switch (LOWORD(wParam)) { case IDC_RSA_COPY: char txt[128]; GetDlgItemText(hDlg, IDC_RSA_SHA, txt, sizeof(txt)); - CopyToClipboard(hDlg,txt); + CopyToClipboard(hDlg, txt); return TRUE; case IDC_RSA_EXP: - { - LPSTR pub = (LPSTR) alloca(RSASIZE); - exp->rsa_export_keypair(CPP_MODE_RSA,NULL,pub,NULL); - if (!SaveExportRSAKeyDlg(hDlg,pub,0)) - msgbox(hDlg,sim114,MODULENAME,MB_OK|MB_ICONEXCLAMATION); - } + { + LPSTR pub = (LPSTR)alloca(RSASIZE); + exp->rsa_export_keypair(CPP_MODE_RSA, NULL, pub, NULL); + if (!SaveExportRSAKeyDlg(hDlg, pub, 0)) + msgbox(hDlg, sim114, MODULENAME, MB_OK | MB_ICONEXCLAMATION); + } return TRUE; case IDC_RSA_EXPPRIV: - { - LPSTR passphrase = (LPSTR) alloca(RSASIZE); - int res = DialogBoxParam(g_hInst,MAKEINTRESOURCE(IDD_PASSPHRASE),NULL,DlgProcSetPassphrase,(LPARAM)passphrase); - if (res == IDOK) { - LPSTR priv = (LPSTR) alloca(RSASIZE); - exp->rsa_export_keypair(CPP_MODE_RSA,priv,NULL,passphrase); - if (!SaveExportRSAKeyDlg(hDlg,priv,1)) - msgbox(hDlg,sim112,MODULENAME,MB_OK|MB_ICONEXCLAMATION); - } + { + LPSTR passphrase = (LPSTR)alloca(RSASIZE); + int res = DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_PASSPHRASE), NULL, DlgProcSetPassphrase, (LPARAM)passphrase); + if (res == IDOK) { + LPSTR priv = (LPSTR)alloca(RSASIZE); + exp->rsa_export_keypair(CPP_MODE_RSA, priv, NULL, passphrase); + if (!SaveExportRSAKeyDlg(hDlg, priv, 1)) + msgbox(hDlg, sim112, MODULENAME, MB_OK | MB_ICONEXCLAMATION); } + } return TRUE; case IDC_RSA_IMPPRIV: - { - LPSTR priv = (LPSTR) alloca(RSASIZE); - if (!LoadImportRSAKeyDlg(hDlg,priv,1)) - return TRUE; + { + LPSTR priv = (LPSTR)alloca(RSASIZE); + if (!LoadImportRSAKeyDlg(hDlg, priv, 1)) + return TRUE; - LPSTR passphrase = (LPSTR) alloca(RSASIZE); - int res = DialogBoxParam(g_hInst,MAKEINTRESOURCE(IDD_PASSPHRASE),NULL,DlgProcSetPassphrase,(LPARAM)passphrase); - if (res == IDOK) { - if (!exp->rsa_import_keypair(CPP_MODE_RSA,priv,passphrase)) - msgbox(hDlg,sim113,MODULENAME,MB_OK|MB_ICONEXCLAMATION); - else // обновить SHA1 значение - RefreshProtoDlg(hDlg); - } + LPSTR passphrase = (LPSTR)alloca(RSASIZE); + int res = DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_PASSPHRASE), NULL, DlgProcSetPassphrase, (LPARAM)passphrase); + if (res == IDOK) { + if (!exp->rsa_import_keypair(CPP_MODE_RSA, priv, passphrase)) + msgbox(hDlg, sim113, MODULENAME, MB_OK | MB_ICONEXCLAMATION); + else // обновить SHA1 значение + RefreshProtoDlg(hDlg); } + } return TRUE; case IDC_SPLITON: @@ -569,15 +567,15 @@ INT_PTR CALLBACK DlgProcOptionsProto(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM idx = ListView_GetSelectionMark(hLV); if (idx == -1) break; - + idx = getListViewParam(hLV, idx); - switch(LOWORD(wParam)) { + switch (LOWORD(wParam)) { case IDC_SPLITON: - GetDlgItemText(hDlg,IDC_SPLITON,buf,5); + GetDlgItemText(hDlg, IDC_SPLITON, buf, 5); arProto[idx]->tsplit_on = atoi(buf); break; case IDC_SPLITOFF: - GetDlgItemText(hDlg,IDC_SPLITOFF,buf,5); + GetDlgItemText(hDlg, IDC_SPLITOFF, buf, 5); arProto[idx]->tsplit_off = atoi(buf); break; } @@ -589,28 +587,28 @@ INT_PTR CALLBACK DlgProcOptionsProto(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM break; case WM_NOTIFY: - switch(((LPNMHDR)lParam)->idFrom) { + switch (((LPNMHDR)lParam)->idFrom) { case 0: if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY) { iInit = TRUE; ApplyProtoSettings(hDlg); RefreshProtoDlg(hDlg); RefreshContactListIcons(); - SendMessage(GetParent(hDlg),WM_COMMAND,ID_UPDATE_CLIST,0); + SendMessage(GetParent(hDlg), WM_COMMAND, ID_UPDATE_CLIST, 0); iInit = FALSE; } break; case IDC_PROTO: if (((LPNMHDR)lParam)->code == (UINT)NM_CLICK) { - idx = (int)getListViewParam(hLV,LPNMLISTVIEW(lParam)->iItem); + idx = (int)getListViewParam(hLV, LPNMLISTVIEW(lParam)->iItem); if (idx == -1) break; - EnableWindow(GetDlgItem(hDlg,IDC_SPLITON), true); - EnableWindow(GetDlgItem(hDlg,IDC_SPLITOFF), true); - mir_itoa(arProto[idx]->tsplit_on,buf,10); SetDlgItemText(hDlg,IDC_SPLITON,buf); - mir_itoa(arProto[idx]->tsplit_off,buf,10); SetDlgItemText(hDlg,IDC_SPLITOFF,buf); + EnableWindow(GetDlgItem(hDlg, IDC_SPLITON), true); + EnableWindow(GetDlgItem(hDlg, IDC_SPLITOFF), true); + mir_itoa(arProto[idx]->tsplit_on, buf, 10); SetDlgItemText(hDlg, IDC_SPLITON, buf); + mir_itoa(arProto[idx]->tsplit_off, buf, 10); SetDlgItemText(hDlg, IDC_SPLITOFF, buf); SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); } } @@ -627,7 +625,7 @@ INT_PTR CALLBACK DlgProcOptionsPGP(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM l static HIMAGELIST hLarge, hSmall; int i; - HWND hLV = GetDlgItem(hDlg,IDC_PGP_USERLIST); + HWND hLV = GetDlgItem(hDlg, IDC_PGP_USERLIST); switch (wMsg) { case WM_INITDIALOG: @@ -658,7 +656,7 @@ INT_PTR CALLBACK DlgProcOptionsPGP(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM l LV_InsertColumn(hLV, i, &lvc); } } - RefreshPGPDlg(hDlg,TRUE); + RefreshPGPDlg(hDlg, TRUE); iInit = FALSE; return TRUE; @@ -669,52 +667,52 @@ INT_PTR CALLBACK DlgProcOptionsPGP(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM l case WM_PAINT: if (!iInit) - InvalidateRect(hDlg,NULL,FALSE); + InvalidateRect(hDlg, NULL, FALSE); break; case WM_COMMAND: - switch(LOWORD(wParam)) { + switch (LOWORD(wParam)) { case IDC_SET_KEYRINGS: - { - char PubRingPath[MAX_PATH], SecRingPath[MAX_PATH]; - PubRingPath[0]='\0'; SecRingPath[0]='\0'; - bPGPkeyrings = pgp_open_keyrings(PubRingPath,SecRingPath); - if (bPGPkeyrings && PubRingPath[0] && SecRingPath[0]) { - db_set_s(0,MODULENAME,"pgpPubRing",PubRingPath); - db_set_s(0,MODULENAME,"pgpSecRing",SecRingPath); - } - SetDlgItemText(hDlg, IDC_KEYRING_STATUS, bPGPkeyrings?Translate(sim216):Translate(sim217)); + { + char PubRingPath[MAX_PATH], SecRingPath[MAX_PATH]; + PubRingPath[0] = '\0'; SecRingPath[0] = '\0'; + bPGPkeyrings = pgp_open_keyrings(PubRingPath, SecRingPath); + if (bPGPkeyrings && PubRingPath[0] && SecRingPath[0]) { + db_set_s(0, MODULENAME, "pgpPubRing", PubRingPath); + db_set_s(0, MODULENAME, "pgpSecRing", SecRingPath); } + SetDlgItemText(hDlg, IDC_KEYRING_STATUS, bPGPkeyrings ? Translate(sim216) : Translate(sim217)); + } return FALSE; case IDC_NO_KEYRINGS: - { - BOOL bNoKR = (SendMessage(GetDlgItem(hDlg, IDC_NO_KEYRINGS),BM_GETCHECK,0L,0L) == BST_CHECKED); - EnableWindow(GetDlgItem(hDlg, IDC_SET_KEYRINGS), !bNoKR); - EnableWindow(GetDlgItem(hDlg, IDC_LOAD_PRIVKEY), bNoKR); - SetDlgItemText(hDlg, IDC_KEYRING_STATUS, bNoKR?Translate(sim225):((bPGP9)?Translate(sim220):(bPGPkeyrings?Translate(sim216):Translate(sim217)))); - } + { + BOOL bNoKR = (SendMessage(GetDlgItem(hDlg, IDC_NO_KEYRINGS), BM_GETCHECK, 0L, 0L) == BST_CHECKED); + EnableWindow(GetDlgItem(hDlg, IDC_SET_KEYRINGS), !bNoKR); + EnableWindow(GetDlgItem(hDlg, IDC_LOAD_PRIVKEY), bNoKR); + SetDlgItemText(hDlg, IDC_KEYRING_STATUS, bNoKR ? Translate(sim225) : ((bPGP9) ? Translate(sim220) : (bPGPkeyrings ? Translate(sim216) : Translate(sim217)))); + } break; case IDC_LOAD_PRIVKEY: - { - char KeyPath[MAX_PATH]; KeyPath[0]='\0'; - if (ShowSelectKeyDlg(hDlg,KeyPath)) { - char *priv = LoadKeys(KeyPath,true); - if (priv) { - db_set_s(0,MODULENAME,"tpgpPrivKey",priv); - mir_free(priv); - } - else { - db_unset(0,MODULENAME,"tpgpPrivKey"); - } + { + char KeyPath[MAX_PATH]; KeyPath[0] = '\0'; + if (ShowSelectKeyDlg(hDlg, KeyPath)) { + char *priv = LoadKeys(KeyPath, true); + if (priv) { + db_set_s(0, MODULENAME, "tpgpPrivKey", priv); + mir_free(priv); + } + else { + db_unset(0, MODULENAME, "tpgpPrivKey"); } } + } break; case ID_UPDATE_PLIST: iInit = TRUE; - RefreshPGPDlg(hDlg,FALSE); + RefreshPGPDlg(hDlg, FALSE); iInit = FALSE; return TRUE; } @@ -723,21 +721,21 @@ INT_PTR CALLBACK DlgProcOptionsPGP(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM l break; case WM_NOTIFY: - switch(((LPNMHDR)lParam)->idFrom) { + switch (((LPNMHDR)lParam)->idFrom) { case 0: if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY) { iInit = TRUE; ApplyPGPSettings(hDlg); - RefreshPGPDlg(hDlg,FALSE); + RefreshPGPDlg(hDlg, FALSE); iInit = FALSE; } break; case IDC_PGP_USERLIST: - switch(((LPNMHDR)lParam)->code) { + switch (((LPNMHDR)lParam)->code) { case LVN_COLUMNCLICK: bChangeSortOrder = true; - ListView_Sort(hLV,(LPARAM)(LPNMLISTVIEW(lParam)->iSubItem+0x11)); + ListView_Sort(hLV, (LPARAM)(LPNMLISTVIEW(lParam)->iSubItem + 0x11)); bChangeSortOrder = false; break; } @@ -753,7 +751,7 @@ INT_PTR CALLBACK DlgProcOptionsGPG(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM l static HIMAGELIST hLarge, hSmall; int i, idx; pUinKey ptr; - HWND hLV = GetDlgItem(hDlg,IDC_GPG_USERLIST); + HWND hLV = GetDlgItem(hDlg, IDC_GPG_USERLIST); switch (wMsg) { case WM_INITDIALOG: @@ -785,7 +783,7 @@ INT_PTR CALLBACK DlgProcOptionsGPG(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM l } } - RefreshGPGDlg(hDlg,TRUE); + RefreshGPGDlg(hDlg, TRUE); iInit = FALSE; return TRUE; @@ -796,37 +794,37 @@ INT_PTR CALLBACK DlgProcOptionsGPG(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM l case WM_PAINT: if (!iInit) - InvalidateRect(hDlg,NULL,FALSE); + InvalidateRect(hDlg, NULL, FALSE); break; case WM_COMMAND: - switch(LOWORD(wParam)) { + switch (LOWORD(wParam)) { case IDC_BROWSEEXECUTABLE_BTN: - { - char gpgexe[256]; - char filter[128]; - GetDlgItemText(hDlg, IDC_GPGEXECUTABLE_EDIT, gpgexe, sizeof(gpgexe)); - - // filter zusammensetzen - mir_snprintf(filter, SIZEOF(filter), _T("%s (*.exe)%c*.exe%c%c"), Translate("Executable Files"), 0, 0, 0); - - // OPENFILENAME initialisieren - OPENFILENAME ofn = { sizeof(ofn) }; - ofn.hwndOwner = hDlg; - ofn.lpstrFilter = filter; - ofn.lpstrFile = gpgexe; - ofn.nMaxFile = sizeof(gpgexe); - ofn.lpstrTitle = Translate("Select GnuPG Executable"); - ofn.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_HIDEREADONLY; - - if (GetOpenFileName(&ofn)) - SetDlgItemText(hDlg, IDC_GPGEXECUTABLE_EDIT, ofn.lpstrFile); - } + { + char gpgexe[256]; + char filter[128]; + GetDlgItemText(hDlg, IDC_GPGEXECUTABLE_EDIT, gpgexe, sizeof(gpgexe)); + + // filter zusammensetzen + mir_snprintf(filter, SIZEOF(filter), _T("%s (*.exe)%c*.exe%c%c"), Translate("Executable Files"), 0, 0, 0); + + // OPENFILENAME initialisieren + OPENFILENAME ofn = { sizeof(ofn) }; + ofn.hwndOwner = hDlg; + ofn.lpstrFilter = filter; + ofn.lpstrFile = gpgexe; + ofn.nMaxFile = sizeof(gpgexe); + ofn.lpstrTitle = Translate("Select GnuPG Executable"); + ofn.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_HIDEREADONLY; + + if (GetOpenFileName(&ofn)) + SetDlgItemText(hDlg, IDC_GPGEXECUTABLE_EDIT, ofn.lpstrFile); + } break; case ID_UPDATE_GLIST: iInit = TRUE; - RefreshGPGDlg(hDlg,FALSE); + RefreshGPGDlg(hDlg, FALSE); iInit = FALSE; return TRUE; } @@ -835,32 +833,32 @@ INT_PTR CALLBACK DlgProcOptionsGPG(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM l break; case WM_NOTIFY: - switch(((LPNMHDR)lParam)->idFrom) { + switch (((LPNMHDR)lParam)->idFrom) { case 0: if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY) { iInit = TRUE; ApplyGPGSettings(hDlg); - RefreshGPGDlg(hDlg,FALSE); + RefreshGPGDlg(hDlg, FALSE); iInit = FALSE; } break; case IDC_GPG_USERLIST: - switch(((LPNMHDR)lParam)->code) { + switch (((LPNMHDR)lParam)->code) { case NM_DBLCLK: if (LPNMLISTVIEW(lParam)->iSubItem == 3) { idx = LPNMLISTVIEW(lParam)->iItem; - ptr = (pUinKey) getListViewParam(hLV,idx); - if (!ptr ) break; - ptr->tgpgMode++; ptr->tgpgMode&=1; - LV_SetItemTextA(hLV, LPNMLISTVIEW(lParam)->iItem, LPNMLISTVIEW(lParam)->iSubItem, (ptr->tgpgMode)?Translate(sim228):Translate(sim229)); + ptr = (pUinKey)getListViewParam(hLV, idx); + 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); } break; case LVN_COLUMNCLICK: bChangeSortOrder = true; - ListView_Sort(hLV,(LPARAM)(LPNMLISTVIEW(lParam)->iSubItem+0x21)); + ListView_Sort(hLV, (LPARAM)(LPNMLISTVIEW(lParam)->iSubItem + 0x21)); bChangeSortOrder = false; } } @@ -869,29 +867,29 @@ INT_PTR CALLBACK DlgProcOptionsGPG(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM l return FALSE; } -INT_PTR CALLBACK DlgProcSetPSK(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) +INT_PTR CALLBACK DlgProcSetPSK(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { static char *buffer; - switch(uMsg) { + switch (uMsg) { case WM_INITDIALOG: TranslateDialogDefault(hDlg); - SendDlgItemMessage(hDlg, IDC_EDIT1, EM_LIMITTEXT, PSKSIZE-1, 0); + SendDlgItemMessage(hDlg, IDC_EDIT1, EM_LIMITTEXT, PSKSIZE - 1, 0); SetDlgItemTextW(hDlg, IDC_EDIT2, (LPWSTR)lParam); buffer = (LPSTR)lParam; return TRUE; case WM_COMMAND: - switch(LOWORD(wParam)) { + switch (LOWORD(wParam)) { case IDOK: if (GetDlgItemTextA(hDlg, IDC_EDIT1, buffer, PSKSIZE) < 8) { msgbox1(hDlg, sim211, MODULENAME, MB_OK | MB_ICONEXCLAMATION); return TRUE; } - EndDialog(hDlg,IDOK); + EndDialog(hDlg, IDOK); break; case IDCANCEL: - EndDialog(hDlg,IDCANCEL); + EndDialog(hDlg, IDCANCEL); break; } break; @@ -903,26 +901,26 @@ INT_PTR CALLBACK DlgProcSetPSK(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) } -INT_PTR CALLBACK DlgProcSetPassphrase(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) +INT_PTR CALLBACK DlgProcSetPassphrase(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { static LPSTR buffer; - switch(uMsg) { + switch (uMsg) { case WM_INITDIALOG: TranslateDialogDefault(hDlg); - SendDlgItemMessage(hDlg,IDC_PASSPHRASE,EM_LIMITTEXT,RSASIZE-1,0); + SendDlgItemMessage(hDlg, IDC_PASSPHRASE, EM_LIMITTEXT, RSASIZE - 1, 0); buffer = (LPSTR)lParam; return TRUE; case WM_COMMAND: - switch(LOWORD(wParam)) { + switch (LOWORD(wParam)) { case IDOK: - GetDlgItemTextA(hDlg,IDC_PASSPHRASE,buffer,RSASIZE); - EndDialog(hDlg,IDOK); + GetDlgItemTextA(hDlg, IDC_PASSPHRASE, buffer, RSASIZE); + EndDialog(hDlg, IDOK); break; case IDCANCEL: - EndDialog(hDlg,IDCANCEL); + EndDialog(hDlg, IDCANCEL); break; } break; @@ -943,36 +941,36 @@ void RefreshGeneralDlg(HWND hDlg, BOOL iInit) // Key Exchange Timeout UINT data = db_get_w(0, MODULENAME, "ket", 10); - mir_itoa(data,timeout,10); - SetDlgItemText(hDlg,IDC_KET,timeout); + mir_itoa(data, timeout, 10); + SetDlgItemText(hDlg, IDC_KET, timeout); // Offline Key Timeout data = db_get_w(0, MODULENAME, "okt", 2); - mir_itoa(data,timeout,10); - SetDlgItemText(hDlg,IDC_OKT,timeout); + mir_itoa(data, timeout, 10); + SetDlgItemText(hDlg, IDC_OKT, timeout); GetFlags(); - SendMessage( GetDlgItem(hDlg,IDC_SFT), BM_SETCHECK, (bSFT) ? BST_CHECKED : BST_UNCHECKED, 0); - SendMessage( GetDlgItem(hDlg,IDC_SOM), BM_SETCHECK, (bSOM) ? BST_CHECKED : BST_UNCHECKED, 0); - SendMessage( GetDlgItem(hDlg,IDC_ASI), BM_SETCHECK, (bASI) ? BST_CHECKED : BST_UNCHECKED, 0); - SendMessage( GetDlgItem(hDlg,IDC_MCD), BM_SETCHECK, (bMCD) ? BST_CHECKED : BST_UNCHECKED, 0); - SendMessage( GetDlgItem(hDlg,IDC_SCM), BM_SETCHECK, (bSCM) ? BST_CHECKED : BST_UNCHECKED, 0); - SendMessage( GetDlgItem(hDlg,IDC_DGP), BM_SETCHECK, (bDGP) ? BST_CHECKED : BST_UNCHECKED, 0); - SendMessage( GetDlgItem(hDlg,IDC_AIP), BM_SETCHECK, (bAIP) ? BST_CHECKED : BST_UNCHECKED, 0); - SendMessage( GetDlgItem(hDlg,IDC_NOL), BM_SETCHECK, (bNOL) ? BST_CHECKED : BST_UNCHECKED, 0); - SendMessage( GetDlgItem(hDlg,IDC_AAK), BM_SETCHECK, (bAAK) ? BST_CHECKED : BST_UNCHECKED, 0); - SendMessage( GetDlgItem(hDlg,IDC_MCM), BM_SETCHECK, (bMCM) ? BST_CHECKED : BST_UNCHECKED, 0); + SendMessage(GetDlgItem(hDlg, IDC_SFT), BM_SETCHECK, (bSFT) ? BST_CHECKED : BST_UNCHECKED, 0); + SendMessage(GetDlgItem(hDlg, IDC_SOM), BM_SETCHECK, (bSOM) ? BST_CHECKED : BST_UNCHECKED, 0); + SendMessage(GetDlgItem(hDlg, IDC_ASI), BM_SETCHECK, (bASI) ? BST_CHECKED : BST_UNCHECKED, 0); + SendMessage(GetDlgItem(hDlg, IDC_MCD), BM_SETCHECK, (bMCD) ? BST_CHECKED : BST_UNCHECKED, 0); + SendMessage(GetDlgItem(hDlg, IDC_SCM), BM_SETCHECK, (bSCM) ? BST_CHECKED : BST_UNCHECKED, 0); + SendMessage(GetDlgItem(hDlg, IDC_DGP), BM_SETCHECK, (bDGP) ? BST_CHECKED : BST_UNCHECKED, 0); + SendMessage(GetDlgItem(hDlg, IDC_AIP), BM_SETCHECK, (bAIP) ? BST_CHECKED : BST_UNCHECKED, 0); + SendMessage(GetDlgItem(hDlg, IDC_NOL), BM_SETCHECK, (bNOL) ? BST_CHECKED : BST_UNCHECKED, 0); + SendMessage(GetDlgItem(hDlg, IDC_AAK), BM_SETCHECK, (bAAK) ? BST_CHECKED : BST_UNCHECKED, 0); + SendMessage(GetDlgItem(hDlg, IDC_MCM), BM_SETCHECK, (bMCM) ? BST_CHECKED : BST_UNCHECKED, 0); // Select {OFF,PGP,GPG} - SendMessage( GetDlgItem(hDlg,IDC_PGP), BM_SETCHECK, bPGP ? BST_CHECKED : BST_UNCHECKED, 0); - SendMessage( GetDlgItem(hDlg,IDC_GPG), BM_SETCHECK, bGPG ? BST_CHECKED : BST_UNCHECKED, 0); + SendMessage(GetDlgItem(hDlg, IDC_PGP), BM_SETCHECK, bPGP ? BST_CHECKED : BST_UNCHECKED, 0); + SendMessage(GetDlgItem(hDlg, IDC_GPG), BM_SETCHECK, bGPG ? BST_CHECKED : BST_UNCHECKED, 0); // rebuild list of contacts - HWND hLV = GetDlgItem(hDlg,IDC_STD_USERLIST); + HWND hLV = GetDlgItem(hDlg, IDC_STD_USERLIST); ListView_DeleteAllItems(hLV); - LVITEM lvi; memset(&lvi,0,sizeof(lvi)); + LVITEM lvi; memset(&lvi, 0, sizeof(lvi)); lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; char tmp[NAMSIZE]; @@ -998,37 +996,37 @@ 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); } } - ListView_Sort(hLV,0); + ListView_Sort(hLV, 0); } void RefreshProtoDlg(HWND hDlg) { - HWND hLV = GetDlgItem(hDlg,IDC_PROTO); + HWND hLV = GetDlgItem(hDlg, IDC_PROTO); ListView_DeleteAllItems(hLV); LVITEM lvi = { 0 }; lvi.mask = LVIF_TEXT | LVIF_PARAM; - for (int i=0; i < arProto.getCount(); i++) { - lvi.iItem = i+1; + for (int i = 0; i < arProto.getCount(); i++) { + lvi.iItem = i + 1; lvi.pszText = arProto[i]->name; lvi.lParam = (LPARAM)i; int itemNum = LV_InsertItemA(hLV, &lvi); - ListView_SetCheckState(hLV,itemNum, arProto[i]->inspecting); + ListView_SetCheckState(hLV, itemNum, arProto[i]->inspecting); } - SetDlgItemText(hDlg,IDC_SPLITON,_T("0")); - SetDlgItemText(hDlg,IDC_SPLITOFF,_T("0")); - EnableWindow(GetDlgItem(hDlg,IDC_SPLITON), false); - EnableWindow(GetDlgItem(hDlg,IDC_SPLITOFF), false); + SetDlgItemText(hDlg, IDC_SPLITON, _T("0")); + SetDlgItemText(hDlg, IDC_SPLITOFF, _T("0")); + EnableWindow(GetDlgItem(hDlg, IDC_SPLITON), false); + EnableWindow(GetDlgItem(hDlg, IDC_SPLITOFF), false); - BYTE sha[64]; int len; exp->rsa_get_keyhash(CPP_MODE_RSA,NULL,NULL,(PBYTE)&sha,&len); - LPSTR txt = mir_strdup(to_hex(sha,len)); + BYTE sha[64]; int len; exp->rsa_get_keyhash(CPP_MODE_RSA, NULL, NULL, (PBYTE)&sha, &len); + LPSTR txt = mir_strdup(to_hex(sha, len)); SetDlgItemText(hDlg, IDC_RSA_SHA, txt); mir_free(txt); } @@ -1036,11 +1034,11 @@ void RefreshProtoDlg(HWND hDlg) void RefreshPGPDlg(HWND hDlg, BOOL iInit) { int ver = pgp_get_version(); - bPGP9 = (ver>=0x03050000); + bPGP9 = (ver >= 0x03050000); EnableWindow(GetDlgItem(hDlg, IDC_SET_KEYRINGS), bUseKeyrings && !bPGP9); EnableWindow(GetDlgItem(hDlg, IDC_LOAD_PRIVKEY), !bUseKeyrings); - SetDlgItemText(hDlg, IDC_PGP_PRIVKEY, bPGPprivkey?Translate(sim222):Translate(sim223)); + SetDlgItemText(hDlg, IDC_PGP_PRIVKEY, bPGPprivkey ? Translate(sim222) : Translate(sim223)); if (bPGPloaded && ver) { char pgpVerStr[64]; @@ -1049,16 +1047,16 @@ void RefreshPGPDlg(HWND hDlg, BOOL iInit) } else SetDlgItemText(hDlg, IDC_PGP_SDK, Translate(sim219)); - SetDlgItemText(hDlg, IDC_KEYRING_STATUS, !bUseKeyrings?Translate(sim225):((bPGP9)?Translate(sim220):(bPGPkeyrings?Translate(sim216):Translate(sim217)))); + SetDlgItemText(hDlg, IDC_KEYRING_STATUS, !bUseKeyrings ? Translate(sim225) : ((bPGP9) ? Translate(sim220) : (bPGPkeyrings ? Translate(sim216) : Translate(sim217)))); // Disable keyrings use - SendMessage(GetDlgItem(hDlg,IDC_NO_KEYRINGS),BM_SETCHECK,(bUseKeyrings)?BST_UNCHECKED:BST_CHECKED,0L); + SendMessage(GetDlgItem(hDlg, IDC_NO_KEYRINGS), BM_SETCHECK, (bUseKeyrings) ? BST_UNCHECKED : BST_CHECKED, 0L); // rebuild list of contacts - HWND hLV = GetDlgItem(hDlg,IDC_PGP_USERLIST); + HWND hLV = GetDlgItem(hDlg, IDC_PGP_USERLIST); ListView_DeleteAllItems(hLV); - LVITEM lvi; memset(&lvi,0,sizeof(lvi)); + LVITEM lvi; memset(&lvi, 0, sizeof(lvi)); lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; char tmp[NAMSIZE]; @@ -1066,7 +1064,7 @@ void RefreshPGPDlg(HWND hDlg, BOOL iInit) for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { pUinKey ptr = getUinKey(hContact); if (ptr && ptr->mode == MODE_PGP && isSecureProtocol(hContact) && !isChatRoom(hContact)) { - LPSTR szKeyID = db_get_sa(hContact,MODULENAME,"pgp_abbr"); + LPSTR szKeyID = db_get_sa(hContact, MODULENAME, "pgp_abbr"); lvi.iItem++; lvi.iImage = (szKeyID != 0); @@ -1079,46 +1077,46 @@ void RefreshPGPDlg(HWND hDlg, BOOL iInit) getContactUin(hContact, tmp); LV_SetItemText(hLV, itemNum, 1, tmp); - LV_SetItemTextA(hLV, itemNum, 2, (szKeyID)?szKeyID:Translate(sim221)); + LV_SetItemTextA(hLV, itemNum, 2, (szKeyID) ? szKeyID : Translate(sim221)); SAFE_FREE(szKeyID); } } - ListView_Sort(hLV,(LPARAM)0x10); + ListView_Sort(hLV, (LPARAM)0x10); } void RefreshGPGDlg(HWND hDlg, BOOL iInit) { - LPSTR path = db_get_sa(0,MODULENAME,"gpgExec"); + LPSTR path = db_get_sa(0, MODULENAME, "gpgExec"); if (path) { SetDlgItemText(hDlg, IDC_GPGEXECUTABLE_EDIT, path); mir_free(path); } - path = db_get_sa(0,MODULENAME,"gpgHome"); + path = db_get_sa(0, MODULENAME, "gpgHome"); if (path) { SetDlgItemText(hDlg, IDC_GPGHOME_EDIT, path); mir_free(path); } - BOOL bGPGLogFlag = db_get_b(0, MODULENAME, "gpgLogFlag",0); - SendMessage(GetDlgItem(hDlg,IDC_LOGGINGON_CBOX),BM_SETCHECK,(bGPGLogFlag)?BST_CHECKED:BST_UNCHECKED,0L); - path = db_get_sa(0,MODULENAME,"gpgLog"); + BOOL bGPGLogFlag = db_get_b(0, MODULENAME, "gpgLogFlag", 0); + SendMessage(GetDlgItem(hDlg, IDC_LOGGINGON_CBOX), BM_SETCHECK, (bGPGLogFlag) ? BST_CHECKED : BST_UNCHECKED, 0L); + path = db_get_sa(0, MODULENAME, "gpgLog"); if (path) { SetDlgItemText(hDlg, IDC_GPGLOGFILE_EDIT, path); mir_free(path); } - SendMessage(GetDlgItem(hDlg,IDC_SAVEPASS_CBOX),BM_SETCHECK,(bSavePass)?BST_CHECKED:BST_UNCHECKED,0L); - BOOL bGPGTmpFlag = db_get_b(0, MODULENAME, "gpgTmpFlag",0); - SendMessage(GetDlgItem(hDlg,IDC_TMPPATHON_CBOX),BM_SETCHECK,(bGPGTmpFlag)?BST_CHECKED:BST_UNCHECKED,0L); - path = db_get_sa(0,MODULENAME,"gpgTmp"); + SendMessage(GetDlgItem(hDlg, IDC_SAVEPASS_CBOX), BM_SETCHECK, (bSavePass) ? BST_CHECKED : BST_UNCHECKED, 0L); + BOOL bGPGTmpFlag = db_get_b(0, MODULENAME, "gpgTmpFlag", 0); + SendMessage(GetDlgItem(hDlg, IDC_TMPPATHON_CBOX), BM_SETCHECK, (bGPGTmpFlag) ? BST_CHECKED : BST_UNCHECKED, 0L); + path = db_get_sa(0, MODULENAME, "gpgTmp"); if (path) { SetDlgItemText(hDlg, IDC_GPGTMPPATH_EDIT, path); mir_free(path); } // rebuild list of contacts - HWND hLV = GetDlgItem(hDlg,IDC_GPG_USERLIST); + HWND hLV = GetDlgItem(hDlg, IDC_GPG_USERLIST); ListView_DeleteAllItems(hLV); - LVITEM lvi; memset(&lvi,0,sizeof(lvi)); + LVITEM lvi; memset(&lvi, 0, sizeof(lvi)); lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; char tmp[NAMSIZE]; @@ -1126,10 +1124,10 @@ void RefreshGPGDlg(HWND hDlg, BOOL iInit) for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { pUinKey ptr = getUinKey(hContact); if (ptr && ptr->mode == MODE_GPG && isSecureProtocol(hContact) && !isChatRoom(hContact)) { - if (iInit ) + if (iInit) ptr->tgpgMode = ptr->gpgMode; - LPSTR szKeyID = db_get_sa(hContact,MODULENAME,"gpg"); + LPSTR szKeyID = db_get_sa(hContact, MODULENAME, "gpg"); lvi.iItem++; lvi.iImage = (szKeyID != 0); @@ -1142,12 +1140,12 @@ void RefreshGPGDlg(HWND hDlg, BOOL iInit) getContactUin(hContact, tmp); LV_SetItemText(hLV, itemNum, 1, tmp); - LV_SetItemTextA(hLV, itemNum, 2, (szKeyID)?szKeyID:Translate(sim221)); - LV_SetItemTextA(hLV, itemNum, 3, (ptr->tgpgMode)?Translate(sim228):Translate(sim229)); + LV_SetItemTextA(hLV, itemNum, 2, (szKeyID) ? szKeyID : Translate(sim221)); + LV_SetItemTextA(hLV, itemNum, 3, (ptr->tgpgMode) ? Translate(sim228) : Translate(sim229)); SAFE_FREE(szKeyID); } } - ListView_Sort(hLV,(LPARAM)0x20); + ListView_Sort(hLV, (LPARAM)0x20); } /////////////// @@ -1156,23 +1154,23 @@ void RefreshGPGDlg(HWND hDlg, BOOL iInit) void ResetGeneralDlg(HWND hDlg) { - SetDlgItemText(hDlg,IDC_KET,_T("10")); - SetDlgItemText(hDlg,IDC_OKT,_T("2")); - - SendMessage(GetDlgItem(hDlg,IDC_SFT),BM_SETCHECK,BST_UNCHECKED,0L); - SendMessage(GetDlgItem(hDlg,IDC_SOM),BM_SETCHECK,BST_UNCHECKED,0L); - SendMessage(GetDlgItem(hDlg,IDC_ASI),BM_SETCHECK,BST_UNCHECKED,0L); - SendMessage(GetDlgItem(hDlg,IDC_MCD),BM_SETCHECK,BST_UNCHECKED,0L); - SendMessage(GetDlgItem(hDlg,IDC_SCM),BM_SETCHECK,BST_UNCHECKED,0L); - SendMessage(GetDlgItem(hDlg,IDC_DGP),BM_SETCHECK,BST_UNCHECKED,0L); - SendMessage(GetDlgItem(hDlg,IDC_AIP),BM_SETCHECK,BST_UNCHECKED,0L); - SendMessage(GetDlgItem(hDlg,IDC_MCM),BM_SETCHECK,BST_UNCHECKED,0L); + SetDlgItemText(hDlg, IDC_KET, _T("10")); + SetDlgItemText(hDlg, IDC_OKT, _T("2")); + + SendMessage(GetDlgItem(hDlg, IDC_SFT), BM_SETCHECK, BST_UNCHECKED, 0L); + SendMessage(GetDlgItem(hDlg, IDC_SOM), BM_SETCHECK, BST_UNCHECKED, 0L); + SendMessage(GetDlgItem(hDlg, IDC_ASI), BM_SETCHECK, BST_UNCHECKED, 0L); + SendMessage(GetDlgItem(hDlg, IDC_MCD), BM_SETCHECK, BST_UNCHECKED, 0L); + SendMessage(GetDlgItem(hDlg, IDC_SCM), BM_SETCHECK, BST_UNCHECKED, 0L); + SendMessage(GetDlgItem(hDlg, IDC_DGP), BM_SETCHECK, BST_UNCHECKED, 0L); + SendMessage(GetDlgItem(hDlg, IDC_AIP), BM_SETCHECK, BST_UNCHECKED, 0L); + SendMessage(GetDlgItem(hDlg, IDC_MCM), BM_SETCHECK, BST_UNCHECKED, 0L); // rebuild list of contacts - HWND hLV = GetDlgItem(hDlg,IDC_STD_USERLIST); + HWND hLV = GetDlgItem(hDlg, IDC_STD_USERLIST); ListView_DeleteAllItems(hLV); - LVITEM lvi; memset(&lvi,0,sizeof(lvi)); + LVITEM lvi; memset(&lvi, 0, sizeof(lvi)); lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; char tmp[NAMSIZE]; @@ -1183,8 +1181,8 @@ void ResetGeneralDlg(HWND hDlg) pUinKey ptr = getUinKey(hContact); if (!ptr) continue; - ptr->tmode=MODE_NATIVE; - ptr->tstatus=STATUS_ENABLED; + ptr->tmode = MODE_NATIVE; + ptr->tstatus = STATUS_ENABLED; lvi.iItem++; lvi.iImage = ptr->tstatus; @@ -1199,7 +1197,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); } @@ -1212,57 +1210,57 @@ void ResetGeneralDlg(HWND hDlg) void ApplyGeneralSettings(HWND hDlg) { char timeout[5]; - int tmp,i; + int tmp, i; // Key Exchange Timeout - GetDlgItemText(hDlg,IDC_KET,timeout,5); + GetDlgItemText(hDlg, IDC_KET, timeout, 5); tmp = atoi(timeout); if (tmp > 65535) tmp = 65535; - db_set_w(0,MODULENAME,"ket",tmp); - exp->rsa_set_timeout( db_get_w(0,MODULENAME,"ket",10)); - mir_itoa(tmp,timeout,10); - SetDlgItemText(hDlg,IDC_KET,timeout); + db_set_w(0, MODULENAME, "ket", tmp); + exp->rsa_set_timeout(db_get_w(0, MODULENAME, "ket", 10)); + mir_itoa(tmp, timeout, 10); + SetDlgItemText(hDlg, IDC_KET, timeout); // Offline Key Timeout - GetDlgItemText(hDlg,IDC_OKT,timeout,5); + GetDlgItemText(hDlg, IDC_OKT, timeout, 5); tmp = atoi(timeout); if (tmp > 65535) tmp = 65535; - db_set_w(0,MODULENAME,"okt",tmp); - mir_itoa(tmp,timeout,10); - SetDlgItemText(hDlg,IDC_OKT,timeout); - - bSFT = (SendMessage(GetDlgItem(hDlg, IDC_SFT),BM_GETCHECK,0L,0L) == BST_CHECKED); - bSOM = (SendMessage(GetDlgItem(hDlg, IDC_SOM),BM_GETCHECK,0L,0L) == BST_CHECKED); - bASI = (SendMessage(GetDlgItem(hDlg, IDC_ASI),BM_GETCHECK,0L,0L) == BST_CHECKED); - bMCD = (SendMessage(GetDlgItem(hDlg, IDC_MCD),BM_GETCHECK,0L,0L) == BST_CHECKED); - bSCM = (SendMessage(GetDlgItem(hDlg, IDC_SCM),BM_GETCHECK,0L,0L) == BST_CHECKED); - bDGP = (SendMessage(GetDlgItem(hDlg, IDC_DGP),BM_GETCHECK,0L,0L) == BST_CHECKED); - bAIP = (SendMessage(GetDlgItem(hDlg, IDC_AIP),BM_GETCHECK,0L,0L) == BST_CHECKED); - bNOL = (SendMessage(GetDlgItem(hDlg, IDC_NOL),BM_GETCHECK,0L,0L) == BST_CHECKED); - bAAK = (SendMessage(GetDlgItem(hDlg, IDC_AAK),BM_GETCHECK,0L,0L) == BST_CHECKED); - bMCM = (SendMessage(GetDlgItem(hDlg, IDC_MCM),BM_GETCHECK,0L,0L) == BST_CHECKED); + db_set_w(0, MODULENAME, "okt", tmp); + mir_itoa(tmp, timeout, 10); + SetDlgItemText(hDlg, IDC_OKT, timeout); + + bSFT = (SendMessage(GetDlgItem(hDlg, IDC_SFT), BM_GETCHECK, 0L, 0L) == BST_CHECKED); + bSOM = (SendMessage(GetDlgItem(hDlg, IDC_SOM), BM_GETCHECK, 0L, 0L) == BST_CHECKED); + bASI = (SendMessage(GetDlgItem(hDlg, IDC_ASI), BM_GETCHECK, 0L, 0L) == BST_CHECKED); + bMCD = (SendMessage(GetDlgItem(hDlg, IDC_MCD), BM_GETCHECK, 0L, 0L) == BST_CHECKED); + bSCM = (SendMessage(GetDlgItem(hDlg, IDC_SCM), BM_GETCHECK, 0L, 0L) == BST_CHECKED); + bDGP = (SendMessage(GetDlgItem(hDlg, IDC_DGP), BM_GETCHECK, 0L, 0L) == BST_CHECKED); + bAIP = (SendMessage(GetDlgItem(hDlg, IDC_AIP), BM_GETCHECK, 0L, 0L) == BST_CHECKED); + bNOL = (SendMessage(GetDlgItem(hDlg, IDC_NOL), BM_GETCHECK, 0L, 0L) == BST_CHECKED); + bAAK = (SendMessage(GetDlgItem(hDlg, IDC_AAK), BM_GETCHECK, 0L, 0L) == BST_CHECKED); + bMCM = (SendMessage(GetDlgItem(hDlg, IDC_MCM), BM_GETCHECK, 0L, 0L) == BST_CHECKED); SetFlags(); // PGP &| GPG flags { tmp = 0; - i = SendMessage(GetDlgItem(hDlg, IDC_PGP),BM_GETCHECK,0L,0L) == BST_CHECKED; + i = SendMessage(GetDlgItem(hDlg, IDC_PGP), BM_GETCHECK, 0L, 0L) == BST_CHECKED; if (i != bPGP) { bPGP = i; tmp++; db_set_b(0, MODULENAME, "pgp", bPGP); } - i = SendMessage(GetDlgItem(hDlg, IDC_GPG),BM_GETCHECK,0L,0L) == BST_CHECKED; + i = SendMessage(GetDlgItem(hDlg, IDC_GPG), BM_GETCHECK, 0L, 0L) == BST_CHECKED; if (i != bGPG) { bGPG = i; tmp++; db_set_b(0, MODULENAME, "gpg", bGPG); } - if (tmp) msgbox1(hDlg, sim224, MODULENAME, MB_OK|MB_ICONINFORMATION); + if (tmp) msgbox1(hDlg, sim224, MODULENAME, MB_OK | MB_ICONINFORMATION); } - HWND hLV = GetDlgItem(hDlg,IDC_STD_USERLIST); - i = ListView_GetNextItem(hLV,(UINT)-1,LVNI_ALL); - while(i != -1) { - pUinKey ptr = (pUinKey)getListViewParam(hLV,i); - if (!ptr ) continue; + HWND hLV = GetDlgItem(hDlg, IDC_STD_USERLIST); + 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) { ptr->mode = ptr->tmode; db_set_b(ptr->hContact, MODULENAME, "mode", ptr->mode); @@ -1273,8 +1271,8 @@ void ApplyGeneralSettings(HWND hDlg) else db_set_b(ptr->hContact, MODULENAME, "StatusID", ptr->status); } if (ptr->mode == MODE_NATIVE) { - if (getListViewPSK(hLV,i)) { - LPSTR tmp = db_get_sa(ptr->hContact,MODULENAME,"tPSK"); + if (getListViewPSK(hLV, i)) { + LPSTR tmp = db_get_sa(ptr->hContact, MODULENAME, "tPSK"); db_set_s(ptr->hContact, MODULENAME, "PSK", tmp); mir_free(tmp); } @@ -1283,45 +1281,45 @@ void ApplyGeneralSettings(HWND hDlg) db_unset(ptr->hContact, MODULENAME, "tPSK"); } else if (ptr->mode == MODE_RSAAES) { - if (!getListViewPUB(hLV,i)) + if (!getListViewPUB(hLV, i)) db_unset(ptr->hContact, MODULENAME, "rsa_pub"); } - i = ListView_GetNextItem(hLV,i,LVNI_ALL); + i = ListView_GetNextItem(hLV, i, LVNI_ALL); } } void ApplyProtoSettings(HWND hDlg) { - LPSTR szNames = (LPSTR) alloca(2048); *szNames = '\0'; + LPSTR szNames = (LPSTR)alloca(2048); *szNames = '\0'; - HWND hLV = GetDlgItem(hDlg,IDC_PROTO); - int i = ListView_GetNextItem(hLV,(UINT)-1,LVNI_ALL); - while(i != -1) { - pSupPro p = arProto[ getListViewProto(hLV,i) ]; - p->inspecting = ListView_GetCheckState(hLV,i); + HWND hLV = GetDlgItem(hDlg, IDC_PROTO); + int i = ListView_GetNextItem(hLV, (UINT)-1, LVNI_ALL); + while (i != -1) { + pSupPro p = arProto[getListViewProto(hLV, i)]; + p->inspecting = ListView_GetCheckState(hLV, i); char tmp[128]; mir_snprintf(tmp, SIZEOF(tmp), "%s:%d:%d:%d;", p->name, p->inspecting, p->tsplit_on, p->tsplit_off); strcat(szNames, tmp); p->split_on = p->tsplit_on; p->split_off = p->tsplit_off; - i = ListView_GetNextItem(hLV,i,LVNI_ALL); + i = ListView_GetNextItem(hLV, i, LVNI_ALL); } - db_set_s(0,MODULENAME,"protos",szNames); + db_set_s(0, MODULENAME, "protos", szNames); } void ApplyPGPSettings(HWND hDlg) { - bUseKeyrings = !(SendMessage(GetDlgItem(hDlg, IDC_NO_KEYRINGS),BM_GETCHECK,0L,0L) == BST_CHECKED); - db_set_b(0,MODULENAME,"ukr",bUseKeyrings); + bUseKeyrings = !(SendMessage(GetDlgItem(hDlg, IDC_NO_KEYRINGS), BM_GETCHECK, 0L, 0L) == BST_CHECKED); + db_set_b(0, MODULENAME, "ukr", bUseKeyrings); - char *priv = db_get_sa(0,MODULENAME,"tpgpPrivKey"); + char *priv = db_get_sa(0, MODULENAME, "tpgpPrivKey"); if (priv) { bPGPprivkey = true; pgp_set_priv_key(priv); - db_set_s(0,MODULENAME,"pgpPrivKey",priv); + db_set_s(0, MODULENAME, "pgpPrivKey", priv); mir_free(priv); - db_unset(0,MODULENAME,"tpgpPrivKey"); + db_unset(0, MODULENAME, "tpgpPrivKey"); } } @@ -1330,39 +1328,39 @@ void ApplyGPGSettings(HWND hDlg) char tmp[256]; GetDlgItemText(hDlg, IDC_GPGEXECUTABLE_EDIT, tmp, sizeof(tmp)); - db_set_s(0,MODULENAME,"gpgExec",tmp); + db_set_s(0, MODULENAME, "gpgExec", tmp); GetDlgItemText(hDlg, IDC_GPGHOME_EDIT, tmp, sizeof(tmp)); - db_set_s(0,MODULENAME,"gpgHome",tmp); + db_set_s(0, MODULENAME, "gpgHome", tmp); - bSavePass = (SendMessage(GetDlgItem(hDlg, IDC_SAVEPASS_CBOX),BM_GETCHECK,0L,0L) == BST_CHECKED); - db_set_b(0,MODULENAME,"gpgSaveFlag",bSavePass); + bSavePass = (SendMessage(GetDlgItem(hDlg, IDC_SAVEPASS_CBOX), BM_GETCHECK, 0L, 0L) == BST_CHECKED); + db_set_b(0, MODULENAME, "gpgSaveFlag", bSavePass); - BOOL bgpgLogFlag = (SendMessage(GetDlgItem(hDlg, IDC_LOGGINGON_CBOX),BM_GETCHECK,0L,0L) == BST_CHECKED); - db_set_b(0,MODULENAME,"gpgLogFlag",bgpgLogFlag); + BOOL bgpgLogFlag = (SendMessage(GetDlgItem(hDlg, IDC_LOGGINGON_CBOX), BM_GETCHECK, 0L, 0L) == BST_CHECKED); + db_set_b(0, MODULENAME, "gpgLogFlag", bgpgLogFlag); GetDlgItemText(hDlg, IDC_GPGLOGFILE_EDIT, tmp, sizeof(tmp)); - db_set_s(0,MODULENAME,"gpgLog",tmp); + db_set_s(0, MODULENAME, "gpgLog", tmp); if (bgpgLogFlag) gpg_set_log(tmp); else gpg_set_log(0); - BOOL bgpgTmpFlag = (SendMessage(GetDlgItem(hDlg, IDC_TMPPATHON_CBOX),BM_GETCHECK,0L,0L) == BST_CHECKED); - db_set_b(0,MODULENAME,"gpgTmpFlag",bgpgTmpFlag); + BOOL bgpgTmpFlag = (SendMessage(GetDlgItem(hDlg, IDC_TMPPATHON_CBOX), BM_GETCHECK, 0L, 0L) == BST_CHECKED); + db_set_b(0, MODULENAME, "gpgTmpFlag", bgpgTmpFlag); GetDlgItemText(hDlg, IDC_GPGTMPPATH_EDIT, tmp, sizeof(tmp)); - db_set_s(0,MODULENAME,"gpgTmp",tmp); + db_set_s(0, MODULENAME, "gpgTmp", tmp); if (bgpgTmpFlag) gpg_set_tmp(tmp); else gpg_set_tmp(0); - HWND hLV = GetDlgItem(hDlg,IDC_GPG_USERLIST); - int i = ListView_GetNextItem(hLV,(UINT)-1,LVNI_ALL); - while(i != -1) { - pUinKey ptr = (pUinKey)getListViewParam(hLV,i); - if (!ptr ) continue; + HWND hLV = GetDlgItem(hDlg, IDC_GPG_USERLIST); + 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) { ptr->gpgMode = ptr->tgpgMode; - if (ptr->gpgMode ) db_set_b(ptr->hContact,MODULENAME,"gpgANSI",1); - else db_unset(ptr->hContact,MODULENAME,"gpgANSI"); - } + if (ptr->gpgMode) db_set_b(ptr->hContact, MODULENAME, "gpgANSI", 1); + else db_unset(ptr->hContact, MODULENAME, "gpgANSI"); + } - i = ListView_GetNextItem(hLV,i,LVNI_ALL); + i = ListView_GetNextItem(hLV, i, LVNI_ALL); } } @@ -1372,7 +1370,7 @@ void ApplyGPGSettings(HWND hDlg) LPARAM getListViewParam(HWND hLV, UINT iItem) { - LVITEM lvi; memset(&lvi,0,sizeof(lvi)); + LVITEM lvi; memset(&lvi, 0, sizeof(lvi)); lvi.iItem = iItem; lvi.mask = LVIF_PARAM; ListView_GetItem(hLV, &lvi); @@ -1381,12 +1379,12 @@ LPARAM getListViewParam(HWND hLV, UINT iItem) void setListViewIcon(HWND hLV, UINT iItem, pUinKey ptr) { - LVITEM lvi; memset(&lvi,0,sizeof(lvi)); + LVITEM lvi; memset(&lvi, 0, sizeof(lvi)); lvi.iItem = iItem; - switch(ptr->tmode) { + switch (ptr->tmode) { case MODE_NATIVE: case MODE_RSAAES: - lvi.iImage = ICO_ST_DIS+ptr->tstatus; + lvi.iImage = ICO_ST_DIS + ptr->tstatus; break; case MODE_PGP: lvi.iImage = ICO_OV_PGP; @@ -1423,7 +1421,7 @@ UINT getListViewPSK(HWND hLV, UINT iItem) void setListViewPSK(HWND hLV, UINT iItem, UINT iStatus) { char str[128]; - strncpy(str, (iStatus)?Translate(sim206):"-", sizeof(str)); + strncpy(str, (iStatus) ? Translate(sim206) : "-", sizeof(str)); LV_SetItemTextA(hLV, iItem, 4, str); } @@ -1437,18 +1435,18 @@ UINT getListViewPUB(HWND hLV, UINT iItem) void setListViewPUB(HWND hLV, UINT iItem, UINT iStatus) { char str[128]; - strncpy(str, (iStatus)?Translate(sim233):"-", sizeof(str)); + strncpy(str, (iStatus) ? Translate(sim233) : "-", sizeof(str)); LV_SetItemTextA(hLV, iItem, 4, str); LPSTR sha = NULL; if (iStatus) { DBVARIANT dbv; dbv.type = DBVT_BLOB; - pUinKey ptr = (pUinKey) getListViewParam(hLV, iItem); - if (db_get(ptr->hContact,MODULENAME,"rsa_pub",&dbv) == 0) { + pUinKey ptr = (pUinKey)getListViewParam(hLV, iItem); + if (db_get(ptr->hContact, MODULENAME, "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)); + exp->rsa_get_hash((PBYTE)dbv.pbVal, dbv.cpbVal, (PBYTE)str, &len); + sha = mir_strdup(to_hex((PBYTE)str, len)); db_free(&dbv); } } @@ -1463,7 +1461,7 @@ int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) { pUinKey p1 = pUinKey(lParam1), p2 = pUinKey(lParam2); char t1[NAMSIZE], t2[NAMSIZE]; - int s,d,m=1; + int s, d, m = 1; DBVARIANT dbv1 = { 0 }, dbv2 = { 0 }; if (lParamSort & 0x100) { @@ -1471,74 +1469,73 @@ int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) m = -1; } - switch(lParamSort){ + switch (lParamSort) { case 0x01: case 0x11: case 0x21: getContactNameA(p1->hContact, t1); getContactNameA(p2->hContact, t2); - return strncmp(t1,t2,NAMSIZE)*m; + return strncmp(t1, t2, NAMSIZE)*m; case 0x02: case 0x12: case 0x22: getContactUinA(p1->hContact, t1); getContactUinA(p2->hContact, t2); - return strncmp(t1,t2,NAMSIZE)*m; + return strncmp(t1, t2, NAMSIZE)*m; case 0x03: s = p1->tmode; d = p2->tmode; - return (s-d)*m; + return (s - d)*m; case 0x13: - db_get_s(p1->hContact,MODULENAME,"pgp_abbr",&dbv1); - db_get_s(p2->hContact,MODULENAME,"pgp_abbr",&dbv2); - s=(dbv1.type == DBVT_ASCIIZ); - d=(dbv2.type == DBVT_ASCIIZ); + db_get_s(p1->hContact, MODULENAME, "pgp_abbr", &dbv1); + db_get_s(p2->hContact, MODULENAME, "pgp_abbr", &dbv2); + s = (dbv1.type == DBVT_ASCIIZ); + d = (dbv2.type == DBVT_ASCIIZ); if (s && d) { - s=strcmp(dbv1.pszVal,dbv2.pszVal); - d=0; + s = strcmp(dbv1.pszVal, dbv2.pszVal); + d = 0; } db_free(&dbv1); db_free(&dbv2); - return (s-d)*m; + return (s - d)*m; case 0x23: - db_get_s(p1->hContact,MODULENAME,"gpg",&dbv1); - db_get_s(p2->hContact,MODULENAME,"gpg",&dbv2); + db_get_s(p1->hContact, MODULENAME, "gpg", &dbv1); + db_get_s(p2->hContact, MODULENAME, "gpg", &dbv2); s = (dbv1.type == DBVT_ASCIIZ); d = (dbv2.type == DBVT_ASCIIZ); if (s && d) { - s = strcmp(dbv1.pszVal,dbv2.pszVal); + s = strcmp(dbv1.pszVal, dbv2.pszVal); d = 0; } db_free(&dbv1); db_free(&dbv2); - return (s-d)*m; + return (s - d)*m; case 0x04: s = p1->tstatus; d = p2->tstatus; - return (s-d)*m; + return (s - d)*m; case 0x05: - db_get_s(p1->hContact,MODULENAME,"PSK",&dbv1); - s=(dbv1.type == DBVT_ASCIIZ); + db_get_s(p1->hContact, MODULENAME, "PSK", &dbv1); + s = (dbv1.type == DBVT_ASCIIZ); db_free(&dbv1); - db_get_s(p2->hContact,MODULENAME,"PSK",&dbv2); - d=(dbv2.type == DBVT_ASCIIZ); + db_get_s(p2->hContact, MODULENAME, "PSK", &dbv2); + d = (dbv2.type == DBVT_ASCIIZ); db_free(&dbv2); - return (s-d)*m; + return (s - d)*m; } return 0; } void ListView_Sort(HWND hLV, LPARAM lParamSort) { - char t[32]; - // restore sort column + char t[32]; mir_snprintf(t, SIZEOF(t), "os%02x", (UINT)lParamSort & 0xF0); if ((lParamSort & 0x0F) == 0) lParamSort = (int)db_get_b(0, MODULENAME, t, lParamSort + 1); @@ -1548,9 +1545,9 @@ void ListView_Sort(HWND hLV, LPARAM lParamSort) // restore sort order mir_snprintf(t, SIZEOF(t), "os%02x", (UINT)lParamSort); int m = db_get_b(0, MODULENAME, t, 0); - if (bChangeSortOrder){ m=!m; db_set_b(0, MODULENAME, t, m); } + if (bChangeSortOrder) { m = !m; db_set_b(0, MODULENAME, t, m); } - ListView_SortItems(hLV,&CompareFunc,lParamSort|(m<<8)); + ListView_SortItems(hLV, &CompareFunc, lParamSort | (m << 8)); } BOOL ShowSelectKeyDlg(HWND hParent, LPSTR KeyPath) @@ -1570,22 +1567,21 @@ BOOL ShowSelectKeyDlg(HWND hParent, LPSTR KeyPath) return TRUE; } - LPCSTR priv_beg = "-----BEGIN PGP PRIVATE KEY BLOCK-----"; LPCSTR priv_end = "-----END PGP PRIVATE KEY BLOCK-----"; LPCSTR publ_beg = "-----BEGIN PGP PUBLIC KEY BLOCK-----"; LPCSTR publ_end = "-----END PGP PUBLIC KEY BLOCK-----"; -LPSTR LoadKeys(LPCSTR file,BOOL priv) +LPSTR LoadKeys(LPCSTR file, BOOL priv) { - FILE *f=fopen(file,"r"); + FILE *f = fopen(file, "r"); if (!f) return NULL; - fseek(f,0,SEEK_END); + fseek(f, 0, SEEK_END); int flen = ftell(f); - fseek(f,0,SEEK_SET); + fseek(f, 0, SEEK_SET); - LPCSTR beg,end; + LPCSTR beg, end; if (priv) { beg = priv_beg; end = priv_end; @@ -1595,26 +1591,26 @@ LPSTR LoadKeys(LPCSTR file,BOOL priv) end = publ_end; } - 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) - b=true; - else if (b && strncmp(keys+i,end,strlen(end)) == 0) { - i+=(int)strlen(keys+i); - b=false; + 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) + b = true; + else if (b && strncmp(keys + i, end, strlen(end)) == 0) { + i += (int)strlen(keys + i); + b = false; } if (b) - i+=(int)strlen(keys+i); + i += (int)strlen(keys + i); } - *(keys+i)='\0'; + *(keys + i) = '\0'; fclose(f); return keys; } BOOL SaveExportRSAKeyDlg(HWND hParent, LPSTR key, BOOL priv) { - TCHAR szFile[MAX_PATH] = _T("rsa_pub.asc"); + TCHAR szFile[MAX_PATH] = _T("rsa_pub.asc"); if (priv) _tcscpy(szFile, _T("rsa_priv.asc")); @@ -1642,11 +1638,11 @@ BOOL SaveExportRSAKeyDlg(HWND hParent, LPSTR key, BOOL priv) BOOL LoadImportRSAKeyDlg(HWND hParent, LPSTR key, BOOL priv) { - TCHAR szFile[MAX_PATH] = _T("rsa_pub.asc"); + TCHAR szFile[MAX_PATH] = _T("rsa_pub.asc"); if (priv) _tcscpy(szFile, _T("rsa_priv.asc")); - OPENFILENAME ofn = {0}; + OPENFILENAME ofn = { 0 }; ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hParent; ofn.nMaxFile = MAX_PATH; @@ -1687,5 +1683,3 @@ int onRegisterOptions(WPARAM wParam, LPARAM) Options_AddPage(wParam, &odp); return 0; } - -// EOF diff --git a/plugins/SecureIM/src/popupOptions.cpp b/plugins/SecureIM/src/popupOptions.cpp index 9195ed7cb7..6ef609b077 100644 --- a/plugins/SecureIM/src/popupOptions.cpp +++ b/plugins/SecureIM/src/popupOptions.cpp @@ -14,48 +14,48 @@ INT_PTR CALLBACK PopOptionsDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM l switch (wMsg) { case WM_INITDIALOG: TranslateDialogDefault(hDlg); - RefreshPopupOptionsDlg(hec,hdc,hss,hsr,hks,hkr); + RefreshPopupOptionsDlg(hec, hdc, hss, hsr, hks, hkr); DBVARIANT dbv; char *timeout; //set timeout value for Key - if (db_get(0, MODULENAME, "timeoutKey", &dbv) == 0) timeout=dbv.pszVal; - else timeout="0"; + if (db_get(0, MODULENAME, "timeoutKey", &dbv) == 0) timeout = dbv.pszVal; + else timeout = "0"; SetDlgItemText(hDlg, IDC_TIMEKEY, timeout); db_free(&dbv); //set timeout value for SEC - if (db_get(0, MODULENAME, "timeoutSec", &dbv) == 0) timeout=dbv.pszVal; - else timeout="0"; + if (db_get(0, MODULENAME, "timeoutSec", &dbv) == 0) timeout = dbv.pszVal; + else timeout = "0"; SetDlgItemText(hDlg, IDC_TIMESEC, timeout); db_free(&dbv); //set timeout value for SR - if (db_get(0, MODULENAME, "timeoutSR", &dbv) == 0) timeout=dbv.pszVal; - else timeout="0"; + if (db_get(0, MODULENAME, "timeoutSR", &dbv) == 0) timeout = dbv.pszVal; + else timeout = "0"; SetDlgItemText(hDlg, IDC_TIMESR, timeout); db_free(&dbv); //key color - SendDlgItemMessage(hDlg,IDC_BACKKEY,CPM_SETCOLOUR,0,db_get_dw(0, MODULENAME, "colorKeyb", RGB(230,230,255))); - SendDlgItemMessage(hDlg,IDC_TEXTKEY,CPM_SETCOLOUR,0,db_get_dw(0, MODULENAME, "colorKeyt", RGB(0,0,0))); + SendDlgItemMessage(hDlg, IDC_BACKKEY, CPM_SETCOLOUR, 0, db_get_dw(0, MODULENAME, "colorKeyb", RGB(230, 230, 255))); + SendDlgItemMessage(hDlg, IDC_TEXTKEY, CPM_SETCOLOUR, 0, db_get_dw(0, MODULENAME, "colorKeyt", RGB(0, 0, 0))); //Session color - SendDlgItemMessage(hDlg,IDC_BACKSEC,CPM_SETCOLOUR,0,db_get_dw(0, MODULENAME, "colorSecb", RGB(255,255,200))); - SendDlgItemMessage(hDlg,IDC_TEXTSEC,CPM_SETCOLOUR,0,db_get_dw(0, MODULENAME, "colorSect", RGB(0,0,0))); + SendDlgItemMessage(hDlg, IDC_BACKSEC, CPM_SETCOLOUR, 0, db_get_dw(0, MODULENAME, "colorSecb", RGB(255, 255, 200))); + SendDlgItemMessage(hDlg, IDC_TEXTSEC, CPM_SETCOLOUR, 0, db_get_dw(0, MODULENAME, "colorSect", RGB(0, 0, 0))); //SR color - SendDlgItemMessage(hDlg,IDC_BACKSR,CPM_SETCOLOUR,0,db_get_dw(0, MODULENAME, "colorSRb", RGB(200,255,200))); - SendDlgItemMessage(hDlg,IDC_TEXTSR,CPM_SETCOLOUR,0,db_get_dw(0, MODULENAME, "colorSRt", RGB(0,0,0))); + SendDlgItemMessage(hDlg, IDC_BACKSR, CPM_SETCOLOUR, 0, db_get_dw(0, MODULENAME, "colorSRb", RGB(200, 255, 200))); + SendDlgItemMessage(hDlg, IDC_TEXTSR, CPM_SETCOLOUR, 0, db_get_dw(0, MODULENAME, "colorSRt", RGB(0, 0, 0))); break; case WM_COMMAND: if (HIWORD(wParam) == CPN_COLOURCHANGED) { //It's a colour picker change. LOWORD(wParam) is the control id. - DWORD color = SendDlgItemMessage(hDlg,LOWORD(wParam),CPM_GETCOLOUR,0,0); + DWORD color = SendDlgItemMessage(hDlg, LOWORD(wParam), CPM_GETCOLOUR, 0, 0); - switch(LOWORD(wParam)) { + switch (LOWORD(wParam)) { case IDC_BACKKEY: db_set_dw(0, MODULENAME, "colorKeyb", color); break; @@ -81,55 +81,55 @@ INT_PTR CALLBACK PopOptionsDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM l switch (LOWORD(wParam)) { case IDC_PREV: //preview popups... - showPopup(LPGEN("Key Popup"),NULL,g_hPOP[POP_PU_PRC],0); - showPopup(LPGEN("Secure Popup"),NULL,g_hPOP[POP_PU_EST],1); - showPopup(LPGEN("Message Popup"),NULL,g_hPOP[POP_PU_MSR],2); + showPopup(LPGEN("Key Popup"), NULL, g_hPOP[POP_PU_PRC], 0); + showPopup(LPGEN("Secure Popup"), NULL, g_hPOP[POP_PU_EST], 1); + showPopup(LPGEN("Message Popup"), NULL, g_hPOP[POP_PU_MSR], 2); break; case IDC_EC: //set ec checkbox value - db_set_b(0, MODULENAME, "ec", (BYTE)(SendMessage(hec,BM_GETCHECK,0L,0L) == BST_CHECKED)); + db_set_b(0, MODULENAME, "ec", (BYTE)(SendMessage(hec, BM_GETCHECK, 0L, 0L) == BST_CHECKED)); break; case IDC_DC: //set dc checkbox value - db_set_b(0, MODULENAME, "dc", (BYTE)(SendMessage(hdc,BM_GETCHECK,0L,0L) == BST_CHECKED)); + db_set_b(0, MODULENAME, "dc", (BYTE)(SendMessage(hdc, BM_GETCHECK, 0L, 0L) == BST_CHECKED)); break; case IDC_SS: //set ss checkbox value - db_set_b(0, MODULENAME, "ss", (BYTE)(SendMessage(hss,BM_GETCHECK,0L,0L) == BST_CHECKED)); + db_set_b(0, MODULENAME, "ss", (BYTE)(SendMessage(hss, BM_GETCHECK, 0L, 0L) == BST_CHECKED)); break; case IDC_SR: //set sr checkbox value - db_set_b(0, MODULENAME, "sr", (BYTE)(SendMessage(hsr,BM_GETCHECK,0L,0L) == BST_CHECKED)); + db_set_b(0, MODULENAME, "sr", (BYTE)(SendMessage(hsr, BM_GETCHECK, 0L, 0L) == BST_CHECKED)); break; case IDC_KS: //set indicator checkbox value - db_set_b(0, MODULENAME, "ks", (BYTE)(SendMessage(hks,BM_GETCHECK,0L,0L) == BST_CHECKED)); + db_set_b(0, MODULENAME, "ks", (BYTE)(SendMessage(hks, BM_GETCHECK, 0L, 0L) == BST_CHECKED)); break; case IDC_KR: //set indicator checkbox value - db_set_b(0, MODULENAME, "kr", (BYTE)(SendMessage(hkr,BM_GETCHECK,0L,0L) == BST_CHECKED)); + db_set_b(0, MODULENAME, "kr", (BYTE)(SendMessage(hkr, BM_GETCHECK, 0L, 0L) == BST_CHECKED)); break; case IDC_TIMEKEY: //set timeout value - GetDlgItemText(hDlg,IDC_TIMEKEY,getTimeout,sizeof(getTimeout)); - mir_itoa(atoi(getTimeout),getTimeout,10); + GetDlgItemText(hDlg, IDC_TIMEKEY, getTimeout, sizeof(getTimeout)); + mir_itoa(atoi(getTimeout), getTimeout, 10); db_set_s(0, MODULENAME, "timeoutKey", getTimeout); break; case IDC_TIMESEC: //set timeout value - GetDlgItemText(hDlg,IDC_TIMESEC,getTimeout,sizeof(getTimeout)); - mir_itoa(atoi(getTimeout),getTimeout,10); + GetDlgItemText(hDlg, IDC_TIMESEC, getTimeout, sizeof(getTimeout)); + mir_itoa(atoi(getTimeout), getTimeout, 10); db_set_s(0, MODULENAME, "timeoutSec", getTimeout); break; case IDC_TIMESR: //set timeout value - GetDlgItemText(hDlg,IDC_TIMESR,getTimeout,sizeof(getTimeout)); - mir_itoa(atoi(getTimeout),getTimeout,10); + GetDlgItemText(hDlg, IDC_TIMESR, getTimeout, sizeof(getTimeout)); + mir_itoa(atoi(getTimeout), getTimeout, 10); db_set_s(0, MODULENAME, "timeoutSR", getTimeout); break; } - RefreshPopupOptionsDlg(hec,hdc,hss,hsr,hks,hkr); + RefreshPopupOptionsDlg(hec, hdc, hss, hsr, hks, hkr); break; default: @@ -138,7 +138,7 @@ INT_PTR CALLBACK PopOptionsDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM l return TRUE; } -void RefreshPopupOptionsDlg(HWND hec,HWND hdc,HWND hss,HWND hsr,HWND hks,HWND hkr) +void RefreshPopupOptionsDlg(HWND hec, HWND hdc, HWND hss, HWND hsr, HWND hks, HWND hkr) { // ec checkbox SendMessage(hec, BM_SETCHECK, db_get_b(0, MODULENAME, "ec", 1), 0L); @@ -172,5 +172,3 @@ int onRegisterPopOptions(WPARAM wParam, LPARAM) } return 0; } - -// EOF diff --git a/plugins/SecureIM/src/rtfconv.cpp b/plugins/SecureIM/src/rtfconv.cpp index f8acf59059..d76b316b22 100644 --- a/plugins/SecureIM/src/rtfconv.cpp +++ b/plugins/SecureIM/src/rtfconv.cpp @@ -1,46 +1,40 @@ #include "commonheaders.h" - HINSTANCE hRtfconv = NULL; RTFCONVSTRING pRtfconvString = NULL; - -BOOL load_rtfconv () { - - hRtfconv = LoadLibrary(_T("rtfconv.dll")) ; - if (hRtfconv == NULL) { - hRtfconv = LoadLibrary(_T("plugins\\rtfconv.dll")) ; - if (hRtfconv == NULL ) - return FALSE; - } - - pRtfconvString = (RTFCONVSTRING) GetProcAddress( hRtfconv, "RtfconvString" ) ; - if (pRtfconvString == NULL) { - FreeLibrary( hRtfconv ) ; - return FALSE; - } - - return TRUE; +BOOL load_rtfconv() +{ + hRtfconv = LoadLibrary(_T("rtfconv.dll")); + if (hRtfconv == NULL) { + hRtfconv = LoadLibrary(_T("plugins\\rtfconv.dll")); + if (hRtfconv == NULL) + return FALSE; + } + + pRtfconvString = (RTFCONVSTRING)GetProcAddress(hRtfconv, "RtfconvString"); + if (pRtfconvString == NULL) { + FreeLibrary(hRtfconv); + return FALSE; + } + + return TRUE; } -void free_rtfconv () { - - if (hRtfconv ) - FreeLibrary( hRtfconv ) ; +void free_rtfconv() +{ + if (hRtfconv) + FreeLibrary(hRtfconv); pRtfconvString = NULL; hRtfconv = NULL; } - -void rtfconvA(LPCSTR rtf, LPWSTR plain) { - - pRtfconvString( rtf, plain, 0, 1200, CONVMODE_USE_SYSTEM_TABLE, (strlen(rtf)+1)*sizeof(WCHAR)); +void rtfconvA(LPCSTR rtf, LPWSTR plain) +{ + pRtfconvString(rtf, plain, 0, 1200, CONVMODE_USE_SYSTEM_TABLE, (strlen(rtf) + 1)*sizeof(WCHAR)); } - -void rtfconvW(LPCWSTR rtf, LPWSTR plain) { - - pRtfconvString( rtf, plain, 0, 1200, CONVMODE_USE_SYSTEM_TABLE, (wcslen(rtf)+1)*sizeof(WCHAR)); +void rtfconvW(LPCWSTR rtf, LPWSTR plain) +{ + pRtfconvString(rtf, plain, 0, 1200, CONVMODE_USE_SYSTEM_TABLE, (wcslen(rtf) + 1)*sizeof(WCHAR)); } - -// EOF diff --git a/plugins/SecureIM/src/splitmsg.cpp b/plugins/SecureIM/src/splitmsg.cpp index c9098e1999..259d636955 100644 --- a/plugins/SecureIM/src/splitmsg.cpp +++ b/plugins/SecureIM/src/splitmsg.cpp @@ -1,28 +1,27 @@ #include "commonheaders.h" - // разбивает сообщение szMsg на части длиной iLen, возвращает строку вида PARTzPARTzz LPSTR splitMsg(LPSTR szMsg, int iLen) { - Sent_NetLog("split: msg: -----\n%s\n-----\n",szMsg); + Sent_NetLog("split: msg: -----\n%s\n-----\n", szMsg); int len = (int)strlen(szMsg); - LPSTR out = (LPSTR) mir_alloc(len*2); + LPSTR out = (LPSTR)mir_alloc(len * 2); LPSTR buf = out; WORD msg_id = db_get_w(0, MODULENAME, "msgid", 0) + 1; db_set_w(0, MODULENAME, "msgid", msg_id); - int part_all = (len+iLen-1)/iLen; - for (int part_num=0; part_numiLen)?iLen:len; - mir_snprintf(buf,32,"%s%04X%02X%02X",SIG_SECP,msg_id,part_num,part_all); - memcpy(buf+LEN_SECP+8,szMsg,sz); - *(buf+LEN_SECP+8+sz) = '\0'; + int part_all = (len + iLen - 1) / iLen; + for (int part_num = 0; part_numiLen) ? iLen : len; + mir_snprintf(buf, 32, "%s%04X%02X%02X", SIG_SECP, msg_id, part_num, part_all); + memcpy(buf + LEN_SECP + 8, szMsg, sz); + *(buf + LEN_SECP + 8 + sz) = '\0'; - Sent_NetLog("split: part: %s",buf); + Sent_NetLog("split: part: %s", buf); - buf += LEN_SECP+8+sz+1; + buf += LEN_SECP + 8 + sz + 1; szMsg += sz; len -= sz; } @@ -34,46 +33,46 @@ LPSTR splitMsg(LPSTR szMsg, int iLen) // собираем сообщение из частей, части храним в структуре у контакта LPSTR combineMessage(pUinKey ptr, LPSTR szMsg) { - Sent_NetLog("combine: part: %s",szMsg); + Sent_NetLog("combine: part: %s", szMsg); - int msg_id,part_num,part_all; - sscanf(szMsg,"%4X%2X%2X",&msg_id,&part_num,&part_all); + int msg_id, part_num, part_all; + sscanf(szMsg, "%4X%2X%2X", &msg_id, &part_num, &part_all); // pPM ppm = NULL, pm = ptr->msgPart; if (!ptr->msgPart) { pm = ptr->msgPart = new partitionMessage; - memset(pm,0,sizeof(partitionMessage)); + memset(pm, 0, sizeof(partitionMessage)); pm->id = msg_id; pm->message = new LPSTR[part_all]; - memset(pm->message,0,sizeof(LPSTR)*part_all); + memset(pm->message, 0, sizeof(LPSTR)*part_all); } else - while(pm) { - if (pm->id == msg_id ) break; + while (pm) { + if (pm->id == msg_id) break; ppm = pm; pm = pm->nextMessage; - } + } if (!pm) { // nothing to found pm = ppm->nextMessage = new partitionMessage; - memset(pm,0,sizeof(partitionMessage)); + memset(pm, 0, sizeof(partitionMessage)); pm->id = msg_id; pm->message = new LPSTR[part_all]; - memset(pm->message,0,sizeof(LPSTR)*part_all); + memset(pm->message, 0, sizeof(LPSTR)*part_all); } pm->message[part_num] = new char[strlen(szMsg)]; - strcpy(pm->message[part_num],szMsg+8); + strcpy(pm->message[part_num], szMsg + 8); - Sent_NetLog("combine: save part: %s",pm->message[part_num]); + Sent_NetLog("combine: save part: %s", pm->message[part_num]); - int len=0,i; - for ( i=0; imessage[i] == NULL) break; - len+=(int)strlen(pm->message[i]); + len += (int)strlen(pm->message[i]); } 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]); + SAFE_FREE(ptr->tmp); + ptr->tmp = (LPSTR)mir_alloc(len + 1); *(ptr->tmp) = '\0'; + for (i = 0; i < part_all; i++) { + strcat(ptr->tmp, pm->message[i]); delete pm->message[i]; } delete pm->message; @@ -91,30 +90,25 @@ LPSTR combineMessage(pUinKey ptr, LPSTR szMsg) return NULL; } - // отправляет сообщение, если надо то разбивает на части -int splitMessageSend(pUinKey ptr, LPSTR szMsg) { - - int ret; +int splitMessageSend(pUinKey ptr, LPSTR szMsg) +{ 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) { - LPSTR msg = splitMsg(szMsg,par); + int par = (getContactStatus(ptr->hContact) == ID_STATUS_OFFLINE) ? ptr->proto->split_off : ptr->proto->split_on; + if (par && len > par) { + int ret; + LPSTR msg = splitMsg(szMsg, par); LPSTR buf = msg; - while( *buf) { + while (*buf) { len = (int)strlen(buf); LPSTR tmp = mir_strdup(buf); - ret = CallContactService(ptr->hContact,PSS_MESSAGE,(WPARAM)PREF_METANODB,(LPARAM)tmp); + ret = CallContactService(ptr->hContact, PSS_MESSAGE, (WPARAM)PREF_METANODB, (LPARAM)tmp); mir_free(tmp); - buf += len+1; + buf += len + 1; } SAFE_FREE(msg); + return ret; } - else { - ret = CallContactService(ptr->hContact,PSS_MESSAGE,(WPARAM)PREF_METANODB,(LPARAM)szMsg); - } - return ret; + + return (int)CallContactService(ptr->hContact, PSS_MESSAGE, (WPARAM)PREF_METANODB, (LPARAM)szMsg); } - - -// EOF diff --git a/plugins/SecureIM/src/svcs_clist.cpp b/plugins/SecureIM/src/svcs_clist.cpp index bb1f422cbe..0b677659c0 100644 --- a/plugins/SecureIM/src/svcs_clist.cpp +++ b/plugins/SecureIM/src/svcs_clist.cpp @@ -1,10 +1,9 @@ #include "commonheaders.h" - int __cdecl onContactSettingChanged(WPARAM hContact, LPARAM lParam) { - DBCONTACTWRITESETTING *cws=(DBCONTACTWRITESETTING*)lParam; - if (!hContact || strcmp(cws->szSetting,"Status")) return 0; + DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam; + if (!hContact || strcmp(cws->szSetting, "Status")) return 0; pUinKey ptr = getUinKey(hContact); int stat = getContactStatus(hContact); @@ -12,7 +11,7 @@ int __cdecl onContactSettingChanged(WPARAM hContact, LPARAM lParam) if (stat == ID_STATUS_OFFLINE) { // go offline if (ptr->mode == MODE_NATIVE && cpp_keyx(ptr->cntx)) { // have active context - cpp_delete_context(ptr->cntx); ptr->cntx=0; // reset context + cpp_delete_context(ptr->cntx); ptr->cntx = 0; // reset context showPopupDC(hContact); // show popup "Disabled" ShowStatusIconNotify(hContact); // change icon in CL } @@ -34,7 +33,7 @@ int __cdecl onContactSettingChanged(WPARAM hContact, LPARAM lParam) // wParam=(MCONTACT)hContact // lParam=0 -int __cdecl onContactAdded(WPARAM wParam,LPARAM lParam) +int __cdecl onContactAdded(WPARAM wParam, LPARAM lParam) { addContact(wParam); return 0; @@ -43,7 +42,7 @@ int __cdecl onContactAdded(WPARAM wParam,LPARAM lParam) // wParam=(MCONTACT)hContact // lParam=0 -int __cdecl onContactDeleted(WPARAM wParam,LPARAM lParam) +int __cdecl onContactDeleted(WPARAM wParam, LPARAM lParam) { delContact(wParam); return 0; @@ -64,9 +63,9 @@ int __cdecl onExtraImageApplying(WPARAM wParam, LPARAM) return 0; } -int __cdecl onRebuildContactMenu(WPARAM hContact,LPARAM lParam) +int __cdecl onRebuildContactMenu(WPARAM hContact, LPARAM lParam) { - BOOL bMC = isProtoMetaContacts(hContact); + BOOL bMC = db_mc_isMeta(hContact); if (bMC) hContact = db_mc_getMostOnline(hContact); // возьмем тот, через который пойдет сообщение pUinKey ptr = getUinKey(hContact); @@ -78,7 +77,7 @@ int __cdecl onRebuildContactMenu(WPARAM hContact,LPARAM lParam) // check offline/online if (!ptr) { // hide menu bars - for (i=0; i < SIZEOF(g_hMenu); i++) + for (i = 0; i < SIZEOF(g_hMenu); i++) Menu_ShowItem(g_hMenu[i], false); return 0; } @@ -91,35 +90,35 @@ int __cdecl onRebuildContactMenu(WPARAM hContact,LPARAM lParam) bool isMiranda = isClientMiranda(hContact); // hide all menu bars - for (i=0; i < SIZEOF(g_hMenu); i++) + for (i = 0; i < SIZEOF(g_hMenu); i++) Menu_ShowItem(g_hMenu[i], false); - if (isSecureProto && !isChat && isMiranda && - (ptr->mode == MODE_NATIVE || ptr->mode == MODE_RSAAES)) { + if (isSecureProto && !isChat && isMiranda && + (ptr->mode == MODE_NATIVE || ptr->mode == MODE_RSAAES)) { // Native/RSAAES mi.flags = CMIM_FLAGS | CMIF_NOTOFFLINE | CMIM_ICON; if (!isSecured) { // create secureim connection - mi.hIcon = mode2icon(ptr->mode|SECURED,2); + mi.hIcon = mode2icon(ptr->mode | SECURED, 2); Menu_ModifyItem(g_hMenu[0], &mi); } else { // disable secureim connection - mi.hIcon = mode2icon(ptr->mode,2); + mi.hIcon = mode2icon(ptr->mode, 2); Menu_ModifyItem(g_hMenu[1], &mi); } // set status menu if (bSCM && !bMC && (!isSecured || ptr->mode == MODE_PGP || ptr->mode == MODE_GPG)) { mi.flags = CMIM_FLAGS | CMIM_NAME | CMIM_ICON; - mi.hIcon = g_hICO[ICO_ST_DIS+ptr->status]; + mi.hIcon = g_hICO[ICO_ST_DIS + ptr->status]; mi.pszName = (LPSTR)sim312[ptr->status]; Menu_ModifyItem(g_hMenu[2], &mi); mi.flags = CMIM_FLAGS | CMIM_ICON; - for (i=0;i<=(ptr->mode == MODE_RSAAES?1:2);i++) { - mi.hIcon = (i == ptr->status) ? g_hICO[ICO_ST_DIS+ptr->status] : NULL; - Menu_ModifyItem(g_hMenu[3+i], &mi); + for (i = 0; i <= (ptr->mode == MODE_RSAAES ? 1 : 2); i++) { + mi.hIcon = (i == ptr->status) ? g_hICO[ICO_ST_DIS + ptr->status] : NULL; + Menu_ModifyItem(g_hMenu[3 + i], &mi); } } } @@ -127,31 +126,29 @@ int __cdecl onRebuildContactMenu(WPARAM hContact,LPARAM lParam) // PGP, GPG if (ptr->mode == MODE_PGP && bPGPloaded) if ((bPGPkeyrings || bPGPprivkey) && !isGPG) - Menu_ShowItem(g_hMenu[isPGP+6], true); + Menu_ShowItem(g_hMenu[isPGP + 6], true); if (ptr->mode == MODE_GPG && bGPGloaded) if (bGPGkeyrings && !isPGP) - Menu_ShowItem(g_hMenu[isGPG+8], true); + Menu_ShowItem(g_hMenu[isGPG + 8], true); } if (isSecureProto && !isChat && isMiranda) { // set mode menu if (bMCM && !bMC && (!isSecured || ptr->mode == MODE_PGP || ptr->mode == MODE_GPG)) { mi.flags = CMIM_FLAGS | CMIM_NAME | CMIM_ICON; - mi.hIcon = g_hICO[ICO_OV_NAT+ptr->mode]; + mi.hIcon = g_hICO[ICO_OV_NAT + ptr->mode]; mi.pszName = (LPSTR)sim311[ptr->mode]; Menu_ModifyItem(g_hMenu[10], &mi); mi.flags = CMIM_FLAGS | CMIM_ICON; - for (i=0;imode != MODE_PGP && !bPGP ) continue; - if (i == MODE_GPG && ptr->mode != MODE_GPG && !bGPG ) continue; + for (i = 0; i < MODE_CNT; i++) { + 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; - Menu_ModifyItem(g_hMenu[11+i], &mi); + Menu_ModifyItem(g_hMenu[11 + i], &mi); } } } return 0; } - -// EOF diff --git a/plugins/SecureIM/src/svcs_menu.cpp b/plugins/SecureIM/src/svcs_menu.cpp index ece52aa842..c9432ba1a0 100644 --- a/plugins/SecureIM/src/svcs_menu.cpp +++ b/plugins/SecureIM/src/svcs_menu.cpp @@ -1,19 +1,17 @@ #include "commonheaders.h" - INT_PTR __cdecl Service_IsContactSecured(WPARAM wParam, LPARAM lParam) { return (isContactSecured(wParam)&SECURED) || isContactPGP(wParam) || isContactGPG(wParam); } - -INT_PTR __cdecl Service_CreateIM(WPARAM wParam,LPARAM lParam) +INT_PTR __cdecl Service_CreateIM(WPARAM wParam, LPARAM lParam) { CallContactService(wParam, PSS_MESSAGE, PREF_METANODB, (LPARAM)SIG_INIT); return 1; } -INT_PTR __cdecl Service_DisableIM(WPARAM wParam,LPARAM lParam) +INT_PTR __cdecl Service_DisableIM(WPARAM wParam, LPARAM lParam) { CallContactService(wParam, PSS_MESSAGE, PREF_METANODB, (LPARAM)SIG_DEIN); return 1; @@ -21,13 +19,13 @@ INT_PTR __cdecl Service_DisableIM(WPARAM wParam,LPARAM lParam) INT_PTR __cdecl Service_Status(WPARAM wParam, LPARAM lParam) { - switch(--lParam) { + switch (--lParam) { case STATUS_DISABLED: case STATUS_ENABLED: case STATUS_ALWAYSTRY: pUinKey ptr = getUinKey(wParam); if (ptr) { - ptr->status=ptr->tstatus=(BYTE)lParam; + ptr->status = ptr->tstatus = (BYTE)lParam; if (ptr->status == STATUS_ENABLED) db_unset(ptr->hContact, MODULENAME, "StatusID"); else db_set_b(ptr->hContact, MODULENAME, "StatusID", ptr->status); } @@ -39,17 +37,17 @@ INT_PTR __cdecl Service_Status(WPARAM wParam, LPARAM lParam) INT_PTR __cdecl Service_StatusDis(WPARAM wParam, LPARAM lParam) { - return Service_Status(wParam,STATUS_DISABLED+1); + return Service_Status(wParam, STATUS_DISABLED + 1); } INT_PTR __cdecl Service_StatusEna(WPARAM wParam, LPARAM lParam) { - return Service_Status(wParam,STATUS_ENABLED+1); + return Service_Status(wParam, STATUS_ENABLED + 1); } INT_PTR __cdecl Service_StatusTry(WPARAM wParam, LPARAM lParam) { - return Service_Status(wParam,STATUS_ALWAYSTRY+1); + return Service_Status(wParam, STATUS_ALWAYSTRY + 1); } INT_PTR __cdecl Service_PGPdelKey(WPARAM wParam, LPARAM lParam) @@ -61,7 +59,7 @@ INT_PTR __cdecl Service_PGPdelKey(WPARAM wParam, LPARAM lParam) } { pUinKey ptr = getUinKey(wParam); - cpp_delete_context(ptr->cntx); ptr->cntx=0; + cpp_delete_context(ptr->cntx); ptr->cntx = 0; } ShowStatusIconNotify(wParam); return 1; @@ -72,8 +70,8 @@ INT_PTR __cdecl Service_PGPsetKey(WPARAM wParam, LPARAM lParam) BOOL del = true; if (bPGPloaded) { if (bPGPkeyrings) { - char szKeyID[128]; szKeyID[0]='\0'; - PVOID KeyID = pgp_select_keyid(GetForegroundWindow(),szKeyID); + char szKeyID[128]; szKeyID[0] = '\0'; + PVOID KeyID = pgp_select_keyid(GetForegroundWindow(), szKeyID); if (szKeyID[0]) { db_unset(wParam, MODULENAME, "pgp"); db_set_blob(wParam, MODULENAME, "pgp", KeyID, pgp_size_keyid()); @@ -83,9 +81,9 @@ INT_PTR __cdecl Service_PGPsetKey(WPARAM wParam, LPARAM lParam) } } else if (bPGPprivkey) { - char KeyPath[MAX_PATH]; KeyPath[0]='\0'; - if (ShowSelectKeyDlg(0,KeyPath)) { - char *publ = LoadKeys(KeyPath,false); + char KeyPath[MAX_PATH]; KeyPath[0] = '\0'; + if (ShowSelectKeyDlg(0, KeyPath)) { + char *publ = LoadKeys(KeyPath, false); if (publ) { db_unset(wParam, MODULENAME, "pgp"); db_set_s(wParam, MODULENAME, "pgp", publ); @@ -99,10 +97,10 @@ INT_PTR __cdecl Service_PGPsetKey(WPARAM wParam, LPARAM lParam) } if (del) - Service_PGPdelKey(wParam,lParam); + Service_PGPdelKey(wParam, lParam); else { pUinKey ptr = getUinKey(wParam); - cpp_delete_context(ptr->cntx); ptr->cntx=0; + cpp_delete_context(ptr->cntx); ptr->cntx = 0; } ShowStatusIconNotify(wParam); return 1; @@ -114,7 +112,7 @@ INT_PTR __cdecl Service_GPGdelKey(WPARAM wParam, LPARAM lParam) db_unset(wParam, MODULENAME, "gpg"); { pUinKey ptr = getUinKey(wParam); - cpp_delete_context(ptr->cntx); ptr->cntx=0; + cpp_delete_context(ptr->cntx); ptr->cntx = 0; } ShowStatusIconNotify(wParam); return 1; @@ -124,18 +122,18 @@ INT_PTR __cdecl Service_GPGsetKey(WPARAM wParam, LPARAM lParam) { bool del = true; if (bGPGloaded && bGPGkeyrings) { - char szKeyID[128]; szKeyID[0]='\0'; - gpg_select_keyid(GetForegroundWindow(),szKeyID); + char szKeyID[128]; szKeyID[0] = '\0'; + gpg_select_keyid(GetForegroundWindow(), szKeyID); if (szKeyID[0]) { db_set_s(wParam, MODULENAME, "gpg", szKeyID); del = false; } } - if (del) Service_GPGdelKey(wParam,lParam); + if (del) Service_GPGdelKey(wParam, lParam); else { pUinKey ptr = getUinKey(wParam); - cpp_delete_context(ptr->cntx); ptr->cntx=0; + cpp_delete_context(ptr->cntx); ptr->cntx = 0; } ShowStatusIconNotify(wParam); return 1; @@ -145,15 +143,15 @@ INT_PTR __cdecl Service_Mode(WPARAM wParam, LPARAM lParam) { pUinKey ptr = getUinKey(wParam); - switch(--lParam) { + switch (--lParam) { case MODE_NATIVE: case MODE_RSAAES: if (isContactSecured(wParam)&SECURED) { msgbox(NULL, sim111, MODULENAME, MB_OK); return 0; } - if (lParam != MODE_NATIVE && ptr->status>STATUS_ENABLED ) - Service_Status(wParam,STATUS_ENABLED+1); + if (lParam != MODE_NATIVE && ptr->status > STATUS_ENABLED) + Service_Status(wParam, STATUS_ENABLED + 1); case MODE_PGP: case MODE_GPG: @@ -164,7 +162,7 @@ INT_PTR __cdecl Service_Mode(WPARAM wParam, LPARAM lParam) ptr->cntx = 0; ptr->keyLoaded = 0; } - ptr->mode=(BYTE)lParam; + ptr->mode = (BYTE)lParam; db_set_b(wParam, MODULENAME, "mode", (BYTE)lParam); } ShowStatusIcon(wParam); @@ -176,23 +174,20 @@ INT_PTR __cdecl Service_Mode(WPARAM wParam, LPARAM lParam) INT_PTR __cdecl Service_ModeNative(WPARAM wParam, LPARAM lParam) { - return Service_Mode(wParam, MODE_NATIVE+1); + return Service_Mode(wParam, MODE_NATIVE + 1); } INT_PTR __cdecl Service_ModePGP(WPARAM wParam, LPARAM lParam) { - return Service_Mode(wParam, MODE_PGP+1); + return Service_Mode(wParam, MODE_PGP + 1); } INT_PTR __cdecl Service_ModeGPG(WPARAM wParam, LPARAM lParam) { - return Service_Mode(wParam, MODE_GPG+1); + return Service_Mode(wParam, MODE_GPG + 1); } - + INT_PTR __cdecl Service_ModeRSAAES(WPARAM wParam, LPARAM lParam) { - return Service_Mode(wParam, MODE_RSAAES+1); + return Service_Mode(wParam, MODE_RSAAES + 1); } - - -// EOF diff --git a/plugins/SecureIM/src/svcs_proto.cpp b/plugins/SecureIM/src/svcs_proto.cpp index a9ec7f2f92..e583506158 100644 --- a/plugins/SecureIM/src/svcs_proto.cpp +++ b/plugins/SecureIM/src/svcs_proto.cpp @@ -1,12 +1,12 @@ #include "commonheaders.h" // return SignID -int getSecureSig(LPCSTR szMsg, LPSTR *szPlainMsg=NULL) +int getSecureSig(LPCSTR szMsg, LPSTR *szPlainMsg = NULL) { if (szPlainMsg) *szPlainMsg = (LPSTR)szMsg; - for (int i=0; signs[i].len; i++) { - if (memcmp(szMsg,signs[i].sig,signs[i].len) == 0) { - if (szPlainMsg) *szPlainMsg = (LPSTR)(szMsg+signs[i].len); + for (int i = 0; signs[i].len; i++) { + if (memcmp(szMsg, signs[i].sig, signs[i].len) == 0) { + if (szPlainMsg) *szPlainMsg = (LPSTR)(szMsg + signs[i].len); if (signs[i].key == SiG_GAME && !bDGP) return SiG_NONE; @@ -23,7 +23,7 @@ static void sttFakeAck(LPVOID param) TFakeAckParams *tParam = (TFakeAckParams*)param; Sleep(100); - if (tParam->msg == NULL ) + if (tParam->msg == NULL) SendBroadcast(tParam->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)tParam->id, 0); else SendBroadcast(tParam->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)tParam->id, LPARAM(tParam->msg)); @@ -56,40 +56,40 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) Sent_NetLog("onRecvMsg: %s", szEncMsg); // 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; + int len = (int)strlen(szEncMsg) + 1; LPWSTR szTemp = (LPWSTR)mir_alloc(len*sizeof(WCHAR)); if (ppre->flags & PREF_UNICODE) - rtfconvW((LPWSTR)(szEncMsg+len),szTemp); + rtfconvW((LPWSTR)(szEncMsg + len), szTemp); else - rtfconvA(szEncMsg,szTemp); - len = (int)wcslen(szTemp)-1; - while(len) { - if (szTemp[len] == 0x0D || szTemp[len] == 0x0A ) + rtfconvA(szEncMsg, szTemp); + len = (int)wcslen(szTemp) - 1; + while (len) { + if (szTemp[len] == 0x0D || szTemp[len] == 0x0A) szTemp[len] = 0; else break; len--; } - len = (int)wcslen(&szTemp[1])+1; - szUnrtfMsg = (LPSTR)mir_alloc(len*(sizeof(WCHAR)+1)); - WideCharToMultiByte(CP_ACP, 0, &szTemp[1], -1, szUnrtfMsg, len*(sizeof(WCHAR)+1), NULL, NULL); - memcpy(szUnrtfMsg+len,&szTemp[1],len*sizeof(WCHAR)); + len = (int)wcslen(&szTemp[1]) + 1; + szUnrtfMsg = (LPSTR)mir_alloc(len*(sizeof(WCHAR) + 1)); + WideCharToMultiByte(CP_ACP, 0, &szTemp[1], -1, szUnrtfMsg, len*(sizeof(WCHAR) + 1), NULL, NULL); + memcpy(szUnrtfMsg + len, &szTemp[1], len*sizeof(WCHAR)); ppre->szMessage = szEncMsg = szUnrtfMsg; ppre->flags |= PREF_UNICODE; mir_free(szTemp); } - int ssig = getSecureSig(ppre->szMessage,&szEncMsg); + int ssig = getSecureSig(ppre->szMessage, &szEncMsg); bool bSecured = (isContactSecured(pccsd->hContact)&SECURED) != 0; bool bPGP = isContactPGP(pccsd->hContact); bool bGPG = isContactGPG(pccsd->hContact); // pass any unchanged message if (!ptr || ssig == SiG_GAME || !isSecureProtocol(pccsd->hContact) || - (isProtoMetaContacts(pccsd->hContact) && (pccsd->wParam & PREF_SIMNOMETA)) || isChatRoom(pccsd->hContact) || - (ssig == SiG_NONE && !ptr->msgSplitted && !bSecured && !bPGP && !bGPG)) { + (db_mc_isMeta(pccsd->hContact) && (pccsd->wParam & PREF_SIMNOMETA)) || isChatRoom(pccsd->hContact) || + (ssig == SiG_NONE && !ptr->msgSplitted && !bSecured && !bPGP && !bGPG)) { Sent_NetLog("onRecvMsg: pass unhandled"); return CallService(MS_PROTO_CHAINRECV, wParam, lParam); } @@ -104,7 +104,7 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) if (ssig == SiG_NONE && !ptr->msgSplitted) { Sent_NetLog("onRecvMsg: non-secure message"); - ptrA szPlainMsg((ppre->flags & PREF_UNICODE) ? m_awstrcat(Translate(sim402),szEncMsg) : m_aastrcat(Translate(sim402),szEncMsg)); + ptrA szPlainMsg((ppre->flags & PREF_UNICODE) ? m_awstrcat(Translate(sim402), szEncMsg) : m_aastrcat(Translate(sim402), szEncMsg)); ppre->szMessage = szPlainMsg; pccsd->wParam |= PREF_SIMNOMETA; return CallService(MS_PROTO_CHAINRECV, wParam, lParam); @@ -117,11 +117,11 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) 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; + pccsd->lParam = (LPARAM)SIG_DISA; pccsd->szProtoService = PSS_MESSAGE; CallService(MS_PROTO_CHAINSEND, wParam, lParam); - showPopup(sim003,pccsd->hContact,g_hPOP[POP_PU_DIS],0); + showPopup(sim003, pccsd->hContact, g_hPOP[POP_PU_DIS], 0); } else { createRSAcntx(ptr); @@ -136,21 +136,21 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) if (ssig == SiG_NONE && ptr->msgSplitted) { Sent_NetLog("onRecvMsg: combine untagged splitted message"); - LPSTR tmp = (LPSTR) mir_alloc(strlen(ptr->msgSplitted)+strlen(szEncMsg)+1); - strcpy(tmp,ptr->msgSplitted); - strcat(tmp,szEncMsg); + LPSTR tmp = (LPSTR)mir_alloc(strlen(ptr->msgSplitted) + strlen(szEncMsg) + 1); + strcpy(tmp, ptr->msgSplitted); + strcat(tmp, szEncMsg); mir_free(ptr->msgSplitted); ptr->msgSplitted = szEncMsg = ppre->szMessage = tmp; - ssig = getSecureSig(tmp,&szEncMsg); + ssig = getSecureSig(tmp, &szEncMsg); } else SAFE_FREE(ptr->msgSplitted); // combine message splitted by secureim (with tags) if (ssig == SiG_SECP || ssig == SiG_PART) { - LPSTR msg = combineMessage(ptr,szEncMsg); - if (!msg ) return 1; + LPSTR msg = combineMessage(ptr, szEncMsg); + if (!msg) return 1; szEncMsg = ppre->szMessage = msg; - ssig = getSecureSig(msg,&szEncMsg); + ssig = getSecureSig(msg, &szEncMsg); } // decrypt PGP/GPG message @@ -159,11 +159,11 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) szEncMsg = ppre->szMessage; if (!ptr->cntx) { - ptr->cntx = cpp_create_context(((bGPGloaded && bGPGkeyrings)?CPP_MODE_GPG:CPP_MODE_PGP) | ((db_get_b(pccsd->hContact,MODULENAME,"gpgANSI",0))?CPP_MODE_GPG_ANSI:0)); + ptr->cntx = cpp_create_context(((bGPGloaded && bGPGkeyrings) ? CPP_MODE_GPG : CPP_MODE_PGP) | ((db_get_b(pccsd->hContact, MODULENAME, "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; @@ -178,8 +178,8 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) if (!szOldMsg) { // error while decrypting message, send error SAFE_FREE(ptr->msgSplitted); - ppre->flags &= ~(PREF_UNICODE|PREF_UTF); - pccsd->wParam &= ~(PREF_UNICODE|PREF_UTF); + ppre->flags &= ~(PREF_UNICODE | PREF_UTF); + pccsd->wParam &= ~(PREF_UNICODE | PREF_UTF); ppre->szMessage = Translate(sim401); return CallService(MS_PROTO_CHAINRECV, wParam, lParam); } @@ -189,7 +189,7 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) szNewMsg = m_ustrcat(Translate(sim403), szOldMsg); szOldMsg = szNewMsg; } - ptrA szMsgUtf( utf8_to_miranda(szOldMsg, ppre->flags)); + ptrA szMsgUtf(utf8_to_miranda(szOldMsg, ppre->flags)); pccsd->wParam = ppre->flags; ppre->szMessage = szMsgUtf; @@ -200,9 +200,9 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) return CallService(MS_PROTO_CHAINRECV, wParam, lParam); } - Sent_NetLog("onRecvMsg: switch(ssig)=%d",ssig); + Sent_NetLog("onRecvMsg: switch(ssig)=%d", ssig); - switch(ssig) { + switch (ssig) { case SiG_PGPM: return CallService(MS_PROTO_CHAINRECV, wParam, lParam); @@ -210,21 +210,21 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) Sent_NetLog("onRecvMsg: RSA/AES message"); if (ptr->mode == MODE_NATIVE) { - ptr->mode = MODE_RSAAES; - deleteRSAcntx(ptr); - db_set_b(ptr->hContact, MODULENAME, "mode", ptr->mode); + ptr->mode = MODE_RSAAES; + deleteRSAcntx(ptr); + db_set_b(ptr->hContact, MODULENAME, "mode", ptr->mode); } createRSAcntx(ptr); loadRSAkey(ptr); - if (exp->rsa_get_state(ptr->cntx) == 0 ) - showPopupKR(ptr->hContact); + if (exp->rsa_get_state(ptr->cntx) == 0) + showPopupKR(ptr->hContact); { - LPSTR szOldMsg = exp->rsa_recv(ptr->cntx,szEncMsg); + LPSTR szOldMsg = exp->rsa_recv(ptr->cntx, szEncMsg); if (!szOldMsg) return 1; // don't display it ... - ptrA szNewMsg( utf8_to_miranda(szOldMsg, ppre->flags)); + ptrA szNewMsg(utf8_to_miranda(szOldMsg, ppre->flags)); pccsd->wParam = ppre->flags; ppre->szMessage = szNewMsg; @@ -240,7 +240,7 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) if (cpp_keyx(ptr->cntx)) { // decrypting message - szPlainMsg = decodeMsg(ptr,lParam,szEncMsg); + szPlainMsg = decodeMsg(ptr, lParam, szEncMsg); if (!ptr->decoded) { mir_free(szPlainMsg); SAFE_FREE(ptr->msgSplitted); @@ -252,20 +252,20 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) // reinit key exchange user has send an encrypted message and i have no key cpp_reset_context(ptr->cntx); - ptrA reSend((LPSTR)mir_alloc(strlen(szEncMsg)+LEN_RSND)); - strcpy(reSend,SIG_RSND); // copy resend sig - strcat(reSend,szEncMsg); // add mess + ptrA reSend((LPSTR)mir_alloc(strlen(szEncMsg) + LEN_RSND)); + strcpy(reSend, SIG_RSND); // copy resend sig + strcat(reSend, szEncMsg); // add mess pccsd->wParam |= PREF_METANODB; - pccsd->lParam = (LPARAM) reSend; // reSend Message to reemit + pccsd->lParam = (LPARAM)reSend; // reSend Message to reemit pccsd->szProtoService = PSS_MESSAGE; CallService(MS_PROTO_CHAINSEND, wParam, lParam); // send back cipher message - ptrA keyToSend( InitKeyA(ptr, 0)); // calculate public and private key + ptrA keyToSend(InitKeyA(ptr, 0)); // calculate public and private key pccsd->lParam = (LPARAM)(char*)keyToSend; CallService(MS_PROTO_CHAINSEND, wParam, lParam); // send new key - showPopup(sim005,NULL,g_hPOP[POP_PU_DIS],0); + showPopup(sim005, NULL, g_hPOP[POP_PU_DIS], 0); showPopupKS(ptr->hContact); return 1; } @@ -288,11 +288,11 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) // if valid key is succefully retrieved ptr->offlineKey = true; - InitKeyX(ptr,dbv.pbVal); + InitKeyX(ptr, dbv.pbVal); db_free(&dbv); // decrypting message - szPlainMsg = decodeMsg(ptr,lParam,szEncMsg); + szPlainMsg = decodeMsg(ptr, lParam, szEncMsg); ShowStatusIconNotify(ptr->hContact); break; @@ -301,9 +301,9 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) if (cpp_keyx(ptr->cntx)) { // decrypt sended back message and save message for future sending with a new secret key - addMsg2Queue(ptr, pccsd->wParam, ptrA(decodeMsg(ptr,(LPARAM)pccsd,szEncMsg))); + addMsg2Queue(ptr, pccsd->wParam, ptrA(decodeMsg(ptr, (LPARAM)pccsd, szEncMsg))); showPopupRM(ptr->hContact); - showPopup(sim004,NULL,g_hPOP[POP_PU_DIS],0); + showPopup(sim004, NULL, g_hPOP[POP_PU_DIS], 0); } return 1; // don't display it ... @@ -312,26 +312,26 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) case SiG_DEIN: // deinit message // other user has disabled SecureIM with you - cpp_delete_context(ptr->cntx); ptr->cntx=0; + cpp_delete_context(ptr->cntx); ptr->cntx = 0; showPopupDC(ptr->hContact); ShowStatusIconNotify(ptr->hContact); - waitForExchange(ptr,3); // дослать нешифрованно + waitForExchange(ptr, 3); // дослать нешифрованно return 1; case SiG_KEYR: // key3 message case SiG_KEYA: // keyA message case SiG_KEYB: // keyB message if (ptr->mode == MODE_RSAAES) { - ptr->mode = MODE_NATIVE; - cpp_delete_context(ptr->cntx); - ptr->cntx = 0; - ptr->keyLoaded = 0; - db_set_b(ptr->hContact, MODULENAME, "mode", ptr->mode); + ptr->mode = MODE_NATIVE; + cpp_delete_context(ptr->cntx); + ptr->cntx = 0; + ptr->keyLoaded = 0; + db_set_b(ptr->hContact, MODULENAME, "mode", ptr->mode); } - switch(ssig) { + switch (ssig) { case SiG_KEYR: // key3 message Sent_NetLog("onRecvMsg: SiG_KEYR received"); @@ -343,14 +343,14 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) cpp_reset_context(ptr->cntx); } - if (InitKeyB(ptr,szEncMsg) != CPP_ERROR_NONE) { + if (InitKeyB(ptr, szEncMsg) != CPP_ERROR_NONE) { Sent_NetLog("onRecvMsg: SiG_KEYR InitKeyB error"); // tell to the other side that we have the plugin disabled with him - showPopup(sim013,ptr->hContact,g_hPOP[POP_PU_DIS],0); + showPopup(sim013, ptr->hContact, g_hPOP[POP_PU_DIS], 0); ShowStatusIconNotify(ptr->hContact); - waitForExchange(ptr,3); // дослать нешифрованно + waitForExchange(ptr, 3); // дослать нешифрованно return 1; } @@ -373,7 +373,7 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) if (ptr->features & CPP_FEATURES_NEWPG) { cpp_reset_context(ptr->cntx); - ptrA keyToSend( InitKeyA(ptr,CPP_FEATURES_NEWPG|KEY_A_SIG)); // calculate NEW public and private key + ptrA keyToSend(InitKeyA(ptr, CPP_FEATURES_NEWPG | KEY_A_SIG)); // calculate NEW public and private key Sent_NetLog("onRecvMsg: Sending KEYA %s", keyToSend); pccsd->wParam |= PREF_METANODB; @@ -388,7 +388,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)) { - ptrA keyToSend( InitKeyA(ptr,0)); // calculate public and private key + ptrA keyToSend(InitKeyA(ptr, 0)); // calculate public and private key Sent_NetLog("onRecvMsg: Sending KEYA %s", keyToSend); pccsd->wParam |= PREF_METANODB; @@ -407,18 +407,18 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) showPopupKR(ptr->hContact); cpp_reset_context(ptr->cntx); - if (InitKeyB(ptr,szEncMsg) != CPP_ERROR_NONE) { + if (InitKeyB(ptr, szEncMsg) != CPP_ERROR_NONE) { Sent_NetLog("onRecvMsg: SiG_KEYA InitKeyB error"); // tell to the other side that we have the plugin disabled with him - showPopup(sim013,ptr->hContact,g_hPOP[POP_PU_DIS],0); + showPopup(sim013, ptr->hContact, g_hPOP[POP_PU_DIS], 0); ShowStatusIconNotify(ptr->hContact); - waitForExchange(ptr,3); // дослать нешифрованно + waitForExchange(ptr, 3); // дослать нешифрованно return 1; } else { - ptrA keyToSend( InitKeyA(ptr, CPP_FEATURES_NEWPG | KEY_B_SIG)); // calculate NEW public and private key + ptrA keyToSend(InitKeyA(ptr, CPP_FEATURES_NEWPG | KEY_B_SIG)); // calculate NEW public and private key Sent_NetLog("onRecvMsg: Sending KEYB %s", keyToSend); pccsd->wParam |= PREF_METANODB; @@ -435,15 +435,15 @@ 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) { Sent_NetLog("onRecvMsg: SiG_KEYB InitKeyB error"); // tell to the other side that we have the plugin disabled with him - showPopup(sim013,ptr->hContact,g_hPOP[POP_PU_DIS],0); + showPopup(sim013, ptr->hContact, g_hPOP[POP_PU_DIS], 0); ShowStatusIconNotify(ptr->hContact); cpp_reset_context(ptr->cntx); - waitForExchange(ptr,3); // дослать нешифрованно + waitForExchange(ptr, 3); // дослать нешифрованно return 1; } break; @@ -452,17 +452,17 @@ 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)) - CalculateKeyX(ptr,ptr->hContact); + CalculateKeyX(ptr, ptr->hContact); ShowStatusIconNotify(ptr->hContact); Sent_NetLog("onRecvMsg: Session established"); - waitForExchange(ptr,2); // дошлем через шифрованное соединение + waitForExchange(ptr, 2); // дошлем через шифрованное соединение return 1; } // receive message - if (cpp_keyx(ptr->cntx) && (ssig == SiG_ENON||ssig == SiG_ENOF)) { + if (cpp_keyx(ptr->cntx) && (ssig == SiG_ENON || ssig == SiG_ENOF)) { Sent_NetLog("onRecvMsg: message received"); showPopupRM(ptr->hContact); } @@ -483,12 +483,12 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) int ssig = getSecureSig((LPCSTR)pccsd->lParam); int stat = getContactStatus(pccsd->hContact); - Sent_NetLog("onSend: %s",(LPSTR)pccsd->lParam); + Sent_NetLog("onSend: %s", (LPSTR)pccsd->lParam); // pass unhandled messages if (!ptr || ssig == SiG_GAME || ssig == SiG_PGPM || ssig == SiG_SECU || ssig == SiG_SECP || - isChatRoom(pccsd->hContact) || stat == -1 || - (ssig == SiG_NONE && ptr->sendQueue) || (ssig == SiG_NONE && ptr->status == STATUS_DISABLED)) { + isChatRoom(pccsd->hContact) || stat == -1 || + (ssig == SiG_NONE && ptr->sendQueue) || (ssig == SiG_NONE && ptr->status == STATUS_DISABLED)) { return CallService(MS_PROTO_CHAINSEND, wParam, lParam); Sent_NetLog("onSendMsg: pass unhandled"); @@ -503,25 +503,25 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) // если можно зашифровать - шифруем if (isContactPGP(ptr->hContact) || isContactGPG(ptr->hContact)) { if (!ptr->cntx) { - ptr->cntx = cpp_create_context((isContactGPG(ptr->hContact)?CPP_MODE_GPG:CPP_MODE_PGP) | ((db_get_b(ptr->hContact,MODULENAME,"gpgANSI",0))?CPP_MODE_GPG_ANSI:0)); + ptr->cntx = cpp_create_context((isContactGPG(ptr->hContact) ? CPP_MODE_GPG : CPP_MODE_PGP) | ((db_get_b(ptr->hContact, MODULENAME, "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; - ptrA szUtfMsg( miranda_to_utf8((LPCSTR)pccsd->lParam,pccsd->wParam)); + ptrA szUtfMsg(miranda_to_utf8((LPCSTR)pccsd->lParam, pccsd->wParam)); if (ptr->keyLoaded == 1) // PGP - szNewMsg = pgp_encode(ptr->cntx,szUtfMsg); + szNewMsg = pgp_encode(ptr->cntx, szUtfMsg); else if (ptr->keyLoaded == 2) // GPG - szNewMsg = gpg_encode(ptr->cntx,szUtfMsg); + szNewMsg = gpg_encode(ptr->cntx, szUtfMsg); if (!szNewMsg) - return returnError(pccsd->hContact,Translate(sim109)); + return returnError(pccsd->hContact, Translate(sim109)); // отправляем зашифрованное сообщение - splitMessageSend(ptr,szNewMsg); + splitMessageSend(ptr, szNewMsg); showPopupSM(ptr->hContact); @@ -549,7 +549,7 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) } else createRSAcntx(ptr); - if (!bSOM || (!isClientMiranda(ptr,1) && !isSecureIM(ptr,1)) || !loadRSAkey(ptr)) { + if (!bSOM || (!isClientMiranda(ptr, 1) && !isSecureIM(ptr, 1)) || !loadRSAkey(ptr)) { if (ssig == SiG_NONE) // просто шлем незашифрованное в оффлайн return CallService(MS_PROTO_CHAINSEND, wParam, lParam); @@ -559,7 +559,7 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) } // шлем шифрованное в оффлайн - exp->rsa_send(ptr->cntx, ptrA( miranda_to_utf8((LPCSTR)pccsd->lParam,pccsd->wParam))); + exp->rsa_send(ptr->cntx, ptrA(miranda_to_utf8((LPCSTR)pccsd->lParam, pccsd->wParam))); showPopupSM(ptr->hContact); return returnNoError(pccsd->hContact); } @@ -585,13 +585,13 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) deleteRSAcntx(ptr); } ShowStatusIconNotify(ptr->hContact); - waitForExchange(ptr,3); // дошлем нешифрованно + waitForExchange(ptr, 3); // дошлем нешифрованно return returnNoError(pccsd->hContact); } // соединение установлено if (ptr->cntx && exp->rsa_get_state(ptr->cntx) == 7) { - exp->rsa_send(ptr->cntx, ptrA(miranda_to_utf8((LPCSTR)pccsd->lParam,pccsd->wParam))); + exp->rsa_send(ptr->cntx, ptrA(miranda_to_utf8((LPCSTR)pccsd->lParam, pccsd->wParam))); ShowStatusIconNotify(ptr->hContact); showPopupSM(ptr->hContact); return returnNoError(pccsd->hContact); @@ -602,7 +602,7 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) // добавим его в очередь addMsg2Queue(ptr, pccsd->wParam, (LPSTR)pccsd->lParam); // запускаем процесс установки соединения - ssig=SiG_INIT; + ssig = SiG_INIT; // запускаем трэд ожидания и досылки waitForExchange(ptr); } @@ -632,16 +632,16 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) // if user try initialize connection if (ssig == SiG_INIT) // secure IM is disabled ... - return returnError(pccsd->hContact,Translate(sim105)); + return returnError(pccsd->hContact, Translate(sim105)); if (ptr->cntx) { // if secure context exists - cpp_delete_context(ptr->cntx); ptr->cntx=0; + cpp_delete_context(ptr->cntx); ptr->cntx = 0; CCSDATA ccsd; memcpy(&ccsd, (HLOCAL)lParam, sizeof(CCSDATA)); pccsd->wParam |= PREF_METANODB; - ccsd.lParam = (LPARAM) SIG_DEIN; + ccsd.lParam = (LPARAM)SIG_DEIN; ccsd.szProtoService = PSS_MESSAGE; CallService(MS_PROTO_CHAINSEND, wParam, (LPARAM)&ccsd); @@ -659,7 +659,7 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) cpp_reset_context(ptr->cntx); if (!bSOM) { - if (ssig != SiG_NONE ) + if (ssig != SiG_NONE) return returnNoError(pccsd->hContact); // exit and send unencrypted message @@ -671,16 +671,16 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) // set key for offline user DBVARIANT dbv; dbv.type = DBVT_BLOB; if (db_get_dw(ptr->hContact, MODULENAME, "offlineKeyTimeout", 0) > gettime() && - db_get(ptr->hContact, MODULENAME, "offlineKey", &dbv) == 0) { + db_get(ptr->hContact, MODULENAME, "offlineKey", &dbv) == 0) { // if valid key is succefully retrieved ptr->offlineKey = true; - InitKeyX(ptr,dbv.pbVal); + InitKeyX(ptr, dbv.pbVal); db_free(&dbv); } else { - db_unset(ptr->hContact,MODULENAME,"offlineKey"); - db_unset(ptr->hContact,MODULENAME,"offlineKeyTimeout"); - if (msgbox1(0,sim106,MODULENAME,MB_YESNO|MB_ICONQUESTION) == IDNO) + db_unset(ptr->hContact, MODULENAME, "offlineKey"); + db_unset(ptr->hContact, MODULENAME, "offlineKeyTimeout"); + if (msgbox1(0, sim106, MODULENAME, MB_YESNO | MB_ICONQUESTION) == IDNO) return returnNoError(pccsd->hContact); // exit and send unencrypted message @@ -718,7 +718,7 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) // disable SecureIM only if it was enabled if (ptr->cntx) { - cpp_delete_context(ptr->cntx); ptr->cntx=0; + cpp_delete_context(ptr->cntx); ptr->cntx = 0; pccsd->wParam |= PREF_METANODB; CallService(MS_PROTO_CHAINSEND, wParam, lParam); @@ -730,7 +730,7 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) } if (cpp_keya(ptr->cntx) && cpp_keyb(ptr->cntx) && !cpp_keyx(ptr->cntx)) - CalculateKeyX(ptr,ptr->hContact); + CalculateKeyX(ptr, ptr->hContact); ShowStatusIconNotify(pccsd->hContact); @@ -738,8 +738,8 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) if (cpp_keyx(ptr->cntx)) { Sent_NetLog("onSendMsg: cryptokey exist"); - ptrA szNewMsg( encodeMsg(ptr,(LPARAM)pccsd)); - Sent_NetLog("onSend: encrypted msg '%s'",szNewMsg); + ptrA szNewMsg(encodeMsg(ptr, (LPARAM)pccsd)); + Sent_NetLog("onSend: encrypted msg '%s'", szNewMsg); pccsd->wParam |= PREF_METANODB; pccsd->lParam = (LPARAM)(char*)szNewMsg; @@ -759,12 +759,12 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) if (!ptr->waitForExchange) { // init || always_try || always_if_possible - ptrA keyToSend( InitKeyA(ptr,0)); // calculate public and private key & fill KeyA + ptrA keyToSend(InitKeyA(ptr, 0)); // calculate public and private key & fill KeyA Sent_NetLog("Sending KEY3: %s", keyToSend); pccsd->wParam &= ~PREF_UNICODE; pccsd->wParam |= PREF_METANODB; - pccsd->lParam = (LPARAM) keyToSend; + pccsd->lParam = (LPARAM)keyToSend; pccsd->szProtoService = PSS_MESSAGE; CallService(MS_PROTO_CHAINSEND, wParam, lParam); @@ -784,22 +784,22 @@ int file_idx = 0; INT_PTR __cdecl onSendFile(WPARAM wParam, LPARAM lParam) { - CCSDATA *pccsd=(CCSDATA*)lParam; + CCSDATA *pccsd = (CCSDATA*)lParam; pUinKey ptr = getUinKey(pccsd->hContact); if (!ptr || !bSFT) return CallService(PSS_FILE, wParam, lParam); if (isContactSecured(pccsd->hContact)&SECURED) { - char **file=(char **)pccsd->lParam; - if (file_idx == 100) file_idx=0; + char **file = (char **)pccsd->lParam; + if (file_idx == 100) file_idx = 0; int i; - for (i=0;file[i];i++) { + for (i = 0; file[i]; i++) { - if (strstr(file[i],".AESHELL")) continue; + if (strstr(file[i], ".AESHELL")) continue; - char *name = strrchr(file[i],'\\'); - if (!name ) name = file[i]; + char *name = strrchr(file[i], '\\'); + if (!name) name = file[i]; else name++; int size = TEMP_SIZE + (int)strlen(name) + 20; @@ -808,25 +808,25 @@ INT_PTR __cdecl onSendFile(WPARAM wParam, LPARAM lParam) char buf[MAX_PATH]; mir_snprintf(buf, SIZEOF(buf), "%s\n%s", Translate(sim011), file[i]); - showPopup(buf,NULL,g_hPOP[POP_PU_MSS],2); + showPopup(buf, NULL, g_hPOP[POP_PU_MSS], 2); if (ptr->mode == MODE_RSAAES) - exp->rsa_encrypt_file(ptr->cntx,file[i],file_out); + exp->rsa_encrypt_file(ptr->cntx, file[i], file_out); else - cpp_encrypt_file(ptr->cntx,file[i],file_out); + cpp_encrypt_file(ptr->cntx, file[i], file_out); mir_free(file[i]); - file[i]=file_out; + file[i] = file_out; } if (ptr->fileSend) { // очистим сохраненный список - for (int j=0; ptr->fileSend[j]; j++) + for (int j = 0; ptr->fileSend[j]; j++) mir_free(ptr->fileSend[j]); SAFE_FREE(ptr->fileSend); } if (i) { // скопируем новый список - ptr->fileSend = (char **) mir_alloc(sizeof(char*)*(i+1)); - for (i=0;file[i];i++) + ptr->fileSend = (char **)mir_alloc(sizeof(char*)*(i + 1)); + for (i = 0; file[i]; i++) ptr->fileSend[i] = mir_strdup(file[i]); ptr->fileSend[i] = NULL; @@ -835,17 +835,17 @@ INT_PTR __cdecl onSendFile(WPARAM wParam, LPARAM lParam) return CallService(PSS_FILE, wParam, lParam); } -int __cdecl onProtoAck(WPARAM wParam,LPARAM lParam) +int __cdecl onProtoAck(WPARAM wParam, LPARAM lParam) { - ACKDATA *ack=(ACKDATA*)lParam; + ACKDATA *ack = (ACKDATA*)lParam; if (ack->type != ACKTYPE_FILE) return 0; //quit if not file transfer event - PROTOFILETRANSFERSTATUS *f = (PROTOFILETRANSFERSTATUS*) ack->lParam; + PROTOFILETRANSFERSTATUS *f = (PROTOFILETRANSFERSTATUS*)ack->lParam; pUinKey ptr = getUinKey(ack->hContact); if (!ptr || (f && (f->flags & PFTS_SENDING) && !bSFT)) return 0; if (isContactSecured(ack->hContact)&SECURED) { - switch(ack->result) { + switch (ack->result) { case ACKRESULT_DATA: if (f->flags & PFTS_SENDING) { ptr->finFileSend = (f->currentFileSize == f->currentFileProgress); @@ -862,17 +862,17 @@ int __cdecl onProtoAck(WPARAM wParam,LPARAM lParam) case ACKRESULT_DENIED: case ACKRESULT_FAILED: if (ptr->lastFileRecv) { - if (strstr(ptr->lastFileRecv,".AESHELL")) mir_unlink(ptr->lastFileRecv); + if (strstr(ptr->lastFileRecv, ".AESHELL")) mir_unlink(ptr->lastFileRecv); SAFE_FREE(ptr->lastFileRecv); } if (ptr->lastFileSend) { - if (strstr(ptr->lastFileSend,".AESHELL")) mir_unlink(ptr->lastFileSend); + if (strstr(ptr->lastFileSend, ".AESHELL")) mir_unlink(ptr->lastFileSend); SAFE_FREE(ptr->lastFileSend); } if (ptr->fileSend) { - char **file=ptr->fileSend; - for (int j=0;file[j];j++) { - if (strstr(file[j],".AESHELL")) mir_unlink(file[j]); + char **file = ptr->fileSend; + for (int j = 0; file[j]; j++) { + if (strstr(file[j], ".AESHELL")) mir_unlink(file[j]); mir_free(file[j]); } SAFE_FREE(ptr->fileSend); @@ -882,33 +882,33 @@ int __cdecl onProtoAck(WPARAM wParam,LPARAM lParam) case ACKRESULT_NEXTFILE: case ACKRESULT_SUCCESS: if (ptr->finFileRecv && ptr->lastFileRecv) { - if (strstr(ptr->lastFileRecv,".AESHELL")) { + 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 + 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)) { - buf[0]='\0'; - LPSTR p=strrchr(file_out,'.'); - LPSTR x=strrchr(file_out,'\\'); - if (p>x) { - strcpy(buf,p); - pos=p; + buf[0] = '\0'; + LPSTR p = strrchr(file_out, '.'); + LPSTR x = strrchr(file_out, '\\'); + if (p > x) { + strcpy(buf, p); + pos = p; } - for (int i=1;i<10000;i++) { - sprintf(pos," (%d)%s",i,buf); //!!!!!!!!!!!!! + for (int i = 1; i < 10000; i++) { + sprintf(pos, " (%d)%s", i, buf); //!!!!!!!!!!!!! if (!isFileExist(file_out)) break; } } mir_snprintf(buf, SIZEOF(buf), "%s\n%s", Translate(sim012), file_out); - showPopup(buf,NULL,g_hPOP[POP_PU_MSR],2); + showPopup(buf, NULL, g_hPOP[POP_PU_MSR], 2); - if (ptr->mode == MODE_RSAAES ) - exp->rsa_decrypt_file(ptr->cntx,ptr->lastFileRecv,file_out); + if (ptr->mode == MODE_RSAAES) + exp->rsa_decrypt_file(ptr->cntx, ptr->lastFileRecv, file_out); else - cpp_decrypt_file(ptr->cntx,ptr->lastFileRecv,file_out); + cpp_decrypt_file(ptr->cntx, ptr->lastFileRecv, file_out); mir_free(file_out); mir_unlink(ptr->lastFileRecv); @@ -917,7 +917,7 @@ int __cdecl onProtoAck(WPARAM wParam,LPARAM lParam) ptr->finFileRecv = false; } if (ptr->finFileSend && ptr->lastFileSend) { - if (strstr(ptr->lastFileSend,".AESHELL")) mir_unlink(ptr->lastFileSend); + if (strstr(ptr->lastFileSend, ".AESHELL")) mir_unlink(ptr->lastFileSend); SAFE_FREE(ptr->lastFileSend); ptr->finFileSend = false; } @@ -926,5 +926,3 @@ int __cdecl onProtoAck(WPARAM wParam,LPARAM lParam) } return 0; } - -// EOF diff --git a/plugins/SecureIM/src/svcs_rsa.cpp b/plugins/SecureIM/src/svcs_rsa.cpp index 22035d17bc..b4ca73fb1f 100644 --- a/plugins/SecureIM/src/svcs_rsa.cpp +++ b/plugins/SecureIM/src/svcs_rsa.cpp @@ -8,7 +8,7 @@ RSA_IMPORT imp = rsa_notify }; -BOOL rsa_4096=0; +BOOL rsa_4096 = 0; int __cdecl rsa_inject(HANDLE context, LPCSTR msg) { @@ -16,12 +16,12 @@ int __cdecl rsa_inject(HANDLE context, LPCSTR msg) Sent_NetLog("rsa_inject: '%s'", msg); - int len = (int)strlen(msg)+1; - LPSTR buf = (LPSTR) mir_alloc(LEN_SECU+len); - memcpy(buf,SIG_SECU,LEN_SECU); - memcpy(buf+LEN_SECU,msg,len); + int len = (int)strlen(msg) + 1; + LPSTR buf = (LPSTR)mir_alloc(LEN_SECU + len); + memcpy(buf, SIG_SECU, LEN_SECU); + memcpy(buf + LEN_SECU, msg, len); // отправляем сообщение - splitMessageSend(ptr,buf); + splitMessageSend(ptr, buf); mir_free(buf); return 1; } @@ -30,41 +30,41 @@ 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; + int v = 0, k = 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); - LPSTR sha = mir_strdup(to_hex(sig,sigLen)); + 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); + LPSTR sha = mir_strdup(to_hex(sig, sigLen)); LPSTR sha_old = NULL; Sent_NetLog("rsa_check_pub: %s %s %s", cnm, uin, sha); DBVARIANT dbv; dbv.type = DBVT_BLOB; - if (db_get(ptr->hContact,MODULENAME,"rsa_pub",&dbv) == 0) { + if (db_get(ptr->hContact, MODULENAME, "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)); + 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)); db_free(&dbv); } 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); + 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); v = 1; #if defined(_DEBUG) || defined(NETLIB_LOG) Sent_NetLog("rsa_check_pub: auto accepted"); #endif } else { - 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,MODULENAME,MB_YESNO|MB_ICONQUESTION) == IDYES); + 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, MODULENAME, MB_YESNO | MB_ICONQUESTION) == IDYES); #if defined(_DEBUG) || defined(NETLIB_LOG) - Sent_NetLog("rsa_check_pub: manual accepted %d",v); + Sent_NetLog("rsa_check_pub: manual accepted %d", v); #endif } if (v) { @@ -82,29 +82,29 @@ 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; - LPCSTR msg=NULL; + LPCSTR msg = NULL; Sent_NetLog("rsa_notify: 0x%x", state); - switch( state) { + switch (state) { case 1: showPopupEC(ptr->hContact); ShowStatusIconNotify(ptr->hContact); - waitForExchange(ptr,2); // досылаем сообщения из очереди + waitForExchange(ptr, 2); // досылаем сообщения из очереди return; case -1: // сессия разорвана по ошибке, неверный тип сообщения - msg=sim501; break; + msg = sim501; break; case -2: // сессия разорвана по ошибке другой стороной - msg=sim502; break; + msg = sim502; break; case -5: // ошибка декодирования AES сообщения - msg=sim505; break; + msg = sim505; break; case -6: // ошибка декодирования RSA сообщения - msg=sim506; break; + msg = sim506; break; case -7: // таймаут установки соединения (10 секунд) - msg=sim507; break; + msg = sim507; break; case -8: // сессия разорвана по причине "disabled" - msg=sim508; break; + msg = sim508; break; case -0x10: // сессия разорвана по ошибке case -0x21: case -0x22: @@ -116,14 +116,14 @@ void __cdecl rsa_notify(HANDLE context, int state) case -0x40: case -0x50: case -0x60: - { - char buf[1024]; - mir_snprintf(buf, SIZEOF(buf), sim510, -state); - showPopupDCmsg(ptr->hContact, buf); - ShowStatusIconNotify(ptr->hContact); - if (ptr->cntx) deleteRSAcntx(ptr); - waitForExchange(ptr, 3); // досылаем нешифровано - } + { + char buf[1024]; + mir_snprintf(buf, SIZEOF(buf), sim510, -state); + showPopupDCmsg(ptr->hContact, buf); + ShowStatusIconNotify(ptr->hContact); + if (ptr->cntx) deleteRSAcntx(ptr); + waitForExchange(ptr, 3); // досылаем нешифровано + } return; case -3: // соединение разорвано вручную @@ -131,16 +131,16 @@ void __cdecl rsa_notify(HANDLE context, int state) showPopupDC(ptr->hContact); ShowStatusIconNotify(ptr->hContact); if (ptr->cntx) deleteRSAcntx(ptr); - waitForExchange(ptr,3); // досылаем нешифровано + waitForExchange(ptr, 3); // досылаем нешифровано return; default: return; } - showPopupDCmsg(ptr->hContact,msg); + showPopupDCmsg(ptr->hContact, msg); ShowStatusIconNotify(ptr->hContact); if (ptr->cntx) deleteRSAcntx(ptr); - waitForExchange(ptr,3); // досылаем нешифровано + waitForExchange(ptr, 3); // досылаем нешифровано } void sttGenerateRSA(LPVOID) @@ -149,7 +149,7 @@ void sttGenerateRSA(LPVOID) char pub_key[4096]; int pub_len; exp->rsa_gen_keypair(CPP_MODE_RSA_4096); - exp->rsa_get_keypair(CPP_MODE_RSA_4096,(PBYTE)&priv_key,&priv_len,(PBYTE)&pub_key,&pub_len); + exp->rsa_get_keypair(CPP_MODE_RSA_4096, (PBYTE)&priv_key, &priv_len, (PBYTE)&pub_key, &pub_len); db_set_blob(NULL, MODULENAME, "rsa_priv", priv_key, priv_len); db_set_blob(NULL, MODULENAME, "rsa_pub", pub_key, pub_len); @@ -162,8 +162,8 @@ BYTE loadRSAkey(pUinKey ptr) if (!ptr->keyLoaded) { DBVARIANT dbv; dbv.type = DBVT_BLOB; - if ( db_get(ptr->hContact,MODULENAME,"rsa_pub",&dbv) == 0) { - ptr->keyLoaded = exp->rsa_set_pubkey(ptr->cntx,dbv.pbVal,dbv.cpbVal); + if (db_get(ptr->hContact, MODULENAME, "rsa_pub", &dbv) == 0) { + ptr->keyLoaded = exp->rsa_set_pubkey(ptr->cntx, dbv.pbVal, dbv.cpbVal); Sent_NetLog("loadRSAkey %d", ptr->keyLoaded); db_free(&dbv); } @@ -187,7 +187,7 @@ void resetRSAcntx(pUinKey ptr) cpp_delete_context(ptr->cntx); ptr->cntx = cpp_create_context(CPP_MODE_RSA); ptr->keyLoaded = 0; - } + } } // удаляет RSA контекст @@ -197,6 +197,3 @@ void deleteRSAcntx(pUinKey ptr) ptr->cntx = 0; ptr->keyLoaded = 0; } - - -// EOF diff --git a/plugins/SecureIM/src/svcs_srmm.cpp b/plugins/SecureIM/src/svcs_srmm.cpp index e9ba237a51..9d021aae42 100644 --- a/plugins/SecureIM/src/svcs_srmm.cpp +++ b/plugins/SecureIM/src/svcs_srmm.cpp @@ -11,7 +11,7 @@ int __cdecl onWindowEvent(WPARAM, LPARAM lParam) int __cdecl onIconPressed(WPARAM hContact, LPARAM lParam) { - if (isProtoMetaContacts(hContact)) + if (db_mc_isMeta(hContact)) hContact = db_mc_getMostOnline(hContact); // возьмем тот, через который пойдет сообщение StatusIconClickData *sicd = (StatusIconClickData *)lParam; @@ -33,31 +33,33 @@ void InitSRMMIcons() // add icon to srmm status icons StatusIconData sid = { sizeof(sid) }; sid.szModule = MODULENAME; - sid.flags = MBF_DISABLED|MBF_HIDDEN; + sid.flags = MBF_DISABLED | MBF_HIDDEN; // Native sid.dwId = MODE_NATIVE; - sid.hIcon = mode2icon(MODE_NATIVE|SECURED,3); - sid.hIconDisabled = mode2icon(MODE_NATIVE,3); + sid.hIcon = mode2icon(MODE_NATIVE | SECURED, 3); + sid.hIconDisabled = mode2icon(MODE_NATIVE, 3); sid.szTooltip = LPGEN("SecureIM [Native]"); Srmm_AddIcon(&sid); // PGP sid.dwId = MODE_PGP; - sid.hIcon = mode2icon(MODE_PGP|SECURED,3); - sid.hIconDisabled = mode2icon(MODE_PGP,3); + sid.hIcon = mode2icon(MODE_PGP | SECURED, 3); + sid.hIconDisabled = mode2icon(MODE_PGP, 3); sid.szTooltip = LPGEN("SecureIM [PGP]"); Srmm_AddIcon(&sid); + // GPG sid.dwId = MODE_GPG; - sid.hIcon = mode2icon(MODE_GPG|SECURED,3); - sid.hIconDisabled = mode2icon(MODE_GPG,3); + sid.hIcon = mode2icon(MODE_GPG | SECURED, 3); + sid.hIconDisabled = mode2icon(MODE_GPG, 3); sid.szTooltip = LPGEN("SecureIM [GPG]"); Srmm_AddIcon(&sid); + // RSAAES sid.dwId = MODE_RSAAES; - sid.hIcon = mode2icon(MODE_RSAAES|SECURED,3); - sid.hIconDisabled = mode2icon(MODE_RSAAES,3); + sid.hIcon = mode2icon(MODE_RSAAES | SECURED, 3); + sid.hIconDisabled = mode2icon(MODE_RSAAES, 3); sid.szTooltip = LPGEN("SecureIM [RSA/AES]"); Srmm_AddIcon(&sid); @@ -65,5 +67,3 @@ void InitSRMMIcons() HookEvent(ME_MSG_WINDOWEVENT, onWindowEvent); HookEvent(ME_MSG_ICONPRESSED, onIconPressed); } - -// EOF -- cgit v1.2.3