diff options
-rwxr-xr-x | plugins/New_GPG/src/init.cpp | 2 | ||||
-rwxr-xr-x | plugins/New_GPG/src/main.cpp | 8 | ||||
-rwxr-xr-x | plugins/New_GPG/src/messages.cpp | 62 | ||||
-rwxr-xr-x | plugins/New_GPG/src/options.cpp | 8 | ||||
-rwxr-xr-x | plugins/New_GPG/src/utilities.cpp | 3 |
5 files changed, 46 insertions, 37 deletions
diff --git a/plugins/New_GPG/src/init.cpp b/plugins/New_GPG/src/init.cpp index 1313dc7edd..532d857092 100755 --- a/plugins/New_GPG/src/init.cpp +++ b/plugins/New_GPG/src/init.cpp @@ -223,7 +223,7 @@ static int OnModulesLoaded(WPARAM wParam,LPARAM lParam) if(bJabberAPI && bIsMiranda09)
HookEvent(ME_PROTO_ACCLISTCHANGED, GetJabberInterface);
- HookEvent(ME_PROTO_ACK, onProtoAck); //filetransfer unimplemented now
+ HookEvent(ME_PROTO_ACK, onProtoAck);
HookEvent(ME_CLIST_PREBUILDCONTACTMENU, OnPreBuildContactMenu);
diff --git a/plugins/New_GPG/src/main.cpp b/plugins/New_GPG/src/main.cpp index 0c212d4e07..e28114c963 100755 --- a/plugins/New_GPG/src/main.cpp +++ b/plugins/New_GPG/src/main.cpp @@ -2261,7 +2261,7 @@ void ImportKey() s2 = output.find("<", s); else if(s2 > output.find("<", s)) s2 = output.find("<", s); - tmp = new char [output.substr(s,s2-s-1).length()+1]; + tmp = (char*)mir_alloc(sizeof(char)*(output.substr(s,s2-s-1).length()+1)); strcpy(tmp, output.substr(s,s2-s-1).c_str()); mir_utf8decode(tmp, 0); DBWriteContactSettingString(hContact, szGPGModuleName, "KeyMainName", tmp); @@ -2273,14 +2273,14 @@ void ImportKey() s2++; if(output[s] == ')') { - tmp = new char [output.substr(s2,s-s2).length()+1]; + tmp = (char*)mir_alloc(sizeof(char)* (output.substr(s2,s-s2).length()+1)); strcpy(tmp, output.substr(s2,s-s2).c_str()); mir_utf8decode(tmp, 0); DBWriteContactSettingString(hContact, szGPGModuleName, "KeyComment", tmp); mir_free(tmp); s+=3; s2 = output.find(">", s); - tmp = new char [output.substr(s,s2-s).length()+1]; + tmp = (char*) mir_alloc(sizeof(char)*(output.substr(s,s2-s).length()+1)); strcpy(tmp, output.substr(s,s2-s).c_str()); mir_utf8decode(tmp, 0); DBWriteContactSettingString(hContact, szGPGModuleName, "KeyMainEmail", tmp); @@ -2288,7 +2288,7 @@ void ImportKey() } else { - tmp = new char [output.substr(s2,s-s2).length()+1]; + tmp = (char*)mir_alloc(sizeof(char)* (output.substr(s2,s-s2).length()+1)); strcpy(tmp, output.substr(s2,s-s2).c_str()); mir_utf8decode(tmp, 0); DBWriteContactSettingString(hContact, szGPGModuleName, "KeyMainEmail", output.substr(s2,s-s2).c_str()); diff --git a/plugins/New_GPG/src/messages.cpp b/plugins/New_GPG/src/messages.cpp index ba9a36c29c..f551680c36 100755 --- a/plugins/New_GPG/src/messages.cpp +++ b/plugins/New_GPG/src/messages.cpp @@ -25,7 +25,7 @@ int returnNoError(HANDLE hContact); std::list<HANDLE> sent_msgs; -int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, DWORD timestamp) +void RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, DWORD timestamp) { DWORD dbflags = DBEF_UTF; { //check for gpg related data @@ -69,7 +69,7 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, D { HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); - return 0; + return; } } { @@ -169,13 +169,13 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, D CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)"Unable to decrypt PGP encrypted message"); HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT)); DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", enc); - return 0; + return; } if(result == pxNotFound) { DeleteFile(path.c_str()); HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); - return 0; + return; } //TODO: check gpg output for errors _terminate = false; @@ -233,13 +233,13 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, D CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)"Unable to decrypt PGP encrypted message"); HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT)); DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", enc); - return 0; + return; } if(result == pxNotFound) { DeleteFile(path.c_str()); HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); - return 0; + return; } //TODO: check gpg output for errors } @@ -258,7 +258,7 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, D CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)"Unable to decrypt PGP encrypted message"); HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT)); DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", enc); - return 0; + return; } if(result == pxNotFound) { @@ -292,7 +292,7 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, D HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT)); DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", enc); mir_free(tmp); - return 0; + return; } } } @@ -329,7 +329,7 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, D HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT)); DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", enc); mir_free(tmp); - return 0; + return; } else { @@ -344,12 +344,12 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, D HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags|DBEF_READ)); HistoryLog(metaGetContact(hContact), db_event(msg, timestamp, 0, dbflags)); mir_free(msg); - return 0; + return; } char *tmp = mir_strdup(toUTF8(str).c_str()); HistoryLog(hContact, db_event(tmp, timestamp, 0, dbflags)); mir_free(tmp); - return 0; + return; } } } @@ -361,13 +361,13 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, D { HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags|DBEF_READ)); HistoryLog(metaGetContact(hContact), db_event(msg, timestamp, 0, dbflags)); - return 0; + return; } HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags|DBEF_READ)); - return 0; + return; } HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); - return 0; + return; } int RecvMsgSvc(WPARAM w, LPARAM l) @@ -621,7 +621,7 @@ int RecvMsgSvc(WPARAM w, LPARAM l) return returnNoError(ccs->hContact); } -int SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) +void SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) { wstring str; bool isansi = false; @@ -668,7 +668,8 @@ int SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) HistoryLog(hContact, db_event("Failed to encrypt message with GPG", 0,0, DBEF_SENT)); hcontact_data[hContact].msgs_to_pass.push_back("Failed to encrypt message with GPG"); mir_free(msg); - return CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); + CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); + return; } if(!bJabberAPI || !bIsMiranda09) //force jabber to handle encrypted message by itself cmd += _T("--comment \"\" --no-version "); @@ -714,12 +715,14 @@ int SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) params.hProcess = NULL; debuglog<<time_str()<<": GPG execution timed out, aborted\n"; mir_free(msg); - return CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); + CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); + return; } if(result == pxNotFound) { mir_free(msg); - return CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); + CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); + return; } //TODO: check gpg output for errors if(out.find("There is no assurance this key belongs to the named user") != string::npos) @@ -744,19 +747,21 @@ int SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) params.hProcess = NULL; debuglog<<time_str()<<": GPG execution timed out, aborted\n"; mir_free(msg); - return CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); + CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); + return; } if(result == pxNotFound) { mir_free(msg); - return CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); + CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); + return; } //TODO: check gpg output for errors } else { mir_free(msg); - return 0; + return; } } if(out.find("usage: ") != string::npos) @@ -764,7 +769,8 @@ int SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) MessageBox(0, _T("Something wrong, gpg does not understand us, aborting encryption."), _T("Warning"), MB_OK); DeleteFile(path.c_str()); mir_free(msg); - return CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); + CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); + return; } DeleteFile(path.c_str()); path.append(_T(".asc")); @@ -790,7 +796,8 @@ int SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) hcontact_data[hContact].msgs_to_pass.push_back("Failed to encrypt message with GPG"); debuglog<<time_str()<<": info: Failed to encrypt message with GPG\n"; mir_free(msg); - return CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); + CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); + return; } string str_event = msg; if(bAppendTags) @@ -810,9 +817,10 @@ int SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) HistoryLog(hContact, db_event((char*)str_event.c_str(), 0,0, dbflags|DBEF_SENT)); if(!(flags & PREF_UTF)) flags |= PREF_UTF; - sent_msgs.push_back((HANDLE)CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)toUTF8(str).c_str())); + HANDLE hProcess = NULL; + sent_msgs.push_back(hProcess = (HANDLE)CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)toUTF8(str).c_str())); mir_free(msg); - return 0; + return; } int SendMsgSvc(WPARAM w, LPARAM l) @@ -901,8 +909,8 @@ int SendMsgSvc(WPARAM w, LPARAM l) mir_free(msg); return CallService(MS_PROTO_CHAINSEND, w, l); } - boost::thread *thr = new boost::thread(boost::bind(SendMsgSvc_func, ccs->hContact, msg, (DWORD)ccs->wParam)); - return returnNoError(ccs->hContact); + boost::thread *thr = new boost::thread(boost::bind(SendMsgSvc_func, ccs->hContact, msg, (DWORD)ccs->wParam));
+ return returnNoError(ccs->hContact);
} boost::mutex event_processing_mutex; diff --git a/plugins/New_GPG/src/options.cpp b/plugins/New_GPG/src/options.cpp index f03879c48b..80cbbbc559 100755 --- a/plugins/New_GPG/src/options.cpp +++ b/plugins/New_GPG/src/options.cpp @@ -669,22 +669,22 @@ static BOOL CALLBACK DlgProcGpgMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP GetDlgItemText(hwndDlg, IDC_IN_OPEN_TAG, tmp, 128);
DBWriteContactSettingTString(NULL, szGPGModuleName, "szInOpenTag", tmp);
mir_free(inopentag);
- inopentag = new TCHAR [_tcslen(tmp)+1];
+ inopentag = (TCHAR*)mir_alloc(sizeof(TCHAR)* (_tcslen(tmp)+1));
_tcscpy(inopentag, tmp);
GetDlgItemText(hwndDlg, IDC_IN_CLOSE_TAG, tmp, 128);
DBWriteContactSettingTString(NULL, szGPGModuleName, "szInCloseTag", tmp);
mir_free(inclosetag);
- inclosetag = new TCHAR [_tcslen(tmp)+1];
+ inclosetag = (TCHAR*)mir_alloc(sizeof(TCHAR)* (_tcslen(tmp)+1));
_tcscpy(inclosetag, tmp);
GetDlgItemText(hwndDlg, IDC_OUT_OPEN_TAG, tmp, 128);
DBWriteContactSettingTString(NULL, szGPGModuleName, "szOutOpenTag", tmp);
mir_free(outopentag);
- outopentag = new TCHAR [_tcslen(tmp)+1];
+ outopentag = (TCHAR*)mir_alloc(sizeof(TCHAR)* (_tcslen(tmp)+1));
_tcscpy(outopentag, tmp);
GetDlgItemText(hwndDlg, IDC_OUT_CLOSE_TAG, tmp, 128);
DBWriteContactSettingTString(NULL, szGPGModuleName, "szOutCloseTag", tmp);
mir_free(outclosetag);
- outclosetag = new TCHAR [_tcslen(tmp)+1];
+ outclosetag = (TCHAR*)mir_alloc(sizeof(TCHAR)*(_tcslen(tmp)+1));
_tcscpy(outclosetag, tmp);
}
return TRUE;
diff --git a/plugins/New_GPG/src/utilities.cpp b/plugins/New_GPG/src/utilities.cpp index 1e9d8997b8..c07be132d2 100755 --- a/plugins/New_GPG/src/utilities.cpp +++ b/plugins/New_GPG/src/utilities.cpp @@ -1150,7 +1150,7 @@ int SendBroadcast( HANDLE hContact, int type, int result, HANDLE hProcess, LPARA ACKDATA ack; memset(&ack,0,sizeof(ack)); ack.cbSize = sizeof( ACKDATA ); - ack.szModule = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + ack.szModule = szGPGModuleName;// (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); ack.hContact = hContact; ack.type = type; ack.result = result; @@ -1189,6 +1189,7 @@ int returnNoError(HANDLE hContact) { // end from secureim + string toUTF8(wstring str) { string ustr; |