diff options
Diffstat (limited to 'meta2/core_functions.cpp')
-rw-r--r-- | meta2/core_functions.cpp | 32 |
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())
|