From f99d18dd83625a753a7171e807b404345b11de4d Mon Sep 17 00:00:00 2001 From: sje Date: Wed, 3 Oct 2007 08:03:17 +0000 Subject: fix major bug in 'get most online supporting cap' function notify of subcontact change on any subcontact status change calculate subcontacts and meta status after modules loaded use meta map for contact count git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@342 4f64403b-2f21-0410-a795-97e2b3489a10 --- meta2/core_functions.cpp | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'meta2/core_functions.cpp') diff --git a/meta2/core_functions.cpp b/meta2/core_functions.cpp index aba22c0..748fddc 100644 --- a/meta2/core_functions.cpp +++ b/meta2/core_functions.cpp @@ -45,21 +45,33 @@ HANDLE Meta_GetMostOnlineSupporting(HANDLE hMeta, int flag, int cap) { HANDLE most_online = (HANDLE)MetaAPI_GetDefault((WPARAM)hMeta, 0); char *most_online_proto = ContactProto(most_online); - int most_online_status = ContactStatus(most_online, most_online_proto); - int most_online_prio = GetRealPriority(most_online_proto, most_online_status); + int most_online_status = ID_STATUS_OFFLINE, + most_online_prio = MAX_PRIORITY; + if(most_online_proto) { + char szService[256]; + mir_snprintf(szService, sizeof(szService), "%s%s", most_online_proto, PS_GETCAPS); + if(CallService(szService, (WPARAM)flag, (LPARAM)0) & cap) { + most_online_status = ContactStatus(most_online, most_online_proto); + most_online_prio = GetRealPriority(most_online_proto, most_online_status); + } + } char *proto; int status, prio; SubcontactList::Iterator i = metaMap[hMeta].start(); while(i.has_val()) { proto = ContactProto(i.val().handle()); - if(proto && (CallContactService(i.val().handle(), PS_GETCAPS, flag, 0) & cap)) { - status = ContactStatus(i.val().handle(), proto); - if((prio = GetRealPriority(proto, status)) < most_online_prio) { - most_online_status = status; - most_online = i.val().handle(); - most_online_proto = proto; - most_online_prio = prio; + if(proto) { + char szService[256]; + mir_snprintf(szService, sizeof(szService), "%s%s", proto, PS_GETCAPS); + if(CallService(szService, (WPARAM)flag, 0) & cap) { + status = ContactStatus(i.val().handle(), proto); + if((prio = GetRealPriority(proto, status)) < most_online_prio) { + most_online_status = status; + most_online = i.val().handle(); + most_online_proto = proto; + most_online_prio = prio; + } } } i.next(); @@ -72,6 +84,7 @@ void Meta_CalcStatus(HANDLE hMeta) { HANDLE hSub = Meta_GetMostOnline(hMeta); char *proto = ContactProto(hSub); DBWriteContactSettingWord(hMeta, MODULE, "Status", ContactStatus(hSub, proto)); + FireSubcontactsChanged(hMeta); } HANDLE Meta_Convert(HANDLE hSub) { @@ -128,6 +141,7 @@ void Meta_Remove(HANDLE hSub) { metaMap[hMeta].remove(hSub); if(metaMap[hMeta].size() == 0) { CallService(MS_DB_CONTACT_DELETE, (WPARAM)hMeta, 0); + metaMap.remove(hMeta); } else { int def = DBGetContactSettingByte(hMeta, MODULE, "Default", -1); if(def < 0 || def >= metaMap[hMeta].size()) -- cgit v1.2.3