summaryrefslogtreecommitdiff
path: root/plugins/SecureIM/src/crypt_metacontacts.cpp
blob: a874f5bb1c5650e21c72d8b5dceb519a8f3d2311 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "commonheaders.h"

BOOL isProtoMetaContacts(MCONTACT hContact)
{
	LPSTR proto = GetContactProto(hContact);
	if (proto && !strcmp(proto,"MetaContacts"))
		return true;
	return false;
}

BOOL isDefaultSubContact(MCONTACT hContact)
{
	return db_mc_getDefault(db_mc_getMeta(hContact)) == hContact;
}

MCONTACT getMostOnline(MCONTACT hContact)
{
	return (MCONTACT)CallService(MS_MC_GETMOSTONLINECONTACT, hContact, 0);
}

// remove all secureim connections on subcontacts
void DeinitMetaContact(MCONTACT hContact)
{
	MCONTACT hMetaContact = isProtoMetaContacts(hContact) ? hContact : db_mc_getMeta(hContact);
 	if (hMetaContact) {
		for (int i=0; i < db_mc_getSubCount(hMetaContact); i++) {
			MCONTACT hSubContact = db_mc_getSub(hMetaContact, i);
			if (hSubContact && (isContactSecured(hSubContact)&SECURED))
				CallContactService(hSubContact,PSS_MESSAGE, PREF_METANODB, (LPARAM)SIG_DEIN);
		}
	}
}

// EOF