4 * Purple is the legal property of its developers, whose names are too numerous
5 * to list here. Please refer to the COPYRIGHT file distributed with this
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
25 static GObjectClass
*parent_class
;
27 /**************************************************************************
29 **************************************************************************/
31 purple_protocol_get_id(const PurpleProtocol
*protocol
)
33 g_return_val_if_fail(PURPLE_IS_PROTOCOL(protocol
), NULL
);
39 purple_protocol_get_name(const PurpleProtocol
*protocol
)
41 g_return_val_if_fail(PURPLE_IS_PROTOCOL(protocol
), NULL
);
43 return protocol
->name
;
47 purple_protocol_get_options(const PurpleProtocol
*protocol
)
49 g_return_val_if_fail(PURPLE_IS_PROTOCOL(protocol
), 0);
51 return protocol
->options
;
55 purple_protocol_get_user_splits(const PurpleProtocol
*protocol
)
57 g_return_val_if_fail(PURPLE_IS_PROTOCOL(protocol
), NULL
);
59 return protocol
->user_splits
;
63 purple_protocol_get_account_options(const PurpleProtocol
*protocol
)
65 g_return_val_if_fail(PURPLE_IS_PROTOCOL(protocol
), NULL
);
67 return protocol
->account_options
;
71 purple_protocol_get_icon_spec(const PurpleProtocol
*protocol
)
73 g_return_val_if_fail(PURPLE_IS_PROTOCOL(protocol
), NULL
);
75 return protocol
->icon_spec
;
79 purple_protocol_get_whiteboard_ops(const PurpleProtocol
*protocol
)
81 g_return_val_if_fail(PURPLE_IS_PROTOCOL(protocol
), NULL
);
83 return protocol
->whiteboard_ops
;
87 user_splits_free(PurpleProtocol
*protocol
)
89 g_return_if_fail(PURPLE_IS_PROTOCOL(protocol
));
91 while (protocol
->user_splits
) {
92 PurpleAccountUserSplit
*split
= protocol
->user_splits
->data
;
93 purple_account_user_split_destroy(split
);
94 protocol
->user_splits
= g_list_delete_link(protocol
->user_splits
,
95 protocol
->user_splits
);
100 account_options_free(PurpleProtocol
*protocol
)
102 g_return_if_fail(PURPLE_IS_PROTOCOL(protocol
));
104 while (protocol
->account_options
) {
105 PurpleAccountOption
*option
= protocol
->account_options
->data
;
106 purple_account_option_destroy(option
);
107 protocol
->account_options
=
108 g_list_delete_link(protocol
->account_options
,
109 protocol
->account_options
);
114 icon_spec_free(PurpleProtocol
*protocol
)
116 g_return_if_fail(PURPLE_IS_PROTOCOL(protocol
));
118 g_free(protocol
->icon_spec
);
119 protocol
->icon_spec
= NULL
;
123 purple_protocol_override(PurpleProtocol
*protocol
,
124 PurpleProtocolOverrideFlags flags
)
126 g_return_if_fail(PURPLE_IS_PROTOCOL(protocol
));
128 if (flags
& PURPLE_PROTOCOL_OVERRIDE_USER_SPLITS
)
129 user_splits_free(protocol
);
130 if (flags
& PURPLE_PROTOCOL_OVERRIDE_PROTOCOL_OPTIONS
)
131 account_options_free(protocol
);
132 if (flags
& PURPLE_PROTOCOL_OVERRIDE_ICON_SPEC
)
133 icon_spec_free(protocol
);
136 /**************************************************************************
138 **************************************************************************/
140 purple_protocol_init(GTypeInstance
*instance
, gpointer klass
)
145 purple_protocol_finalize(GObject
*object
)
147 PurpleProtocol
*protocol
= PURPLE_PROTOCOL(object
);
150 accounts
= purple_accounts_get_all_active();
151 for (l
= accounts
; l
!= NULL
; l
= l
->next
) {
152 PurpleAccount
*account
= PURPLE_ACCOUNT(l
->data
);
153 if (purple_account_is_disconnected(account
))
156 if (purple_strequal(protocol
->id
,
157 purple_account_get_protocol_id(account
)))
158 purple_account_disconnect(account
);
161 g_list_free(accounts
);
163 purple_request_close_with_handle(protocol
);
164 purple_notify_close_with_handle(protocol
);
166 purple_signals_disconnect_by_handle(protocol
);
167 purple_signals_unregister_by_instance(protocol
);
169 purple_prefs_disconnect_by_handle(protocol
);
171 user_splits_free(protocol
);
172 account_options_free(protocol
);
173 icon_spec_free(protocol
);
175 parent_class
->finalize(object
);
179 purple_protocol_class_init(PurpleProtocolClass
*klass
)
181 GObjectClass
*obj_class
= G_OBJECT_CLASS(klass
);
183 parent_class
= g_type_class_peek_parent(klass
);
185 obj_class
->finalize
= purple_protocol_finalize
;
189 purple_protocol_get_type(void)
191 static GType type
= 0;
193 if (G_UNLIKELY(type
== 0)) {
194 static const GTypeInfo info
= {
195 .class_size
= sizeof(PurpleProtocolClass
),
196 .class_init
= (GClassInitFunc
)purple_protocol_class_init
,
197 .instance_size
= sizeof(PurpleProtocol
),
198 .instance_init
= (GInstanceInitFunc
)purple_protocol_init
,
201 type
= g_type_register_static(G_TYPE_OBJECT
, "PurpleProtocol",
202 &info
, G_TYPE_FLAG_ABSTRACT
);
208 /**************************************************************************
210 **************************************************************************/
211 #define DEFINE_PROTOCOL_FUNC(protocol,funcname,...) \
212 PurpleProtocolClass *klass = PURPLE_PROTOCOL_GET_CLASS(protocol); \
213 g_return_if_fail(klass != NULL); \
214 if (klass->funcname) \
215 klass->funcname(__VA_ARGS__);
217 #define DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol,defaultreturn,funcname,...) \
218 PurpleProtocolClass *klass = PURPLE_PROTOCOL_GET_CLASS(protocol); \
219 g_return_val_if_fail(klass != NULL, defaultreturn); \
220 if (klass->funcname) \
221 return klass->funcname(__VA_ARGS__); \
223 return defaultreturn;
226 purple_protocol_class_login(PurpleProtocol
*protocol
, PurpleAccount
*account
)
228 DEFINE_PROTOCOL_FUNC(protocol
, login
, account
);
232 purple_protocol_class_close(PurpleProtocol
*protocol
, PurpleConnection
*gc
)
234 DEFINE_PROTOCOL_FUNC(protocol
, close
, gc
);
238 purple_protocol_class_status_types(PurpleProtocol
*protocol
,
239 PurpleAccount
*account
)
241 DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol
, NULL
, status_types
, account
);
245 purple_protocol_class_list_icon(PurpleProtocol
*protocol
,
246 PurpleAccount
*account
, PurpleBuddy
*buddy
)
248 DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol
, NULL
, list_icon
, account
, buddy
);
251 #undef DEFINE_PROTOCOL_FUNC_WITH_RETURN
252 #undef DEFINE_PROTOCOL_FUNC
254 /**************************************************************************
255 * Protocol Client Interface API
256 **************************************************************************/
257 #define DEFINE_PROTOCOL_FUNC(protocol,funcname,...) \
258 PurpleProtocolClientInterface *client_iface = \
259 PURPLE_PROTOCOL_CLIENT_GET_IFACE(protocol); \
260 if (client_iface && client_iface->funcname) \
261 client_iface->funcname(__VA_ARGS__);
263 #define DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol,defaultreturn,funcname,...) \
264 PurpleProtocolClientInterface *client_iface = \
265 PURPLE_PROTOCOL_CLIENT_GET_IFACE(protocol); \
266 if (client_iface && client_iface->funcname) \
267 return client_iface->funcname(__VA_ARGS__); \
269 return defaultreturn;
272 purple_protocol_client_iface_get_type(void)
274 static GType type
= 0;
276 if (G_UNLIKELY(type
== 0)) {
277 static const GTypeInfo info
= {
278 .class_size
= sizeof(PurpleProtocolClientInterface
),
281 type
= g_type_register_static(G_TYPE_INTERFACE
,
282 "PurpleProtocolClientInterface", &info
, 0);
288 purple_protocol_client_iface_get_actions(PurpleProtocol
*protocol
,
289 PurpleConnection
*gc
)
291 DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol
, NULL
, get_actions
, gc
);
295 purple_protocol_client_iface_list_emblem(PurpleProtocol
*protocol
,
298 DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol
, NULL
, list_emblem
, buddy
);
302 purple_protocol_client_iface_status_text(PurpleProtocol
*protocol
,
305 DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol
, NULL
, status_text
, buddy
);
309 purple_protocol_client_iface_tooltip_text(PurpleProtocol
*protocol
,
310 PurpleBuddy
*buddy
, PurpleNotifyUserInfo
*user_info
, gboolean full
)
312 DEFINE_PROTOCOL_FUNC(protocol
, tooltip_text
, buddy
, user_info
, full
);
316 purple_protocol_client_iface_blist_node_menu(PurpleProtocol
*protocol
,
317 PurpleBlistNode
*node
)
319 DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol
, NULL
, blist_node_menu
, node
);
323 purple_protocol_client_iface_buddy_free(PurpleProtocol
*protocol
,
326 DEFINE_PROTOCOL_FUNC(protocol
, buddy_free
, buddy
);
330 purple_protocol_client_iface_convo_closed(PurpleProtocol
*protocol
,
331 PurpleConnection
*gc
, const char *who
)
333 DEFINE_PROTOCOL_FUNC(protocol
, convo_closed
, gc
, who
);
337 purple_protocol_client_iface_normalize(PurpleProtocol
*protocol
,
338 const PurpleAccount
*account
, const char *who
)
340 DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol
, NULL
, normalize
, account
, who
);
344 purple_protocol_client_iface_find_blist_chat(PurpleProtocol
*protocol
,
345 PurpleAccount
*account
, const char *name
)
347 DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol
, NULL
, find_blist_chat
, account
,
352 purple_protocol_client_iface_offline_message(PurpleProtocol
*protocol
,
353 const PurpleBuddy
*buddy
)
355 DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol
, FALSE
, offline_message
, buddy
);
359 purple_protocol_client_iface_get_account_text_table(PurpleProtocol
*protocol
,
360 PurpleAccount
*account
)
362 DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol
, NULL
, get_account_text_table
,
367 purple_protocol_client_iface_get_moods(PurpleProtocol
*protocol
,
368 PurpleAccount
*account
)
370 DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol
, NULL
, get_moods
, account
);
374 purple_protocol_client_iface_get_max_message_size(PurpleProtocol
*protocol
,
375 PurpleConversation
*conv
)
377 DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol
, 0, get_max_message_size
, conv
);
380 #undef DEFINE_PROTOCOL_FUNC_WITH_RETURN
381 #undef DEFINE_PROTOCOL_FUNC
383 /**************************************************************************
384 * Protocol Server Interface API
385 **************************************************************************/
386 #define DEFINE_PROTOCOL_FUNC(protocol,funcname,...) \
387 PurpleProtocolServerInterface *server_iface = \
388 PURPLE_PROTOCOL_SERVER_GET_IFACE(protocol); \
389 if (server_iface && server_iface->funcname) \
390 server_iface->funcname(__VA_ARGS__);
392 #define DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol,defaultreturn,funcname,...) \
393 PurpleProtocolServerInterface *server_iface = \
394 PURPLE_PROTOCOL_SERVER_GET_IFACE(protocol); \
395 if (server_iface && server_iface->funcname) \
396 return server_iface->funcname(__VA_ARGS__); \
398 return defaultreturn;
401 purple_protocol_server_iface_get_type(void)
403 static GType type
= 0;
405 if (G_UNLIKELY(type
== 0)) {
406 static const GTypeInfo info
= {
407 .class_size
= sizeof(PurpleProtocolServerInterface
),
410 type
= g_type_register_static(G_TYPE_INTERFACE
,
411 "PurpleProtocolServerInterface", &info
, 0);
417 purple_protocol_server_iface_register_user(PurpleProtocol
*protocol
,
418 PurpleAccount
*account
)
420 DEFINE_PROTOCOL_FUNC(protocol
, register_user
, account
);
424 purple_protocol_server_iface_unregister_user(PurpleProtocol
*protocol
,
425 PurpleAccount
*account
, PurpleAccountUnregistrationCb cb
,
428 DEFINE_PROTOCOL_FUNC(protocol
, unregister_user
, account
, cb
, user_data
);
432 purple_protocol_server_iface_set_info(PurpleProtocol
*protocol
,
433 PurpleConnection
*gc
, const char *info
)
435 DEFINE_PROTOCOL_FUNC(protocol
, set_info
, gc
, info
);
439 purple_protocol_server_iface_get_info(PurpleProtocol
*protocol
,
440 PurpleConnection
*gc
, const char *who
)
442 DEFINE_PROTOCOL_FUNC(protocol
, get_info
, gc
, who
);
446 purple_protocol_server_iface_set_status(PurpleProtocol
*protocol
,
447 PurpleAccount
*account
, PurpleStatus
*status
)
449 DEFINE_PROTOCOL_FUNC(protocol
, set_status
, account
, status
);
453 purple_protocol_server_iface_set_idle(PurpleProtocol
*protocol
,
454 PurpleConnection
*gc
, int idletime
)
456 DEFINE_PROTOCOL_FUNC(protocol
, set_idle
, gc
, idletime
);
460 purple_protocol_server_iface_change_passwd(PurpleProtocol
*protocol
,
461 PurpleConnection
*gc
, const char *old_pass
, const char *new_pass
)
463 DEFINE_PROTOCOL_FUNC(protocol
, change_passwd
, gc
, old_pass
, new_pass
);
467 purple_protocol_server_iface_add_buddy(PurpleProtocol
*protocol
,
468 PurpleConnection
*gc
, PurpleBuddy
*buddy
, PurpleGroup
*group
,
471 DEFINE_PROTOCOL_FUNC(protocol
, add_buddy
, gc
, buddy
, group
, message
);
475 purple_protocol_server_iface_add_buddies(PurpleProtocol
*protocol
,
476 PurpleConnection
*gc
, GList
*buddies
, GList
*groups
,
479 DEFINE_PROTOCOL_FUNC(protocol
, add_buddies
, gc
, buddies
, groups
, message
);
483 purple_protocol_server_iface_remove_buddy(PurpleProtocol
*protocol
,
484 PurpleConnection
*gc
, PurpleBuddy
*buddy
, PurpleGroup
*group
)
486 DEFINE_PROTOCOL_FUNC(protocol
, remove_buddy
, gc
, buddy
, group
);
490 purple_protocol_server_iface_remove_buddies(PurpleProtocol
*protocol
,
491 PurpleConnection
*gc
, GList
*buddies
, GList
*groups
)
493 DEFINE_PROTOCOL_FUNC(protocol
, remove_buddies
, gc
, buddies
, groups
);
497 purple_protocol_server_iface_keepalive(PurpleProtocol
*protocol
,
498 PurpleConnection
*gc
)
500 DEFINE_PROTOCOL_FUNC(protocol
, keepalive
, gc
);
504 purple_protocol_server_iface_get_keepalive_interval(PurpleProtocol
*protocol
)
506 DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol
, 30, get_keepalive_interval
);
510 purple_protocol_server_iface_alias_buddy(PurpleProtocol
*protocol
,
511 PurpleConnection
*gc
, const char *who
, const char *alias
)
513 DEFINE_PROTOCOL_FUNC(protocol
, alias_buddy
, gc
, who
, alias
);
517 purple_protocol_server_iface_group_buddy(PurpleProtocol
*protocol
,
518 PurpleConnection
*gc
, const char *who
, const char *old_group
,
519 const char *new_group
)
521 DEFINE_PROTOCOL_FUNC(protocol
, group_buddy
, gc
, who
, old_group
, new_group
);
525 purple_protocol_server_iface_rename_group(PurpleProtocol
*protocol
,
526 PurpleConnection
*gc
, const char *old_name
, PurpleGroup
*group
,
527 GList
*moved_buddies
)
529 DEFINE_PROTOCOL_FUNC(protocol
, rename_group
, gc
, old_name
, group
,
534 purple_protocol_server_iface_set_buddy_icon(PurpleProtocol
*protocol
,
535 PurpleConnection
*gc
, PurpleImage
*img
)
537 DEFINE_PROTOCOL_FUNC(protocol
, set_buddy_icon
, gc
, img
);
541 purple_protocol_server_iface_remove_group(PurpleProtocol
*protocol
,
542 PurpleConnection
*gc
, PurpleGroup
*group
)
544 DEFINE_PROTOCOL_FUNC(protocol
, remove_group
, gc
, group
);
548 purple_protocol_server_iface_send_raw(PurpleProtocol
*protocol
,
549 PurpleConnection
*gc
, const char *buf
, int len
)
551 DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol
, 0, send_raw
, gc
, buf
, len
);
555 purple_protocol_server_iface_set_public_alias(PurpleProtocol
*protocol
,
556 PurpleConnection
*gc
, const char *alias
,
557 PurpleSetPublicAliasSuccessCallback success_cb
,
558 PurpleSetPublicAliasFailureCallback failure_cb
)
560 DEFINE_PROTOCOL_FUNC(protocol
, set_public_alias
, gc
, alias
, success_cb
,
565 purple_protocol_server_iface_get_public_alias(PurpleProtocol
*protocol
,
566 PurpleConnection
*gc
, PurpleGetPublicAliasSuccessCallback success_cb
,
567 PurpleGetPublicAliasFailureCallback failure_cb
)
569 DEFINE_PROTOCOL_FUNC(protocol
, get_public_alias
, gc
, success_cb
,
573 #undef DEFINE_PROTOCOL_FUNC_WITH_RETURN
574 #undef DEFINE_PROTOCOL_FUNC
576 /**************************************************************************
577 * Protocol IM Interface API
578 **************************************************************************/
579 #define DEFINE_PROTOCOL_FUNC(protocol,funcname,...) \
580 PurpleProtocolIMInterface *im_iface = \
581 PURPLE_PROTOCOL_IM_GET_IFACE(protocol); \
582 if (im_iface && im_iface->funcname) \
583 im_iface->funcname(__VA_ARGS__);
585 #define DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol,defaultreturn,funcname,...) \
586 PurpleProtocolIMInterface *im_iface = \
587 PURPLE_PROTOCOL_IM_GET_IFACE(protocol); \
588 if (im_iface && im_iface->funcname) \
589 return im_iface->funcname(__VA_ARGS__); \
591 return defaultreturn;
594 purple_protocol_im_iface_get_type(void)
596 static GType type
= 0;
598 if (G_UNLIKELY(type
== 0)) {
599 static const GTypeInfo info
= {
600 .class_size
= sizeof(PurpleProtocolIMInterface
),
603 type
= g_type_register_static(G_TYPE_INTERFACE
,
604 "PurpleProtocolIMInterface", &info
, 0);
610 purple_protocol_im_iface_send(PurpleProtocol
*protocol
, PurpleConnection
*gc
,
613 DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol
, 0, send
, gc
, msg
);
617 purple_protocol_im_iface_send_typing(PurpleProtocol
*protocol
,
618 PurpleConnection
*gc
, const char *name
, PurpleIMTypingState state
)
620 DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol
, 0, send_typing
, gc
, name
, state
);
623 #undef DEFINE_PROTOCOL_FUNC_WITH_RETURN
624 #undef DEFINE_PROTOCOL_FUNC
626 /**************************************************************************
627 * Protocol Chat Interface API
628 **************************************************************************/
629 #define DEFINE_PROTOCOL_FUNC(protocol,funcname,...) \
630 PurpleProtocolChatInterface *chat_iface = \
631 PURPLE_PROTOCOL_CHAT_GET_IFACE(protocol); \
632 if (chat_iface && chat_iface->funcname) \
633 chat_iface->funcname(__VA_ARGS__);
635 #define DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol,defaultreturn,funcname,...) \
636 PurpleProtocolChatInterface *chat_iface = \
637 PURPLE_PROTOCOL_CHAT_GET_IFACE(protocol); \
638 if (chat_iface && chat_iface->funcname) \
639 return chat_iface->funcname(__VA_ARGS__); \
641 return defaultreturn;
644 purple_protocol_chat_iface_get_type(void)
646 static GType type
= 0;
648 if (G_UNLIKELY(type
== 0)) {
649 static const GTypeInfo info
= {
650 .class_size
= sizeof(PurpleProtocolChatInterface
),
653 type
= g_type_register_static(G_TYPE_INTERFACE
,
654 "PurpleProtocolChatInterface", &info
, 0);
660 purple_protocol_chat_iface_info(PurpleProtocol
*protocol
, PurpleConnection
*gc
)
662 DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol
, NULL
, info
, gc
);
666 purple_protocol_chat_iface_info_defaults(PurpleProtocol
*protocol
,
667 PurpleConnection
*gc
, const char *chat_name
)
669 DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol
, NULL
, info_defaults
, gc
,
674 purple_protocol_chat_iface_join(PurpleProtocol
*protocol
, PurpleConnection
*gc
,
675 GHashTable
*components
)
677 DEFINE_PROTOCOL_FUNC(protocol
, join
, gc
, components
);
681 purple_protocol_chat_iface_reject(PurpleProtocol
*protocol
,
682 PurpleConnection
*gc
, GHashTable
*components
)
684 DEFINE_PROTOCOL_FUNC(protocol
, reject
, gc
, components
);
688 purple_protocol_chat_iface_get_name(PurpleProtocol
*protocol
,
689 GHashTable
*components
)
691 DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol
, NULL
, get_name
, components
);
695 purple_protocol_chat_iface_invite(PurpleProtocol
*protocol
,
696 PurpleConnection
*gc
, int id
, const char *message
, const char *who
)
698 DEFINE_PROTOCOL_FUNC(protocol
, invite
, gc
, id
, message
, who
);
702 purple_protocol_chat_iface_leave(PurpleProtocol
*protocol
, PurpleConnection
*gc
,
705 DEFINE_PROTOCOL_FUNC(protocol
, leave
, gc
, id
);
709 purple_protocol_chat_iface_send(PurpleProtocol
*protocol
, PurpleConnection
*gc
,
710 int id
, PurpleMessage
*msg
)
712 DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol
, 0, send
, gc
, id
, msg
);
716 purple_protocol_chat_iface_get_user_real_name(PurpleProtocol
*protocol
,
717 PurpleConnection
*gc
, int id
, const char *who
)
719 DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol
, NULL
, get_user_real_name
, gc
, id
,
724 purple_protocol_chat_iface_set_topic(PurpleProtocol
*protocol
,
725 PurpleConnection
*gc
, int id
, const char *topic
)
727 DEFINE_PROTOCOL_FUNC(protocol
, set_topic
, gc
, id
, topic
);
730 #undef DEFINE_PROTOCOL_FUNC_WITH_RETURN
731 #undef DEFINE_PROTOCOL_FUNC
733 /**************************************************************************
734 * Protocol Privacy Interface API
735 **************************************************************************/
736 #define DEFINE_PROTOCOL_FUNC(protocol,funcname,...) \
737 PurpleProtocolPrivacyInterface *privacy_iface = \
738 PURPLE_PROTOCOL_PRIVACY_GET_IFACE(protocol); \
739 if (privacy_iface && privacy_iface->funcname) \
740 privacy_iface->funcname(__VA_ARGS__);
742 #define DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol,defaultreturn,funcname,...) \
743 PurpleProtocolPrivacyInterface *privacy_iface = \
744 PURPLE_PROTOCOL_PRIVACY_GET_IFACE(protocol); \
745 if (privacy_iface && privacy_iface->funcname) \
746 return privacy_iface->funcname(__VA_ARGS__); \
748 return defaultreturn;
751 purple_protocol_privacy_iface_get_type(void)
753 static GType type
= 0;
755 if (G_UNLIKELY(type
== 0)) {
756 static const GTypeInfo info
= {
757 .class_size
= sizeof(PurpleProtocolPrivacyInterface
),
760 type
= g_type_register_static(G_TYPE_INTERFACE
,
761 "PurpleProtocolPrivacyInterface", &info
, 0);
767 purple_protocol_privacy_iface_add_permit(PurpleProtocol
*protocol
,
768 PurpleConnection
*gc
, const char *name
)
770 DEFINE_PROTOCOL_FUNC(protocol
, add_permit
, gc
, name
);
774 purple_protocol_privacy_iface_add_deny(PurpleProtocol
*protocol
,
775 PurpleConnection
*gc
, const char *name
)
777 DEFINE_PROTOCOL_FUNC(protocol
, add_deny
, gc
, name
);
781 purple_protocol_privacy_iface_rem_permit(PurpleProtocol
*protocol
,
782 PurpleConnection
*gc
, const char *name
)
784 DEFINE_PROTOCOL_FUNC(protocol
, rem_permit
, gc
, name
);
788 purple_protocol_privacy_iface_rem_deny(PurpleProtocol
*protocol
,
789 PurpleConnection
*gc
, const char *name
)
791 DEFINE_PROTOCOL_FUNC(protocol
, rem_deny
, gc
, name
);
795 purple_protocol_privacy_iface_set_permit_deny(PurpleProtocol
*protocol
,
796 PurpleConnection
*gc
)
798 DEFINE_PROTOCOL_FUNC(protocol
, set_permit_deny
, gc
);
801 #undef DEFINE_PROTOCOL_FUNC_WITH_RETURN
802 #undef DEFINE_PROTOCOL_FUNC
804 /**************************************************************************
805 * Protocol Roomlist Interface API
806 **************************************************************************/
807 #define DEFINE_PROTOCOL_FUNC(protocol,funcname,...) \
808 PurpleProtocolRoomlistInterface *roomlist_iface = \
809 PURPLE_PROTOCOL_ROOMLIST_GET_IFACE(protocol); \
810 if (roomlist_iface && roomlist_iface->funcname) \
811 roomlist_iface->funcname(__VA_ARGS__);
813 #define DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol,defaultreturn,funcname,...) \
814 PurpleProtocolRoomlistInterface *roomlist_iface = \
815 PURPLE_PROTOCOL_ROOMLIST_GET_IFACE(protocol); \
816 if (roomlist_iface && roomlist_iface->funcname) \
817 return roomlist_iface->funcname(__VA_ARGS__); \
819 return defaultreturn;
822 purple_protocol_roomlist_iface_get_type(void)
824 static GType type
= 0;
826 if (G_UNLIKELY(type
== 0)) {
827 static const GTypeInfo info
= {
828 .class_size
= sizeof(PurpleProtocolRoomlistInterface
),
831 type
= g_type_register_static(G_TYPE_INTERFACE
,
832 "PurpleProtocolRoomlistInterface", &info
, 0);
838 purple_protocol_roomlist_iface_get_list(PurpleProtocol
*protocol
,
839 PurpleConnection
*gc
)
841 DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol
, NULL
, get_list
, gc
);
845 purple_protocol_roomlist_iface_cancel(PurpleProtocol
*protocol
,
846 PurpleRoomlist
*list
)
848 DEFINE_PROTOCOL_FUNC(protocol
, cancel
, list
);
852 purple_protocol_roomlist_iface_expand_category(PurpleProtocol
*protocol
,
853 PurpleRoomlist
*list
, PurpleRoomlistRoom
*category
)
855 DEFINE_PROTOCOL_FUNC(protocol
, expand_category
, list
, category
);
859 purple_protocol_roomlist_iface_room_serialize(PurpleProtocol
*protocol
,
860 PurpleRoomlistRoom
*room
)
862 DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol
, NULL
, room_serialize
, room
);
865 #undef DEFINE_PROTOCOL_FUNC_WITH_RETURN
866 #undef DEFINE_PROTOCOL_FUNC
868 /**************************************************************************
869 * Protocol Media Interface API
870 **************************************************************************/
871 #define DEFINE_PROTOCOL_FUNC(protocol,funcname,...) \
872 PurpleProtocolMediaInterface *media_iface = \
873 PURPLE_PROTOCOL_MEDIA_GET_IFACE(protocol); \
874 if (media_iface && media_iface->funcname) \
875 media_iface->funcname(__VA_ARGS__);
877 #define DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol,defaultreturn,funcname,...) \
878 PurpleProtocolMediaInterface *media_iface = \
879 PURPLE_PROTOCOL_MEDIA_GET_IFACE(protocol); \
880 if (media_iface && media_iface->funcname) \
881 return media_iface->funcname(__VA_ARGS__); \
883 return defaultreturn;
886 purple_protocol_media_iface_get_type(void)
888 static GType type
= 0;
890 if (G_UNLIKELY(type
== 0)) {
891 static const GTypeInfo info
= {
892 .class_size
= sizeof(PurpleProtocolMediaInterface
),
895 type
= g_type_register_static(G_TYPE_INTERFACE
,
896 "PurpleProtocolMediaInterface", &info
, 0);
902 purple_protocol_media_iface_initiate_session(PurpleProtocol
*protocol
,
903 PurpleAccount
*account
, const char *who
, PurpleMediaSessionType type
)
905 DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol
, FALSE
, initiate_session
, account
,
910 purple_protocol_media_iface_get_caps(PurpleProtocol
*protocol
,
911 PurpleAccount
*account
, const char *who
)
913 DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol
, 0, get_caps
, account
, who
);
916 gboolean
purple_protocol_media_iface_send_dtmf(PurpleProtocol
*protocol
,
917 PurpleMedia
*media
, gchar dtmf
, guint8 volume
, guint8 duration
)
919 DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol
, FALSE
, send_dtmf
, media
,
920 dtmf
, volume
, duration
);
923 #undef DEFINE_PROTOCOL_FUNC_WITH_RETURN
924 #undef DEFINE_PROTOCOL_FUNC
926 /**************************************************************************
927 * Protocol Factory Interface API
928 **************************************************************************/
929 #define DEFINE_PROTOCOL_FUNC(protocol,funcname,...) \
930 PurpleProtocolFactoryInterface *factory_iface = \
931 PURPLE_PROTOCOL_FACTORY_GET_IFACE(protocol); \
932 if (factory_iface && factory_iface->funcname) \
933 factory_iface->funcname(__VA_ARGS__);
935 #define DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol,defaultreturn,funcname,...) \
936 PurpleProtocolFactoryInterface *factory_iface = \
937 PURPLE_PROTOCOL_FACTORY_GET_IFACE(protocol); \
938 if (factory_iface && factory_iface->funcname) \
939 return factory_iface->funcname(__VA_ARGS__); \
941 return defaultreturn;
944 purple_protocol_factory_iface_get_type(void)
946 static GType type
= 0;
948 if (G_UNLIKELY(type
== 0)) {
949 static const GTypeInfo info
= {
950 .class_size
= sizeof(PurpleProtocolFactoryInterface
),
953 type
= g_type_register_static(G_TYPE_INTERFACE
,
954 "PurpleProtocolFactoryInterface", &info
, 0);
960 purple_protocol_factory_iface_connection_new(PurpleProtocol
*protocol
,
961 PurpleAccount
*account
, const char *password
)
963 DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol
, NULL
, connection_new
, protocol
,
968 purple_protocol_factory_iface_roomlist_new(PurpleProtocol
*protocol
,
969 PurpleAccount
*account
)
971 DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol
, NULL
, roomlist_new
, account
);
975 purple_protocol_factory_iface_whiteboard_new(PurpleProtocol
*protocol
,
976 PurpleAccount
*account
, const char *who
, int state
)
978 DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol
, NULL
, whiteboard_new
, account
,
982 #undef DEFINE_PROTOCOL_FUNC_WITH_RETURN
983 #undef DEFINE_PROTOCOL_FUNC