summaryrefslogtreecommitdiff
path: root/meta2/core_functions.cpp
diff options
context:
space:
mode:
authorsje <sje@4f64403b-2f21-0410-a795-97e2b3489a10>2007-10-03 08:03:17 +0000
committersje <sje@4f64403b-2f21-0410-a795-97e2b3489a10>2007-10-03 08:03:17 +0000
commitf99d18dd83625a753a7171e807b404345b11de4d (patch)
tree3e05a5a78611fb447951ed800355bd335c1b2b2c /meta2/core_functions.cpp
parente52098965bc45872cff2d99147b0c27769c146f0 (diff)
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
Diffstat (limited to 'meta2/core_functions.cpp')
-rw-r--r--meta2/core_functions.cpp32
1 files changed, 23 insertions, 9 deletions
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())