summaryrefslogtreecommitdiff
path: root/libpurple/plugins/perl/common/Conversation.xs
blob: e8e2114b9b448348e70c063cd65b61f0d8d0faca (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
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
#include "module.h"

MODULE = Purple::Conversation  PACKAGE = Purple  PREFIX = purple_
PROTOTYPES: ENABLE

BOOT:
{
	HV *type_stash = gv_stashpv("Purple::Conversation::Type", 1);
	HV *update_stash = gv_stashpv("Purple::Conversation::Update::Type", 1);
	HV *typing_stash = gv_stashpv("Purple::Conversation::TypingState", 1);
	HV *flags_stash = gv_stashpv("Purple::Conversation::Flags", 1);
	HV *cbflags_stash = gv_stashpv("Purple::Conversation::ChatBuddy::Flags", 1);

	static const constiv *civ, type_const_iv[] = {
#define const_iv(name) {#name, (IV)PURPLE_CONV_TYPE_##name}
		const_iv(UNKNOWN),
		const_iv(IM),
		const_iv(CHAT),
		const_iv(MISC),
		const_iv(ANY),
	};
	static const constiv update_const_iv[] = {
#undef const_iv
#define const_iv(name) {#name, (IV)PURPLE_CONV_UPDATE_##name}
		const_iv(ADD),
		const_iv(REMOVE),
		const_iv(ACCOUNT),
		const_iv(TYPING),
		const_iv(UNSEEN),
		const_iv(LOGGING),
		const_iv(TOPIC),
/*
		const_iv(ONLINE),
		const_iv(OFFLINE),
*/
		const_iv(AWAY),
		const_iv(ICON),
		const_iv(TITLE),
		const_iv(CHATLEFT),
		const_iv(FEATURES),
	};
	static const constiv typing_const_iv[] = {
#undef const_iv
#define const_iv(name) {#name, (IV)PURPLE_##name}
		const_iv(NOT_TYPING),
		const_iv(TYPING),
		const_iv(TYPED),
	};
	static const constiv flags_const_iv[] = {
#undef const_iv
#define const_iv(name) {#name, (IV)PURPLE_MESSAGE_##name}
		const_iv(SEND),
		const_iv(RECV),
		const_iv(SYSTEM),
		const_iv(AUTO_RESP),
		const_iv(ACTIVE_ONLY),
		const_iv(NICK),
		const_iv(NO_LOG),
		const_iv(WHISPER),
		const_iv(ERROR),
		const_iv(DELAYED),
		const_iv(RAW),
		const_iv(IMAGES),
		const_iv(NOTIFY),
		const_iv(NO_LINKIFY),
	};
	static const constiv cbflags_const_iv[] = {
#undef const_iv
#define const_iv(name) {#name, (IV)PURPLE_CBFLAGS_##name}
		const_iv(NONE),
		const_iv(VOICE),
		const_iv(HALFOP),
		const_iv(OP),
		const_iv(FOUNDER),
		const_iv(TYPING),
	};

	for (civ = type_const_iv + sizeof(type_const_iv) / sizeof(type_const_iv[0]); civ-- > type_const_iv; )
		newCONSTSUB(type_stash, (char *)civ->name, newSViv(civ->iv));

	for (civ = update_const_iv + sizeof(update_const_iv) / sizeof(update_const_iv[0]); civ-- > update_const_iv; )
		newCONSTSUB(update_stash, (char *)civ->name, newSViv(civ->iv));

	for (civ = typing_const_iv + sizeof(typing_const_iv) / sizeof(typing_const_iv[0]); civ-- > typing_const_iv; )
		newCONSTSUB(typing_stash, (char *)civ->name, newSViv(civ->iv));

	for (civ = flags_const_iv + sizeof(flags_const_iv) / sizeof(flags_const_iv[0]); civ-- > flags_const_iv; )
		newCONSTSUB(flags_stash, (char *)civ->name, newSViv(civ->iv));

	for (civ = cbflags_const_iv + sizeof(cbflags_const_iv) / sizeof(cbflags_const_iv[0]); civ-- > cbflags_const_iv; )
		newCONSTSUB(cbflags_stash, (char *)civ->name, newSViv(civ->iv));
}

void
purple_get_ims()
PREINIT:
	GList *l;
PPCODE:
	for (l = purple_get_ims(); l != NULL; l = l->next) {
		XPUSHs(sv_2mortal(purple_perl_bless_object(l->data, "Purple::Conversation")));
	}

void
purple_get_conversations()
PREINIT:
	GList *l;
PPCODE:
	for (l = purple_get_conversations(); l != NULL; l = l->next) {
		XPUSHs(sv_2mortal(purple_perl_bless_object(l->data, "Purple::Conversation")));
	}

void
purple_get_chats()
PREINIT:
	GList *l;
PPCODE:
	for (l = purple_get_chats(); l != NULL; l = l->next) {
		XPUSHs(sv_2mortal(purple_perl_bless_object(l->data, "Purple::Conversation")));
	}

MODULE = Purple::Conversation  PACKAGE = Purple::Conversations  PREFIX = purple_conversations_
PROTOTYPES: ENABLE

Purple::Handle
purple_conversations_get_handle()

MODULE = Purple::Conversation  PACKAGE = Purple::Conversation  PREFIX = purple_conversation_
PROTOTYPES: ENABLE

void
purple_conversation_destroy(conv)
	Purple::Conversation conv

Purple::ConversationType
purple_conversation_get_type(conv)
	Purple::Conversation conv

Purple::Account
purple_conversation_get_account(conv)
	Purple::Conversation conv

Purple::Connection
purple_conversation_get_gc(conv)
	Purple::Conversation conv

void
purple_conversation_set_title(conv, title);
	Purple::Conversation conv
	const char * title

const char *
purple_conversation_get_title(conv)
	Purple::Conversation conv

void
purple_conversation_autoset_title(conv)
	Purple::Conversation conv

void
purple_conversation_set_name(conv, name)
	Purple::Conversation conv
	const char *name

const char *
purple_conversation_get_name(conv)
	Purple::Conversation conv

void
purple_conversation_set_logging(conv, log)
	Purple::Conversation conv
	gboolean log

gboolean
purple_conversation_is_logging(conv)
	Purple::Conversation conv

Purple::Conversation::IM
purple_conversation_get_im_data(conv)
	Purple::Conversation conv

Purple::Conversation::Chat
purple_conversation_get_chat_data(conv)
	Purple::Conversation conv

gpointer
purple_conversation_get_data(conv, key)
	Purple::Conversation conv
	const char * key

Purple::ConnectionFlags
purple_conversation_get_features(conv)
	Purple::Conversation conv

gboolean
purple_conversation_has_focus(conv)
	Purple::Conversation conv

void
purple_conversation_update(conv, type)
	Purple::Conversation conv
	Purple::ConvUpdateType type

Purple::Conversation
purple_conversation_new(class, type, account, name)
	Purple::ConversationType type
	Purple::Account account
	const char *name
    C_ARGS:
	type, account, name

void
purple_conversation_set_account(conv, account);
	Purple::Conversation conv
	Purple::Account account

void
purple_conversation_write(conv, who, message, flags, mtime)
	Purple::Conversation conv
	const char *who
	const char *message
	Purple::MessageFlags flags
	time_t mtime

gboolean
purple_conversation_do_command(conv, cmdline, markup, error)
	Purple::Conversation conv
	const char *cmdline
	const char *markup
	char **error

MODULE = Purple::Conversation  PACKAGE = Purple::Conversation::IM  PREFIX = purple_conv_im_
PROTOTYPES: ENABLE

Purple::Conversation
purple_conv_im_get_conversation(im)
	Purple::Conversation::IM im

void
purple_conv_im_set_icon(im, icon)
	Purple::Conversation::IM im
	Purple::Buddy::Icon icon

Purple::Buddy::Icon
purple_conv_im_get_icon(im)
	Purple::Conversation::IM im

void
purple_conv_im_set_typing_state(im, state)
	Purple::Conversation::IM im
	Purple::TypingState state

Purple::TypingState
purple_conv_im_get_typing_state(im)
	Purple::Conversation::IM im

void
purple_conv_im_start_typing_timeout(im, timeout)
	Purple::Conversation::IM im
	int timeout

void
purple_conv_im_stop_typing_timeout(im)
	Purple::Conversation::IM im

guint
purple_conv_im_get_typing_timeout(im)
	Purple::Conversation::IM im

void
purple_conv_im_set_type_again(im, val)
	Purple::Conversation::IM im
	time_t val

time_t
purple_conv_im_get_type_again(im)
	Purple::Conversation::IM im

void
purple_conv_im_start_send_typed_timeout(im)
	Purple::Conversation::IM im

void
purple_conv_im_stop_send_typed_timeout(im)
	Purple::Conversation::IM im

guint
purple_conv_im_get_send_typed_timeout(im)
	Purple::Conversation::IM im

void
purple_conv_im_update_typing(im)
	Purple::Conversation::IM im

void
purple_conv_im_send(im, message)
	Purple::Conversation::IM im
	const char *message

void
purple_conv_im_write(im, who, message, flags, mtime)
	Purple::Conversation::IM im
	const char *who
	const char *message
	Purple::MessageFlags flags
	time_t mtime

MODULE = Purple::Conversation  PACKAGE = Purple::Conversation  PREFIX = purple_conv_
PROTOTYPES: ENABLE

gboolean
purple_conv_present_error(who, account, what)
	const char *who
	Purple::Account account
	const char *what

void
purple_conv_custom_smiley_close(conv, smile)
	Purple::Conversation conv
	const char *smile

MODULE = Purple::Conversation  PACKAGE = Purple::Conversation::Chat  PREFIX = purple_conv_chat_
PROTOTYPES: ENABLE

Purple::Conversation
purple_conv_chat_get_conversation(chat)
	Purple::Conversation::Chat chat

void
purple_conv_chat_set_users(chat, users)
	Purple::Conversation::Chat chat
	SV * users
PREINIT:
	GList *l, *t_GL;
	int i, t_len;
PPCODE:
	t_GL = NULL;
	t_len = av_len((AV *)SvRV(users)) + 1;

	for (i = 0; i < t_len; i++)
		t_GL = g_list_append(t_GL, SvPVutf8_nolen(*av_fetch((AV *)SvRV(users), i, 0)));

	for (l = purple_conv_chat_set_users(chat, t_GL); l != NULL; l = l->next) {
		XPUSHs(sv_2mortal(purple_perl_bless_object(l->data, "Purple::ListEntry")));
	}

void
purple_conv_chat_get_users(chat)
	Purple::Conversation::Chat chat
PREINIT:
	GList *l;
PPCODE:
	for (l = purple_conv_chat_get_users(chat); l != NULL; l = l->next) {
		XPUSHs(sv_2mortal(purple_perl_bless_object(l->data, "Purple::ListEntry")));
	}

void
purple_conv_chat_ignore(chat, name)
	Purple::Conversation::Chat chat
	const char *name

void
purple_conv_chat_unignore(chat, name)
	Purple::Conversation::Chat chat
	const char *name

void
purple_conv_chat_set_ignored(chat, ignored)
	Purple::Conversation::Chat chat
	SV * ignored
PREINIT:
	GList *l, *t_GL;
	int i, t_len;
PPCODE:
	t_GL = NULL;
	t_len = av_len((AV *)SvRV(ignored)) + 1;

	for (i = 0; i < t_len; i++)
		t_GL = g_list_append(t_GL, SvPVutf8_nolen(*av_fetch((AV *)SvRV(ignored), i, 0)));

	for (l = purple_conv_chat_set_ignored(chat, t_GL); l != NULL; l = l->next) {
		XPUSHs(sv_2mortal(purple_perl_bless_object(l->data, "Purple::ListEntry")));
	}

void
purple_conv_chat_get_ignored(chat)
	Purple::Conversation::Chat chat
PREINIT:
	GList *l;
PPCODE:
	for (l = purple_conv_chat_get_ignored(chat); l != NULL; l = l->next) {
		XPUSHs(sv_2mortal(purple_perl_bless_object(l->data, "Purple::ListEntry")));
	}

const char *
purple_conv_chat_get_topic(chat)
	Purple::Conversation::Chat chat

void
purple_conv_chat_set_id(chat, id)
	Purple::Conversation::Chat chat
	int id

int
purple_conv_chat_get_id(chat)
	Purple::Conversation::Chat chat

void
purple_conv_chat_send(chat, message)
	Purple::Conversation::Chat chat
	const char * message

void
purple_conv_chat_write(chat, who, message, flags, mtime)
	Purple::Conversation::Chat chat
	const char *who
	const char *message
	Purple::MessageFlags flags
	time_t mtime

void
purple_conv_chat_add_users(chat, users, extra_msgs, flags, new_arrivals)
	Purple::Conversation::Chat chat
	SV * users
	SV * extra_msgs
	SV * flags
	gboolean new_arrivals
PREINIT:
	GList *t_GL_users, *t_GL_extra_msgs, *t_GL_flags;
	int i, t_len;
PPCODE:
	t_GL_users = NULL;
	t_len = av_len((AV *)SvRV(users)) + 1;

	for (i = 0; i < t_len; i++)
		t_GL_users = g_list_append(t_GL_users, SvPVutf8_nolen(*av_fetch((AV *)SvRV(users), i, 0)));

	t_GL_flags = NULL;
	t_len = av_len((AV *)SvRV(flags)) + 1;

	for (i = 0; i < t_len; i++)
		t_GL_flags = g_list_append(t_GL_flags, SvPVutf8_nolen(*av_fetch((AV *)SvRV(flags), i, 0)));

	t_GL_extra_msgs = NULL;
	t_len = av_len((AV *)SvRV(extra_msgs)) + 1;

	for (i = 0; i < t_len; i++)
		t_GL_extra_msgs = g_list_append(t_GL_extra_msgs, SvPVutf8_nolen(*av_fetch((AV *)SvRV(extra_msgs), i, 0)));

	purple_conv_chat_add_users(chat, t_GL_users, t_GL_extra_msgs, t_GL_flags, new_arrivals);

	g_list_free(t_GL_users);
	g_list_free(t_GL_extra_msgs);
	g_list_free(t_GL_flags);

gboolean
purple_conv_chat_find_user(chat, user)
	Purple::Conversation::Chat chat
	const char * user

void purple_conv_chat_clear_users(chat)
	Purple::Conversation::Chat chat

void purple_conv_chat_set_nick(chat, nick)
	Purple::Conversation::Chat chat
	const char * nick

const char *
purple_conv_chat_get_nick(chat)
	Purple::Conversation::Chat chat

Purple::Conversation
purple_find_chat(gc, id)
	Purple::Connection gc
	int id

void purple_conv_chat_left(chat)
	Purple::Conversation::Chat chat

gboolean purple_conv_chat_has_left(chat)
	Purple::Conversation::Chat chat

Purple::Conversation::ChatBuddy
purple_conv_chat_cb_find(chat, name)
	Purple::Conversation::Chat chat
	const char *name

const char *
purple_conv_chat_cb_get_name(cb)
	Purple::Conversation::ChatBuddy cb

void
purple_conv_chat_cb_destroy(cb);
	Purple::Conversation::ChatBuddy cb