summaryrefslogtreecommitdiff
path: root/plugins/SecureIM/src/crypt_metacontacts.cpp
blob: d78f4adc490c39bb3cf48090bfe860a50e1069b9 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "commonheaders.h"


BOOL isProtoMetaContacts(HANDLE hContact) {
    if (bMetaContacts) {
    	LPSTR proto = GetContactProto(hContact);
    	if ( proto && strcmp(proto,"MetaContacts")==0 ) {
    		return true;
    	}
    }
//    for(int j=0;j<clist_cnt;j++)
//	if (clist[j].hContact==hContact && clist[j].proto->inspecting)
//	    return strstr(clist[j].proto->name,"MetaContacts")!=NULL;
    return false;
}


BOOL isDefaultSubContact(HANDLE hContact) {

    if (bMetaContacts) {
	return (HANDLE)CallService(MS_MC_GETDEFAULTCONTACT,(WPARAM)CallService(MS_MC_GETMETACONTACT,(WPARAM)hContact,0),0)==hContact;
    }
    return false;
}


HANDLE getMetaContact(HANDLE hContact) {

    if (bMetaContacts) {
	return (HANDLE)CallService(MS_MC_GETMETACONTACT,(WPARAM)hContact,0);
    }
    return 0;
}


HANDLE getMostOnline(HANDLE hContact) {

    if (bMetaContacts) {
	return (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT,(WPARAM)hContact,0);
    }
    return 0;
}


// remove all secureim connections on subcontacts
void DeinitMetaContact(HANDLE hContact) {

	HANDLE hMetaContact = isProtoMetaContacts(hContact) ? hContact : getMetaContact(hContact);

	if ( hMetaContact ) {
		for(int i=0;i<CallService(MS_MC_GETNUMCONTACTS,(WPARAM)hMetaContact,0);i++) {
			HANDLE hSubContact = (HANDLE)CallService(MS_MC_GETSUBCONTACT,(WPARAM)hMetaContact,(LPARAM)i);
			if ( hSubContact && isContactSecured(hSubContact)&SECURED ) {
				CallContactService(hSubContact,PSS_MESSAGE,(WPARAM)PREF_METANODB,(LPARAM)SIG_DEIN);
			}
		}
	}
}

// EOF