diff options
author | George Hazan <george.hazan@gmail.com> | 2013-04-20 14:25:52 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-04-20 14:25:52 +0000 |
commit | a346491026d5df1ffe0d41e4881613a47ca6ca47 (patch) | |
tree | ffd505fe0680db47ea51549ec3565e23f56e34a1 /plugins | |
parent | 2ffa7047ec0475856481b9e813eecb99b268d2d0 (diff) |
end of the city legend that PSS_MESSAGEW ever existed
git-svn-id: http://svn.miranda-ng.org/main/trunk@4482 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
22 files changed, 288 insertions, 485 deletions
diff --git a/plugins/Boltun/src/actionQueue.cpp b/plugins/Boltun/src/actionQueue.cpp index a3915bf255..7a8f5be790 100644 --- a/plugins/Boltun/src/actionQueue.cpp +++ b/plugins/Boltun/src/actionQueue.cpp @@ -81,21 +81,6 @@ static bool NotifyTyping(HANDLE hContact) return res != 0;
}
-static char *MsgServiceName(HANDLE hContact)
-{
-
- char szServiceName[100];
- char *szProto = GetContactProto(hContact);
- if (szProto == NULL)
- return PSS_MESSAGE;
-
- mir_snprintf(szServiceName, sizeof(szServiceName), "%s%sW", szProto, PSS_MESSAGE);
- if (ServiceExists(szServiceName))
- return PSS_MESSAGE "W";
-
- return PSS_MESSAGE;
-}
-
static void TimerAnswer(HANDLE hContact, const TalkBot::MessageInfo* info)
{
DBEVENTINFO ldbei;
@@ -105,15 +90,13 @@ static void TimerAnswer(HANDLE hContact, const TalkBot::MessageInfo* info) bufsize *= sizeof(TCHAR) + 1;
msg = new char[bufsize];
- //msg[size - 1] = '\0';
if (!WideCharToMultiByte(CP_ACP, 0, info->Answer.c_str(), -1, msg, size,
NULL, NULL))
FillMemory(msg, size - 1, '-'); //In case of fault return "----" in ANSI part
CopyMemory(msg + size, info->Answer.c_str(), size * 2);
-
- CallContactService(hContact, MsgServiceName(hContact), PREF_TCHAR, (LPARAM)msg);
+ CallContactService(hContact, PSS_MESSAGE, PREF_TCHAR, (LPARAM)msg);
ZeroMemory(&ldbei, sizeof(ldbei));
ldbei.cbSize = sizeof(ldbei);
diff --git a/plugins/CyrTranslit/src/TransliterationProtocol.cpp b/plugins/CyrTranslit/src/TransliterationProtocol.cpp index ecb650571f..dc75e17dbf 100644 --- a/plugins/CyrTranslit/src/TransliterationProtocol.cpp +++ b/plugins/CyrTranslit/src/TransliterationProtocol.cpp @@ -33,8 +33,7 @@ void TransliterationProtocol::initialize() pd.type = PROTOTYPE_TRANSLATION;
CallService(MS_PROTO_REGISTERMODULE, 0, reinterpret_cast<LPARAM>(&pd));
- CreateProtoServiceFunction(MODULE_NAME, PSS_MESSAGE, sendMessageA);
- CreateProtoServiceFunction(MODULE_NAME, PSS_MESSAGE"W", sendMessageW);
+ CreateProtoServiceFunction(MODULE_NAME, PSS_MESSAGE, sendMessage);
}
//------------------------------------------------------------------------------
@@ -90,26 +89,9 @@ void TransliterationProtocol::TranslateMessageA(WPARAM wParam, LPARAM lParam) strcpy(reinterpret_cast<char*>(ccs->lParam), txt.c_str());
}
-INT_PTR TransliterationProtocol::sendMessageW(WPARAM wParam, LPARAM lParam)
-{
- CCSDATA *ccs = reinterpret_cast<CCSDATA*>(lParam);
- if ( !MirandaContact::bIsActive(ccs->hContact))
- return CallService(MS_PROTO_CHAINSEND, wParam, lParam);
-
- LPARAM oldlParam = ccs->lParam;
-
- TranslateMessageW(wParam, lParam);
-
- int ret = CallService(MS_PROTO_CHAINSEND /* "W" */, wParam, lParam);
-
- mir_free(reinterpret_cast<void*>(ccs->lParam));
- ccs->lParam = oldlParam;
-
- return ret;
-}
//------------------------------------------------------------------------------
-INT_PTR TransliterationProtocol::sendMessageA(WPARAM wParam, LPARAM lParam)
+INT_PTR TransliterationProtocol::sendMessage(WPARAM wParam, LPARAM lParam)
{
CCSDATA *ccs = reinterpret_cast<CCSDATA*>(lParam);
if ( !MirandaContact::bIsActive(ccs->hContact))
diff --git a/plugins/CyrTranslit/src/TransliterationProtocol.h b/plugins/CyrTranslit/src/TransliterationProtocol.h index 30c890d971..2f746a64b8 100644 --- a/plugins/CyrTranslit/src/TransliterationProtocol.h +++ b/plugins/CyrTranslit/src/TransliterationProtocol.h @@ -44,8 +44,7 @@ public: * @param lParam (LPARAM)(const char*)szMessage
* @return a hProcess corresponding to the one in the ack event.
*/
- static INT_PTR sendMessageA(WPARAM wParam, LPARAM lParam);
- static INT_PTR sendMessageW(WPARAM wParam, LPARAM lParam);
+ static INT_PTR sendMessage(WPARAM wParam, LPARAM lParam);
static void TranslateMessageA(WPARAM wParam, LPARAM lParam);
static void TranslateMessageW(WPARAM wParam, LPARAM lParam);
diff --git a/plugins/MetaContacts/src/meta_services.cpp b/plugins/MetaContacts/src/meta_services.cpp index 70ed20c633..db338c5477 100755 --- a/plugins/MetaContacts/src/meta_services.cpp +++ b/plugins/MetaContacts/src/meta_services.cpp @@ -294,7 +294,6 @@ INT_PTR Meta_SendMessage(WPARAM wParam,LPARAM lParam) return CallService(MS_PROTO_CHAINSEND, wParam, lParam);
}
- char szServiceName[100];
HANDLE most_online = Meta_GetMostOnline(ccs->hContact);
if ( !most_online) {
@@ -324,15 +323,6 @@ INT_PTR Meta_SendMessage(WPARAM wParam,LPARAM lParam) Meta_SetNick(proto); // (no matter what was there before)
// don't bypass filters etc
- strncpy(szServiceName, PSS_MESSAGE, sizeof(szServiceName));
-
- if (ccs->wParam & PREF_UNICODE) {
- char szTemp[100];
- _snprintf(szTemp, sizeof(szTemp), "%s%sW", proto, PSS_MESSAGE);
- if (ServiceExists(szTemp))
- strncpy(szServiceName, PSS_MESSAGE "W", sizeof(szServiceName));
- }
-
if (options.subhistory && !(ccs->wParam & PREF_METANODB)) {
// add sent event to subcontact
DBEVENTINFO dbei = { sizeof(dbei) };
@@ -354,7 +344,7 @@ INT_PTR Meta_SendMessage(WPARAM wParam,LPARAM lParam) // prevent send filter from adding another copy of this send event to the db
ccs->wParam |= PREF_METANODB;
- return CallContactService(ccs->hContact, szServiceName, ccs->wParam, ccs->lParam);
+ return CallContactService(ccs->hContact, PSS_MESSAGE, ccs->wParam, ccs->lParam);
}
/** Transmit a message received by a contact.
@@ -1464,7 +1454,6 @@ void Meta_InitServices() CreateProtoServiceFunction(META_PROTO, PS_GETSTATUS, Meta_GetStatus);
CreateProtoServiceFunction(META_PROTO, PSS_MESSAGE, Meta_SendMessage);
- CreateProtoServiceFunction(META_PROTO, PSS_MESSAGE"W", Meta_SendMessage); // unicode send (same send func as above line, checks for PREF_UNICODE)
CreateProtoServiceFunction(META_PROTO, PSS_USERISTYPING, Meta_UserIsTyping );
@@ -1481,7 +1470,6 @@ void Meta_InitServices() CreateProtoServiceFunction(META_FILTER, PSR_MESSAGE, MetaFilter_RecvMessage);
CreateProtoServiceFunction(META_FILTER, PSS_MESSAGE, MetaFilter_SendMessage);
- CreateProtoServiceFunction(META_FILTER, PSS_MESSAGE"W", MetaFilter_SendMessage);
// API services and events
CreateServiceFunction(MS_MC_GETMETACONTACT, MetaAPI_GetMeta);
diff --git a/plugins/MirOTR/MirOTR/src/dllmain.cpp b/plugins/MirOTR/MirOTR/src/dllmain.cpp index f8eb373fec..c17b1b6b76 100644 --- a/plugins/MirOTR/MirOTR/src/dllmain.cpp +++ b/plugins/MirOTR/MirOTR/src/dllmain.cpp @@ -95,10 +95,8 @@ extern "C" __declspec(dllexport) int Load(void) // create our services
CreateProtoServiceFunction(MODULENAME, PSS_MESSAGE, SVC_OTRSendMessage);
- CreateProtoServiceFunction(MODULENAME, PSS_MESSAGE"W", SVC_OTRSendMessageW);
CreateProtoServiceFunction(MODULENAME, PSR_MESSAGE, SVC_OTRRecvMessage);
-
// hook modules loaded for updater support
HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
diff --git a/plugins/MirOTR/MirOTR/src/otr.cpp b/plugins/MirOTR/MirOTR/src/otr.cpp index c7f37b9ac6..e22f7adb18 100644 --- a/plugins/MirOTR/MirOTR/src/otr.cpp +++ b/plugins/MirOTR/MirOTR/src/otr.cpp @@ -141,17 +141,8 @@ extern "C" { //MessageBox(0, message, "OTR Inject", MB_OK);
HANDLE hContact = (HANDLE)opdata;
- if(protocol && db_get_w(hContact, protocol, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) {
- /* this would be with translation
- TCHAR *decode = mir_utf8decodeT(message);
- TCHAR *encode = mir_utf8encodeT(TranslateT(decide));
- mir_free(decode);
- CallContactService(hContact, PSS_MESSAGE, PREF_UTF|PREF_BYPASS_OTR, (LPARAM)encode);
- mir_free(encode);
- */
+ if(protocol && db_get_w(hContact, protocol, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE)
CallContactService(hContact, PSS_MESSAGE, PREF_UTF|PREF_BYPASS_OTR, (LPARAM)message);
- //DEBUGOUT_T("INJECT")
- }
}
/* Display a notification message for a particular accountname /
diff --git a/plugins/MirOTR/MirOTR/src/svcs_proto.cpp b/plugins/MirOTR/MirOTR/src/svcs_proto.cpp index ed7b16bd96..2f814087e2 100644 --- a/plugins/MirOTR/MirOTR/src/svcs_proto.cpp +++ b/plugins/MirOTR/MirOTR/src/svcs_proto.cpp @@ -124,15 +124,6 @@ INT_PTR SVC_OTRSendMessage(WPARAM wParam,LPARAM lParam){ return CallService(MS_PROTO_CHAINSEND, wParam, lParam);
}
-INT_PTR SVC_OTRSendMessageW(WPARAM wParam, LPARAM lParam){
- if (!lParam) return 0;
-
- CCSDATA *ccs = (CCSDATA *) lParam;
- if (!(ccs->wParam & PREF_UTF)) ccs->wParam |= PREF_UNICODE;
-
- return SVC_OTRSendMessage(wParam, lParam);
-}
-
/*
#define MESSAGE_PREFIX "(OTR) "
#define MESSAGE_PREFIXW L"(OTR) "
diff --git a/plugins/MirOTR/MirOTR/src/svcs_proto.h b/plugins/MirOTR/MirOTR/src/svcs_proto.h index fe0db53a4e..a260560cc6 100644 --- a/plugins/MirOTR/MirOTR/src/svcs_proto.h +++ b/plugins/MirOTR/MirOTR/src/svcs_proto.h @@ -1,7 +1,6 @@ #pragma once
INT_PTR SVC_OTRSendMessage(WPARAM wParam,LPARAM lParam);
-INT_PTR SVC_OTRSendMessageW(WPARAM wParam, LPARAM lParam);
INT_PTR SVC_OTRRecvMessage(WPARAM wParam,LPARAM lParam);
void otr_abort_smp(ConnContext *context);
diff --git a/plugins/New_GPG/src/init.cpp b/plugins/New_GPG/src/init.cpp index cff2d14573..0729b277f4 100755 --- a/plugins/New_GPG/src/init.cpp +++ b/plugins/New_GPG/src/init.cpp @@ -164,13 +164,9 @@ static int OnModulesLoaded(WPARAM wParam,LPARAM lParam) pd.type = PROTOTYPE_ENCRYPTION;
CallService(MS_PROTO_REGISTERMODULE,0,(LPARAM)&pd);
- CreateProtoServiceFunction(szGPGModuleName, PSR_MESSAGE, (MIRANDASERVICE)RecvMsgSvc);
- CreateProtoServiceFunction(szGPGModuleName, PSS_MESSAGE, (MIRANDASERVICE)SendMsgSvc);
- CreateProtoServiceFunction(szGPGModuleName, PSR_MESSAGE"W", (MIRANDASERVICE)RecvMsgSvc);
- CreateProtoServiceFunction(szGPGModuleName, PSS_MESSAGE"W", (MIRANDASERVICE)SendMsgSvc);
-
- CreateProtoServiceFunction(szGPGModuleName, PSS_FILE, (MIRANDASERVICE)onSendFile);
- CreateProtoServiceFunction(szGPGModuleName, PSS_FILE"W", (MIRANDASERVICE)onSendFile);
+ CreateProtoServiceFunction(szGPGModuleName, PSR_MESSAGE, RecvMsgSvc);
+ CreateProtoServiceFunction(szGPGModuleName, PSS_MESSAGE, SendMsgSvc);
+ CreateProtoServiceFunction(szGPGModuleName, PSS_FILE, onSendFile);
clean_temp_dir();
return 0;
}
diff --git a/plugins/New_GPG/src/messages.cpp b/plugins/New_GPG/src/messages.cpp index 7ad33d4cc6..dc870d9f37 100755 --- a/plugins/New_GPG/src/messages.cpp +++ b/plugins/New_GPG/src/messages.cpp @@ -185,7 +185,7 @@ void RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, { BYTE enc = db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0); db_set_b(hContact, szGPGModuleName, "GPGEncryption", 0); - CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)"Unable to decrypt PGP encrypted message"); + CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)"Unable to decrypt PGP encrypted message"); HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT)); db_set_b(hContact, szGPGModuleName, "GPGEncryption", enc); break; @@ -223,7 +223,7 @@ void RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); BYTE enc = db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0); db_set_b(hContact, szGPGModuleName, "GPGEncryption", 0); - CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)"Unable to decrypt PGP encrypted message"); + CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)"Unable to decrypt PGP encrypted message"); HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT)); db_set_b(hContact, szGPGModuleName, "GPGEncryption", enc); return; @@ -242,7 +242,7 @@ void RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); BYTE enc = db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0); db_set_b(hContact, szGPGModuleName, "GPGEncryption", 0); - CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)"Unable to decrypt PGP encrypted message"); + CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)"Unable to decrypt PGP encrypted message"); HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT)); db_set_b(hContact, szGPGModuleName, "GPGEncryption", enc); return; @@ -273,7 +273,7 @@ void RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); BYTE enc = db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0); db_set_b(hContact, szGPGModuleName, "GPGEncryption", 0); - CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)"Unable to decrypt PGP encrypted message"); + CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)"Unable to decrypt PGP encrypted message"); HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT)); db_set_b(hContact, szGPGModuleName, "GPGEncryption", enc); mir_free(tmp); @@ -310,7 +310,7 @@ void RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); BYTE enc = db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0); db_set_b(hContact, szGPGModuleName, "GPGEncryption", 0); - CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)"Unable to decrypt PGP encrypted message"); + CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)"Unable to decrypt PGP encrypted message"); HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT)); db_set_b(hContact, szGPGModuleName, "GPGEncryption", enc); mir_free(tmp); @@ -546,7 +546,7 @@ int RecvMsgSvc(WPARAM w, LPARAM l) db_set_b(ccs->hContact, szGPGModuleName, "GPGEncryption", 0); string str = "-----PGP KEY RESPONSE-----"; str.append(tmp); - CallContactService(ccs->hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)str.c_str()); + CallContactService(ccs->hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)str.c_str()); if(enc_state) db_set_b(ccs->hContact, szGPGModuleName, "GPGEncryption", 1); } @@ -567,7 +567,7 @@ int RecvMsgSvc(WPARAM w, LPARAM l) strcpy(cap.caps, "GPG AutoExchange"); if(CallService(svc, (WPARAM)ccs->hContact, (LPARAM)&cap)) { - CallContactService(ccs->hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)"-----PGP KEY REQUEST-----"); + CallContactService(ccs->hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)"-----PGP KEY REQUEST-----"); return 0; } } @@ -636,7 +636,7 @@ void SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) HistoryLog(hContact, db_event("Failed to encrypt message with GPG (not found key for encryption in db)", 0,0, DBEF_SENT)); // hcontact_data[hContact].msgs_to_pass.push_back("Failed to encrypt message with GPG (not found key for encryption in db)"); //mir_free(msg); - CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); + CallContactService(hContact, PSS_MESSAGE, flags, (LPARAM)msg); return; } if(!bJabberAPI || !bIsMiranda09) //force jabber to handle encrypted message by itself @@ -682,13 +682,13 @@ void SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) if(!gpg_launcher(params)) { //mir_free(msg); - CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); + CallContactService(hContact, PSS_MESSAGE, flags, (LPARAM)msg); return; } if(result == pxNotFound) { //mir_free(msg); - CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); + CallContactService(hContact, PSS_MESSAGE, flags, (LPARAM)msg); return; } if(out.find("There is no assurance this key belongs to the named user") != string::npos) @@ -709,13 +709,13 @@ void SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) if(!gpg_launcher(params)) { //mir_free(msg); - CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); + CallContactService(hContact, PSS_MESSAGE, flags, (LPARAM)msg); return; } if(result == pxNotFound) { //mir_free(msg); - CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); + CallContactService(hContact, PSS_MESSAGE, flags, (LPARAM)msg); return; } //TODO: check gpg output for errors @@ -737,7 +737,7 @@ void SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) { MessageBox(0, TranslateT("Something wrong, gpg does not understand us, aborting encryption."), TranslateT("Warning"), MB_OK); //mir_free(msg); - CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); + CallContactService(hContact, PSS_MESSAGE, flags, (LPARAM)msg); boost::filesystem::remove(path); return; } @@ -769,7 +769,7 @@ void SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) if(bDebugLog) debuglog<<std::string(time_str()+": info: Failed to encrypt message with GPG"); //mir_free(msg); - CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); + CallContactService(hContact, PSS_MESSAGE, flags, (LPARAM)msg); return; } string str_event = msg; @@ -795,7 +795,7 @@ void SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) if(!(flags & PREF_UTF)) flags |= PREF_UTF; fix_line_term(str); - sent_msgs.push_back((HANDLE)CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)toUTF8(str).c_str())); + sent_msgs.push_back((HANDLE)CallContactService(hContact, PSS_MESSAGE, flags, (LPARAM)toUTF8(str).c_str())); //mir_free(msg); return; } @@ -979,7 +979,7 @@ int HookSendMsg(WPARAM w, LPARAM l) { if(bDebugLog) debuglog<<std::string(time_str()+": info(autoexchange, icq): sending key requiest, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR))); - CallContactService(hContact, PSS_MESSAGE, (WPARAM)((dbei->flags & DBEF_UTF) == DBEF_UTF)?PREF_UTF:0, (LPARAM)"-----PGP KEY REQUEST-----"); + CallContactService(hContact, PSS_MESSAGE, (dbei->flags & DBEF_UTF) ? PREF_UTF : 0, (LPARAM)"-----PGP KEY REQUEST-----"); hcontact_data[hContact].msgs_to_send.push_back((char*)dbei->pBlob); boost::thread *thr = new boost::thread(boost::bind(send_encrypted_msgs_thread, hContact)); //TODO: wait for message @@ -1014,7 +1014,7 @@ int HookSendMsg(WPARAM w, LPARAM l) { if(bDebugLog) debuglog<<std::string(time_str()+": info(autoexchange, jabber): autoexchange capability found, sending key request, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR))); - CallContactService(hContact, PSS_MESSAGE, (WPARAM)((dbei->flags & DBEF_UTF) == DBEF_UTF)?PREF_UTF:0, (LPARAM)"-----PGP KEY REQUEST-----"); + CallContactService(hContact, PSS_MESSAGE, (dbei->flags & DBEF_UTF) ? PREF_UTF : 0, (LPARAM)"-----PGP KEY REQUEST-----"); hcontact_data[hContact].msgs_to_send.push_back((char*)dbei->pBlob); boost::thread *thr = new boost::thread(boost::bind(send_encrypted_msgs_thread, hContact)); mir_free((char*)dbei->pBlob); diff --git a/plugins/New_GPG/src/utilities.cpp b/plugins/New_GPG/src/utilities.cpp index aa43bb7a50..7d3e92d915 100755 --- a/plugins/New_GPG/src/utilities.cpp +++ b/plugins/New_GPG/src/utilities.cpp @@ -171,7 +171,7 @@ INT_PTR SendKey(WPARAM w, LPARAM l) {
BYTE enc = db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0);
db_set_b(hContact, szGPGModuleName, "GPGEncryption", 0);
- CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)szMessage);
+ CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)szMessage);
std::string msg = "Public key ";
char *keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, key_id_str.c_str(), "");
if(!keyid[0])
@@ -1332,7 +1332,7 @@ void send_encrypted_msgs_thread(HANDLE hContact) extern std::list<HANDLE> sent_msgs;
for(list<string>::iterator p = hcontact_data[hContact].msgs_to_send.begin(); p != end; ++p)
{
- sent_msgs.push_back((HANDLE)CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)p->c_str()));
+ sent_msgs.push_back((HANDLE)CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)p->c_str()));
HistoryLog(hContact, db_event((char*)p->c_str(),0,0, DBEF_SENT));
boost::this_thread::sleep(boost::posix_time::seconds(1));
}
diff --git a/plugins/Popup/src/popup_wnd2.cpp b/plugins/Popup/src/popup_wnd2.cpp index 7a7782602e..6f2ae05cdd 100644 --- a/plugins/Popup/src/popup_wnd2.cpp +++ b/plugins/Popup/src/popup_wnd2.cpp @@ -943,17 +943,6 @@ struct ReplyEditData WNDPROC oldWndProc;
};
-bool IsMsgServiceNameW(HANDLE hContact)
-{
- char szServiceName[100];
- char *szProto = GetContactProto(hContact);
- if (szProto == NULL)
- return false;
-
- mir_snprintf(szServiceName, sizeof(szServiceName), "%s%sW", szProto, PSS_MESSAGE);
- return ServiceExists(szServiceName) != 0;
-}
-
BOOL IsUtfSendAvailable(HANDLE hContact)
{
char* szProto = GetContactProto(hContact);
@@ -988,101 +977,76 @@ LRESULT CALLBACK ReplyEditWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM ReplyEditData *dat = (ReplyEditData *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
WNDPROC oldWndProc = dat ? dat->oldWndProc : NULL;
- switch (message)
- {
-/*
- case WM_ERASEBKGND:
- {
- HDC hdc = (HDC)wParam;
- RECT rc; GetClientRect(hwnd, &rc);
- FillRect(hdc, &rc, GetSysColorBrush(COLOR_WINDOW));
- SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT));
- DrawText(hdc, "Quick Reply", -1, &rc, DT_BOTTOM|DT_RIGHT|DT_SINGLELINE);
- return TRUE;
- }
-*/
- case WM_KEYDOWN:
- {
- switch (wParam)
+ switch (message) {
+ case WM_KEYDOWN:
+ switch (wParam) {
+ case VK_RETURN:
{
- case VK_RETURN:
- {
- char *buf = NULL;
- int flag = 0;
- bool bSendW = IsMsgServiceNameW(dat->hContact);
- //if (g_popup.isMirUnicode)
- if (IsWindowUnicode(hwnd))
- {
- WCHAR msg[2048];
- LPWSTR bufW = NULL;
+ char *buf = NULL;
+ int flag = 0;
+ if (IsWindowUnicode(hwnd)) {
+ WCHAR msg[2048];
+ LPWSTR bufW = NULL;
- SendMessageW(hwnd, WM_GETTEXT, SIZEOF(msg), (LPARAM)msg);
+ SendMessageW(hwnd, WM_GETTEXT, SIZEOF(msg), (LPARAM)msg);
- if (wcslen(msg)==0){
- DestroyWindow(hwnd);
- return 0;
- }
- // we have unicode message, check if it is possible and reasonable to send it as unicode
- if (IsUtfSendAvailable(dat->hContact)) {
- buf = mir_utf8encodeW(msg);
- flag = PREF_UTF;
- }
- else if (bSendW){
- bufW = mir_wstrdup(msg) /*mir_tstrdup(msg)*/;
- buf = (char*)bufW;
- flag = PREF_UNICODE /*PREF_TCHAR*/;
- }
- else {
- buf = mir_u2a(msg);
- flag = 0;
- }
+ if (wcslen(msg)==0){
+ DestroyWindow(hwnd);
+ return 0;
+ }
+ // we have unicode message, check if it is possible and reasonable to send it as unicode
+ if (IsUtfSendAvailable(dat->hContact)) {
+ buf = mir_utf8encodeW(msg);
+ flag = PREF_UTF;
}
else {
- char msg[2048];
- GetWindowTextA(hwnd, msg, SIZEOF(msg));
- if (strlen(msg)==0){
- DestroyWindow(hwnd);
- return 0;
- }
- // we have message, check if it is possible and reasonable to send it as unicode
- if ( IsUtfSendAvailable( dat->hContact )) {
- buf = mir_utf8encode(msg);
- flag = PREF_UTF;
- }
- else {
- buf = mir_strdup(msg) /*mir_tstrdup(msg)*/;
- flag = 0 /*PREF_TCHAR*/;
- }
+ buf = mir_u2a(msg);
+ flag = 0;
}
-
- CallContactService(dat->hContact, bSendW ? (PSS_MESSAGE"W"):PSS_MESSAGE, flag, (LPARAM)buf);
- AddMessageToDB(dat->hContact, buf, flag);
- mir_free(buf);
-
- DestroyWindow(hwnd);
- return 0;
}
- case VK_ESCAPE:
- {
- DestroyWindow(hwnd);
- return 0;
+ else {
+ char msg[2048];
+ GetWindowTextA(hwnd, msg, SIZEOF(msg));
+ if (strlen(msg)==0){
+ DestroyWindow(hwnd);
+ return 0;
+ }
+ // we have message, check if it is possible and reasonable to send it as unicode
+ if ( IsUtfSendAvailable( dat->hContact )) {
+ buf = mir_utf8encode(msg);
+ flag = PREF_UTF;
+ }
+ else {
+ buf = mir_strdup(msg) /*mir_tstrdup(msg)*/;
+ flag = 0 /*PREF_TCHAR*/;
+ }
}
+
+ CallContactService(dat->hContact, PSS_MESSAGE, flag, (LPARAM)buf);
+ AddMessageToDB(dat->hContact, buf, flag);
+ mir_free(buf);
}
- break;
+ DestroyWindow(hwnd);
+ return 0;
+
+ case VK_ESCAPE:
+ DestroyWindow(hwnd);
+ return 0;
}
+ break;
- case WM_ACTIVATE:
- if (wParam == WA_INACTIVE)
- DestroyWindow(hwnd);
- break;
+ case WM_ACTIVATE:
+ if (wParam == WA_INACTIVE)
+ DestroyWindow(hwnd);
+ break;
- case WM_DESTROY:
- PopupThreadUnlock();
- if (!(PopUpOptions.actions&ACT_DEF_KEEPWND))
- PUDeletePopUp(dat->hwndPopup);
- SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)dat->oldWndProc);
- SetWindowLongPtr(hwnd, GWLP_USERDATA, 0);
- mir_free(dat);
+ case WM_DESTROY:
+ PopupThreadUnlock();
+ if (!(PopUpOptions.actions&ACT_DEF_KEEPWND))
+ PUDeletePopUp(dat->hwndPopup);
+ SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)dat->oldWndProc);
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, 0);
+ mir_free(dat);
}
if (oldWndProc)
diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index 0149cbd1a5..084a91145f 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -1579,13 +1579,12 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP item->flags = msi->flags;
item->codepage = dat->windowData.codePage;
if ( IsUtfSendAvailable( dat->windowData.hContact )) {
- char* szMsgUtf;
- szMsgUtf = mir_utf8encodeW( (TCHAR *)&msi->sendBuffer[strlen(msi->sendBuffer) + 1] );
+ char *szMsgUtf = mir_utf8encodeW( (TCHAR *)&msi->sendBuffer[strlen(msi->sendBuffer) + 1] );
item->flags &= ~PREF_UNICODE;
if (!szMsgUtf) {
break;
}
- if (*szMsgUtf == 0) {
+ if (*szMsgUtf == 0) {
mir_free(szMsgUtf);
break;
}
@@ -1726,24 +1725,23 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP break;
if (dat->windowData.hContact != NULL) {
- GETTEXTEX gt = {0};
- PARAFORMAT2 pf2;
- MessageSendQueueItem msi = { 0 };
- int bufSize;
int ansiBufSize = GetRichTextLength(GetDlgItem(hwndDlg, IDC_MESSAGE), dat->windowData.codePage, TRUE) + 1;
- bufSize = ansiBufSize;
+ int bufSize = ansiBufSize + GetRichTextLength(GetDlgItem(hwndDlg, IDC_MESSAGE), 1200, TRUE) + 2;
+
+ PARAFORMAT2 pf2;
ZeroMemory((void *)&pf2, sizeof(pf2));
pf2.cbSize = sizeof(pf2);
pf2.dwMask = PFM_RTLPARA;
SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_GETPARAFORMAT, 0, (LPARAM)&pf2);
+
+ MessageSendQueueItem msi = { 0 };
+ msi.flags = PREF_TCHAR;
if (pf2.wEffects & PFE_RTLPARA)
msi.flags |= PREF_RTL;
- bufSize += GetRichTextLength(GetDlgItem(hwndDlg, IDC_MESSAGE), 1200, TRUE) + 2;
-
msi.sendBufferSize = bufSize;
msi.sendBuffer = (char *) mir_alloc(msi.sendBufferSize);
- msi.flags |= PREF_TCHAR;
+ GETTEXTEX gt = {0};
gt.flags = GT_USECRLF;
gt.cb = ansiBufSize;
gt.codepage = dat->windowData.codePage;
@@ -1758,20 +1756,20 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP mir_free (msi.sendBuffer);
break;
}
- {
- /* Store messaging history */
- char *msgText = GetRichTextEncoded(GetDlgItem(hwndDlg, IDC_MESSAGE), dat->windowData.codePage);
- TCmdList *cmdListNew = tcmdlist_last(dat->windowData.cmdList);
- while (cmdListNew != NULL && cmdListNew->temporary) {
- dat->windowData.cmdList = tcmdlist_remove(dat->windowData.cmdList, cmdListNew);
- cmdListNew = tcmdlist_last(dat->windowData.cmdList);
- }
- if (msgText != NULL) {
- dat->windowData.cmdList = tcmdlist_append(dat->windowData.cmdList, msgText, 20, FALSE);
- mir_free(msgText);
- }
- dat->windowData.cmdListCurrent = NULL;
+
+ /* Store messaging history */
+ char *msgText = GetRichTextEncoded(GetDlgItem(hwndDlg, IDC_MESSAGE), dat->windowData.codePage);
+ TCmdList *cmdListNew = tcmdlist_last(dat->windowData.cmdList);
+ while (cmdListNew != NULL && cmdListNew->temporary) {
+ dat->windowData.cmdList = tcmdlist_remove(dat->windowData.cmdList, cmdListNew);
+ cmdListNew = tcmdlist_last(dat->windowData.cmdList);
}
+ if (msgText != NULL) {
+ dat->windowData.cmdList = tcmdlist_append(dat->windowData.cmdList, msgText, 20, FALSE);
+ mir_free(msgText);
+ }
+ dat->windowData.cmdListCurrent = NULL;
+
if (dat->nTypeMode == PROTOTYPE_SELFTYPING_ON)
NotifyTyping(dat, PROTOTYPE_SELFTYPING_OFF);
diff --git a/plugins/Scriver/src/sendqueue.cpp b/plugins/Scriver/src/sendqueue.cpp index fda0384591..0022478912 100644 --- a/plugins/Scriver/src/sendqueue.cpp +++ b/plugins/Scriver/src/sendqueue.cpp @@ -25,44 +25,34 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static MessageSendQueueItem *global_sendQueue = NULL;
static CRITICAL_SECTION queueMutex;
-static char *MsgServiceName(HANDLE hContact)
-{
-
- char szServiceName[100];
- char *szProto = GetContactProto(hContact);
- if (szProto == NULL)
- return PSS_MESSAGE;
-
- mir_snprintf(szServiceName, sizeof(szServiceName), "%s%sW", szProto, PSS_MESSAGE);
- if (ServiceExists(szServiceName))
- return PSS_MESSAGE "W";
-
- return PSS_MESSAGE;
-}
-TCHAR * GetSendBufferMsg(MessageSendQueueItem *item) {
- TCHAR *szMsg = NULL;
- size_t len = strlen(item->sendBuffer);
-
- if (item->flags & PREF_UTF) {
- szMsg = mir_utf8decodeW(item->sendBuffer);
- } else {
- szMsg = (TCHAR *)mir_alloc(item->sendBufferSize - len - 1);
- memcpy(szMsg, item->sendBuffer + len + 1, item->sendBufferSize - len - 1);
- }
+TCHAR * GetSendBufferMsg(MessageSendQueueItem *item)
+{
+ TCHAR *szMsg = NULL;
+ size_t len = strlen(item->sendBuffer);
+
+ if (item->flags & PREF_UTF)
+ szMsg = mir_utf8decodeW(item->sendBuffer);
+ else {
+ szMsg = (TCHAR *)mir_alloc(item->sendBufferSize - len - 1);
+ memcpy(szMsg, item->sendBuffer + len + 1, item->sendBufferSize - len - 1);
+ }
- return szMsg;
+ return szMsg;
}
-void InitSendQueue() {
+void InitSendQueue()
+{
InitializeCriticalSection(&queueMutex);
}
-void DestroySendQueue() {
+void DestroySendQueue()
+{
DeleteCriticalSection(&queueMutex);
}
-MessageSendQueueItem* CreateSendQueueItem(HWND hwndSender) {
+MessageSendQueueItem* CreateSendQueueItem(HWND hwndSender)
+{
MessageSendQueueItem *item = (MessageSendQueueItem *) mir_alloc(sizeof(MessageSendQueueItem));
EnterCriticalSection(&queueMutex);
ZeroMemory(item, sizeof(MessageSendQueueItem));
@@ -76,7 +66,8 @@ MessageSendQueueItem* CreateSendQueueItem(HWND hwndSender) { return item;
}
-MessageSendQueueItem* FindOldestPendingSendQueueItem(HWND hwndSender, HANDLE hContact) {
+MessageSendQueueItem* FindOldestPendingSendQueueItem(HWND hwndSender, HANDLE hContact)
+{
MessageSendQueueItem *item, *found = NULL;
EnterCriticalSection(&queueMutex);
for (item = global_sendQueue; item != NULL; item = item->next) {
@@ -88,54 +79,49 @@ MessageSendQueueItem* FindOldestPendingSendQueueItem(HWND hwndSender, HANDLE hCo return found;
}
-MessageSendQueueItem* FindSendQueueItem(HANDLE hContact, HANDLE hSendId) {
- MessageSendQueueItem *item;
- EnterCriticalSection(&queueMutex);
- for (item = global_sendQueue; item != NULL; item = item->next) {
- if (item->hContact == hContact && item->hSendId == hSendId) {
- break;
- }
- }
- LeaveCriticalSection(&queueMutex);
- return item;
+MessageSendQueueItem* FindSendQueueItem(HANDLE hContact, HANDLE hSendId)
+{
+ mir_cslock lock(queueMutex);
+ for (MessageSendQueueItem *item = global_sendQueue; item != NULL; item = item->next)
+ if (item->hContact == hContact && item->hSendId == hSendId)
+ return item;
+
+ return NULL;
}
-BOOL RemoveSendQueueItem(MessageSendQueueItem* item) {
- BOOL result = TRUE;
+BOOL RemoveSendQueueItem(MessageSendQueueItem* item)
+{
HWND hwndSender = item->hwndSender;
-// logInfo(" removing [%s] next: [%s] prev: [%s]", item->sendBuffer, item->next != NULL ? item->next->sendBuffer : "", item->prev != NULL ? item->prev->sendBuffer : "");
- EnterCriticalSection(&queueMutex);
- if (item->prev != NULL) {
+
+ mir_cslock lock(queueMutex);
+ if (item->prev != NULL)
item->prev->next = item->next;
- } else {
+ else
global_sendQueue = item->next;
- }
- if (item->next != NULL) {
+
+ if (item->next != NULL)
item->next->prev = item->prev;
- }
- if (item->sendBuffer) {
- mir_free(item->sendBuffer);
- }
- if (item->proto) {
- mir_free(item->proto);
- }
+
+ mir_free(item->sendBuffer);
+ mir_free(item->proto);
mir_free(item);
- for (item = global_sendQueue; item != NULL; item = item->next) {
- if (item->hwndSender == hwndSender) {
- result = FALSE;
- }
- }
- LeaveCriticalSection(&queueMutex);
- return result;
+
+ for (item = global_sendQueue; item != NULL; item = item->next)
+ if (item->hwndSender == hwndSender)
+ return FALSE;
+
+ return TRUE;
}
-void ReportSendQueueTimeouts(HWND hwndSender) {
+void ReportSendQueueTimeouts(HWND hwndSender)
+{
MessageSendQueueItem *item, *item2;
int timeout = db_get_dw(NULL, SRMMMOD, SRMSGSET_MSGTIMEOUT, SRMSGDEFSET_MSGTIMEOUT);
- EnterCriticalSection(&queueMutex);
+
+ mir_cslock lock(queueMutex);
+
for (item = global_sendQueue; item != NULL; item = item2) {
item2 = item->next;
-// logInfo(" item in the queue [%s] next: [%s] prev: [%s]", item->sendBuffer, item->next != NULL ? item->next->sendBuffer : "", item->prev != NULL ? item->prev->sendBuffer : "");
if (item->timeout < timeout) {
item->timeout += 1000;
if (item->timeout >= timeout) {
@@ -156,68 +142,67 @@ void ReportSendQueueTimeouts(HWND hwndSender) { }
}
}
- LeaveCriticalSection(&queueMutex);
}
-void ReleaseSendQueueItems(HWND hwndSender) {
- MessageSendQueueItem *item;
- EnterCriticalSection(&queueMutex);
- for (item = global_sendQueue; item != NULL; item = item->next) {
+void ReleaseSendQueueItems(HWND hwndSender)
+{
+ mir_cslock lock(queueMutex);
+
+ for (MessageSendQueueItem *item = global_sendQueue; item != NULL; item = item->next) {
if (item->hwndSender == hwndSender) {
item->hwndSender = NULL;
- if (item->hwndErrorDlg != NULL) {
+ if (item->hwndErrorDlg != NULL)
DestroyWindow(item->hwndErrorDlg);
- }
+
item->hwndErrorDlg = NULL;
}
}
- LeaveCriticalSection(&queueMutex);
}
-int ReattachSendQueueItems(HWND hwndSender, HANDLE hContact) {
+int ReattachSendQueueItems(HWND hwndSender, HANDLE hContact)
+{
int count = 0;
- MessageSendQueueItem *item;
- EnterCriticalSection(&queueMutex);
- for (item = global_sendQueue; item != NULL; item = item->next) {
+
+ mir_cslock lock(queueMutex);
+
+ for (MessageSendQueueItem *item = global_sendQueue; item != NULL; item = item->next) {
if (item->hContact == hContact && item->hwndSender == NULL) {
item->hwndSender = hwndSender;
item->timeout = 0;
count++;
-// logInfo(" reattaching [%s]", item->sendBuffer);
}
}
- LeaveCriticalSection(&queueMutex);
return count;
}
-
-void RemoveAllSendQueueItems() {
+void RemoveAllSendQueueItems()
+{
MessageSendQueueItem *item, *item2;
- EnterCriticalSection(&queueMutex);
+ mir_cslock lock(queueMutex);
for (item = global_sendQueue; item != NULL; item = item2) {
item2 = item->next;
RemoveSendQueueItem(item);
}
- LeaveCriticalSection(&queueMutex);
}
-void SendSendQueueItem(MessageSendQueueItem* item) {
- EnterCriticalSection(&queueMutex);
+void SendSendQueueItem(MessageSendQueueItem* item)
+{
+ mir_cslockfull lock(queueMutex);
item->timeout = 0;
-// logInfo(" sending item [%s] next: [%s] prev: [%s]", item->sendBuffer, item->next != NULL ? item->next->sendBuffer : "", item->prev != NULL ? item->prev->sendBuffer : "");
+
if (item->prev != NULL) {
item->prev->next = item->next;
- if (item->next != NULL) {
+ if (item->next != NULL)
item->next->prev = item->prev;
- }
+
item->next = global_sendQueue;
item->prev = NULL;
- if (global_sendQueue != NULL) {
+ if (global_sendQueue != NULL)
global_sendQueue->prev = item;
- }
+
global_sendQueue = item;
}
-// logInfo(" item sent [%s] next: [%s] prev: [%s]", item->sendBuffer, item->next != NULL ? item->next->sendBuffer : "", item->prev != NULL ? item->prev->sendBuffer : "");
- LeaveCriticalSection(&queueMutex);
- item->hSendId = (HANDLE)CallContactService(item->hContact, MsgServiceName(item->hContact), item->flags, (LPARAM)item->sendBuffer);
+ lock.unlock();
+
+ item->hSendId = (HANDLE)CallContactService(item->hContact, PSS_MESSAGE, item->flags, (LPARAM)item->sendBuffer);
}
diff --git a/plugins/SecureIM/src/main.cpp b/plugins/SecureIM/src/main.cpp index 81c66f45fd..c4c22653af 100644 --- a/plugins/SecureIM/src/main.cpp +++ b/plugins/SecureIM/src/main.cpp @@ -310,7 +310,6 @@ int onModulesLoaded(WPARAM, LPARAM) // hook message transport
CreateProtoServiceFunction(MODULENAME, PSR_MESSAGE, onRecvMsg);
CreateProtoServiceFunction(MODULENAME, PSS_MESSAGE, onSendMsg);
- CreateProtoServiceFunction(MODULENAME, PSS_MESSAGE"W", onSendMsgW);
CreateProtoServiceFunction(MODULENAME, PSS_FILE, onSendFile);
// create a menu item for creating a secure im connection to the user.
diff --git a/plugins/SecureIM/src/svcs_proto.cpp b/plugins/SecureIM/src/svcs_proto.cpp index 9031b88231..21a228b041 100644 --- a/plugins/SecureIM/src/svcs_proto.cpp +++ b/plugins/SecureIM/src/svcs_proto.cpp @@ -475,18 +475,6 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) return ret;
}
-// SendMsgW handler
-INT_PTR __cdecl onSendMsgW(WPARAM wParam, LPARAM lParam)
-{
- if (!lParam) return 0;
-
- CCSDATA *ccs = (CCSDATA*)lParam;
- if (!(ccs->wParam & PREF_UTF))
- ccs->wParam |= PREF_UNICODE;
-
- return onSendMsg(wParam, lParam);
-}
-
// SendMsg handler
INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam)
{
diff --git a/plugins/SecureIM/src/svcs_proto.h b/plugins/SecureIM/src/svcs_proto.h index c2a9506742..8b7aa6e398 100644 --- a/plugins/SecureIM/src/svcs_proto.h +++ b/plugins/SecureIM/src/svcs_proto.h @@ -2,7 +2,6 @@ #define __SVCS_PROTO_H__
INT_PTR __cdecl onRecvMsg(WPARAM,LPARAM);
-INT_PTR __cdecl onSendMsgW(WPARAM,LPARAM);
INT_PTR __cdecl onSendMsg(WPARAM,LPARAM);
INT_PTR __cdecl onSendFile(WPARAM,LPARAM);
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index 29891b4142..96e2477eb1 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -2698,40 +2698,38 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP sendQueue->handleError(dat, iNextFailed);
break;
}
- case MSGERROR_RETRY: {
- int resent = 0;;
-
- if (!(dat->dwFlags & MWF_ERRORSTATE))
- break;
-
- dat->cache->saveHistory(0, 0);
- if (dat->iCurrentQueueError >= 0 && dat->iCurrentQueueError < SendQueue::NR_SENDJOBS) {
- SendJob *job = sendQueue->getJobByIndex(dat->iCurrentQueueError);
-
- if (job->hSendId == 0 && job->hOwner == 0)
- break;
- job->hSendId = (HANDLE) CallContactService(job->hOwner,
- SendQueue::MsgServiceName(job->hOwner, dat, job->dwFlags), (dat->sendMode & SMODE_FORCEANSI) ? (job->dwFlags & ~PREF_UNICODE) : job->dwFlags, (LPARAM)job->sendBuffer);
- resent++;
- }
+ case MSGERROR_RETRY:
+ if (dat->dwFlags & MWF_ERRORSTATE) {
+ int resent = 0;
+
+ dat->cache->saveHistory(0, 0);
+ if (dat->iCurrentQueueError >= 0 && dat->iCurrentQueueError < SendQueue::NR_SENDJOBS) {
+ SendJob *job = sendQueue->getJobByIndex(dat->iCurrentQueueError);
+ if (job->hSendId == 0 && job->hOwner == 0)
+ break;
- if (resent) {
- int iNextFailed;
- SendJob *job = sendQueue->getJobByIndex(dat->iCurrentQueueError);
+ job->hSendId = (HANDLE) CallContactService(job->hOwner, PSS_MESSAGE,
+ (dat->sendMode & SMODE_FORCEANSI) ? (job->dwFlags & ~PREF_UNICODE) : job->dwFlags, (LPARAM)job->sendBuffer);
+ resent++;
+ }
- SetTimer(hwndDlg, TIMERID_MSGSEND + dat->iCurrentQueueError, PluginConfig.m_MsgTimeout, NULL);
- job->iStatus = SendQueue::SQ_INPROGRESS;
- dat->iCurrentQueueError = -1;
- sendQueue->showErrorControls(dat, FALSE);
- SetDlgItemText(hwndDlg, IDC_MESSAGE, _T(""));
- sendQueue->checkQueue(dat);
- if ((iNextFailed = sendQueue->findNextFailed(dat)) >= 0)
- sendQueue->handleError(dat, iNextFailed);
+ if (resent) {
+ int iNextFailed;
+ SendJob *job = sendQueue->getJobByIndex(dat->iCurrentQueueError);
+
+ SetTimer(hwndDlg, TIMERID_MSGSEND + dat->iCurrentQueueError, PluginConfig.m_MsgTimeout, NULL);
+ job->iStatus = SendQueue::SQ_INPROGRESS;
+ dat->iCurrentQueueError = -1;
+ sendQueue->showErrorControls(dat, FALSE);
+ SetDlgItemText(hwndDlg, IDC_MESSAGE, _T(""));
+ sendQueue->checkQueue(dat);
+ if ((iNextFailed = sendQueue->findNextFailed(dat)) >= 0)
+ sendQueue->handleError(dat, iNextFailed);
+ }
}
- }
- break;
}
break;
+
case DM_SELECTTAB:
SendMessage(hwndContainer, DM_SELECTTAB, wParam, lParam); // pass the msg to our container
return 0;
diff --git a/plugins/TabSRMM/src/msglog.cpp b/plugins/TabSRMM/src/msglog.cpp index f8a35f26cd..75784e1987 100644 --- a/plugins/TabSRMM/src/msglog.cpp +++ b/plugins/TabSRMM/src/msglog.cpp @@ -1388,8 +1388,7 @@ void TSAPI StreamInEvents(HWND hwndDlg, HANDLE hDbEventFirst, int count, int fAp if (streamData.dbei != 0)
isSent = (streamData.dbei->flags & DBEF_SENT) != 0;
else {
- DBEVENTINFO dbei = {0};
- dbei.cbSize = sizeof(dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
db_event_get(hDbEventFirst, &dbei);
isSent = (dbei.flags & DBEF_SENT) != 0;
}
diff --git a/plugins/TabSRMM/src/sendlater.cpp b/plugins/TabSRMM/src/sendlater.cpp index 596ce729d3..634f26042e 100644 --- a/plugins/TabSRMM/src/sendlater.cpp +++ b/plugins/TabSRMM/src/sendlater.cpp @@ -33,7 +33,6 @@ CSendLater *sendLater = 0;
-#define U_PREF_UNICODE PREF_UNICODE
/*
* implementation of the CSendLaterJob class
*/
@@ -461,9 +460,7 @@ int CSendLater::sendIt(CSendLaterJob *job) return 0;
}
- dwFlags = IsUtfSendAvailable(hContact) ? PREF_UTF : U_PREF_UNICODE;
-
- char *svcName = SendQueue::MsgServiceName(hContact, 0, dwFlags);
+ dwFlags = IsUtfSendAvailable(hContact) ? PREF_UTF : PREF_UNICODE;
job->lastSent = now;
job->iSendCount++;
@@ -471,9 +468,9 @@ int CSendLater::sendIt(CSendLaterJob *job) job->bCode = CSendLaterJob::JOB_WAITACK;
if (dwFlags & PREF_UTF)
- job->hProcess = (HANDLE)CallContactService(hContact, svcName, dwFlags, (LPARAM)job->sendBuffer);
+ job->hProcess = (HANDLE)CallContactService(hContact, PSS_MESSAGE, dwFlags, (LPARAM)job->sendBuffer);
else
- job->hProcess = (HANDLE)CallContactService(hContact, svcName, dwFlags, (LPARAM)job->pBuf);
+ job->hProcess = (HANDLE)CallContactService(hContact, PSS_MESSAGE, dwFlags, (LPARAM)job->pBuf);
return 0;
}
diff --git a/plugins/TabSRMM/src/sendqueue.cpp b/plugins/TabSRMM/src/sendqueue.cpp index 3f78cf8c32..2713cd1470 100644 --- a/plugins/TabSRMM/src/sendqueue.cpp +++ b/plugins/TabSRMM/src/sendqueue.cpp @@ -34,38 +34,6 @@ SendQueue *sendQueue = 0;
-static char *pss_msg = "/SendMsg";
-static char *pss_msgw = "/SendMsgW";
-
-/**
- * get the service name to send a message
- *
- * @param hContact (HANDLE) contact's handle
- * @param dat _MessageWindowData
- * @param dwFlags
- *
- * @return (char *) name of the service to send a message to this contact
- */
-char *SendQueue::MsgServiceName(const HANDLE hContact = 0, const TWindowData *dat = 0, int dwFlags = 0)
-{
- char szServiceName[100];
- char *szProto = GetContactProto(hContact);
-
- if (szProto == NULL)
- return pss_msg;
-
- if (dat) {
- if (dat->sendMode & SMODE_FORCEANSI || !(dwFlags & PREF_UNICODE))
- return pss_msg;
- }
-
- _snprintf(szServiceName, sizeof(szServiceName), "%s%sW", szProto, PSS_MESSAGE);
- if (ServiceExists(szServiceName))
- return pss_msgw;
-
- return pss_msg;
-}
-
/*
* searches the queue for a message belonging to the given contact which has been marked
* as "failed" by either the ACKRESULT_FAILED or a timeout handler
@@ -169,21 +137,19 @@ entry_found: #define SPLIT_WORD_CUTOFF 20
-static int SendChunkW(WCHAR *chunk, HANDLE hContact, char *szSvc, DWORD dwFlags)
+static int SendChunkW(WCHAR *chunk, HANDLE hContact, DWORD dwFlags)
{
- BYTE *pBuf = NULL;
- int wLen = lstrlenW(chunk), id;
+ int wLen = lstrlenW(chunk);
DWORD memRequired = (wLen + 1) * sizeof(WCHAR);
DWORD codePage = db_get_dw(hContact, SRMSGMOD_T, "ANSIcodepage", CP_ACP);
- int mbcsSize = WideCharToMultiByte(codePage, 0, chunk, -1, (char *)pBuf, 0, 0, 0);
+ int mbcsSize = WideCharToMultiByte(codePage, 0, chunk, -1, NULL, 0, 0, 0);
memRequired += mbcsSize;
- pBuf = (BYTE *)mir_alloc(memRequired);
- WideCharToMultiByte(codePage, 0, chunk, -1, (char *)pBuf, mbcsSize, 0, 0);
- CopyMemory(&pBuf[mbcsSize], chunk, (wLen + 1) * sizeof(WCHAR));
- id = CallContactService(hContact, szSvc, dwFlags, (LPARAM)pBuf);
- mir_free(pBuf);
- return id;
+
+ mir_ptr<char> pBuf((char*)mir_alloc(memRequired));
+ WideCharToMultiByte(codePage, 0, chunk, -1, pBuf, mbcsSize, 0, 0);
+ CopyMemory(&pBuf[mbcsSize], chunk, (wLen+1) * sizeof(WCHAR));
+ return CallContactService(hContact, PSS_MESSAGE, dwFlags, (LPARAM)pBuf);
}
static int SendChunkA(char *chunk, HANDLE hContact, char *szSvc, DWORD dwFlags)
@@ -199,22 +165,11 @@ static void DoSplitSendW(LPVOID param) WCHAR *wszBegin, *wszTemp, *wszSaved, savedChar;
int iLen, iCur = 0, iSavedCur = 0, i;
BOOL fSplitting = TRUE;
- char szServiceName[100], *svcName;
HANDLE hContact = job->hOwner;
DWORD dwFlags = job->dwFlags;
int chunkSize = job->chunkSize / 2;
char *szProto = GetContactProto(hContact);
- if (szProto == NULL)
- svcName = pss_msg;
- else {
- _snprintf(szServiceName, sizeof(szServiceName), "%s%sW", szProto, PSS_MESSAGE);
- if (ServiceExists(szServiceName))
- svcName = pss_msgw;
- else
- svcName = pss_msg;
- }
-
iLen = lstrlenA(job->sendBuffer);
wszBegin = (WCHAR *) & job->sendBuffer[iLen + 1];
wszTemp = (WCHAR *)mir_alloc(sizeof(WCHAR) * (lstrlenW(wszBegin) + 1));
@@ -250,7 +205,7 @@ static void DoSplitSendW(LPVOID param) }
savedChar = *wszSaved;
*wszSaved = 0;
- id = SendChunkW(wszTemp, hContact, svcName, dwFlags);
+ id = SendChunkW(wszTemp, hContact, dwFlags);
if (!fFirstSend) {
job->hSendId = (HANDLE)id;
fFirstSend = TRUE;
@@ -264,7 +219,7 @@ static void DoSplitSendW(LPVOID param) }
}
else {
- id = SendChunkW(wszTemp, hContact, svcName, dwFlags);
+ id = SendChunkW(wszTemp, hContact, dwFlags);
if (!fFirstSend) {
job->hSendId = (HANDLE)id;
fFirstSend = TRUE;
@@ -285,13 +240,10 @@ static void DoSplitSendA(LPVOID param) char *szBegin, *szTemp, *szSaved, savedChar;
int iLen, iCur = 0, iSavedCur = 0, i;
BOOL fSplitting = TRUE;
- char *svcName;
HANDLE hContact = job->hOwner;
DWORD dwFlags = job->dwFlags;
int chunkSize = job->chunkSize;
- svcName = pss_msg;
-
iLen = lstrlenA(job->sendBuffer);
szTemp = (char *)mir_alloc(iLen + 1);
CopyMemory(szTemp, job->sendBuffer, iLen + 1);
@@ -414,82 +366,82 @@ int SendQueue::sendQueued(TWindowData *dat, const int iEntry) sendLater->flushQueue(); // force queue processing
return 0;
}
- else {
- if (dat->hContact == NULL)
- return 0; //never happens
- dat->nMax = dat->cache->getMaxMessageLength(); // refresh length info
+ if (dat->hContact == NULL)
+ return 0; //never happens
- if (dat->sendMode & SMODE_FORCEANSI && M->GetByte(dat->cache->getActiveContact(), dat->cache->getActiveProto(), "UnicodeSend", 1))
- M->WriteByte(dat->cache->getActiveContact(), dat->cache->getActiveProto(), "UnicodeSend", 0);
- else if (!(dat->sendMode & SMODE_FORCEANSI) && !M->GetByte(dat->cache->getActiveContact(), dat->cache->getActiveProto(), "UnicodeSend", 0))
- M->WriteByte(dat->cache->getActiveContact(), dat->cache->getActiveProto(), "UnicodeSend", 1);
+ dat->nMax = dat->cache->getMaxMessageLength(); // refresh length info
- if (M->GetByte("autosplit", 0) && !(dat->sendMode & SMODE_SENDLATER)) {
- BOOL fSplit = FALSE;
- DWORD dwOldFlags;
+ if (dat->sendMode & SMODE_FORCEANSI && M->GetByte(dat->cache->getActiveContact(), dat->cache->getActiveProto(), "UnicodeSend", 1))
+ M->WriteByte(dat->cache->getActiveContact(), dat->cache->getActiveProto(), "UnicodeSend", 0);
+ else if (!(dat->sendMode & SMODE_FORCEANSI) && !M->GetByte(dat->cache->getActiveContact(), dat->cache->getActiveProto(), "UnicodeSend", 0))
+ M->WriteByte(dat->cache->getActiveContact(), dat->cache->getActiveProto(), "UnicodeSend", 1);
- /*
- * determine send buffer length
- */
- if (getSendLength(iEntry, dat->sendMode) >= dat->nMax)
- fSplit = true;
+ if (M->GetByte("autosplit", 0) && !(dat->sendMode & SMODE_SENDLATER)) {
+ BOOL fSplit = FALSE;
+ DWORD dwOldFlags;
- if (!fSplit)
- goto send_unsplitted;
+ /*
+ * determine send buffer length
+ */
+ if (getSendLength(iEntry, dat->sendMode) >= dat->nMax)
+ fSplit = true;
- m_jobs[iEntry].hOwner = dat->hContact;
- m_jobs[iEntry].hwndOwner = hwndDlg;
- m_jobs[iEntry].iStatus = SQ_INPROGRESS;
- m_jobs[iEntry].iAcksNeeded = 1;
- m_jobs[iEntry].chunkSize = dat->nMax;
+ if (!fSplit)
+ goto send_unsplitted;
- dwOldFlags = m_jobs[iEntry].dwFlags;
- if (dat->sendMode & SMODE_FORCEANSI)
- m_jobs[iEntry].dwFlags &= ~PREF_UNICODE;
+ m_jobs[iEntry].hOwner = dat->hContact;
+ m_jobs[iEntry].hwndOwner = hwndDlg;
+ m_jobs[iEntry].iStatus = SQ_INPROGRESS;
+ m_jobs[iEntry].iAcksNeeded = 1;
+ m_jobs[iEntry].chunkSize = dat->nMax;
- if (!(m_jobs[iEntry].dwFlags & PREF_UNICODE) || dat->sendMode & SMODE_FORCEANSI)
- mir_forkthread(DoSplitSendA, (LPVOID)iEntry);
- else
- mir_forkthread(DoSplitSendW, (LPVOID)iEntry);
- m_jobs[iEntry].dwFlags = dwOldFlags;
- }
- else {
+ dwOldFlags = m_jobs[iEntry].dwFlags;
+ if (dat->sendMode & SMODE_FORCEANSI)
+ m_jobs[iEntry].dwFlags &= ~PREF_UNICODE;
+
+ if (!(m_jobs[iEntry].dwFlags & PREF_UNICODE) || dat->sendMode & SMODE_FORCEANSI)
+ mir_forkthread(DoSplitSendA, (LPVOID)iEntry);
+ else
+ mir_forkthread(DoSplitSendW, (LPVOID)iEntry);
+ m_jobs[iEntry].dwFlags = dwOldFlags;
+ }
+ else {
send_unsplitted:
- m_jobs[iEntry].hOwner = dat->hContact;
- m_jobs[iEntry].hwndOwner = hwndDlg;
- m_jobs[iEntry].iStatus = SQ_INPROGRESS;
- m_jobs[iEntry].iAcksNeeded = 1;
- if (dat->sendMode & SMODE_SENDLATER) {
- TCHAR tszError[256];
-
- int iSendLength = getSendLength(iEntry, dat->sendMode);
- if (iSendLength >= dat->nMax) {
- mir_sntprintf(tszError, 256, TranslateT("The message cannot be sent delayed or to multiple contacts, because it exceeds the maximum allowed message length of %d bytes"), dat->nMax);
- SendMessage(dat->hwnd, DM_ACTIVATETOOLTIP, IDC_MESSAGE, reinterpret_cast<LPARAM>(tszError));
- clearJob(iEntry);
- return 0;
- }
- doSendLater(iEntry, dat);
+ m_jobs[iEntry].hOwner = dat->hContact;
+ m_jobs[iEntry].hwndOwner = hwndDlg;
+ m_jobs[iEntry].iStatus = SQ_INPROGRESS;
+ m_jobs[iEntry].iAcksNeeded = 1;
+ if (dat->sendMode & SMODE_SENDLATER) {
+ TCHAR tszError[256];
+
+ int iSendLength = getSendLength(iEntry, dat->sendMode);
+ if (iSendLength >= dat->nMax) {
+ mir_sntprintf(tszError, 256, TranslateT("The message cannot be sent delayed or to multiple contacts, because it exceeds the maximum allowed message length of %d bytes"), dat->nMax);
+ SendMessage(dat->hwnd, DM_ACTIVATETOOLTIP, IDC_MESSAGE, reinterpret_cast<LPARAM>(tszError));
clearJob(iEntry);
return 0;
}
- m_jobs[iEntry].hSendId = (HANDLE) CallContactService(dat->hContact, MsgServiceName(dat->hContact, dat, m_jobs[iEntry].dwFlags), (dat->sendMode & SMODE_FORCEANSI) ? (m_jobs[iEntry].dwFlags & ~PREF_UNICODE) : m_jobs[iEntry].dwFlags, (LPARAM)m_jobs[iEntry].sendBuffer);
-
- if (dat->sendMode & SMODE_NOACK) { // fake the ack if we are not interested in receiving real acks
- ACKDATA ack = {0};
- ack.hContact = dat->hContact;
- ack.hProcess = m_jobs[iEntry].hSendId;
- ack.type = ACKTYPE_MESSAGE;
- ack.result = ACKRESULT_SUCCESS;
- SendMessage(hwndDlg, HM_EVENTSENT, (WPARAM)MAKELONG(iEntry, 0), (LPARAM)&ack);
- }
- else
- SetTimer(hwndDlg, TIMERID_MSGSEND + iEntry, PluginConfig.m_MsgTimeout, NULL);
+ doSendLater(iEntry, dat);
+ clearJob(iEntry);
+ return 0;
}
+ m_jobs[iEntry].hSendId = (HANDLE) CallContactService(dat->hContact, PSS_MESSAGE,
+ (dat->sendMode & SMODE_FORCEANSI) ? (m_jobs[iEntry].dwFlags & ~PREF_UNICODE) : m_jobs[iEntry].dwFlags, (LPARAM)m_jobs[iEntry].sendBuffer);
+
+ if (dat->sendMode & SMODE_NOACK) { // fake the ack if we are not interested in receiving real acks
+ ACKDATA ack = {0};
+ ack.hContact = dat->hContact;
+ ack.hProcess = m_jobs[iEntry].hSendId;
+ ack.type = ACKTYPE_MESSAGE;
+ ack.result = ACKRESULT_SUCCESS;
+ SendMessage(hwndDlg, HM_EVENTSENT, (WPARAM)MAKELONG(iEntry, 0), (LPARAM)&ack);
+ }
+ else SetTimer(hwndDlg, TIMERID_MSGSEND + iEntry, PluginConfig.m_MsgTimeout, NULL);
}
+
dat->iOpenJobs++;
m_currentIndex++;
@@ -550,14 +502,13 @@ void SendQueue::checkQueue(const TWindowData *dat) const void SendQueue::logError(const TWindowData *dat, int iSendJobIndex, const TCHAR *szErrMsg) const
{
- DBEVENTINFO dbei = {0};
int iMsgLen;
if (dat == 0)
return;
+ DBEVENTINFO dbei = { sizeof(dbei) };
dbei.eventType = EVENTTYPE_ERRMSG;
- dbei.cbSize = sizeof(dbei);
if (iSendJobIndex >= 0) {
dbei.pBlob = (BYTE *)m_jobs[iSendJobIndex].sendBuffer;
iMsgLen = lstrlenA(m_jobs[iSendJobIndex].sendBuffer) + 1;
@@ -738,7 +689,6 @@ int SendQueue::RTL_Detect(const WCHAR *pszwText) int SendQueue::ackMessage(TWindowData *dat, WPARAM wParam, LPARAM lParam)
{
ACKDATA *ack = (ACKDATA *) lParam;
- DBEVENTINFO dbei = { 0};
HANDLE hNewEvent;
int iFound = SendQueue::NR_SENDJOBS, iNextFailed;
TContainerData *m_pContainer = 0;
@@ -792,7 +742,7 @@ inform_and_discard: }
}
- dbei.cbSize = sizeof(dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
dbei.eventType = EVENTTYPE_MESSAGE;
dbei.flags = DBEF_SENT;
dbei.szModule = GetContactProto(m_jobs[iFound].hOwner);
diff --git a/plugins/TabSRMM/src/sendqueue.h b/plugins/TabSRMM/src/sendqueue.h index 428ee49b32..1eac7f557d 100644 --- a/plugins/TabSRMM/src/sendqueue.h +++ b/plugins/TabSRMM/src/sendqueue.h @@ -100,7 +100,6 @@ public: * static members
*/
static int TSAPI RTL_Detect (const wchar_t *pszwText);
- static char* TSAPI MsgServiceName (const HANDLE hContact, const TWindowData *dat, int isUnicode);
static int TSAPI GetProtoIconFromList (const char *szProto, int iStatus);
static LRESULT TSAPI WarnPendingJobs (unsigned int uNrMessages);
static void TSAPI NotifyDeliveryFailure (const TWindowData *dat);
|