diff options
-rw-r--r-- | icons.cpp | 2 | ||||
-rw-r--r-- | main.cpp | 16 | ||||
-rw-r--r-- | messages.cpp | 12 | ||||
-rw-r--r-- | metacontacts.cpp | 24 | ||||
-rw-r--r-- | metacontacts.h | 1 | ||||
-rw-r--r-- | utilities.cpp | 2 |
6 files changed, 22 insertions, 35 deletions
@@ -104,7 +104,7 @@ void setClistIcon(HANDLE hContact) void setSrmmIcon(HANDLE hContact)
{
- hContact = metaGetCurrent(hContact);
+ hContact = metaGetMostOnline(hContact);
bool enabled = isContactSecured(hContact);
HANDLE hMC = hContact;
if(metaIsProtoMetaContacts(hContact))
@@ -1839,7 +1839,7 @@ void ImportKey() } } else - DBWriteContactSettingTString(metaGetCurrent(hContact), szGPGModuleName, "GPGPubKey", new_key.c_str()); + DBWriteContactSettingTString(metaGetMostOnline(hContact), szGPGModuleName, "GPGPubKey", new_key.c_str()); } else DBWriteContactSettingTString(hContact, szGPGModuleName, "GPGPubKey", new_key.c_str()); @@ -1859,7 +1859,7 @@ void ImportKey() DeleteFile(tmp2); wfstream f(tmp2, std::ios::out); if(metaIsProtoMetaContacts(hContact)) - ptmp = UniGetContactSettingUtf(metaGetCurrent(hContact), szGPGModuleName, "GPGPubKey", _T("")); + ptmp = UniGetContactSettingUtf(metaGetMostOnline(hContact), szGPGModuleName, "GPGPubKey", _T("")); else ptmp = UniGetContactSettingUtf(hContact, szGPGModuleName, "GPGPubKey", _T("")); wstring new_key = ptmp; @@ -1959,7 +1959,7 @@ void ImportKey() char *tmp = NULL; string::size_type s = output.find("gpg: key ") + strlen("gpg: key "); string::size_type s2 = output.find(":", s); - DBWriteContactSettingString(metaGetCurrent(hContact), szGPGModuleName, "KeyID", output.substr(s,s2-s).c_str()); + DBWriteContactSettingString(metaGetMostOnline(hContact), szGPGModuleName, "KeyID", output.substr(s,s2-s).c_str()); s2+=2; s = output.find("“", s2); if(s == string::npos) @@ -1976,7 +1976,7 @@ void ImportKey() tmp = new char [output.substr(s,s2-s-1).length()+1]; strcpy(tmp, output.substr(s,s2-s-1).c_str()); mir_utf8decode(tmp, 0); - DBWriteContactSettingString(metaGetCurrent(hContact), szGPGModuleName, "KeyMainName", tmp); + DBWriteContactSettingString(metaGetContact(hContact), szGPGModuleName, "KeyMainName", tmp); mir_free(tmp); if((s = output.find(")", s2)) == string::npos) s = output.find(">", s2); @@ -1988,14 +1988,14 @@ void ImportKey() tmp = new char [output.substr(s2,s-s2).length()+1]; strcpy(tmp, output.substr(s2,s-s2).c_str()); mir_utf8decode(tmp, 0); - DBWriteContactSettingString(metaGetCurrent(hContact), szGPGModuleName, "KeyComment", tmp); + DBWriteContactSettingString(metaGetMostOnline(hContact), szGPGModuleName, "KeyComment", tmp); mir_free(tmp); s+=3; s2 = output.find(">", s); tmp = new char [output.substr(s,s2-s).length()+1]; strcpy(tmp, output.substr(s,s2-s).c_str()); mir_utf8decode(tmp, 0); - DBWriteContactSettingString(metaGetCurrent(hContact), szGPGModuleName, "KeyMainEmail", tmp); + DBWriteContactSettingString(metaGetMostOnline(hContact), szGPGModuleName, "KeyMainEmail", tmp); mir_free(tmp); } else @@ -2003,10 +2003,10 @@ void ImportKey() tmp = new char [output.substr(s2,s-s2).length()+1]; strcpy(tmp, output.substr(s2,s-s2).c_str()); mir_utf8decode(tmp, 0); - DBWriteContactSettingString(metaGetCurrent(hContact), szGPGModuleName, "KeyMainEmail", output.substr(s2,s-s2).c_str()); + DBWriteContactSettingString(metaGetMostOnline(hContact), szGPGModuleName, "KeyMainEmail", output.substr(s2,s-s2).c_str()); mir_free(tmp); } - DBDeleteContactSetting(metaGetCurrent(hContact), szGPGModuleName, "bAlwatsTrust"); + DBDeleteContactSetting(metaGetMostOnline(hContact), szGPGModuleName, "bAlwatsTrust"); } } else diff --git a/messages.cpp b/messages.cpp index 226445a..f7ea63f 100644 --- a/messages.cpp +++ b/messages.cpp @@ -36,7 +36,7 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) void setSrmmIcon(HANDLE); void setClistIcon(HANDLE); bool isContactHaveKey(HANDLE hContact); - if(!DBGetContactSettingByte(metaGetCurrent(hContact), szGPGModuleName, "GPGEncryption", 0)) + if(!DBGetContactSettingByte(metaGetMostOnline(hContact), szGPGModuleName, "GPGEncryption", 0)) { debuglog<<time_str()<<": info: "<<"received message from: "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<" whith tyrned off encryption\n"; if(MessageBox(0, _T("We received encrypted message from contact with encryption turned off.\nDo you want turn on encryption for this contact ?"), _T("Warning"), MB_YESNO) == IDYES) @@ -52,13 +52,13 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) } else { - DBWriteContactSettingByte(metaGetCurrent(hContact), szGPGModuleName, "GPGEncryption", 1); + DBWriteContactSettingByte(metaGetMostOnline(hContact), szGPGModuleName, "GPGEncryption", 1); setSrmmIcon(hContact); setClistIcon(hContact); } if(isContactHaveKey(hContact)) { - DBWriteContactSettingByte(metaGetCurrent(hContact), szGPGModuleName, "GPGEncryption", 1); + DBWriteContactSettingByte(metaGetMostOnline(hContact), szGPGModuleName, "GPGEncryption", 1); setSrmmIcon(hContact); setClistIcon(hContact); } @@ -96,7 +96,7 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) wstring cmd; cmd += _T("--batch "); { - char *inkeyid = UniGetContactSettingUtf(metaGetCurrent(hContact), szGPGModuleName, "InKeyID", ""); + char *inkeyid = UniGetContactSettingUtf(metaGetMostOnline(hContact), szGPGModuleName, "InKeyID", ""); TCHAR *pass = NULL; if(strlen(inkeyid) > 0) { @@ -179,7 +179,7 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) s = out.find(" ID ", s); s += strlen(" ID "); string::size_type s2 = out.find(",",s); - DBWriteContactSettingString(metaGetCurrent(hContact), szGPGModuleName, "InKeyID", out.substr(s, s2-s).c_str()); + DBWriteContactSettingString(metaGetMostOnline(hContact), szGPGModuleName, "InKeyID", out.substr(s, s2-s).c_str()); } void ShowLoadKeyPasswordWindow(); new_key_hcnt_mutex.lock(); @@ -313,7 +313,7 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) } } } - if(DBGetContactSettingByte(metaGetCurrent(hContact), szGPGModuleName, "GPGEncryption", 0)) + if(DBGetContactSettingByte(metaGetMostOnline(hContact), szGPGModuleName, "GPGEncryption", 0)) { if(metaIsSubcontact(hContact)) { diff --git a/metacontacts.cpp b/metacontacts.cpp index 8e282c6..46185e4 100644 --- a/metacontacts.cpp +++ b/metacontacts.cpp @@ -42,7 +42,8 @@ bool metaIsDefaultSubContact(HANDLE hContact) HANDLE metaGetContact(HANDLE hContact)
{
if(bMetaContacts)
- return (HANDLE)CallService(MS_MC_GETMETACONTACT,(WPARAM)hContact,0);
+ if(metaIsSubcontact(hContact))
+ return (HANDLE)CallService(MS_MC_GETMETACONTACT,(WPARAM)hContact,0);
return hContact;
}
bool metaIsSubcontact(HANDLE hContact)
@@ -57,32 +58,19 @@ HANDLE metaGetMostOnline(HANDLE hContact) {
if(bMetaContacts)
- return (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT,(WPARAM)hContact,0);
+ if(metaIsProtoMetaContacts(hContact))
+ return (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT,(WPARAM)hContact,0);
return hContact;
}
HANDLE metaGetDefault(HANDLE hContact)
{
if(bMetaContacts)
- return (HANDLE)CallService(MS_MC_GETDEFAULTCONTACT,(WPARAM)hContact,0);
+ if(metaIsProtoMetaContacts(hContact))
+ return (HANDLE)CallService(MS_MC_GETDEFAULTCONTACT,(WPARAM)hContact,0);
return hContact;
}
-HANDLE metaGetCurrent(HANDLE hContact)
-{
- bool IsOnline(HANDLE hContact);
- if(bMetaContacts)
- {
- if(!metaIsProtoMetaContacts(hContact))
- return hContact;
- HANDLE hcnt = metaGetMostOnline (hContact);
- if(!hcnt)
- hcnt = metaGetDefault(hContact);
- return hcnt;
- }
- return hContact;
-}
-
DWORD metaGetContactsNum(HANDLE hContact)
{
diff --git a/metacontacts.h b/metacontacts.h index b7928a9..f7dcfe7 100644 --- a/metacontacts.h +++ b/metacontacts.h @@ -20,6 +20,5 @@ HANDLE metaGetContact(HANDLE hContact); bool metaIsSubcontact(HANDLE hContact);
HANDLE metaGetMostOnline(HANDLE hContact);
HANDLE metaGetDefault(HANDLE hContact);
-HANDLE metaGetCurrent(HANDLE hContact);
DWORD metaGetContactsNum(HANDLE hContact);
HANDLE metaGetSubcontact(HANDLE hContact, int num);
\ No newline at end of file diff --git a/utilities.cpp b/utilities.cpp index 201f359..d368c56 100644 --- a/utilities.cpp +++ b/utilities.cpp @@ -396,7 +396,7 @@ int onProtoAck(WPARAM w, LPARAM l) s = out.find(" ID ", s); s += strlen(" ID "); string::size_type s2 = out.find(",",s); - DBWriteContactSettingString(metaGetCurrent(ccs->hContact), szGPGModuleName, "InKeyID", out.substr(s, s2-s).c_str()); + DBWriteContactSettingString(metaGetMostOnline(ccs->hContact), szGPGModuleName, "InKeyID", out.substr(s, s2-s).c_str()); } void ShowLoadKeyPasswordWindow(); new_key_hcnt_mutex.lock(); |