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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
/*
former MetaContacts Plugin for Miranda IM.
Copyright © 2014 Miranda NG Team
Copyright © 2004-07 Scott Ellis
Copyright © 2004 Universite Louis PASTEUR, STRASBOURG.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "..\..\core\commonheaders.h"
#include "metacontacts.h"
//gets the handle for the default contact
//wParam=(MCONTACT)hMetaContact
//lParam=0
//returns a handle to the default contact, or null on failure
INT_PTR MetaAPI_GetDefault(WPARAM hMetaContact, LPARAM)
{
DBCachedContact *cc = CheckMeta(hMetaContact);
if (cc == NULL)
return 1;
if (cc->nDefault != -1)
return Meta_GetContactHandle(cc, cc->nDefault);
return 0;
}
//gets the contact number for the default contact
//wParam=(MCONTACT)hMetaContact
//lParam=0
//returns a DWORD contact number, or -1 on failure
INT_PTR MetaAPI_GetDefaultNum(WPARAM hMetaContact, LPARAM)
{
DBCachedContact *cc = CheckMeta(hMetaContact);
return (cc == NULL) ? -1 : cc->nDefault;
}
//gets the handle for the 'most online' contact
//wParam=(MCONTACT)hMetaContact
//lParam=0
//returns a handle to the 'most online' contact
INT_PTR MetaAPI_GetMostOnline(WPARAM hMetaContact, LPARAM)
{
DBCachedContact *cc = CheckMeta(hMetaContact);
if (cc == NULL)
return 1;
return Meta_GetMostOnline(cc);
}
//gets the number of subcontacts for a metacontact
//wParam=(MCONTACT)hMetaContact
//lParam=0
//returns a DWORD representing the number of subcontacts for the given metacontact
INT_PTR MetaAPI_GetNumContacts(WPARAM hMetaContact, LPARAM)
{
DBCachedContact *cc = CheckMeta(hMetaContact);
return (cc == NULL) ? -1 : cc->nSubs;
}
//gets the handle of a subcontact, using the subcontact's number
//wParam=(MCONTACT)hMetaContact
//lParam=(DWORD)contact number
//returns a handle to the specified subcontact
INT_PTR MetaAPI_GetContact(WPARAM hMetaContact, LPARAM lParam)
{
DBCachedContact *cc = CheckMeta(hMetaContact);
return (cc == NULL) ? 0 : Meta_GetContactHandle(cc, lParam);
}
//sets the default contact, using the subcontact's contact number
//wParam=(MCONTACT)hMetaContact
//lParam=(DWORD)contact number
//returns 0 on success
INT_PTR MetaAPI_SetDefaultContactNum(WPARAM hMetaContact, LPARAM lParam)
{
DBCachedContact *cc = CheckMeta(hMetaContact);
if (cc == NULL)
return 1;
if ((int)lParam >= cc->nSubs || (int)lParam < 0)
return 1;
cc->nDefault = lParam;
currDb->MetaSetDefault(cc);
NotifyEventHooks(hEventDefaultChanged, hMetaContact, Meta_GetContactHandle(cc, (int)lParam));
return 0;
}
//sets the default contact, using the subcontact's handle
//wParam=(MCONTACT)hMetaContact
//lParam=(MCONTACT)hSubcontact
//returns 0 on success
INT_PTR MetaAPI_SetDefaultContact(WPARAM hMetaContact, LPARAM lParam)
{
DBCachedContact *cc = CheckMeta(lParam);
if (cc == NULL)
return 1;
int contact_number = Meta_GetContactNumber(cc, lParam);
if (contact_number == -1)
return 1;
cc->nDefault = contact_number;
currDb->MetaSetDefault(cc);
NotifyEventHooks(hEventDefaultChanged, hMetaContact, lParam);
return 0;
}
//forces the metacontact to send using a specific subcontact, using the subcontact's contact number
//wParam=(MCONTACT)hMetaContact
//lParam=(DWORD)contact number
//returns 0 on success
INT_PTR MetaAPI_ForceSendContactNum(WPARAM hMetaContact, LPARAM lParam)
{
DBCachedContact *cc = CheckMeta(hMetaContact);
if (cc == NULL)
return 1;
MCONTACT hContact = Meta_GetContactHandle(cc, (int)lParam);
if (!hContact || db_get_b(cc->contactID, META_PROTO, "ForceDefault", 0))
return 1;
db_set_dw(cc->contactID, META_PROTO, "ForceSend", hContact);
NotifyEventHooks(hEventForceSend, hMetaContact, hContact);
return 0;
}
//forces the metacontact to send using a specific subcontact, using the subcontact's handle
//wParam=(MCONTACT)hMetaContact
//lParam=(MCONTACT)hSubcontact
//returns 0 on success (will fail if 'force default' is in effect)
INT_PTR MetaAPI_ForceSendContact(WPARAM hMetaContact, LPARAM lParam)
{
DBCachedContact *cc = CheckMeta(hMetaContact);
if (cc == NULL)
return 1;
if (Meta_GetContactNumber(cc, lParam) == -1)
return 1;
if (!db_get_b(cc->contactID, META_PROTO, "ForceDefault", 0))
return 1;
db_set_dw(cc->contactID, META_PROTO, "ForceSend", lParam);
NotifyEventHooks(hEventForceSend, hMetaContact, lParam);
return 0;
}
//'unforces' the metacontact to send using a specific subcontact
//wParam=(MCONTACT)hMetaContact
//lParam=0
//returns 0 on success (will fail if 'force default' is in effect)
INT_PTR MetaAPI_UnforceSendContact(WPARAM hMetaContact, LPARAM lParam)
{
if (db_get_b(hMetaContact, META_PROTO, "ForceDefault", 0))
return 1;
db_set_dw(hMetaContact, META_PROTO, "ForceSend", 0);
NotifyEventHooks(hEventUnforceSend, hMetaContact, lParam);
return 0;
}
//'forces' or 'unforces' (i.e. toggles) the metacontact to send using it's default contact
// overrides 'force send' above, and will even force use of offline contacts
// will send ME_MC_FORCESEND event
//wParam=(MCONTACT)hMetaContact
//lParam=0
//returns 1(true) or 0(false) representing new state of 'force default'
INT_PTR MetaAPI_ForceDefault(WPARAM hMetaContact, LPARAM lParam)
{
// forward to menu function
Meta_ForceDefault(hMetaContact, lParam);
return db_get_b(hMetaContact, META_PROTO, "ForceDefault", 0);
}
// method to get state of 'force' for a metacontact
// wParam=(MCONTACT)hMetaContact
// lParam= (DWORD)&contact_number or NULL
// if lparam supplied, the contact_number of the contatct 'in force' will be copied to the address it points to,
// or if none is in force, the value INVALID_CONTACT_ID will be copied
// (v0.8.0.8+ returns 1 if 'force default' is true with *lParam == default contact number, else returns 0 with *lParam as above)
INT_PTR MetaAPI_GetForceState(WPARAM hMetaContact, LPARAM lParam)
{
DBCachedContact *cc = CheckMeta(hMetaContact);
if (cc == NULL)
return 0;
if (db_get_b(hMetaContact, META_PROTO, "ForceDefault", 0)) {
if (lParam) *(DWORD *)lParam = cc->nDefault;
return 1;
}
MCONTACT hContact = (MCONTACT)db_get_dw(hMetaContact, META_PROTO, "ForceSend", 0);
if (!hContact) {
if (lParam) *(DWORD *)lParam = -1;
}
else {
if (lParam) *(DWORD *)lParam = (DWORD)Meta_GetContactNumber(cc, hContact);
}
return 0;
}
// added 0.9.5.0 (22/3/05)
// wParam=(HANDLE)hContact
// lParam=0
// convert a given contact into a metacontact
INT_PTR MetaAPI_ConvertToMeta(WPARAM wParam, LPARAM lParam)
{
return Meta_Convert(wParam, lParam);
}
// added 0.9.5.0 (22/3/05)
// wParam=(HANDLE)hContact
// lParam=(HANDLE)hMeta
// add an existing contact to a metacontact
INT_PTR MetaAPI_AddToMeta(WPARAM wParam, LPARAM lParam)
{
return Meta_Assign(wParam, lParam, FALSE);
}
// added 0.9.5.0 (22/3/05)
// wParam=0
// lParam=(HANDLE)hContact
// remove a contact from a metacontact
INT_PTR MetaAPI_RemoveFromMeta(WPARAM wParam, LPARAM lParam)
{
// notice we switch args - to keep the API function consistent with the others
return Meta_Delete((WPARAM)lParam, (LPARAM)wParam);
}
|