summaryrefslogtreecommitdiff
path: root/plugins/New_GPG
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-07-19 14:11:25 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-07-19 14:11:25 +0000
commit6be9b9c1dd00da5ecd33cbc20ece4162ba56c402 (patch)
tree73fbf2e3632a8372d8102a07c4f374b3289c7e97 /plugins/New_GPG
parente4a8fd6f323b262018bae68bfe87da65cf2092c0 (diff)
db_mc_tryMeta applied
git-svn-id: http://svn.miranda-ng.org/main/trunk@9860 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/New_GPG')
-rw-r--r--plugins/New_GPG/src/icons.cpp20
-rwxr-xr-xplugins/New_GPG/src/main.cpp16
-rwxr-xr-xplugins/New_GPG/src/messages.cpp57
-rw-r--r--plugins/New_GPG/src/metacontacts.cpp11
-rw-r--r--plugins/New_GPG/src/metacontacts.h1
-rwxr-xr-xplugins/New_GPG/src/options.cpp44
-rw-r--r--plugins/New_GPG/src/srmm.cpp2
-rwxr-xr-xplugins/New_GPG/src/utilities.cpp31
8 files changed, 56 insertions, 126 deletions
diff --git a/plugins/New_GPG/src/icons.cpp b/plugins/New_GPG/src/icons.cpp
index dffaad03bd..71493e49f2 100644
--- a/plugins/New_GPG/src/icons.cpp
+++ b/plugins/New_GPG/src/icons.cpp
@@ -48,26 +48,18 @@ void setClistIcon(MCONTACT hContact)
{
bool enabled = isContactSecured(hContact);
extern HANDLE g_hCLIcon;
- MCONTACT hMC = hContact;
- if(db_mc_isSub(hContact))
- hMC = db_mc_getMeta(hContact);
- else if(metaIsProtoMetaContacts(hContact))
- hMC = db_mc_getMeta(hContact);
+ MCONTACT hMC = db_mc_tryMeta(hContact);
const char *szIconId = (enabled) ? "secured" : NULL;
ExtraIcon_SetIcon(g_hCLIcon, hContact, szIconId);
- if(hMC)
+ if(hMC != hContact)
ExtraIcon_SetIcon(g_hCLIcon, hMC, szIconId);
}
void setSrmmIcon(MCONTACT h)
{
- MCONTACT hContact = metaIsProtoMetaContacts(h) ? metaGetMostOnline(h) : h;
+ MCONTACT hContact = db_mc_isMeta(h) ? metaGetMostOnline(h) : h;
bool enabled = isContactSecured(hContact);
- MCONTACT hMC = NULL;
- if(db_mc_isSub(hContact))
- hMC = db_mc_getMeta(hContact);
- else if(metaIsProtoMetaContacts(hContact))
- hMC = db_mc_getMeta(hContact);
+ MCONTACT hMC = db_mc_tryMeta(hContact);
StatusIconData sid = { sizeof(sid) };
sid.szModule = szGPGModuleName;
@@ -75,14 +67,14 @@ void setSrmmIcon(MCONTACT h)
sid.dwId = 1;
sid.flags = enabled ? 0 : MBF_HIDDEN;
Srmm_ModifyIcon(hContact, &sid);
- if(hMC)
+ if(hMC != hContact)
Srmm_ModifyIcon(hMC, &sid);
sid.hIcon = IconLibGetIcon("unsecured");
sid.dwId = 2;
sid.flags = enabled ? MBF_HIDDEN : 0;
Srmm_ModifyIcon(hContact, &sid);
- if(hMC)
+ if(hMC != hContact)
Srmm_ModifyIcon(hMC, &sid);
}
diff --git a/plugins/New_GPG/src/main.cpp b/plugins/New_GPG/src/main.cpp
index 49651b7fb8..97ba1eabe9 100755
--- a/plugins/New_GPG/src/main.cpp
+++ b/plugins/New_GPG/src/main.cpp
@@ -2271,11 +2271,10 @@ void ImportKey()
MCONTACT hContact = new_key_hcnt;
new_key_hcnt_mutex.unlock();
bool for_all_sub = false;
- if(metaIsProtoMetaContacts(hContact))
+ if(db_mc_isMeta(hContact)) {
if(MessageBox(0, TranslateT("Do you want to load key for all subcontacts?"), TranslateT("Metacontact detected"), MB_YESNO) == IDYES)
for_all_sub = true;
- if(metaIsProtoMetaContacts(hContact))
- {
+
if(for_all_sub)
{
int count = db_mc_getSubCount(hContact);
@@ -2286,11 +2285,10 @@ void ImportKey()
db_set_ts(hcnt, szGPGModuleName, "GPGPubKey", new_key.c_str());
}
}
- else
- db_set_ts(metaGetMostOnline(hContact), szGPGModuleName, "GPGPubKey", new_key.c_str());
+ else db_set_ts(metaGetMostOnline(hContact), szGPGModuleName, "GPGPubKey", new_key.c_str());
}
- else
- db_set_ts(hContact, szGPGModuleName, "GPGPubKey", new_key.c_str());
+ else db_set_ts(hContact, szGPGModuleName, "GPGPubKey", new_key.c_str());
+
new_key.clear();
{ //gpg execute block
std::vector<wstring> cmd;
@@ -2306,7 +2304,7 @@ void ImportKey()
_tcscat(tmp2, _T("temporary_exported.asc"));
boost::filesystem::remove(tmp2);
wfstream f(tmp2, std::ios::out);
- if(metaIsProtoMetaContacts(hContact))
+ if(db_mc_isMeta(hContact))
ptmp = UniGetContactSettingUtf(metaGetMostOnline(hContact), szGPGModuleName, "GPGPubKey", _T(""));
else
ptmp = UniGetContactSettingUtf(hContact, szGPGModuleName, "GPGPubKey", _T(""));
@@ -2328,7 +2326,7 @@ void ImportKey()
if(result == pxNotFound)
return;
{
- if(metaIsProtoMetaContacts(hContact))
+ if(db_mc_isMeta(hContact))
{
if(for_all_sub)
{
diff --git a/plugins/New_GPG/src/messages.cpp b/plugins/New_GPG/src/messages.cpp
index dd05955bf6..fbc4f428ed 100755
--- a/plugins/New_GPG/src/messages.cpp
+++ b/plugins/New_GPG/src/messages.cpp
@@ -50,20 +50,19 @@ void RecvMsgSvc_func(MCONTACT hContact, std::wstring str, char *msg, DWORD flags
}
else
{
- db_set_b(metaIsProtoMetaContacts(hContact)?metaGetMostOnline(hContact):hContact, szGPGModuleName, "GPGEncryption", 1);
+ db_set_b(db_mc_isMeta(hContact)?metaGetMostOnline(hContact):hContact, szGPGModuleName, "GPGEncryption", 1);
setSrmmIcon(hContact);
setClistIcon(hContact);
}
if(isContactHaveKey(hContact))
{
- db_set_b(metaIsProtoMetaContacts(hContact)?metaGetMostOnline(hContact):hContact, szGPGModuleName, "GPGEncryption", 1);
+ db_set_b(db_mc_isMeta(hContact)?metaGetMostOnline(hContact):hContact, szGPGModuleName, "GPGEncryption", 1);
setSrmmIcon(hContact);
setClistIcon(hContact);
}
}
else if(MessageBox(0, TranslateT("Do you want to try to decrypt encrypted message?"), TranslateT("Warning"), MB_YESNO) == IDNO)
{
-
HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags));
return;
}
@@ -95,7 +94,7 @@ void RecvMsgSvc_func(MCONTACT hContact, std::wstring str, char *msg, DWORD flags
std::vector<wstring> cmd;
cmd.push_back(L"--batch");
{
- char *inkeyid = UniGetContactSettingUtf(metaIsProtoMetaContacts(hContact)?metaGetMostOnline(hContact):hContact, szGPGModuleName, "InKeyID", "");
+ char *inkeyid = UniGetContactSettingUtf(db_mc_isMeta(hContact)?metaGetMostOnline(hContact):hContact, szGPGModuleName, "InKeyID", "");
TCHAR *pass = NULL;
if(inkeyid[0])
{
@@ -190,7 +189,7 @@ void RecvMsgSvc_func(MCONTACT hContact, std::wstring str, char *msg, DWORD flags
s = out.find(" ID ", s);
s += strlen(" ID ");
string::size_type s2 = out.find(",",s);
- db_set_s(metaIsProtoMetaContacts(hContact)?metaGetMostOnline(hContact):hContact, szGPGModuleName, "InKeyID", out.substr(s, s2-s).c_str());
+ db_set_s(db_mc_isMeta(hContact)?metaGetMostOnline(hContact):hContact, szGPGModuleName, "InKeyID", out.substr(s, s2-s).c_str());
}
void ShowLoadKeyPasswordWindow();
new_key_hcnt_mutex.lock();
@@ -319,14 +318,7 @@ void RecvMsgSvc_func(MCONTACT hContact, std::wstring str, char *msg, DWORD flags
str.insert(0, inopentag);
str.append(inclosetag);
}
- if(db_mc_isSub(hContact))
- {
- char *msg = mir_strdup(toUTF8(str).c_str());
- HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags|DBEF_READ));
- HistoryLog(db_mc_getMeta(hContact), db_event(msg, timestamp, 0, dbflags));
- mir_free(msg);
- return;
- }
+
char *tmp = mir_strdup(toUTF8(str).c_str());
HistoryLog(hContact, db_event(tmp, timestamp, 0, dbflags));
mir_free(tmp);
@@ -336,14 +328,8 @@ void RecvMsgSvc_func(MCONTACT hContact, std::wstring str, char *msg, DWORD flags
}
}
}
- if(db_get_b(metaIsProtoMetaContacts(hContact)?metaGetMostOnline(hContact):hContact, szGPGModuleName, "GPGEncryption", 0))
+ if(db_get_b(db_mc_isMeta(hContact)?metaGetMostOnline(hContact):hContact, szGPGModuleName, "GPGEncryption", 0))
{
- if(db_mc_isSub(hContact))
- {
- HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags|DBEF_READ));
- HistoryLog(db_mc_getMeta(hContact), db_event(msg, timestamp, 0, dbflags));
- return;
- }
HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags|DBEF_READ));
return;
}
@@ -363,7 +349,7 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l)
if (!msg)
return CallService(MS_PROTO_CHAINRECV, w, l);
DWORD dbflags = DBEF_UTF;
- if(metaIsProtoMetaContacts(ccs->hContact))
+ if(db_mc_isMeta(ccs->hContact))
{
if(!strstr(msg, "-----BEGIN PGP MESSAGE-----"))
return CallService(MS_PROTO_CHAINRECV, w, l);
@@ -491,7 +477,6 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l)
{
setSrmmIcon(db_mc_getMeta(ccs->hContact));
setClistIcon(db_mc_getMeta(ccs->hContact));
- HistoryLog(db_mc_getMeta(ccs->hContact), "PGP Encryption turned on by key autoexchange feature");
}
HistoryLog(ccs->hContact, "PGP Encryption turned on by key autoexchange feature");
}
@@ -623,8 +608,6 @@ void SendMsgSvc_func(MCONTACT hContact, char *msg, DWORD flags)
{
mir_free(tmp);
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, flags, (LPARAM)msg);
return;
}
@@ -754,10 +737,8 @@ void SendMsgSvc_func(MCONTACT hContact, char *msg, DWORD flags)
if(str.empty())
{
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");
if(bDebugLog)
debuglog<<std::string(time_str()+": info: Failed to encrypt message with GPG");
- //mir_free(msg);
CallContactService(hContact, PSS_MESSAGE, flags, (LPARAM)msg);
return;
}
@@ -767,26 +748,14 @@ void SendMsgSvc_func(MCONTACT hContact, char *msg, DWORD flags)
str_event.insert(0, toUTF8(outopentag));
str_event.append(toUTF8(outclosetag));
}
- /*if(db_mc_isSub(hContact))
- {
- hcontact_data[db_mc_getMeta(hContact)].msgs_to_pass.push_back(str_event);
- if(bDebugLog)
- {
- debuglog<<std::string(time_str() + toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR)) +"is subcontact of" + toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)db_mc_getMeta(hContact), GCDNF_TCHAR)));
- debuglog<<std::string(time_str()+": adding event to metacontact: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)db_mc_getMeta(hContact), GCDNF_TCHAR))+" on send message.");
- }
- HistoryLog(db_mc_getMeta(hContact), db_event((char*)str_event.c_str(), 0,0, DBEF_SENT|dbflags));
- }*/ //unneeded ?
-// hcontact_data[hContact].msgs_to_pass.push_back(str_event);
+
if(bDebugLog)
debuglog<<std::string(time_str()+": adding event to contact: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR))+" on send message.");
- //HistoryLog(hContact, db_event((char*)str_event.c_str(), 0,0, dbflags|DBEF_SENT));
+
if(!(flags & PREF_UTF))
flags |= PREF_UTF;
fix_line_term(str);
sent_msgs.push_back((HANDLE)CallContactService(hContact, PSS_MESSAGE, flags, (LPARAM)toUTF8(str).c_str()));
- //mir_free(msg);
- return;
}
INT_PTR SendMsgSvc(WPARAM w, LPARAM l)
@@ -816,9 +785,9 @@ INT_PTR SendMsgSvc(WPARAM w, LPARAM l)
}
if(bDebugLog)
debuglog<<std::string(time_str()+": info: contact have key, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR)));
- if(bDebugLog && metaIsProtoMetaContacts(ccs->hContact))
+ if(bDebugLog && db_mc_isMeta(ccs->hContact))
debuglog<<std::string(time_str()+": info: protocol is metacontacts, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR)));
- if(!isContactSecured(ccs->hContact) || metaIsProtoMetaContacts(ccs->hContact))
+ if(!isContactSecured(ccs->hContact) || db_mc_isMeta(ccs->hContact))
{
if(bDebugLog)
debuglog<<std::string(time_str()+": info: contact not secured, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR)));
@@ -854,7 +823,7 @@ int HookSendMsg(WPARAM w, LPARAM l)
return 1;
}
}
- if(metaIsProtoMetaContacts(hContact))
+ if(db_mc_isMeta(hContact))
return 0;
if(!isContactHaveKey(hContact))
@@ -986,7 +955,7 @@ int HookSendMsg(WPARAM w, LPARAM l)
debuglog<<std::string(time_str()+": event message: \""+(char*)dbei->pBlob+"\" passed event filter, contact "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR))+" is unsecured");
return 0;
}
- if(!(dbei->flags & DBEF_SENT) && metaIsProtoMetaContacts((MCONTACT)w))
+ if(!(dbei->flags & DBEF_SENT) && db_mc_isMeta((MCONTACT)w))
{
char tmp[29];
strncpy(tmp, (char*)dbei->pBlob, 27);
diff --git a/plugins/New_GPG/src/metacontacts.cpp b/plugins/New_GPG/src/metacontacts.cpp
index 7db1725be3..5a7fa5a031 100644
--- a/plugins/New_GPG/src/metacontacts.cpp
+++ b/plugins/New_GPG/src/metacontacts.cpp
@@ -16,15 +16,6 @@
#include "commonheaders.h"
-bool metaIsProtoMetaContacts(MCONTACT hContact)
-{
- LPSTR proto = GetContactProto(hContact);
- if(proto && strcmp(proto,"MetaContacts") == 0)
- return true;
-
- return false;
-}
-
bool metaIsDefaultSubContact(MCONTACT hContact)
{
return db_mc_getDefault(db_mc_getMeta(hContact)) == hContact;
@@ -32,7 +23,7 @@ bool metaIsDefaultSubContact(MCONTACT hContact)
MCONTACT metaGetMostOnline(MCONTACT hContact)
{
- if(metaIsProtoMetaContacts(hContact))
+ if(db_mc_isMeta(hContact))
return db_mc_getMostOnline(hContact);
return NULL;
}
diff --git a/plugins/New_GPG/src/metacontacts.h b/plugins/New_GPG/src/metacontacts.h
index 4e43860c57..c0d2dd2b3b 100644
--- a/plugins/New_GPG/src/metacontacts.h
+++ b/plugins/New_GPG/src/metacontacts.h
@@ -14,7 +14,6 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-bool metaIsProtoMetaContacts(MCONTACT hContact);
bool metaIsDefaultSubContact(MCONTACT hContact) ;
MCONTACT metaGetMostOnline(MCONTACT hContact);
diff --git a/plugins/New_GPG/src/options.cpp b/plugins/New_GPG/src/options.cpp
index a8f5ff9193..8490ca1fd1 100755
--- a/plugins/New_GPG/src/options.cpp
+++ b/plugins/New_GPG/src/options.cpp
@@ -202,7 +202,7 @@ static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
bool ismetacontact = false;
MCONTACT meta = NULL;
MCONTACT hContact = user_data[item_num+1];
- if(metaIsProtoMetaContacts(hContact))
+ if(db_mc_isMeta(hContact))
{
meta = hContact;
hContact = metaGetMostOnline(hContact);
@@ -729,9 +729,7 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam
hContact = user_data[1];
SetWindowPos(hwndDlg, 0, load_key_rect.left, load_key_rect.top, 0, 0, SWP_NOSIZE|SWP_SHOWWINDOW);
mir_subclassWindow(GetDlgItem(hwndDlg, IDC_PUBLIC_KEY_EDIT), editctrl_ctrl_a);
- MCONTACT hcnt = hContact;
- if(metaIsProtoMetaContacts(hcnt))
- hcnt = metaGetMostOnline(hcnt);
+ MCONTACT hcnt = db_mc_tryMeta(hContact);
TranslateDialogDefault(hwndDlg);
{
wstring msg = TranslateT("Load Public GPG Key for ");
@@ -875,7 +873,7 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam
ws2 += _tcslen(end);
bool allsubcontacts = false;
{
- if(metaIsProtoMetaContacts(hContact))
+ if(db_mc_isMeta(hContact))
{
if(MessageBox(0, TranslateT("Do you want to load key for all subcontacts?"), TranslateT("Metacontact detected"), MB_YESNO) == IDYES)
{
@@ -888,11 +886,9 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam
db_set_ts(hcnt, szGPGModuleName, "GPGPubKey", key_buf.substr(ws1,ws2-ws1).c_str());
}
}
- else
- db_set_ts(metaGetMostOnline(hContact), szGPGModuleName, "GPGPubKey", key_buf.substr(ws1,ws2-ws1).c_str());
+ else db_set_ts(metaGetMostOnline(hContact), szGPGModuleName, "GPGPubKey", key_buf.substr(ws1,ws2-ws1).c_str());
}
- else
- db_set_ts(hContact, szGPGModuleName, "GPGPubKey", key_buf.substr(ws1,ws2-ws1).c_str());
+ else db_set_ts(hContact, szGPGModuleName, "GPGPubKey", key_buf.substr(ws1,ws2-ws1).c_str());
}
tmp = (TCHAR*)mir_alloc(sizeof( TCHAR) * (key_buf.length()+1));
_tcscpy(tmp, key_buf.substr(ws1,ws2-ws1).c_str());
@@ -903,9 +899,7 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam
string output;
DWORD exitcode;
{
- MCONTACT hcnt = hContact;
- if(metaIsProtoMetaContacts(hcnt))
- hcnt = metaGetMostOnline(hcnt);
+ MCONTACT hcnt = db_mc_tryMeta(hContact);
ptmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", _T(""));
_tcscpy(tmp2, ptmp);
mir_free(ptmp);
@@ -940,7 +934,7 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam
mir_free(end);
if(hContact)
{
- if(metaIsProtoMetaContacts(hContact))
+ if(db_mc_isMeta(hContact))
{
if(allsubcontacts)
{
@@ -971,7 +965,7 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam
strcpy(tmp2, output.substr(s,s2-s).c_str());
mir_utf8decode(tmp2, 0);
{
- if(metaIsProtoMetaContacts(hContact))
+ if(db_mc_isMeta(hContact))
{
if(allsubcontacts)
{
@@ -1020,7 +1014,7 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam
mir_utf8decode(tmp2, 0);
if(hContact)
{
- if(metaIsProtoMetaContacts(hContact))
+ if(db_mc_isMeta(hContact))
{
if(allsubcontacts)
{
@@ -1032,11 +1026,9 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam
db_set_s(hcnt, szGPGModuleName, "KeyMainName", output.substr(s,s2-s-1).c_str());
}
}
- else
- db_set_s(metaGetMostOnline(hContact), szGPGModuleName, "KeyMainName", output.substr(s,s2-s-1).c_str());
+ else db_set_s(metaGetMostOnline(hContact), szGPGModuleName, "KeyMainName", output.substr(s,s2-s-1).c_str());
}
- else
- db_set_s(hContact, szGPGModuleName, "KeyMainName", output.substr(s,s2-s-1).c_str());
+ else db_set_s(hContact, szGPGModuleName, "KeyMainName", output.substr(s,s2-s-1).c_str());
}
mir_free(tmp2);
tmp = mir_wstrdup(toUTF16(output.substr(s,s2-s-1)).c_str());
@@ -1057,7 +1049,7 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam
mir_utf8decode(tmp2, 0);
if(hContact)
{
- if(metaIsProtoMetaContacts(hContact))
+ if(db_mc_isMeta(hContact))
{
if(allsubcontacts)
{
@@ -1069,11 +1061,9 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam
db_set_s(hcnt, szGPGModuleName, "KeyComment", output.substr(s2,s-s2).c_str());
}
}
- else
- db_set_s(metaGetMostOnline(hContact), szGPGModuleName, "KeyComment", output.substr(s2,s-s2).c_str());
+ else db_set_s(metaGetMostOnline(hContact), szGPGModuleName, "KeyComment", output.substr(s2,s-s2).c_str());
}
- else
- db_set_s(hContact, szGPGModuleName, "KeyComment", output.substr(s2,s-s2).c_str());
+ else db_set_s(hContact, szGPGModuleName, "KeyComment", output.substr(s2,s-s2).c_str());
}
mir_free(tmp2);
s+=3;
@@ -1083,7 +1073,7 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam
mir_utf8decode(tmp2, 0);
if(hContact)
{
- if(metaIsProtoMetaContacts(hContact))
+ if(db_mc_isMeta(hContact))
{
if(allsubcontacts)
{
@@ -1112,7 +1102,7 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam
mir_utf8decode(tmp2, 0);
if(hContact)
{
- if(metaIsProtoMetaContacts(hContact))
+ if(db_mc_isMeta(hContact))
{
if(allsubcontacts)
{
@@ -1183,7 +1173,7 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam
{
if(hContact)
{
- if(metaIsProtoMetaContacts(hContact))
+ if(db_mc_isMeta(hContact))
{
if(allsubcontacts)
{
diff --git a/plugins/New_GPG/src/srmm.cpp b/plugins/New_GPG/src/srmm.cpp
index 63ff84ff0f..1cca711d67 100644
--- a/plugins/New_GPG/src/srmm.cpp
+++ b/plugins/New_GPG/src/srmm.cpp
@@ -36,7 +36,7 @@ int __cdecl onIconPressed(WPARAM wParam, LPARAM lParam)
{
MCONTACT hContact = wParam;
MCONTACT hMeta = NULL;
- if(metaIsProtoMetaContacts(hContact))
+ if(db_mc_isMeta(hContact))
{
hMeta = hContact;
hContact = metaGetMostOnline(hContact); // возьмем тот, через который пойдет сообщение
diff --git a/plugins/New_GPG/src/utilities.cpp b/plugins/New_GPG/src/utilities.cpp
index e5f67a539b..ece1904580 100755
--- a/plugins/New_GPG/src/utilities.cpp
+++ b/plugins/New_GPG/src/utilities.cpp
@@ -150,9 +150,7 @@ INT_PTR LoadKey(WPARAM w, LPARAM)
INT_PTR SendKey(WPARAM w, LPARAM l)
{
- MCONTACT hContact = (MCONTACT)w;
- if(metaIsProtoMetaContacts(hContact))
- hContact = metaGetMostOnline(hContact);
+ MCONTACT hContact = db_mc_tryMeta(w);
char *szMessage;
std::string key_id_str;
{
@@ -204,13 +202,10 @@ INT_PTR SendKey(WPARAM w, LPARAM l)
INT_PTR ToggleEncryption(WPARAM w, LPARAM l)
{
MCONTACT hContact = (MCONTACT)w;
- BYTE enc = 0;
- if(metaIsProtoMetaContacts(hContact))
- enc = db_get_b(metaGetMostOnline(hContact), szGPGModuleName, "GPGEncryption", 0);
- else
- enc = db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0);
- if(metaIsProtoMetaContacts(hContact))
+ BYTE enc;
+ if(db_mc_isMeta(hContact))
{
+ enc = db_get_b(metaGetMostOnline(hContact), szGPGModuleName, "GPGEncryption", 0);
if(MessageBox(0, TranslateT("Do you want to toggle encryption for all subcontacts?"), TranslateT("Metacontact detected"), MB_YESNO) == IDYES)
{
int count = db_mc_getSubCount(hContact);
@@ -223,8 +218,10 @@ INT_PTR ToggleEncryption(WPARAM w, LPARAM l)
db_set_b(hContact, szGPGModuleName, "GPGEncryption", enc?0:1);
}
}
- else
+ else {
+ enc = db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0);
db_set_b(hContact, szGPGModuleName, "GPGEncryption", enc?0:1);
+ }
void setSrmmIcon(MCONTACT hContact);
void setClistIcon(MCONTACT hContact);
setSrmmIcon(hContact);
@@ -239,10 +236,7 @@ INT_PTR ToggleEncryption(WPARAM w, LPARAM l)
int OnPreBuildContactMenu(WPARAM w, LPARAM l)
{
- MCONTACT hContact = (MCONTACT)w;
- if(metaIsProtoMetaContacts(hContact))
- hContact = metaGetMostOnline(hContact);
-
+ MCONTACT hContact = db_mc_tryMeta(w);
{
CLISTMENUITEM mi2 = { sizeof(mi2) };
LPSTR proto = GetContactProto(hContact);
@@ -405,7 +399,7 @@ int onProtoAck(WPARAM w, LPARAM l)
s = out.find(" ID ", s);
s += strlen(" ID ");
string::size_type s2 = out.find(",",s);
- if(metaIsProtoMetaContacts(ack->hContact))
+ if(db_mc_isMeta(ack->hContact))
db_set_s(metaGetMostOnline(ack->hContact), szGPGModuleName, "InKeyID", out.substr(s, s2-s).c_str());
else
db_set_s(ack->hContact, szGPGModuleName, "InKeyID", out.substr(s, s2-s).c_str());
@@ -459,10 +453,7 @@ int onProtoAck(WPARAM w, LPARAM l)
{
std::list<HANDLE>::iterator it = std::find(sent_msgs.begin(), sent_msgs.end(), ack->hProcess);
if(it != sent_msgs.end())
- {
HistoryLog(ack->hContact, db_event("Failed to send encrypted message", 0,0, 0));
-
- }
}
else if(ack->result == ACKRESULT_SUCCESS)
{
@@ -480,7 +471,7 @@ std::wstring encrypt_file(MCONTACT hContact, TCHAR *filename)
string out;
DWORD code;
pxResult result;
- MCONTACT hcnt = metaIsProtoMetaContacts(hContact)?metaGetMostOnline(hContact):hContact;
+ MCONTACT hcnt = db_mc_isMeta(hContact)?metaGetMostOnline(hContact):hContact;
std::vector<wstring> cmd;
cmd.push_back(L"--batch");
cmd.push_back(L"--tes");
@@ -1081,7 +1072,7 @@ bool isContactSecured(MCONTACT hContact)
debuglog<<std::string(time_str()+": encryption is turned off for "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR)));
return false;
}
- if(!metaIsProtoMetaContacts(hContact))
+ if(!db_mc_isMeta(hContact))
{
TCHAR *key = UniGetContactSettingUtf(hContact, szGPGModuleName, "GPGPubKey", _T(""));
if(!key[0])