summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.cpp6
-rw-r--r--messages.cpp17
-rw-r--r--utilities.cpp16
-rw-r--r--utilities.h1
4 files changed, 31 insertions, 9 deletions
diff --git a/main.cpp b/main.cpp
index e332f41..53e5d33 100644
--- a/main.cpp
+++ b/main.cpp
@@ -1727,7 +1727,6 @@ void ImportKey()
if(metaIsProtoMetaContacts(hContact))
if(MessageBox(0, _T("Do you want load key for all subcontacts ?"), _T("Metacontact detected"), MB_YESNO) == IDYES)
for_all_sub = true;
-
if(metaIsProtoMetaContacts(hContact))
{
HANDLE hcnt = NULL;
@@ -1761,7 +1760,10 @@ void ImportKey()
_tcscat(tmp2, _T("temporary_exported.asc"));
DeleteFile(tmp2);
wfstream f(tmp2, std::ios::out);
- ptmp = UniGetContactSettingUtf(hContact, szGPGModuleName, "GPGPubKey", _T(""));
+ if(metaIsProtoMetaContacts(hContact))
+ ptmp = UniGetContactSettingUtf(metaGetCurrent(hContact), szGPGModuleName, "GPGPubKey", _T(""));
+ else
+ ptmp = UniGetContactSettingUtf(hContact, szGPGModuleName, "GPGPubKey", _T(""));
wstring new_key = ptmp;
mir_free(ptmp);
f<<new_key.c_str();
diff --git a/messages.cpp b/messages.cpp
index 537e25b..c4c804c 100644
--- a/messages.cpp
+++ b/messages.cpp
@@ -150,7 +150,7 @@ int RecvMsgSvc(WPARAM w, LPARAM l)
{
setSrmmIcon(metaGetContact(hContact));
setClistIcon(metaGetContact(hContact));
- HistoryLog(metaGetContact(hContact), "PGP Encryption turned on by key autoexchange feature", EVENTTYPE_MESSAGE, DBEF_READ);
+ HistoryLog(metaGetContact(hContact), "PGP Encryption turned on by key autoexchange feature", EVENTTYPE_MESSAGE, 0);
}
HistoryLog(hContact, "PGP Encryption turned on by key autoexchange feature", EVENTTYPE_MESSAGE, 0);
}
@@ -634,9 +634,16 @@ int SendMsgSvc(WPARAM w, LPARAM l)
if(!isContactSecured(hContact))
return CallService(MS_PROTO_CHAINSEND, w, l);
-
{ //encrypt data here
- wstring str = toUTF16(msg);
+ wstring str;
+ if(!metaIsSubcontact(hContact))
+ str = toUTF16(msg);
+ else
+ {//workaround ...
+ wchar_t *tmp = mir_a2t(msg);
+ str.append(tmp);
+ mir_free(tmp);
+ }
{ //not xmpp, just replace whole message
string out;
DWORD code;
@@ -775,8 +782,8 @@ int SendMsgSvc(WPARAM w, LPARAM l)
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);
+ HistoryLog(hContact, (char*)str_event.c_str(), EVENTTYPE_MESSAGE, DBEF_SENT);
+ HistoryLog(metaGetContact(hContact), (char*)str_event.c_str(), EVENTTYPE_MESSAGE, DBEF_SENT);
hcontact_data[hContact].msgs_to_ignore.push_back((char*)ccs->lParam);
hcontact_data[metaGetContact(hContact)].msgs_to_ignore.push_back((char*)ccs->lParam); //hmm, twice ? metacontacts !! %)
CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)toUTF8(str).c_str());
diff --git a/utilities.cpp b/utilities.cpp
index 4f594cb..b462a23 100644
--- a/utilities.cpp
+++ b/utilities.cpp
@@ -438,7 +438,7 @@ void HistoryLog(HANDLE hContact, char *data, int event_type, int flags)
Event.cbSize = sizeof(Event);
Event.szModule = szGPGModuleName;
Event.eventType = event_type;
- Event.flags = flags, DBEF_UTF;
+ Event.flags = flags;
Event.timestamp = (DWORD)time(NULL);
Event.cbBlob = strlen(data)+1;
Event.pBlob = (PBYTE)_strdup(data);
@@ -934,10 +934,22 @@ int returnNoError(HANDLE hContact) {
string toUTF8(wstring str)
{
string ustr;
- utf8::utf16to8(str.begin(), str.end(), back_inserter(ustr));
+ wstring tmpstr;
+ utf8::replace_invalid(str.begin(), str.end(), back_inserter(tmpstr));
+ utf8::utf16to8(tmpstr.begin(), tmpstr.end(), back_inserter(ustr));
+ return ustr;
+}
+
+string toUTF8(string str)
+{
+ string ustr;
+ wstring tmpstr;
+ utf8::replace_invalid(str.begin(), str.end(), back_inserter(tmpstr));
+ utf8::utf16to8(tmpstr.begin(), tmpstr.end(), back_inserter(ustr));
return ustr;
}
+
wstring toUTF16(string str) //convert as much as possible
{
wstring ustr;
diff --git a/utilities.h b/utilities.h
index 7255724..3871f67 100644
--- a/utilities.h
+++ b/utilities.h
@@ -32,6 +32,7 @@ bool isContactHaveKey(HANDLE hContact);
bool isGPGConfigured();
const bool StriStr(const char *str, const char *substr);
string toUTF8(wstring str);
+string toUTF8(string str);
wstring toUTF16(string str);
string get_random(int length);
string time_str();