diff options
author | George Hazan <george.hazan@gmail.com> | 2014-07-08 15:49:18 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-07-08 15:49:18 +0000 |
commit | 62ab18a9fda2f19c08ae63a14c7a262ca62f0cce (patch) | |
tree | 821876224af8cb3e3f4b9b29ea3237212cde37e7 /plugins/SecureIM/src/svcs_proto.cpp | |
parent | 19a5e6f0b9c3232933132dbaa9420aecef497336 (diff) |
code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@9732 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SecureIM/src/svcs_proto.cpp')
-rw-r--r-- | plugins/SecureIM/src/svcs_proto.cpp | 300 |
1 files changed, 149 insertions, 151 deletions
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
|