summaryrefslogtreecommitdiff
path: root/libpurple/plugins/perl/common/BuddyList.xs
blob: 518dd3a2bfe3e77de4ea6590d49dbe9933886b12 (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
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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
#undef PURPLE_DISABLE_DEPRECATED
#include "module.h"
#include "../perl-handlers.h"

static void
chat_components_foreach(gpointer key, gpointer value, gpointer user_data)
{
	HV *hv = user_data;
	if (hv_store(hv, key, strlen(key), newSVpv(value, 0), 0) == NULL)
		purple_debug_error("perl", "hv_store failed\n");
}

MODULE = Purple::BuddyList  PACKAGE = Purple::Find  PREFIX = purple_
PROTOTYPES: ENABLE

gboolean
purple_group_on_account(group, account)
	Purple::BuddyList::Group  group
	Purple::Account account

MODULE = Purple::BuddyList  PACKAGE = Purple::BuddyList::Contact  PREFIX = purple_contact_
PROTOTYPES: ENABLE

Purple::BuddyList::Contact
purple_contact_new();

Purple::BuddyList::Buddy
purple_contact_get_priority_buddy(contact)
	Purple::BuddyList::Contact contact

const char *
purple_contact_get_alias(contact)
	Purple::BuddyList::Contact contact

gboolean
purple_contact_on_account(contact, account)
	Purple::BuddyList::Contact contact
	Purple::Account account

void
purple_contact_invalidate_priority_buddy(contact)
	Purple::BuddyList::Contact contact

void
purple_contact_merge(source, node)
	Purple::BuddyList::Contact source
	Purple::BuddyList::Node node

MODULE = Purple::BuddyList  PACKAGE = Purple::BuddyList::Group  PREFIX = purple_group_
PROTOTYPES: ENABLE

Purple::BuddyList::Group
purple_group_new(name)
	const char *name

void
purple_group_get_accounts(group)
	Purple::BuddyList::Group  group
PREINIT:
	GSList *l, *ll;
PPCODE:
	ll = purple_group_get_accounts(group);
	for (l = ll; l != NULL; l = l->next) {
		XPUSHs(sv_2mortal(purple_perl_bless_object(l->data, "Purple::Account")));
	}
	g_slist_free(ll);

gboolean
purple_group_on_account(group, account)
	Purple::BuddyList::Group  group
	Purple::Account account

void
purple_group_set_name(group, name)
	Purple::BuddyList::Group  group
	const char * name

const char *
purple_group_get_name(group)
	Purple::BuddyList::Group group

MODULE = Purple::BuddyList  PACKAGE = Purple::BuddyList  PREFIX = purple_blist_
PROTOTYPES: ENABLE

Purple::BuddyList
purple_blist_get_buddy_list()

Purple::BuddyList::Buddy
purple_blist_find_buddy(account, name)
	Purple::Account account
	const char * name

void
purple_blist_find_buddies(account, name)
	Purple::Account account
	const char * name
PREINIT:
	GSList *l, *ll;
PPCODE:
	ll = purple_blist_find_buddies(account, name);
	for (l = ll; l != NULL; l = l->next) {
		XPUSHs(sv_2mortal(purple_perl_bless_object(l->data, "Purple::BuddyList::Buddy")));
	}
	g_slist_free(ll);

Purple::BuddyList::Group
purple_blist_find_group(name)
	const char *name

void
purple_blist_add_contact(contact, group, node)
	Purple::BuddyList::Contact contact
	Purple::BuddyList::Group  group
	Purple::BuddyList::Node node

void
purple_blist_add_group(group, node)
	Purple::BuddyList::Group  group
	Purple::BuddyList::Node node

void
purple_blist_add_buddy(buddy, contact, group, node)
	Purple::BuddyList::Buddy buddy
	Purple::BuddyList::Contact contact
	Purple::BuddyList::Group  group
	Purple::BuddyList::Node node

void
purple_blist_remove_buddy(buddy)
	Purple::BuddyList::Buddy buddy

void
purple_blist_remove_contact(contact)
	Purple::BuddyList::Contact contact

void
purple_blist_remove_chat(chat)
	Purple::BuddyList::Chat chat

void
purple_blist_remove_group(group)
	Purple::BuddyList::Group  group

Purple::BuddyList::Chat
purple_blist_find_chat(account, name)
	Purple::Account account
	const char *name

void
purple_blist_add_chat(chat, group, node)
	Purple::BuddyList::Chat chat
	Purple::BuddyList::Group  group
	Purple::BuddyList::Node node

void
purple_blist_show()

void
purple_blist_set_visible(show)
	gboolean show

void
purple_blist_add_account(account)
	Purple::Account account

void
purple_blist_remove_account(account)
	Purple::Account account

void
purple_blist_schedule_save()

void
purple_blist_request_add_group()

Purple::Handle
purple_blist_get_handle()

Purple::BuddyList::Node
purple_blist_get_root()

MODULE = Purple::BuddyList  PACKAGE = Purple::BuddyList::Node  PREFIX = purple_blist_node_
PROTOTYPES: ENABLE

void
purple_blist_node_get_extended_menu(node)
	Purple::BuddyList::Node node
PREINIT:
	GList *l, *ll;
PPCODE:
	ll = purple_blist_node_get_extended_menu(node);
	for (l = ll; l != NULL; l = l->next) {
		XPUSHs(sv_2mortal(purple_perl_bless_object(l->data, "Purple::Menu::Action")));
	}
	/* We can free the list here but the script needs to free the
	 * Purple::Menu::Action 'objects' itself. */
	g_list_free(ll);

void
purple_blist_node_set_bool(node, key, value)
	Purple::BuddyList::Node node
	const char * key
	gboolean value

gboolean
purple_blist_node_get_bool(node, key)
	Purple::BuddyList::Node node
	const char * key

void
purple_blist_node_set_int(node, key, value)
	Purple::BuddyList::Node node
	const char * key
	int value

int
purple_blist_node_get_int(node, key)
	Purple::BuddyList::Node node
	const char * key

const char *
purple_blist_node_get_string(node, key)
	Purple::BuddyList::Node node
	const char * key

void
purple_blist_node_set_transient(node, transient)
	Purple::BuddyList::Node node
	gboolean transient

gboolean
purple_blist_node_is_transient(node);
	Purple::BuddyList::Node node

void
purple_blist_node_remove_setting(node, key)
	Purple::BuddyList::Node node
	const char * key

MODULE = Purple::BuddyList  PACKAGE = Purple::BuddyList::CountingNode  PREFIX = purple_counting_node_
PROTOTYPES: ENABLE

int
purple_counting_node_get_total_size(counter);
	Purple::BuddyList::CountingNode counter

int
purple_counting_node_get_current_size(counter);
	Purple::BuddyList::CountingNode counter

int
purple_counting_node_get_online_count(counter);
	Purple::BuddyList::CountingNode counter

void
purple_counting_node_change_total_size(counter, delta);
	Purple::BuddyList::CountingNode counter
	int delta

void
purple_counting_node_change_current_size(counter, delta);
	Purple::BuddyList::CountingNode counter
	int delta

void
purple_counting_node_change_online_count(counter, delta);
	Purple::BuddyList::CountingNode counter
	int delta

void
purple_counting_node_set_total_size(counter, totalsize);
	Purple::BuddyList::CountingNode counter
	int totalsize

void
purple_counting_node_set_current_size(counter, currentsize);
	Purple::BuddyList::CountingNode counter
	int currentsize

void
purple_counting_node_set_online_count(counter, onlinecount);
	Purple::BuddyList::CountingNode counter
	int onlinecount

MODULE = Purple::BuddyList  PACKAGE = Purple::BuddyList::Chat  PREFIX = purple_chat_
PROTOTYPES: ENABLE

Purple::BuddyList::Group
purple_chat_get_group(chat)
	Purple::BuddyList::Chat chat

void
purple_chat_set_alias(chat, alias)
	Purple::BuddyList::Chat chat
	const char * alias

const char *
purple_chat_get_name(chat)
	Purple::BuddyList::Chat chat

const char *
purple_chat_get_name_only(chat)
	Purple::BuddyList::Chat chat

HV *
purple_chat_get_components(chat)
	Purple::BuddyList::Chat chat
INIT:
	HV * t_HV;
	GHashTable * t_GHash;
CODE:
	t_GHash = purple_chat_get_components(chat);
	RETVAL = t_HV = newHV();
	g_hash_table_foreach(t_GHash, chat_components_foreach, t_HV);
OUTPUT:
	RETVAL

Purple::BuddyList::Chat
purple_chat_new(account, alias, components)
	Purple::Account account
	const char * alias
	SV * components
INIT:
	HV * t_HV;
	HE * t_HE;
	SV * t_SV;
	GHashTable * t_GHash;
	I32 len;
	char *t_key, *t_value;
CODE:
	t_HV =  (HV *)SvRV(components);
	t_GHash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);

	for (t_HE = hv_iternext(t_HV); t_HE != NULL; t_HE = hv_iternext(t_HV) ) {
		t_key = hv_iterkey(t_HE, &len);
		t_SV = *hv_fetch(t_HV, t_key, len, 0);
		t_value = SvPVutf8_nolen(t_SV);

		g_hash_table_insert(t_GHash, g_strdup(t_key), g_strdup(t_value));
	}

	RETVAL = purple_chat_new(account, alias, t_GHash);
