From 8c7fd7f3d5ac0a5e71830342df5f55a5660faa98 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 15 Mar 2014 19:15:23 +0000 Subject: - srmm icon added for metacontacts; - wipe out the rest of srmm related clutches from mc git-svn-id: http://svn.miranda-ng.org/main/trunk@8631 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/clist/protocolorder.cpp | 2 +- src/modules/metacontacts/meta_main.cpp | 1 - src/modules/metacontacts/meta_services.cpp | 26 +++++------- src/modules/metacontacts/meta_utils.cpp | 65 +++++++++++++++--------------- src/modules/metacontacts/metacontacts.h | 1 + 5 files changed, 45 insertions(+), 50 deletions(-) (limited to 'src/modules') diff --git a/src/modules/clist/protocolorder.cpp b/src/modules/clist/protocolorder.cpp index a6d45fdc94..c8e91ac07c 100644 --- a/src/modules/clist/protocolorder.cpp +++ b/src/modules/clist/protocolorder.cpp @@ -201,7 +201,7 @@ INT_PTR CALLBACK ProtocolOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM while (idx < accounts.getCount() && !ProtoToInclude(accounts[idx])) idx++; pa->iOrder = idx++; if (ppd->enabled) - pa->bIsVisible = ppd->show; + pa->bIsVisible = ppd->show != 0; } } diff --git a/src/modules/metacontacts/meta_main.cpp b/src/modules/metacontacts/meta_main.cpp index e550c329c7..c031e6ce77 100644 --- a/src/modules/metacontacts/meta_main.cpp +++ b/src/modules/metacontacts/meta_main.cpp @@ -62,7 +62,6 @@ int LoadMetacontacts(void) db_set_resident(META_PROTO, "Status"); db_set_resident(META_PROTO, "IdleTS"); - db_set_resident(META_PROTO, "WindowOpen"); //set all contacts to 'offline', and initialize subcontact counter for db consistency check for (MCONTACT hContact = db_find_first(META_PROTO); hContact; hContact = db_find_next(hContact, META_PROTO)) { diff --git a/src/modules/metacontacts/meta_services.cpp b/src/modules/metacontacts/meta_services.cpp index 3ed877f6e6..7ee5556559 100644 --- a/src/modules/metacontacts/meta_services.cpp +++ b/src/modules/metacontacts/meta_services.cpp @@ -554,23 +554,12 @@ int Meta_UserInfo(WPARAM wParam, LPARAM hMeta) int Meta_MessageWindowEvent(WPARAM wParam, LPARAM lParam) { MessageWindowEventData *mwed = (MessageWindowEventData *)lParam; - - DBCachedContact *cc = currDb->m_cache->GetCachedContact(mwed->hContact); - if (cc == NULL) + if (mwed->uType != MSG_WINDOW_EVT_OPEN) return 0; - if (cc->IsMeta() || cc->IsSub()) { - // contact is subcontact of metacontact, or an actual metacontact - record whether window is open or closed - if (mwed->uType == MSG_WINDOW_EVT_OPEN || mwed->uType == MSG_WINDOW_EVT_OPENING) { - db_set_b(mwed->hContact, META_PROTO, "WindowOpen", 1); - - if (cc->IsSub()) // subcontact window opened - remove clist events we added for metacontact - while (!CallService(MS_CLIST_REMOVEEVENT, cc->parentID, mwed->hContact)); - } - else if (mwed->uType == MSG_WINDOW_EVT_CLOSE || mwed->uType == MSG_WINDOW_EVT_CLOSING) - db_set_b(mwed->hContact, META_PROTO, "WindowOpen", 0); - } - + DBCachedContact *cc = currDb->m_cache->GetCachedContact(mwed->hContact); + if (cc != NULL && cc->IsMeta()) + Meta_UpdateSrmmIcon(cc, db_get_w(cc->contactID, META_PROTO, "Status", ID_STATUS_OFFLINE)); return 0; } @@ -610,7 +599,12 @@ int Meta_ModulesLoaded(WPARAM wParam, LPARAM lParam) //////////////////////////////////////////////////////////////////////////// InitMenus(); - // hook srmm window close/open events - message api ver 0.0.0.1+ + // create srmm icon + StatusIconData sid = { sizeof(sid) }; + sid.szModule = META_PROTO; + Srmm_AddIcon(&sid); + + // hook srmm window close/open events HookEvent(ME_MSG_WINDOWEVENT, Meta_MessageWindowEvent); // hook protocol nudge events to forward to subcontacts diff --git a/src/modules/metacontacts/meta_utils.cpp b/src/modules/metacontacts/meta_utils.cpp index a30442c6ec..8429fec83f 100644 --- a/src/modules/metacontacts/meta_utils.cpp +++ b/src/modules/metacontacts/meta_utils.cpp @@ -235,37 +235,17 @@ MCONTACT Meta_GetMostOnline(DBCachedContact *cc) MCONTACT Meta_GetMostOnlineSupporting(DBCachedContact *cc, int pflagnum, unsigned long capability) { if (cc == NULL || cc->nDefault == -1) - return 0; - - int most_online_status = ID_STATUS_OFFLINE; - MCONTACT hContact; - int i; + return NULL; // if the default is beyond the end of the list (eek!) return null if (cc->nDefault >= cc->nSubs) return NULL; + int most_online_status = ID_STATUS_OFFLINE; MCONTACT most_online_contact = Meta_GetContactHandle(cc, cc->nDefault); char *szProto = GetContactProto(most_online_contact); - DWORD caps = szProto ? CallProtoService(szProto, PS_GETCAPS, pflagnum, 0) : 0; - if (szProto && strcmp(szProto, "IRC") == 0) caps |= PF1_IM; - // we are forced to do use default for sending - '-1' capability indicates no specific capability, but respect 'Force Default' - if (szProto && db_get_b(cc->contactID, META_PROTO, "ForceDefault", 0) && capability != 0 && (capability == -1 || (caps & capability) == capability)) // capability is 0 when we're working out status - return most_online_contact; - - // a subcontact is being temporarily 'forced' to do sending - if ((most_online_contact = db_get_dw(cc->contactID, META_PROTO, "ForceSend", 0))) { - caps = szProto ? CallProtoService(szProto, PS_GETCAPS, pflagnum, 0) : 0; - if (szProto && strcmp(szProto, "IRC") == 0) caps |= PF1_IM; - if (szProto && (caps & capability) == capability && capability != 0) // capability is 0 when we're working out status - return most_online_contact; - } - - most_online_contact = Meta_GetContactHandle(cc, cc->nDefault); - szProto = GetContactProto(most_online_contact); if (szProto && CallProtoService(szProto, PS_GETSTATUS, 0, 0) >= ID_STATUS_ONLINE) { - caps = szProto ? CallProtoService(szProto, PS_GETCAPS, pflagnum, 0) : 0; - if (szProto && strcmp(szProto, "IRC") == 0) caps |= PF1_IM; + DWORD caps = szProto ? CallProtoService(szProto, PS_GETCAPS, pflagnum, 0) : 0; if (szProto && (capability == -1 || (caps & capability) == capability)) { most_online_status = db_get_w(most_online_contact, szProto, "Status", ID_STATUS_OFFLINE); @@ -280,18 +260,17 @@ MCONTACT Meta_GetMostOnlineSupporting(DBCachedContact *cc, int pflagnum, unsigne char *most_online_proto = szProto; // otherwise, check all the subcontacts for the one closest to the ONLINE state which supports the required capability - for (i = 0; i < cc->nSubs; i++) { + for (int i = 0; i < cc->nSubs; i++) { if (i == cc->nDefault) // already checked that (i.e. initial value of most_online_contact and most_online_status are those of the default contact) continue; - hContact = Meta_GetContactHandle(cc, i); + MCONTACT hContact = Meta_GetContactHandle(cc, i); szProto = GetContactProto(hContact); if (!szProto || CallProtoService(szProto, PS_GETSTATUS, 0, 0) < ID_STATUS_ONLINE) // szProto offline or connecting continue; - caps = szProto ? CallProtoService(szProto, PS_GETCAPS, pflagnum, 0) : 0; - if (szProto && strcmp(szProto, "IRC") == 0) caps |= PF1_IM; + DWORD caps = szProto ? CallProtoService(szProto, PS_GETCAPS, pflagnum, 0) : 0; if (szProto && (capability == -1 || (caps & capability) == capability)) { int status = db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE); if (status == ID_STATUS_ONLINE) { @@ -567,14 +546,36 @@ INT_PTR CALLBACK DlgProcNull(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara void Meta_FixStatus(DBCachedContact *ccMeta) { + WORD status = ID_STATUS_OFFLINE; + MCONTACT most_online = Meta_GetMostOnlineSupporting(ccMeta, PFLAGNUM_1, 0); if (most_online) { char *szProto = GetContactProto(most_online); + if (szProto) + status = db_get_w(most_online, szProto, "Status", ID_STATUS_OFFLINE); + } + + db_set_w(ccMeta->contactID, META_PROTO, "Status", status); + Meta_UpdateSrmmIcon(ccMeta, status); +} + +void Meta_UpdateSrmmIcon(DBCachedContact *ccMeta, int iStatus) +{ + StatusIconData sid = { sizeof(sid) }; + sid.szModule = META_PROTO; + sid.flags = MBF_HIDDEN; + if (ccMeta->IsMeta()) { + MCONTACT hSub = Meta_GetMostOnline(ccMeta); + char *szProto = GetContactProto(hSub); if (szProto) { - WORD status = db_get_w(most_online, szProto, "Status", ID_STATUS_OFFLINE); - db_set_w(ccMeta->contactID, META_PROTO, "Status", status); + sid.hIcon = LoadSkinnedProtoIcon(szProto, iStatus); + + PROTOACCOUNT *pa = Proto_GetAccount(szProto); + if (pa) { + sid.flags = MBF_TCHAR; + sid.tszTooltip = pa->tszAccountName; + } } - else db_set_w(ccMeta->contactID, META_PROTO, "Status", ID_STATUS_OFFLINE); } - else db_set_w(ccMeta->contactID, META_PROTO, "Status", ID_STATUS_OFFLINE); -} + Srmm_ModifyIcon(ccMeta->contactID, &sid); +} \ No newline at end of file diff --git a/src/modules/metacontacts/metacontacts.h b/src/modules/metacontacts/metacontacts.h index b8d9b10921..d550740242 100644 --- a/src/modules/metacontacts/metacontacts.h +++ b/src/modules/metacontacts/metacontacts.h @@ -55,6 +55,7 @@ DBCachedContact* CheckMeta(MCONTACT hMeta); // function to copy history from one contact to another - courtesy JdGordon with mods (thx) void Meta_FixStatus(DBCachedContact *ccMeta); +void Meta_UpdateSrmmIcon(DBCachedContact *ccMeta, int iStatus); char *Meta_GetUniqueIdentifier(MCONTACT hContact, DWORD *pused); -- cgit v1.2.3