Mercurial > pidgin
changeset 16240:547c76fe2e7a
This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Wed, 18 Apr 2007 19:51:24 +0000 |
parents | 55a5791838f7 |
children | 1aed376daccb b6dcc2a45154 |
files | libpurple/protocols/jabber/Makefile.am libpurple/protocols/jabber/jabber.c libpurple/protocols/jabber/jabber.h |
diffstat | 3 files changed, 47 insertions(+), 198 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/Makefile.am Wed Apr 18 07:42:23 2007 +0000 +++ b/libpurple/protocols/jabber/Makefile.am Wed Apr 18 19:51:24 2007 +0000 @@ -38,26 +38,32 @@ AM_CFLAGS = $(st) -libjabber_la_LDFLAGS = -module -avoid-version +libxmpp_la_LDFLAGS = -module -avoid-version if STATIC_JABBER st = -DPURPLE_STATIC_PRPL -noinst_LIBRARIES = libjabber.a +noinst_LIBRARIES = libjabber.a libxmpp.a pkg_LTLIBRARIES = libjabber_a_SOURCES = $(JABBERSOURCES) libjabber_a_CFLAGS = $(AM_CFLAGS) +libxmpp_a_SOURCES = libxmpp.c +libxmpp_a_CFLAGS = $(AM_CFLAGS) + else st = -pkg_LTLIBRARIES = libjabber.la +pkg_LTLIBRARIES = libjabber.la libxmpp.la noinst_LIBRARIES = libjabber_la_SOURCES = $(JABBERSOURCES) libjabber_la_LIBADD = $(GLIB_LIBS) $(SASL_LIBS) $(LIBXML_LIBS) +libxmpp_la_SOURCES = libxmpp.c +libxmpp_la_LIBADD = libjabber.la + endif AM_CPPFLAGS = \
--- a/libpurple/protocols/jabber/jabber.c Wed Apr 18 07:42:23 2007 +0000 +++ b/libpurple/protocols/jabber/jabber.c Wed Apr 18 19:51:24 2007 +0000 @@ -339,7 +339,7 @@ return; } -static int jabber_prpl_send_raw(PurpleConnection *gc, const char *buf, int len) +int jabber_prpl_send_raw(PurpleConnection *gc, const char *buf, int len) { JabberStream *js = (JabberStream*)gc->proto_data; jabber_send_raw(js, buf, len); @@ -362,7 +362,7 @@ g_free(txt); } -static void jabber_keepalive(PurpleConnection *gc) +void jabber_keepalive(PurpleConnection *gc) { jabber_send_raw(gc->proto_data, "\t", -1); } @@ -535,9 +535,7 @@ } } - - -static void +void jabber_login(PurpleAccount *account) { PurpleConnection *gc = purple_account_get_connection(account); @@ -887,7 +885,7 @@ jabber_iq_send(iq); } -static void jabber_register_account(PurpleAccount *account) +void jabber_register_account(PurpleAccount *account) { PurpleConnection *gc = purple_account_get_connection(account); JabberStream *js; @@ -958,7 +956,7 @@ } } -static void jabber_close(PurpleConnection *gc) +void jabber_close(PurpleConnection *gc) { JabberStream *js = gc->proto_data; @@ -1073,19 +1071,19 @@ } -static void jabber_idle_set(PurpleConnection *gc, int idle) +void jabber_idle_set(PurpleConnection *gc, int idle) { JabberStream *js = gc->proto_data; js->idle = idle ? time(NULL) - idle : idle; } -static const char *jabber_list_icon(PurpleAccount *a, PurpleBuddy *b) +const char *jabber_list_icon(PurpleAccount *a, PurpleBuddy *b) { return "jabber"; } -static const char* jabber_list_emblem(PurpleBuddy *b) +const char* jabber_list_emblem(PurpleBuddy *b) { JabberStream *js; JabberBuddy *jb = NULL; @@ -1105,7 +1103,7 @@ return NULL; } -static char *jabber_status_text(PurpleBuddy *b) +char *jabber_status_text(PurpleBuddy *b) { JabberBuddy *jb = jabber_buddy_find(b->account->gc->proto_data, b->name, FALSE); @@ -1134,7 +1132,7 @@ return ret; } -static void jabber_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) +void jabber_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) { JabberBuddy *jb; @@ -1218,7 +1216,7 @@ } } -static GList *jabber_status_types(PurpleAccount *account) +GList *jabber_status_types(PurpleAccount *account) { PurpleStatusType *type; GList *types = NULL; @@ -1371,7 +1369,7 @@ _("Cancel"), NULL, js); } -static GList *jabber_actions(PurplePlugin *plugin, gpointer context) +GList *jabber_actions(PurplePlugin *plugin, gpointer context) { GList *m = NULL; PurplePluginAction *act; @@ -1393,7 +1391,7 @@ return m; } -static PurpleChat *jabber_find_blist_chat(PurpleAccount *account, const char *name) +PurpleChat *jabber_find_blist_chat(PurpleAccount *account, const char *name) { PurpleBlistNode *gnode, *cnode; JabberID *jid; @@ -1427,7 +1425,7 @@ return NULL; } -static void jabber_convo_closed(PurpleConnection *gc, const char *who) +void jabber_convo_closed(PurpleConnection *gc, const char *who) { JabberStream *js = gc->proto_data; JabberID *jid; @@ -1777,12 +1775,12 @@ return PURPLE_CMD_RET_OK; } -static gboolean jabber_offline_message(const PurpleBuddy *buddy) +gboolean jabber_offline_message(const PurpleBuddy *buddy) { return TRUE; } -static void jabber_register_commands(void) +void jabber_register_commands(void) { purple_cmd_register("config", "", PURPLE_CMD_P_PRPL, PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY, @@ -1856,182 +1854,8 @@ NULL); } -static PurplePluginProtocolInfo prpl_info = -{ -#ifdef HAVE_CYRUS_SASL - OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME | - OPT_PROTO_MAIL_CHECK | OPT_PROTO_PASSWORD_OPTIONAL, -#else - OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME | OPT_PROTO_MAIL_CHECK, -#endif - NULL, /* user_splits */ - NULL, /* protocol_options */ - {"png,gif,jpeg", 32, 32, 96, 96, 8191, PURPLE_ICON_SCALE_SEND | PURPLE_ICON_SCALE_DISPLAY}, /* icon_spec */ - jabber_list_icon, /* list_icon */ - jabber_list_emblem, /* list_emblems */ - jabber_status_text, /* status_text */ - jabber_tooltip_text, /* tooltip_text */ - jabber_status_types, /* status_types */ - jabber_blist_node_menu, /* blist_node_menu */ - jabber_chat_info, /* chat_info */ - jabber_chat_info_defaults, /* chat_info_defaults */ - jabber_login, /* login */ - jabber_close, /* close */ - jabber_message_send_im, /* send_im */ - jabber_set_info, /* set_info */ - jabber_send_typing, /* send_typing */ - jabber_buddy_get_info, /* get_info */ - jabber_presence_send, /* set_away */ - jabber_idle_set, /* set_idle */ - NULL, /* change_passwd */ - jabber_roster_add_buddy, /* add_buddy */ - NULL, /* add_buddies */ - jabber_roster_remove_buddy, /* remove_buddy */ - NULL, /* remove_buddies */ - NULL, /* add_permit */ - jabber_google_roster_add_deny, /* add_deny */ - NULL, /* rem_permit */ - jabber_google_roster_rem_deny, /* rem_deny */ - NULL, /* set_permit_deny */ - jabber_chat_join, /* join_chat */ - NULL, /* reject_chat */ - jabber_get_chat_name, /* get_chat_name */ - jabber_chat_invite, /* chat_invite */ - jabber_chat_leave, /* chat_leave */ - NULL, /* chat_whisper */ - jabber_message_send_chat, /* chat_send */ - jabber_keepalive, /* keepalive */ - jabber_register_account, /* register_user */ - jabber_buddy_get_info_chat, /* get_cb_info */ - NULL, /* get_cb_away */ - jabber_roster_alias_change, /* alias_buddy */ - jabber_roster_group_change, /* group_buddy */ - jabber_roster_group_rename, /* rename_group */ - NULL, /* buddy_free */ - jabber_convo_closed, /* convo_closed */ - jabber_normalize, /* normalize */ - jabber_set_buddy_icon, /* set_buddy_icon */ - NULL, /* remove_group */ - jabber_chat_buddy_real_name, /* get_cb_real_name */ - jabber_chat_set_topic, /* set_chat_topic */ - jabber_find_blist_chat, /* find_blist_chat */ - jabber_roomlist_get_list, /* roomlist_get_list */ - jabber_roomlist_cancel, /* roomlist_cancel */ - NULL, /* roomlist_expand_category */ - NULL, /* can_receive_file */ - jabber_si_xfer_send, /* send_file */ - jabber_si_new_xfer, /* new_xfer */ - jabber_offline_message, /* offline_message */ - NULL, /* whiteboard_prpl_ops */ - jabber_prpl_send_raw, /* send_raw */ - jabber_roomlist_room_serialize, /* roomlist_room_serialize */ -}; - -static gboolean load_plugin(PurplePlugin *plugin) +void +jabber_init_plugin(PurplePlugin *plugin) { - purple_signal_register(plugin, "jabber-receiving-xmlnode", - purple_marshal_VOID__POINTER_POINTER, NULL, 2, - purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONNECTION), - purple_value_new_outgoing(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_XMLNODE)); - - purple_signal_register(plugin, "jabber-sending-xmlnode", - purple_marshal_VOID__POINTER_POINTER, NULL, 2, - purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONNECTION), - purple_value_new_outgoing(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_XMLNODE)); - - purple_signal_register(plugin, "jabber-sending-text", - purple_marshal_VOID__POINTER_POINTER, NULL, 2, - purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONNECTION), - purple_value_new_outgoing(PURPLE_TYPE_STRING)); - - - return TRUE; -} - -static gboolean unload_plugin(PurplePlugin *plugin) -{ - purple_signal_unregister(plugin, "jabber-receiving-xmlnode"); - - purple_signal_unregister(plugin, "jabber-sending-xmlnode"); - - purple_signal_unregister(plugin, "jabber-sending-text"); - - return TRUE; + my_protocol = plugin; } - -static PurplePluginInfo info = -{ - PURPLE_PLUGIN_MAGIC, - PURPLE_MAJOR_VERSION, - PURPLE_MINOR_VERSION, - PURPLE_PLUGIN_PROTOCOL, /**< type */ - NULL, /**< ui_requirement */ - 0, /**< flags */ - NULL, /**< dependencies */ - PURPLE_PRIORITY_DEFAULT, /**< priority */ - - "prpl-jabber", /**< id */ - "Jabber", /**< name */ - VERSION, /**< version */ - /** summary */ - N_("Jabber Protocol Plugin"), - /** description */ - N_("Jabber Protocol Plugin"), - NULL, /**< author */ - PURPLE_WEBSITE, /**< homepage */ - - load_plugin, /**< load */ - unload_plugin, /**< unload */ - NULL, /**< destroy */ - - NULL, /**< ui_info */ - &prpl_info, /**< extra_info */ - NULL, /**< prefs_info */ - jabber_actions -}; - -static void -init_plugin(PurplePlugin *plugin) -{ - PurpleAccountUserSplit *split; - PurpleAccountOption *option; - - split = purple_account_user_split_new(_("Server"), "jabber.org", '@'); - prpl_info.user_splits = g_list_append(prpl_info.user_splits, split); - - split = purple_account_user_split_new(_("Resource"), "Home", '/'); - prpl_info.user_splits = g_list_append(prpl_info.user_splits, split); - - option = purple_account_option_bool_new(_("Force old (port 5223) SSL"), "old_ssl", FALSE); - prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, - option); - - option = purple_account_option_bool_new( - _("Allow plaintext auth over unencrypted streams"), - "auth_plain_in_clear", FALSE); - prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, - option); - - option = purple_account_option_int_new(_("Connect port"), "port", 5222); - prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, - option); - - option = purple_account_option_string_new(_("Connect server"), - "connect_server", NULL); - prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, - option); - - my_protocol = plugin; - - purple_prefs_remove("/plugins/prpl/jabber"); - - /* XXX - If any other plugin wants SASL this won't be good ... */ -#ifdef HAVE_CYRUS_SASL - sasl_client_init(NULL); -#endif - jabber_register_commands(); - - jabber_iq_init(); -} - -PURPLE_INIT_PLUGIN(jabber, init_plugin, info);
--- a/libpurple/protocols/jabber/jabber.h Wed Apr 18 07:42:23 2007 +0000 +++ b/libpurple/protocols/jabber/jabber.h Wed Apr 18 19:51:24 2007 +0000 @@ -163,4 +163,23 @@ char *jabber_parse_error(JabberStream *js, xmlnode *packet); +/** PRPL functions */ +const char *jabber_list_icon(PurpleAccount *a, PurpleBuddy *b); +const char* jabber_list_emblem(PurpleBuddy *b); +char *jabber_status_text(PurpleBuddy *b); +void jabber_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full); +GList *jabber_status_types(PurpleAccount *account); +void jabber_login(PurpleAccount *account); +void jabber_close(PurpleConnection *gc); +void jabber_idle_set(PurpleConnection *gc, int idle); +void jabber_keepalive(PurpleConnection *gc); +void jabber_register_account(PurpleAccount *account); +void jabber_convo_closed(PurpleConnection *gc, const char *who); +PurpleChat *jabber_find_blist_chat(PurpleAccount *account, const char *name); +gboolean jabber_offline_message(const PurpleBuddy *buddy); +int jabber_prpl_send_raw(PurpleConnection *gc, const char *buf, int len); +GList *jabber_actions(PurplePlugin *plugin, gpointer context); +void jabber_register_commands(void); +void jabber_init_plugin(PurplePlugin *plugin); + #endif /* _PURPLE_JABBER_H_ */