OUTPUT:
	RETVAL

MODULE = Purple::BuddyList  PACKAGE = Purple::BuddyList::Buddy  PREFIX = purple_buddy_
PROTOTYPES: ENABLE

Purple::BuddyList::Buddy
purple_buddy_new(account, name, alias)
	Purple::Account account
	const char *name
	const char *alias

void
purple_buddy_update_status(buddy, old_status)
	Purple::BuddyList::Buddy buddy
	Purple::Status old_status

void
purple_buddy_set_name(buddy, name)
	Purple::BuddyList::Buddy buddy
	const char * name

void
purple_buddy_set_local_alias(buddy, alias)
	Purple::BuddyList::Buddy buddy
	const char * alias

void
purple_buddy_set_server_alias(buddy, alias)
	Purple::BuddyList::Buddy buddy
	const char * alias

const char *
purple_buddy_get_server_alias(buddy)
    Purple::BuddyList::Buddy buddy

void
purple_buddy_set_icon(buddy, icon)
	Purple::BuddyList::Buddy buddy
	Purple::Buddy::Icon icon

Purple::Account
purple_buddy_get_account(buddy)
	Purple::BuddyList::Buddy buddy

Purple::BuddyList::Group
purple_buddy_get_group(buddy)
	Purple::BuddyList::Buddy buddy

const char *
purple_buddy_get_name(buddy)
	Purple::BuddyList::Buddy buddy

Purple::Buddy::Icon
purple_buddy_get_icon(buddy)
	Purple::BuddyList::Buddy buddy

Purple::BuddyList::Contact
purple_buddy_get_contact(buddy)
	Purple::BuddyList::Buddy buddy

Purple::Presence
purple_buddy_get_presence(buddy)
	Purple::BuddyList::Buddy buddy

const char *
purple_buddy_get_alias_only(buddy)
	Purple::BuddyList::Buddy buddy

const char *
purple_buddy_get_contact_alias(buddy)
	Purple::BuddyList::Buddy buddy

const char *
purple_buddy_get_alias(buddy)
	Purple::BuddyList::Buddy buddy