summaryrefslogtreecommitdiff
path: root/messages.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'messages.cpp')
-rw-r--r--messages.cpp35
1 files changed, 24 insertions, 11 deletions
diff --git a/messages.cpp b/messages.cpp
index 36434ea..952d9e5 100644
--- a/messages.cpp
+++ b/messages.cpp
@@ -520,7 +520,7 @@ int RecvMsgSvc(WPARAM w, LPARAM l)
{
if(metaIsSubcontact(hContact))
{
- HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, DBEF_UTF);
+ HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, DBEF_UTF| DBEF_READ);
HistoryLog(metaGetContact(hContact), msg, EVENTTYPE_MESSAGE, DBEF_UTF);
mir_free(msg);
return 1;
@@ -551,7 +551,7 @@ int SendMsgSvc(WPARAM w, LPARAM l)
hcontact_data[ccs->hContact].msgs_to_ignore.push_back((char*)ccs->lParam);
return CallService(MS_PROTO_CHAINSEND, w, l);
}
- if(!isContactHaveKey(hContact) && bAutoExchange && !strstr(msg, "-----PGP KEY REQUEST-----") && !strstr(msg, "-----BEGIN PGP PUBLIC KEY BLOCK-----") && isGPGConfigured()) //TODO: add all mesages to list, and send after key exchange done, encrypted
+ if(!isContactHaveKey(hContact) && bAutoExchange && !strstr(msg, "-----PGP KEY REQUEST-----") && !strstr(msg, "-----BEGIN PGP PUBLIC KEY BLOCK-----") && isGPGConfigured())
{
void send_encrypted_msgs_thread(HANDLE hContact);
LPSTR proto = (LPSTR)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
@@ -611,11 +611,17 @@ int SendMsgSvc(WPARAM w, LPARAM l)
{ //encrypt data here
wstring str;
+ bool isansi = false;
if(!metaIsSubcontact(hContact))
str = toUTF16(msg);
else
{//workaround ...
- wchar_t *tmp = mir_a2t(msg);
+ wchar_t *tmp = mir_utf8decodeW(msg);
+ if(!tmp)
+ {
+ tmp = mir_a2t(msg);
+ isansi = true;
+ }
str.append(tmp);
mir_free(tmp);
}
@@ -702,7 +708,7 @@ int SendMsgSvc(WPARAM w, LPARAM l)
}
if(out.find("usage: ") != string::npos)
{
- MessageBox(0, _T("Something wrong, gpg does not understand us, aborting encrypting."), _T("Warning"), MB_OK);
+ MessageBox(0, _T("Something wrong, gpg does not understand us, aborting encryption."), _T("Warning"), MB_OK);
DeleteFile(path.c_str());
return CallService(MS_PROTO_CHAINSEND, w, l);
}
@@ -732,15 +738,22 @@ int SendMsgSvc(WPARAM w, LPARAM l)
{ //dirty hack to avoid metacontacts problem ..., this also broke filters chain
string str_event = (char*)ccs->lParam;
if(bAppendTags)
- {
+ { //utf8 tag will cause problems here
str_event.insert(0, toUTF8(outopentag));
str_event.append(toUTF8(outclosetag));
}
- HistoryLog(hContact, (char*)str_event.c_str(), EVENTTYPE_MESSAGE, DBEF_SENT | DBEF_UTF);
- HistoryLog(metaGetContact(hContact), (char*)str_event.c_str(), EVENTTYPE_MESSAGE, DBEF_SENT |DBEF_UTF);
- hcontact_data[hContact].msgs_to_ignore.push_back(toUTF8(toUTF16((char*)ccs->lParam)));
- hcontact_data[metaGetContact(hContact)].msgs_to_ignore.push_back(toUTF8(toUTF16((char*)ccs->lParam))); //hmm, twice ? metacontacts !! %)
- CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UNICODE, (LPARAM)str.c_str());
+ DWORD flags = 0, flags2 = 0;
+ if(!isansi) //message from metacontact itself, yet another metacontacts workaround...
+ flags |= DBEF_UTF;
+ else
+ flags2 |= DBEF_READ;
+ HistoryLog(hContact, (char*)str_event.c_str(), EVENTTYPE_MESSAGE, DBEF_SENT | flags2 | flags);
+ HistoryLog(metaGetContact(hContact), (char*)str_event.c_str(), EVENTTYPE_MESSAGE, DBEF_SENT | flags);
+ hcontact_data[hContact].msgs_to_ignore.push_back(msg);
+ if(isansi)
+ hcontact_data[hContact].msgs_to_ignore.push_back(msg);
+ hcontact_data[metaGetContact(hContact)].msgs_to_ignore.push_back(msg);
+ CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)toUTF8(str).c_str());
return returnNoError(hContact);
}
if(bAppendTags)
@@ -758,7 +771,7 @@ int HookSendMsg(WPARAM w, LPARAM l)
DBEVENTINFO * dbei = (DBEVENTINFO*)l;
if((dbei->eventType == EVENTTYPE_MESSAGE) && (dbei->flags & DBEF_SENT))
{
- if(strstr((char*)dbei->pBlob, "-----BEGIN PGP MESSAGE-----") || strstr((char*)dbei->pBlob, "-----PGP KEY RESPONSE-----") || strstr((char*)dbei->pBlob, "-----PGP KEY REQUEST-----") || strstr((char*)dbei->pBlob, "-----PGP KEY RESPONSE-----")) //grrrr!
+ if(strstr((char*)dbei->pBlob, "-----BEGIN PGP MESSAGE-----") || strstr((char*)dbei->pBlob, "-----PGP KEY RESPONSE-----") || strstr((char*)dbei->pBlob, "-----PGP KEY REQUEST-----") || strstr((char*)dbei->pBlob, "-----PGP KEY RESPONSE-----")) //our service data, can be double added by metacontacts e.t.c.
return 1;
HANDLE hContact = NULL;
if(!hcontact_data[(HANDLE)w].msgs_to_ignore.empty())