From 6be9b9c1dd00da5ecd33cbc20ece4162ba56c402 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 19 Jul 2014 14:11:25 +0000 Subject: db_mc_tryMeta applied git-svn-id: http://svn.miranda-ng.org/main/trunk@9860 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- bin10/lib/mir_core.lib | Bin 59540 -> 59750 bytes bin10/lib/mir_core64.lib | Bin 54486 -> 54678 bytes plugins/Clist_nicer/src/clc.cpp | 4 +- plugins/HistoryStats/src/mirandahistory.cpp | 2 +- plugins/MirandaG15/src/CAppletManager.cpp | 12 +----- plugins/MirandaG15/src/CAppletManager.h | 2 - plugins/MirandaG15/src/CContactList.cpp | 28 +++++++------- plugins/New_GPG/src/icons.cpp | 20 +++------- plugins/New_GPG/src/main.cpp | 16 ++++---- plugins/New_GPG/src/messages.cpp | 57 +++++++--------------------- plugins/New_GPG/src/metacontacts.cpp | 11 +----- plugins/New_GPG/src/metacontacts.h | 1 - plugins/New_GPG/src/options.cpp | 44 +++++++++------------ plugins/New_GPG/src/srmm.cpp | 2 +- plugins/New_GPG/src/utilities.cpp | 31 ++++++--------- plugins/Nudge/src/headers.h | 5 --- plugins/Nudge/src/main.cpp | 16 +------- plugins/Nudge/src/shake.cpp | 2 +- plugins/Scriver/src/msgs.cpp | 6 +-- plugins/UserInfoEx/src/svc_reminder.cpp | 17 ++++----- plugins/WhenWasIt/src/notifiers.cpp | 14 ++----- src/core/stdfile/filerecvdlg.cpp | 3 +- src/core/stdmsg/src/msgs.cpp | 6 +-- 23 files changed, 92 insertions(+), 207 deletions(-) diff --git a/bin10/lib/mir_core.lib b/bin10/lib/mir_core.lib index 56d7f7db8d..c9e220b219 100644 Binary files a/bin10/lib/mir_core.lib and b/bin10/lib/mir_core.lib differ diff --git a/bin10/lib/mir_core64.lib b/bin10/lib/mir_core64.lib index 3a2e54ddc6..4611781acd 100644 Binary files a/bin10/lib/mir_core64.lib and b/bin10/lib/mir_core64.lib differ diff --git a/plugins/Clist_nicer/src/clc.cpp b/plugins/Clist_nicer/src/clc.cpp index 3788b87334..2821d6c39a 100644 --- a/plugins/Clist_nicer/src/clc.cpp +++ b/plugins/Clist_nicer/src/clc.cpp @@ -570,8 +570,8 @@ LBL_Def: if (!FindItem(hwnd, dat, (HANDLE)hContact, &contact, NULL, NULL)) { p = cfg::getCache(hContact, szProto); if (!dat->bisEmbedded && szProto) { // may be a subcontact, forward the xstatus - MCONTACT hMasterContact = db_mc_getMeta(hContact); - if (hMasterContact && hMasterContact != hContact) // avoid recursive call of settings handler + MCONTACT hMasterContact = db_mc_tryMeta(hContact); + if (hMasterContact != hContact) // avoid recursive call of settings handler cfg::writeByte(hMasterContact, META_PROTO, "XStatusId", (BYTE)cfg::getByte(hContact, szProto, "XStatusId", 0)); break; } diff --git a/plugins/HistoryStats/src/mirandahistory.cpp b/plugins/HistoryStats/src/mirandahistory.cpp index 60c4df0ba0..656ce08870 100644 --- a/plugins/HistoryStats/src/mirandahistory.cpp +++ b/plugins/HistoryStats/src/mirandahistory.cpp @@ -118,7 +118,7 @@ void MirandaHistory::readContacts() } else { // ignore because of meta-contact? - if (db_mc_getMeta(hContact)) + if (db_mc_isMeta(hContact)) break; } } diff --git a/plugins/MirandaG15/src/CAppletManager.cpp b/plugins/MirandaG15/src/CAppletManager.cpp index 4cdd3c4296..2ae86f175b 100644 --- a/plugins/MirandaG15/src/CAppletManager.cpp +++ b/plugins/MirandaG15/src/CAppletManager.cpp @@ -589,7 +589,7 @@ void CAppletManager::HandleEvent(CEvent *pEvent) } pEvent->bLog = pEvent->bNotification; - if(CAppletManager::IsSubContact(pEvent->hContact)) + if(db_mc_isSub(pEvent->hContact)) { pEvent->bLog = false; pEvent->bNotification = false; @@ -755,16 +755,6 @@ void CAppletManager::CancelMessageJob(SMessageJob *pJob) } } -//************************************************************************ -// returns wether or not a contact is a subcontact -//************************************************************************ -bool CAppletManager::IsSubContact(MCONTACT hContact) -{ - if(!db_get_b(0, "MetaContacts", "Enabled", 1)) - return false; - return db_mc_isSub(hContact) != 0; -} - //************************************************************************ // sends typing notifications to the specified contact //************************************************************************ diff --git a/plugins/MirandaG15/src/CAppletManager.h b/plugins/MirandaG15/src/CAppletManager.h index 13efb58c5d..e95a063cb8 100644 --- a/plugins/MirandaG15/src/CAppletManager.h +++ b/plugins/MirandaG15/src/CAppletManager.h @@ -89,8 +89,6 @@ public: // returns a formatted timestamp string static tstring GetFormattedTimestamp(tm *time); - // returns wether or not a contact is a subcontact - static bool IsSubContact(MCONTACT hContact); // returns the contacts group static tstring GetContactGroup(MCONTACT hContact); // returns the contacts displayname diff --git a/plugins/MirandaG15/src/CContactList.cpp b/plugins/MirandaG15/src/CContactList.cpp index 904090ddd8..3f951be342 100644 --- a/plugins/MirandaG15/src/CContactList.cpp +++ b/plugins/MirandaG15/src/CContactList.cpp @@ -81,7 +81,7 @@ CContactListEntry *CContactList::GetContactData(CListEntry *pItem = NULL; - if((!CAppletManager::IsSubContact(hContact) && !CConfig::GetBoolSetting(CLIST_USEGROUPS)) || strGroup.empty()) + if((!db_mc_isSub(hContact) && !CConfig::GetBoolSetting(CLIST_USEGROUPS)) || strGroup.empty()) { pItem = AddItem(psContact); ((CListContainer*)this)->sort(CContactList::CompareEntries); @@ -180,7 +180,7 @@ void CContactList::AddContact(MCONTACT hContact) } pItem = pGroup->AddItem(psContact); - if(!CAppletManager::IsSubContact(hContact) && iStatus != ID_STATUS_OFFLINE) + if(!db_mc_isSub(hContact) && iStatus != ID_STATUS_OFFLINE) ChangeGroupObjectCounters(pGroup->GetGroupData()->strPath,0,1); pGroup->sort(CContactList::CompareEntries); @@ -220,7 +220,7 @@ bool CContactList::IsVisible(CContactListEntry *pEntry) { if(db_get_b(pEntry->hHandle,"CList","Hidden",0)) return false; - if(CAppletManager::IsSubContact(pEntry->hHandle)) { + if(db_mc_isSub(pEntry->hHandle)) { MCONTACT hMetaContact = db_mc_getMeta(pEntry->hHandle); if(db_get_b(hMetaContact,"CList","Hidden",0)) return false; @@ -266,10 +266,10 @@ void CContactList::RemoveContact(MCONTACT hContact) { // Update the contacts group if it has one if(pGroup->GetType() != ROOT) { - if(!CAppletManager::IsSubContact(hContact) && pEntry->iStatus != ID_STATUS_OFFLINE) + if(!db_mc_isSub(hContact) && pEntry->iStatus != ID_STATUS_OFFLINE) ChangeGroupObjectCounters(pGroup->GetGroupData()->strPath,0,-1); - if(!CAppletManager::IsSubContact(hContact) && pEntry->iMessages > 0) + if(!db_mc_isSub(hContact) && pEntry->iMessages > 0) ChangeGroupObjectCounters(pGroup->GetGroupData()->strPath,0,0,-pEntry->iMessages); } @@ -739,10 +739,10 @@ void CContactList::OnStatusChange(MCONTACT hContact,int iStatus) CListContainer* pGroup = ((CListContainer*)pContactEntry->GetParent()); if(pGroup->GetType() != ROOT) { - if(!CAppletManager::IsSubContact(hContact) && iStatus == ID_STATUS_OFFLINE && iOldStatus != ID_STATUS_OFFLINE) + if(!db_mc_isSub(hContact) && iStatus == ID_STATUS_OFFLINE && iOldStatus != ID_STATUS_OFFLINE) ChangeGroupObjectCounters(pGroup->GetGroupData()->strPath,0,-1); - else if(!CAppletManager::IsSubContact(hContact) && iStatus != ID_STATUS_OFFLINE && iOldStatus == ID_STATUS_OFFLINE) + else if(!db_mc_isSub(hContact) && iStatus != ID_STATUS_OFFLINE && iOldStatus == ID_STATUS_OFFLINE) ChangeGroupObjectCounters(pGroup->GetGroupData()->strPath,0,1); } @@ -796,7 +796,7 @@ void CContactList::OnContactAdded(MCONTACT hContact) if(!pGroup) pGroup = CreateGroupObjectByPath(strGroup); - if(!CAppletManager::IsSubContact(hContact)) + if(!db_mc_isSub(hContact)) ChangeGroupObjectCounters(strGroup,1); } } @@ -817,7 +817,7 @@ void CContactList::OnContactDeleted(MCONTACT hContact) CContactListGroup *pGroup = GetGroupObjectByPath(strGroup); - if(!CAppletManager::IsSubContact(hContact)) + if(!db_mc_isSub(hContact)) ChangeGroupObjectCounters(strGroup,-1); if(pGroup->iMembers <= 0) @@ -851,7 +851,7 @@ void CContactList::OnContactGroupChanged(MCONTACT hContact,tstring strGroup) if(pContainer->GetType() != ROOT) { pOldGroup = pContainer->GetGroupData(); - if(!CAppletManager::IsSubContact(hContact)) + if(!db_mc_isSub(hContact)) ChangeGroupObjectCounters(pOldGroup->strPath,-1); } @@ -861,7 +861,7 @@ void CContactList::OnContactGroupChanged(MCONTACT hContact,tstring strGroup) CContactListGroup *pGroup = GetGroupObjectByPath(strGroup); if(!pGroup) pGroup = CreateGroupObjectByPath(strGroup); - if(!CAppletManager::IsSubContact(hContact)) + if(!db_mc_isSub(hContact)) ChangeGroupObjectCounters(strGroup,1); } @@ -1043,7 +1043,7 @@ void CContactList::InitializeGroupObjects() pGroup = CreateGroupObjectByPath(strGroup); // update it's counters - if(!CAppletManager::IsSubContact(hContact)) + if(!db_mc_isSub(hContact)) ChangeGroupObjectCounters(strGroup,1); } 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 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 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<hContact, GCDNF_TCHAR))); - if(bDebugLog && metaIsProtoMetaContacts(ccs->hContact)) + if(bDebugLog && db_mc_isMeta(ccs->hContact)) debuglog<hContact, GCDNF_TCHAR))); - if(!isContactSecured(ccs->hContact) || metaIsProtoMetaContacts(ccs->hContact)) + if(!isContactSecured(ccs->hContact) || db_mc_isMeta(ccs->hContact)) { if(bDebugLog) debuglog<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<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::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 cmd; cmd.push_back(L"--batch"); cmd.push_back(L"--tes"); @@ -1081,7 +1072,7 @@ bool isContactSecured(MCONTACT hContact) debuglog<szSetting, "Anniv", 5) || !strncmp(pdbcws->szSetting, "DOB", 3))) { - MCONTACT hMeta = db_mc_getMeta(hContact); - WORD LastAnswer = IDNONE; - CEvent evt; - MTime now; - // check metacontact instead of subcontact - if (hMeta) - hContact = hMeta; + hContact = db_mc_tryMeta(hContact); + CEvent evt; + MTime now; now.GetLocalTime(); - if (!strcmp(pdbcws->szModule, SvcReminderGetMyBirthdayModule())) + if (!strcmp(pdbcws->szModule, SvcReminderGetMyBirthdayModule())) { + WORD LastAnswer = IDNONE; CheckContact(hContact, now, evt, FALSE, &LastAnswer); - else - CheckContact(hContact, now, evt, FALSE, 0); + } + else CheckContact(hContact, now, evt, FALSE, 0); } return 0; } diff --git a/plugins/WhenWasIt/src/notifiers.cpp b/plugins/WhenWasIt/src/notifiers.cpp index 83eb7c9c30..89ef77dafe 100644 --- a/plugins/WhenWasIt/src/notifiers.cpp +++ b/plugins/WhenWasIt/src/notifiers.cpp @@ -66,11 +66,8 @@ TCHAR *BuildDABText(int dab, TCHAR *name, TCHAR *text, int size) int PopupNotifyBirthday(MCONTACT hContact, int dtb, int age) { - if (commonData.bIgnoreSubcontacts) { - MCONTACT hMetacontact = db_mc_getMeta(hContact); - if (hMetacontact && hMetacontact != hContact) //not main metacontact - return 0; - } + if (commonData.bIgnoreSubcontacts && db_mc_isSub(hContact)) + return 0; TCHAR *name = pcli->pfnGetContactDisplayName(hContact, 0); @@ -109,11 +106,8 @@ int PopupNotifyBirthday(MCONTACT hContact, int dtb, int age) int PopupNotifyMissedBirthday(MCONTACT hContact, int dab, int age) { - if (commonData.bIgnoreSubcontacts) { - MCONTACT hMetacontact = db_mc_getMeta(hContact); - if (hMetacontact && hMetacontact != hContact) //not main metacontact - return 0; - } + if (commonData.bIgnoreSubcontacts && db_mc_isSub(hContact)) + return 0; TCHAR *name = pcli->pfnGetContactDisplayName(hContact, 0); diff --git a/src/core/stdfile/filerecvdlg.cpp b/src/core/stdfile/filerecvdlg.cpp index f238a91199..5bed7dbd7b 100644 --- a/src/core/stdfile/filerecvdlg.cpp +++ b/src/core/stdfile/filerecvdlg.cpp @@ -139,8 +139,7 @@ void GetContactReceivedFilesDir(MCONTACT hContact, TCHAR *szDir, int cchDir, BOO mir_sntprintf(tszTemp, SIZEOF(tszTemp), _T("%%mydocuments%%\\%s\\%%userid%%"), TranslateT("My received files")); if (hContact) { - if (db_mc_isSub(hContact)) - hContact = db_mc_getMeta(hContact); + hContact = db_mc_tryMeta(hContact); REPLACEVARSDATA dat = { 0 }; REPLACEVARSARRAY rvaVarsToReplace[4]; diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp index 50ac6ae753..66c8f739cb 100644 --- a/src/core/stdmsg/src/msgs.cpp +++ b/src/core/stdmsg/src/msgs.cpp @@ -108,8 +108,7 @@ INT_PTR SendMessageCmd(MCONTACT hContact, char* msg, int isWchar) if (!szProto || (!CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND)) return 1; - if (db_mc_isSub(hContact)) - hContact = db_mc_getMeta(hContact); + hContact = db_mc_tryMeta(hContact); HWND hwnd; if (hwnd = WindowList_Find(g_dat.hMessageWindowList, hContact)) { @@ -160,8 +159,7 @@ static int TypingMessage(WPARAM hContact, LPARAM lParam) if (!(g_dat.flags & SMF_SHOWTYPING)) return 0; - if (db_mc_isSub(hContact)) - hContact = db_mc_getMeta(hContact); + hContact = db_mc_tryMeta(hContact); SkinPlaySound((lParam) ? "TNStart" : "TNStop"); -- cgit v1.2.3