Mon, 18 Jun 2007 12:37:29 +0000
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
| 16303 | 1 | /* purple |
| 2 | * | |
| 3 | * Purple is the legal property of its developers, whose names are too numerous | |
| 4 | * to list here. Please refer to the COPYRIGHT file distributed with this | |
| 5 | * source distribution. | |
| 6 | * | |
| 7 | * This program is free software; you can redistribute it and/or modify | |
| 8 | * it under the terms of the GNU General Public License as published by | |
| 9 | * the Free Software Foundation; either version 2 of the License, or | |
| 10 | * (at your option) any later version. | |
| 11 | * | |
| 12 | * This program is distributed in the hope that it will be useful, | |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 15 | * GNU General Public License for more details. | |
| 16 | * | |
| 17 | * You should have received a copy of the GNU General Public License | |
| 18 | * along with this program; if not, write to the Free Software | |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 20 | * | |
| 21 | */ | |
| 22 | ||
| 23 | /* libxmpp is the XMPP protocol plugin. It is linked against libjabbercommon, | |
| 24 | * which may be used to support other protocols (Bonjour) which may need to | |
| 25 | * share code. | |
| 26 | */ | |
| 27 | ||
| 28 | #include "accountopt.h" | |
| 29 | #include "internal.h" | |
| 30 | #include "version.h" | |
| 31 | ||
| 32 | #include "iq.h" | |
| 33 | #include "jabber.h" | |
| 34 | #include "chat.h" | |
| 35 | #include "message.h" | |
| 36 | #include "roster.h" | |
| 37 | #include "si.h" | |
| 38 | #include "message.h" | |
| 39 | #include "presence.h" | |
| 40 | #include "google.h" | |
|
17773
6956b763b3d1
Implemented adding callbacks for PEP events. Moved the feature list to be application-global instead of per-connection (makes more sense).
Andreas Monitzer <am@adiumx.com>
parents:
17012
diff
changeset
|
41 | #include "pep.h" |
|
17791
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
42 | #include "usertune.h" |
| 16303 | 43 | |
| 44 | static PurplePluginProtocolInfo prpl_info = | |
| 45 | { | |
| 46 | #ifdef HAVE_CYRUS_SASL | |
| 47 | OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME | | |
| 48 | OPT_PROTO_MAIL_CHECK | OPT_PROTO_PASSWORD_OPTIONAL, | |
| 49 | #else | |
| 50 | OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME | OPT_PROTO_MAIL_CHECK, | |
| 51 | #endif | |
| 52 | NULL, /* user_splits */ | |
| 53 | NULL, /* protocol_options */ | |
|
17787
439329d20337
Added support for setting the avatar via XEP-0084. Receiving other people's avatar is up next.
Andreas Monitzer <am@adiumx.com>
parents:
17773
diff
changeset
|
54 | {"png", 32, 32, 96, 96, 8191, PURPLE_ICON_SCALE_SEND | PURPLE_ICON_SCALE_DISPLAY}, /* icon_spec */ |
| 16303 | 55 | jabber_list_icon, /* list_icon */ |
| 56 | jabber_list_emblem, /* list_emblems */ | |
| 57 | jabber_status_text, /* status_text */ | |
| 58 | jabber_tooltip_text, /* tooltip_text */ | |
| 59 | jabber_status_types, /* status_types */ | |
| 60 | jabber_blist_node_menu, /* blist_node_menu */ | |
| 61 | jabber_chat_info, /* chat_info */ | |
| 62 | jabber_chat_info_defaults, /* chat_info_defaults */ | |
| 63 | jabber_login, /* login */ | |
| 64 | jabber_close, /* close */ | |
| 65 | jabber_message_send_im, /* send_im */ | |
| 66 | jabber_set_info, /* set_info */ | |
| 67 | jabber_send_typing, /* send_typing */ | |
| 68 | jabber_buddy_get_info, /* get_info */ | |
| 69 | jabber_presence_send, /* set_away */ | |
| 70 | jabber_idle_set, /* set_idle */ | |
| 71 | NULL, /* change_passwd */ | |
| 72 | jabber_roster_add_buddy, /* add_buddy */ | |
| 73 | NULL, /* add_buddies */ | |
| 74 | jabber_roster_remove_buddy, /* remove_buddy */ | |
| 75 | NULL, /* remove_buddies */ | |
| 76 | NULL, /* add_permit */ | |
| 77 | jabber_google_roster_add_deny, /* add_deny */ | |
| 78 | NULL, /* rem_permit */ | |
| 79 | jabber_google_roster_rem_deny, /* rem_deny */ | |
| 80 | NULL, /* set_permit_deny */ | |
| 81 | jabber_chat_join, /* join_chat */ | |
| 82 | NULL, /* reject_chat */ | |
| 83 | jabber_get_chat_name, /* get_chat_name */ | |
| 84 | jabber_chat_invite, /* chat_invite */ | |
| 85 | jabber_chat_leave, /* chat_leave */ | |
| 86 | NULL, /* chat_whisper */ | |
| 87 | jabber_message_send_chat, /* chat_send */ | |
| 88 | jabber_keepalive, /* keepalive */ | |
| 89 | jabber_register_account, /* register_user */ | |
| 90 | jabber_buddy_get_info_chat, /* get_cb_info */ | |
| 91 | NULL, /* get_cb_away */ | |
| 92 | jabber_roster_alias_change, /* alias_buddy */ | |
| 93 | jabber_roster_group_change, /* group_buddy */ | |
| 94 | jabber_roster_group_rename, /* rename_group */ | |
| 95 | NULL, /* buddy_free */ | |
| 96 | jabber_convo_closed, /* convo_closed */ | |
| 97 | jabber_normalize, /* normalize */ | |
| 98 | jabber_set_buddy_icon, /* set_buddy_icon */ | |
| 99 | NULL, /* remove_group */ | |
| 100 | jabber_chat_buddy_real_name, /* get_cb_real_name */ | |
| 101 | jabber_chat_set_topic, /* set_chat_topic */ | |
| 102 | jabber_find_blist_chat, /* find_blist_chat */ | |
| 103 | jabber_roomlist_get_list, /* roomlist_get_list */ | |
| 104 | jabber_roomlist_cancel, /* roomlist_cancel */ | |
| 105 | NULL, /* roomlist_expand_category */ | |
| 106 | NULL, /* can_receive_file */ | |
| 107 | jabber_si_xfer_send, /* send_file */ | |
| 108 | jabber_si_new_xfer, /* new_xfer */ | |
| 109 | jabber_offline_message, /* offline_message */ | |
| 110 | NULL, /* whiteboard_prpl_ops */ | |
| 111 | jabber_prpl_send_raw, /* send_raw */ | |
| 112 | jabber_roomlist_room_serialize, /* roomlist_room_serialize */ | |
|
16746
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16303
diff
changeset
|
113 | |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16303
diff
changeset
|
114 | /* padding */ |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16303
diff
changeset
|
115 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16303
diff
changeset
|
116 | NULL, |
|
17800
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17799
diff
changeset
|
117 | NULL, |
|
16746
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16303
diff
changeset
|
118 | NULL |
| 16303 | 119 | }; |
| 120 | ||
| 121 | static gboolean load_plugin(PurplePlugin *plugin) | |
| 122 | { | |
| 123 | purple_signal_register(plugin, "jabber-receiving-xmlnode", | |
| 124 | purple_marshal_VOID__POINTER_POINTER, NULL, 2, | |
| 125 | purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONNECTION), | |
| 126 | purple_value_new_outgoing(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_XMLNODE)); | |
| 127 | ||
| 128 | purple_signal_register(plugin, "jabber-sending-xmlnode", | |
| 129 | purple_marshal_VOID__POINTER_POINTER, NULL, 2, | |
| 130 | purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONNECTION), | |
| 131 | purple_value_new_outgoing(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_XMLNODE)); | |
| 132 | ||
| 133 | purple_signal_register(plugin, "jabber-sending-text", | |
| 134 | purple_marshal_VOID__POINTER_POINTER, NULL, 2, | |
| 135 | purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONNECTION), | |
| 136 | purple_value_new_outgoing(PURPLE_TYPE_STRING)); | |
| 137 | ||
| 138 | ||
| 139 | return TRUE; | |
| 140 | } | |
| 141 | ||
| 142 | static gboolean unload_plugin(PurplePlugin *plugin) | |
| 143 | { | |
| 144 | purple_signal_unregister(plugin, "jabber-receiving-xmlnode"); | |
| 145 | ||
| 146 | purple_signal_unregister(plugin, "jabber-sending-xmlnode"); | |
| 147 | ||
| 148 | purple_signal_unregister(plugin, "jabber-sending-text"); | |
| 149 | ||
| 150 | return TRUE; | |
| 151 | } | |
| 152 | ||
| 153 | static PurplePluginInfo info = | |
| 154 | { | |
| 155 | PURPLE_PLUGIN_MAGIC, | |
| 156 | PURPLE_MAJOR_VERSION, | |
| 157 | PURPLE_MINOR_VERSION, | |
| 158 | PURPLE_PLUGIN_PROTOCOL, /**< type */ | |
| 159 | NULL, /**< ui_requirement */ | |
| 160 | 0, /**< flags */ | |
| 161 | NULL, /**< dependencies */ | |
| 162 | PURPLE_PRIORITY_DEFAULT, /**< priority */ | |
| 163 | ||
| 164 | "prpl-jabber", /**< id */ | |
| 165 | "XMPP", /**< name */ | |
| 166 | VERSION, /**< version */ | |
| 167 | /** summary */ | |
|
16961
b6955f946f8f
s/Jabber/XMPP in user-visible places.
Richard Laager <rlaager@pidgin.im>
parents:
16799
diff
changeset
|
168 | N_("XMPP Protocol Plugin"), |
| 16303 | 169 | /** description */ |
|
16961
b6955f946f8f
s/Jabber/XMPP in user-visible places.
Richard Laager <rlaager@pidgin.im>
parents:
16799
diff
changeset
|
170 | N_("XMPP Protocol Plugin"), |
| 16303 | 171 | NULL, /**< author */ |
| 172 | PURPLE_WEBSITE, /**< homepage */ | |
| 173 | ||
| 174 | load_plugin, /**< load */ | |
| 175 | unload_plugin, /**< unload */ | |
| 176 | NULL, /**< destroy */ | |
| 177 | ||
| 178 | NULL, /**< ui_info */ | |
| 179 | &prpl_info, /**< extra_info */ | |
| 180 | NULL, /**< prefs_info */ | |
|
16746
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16303
diff
changeset
|
181 | jabber_actions, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16303
diff
changeset
|
182 | |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16303
diff
changeset
|
183 | /* padding */ |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16303
diff
changeset
|
184 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16303
diff
changeset
|
185 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16303
diff
changeset
|
186 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16303
diff
changeset
|
187 | NULL |
| 16303 | 188 | }; |
| 189 | ||
| 190 | static void | |
| 191 | init_plugin(PurplePlugin *plugin) | |
| 192 | { | |
| 193 | PurpleAccountUserSplit *split; | |
| 194 | PurpleAccountOption *option; | |
| 195 | ||
|
17008
502623177086
Handle people forgetting to enter a domain. Also, change 'server,' in the account options to 'domain,' which is its proper name, and hopefully less confusion
Sean Egan <seanegan@pidgin.im>
parents:
17007
diff
changeset
|
196 | /* Translators: 'domain' is used here in the context of Internet domains, e.g. pidgin.im */ |
|
17012
d8ebf5b1495a
disapproval of revision '1fc45901ebedf4d25b4b3a763665df36d8e411a3'
Richard Laager <rlaager@pidgin.im>
parents:
17011
diff
changeset
|
197 | split = purple_account_user_split_new(_("Domain"), NULL, '@'); |
| 16303 | 198 | prpl_info.user_splits = g_list_append(prpl_info.user_splits, split); |
| 199 | ||
| 200 | split = purple_account_user_split_new(_("Resource"), "Home", '/'); | |
| 201 | prpl_info.user_splits = g_list_append(prpl_info.user_splits, split); | |
| 202 | ||
| 203 | option = purple_account_option_bool_new(_("Force old (port 5223) SSL"), "old_ssl", FALSE); | |
| 204 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
| 205 | option); | |
| 206 | ||
| 207 | option = purple_account_option_bool_new( | |
| 208 | _("Allow plaintext auth over unencrypted streams"), | |
| 209 | "auth_plain_in_clear", FALSE); | |
| 210 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
| 211 | option); | |
| 212 | ||
| 213 | option = purple_account_option_int_new(_("Connect port"), "port", 5222); | |
| 214 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
| 215 | option); | |
| 216 | ||
| 217 | option = purple_account_option_string_new(_("Connect server"), | |
| 218 | "connect_server", NULL); | |
| 219 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
| 220 | option); | |
| 221 | ||
| 222 | ||
| 223 | jabber_init_plugin(plugin); | |
| 224 | ||
| 225 | purple_prefs_remove("/plugins/prpl/jabber"); | |
| 226 | ||
| 227 | /* XXX - If any other plugin wants SASL this won't be good ... */ | |
| 228 | #ifdef HAVE_CYRUS_SASL | |
| 229 | sasl_client_init(NULL); | |
| 230 | #endif | |
| 231 | jabber_register_commands(); | |
| 232 | ||
| 233 | jabber_iq_init(); | |
|
17773
6956b763b3d1
Implemented adding callbacks for PEP events. Moved the feature list to be application-global instead of per-connection (makes more sense).
Andreas Monitzer <am@adiumx.com>
parents:
17012
diff
changeset
|
234 | jabber_pep_init(); |
|
17796
b2b26f663618
Forgot to initialize the user tune
Andreas Monitzer <am@adiumx.com>
parents:
17795
diff
changeset
|
235 | |
|
b2b26f663618
Forgot to initialize the user tune
Andreas Monitzer <am@adiumx.com>
parents:
17795
diff
changeset
|
236 | jabber_tune_init(); |
|
17788
e6e381b0c7d6
Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents:
17787
diff
changeset
|
237 | |
|
17795
53bbd36c7cc6
svn revision 728 of Psi fixes the avatar namespace issue, so I can remove this workaround.
Andreas Monitzer <am@adiumx.com>
parents:
17791
diff
changeset
|
238 | jabber_add_feature("avatarmeta", AVATARNAMESPACEMETA, jabber_pep_namespace_only_when_pep_enabled_cb); |
|
53bbd36c7cc6
svn revision 728 of Psi fixes the avatar namespace issue, so I can remove this workaround.
Andreas Monitzer <am@adiumx.com>
parents:
17791
diff
changeset
|
239 | jabber_add_feature("avatardata", AVATARNAMESPACEDATA, jabber_pep_namespace_only_when_pep_enabled_cb); |
|
17788
e6e381b0c7d6
Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents:
17787
diff
changeset
|
240 | |
|
17795
53bbd36c7cc6
svn revision 728 of Psi fixes the avatar namespace issue, so I can remove this workaround.
Andreas Monitzer <am@adiumx.com>
parents:
17791
diff
changeset
|
241 | jabber_pep_register_handler("avatar", AVATARNAMESPACEMETA, jabber_buddy_avatar_update_metadata); |
| 16303 | 242 | } |
| 243 | ||
| 244 | ||
| 245 | PURPLE_INIT_PLUGIN(jabber, init_plugin, info); |