summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSulabh Mahajan <sulabh@soc.pidgin.im>2009-03-08 06:24:15 (GMT)
committerSulabh Mahajan <sulabh@soc.pidgin.im>2009-03-08 06:24:15 (GMT)
commitf7bb8fde7c600b51d1894da85f08e674d03c1a9c (patch)
treeaba742f4e1e44f4e85b0a437f698de2c1dc5a47b
parent487ea3bda565c9d0c472e465c9438866435250f4 (diff)
parente0d8e16ee8864962efd9f2b06ef6591b9e49c641 (diff)
downloadpidgin-f7bb8fde7c600b51d1894da85f08e674d03c1a9c.tar.gz
pidgin-f7bb8fde7c600b51d1894da85f08e674d03c1a9c.tar.xz
propagate from branch 'im.pidgin.pidgin' (head aa9e255d8e32921a2fe4e6bd74fe36d1ffdc9ec1)
to branch 'im.pidgin.soc.2008.yahoo' (head 9aa024e38a2c67dd29dd2007e9af7a849c90fb26)
-rw-r--r--.mtn-ignore1
-rw-r--r--.todo7
-rw-r--r--COPYRIGHT2
-rw-r--r--ChangeLog27
-rw-r--r--ChangeLog.API70
-rw-r--r--ChangeLog.win325
-rw-r--r--Makefile.am1
-rw-r--r--Makefile.mingw2
-rw-r--r--NEWS11
-rw-r--r--configure.ac44
-rw-r--r--doc/TCL-HOWTO.dox2
-rw-r--r--doc/funniest_home_convos.txt7
-rw-r--r--doc/notify-signals.dox2
-rw-r--r--doc/pidgin.1.in8
-rw-r--r--finch/gntaccount.c10
-rw-r--r--finch/gntblist.c32
-rw-r--r--finch/gntconv.c7
-rw-r--r--finch/gntlog.c46
-rw-r--r--finch/gntlog.h2
-rw-r--r--finch/gntrequest.c27
-rw-r--r--finch/plugins/grouping.c2
-rwxr-xr-xfix-casts.sh18
-rw-r--r--libpurple/Makefile.am10
-rw-r--r--libpurple/Makefile.mingw7
-rw-r--r--libpurple/account.c87
-rw-r--r--libpurple/account.h2
-rw-r--r--libpurple/blist.c125
-rw-r--r--libpurple/blist.h139
-rw-r--r--libpurple/buddyicon.c18
-rw-r--r--libpurple/certificate.c132
-rw-r--r--libpurple/certificate.h16
-rw-r--r--libpurple/cipher.c38
-rw-r--r--libpurple/cipher.h2
-rw-r--r--libpurple/circbuffer.c4
-rw-r--r--libpurple/cmds.c16
-rw-r--r--libpurple/connection.c36
-rw-r--r--libpurple/connection.h110
-rw-r--r--libpurple/conversation.c10
-rw-r--r--libpurple/conversation.h2
-rw-r--r--libpurple/core.c29
-rw-r--r--libpurple/core.h10
-rw-r--r--libpurple/dbus-bindings.h2
-rw-r--r--libpurple/dbus-server.h2
-rw-r--r--libpurple/desktopitem.c81
-rw-r--r--libpurple/desktopitem.h6
-rw-r--r--libpurple/eventloop.h10
-rw-r--r--libpurple/idle.c6
-rw-r--r--libpurple/internal.h2
-rw-r--r--libpurple/log.c130
-rw-r--r--libpurple/log.h15
-rw-r--r--libpurple/nat-pmp.c30
-rw-r--r--libpurple/network.c17
-rw-r--r--libpurple/network.h11
-rw-r--r--libpurple/notify.c32
-rw-r--r--libpurple/notify.h8
-rw-r--r--libpurple/ntlm.h2
-rw-r--r--libpurple/plugin.c12
-rw-r--r--libpurple/plugin.h4
-rw-r--r--libpurple/plugins/Makefile.am4
-rw-r--r--libpurple/plugins/Makefile.mingw2
-rw-r--r--libpurple/plugins/autoaccept.c2
-rw-r--r--libpurple/plugins/one_time_password.c151
-rw-r--r--libpurple/plugins/perl/common/BuddyList.xs4
-rw-r--r--libpurple/plugins/perl/common/Request.xs30
-rw-r--r--libpurple/plugins/ssl/ssl-gnutls.c4
-rw-r--r--libpurple/plugins/statenotify.c2
-rw-r--r--libpurple/plugins/tcl/tcl_cmds.c13
-rw-r--r--libpurple/pounce.c76
-rw-r--r--libpurple/prefs.c43
-rw-r--r--libpurple/prefs.h4
-rw-r--r--libpurple/privacy.c10
-rw-r--r--libpurple/privacy.h2
-rw-r--r--libpurple/protocols/Makefile.mingw2
-rw-r--r--libpurple/protocols/bonjour/bonjour.c15
-rw-r--r--libpurple/protocols/bonjour/bonjour_ft.c28
-rw-r--r--libpurple/protocols/bonjour/buddy.c6
-rw-r--r--libpurple/protocols/bonjour/jabber.c106
-rw-r--r--libpurple/protocols/bonjour/mdns_avahi.c4
-rw-r--r--libpurple/protocols/gg/buddylist.c91
-rw-r--r--libpurple/protocols/gg/gg.c7
-rw-r--r--libpurple/protocols/irc/irc.c4
-rw-r--r--libpurple/protocols/irc/msgs.c21
-rw-r--r--libpurple/protocols/jabber/Makefile.am2
-rw-r--r--libpurple/protocols/jabber/Makefile.mingw1
-rw-r--r--libpurple/protocols/jabber/adhoccommands.c67
-rw-r--r--libpurple/protocols/jabber/auth.c10
-rw-r--r--libpurple/protocols/jabber/buddy.c168
-rw-r--r--libpurple/protocols/jabber/caps.c44
-rw-r--r--libpurple/protocols/jabber/chat.c8
-rw-r--r--libpurple/protocols/jabber/data.c14
-rw-r--r--libpurple/protocols/jabber/data.h6
-rw-r--r--libpurple/protocols/jabber/disco.c20
-rw-r--r--libpurple/protocols/jabber/google.c14
-rw-r--r--libpurple/protocols/jabber/ibb.c521
-rw-r--r--libpurple/protocols/jabber/ibb.h119
-rw-r--r--libpurple/protocols/jabber/iq.c8
-rw-r--r--libpurple/protocols/jabber/jabber.c199
-rw-r--r--libpurple/protocols/jabber/jabber.h12
-rw-r--r--libpurple/protocols/jabber/libxmpp.c38
-rw-r--r--libpurple/protocols/jabber/message.c65
-rw-r--r--libpurple/protocols/jabber/message.h2
-rw-r--r--libpurple/protocols/jabber/pep.c24
-rw-r--r--libpurple/protocols/jabber/presence.c28
-rw-r--r--libpurple/protocols/jabber/roster.c47
-rw-r--r--libpurple/protocols/jabber/si.c505
-rw-r--r--libpurple/protocols/jabber/si.h2
-rw-r--r--libpurple/protocols/jabber/usermood.c12
-rw-r--r--libpurple/protocols/jabber/usernick.c16
-rw-r--r--libpurple/protocols/jabber/usertune.c6
-rw-r--r--libpurple/protocols/jabber/xdata.c4
-rw-r--r--libpurple/protocols/msn/directconn.c20
-rw-r--r--libpurple/protocols/msn/msn.c69
-rw-r--r--libpurple/protocols/msn/notification.c5
-rw-r--r--libpurple/protocols/msn/session.c13
-rw-r--r--libpurple/protocols/msn/user.c3
-rw-r--r--libpurple/protocols/msn/userlist.c20
-rw-r--r--libpurple/protocols/myspace/README16
-rw-r--r--libpurple/protocols/myspace/myspace.c66
-rw-r--r--libpurple/protocols/myspace/user.c42
-rw-r--r--libpurple/protocols/myspace/zap.c4
-rw-r--r--libpurple/protocols/novell/novell.c110
-rw-r--r--libpurple/protocols/null/README7
-rw-r--r--libpurple/protocols/null/nullprpl.c86
-rw-r--r--libpurple/protocols/oscar/bstream.c34
-rw-r--r--libpurple/protocols/oscar/family_admin.c7
-rw-r--r--libpurple/protocols/oscar/family_alert.c10
-rw-r--r--libpurple/protocols/oscar/family_auth.c18
-rw-r--r--libpurple/protocols/oscar/family_bart.c22
-rw-r--r--libpurple/protocols/oscar/family_bos.c3
-rw-r--r--libpurple/protocols/oscar/family_buddy.c4
-rw-r--r--libpurple/protocols/oscar/family_feedbag.c164
-rw-r--r--libpurple/protocols/oscar/family_icbm.c196
-rw-r--r--libpurple/protocols/oscar/family_locate.c112
-rw-r--r--libpurple/protocols/oscar/family_odir.c8
-rw-r--r--libpurple/protocols/oscar/family_oservice.c27
-rw-r--r--libpurple/protocols/oscar/odc.c32
-rw-r--r--libpurple/protocols/oscar/oft.c2
-rw-r--r--libpurple/protocols/oscar/oscar.c976
-rw-r--r--libpurple/protocols/oscar/oscar.h107
-rw-r--r--libpurple/protocols/oscar/peer.c56
-rw-r--r--libpurple/protocols/oscar/peer.h14
-rw-r--r--libpurple/protocols/oscar/peer_proxy.c32
-rw-r--r--libpurple/protocols/oscar/snactypes.h5
-rw-r--r--libpurple/protocols/oscar/util.c72
-rw-r--r--libpurple/protocols/qq/buddy_info.c12
-rw-r--r--libpurple/protocols/qq/buddy_list.c25
-rw-r--r--libpurple/protocols/qq/buddy_opt.c50
-rw-r--r--libpurple/protocols/qq/group_internal.c28
-rw-r--r--libpurple/protocols/qq/im.c4
-rw-r--r--libpurple/protocols/qq/qq.c31
-rw-r--r--libpurple/protocols/qq/send_file.c2
-rw-r--r--libpurple/protocols/sametime/sametime.c187
-rw-r--r--libpurple/protocols/silc/buddy.c100
-rw-r--r--libpurple/protocols/silc/chat.c54
-rw-r--r--libpurple/protocols/silc/ops.c22
-rw-r--r--libpurple/protocols/simple/simple.c35
-rw-r--r--libpurple/protocols/toc/toc.c12
-rw-r--r--libpurple/protocols/yahoo/yahoo.c69
-rw-r--r--libpurple/protocols/yahoo/yahoo_picture.c2
-rw-r--r--libpurple/protocols/yahoo/yahoo_profile.c11
-rw-r--r--libpurple/protocols/yahoo/yahoochat.c2
-rw-r--r--libpurple/protocols/zephyr/zephyr.c152
-rw-r--r--libpurple/proxy.c36
-rw-r--r--libpurple/proxy.h8
-rw-r--r--libpurple/prpl.c8
-rw-r--r--libpurple/prpl.h57
-rwxr-xr-xlibpurple/purple-send-async12
-rwxr-xr-xlibpurple/purple-url-handler6
-rw-r--r--libpurple/request.c27
-rw-r--r--libpurple/request.h44
-rw-r--r--libpurple/savedstatuses.c7
-rw-r--r--libpurple/server.c34
-rw-r--r--libpurple/server.h12
-rw-r--r--libpurple/signals.c4
-rw-r--r--libpurple/signals.h2
-rw-r--r--libpurple/smiley.c2
-rw-r--r--libpurple/sound-theme-loader.c111
-rw-r--r--libpurple/sound-theme-loader.h71
-rw-r--r--libpurple/sound-theme.c158
-rw-r--r--libpurple/sound-theme.h105
-rw-r--r--libpurple/sound.c4
-rw-r--r--libpurple/sslconn.c2
-rw-r--r--libpurple/sslconn.h4
-rw-r--r--libpurple/status.c40
-rw-r--r--libpurple/status.h50
-rw-r--r--libpurple/stun.c4
-rw-r--r--libpurple/theme-loader.c183
-rw-r--r--libpurple/theme-loader.h92
-rw-r--r--libpurple/theme-manager.c295
-rw-r--r--libpurple/theme-manager.h131
-rw-r--r--libpurple/theme.c408
-rw-r--r--libpurple/theme.h175
-rw-r--r--libpurple/upnp.c2
-rw-r--r--libpurple/util.c88
-rw-r--r--libpurple/util.h15
-rw-r--r--libpurple/whiteboard.c2
-rw-r--r--libpurple/xmlnode.c110
-rw-r--r--libpurple/xmlnode.h18
-rw-r--r--pidgin/Makefile.am10
-rw-r--r--pidgin/Makefile.mingw5
-rw-r--r--pidgin/eggtrayicon.c28
-rw-r--r--pidgin/eggtrayicon.h6
-rw-r--r--pidgin/getopt.c8
-rw-r--r--pidgin/getopt1.c2
-rw-r--r--pidgin/gtkaccount.c62
-rw-r--r--pidgin/gtkblist-theme-loader.c279
-rw-r--r--pidgin/gtkblist-theme-loader.h71
-rw-r--r--pidgin/gtkblist-theme.c784
-rw-r--r--pidgin/gtkblist-theme.h332
-rw-r--r--pidgin/gtkblist.c988
-rw-r--r--pidgin/gtkblist.h20
-rw-r--r--pidgin/gtkcellrendererexpander.c45
-rw-r--r--pidgin/gtkcellrendererexpander.h2
-rw-r--r--pidgin/gtkcellrendererprogress.c32
-rw-r--r--pidgin/gtkcellrendererprogress.h2
-rw-r--r--pidgin/gtkcellview.c20
-rw-r--r--pidgin/gtkconv.c81
-rw-r--r--pidgin/gtkdebug.c4
-rw-r--r--pidgin/gtkdialogs.c10
-rw-r--r--pidgin/gtkdnd-hints.c8
-rw-r--r--pidgin/gtkdocklet-x11.c12
-rw-r--r--pidgin/gtkdocklet.h8
-rw-r--r--pidgin/gtkexpander.c40
-rw-r--r--pidgin/gtkicon-theme-loader.c111
-rw-r--r--pidgin/gtkicon-theme-loader.h71
-rw-r--r--pidgin/gtkicon-theme.c142
-rw-r--r--pidgin/gtkicon-theme.h93
-rw-r--r--pidgin/gtkimhtml.c404
-rw-r--r--pidgin/gtkimhtml.h74
-rw-r--r--pidgin/gtkimhtmltoolbar.c8
-rw-r--r--pidgin/gtklog.c44
-rw-r--r--pidgin/gtklog.h4
-rw-r--r--pidgin/gtkmain.c43
-rw-r--r--pidgin/gtkpluginpref.c2
-rw-r--r--pidgin/gtkpounce.c16
-rw-r--r--pidgin/gtkpounce.h2
-rw-r--r--pidgin/gtkprefs.c293
-rw-r--r--pidgin/gtkprefs.h2
-rw-r--r--pidgin/gtkrequest.c59
-rw-r--r--pidgin/gtksavedstatuses.c16
-rw-r--r--pidgin/gtkscrollbook.h2
-rw-r--r--pidgin/gtksession.c2
-rw-r--r--pidgin/gtksmiley.c30
-rw-r--r--pidgin/gtksmiley.h8
-rw-r--r--pidgin/gtksound.c48
-rw-r--r--pidgin/gtksound.h9
-rw-r--r--pidgin/gtksourceiter.c26
-rw-r--r--pidgin/gtksourceiter.h4
-rw-r--r--pidgin/gtksourceundomanager.c298
-rw-r--r--pidgin/gtksourceundomanager.h18
-rw-r--r--pidgin/gtkstatus-icon-theme.c72
-rw-r--r--pidgin/gtkstatus-icon-theme.h71
-rw-r--r--pidgin/gtkstatusbox.c40
-rw-r--r--pidgin/gtkthemes.c6
-rw-r--r--pidgin/gtkutils.c282
-rw-r--r--pidgin/gtkutils.h50
-rw-r--r--pidgin/gtkwhiteboard.c2
-rw-r--r--pidgin/pidgincombobox.c234
-rw-r--r--pidgin/pidginstock.c303
-rw-r--r--pidgin/pidginstock.h11
-rw-r--r--pidgin/pixmaps/Makefile.am4
-rwxr-xr-x[-rw-r--r--]pidgin/pixmaps/art-tools/clean-svg-definitions.sh0
-rw-r--r--pidgin/plugins/gevolution/gevo-util.c6
-rw-r--r--pidgin/plugins/gevolution/gevolution.c8
-rw-r--r--pidgin/plugins/gevolution/new_person_dialog.c26
-rw-r--r--pidgin/plugins/history.c31
-rw-r--r--pidgin/plugins/perl/common/GtkLog.xs4
-rw-r--r--pidgin/plugins/ticker/ticker.c23
-rw-r--r--pidgin/plugins/win32/winprefs/gtkappbar.c6
-rw-r--r--po/ChangeLog2
-rw-r--r--po/POTFILES.in1
-rw-r--r--po/README2
-rw-r--r--po/ca.po222
-rw-r--r--po/et.po2
-rw-r--r--po/ru.po74
275 files changed, 11553 insertions, 4193 deletions
diff --git a/.mtn-ignore b/.mtn-ignore
index 3f6c88a..de8aae2 100644
--- a/.mtn-ignore
+++ b/.mtn-ignore
@@ -10,6 +10,7 @@
.*\.def$
.*\.dll$
.*\.exe$
+.*\.loT$
intltool-.*
Doxyfile(\.mingw)?$
aclocal.m4
diff --git a/.todo b/.todo
deleted file mode 100644
index 20487b9..0000000
--- a/.todo
+++ /dev/null
@@ -1,7 +0,0 @@
-<todo version="0.1.19">
- <title>
- Gaim TODO List
- </title>
- <link filename="./libpurple/protocols/oscar/.todo" priority="medium" time="0"/>
- <link filename="./libpurple/protocols/jabber/.todo" priority="medium" time="1176995038"/>
-</todo>
diff --git a/COPYRIGHT b/COPYRIGHT
index 50b62ed..239003d 100644
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -57,6 +57,7 @@ Jeffery Brown
Philip Brown
Dan Bruce
Norbert Buchmuller
+Johannes Buchner
Sean Burke
Thomas Butter
Trevor Caira
@@ -87,6 +88,7 @@ Jono Cole
Lorenzo Colitti
Collabora Ltd.
Jeff Connelly
+Chris Connett
Nathan Conrad
Felipe Contreras
Alex Converse
diff --git a/ChangeLog b/ChangeLog
index 33f8d80..ef538d8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,25 @@
Pidgin and Finch: The Pimpin' Penguin IM Clients That're Good for the Soul
-version 2.5.5 (??/??/????):
+version 2.6.0 (??/??/2009):
+ General:
+ * Theme support in libpurple thanks to Justin Rodriguez's summer of code
+ project. With some minor additions and clean ups from Paul Aurich.
+
+ XMPP:
+ * Add support for in-band bytestreams (XEP-0047).
+ * Add support for attention (XEP-0224).
+
+ Pidgin:
+ * Added -f command line option to tell Pidgin to ignore NetworkManager
+ and assume it has a valid network connection.
+ * Allow plugins to specify custom link types to the GtkIMHtml widget.
+ * The status message input box at the bottom of the buddy list expands
+ correctly when starting a new line of text.
+ * Pressing the Enter key in the message entry box of the New Status
+ dialog and various other dialogs now causes the cursor to move to
+ the next line.
+
+version 2.5.5 (03/01/2009):
libpurple:
* Fix a crash when removing an account with an unknown protocol id.
* Beta support for SSL connections for AIM and ICQ accounts. To
@@ -669,13 +688,13 @@ version 2.2.1 (09/29/2007):
version 2.2.0 (09/13/2007):
http://developer.pidgin.im/query?status=closed&milestone=2.2.0
- Libpurple:
+ libpurple:
* New protocol plugin: MySpaceIM (Jeff Connelly, Google Summer of
Code)
* XMPP enhancements. See
- http://www.adiumx.com/blog/2007/07/soc-xmpp-update.php (Andreas
+ http://www.adiumx.com/blog/2007/07/soc-xmpp-update.php (Andreas
Monitzer, Google Summer of Code for Adium)
- * Certificate management. Libpurple will validate certificates on
+ * Certificate management. libpurple will validate certificates on
SSL-encrypted protocols (William Ehlhardt, Google Summer of Code)
* Some adjustments were made to fix sending messages when using
the MSN HTTP method. (Laszlo Pandy)
diff --git a/ChangeLog.API b/ChangeLog.API
index 883c8fb..ba94d7b 100644
--- a/ChangeLog.API
+++ b/ChangeLog.API
@@ -1,6 +1,74 @@
Pidgin and Finch: The Pimpin' Penguin IM Clients That're Good for the Soul
-version 2.5.5 (??/??/2009):
+version 2.6.0 (??/??/2009):
+ libpurple:
+ Added:
+ * PURPLE_BLIST_NODE
+ * PURPLE_GROUP
+ * PURPLE_CONTACT
+ * PURPLE_BUDDY
+ * PURPLE_CHAT
+ * purple_buddy_get_protocol_data
+ * purple_buddy_set_protocol_data
+ * purple_buddy_get_local_buddy_alias
+ * purple_blist_get_buddies
+ * purple_blist_get_ui_data
+ * purple_blist_set_ui_data
+ * purple_blist_node_get_ui_data
+ * purple_blist_node_set_ui_data
+ * purple_connection_get_protocol_data
+ * purple_connection_set_protocol_data
+ * purple_global_proxy_set_info
+ * purple_log_get_activity_score
+ * purple_network_force_online
+ * purple_request_field_get_group
+ * purple_request_field_get_ui_data
+ * purple_request_field_set_ui_data
+ * purple_strequal
+ * xmlnode_from_file
+
+ Deprecated:
+ * purple_buddy_get_local_alias
+ * purple_notify_user_info_remove_entry
+ * purple_status_type_set_primary_attr
+ * purple_status_type_add_attr
+ * purple_status_type_add_attrs
+ * purple_status_type_add_attrs_vargs
+ * purple_status_type_get_primary_attr
+ * purple_status_set_attr_boolean
+ * purple_status_set_attr_int
+ * purple_status_set_attr_string
+ * purple_presence_add_status
+ * purple_presence_add_list
+
+ pidgin:
+ Added:
+ * gtk_imhtml_class_register_protocol
+ * gtk_imhtml_link_get_url, gtk_imhtml_link_get_text_tag,
+ gtk_imhtml_link_activate functions to process GtkIMHtmlLink
+ objects from GtkIMHtml protocol callbacks.
+ * gtk_imhtml_set_return_inserts_newline
+ * pidgin_blist_set_theme
+ * pidgin_blist_get_theme
+ * pidgin_sound_is_customized
+ * pidgin_utils_init, pidgin_utils_uninit
+
+ perl:
+ Changed:
+ * Made a bunch of functions act more perl-like. Call the new()
+ functions as Class->new(...) instead of Class::new(...):
+ * Purple::Request::Fields::new
+ * Purple::Request::Field::new
+ * Purple::Request::Field::account_new
+ * Purple::Request::Field::bool_new
+ * Purple::Request::Field::choice_new
+ * Purple::Request::Field::int_new
+ * Purple::Request::Field::label_new
+ * Purple::Request::Field::list_new
+ * Purple::Request::Field::string_new
+ * Purple::Request::Field::group_new
+
+version 2.5.5 (03/01/2009):
libpurple:
Changed:
* purple_status_type_new now defaults "saveable" to TRUE.
diff --git a/ChangeLog.win32 b/ChangeLog.win32
index 3e3e10c..74b752a 100644
--- a/ChangeLog.win32
+++ b/ChangeLog.win32
@@ -1,7 +1,10 @@
-version 2.5.5 (??/??/2009):
+version 2.6.0 (??/??/2009):
+
+version 2.5.5 (03/01/2009):
* Remove the "Flash window when chat messages are received" pref from
the Windows Pidgin Options plugin - the Message Notification plugin
does this (and much more).
+ * Updated GTK+ to 2.14.7
version 2.5.4 (01/12/2009):
* Fix the "Hang on Exit" issue that a number of users encountered.
diff --git a/Makefile.am b/Makefile.am
index d875d81..28c2e40 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -10,6 +10,7 @@ EXTRA_DIST = \
README.mingw \
config.h.mingw \
doxy2devhelp.xsl \
+ fix-casts.sh \
gaim.pc.in \
gaim-uninstalled.pc.in \
intltool-extract.in \
diff --git a/Makefile.mingw b/Makefile.mingw
index b5acdba..a1d7c8d 100644
--- a/Makefile.mingw
+++ b/Makefile.mingw
@@ -2,7 +2,7 @@
#
# Author: hermanator12002@yahoo.com
# Date 9/11/02
-# Description: Top Makefile for win32 (mingw) port of Pidgin and LibPurple
+# Description: Top Makefile for win32 (mingw) port of Pidgin and libpurple
#
PIDGIN_TREE_TOP := .
diff --git a/NEWS b/NEWS
index ed6536b..d43f4ed 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,17 @@ Pidgin and Finch: The Pimpin' Penguin IM Clients That're Good for the Soul
Our development blog is available at: http://planet.pidgin.im
+2.5.5 (03/01/2009):
+ John: Well, yet another release with bug fixing and patches. Hopefully
+ one of the fixed bugs is one that irritated you. Also, thank Dimmuxx
+ for spending far too much time working on ICQ this release.
+
+ Elliott: Lots and lots of MSN bugfixes again (I hope they're fixed, at
+ least). I think we finally have OCS/Yahoo!/federated buddies working
+ now. And there should be some workarounds for some server things that
+ may or may not have been our fault (like buddies on Allow+Block) which
+ should make general usage a bit smoother.
+
2.5.4 (01/12/2009):
John: Well, we fixed a few bugs for you this time around, I applied
a few patches, and we've dealt with what feels like a TON of tickets
diff --git a/configure.ac b/configure.ac
index cbe2c90..88de36f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -43,19 +43,19 @@ AC_PREREQ([2.50])
#
# Make sure to update finch/libgnt/configure.ac with libgnt version changes.
#
-m4_define([purple_lt_current], [5])
+m4_define([purple_lt_current], [6])
m4_define([purple_major_version], [2])
-m4_define([purple_minor_version], [5])
-m4_define([purple_micro_version], [5])
+m4_define([purple_minor_version], [6])
+m4_define([purple_micro_version], [0])
m4_define([purple_version_suffix], [devel])
m4_define([purple_version],
[purple_major_version.purple_minor_version.purple_micro_version])
m4_define([purple_display_version], purple_version[]m4_ifdef([purple_version_suffix],[purple_version_suffix]))
-m4_define([gnt_lt_current], [5])
+m4_define([gnt_lt_current], [6])
m4_define([gnt_major_version], [2])
-m4_define([gnt_minor_version], [5])
-m4_define([gnt_micro_version], [5])
+m4_define([gnt_minor_version], [6])
+m4_define([gnt_micro_version], [0])
m4_define([gnt_version_suffix], [devel])
m4_define([gnt_version],
[gnt_major_version.gnt_minor_version.gnt_micro_version])
@@ -1103,6 +1103,7 @@ for i in $DYNAMIC_PRPLS ; do
msnp9) dynamic_msn=yes ;;
myspace) dynamic_myspace=yes ;;
novell) dynamic_novell=yes ;;
+ null) dynamic_null=yes ;;
oscar) dynamic_oscar=yes ;;
aim) dynamic_oscar=yes ;;
icq) dynamic_oscar=yes ;;
@@ -1117,21 +1118,6 @@ for i in $DYNAMIC_PRPLS ; do
*) echo "Invalid dynamic protocol $i!!" ; exit ;;
esac
done
-AM_CONDITIONAL(DYNAMIC_BONJOUR, test "x$dynamic_bonjour" = "xyes" -a [ "x$avahiincludes" = "xyes" -a "x$avahilibs " = "xyes" ] )
-AM_CONDITIONAL(DYNAMIC_GG, test "x$dynamic_gg" = "xyes")
-AM_CONDITIONAL(DYNAMIC_IRC, test "x$dynamic_irc" = "xyes")
-AM_CONDITIONAL(DYNAMIC_JABBER, test "x$dynamic_jabber" = "xyes")
-AM_CONDITIONAL(DYNAMIC_MSN, test "x$dynamic_msn" = "xyes")
-AM_CONDITIONAL(DYNAMIC_MYSPACE, test "x$dynamic_myspace" = "xyes")
-AM_CONDITIONAL(DYNAMIC_NOVELL, test "x$dynamic_novell" = "xyes")
-AM_CONDITIONAL(DYNAMIC_OSCAR, test "x$dynamic_oscar" = "xyes")
-AM_CONDITIONAL(DYNAMIC_QQ, test "x$dynamic_qq" = "xyes")
-AM_CONDITIONAL(DYNAMIC_SAMETIME, test "x$dynamic_sametime" = "xyes" -a "x$have_meanwhile" = "xyes")
-AM_CONDITIONAL(DYNAMIC_SILC, test "x$dynamic_silc" = "xyes" -a "x$have_silc" = "xyes")
-AM_CONDITIONAL(DYNAMIC_SIMPLE, test "x$dynamic_simple" = "xyes")
-AM_CONDITIONAL(DYNAMIC_TOC, test "x$dynamic_toc" = "xyes")
-AM_CONDITIONAL(DYNAMIC_YAHOO, test "x$dynamic_yahoo" = "xyes")
-AM_CONDITIONAL(DYNAMIC_ZEPHYR, test "x$dynamic_zephyr" = "xyes")
AC_ARG_ENABLE(plugins, [AC_HELP_STRING([--disable-plugins], [compile without plugin support])], , enable_plugins=yes)
AC_ARG_WITH(krb4, [AC_HELP_STRING([--with-krb4=PREFIX], [compile Zephyr plugin with Kerberos 4 support])], kerberos="$withval", kerberos="no")
@@ -1702,6 +1688,22 @@ fi
AC_SUBST(GNUTLS_CFLAGS)
AC_SUBST(GNUTLS_LIBS)
+if test "x$enable_gnutls" = "xyes"; then
+ AC_MSG_CHECKING(for gnutls_priority_set_direct)
+ LIBS_save="$LIBS"
+ LIBS="$LIBS $GNUTLS_LIBS"
+ CPPFLAGS_save="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS $GNUTLS_CFLAGS"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <gnutls/gnutls.h>],
+ [gnutls_session s; gnutls_priority_set_direct(s, NULL, NULL);])],
+ [AC_DEFINE([HAVE_GNUTLS_PRIORITY_FUNCS], 1,
+ [Define if your gnutls has gnutls_priority_set_direct and friends])
+ AC_MSG_RESULT(yes)],
+ [AC_MSG_RESULT(no)])
+ CPPFLAGS="$CPPFLAGS_save"
+ LIBS="$LIBS_save"
+fi
+
AM_CONDITIONAL(USE_GNUTLS, test "x$enable_gnutls" = "xyes")
diff --git a/doc/TCL-HOWTO.dox b/doc/TCL-HOWTO.dox
index 931e5bf..f8a4830 100644
--- a/doc/TCL-HOWTO.dox
+++ b/doc/TCL-HOWTO.dox
@@ -332,7 +332,7 @@ be made in their own namespace, and arguments to those signal
callbacks will live in the namespace @c event underneath that
namespace. To briefly illustrate, the signal @c receiving-im-msg is
provided with three arguments; the account on which the IM was
-received, the screen name of the user sending the IM, and the text of
+received, the name of the buddy sending the IM, and the text of
the IM. These arguments live in the variables @c event::account,
@c event::sender, and @c event::buffer, respectively. Therefore a callback
which notifies the user of an incoming IM containing the word 'shizzle'
diff --git a/doc/funniest_home_convos.txt b/doc/funniest_home_convos.txt
index 08950dd..29f10d0 100644
--- a/doc/funniest_home_convos.txt
+++ b/doc/funniest_home_convos.txt
@@ -565,3 +565,10 @@ not :)
for using pidgen
22:36 <user> why do they think this is a bad client? does it have history?
+--
+
+15:45 <deryni> We've had a Grand Plugin Database Plan for approximately forever.
+15:45 <SimGuy> ah, the GPDP
+15:46 <khc> well, there was a Grand Smiley Theme Database
+15:47 <SimGuy> the GSTD sounds like a bad acronym
+15:47 <khc> I realized after typing that
diff --git a/doc/notify-signals.dox b/doc/notify-signals.dox
index a21c6ef..9c85c47 100644
--- a/doc/notify-signals.dox
+++ b/doc/notify-signals.dox
@@ -18,7 +18,7 @@ void (*displaying_userinfo)(PurpleAccount *account, const char *who, PurpleNotif
@note
If adding a PurpleNotifyUserInfoEntry, be sure not to free it -- PurpleNotifyUserInfo assumes responsibility for its objects.
@param account The account on which the info was obtained.
- @param who The screen name of the user whose info is to be displayed.
+ @param who The name of the buddy whose info is to be displayed.
@param user_info The information to be displayed, as PurpleNotifyUserInfoEntry objects
@endsignaldef
diff --git a/doc/pidgin.1.in b/doc/pidgin.1.in
index 8675870..0a91454 100644
--- a/doc/pidgin.1.in
+++ b/doc/pidgin.1.in
@@ -128,11 +128,11 @@ buddy or chat.
.TP
.B Alias
Create an alias for this buddy. This will show an editable text field where
-the buddy's screen name was displayed. In this field one can give this
+the buddy's name was displayed. In this field one can give this
buddy an alternate, more friendly name to appear on the buddy list and in
conversations.
-For example, if a buddy's name screen name was jsmith1281xx and his real
+For example, if a buddy's name was jsmith1281xx and his real
name was 'John Q. Smith,' one could create an alias as to identify the
buddy by his common name.
.LP
@@ -150,7 +150,7 @@ them. It can be accessed by selecting \fBManage\fR from the Accounts menu.
Clicking \fIDelete\fR will delete the currently selected account.
Clicking \fIAdd\fR or \fIModify\fR will invoke a \fBModify Account\fR
window. Here, the user can add or alter account information. When creating
-a new account, the user will submit a screen name and password. The user will
+a new account, the user will submit a username and password. The user will
also choose the protocol for the account.
If \fIRemember Password\fR is chosen, the password will be saved in
@@ -545,7 +545,7 @@ about this interaction exists.
.br
\fI~/.purple/status.xml\fR: stores the user's away messages.
.br
- \fI~/.purple/logs/PROTOCOL/ACCOUNT/SCREENNAME/DATE.{html,txt}\fR: conversation logs.
+ \fI~/.purple/logs/PROTOCOL/ACCOUNT/BUDDYNAME/DATE.{html,txt}\fR: conversation logs.
.SH DIRECTORIES
\fI@prefix@/lib/pidgin/\fR: Pidgin's plugins directory.
diff --git a/finch/gntaccount.c b/finch/gntaccount.c
index 575f3b0..b7fe539 100644
--- a/finch/gntaccount.c
+++ b/finch/gntaccount.c
@@ -65,7 +65,7 @@ typedef struct
GntWidget *window;
GntWidget *protocol;
- GntWidget *screenname;
+ GntWidget *username;
GntWidget *password;
GntWidget *alias;
@@ -118,8 +118,8 @@ save_account_cb(AccountEditDialog *dialog)
plugin = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(dialog->protocol));
prplinfo = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);
- /* Screenname && user-splits */
- value = gnt_entry_get_text(GNT_ENTRY(dialog->screenname));
+ /* Username && user-splits */
+ value = gnt_entry_get_text(GNT_ENTRY(dialog->username));
if (value == NULL || *value == '\0')
{
@@ -326,7 +326,7 @@ update_user_splits(AccountEditDialog *dialog)
}
if (username != NULL)
- gnt_entry_set_text(GNT_ENTRY(dialog->screenname), username);
+ gnt_entry_set_text(GNT_ENTRY(dialog->username), username);
g_free(username);
}
@@ -546,7 +546,7 @@ edit_account(PurpleAccount *account)
gnt_box_set_pad(GNT_BOX(hbox), 0);
gnt_box_add_widget(GNT_BOX(window), hbox);
- dialog->screenname = entry = gnt_entry_new(NULL);
+ dialog->username = entry = gnt_entry_new(NULL);
gnt_box_add_widget(GNT_BOX(hbox), gnt_label_new(_("Username:")));
gnt_box_add_widget(GNT_BOX(hbox), entry);
diff --git a/finch/gntblist.c b/finch/gntblist.c
index 39f852f..949d5b7 100644
--- a/finch/gntblist.c
+++ b/finch/gntblist.c
@@ -357,7 +357,7 @@ get_display_color(PurpleBlistNode *node)
int color = 0;
if (PURPLE_BLIST_NODE_IS_CONTACT(node))
- node = (PurpleBlistNode*)purple_contact_get_priority_buddy((PurpleContact*)node);
+ node = PURPLE_BLIST_NODE(purple_contact_get_priority_buddy(PURPLE_CONTACT(node)));
if (!PURPLE_BLIST_NODE_IS_BUDDY(node))
return 0;
@@ -388,7 +388,7 @@ get_blist_node_flag(PurpleBlistNode *node)
if (fnode && fnode->signed_timer)
flag |= GNT_TEXT_FLAG_BLINK;
else if (PURPLE_BLIST_NODE_IS_CONTACT(node)) {
- node = (PurpleBlistNode*)purple_contact_get_priority_buddy((PurpleContact *)node);
+ node = PURPLE_BLIST_NODE(purple_contact_get_priority_buddy(PURPLE_CONTACT(node)));
fnode = FINCH_GET_DATA(node);
if (fnode && fnode->signed_timer)
flag |= GNT_TEXT_FLAG_BLINK;
@@ -886,7 +886,7 @@ get_display_name(PurpleBlistNode *node)
const char *name = NULL;
if (PURPLE_BLIST_NODE_IS_CONTACT(node))
- node = (PurpleBlistNode*)purple_contact_get_priority_buddy((PurpleContact*)node); /* XXX: this can return NULL?! */
+ node = PURPLE_BLIST_NODE(purple_contact_get_priority_buddy(PURPLE_CONTACT(node))); /* XXX: this can return NULL?! */
if (node == NULL)
return NULL;
@@ -1027,7 +1027,7 @@ selection_activate(GntWidget *widget, FinchBlist *ggblist)
return;
if (PURPLE_BLIST_NODE_IS_CONTACT(node))
- node = (PurpleBlistNode*)purple_contact_get_priority_buddy((PurpleContact*)node);
+ node = PURPLE_BLIST_NODE(purple_contact_get_priority_buddy(PURPLE_CONTACT(node)));
if (PURPLE_BLIST_NODE_IS_BUDDY(node))
{
@@ -1438,16 +1438,16 @@ static void showlog_cb(PurpleBlistNode *sel, PurpleBlistNode *node)
if (PURPLE_BLIST_NODE_IS_BUDDY(node)) {
PurpleBuddy *b = (PurpleBuddy*) node;
type = PURPLE_LOG_IM;
- name = g_strdup(b->name);
- account = b->account;
+ name = g_strdup(purple_buddy_get_name(b));
+ account = purple_buddy_get_account(b);
} else if (PURPLE_BLIST_NODE_IS_CHAT(node)) {
PurpleChat *c = (PurpleChat*) node;
PurplePluginProtocolInfo *prpl_info = NULL;
type = PURPLE_LOG_CHAT;
- account = c->account;
+ account = purple_chat_get_account(c);
prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_find_prpl(purple_account_get_protocol_id(account)));
if (prpl_info && prpl_info->get_chat_name) {
- name = prpl_info->get_chat_name(c->components);
+ name = prpl_info->get_chat_name(purple_chat_get_components(c));
}
} else if (PURPLE_BLIST_NODE_IS_CONTACT(node)) {
finch_log_show_contact((PurpleContact *)node);
@@ -1571,8 +1571,8 @@ finch_blist_toggle_tag_buddy(PurpleBlistNode *node)
ggblist->tagged = g_list_prepend(ggblist->tagged, node);
}
if (PURPLE_BLIST_NODE_IS_CONTACT(node))
- node = (PurpleBlistNode*)purple_contact_get_priority_buddy((PurpleContact*)node);
- if (PURPLE_BLIST_NODE_IS_BUDDY(node))
+ update_buddy_display(purple_contact_get_priority_buddy(PURPLE_CONTACT(node)), ggblist);
+ else if (PURPLE_BLIST_NODE_IS_BUDDY(node))
update_buddy_display((PurpleBuddy*)node, ggblist);
else
update_node_display(node, ggblist);
@@ -1612,7 +1612,7 @@ finch_blist_place_tagged(PurpleBlistNode *target)
purple_blist_add_group((PurpleGroup*)node, (PurpleBlistNode*)tg);
} else if (PURPLE_BLIST_NODE_IS_CONTACT(node)) {
update_buddy_display(purple_contact_get_priority_buddy((PurpleContact*)node), ggblist);
- if ((PurpleBlistNode*)tg == target) {
+ if (PURPLE_BLIST_NODE(tg) == target) {
/* The target is a group, just add the contact to the group. */
purple_blist_add_contact((PurpleContact*)node, tg, NULL);
} else if (tc) {
@@ -1624,7 +1624,7 @@ finch_blist_place_tagged(PurpleBlistNode *target)
}
} else if (PURPLE_BLIST_NODE_IS_BUDDY(node)) {
update_buddy_display((PurpleBuddy*)node, ggblist);
- if ((PurpleBlistNode*)tg == target) {
+ if (PURPLE_BLIST_NODE(tg) == target) {
/* The target is a group. Add this buddy in a new contact under this group. */
purple_blist_add_buddy((PurpleBuddy*)node, NULL, tg, NULL);
} else if (PURPLE_BLIST_NODE_IS_CONTACT(target)) {
@@ -1639,7 +1639,7 @@ finch_blist_place_tagged(PurpleBlistNode *target)
}
} else if (PURPLE_BLIST_NODE_IS_CHAT(node)) {
update_node_display(node, ggblist);
- if ((PurpleBlistNode*)tg == target)
+ if (PURPLE_BLIST_NODE(tg) == target)
purple_blist_add_chat((PurpleChat*)node, tg, NULL);
else
purple_blist_add_chat((PurpleChat*)node, NULL, target);
@@ -1685,7 +1685,7 @@ draw_context_menu(FinchBlist *ggblist)
create_group_menu(GNT_MENU(context), NULL);
title = g_strdup(_("Buddy List"));
} else if (PURPLE_BLIST_NODE_IS_CONTACT(node)) {
- ggblist->cnode = (PurpleBlistNode*)purple_contact_get_priority_buddy((PurpleContact*)node);
+ ggblist->cnode = PURPLE_BLIST_NODE(purple_contact_get_priority_buddy(PURPLE_CONTACT(node)));
create_buddy_menu(GNT_MENU(context), (PurpleBuddy*)ggblist->cnode);
title = g_strdup(purple_contact_get_alias((PurpleContact*)node));
} else if (PURPLE_BLIST_NODE_IS_BUDDY(node)) {
@@ -2415,8 +2415,8 @@ blist_node_compare_status(PurpleBlistNode *n1, PurpleBlistNode *n2)
switch (purple_blist_node_get_type(n1)) {
case PURPLE_BLIST_CONTACT_NODE:
- n1 = (PurpleBlistNode*)purple_contact_get_priority_buddy((PurpleContact*)n1);
- n2 = (PurpleBlistNode*)purple_contact_get_priority_buddy((PurpleContact*)n2);
+ n1 = PURPLE_BLIST_NODE(purple_contact_get_priority_buddy(PURPLE_CONTACT(n1)));
+ n2 = PURPLE_BLIST_NODE(purple_contact_get_priority_buddy(PURPLE_CONTACT(n2)));
/* now compare the presence of the priority buddies */
case PURPLE_BLIST_BUDDY_NODE:
ret = purple_presence_compare(purple_buddy_get_presence((PurpleBuddy*)n1),
diff --git a/finch/gntconv.c b/finch/gntconv.c
index 103048b..c836262 100644
--- a/finch/gntconv.c
+++ b/finch/gntconv.c
@@ -496,8 +496,9 @@ view_log_cb(GntMenuItem *n, gpointer ggc)
buddies = purple_find_buddies(account, name);
for (cur = buddies; cur != NULL; cur = cur->next) {
PurpleBlistNode *node = cur->data;
- if ((node != NULL) && ((node->prev != NULL) || (node->next != NULL))) {
- finch_log_show_contact((PurpleContact *)node->parent);
+ if ((node != NULL) &&
+ (purple_blist_node_get_sibling_prev(node) || purple_blist_node_get_sibling_next(node))) {
+ finch_log_show_contact((PurpleContact *)purple_blist_node_get_parent(node));
g_slist_free(buddies);
return;
}
@@ -529,7 +530,7 @@ generate_send_to_menu(FinchConv *ggc)
gnt_menuitem_set_submenu(item, GNT_MENU(sub));
for (; buds; buds = g_slist_delete_link(buds, buds)) {
- PurpleBlistNode *node = (PurpleBlistNode *)purple_buddy_get_contact((PurpleBuddy *)buds->data);
+ PurpleBlistNode *node = PURPLE_BLIST_NODE(purple_buddy_get_contact(PURPLE_BUDDY(buds->data)));
for (node = purple_blist_node_get_first_child(node); node != NULL;
node = purple_blist_node_get_sibling_next(node)) {
PurpleBuddy *buddy = (PurpleBuddy *)node;
diff --git a/finch/gntlog.c b/finch/gntlog.c
index 1dc973f..5593f73 100644
--- a/finch/gntlog.c
+++ b/finch/gntlog.c
@@ -49,7 +49,7 @@ static FinchLogViewer *syslog_viewer = NULL;
struct log_viewer_hash_t {
PurpleLogType type;
- char *screenname;
+ char *username;
PurpleAccount *account;
PurpleContact *contact;
};
@@ -62,7 +62,7 @@ static guint log_viewer_hash(gconstpointer data)
return g_direct_hash(viewer->contact);
if (viewer->account) {
- return g_str_hash(viewer->screenname) +
+ return g_str_hash(viewer->username) +
g_str_hash(purple_account_get_username(viewer->account));
}
@@ -88,10 +88,10 @@ static gboolean log_viewer_equal(gconstpointer y, gconstpointer z)
return FALSE;
}
- if (a->screenname && b->screenname) {
- normal = g_strdup(purple_normalize(a->account, a->screenname));
+ if (a->username && b->username) {
+ normal = g_strdup(purple_normalize(a->account, a->username));
ret = (a->account == b->account) &&
- !strcmp(normal, purple_normalize(b->account, b->screenname));
+ !strcmp(normal, purple_normalize(b->account, b->username));
g_free(normal);
} else {
ret = (a == b);
@@ -155,7 +155,7 @@ static void destroy_cb(GntWidget *w, struct log_viewer_hash_t *ht)
lv = g_hash_table_lookup(log_viewers, ht);
g_hash_table_remove(log_viewers, ht);
- g_free(ht->screenname);
+ g_free(ht->username);
g_free(ht);
} else
syslog_viewer = NULL;
@@ -284,7 +284,7 @@ static FinchLogViewer *display_log_viewer(struct log_viewer_hash_t *ht, GList *l
if (!purple_prefs_get_bool("/purple/logging/log_chats"))
log_preferences = _("Chats will only be logged if the \"Log all chats\" preference is enabled.");
}
- g_free(ht->screenname);
+ g_free(ht->username);
g_free(ht);
}
@@ -365,31 +365,31 @@ our_logging_blows(PurpleLogSet *set, PurpleLogSet *setagain, GList **list)
*list = g_list_concat(purple_log_get_logs(PURPLE_LOG_IM, set->name, set->account), *list);
}
-void finch_log_show(PurpleLogType type, const char *screenname, PurpleAccount *account)
+void finch_log_show(PurpleLogType type, const char *username, PurpleAccount *account)
{
struct log_viewer_hash_t *ht;
FinchLogViewer *lv = NULL;
- const char *name = screenname;
+ const char *name = username;
char *title;
GList *logs = NULL;
int size = 0;
if (type != PURPLE_LOG_IM) {
g_return_if_fail(account != NULL);
- g_return_if_fail(screenname != NULL);
+ g_return_if_fail(username != NULL);
}
ht = g_new0(struct log_viewer_hash_t, 1);
ht->type = type;
- ht->screenname = g_strdup(screenname);
+ ht->username = g_strdup(username);
ht->account = account;
if (log_viewers == NULL) {
log_viewers = g_hash_table_new(log_viewer_hash, log_viewer_equal);
} else if ((lv = g_hash_table_lookup(log_viewers, ht))) {
gnt_window_present(lv->window);
- g_free(ht->screenname);
+ g_free(ht->username);
g_free(ht);
return;
}
@@ -397,7 +397,7 @@ void finch_log_show(PurpleLogType type, const char *screenname, PurpleAccount *a
if (type == PURPLE_LOG_CHAT) {
PurpleChat *chat;
- chat = purple_blist_find_chat(account, screenname);
+ chat = purple_blist_find_chat(account, username);
if (chat != NULL)
name = purple_chat_get_name(chat);
@@ -405,8 +405,8 @@ void finch_log_show(PurpleLogType type, const char *screenname, PurpleAccount *a
} else {
PurpleBuddy *buddy;
- if (screenname) {
- buddy = purple_find_buddy(account, screenname);
+ if (username) {
+ buddy = purple_find_buddy(account, username);
if (buddy != NULL)
name = purple_buddy_get_contact_alias(buddy);
title = g_strdup_printf(_("Conversations with %s"), name);
@@ -415,9 +415,9 @@ void finch_log_show(PurpleLogType type, const char *screenname, PurpleAccount *a
}
}
- if (screenname) {
- logs = purple_log_get_logs(type, screenname, account);
- size = purple_log_get_total_size(type, screenname, account);
+ if (username) {
+ logs = purple_log_get_logs(type, username, account);
+ size = purple_log_get_total_size(type, username, account);
} else {
/* This will happen only for IMs */
GHashTable *table = purple_log_get_log_sets();
@@ -458,12 +458,16 @@ void finch_log_show_contact(PurpleContact *contact)
for (child = purple_blist_node_get_first_child((PurpleBlistNode*)contact); child;
child = purple_blist_node_get_sibling_next(child)) {
+ const char *name;
+ PurpleAccount *account;
if (!PURPLE_BLIST_NODE_IS_BUDDY(child))
continue;
- logs = g_list_concat(purple_log_get_logs(PURPLE_LOG_IM, ((PurpleBuddy *)child)->name,
- ((PurpleBuddy *)child)->account), logs);
- total_log_size += purple_log_get_total_size(PURPLE_LOG_IM, ((PurpleBuddy *)child)->name, ((PurpleBuddy *)child)->account);
+ name = purple_buddy_get_name((PurpleBuddy *)child);
+ account = purple_buddy_get_account((PurpleBuddy *)child);
+ logs = g_list_concat(purple_log_get_logs(PURPLE_LOG_IM, name,
+ account), logs);
+ total_log_size += purple_log_get_total_size(PURPLE_LOG_IM, name, account);
}
logs = g_list_sort(logs, purple_log_compare);
diff --git a/finch/gntlog.h b/finch/gntlog.h
index c792e5d..e6bc43c 100644
--- a/finch/gntlog.h
+++ b/finch/gntlog.h
@@ -50,7 +50,7 @@ struct _FinchLogViewer {
-void finch_log_show(PurpleLogType type, const char *screenname, PurpleAccount *account);
+void finch_log_show(PurpleLogType type, const char *username, PurpleAccount *account);
void finch_log_show_contact(PurpleContact *contact);
void finch_syslog_show(void);
diff --git a/finch/gntrequest.c b/finch/gntrequest.c
index b613d8f..9b37349 100644
--- a/finch/gntrequest.c
+++ b/finch/gntrequest.c
@@ -39,6 +39,12 @@
#include "debug.h"
#include "util.h"
+/* XXX: Until gobjectification ... */
+#undef FINCH_GET_DATA
+#undef FINCH_SET_DATA
+#define FINCH_GET_DATA(obj) purple_request_field_get_ui_data(obj)
+#define FINCH_SET_DATA(obj, data) purple_request_field_set_ui_data(obj, data)
+
typedef struct
{
void *user_data;
@@ -393,11 +399,11 @@ request_fields_cb(GntWidget *button, PurpleRequestFields *fields)
}
static void
-update_selected_account(GntEntry *screenname, const char *start, const char *end,
+update_selected_account(GntEntry *username, const char *start, const char *end,
GntComboBox *accountlist)
{
GList *accounts = gnt_tree_get_rows(GNT_TREE(accountlist->dropdown));
- const char *name = gnt_entry_get_text(screenname);
+ const char *name = gnt_entry_get_text(username);
while (accounts) {
if (purple_find_buddy(accounts->data, name)) {
gnt_combo_box_set_selected(accountlist, accounts->data);
@@ -419,7 +425,7 @@ create_boolean_field(PurpleRequestField *field)
}
static GntWidget*
-create_string_field(PurpleRequestField *field, GntWidget **screenname)
+create_string_field(PurpleRequestField *field, GntWidget **username)
{
const char *hint = purple_request_field_get_type_hint(field);
GntWidget *entry = gnt_entry_new(
@@ -435,8 +441,8 @@ create_string_field(PurpleRequestField *field, GntWidget **screenname)
gnt_entry_add_suggest(GNT_ENTRY(entry), purple_buddy_get_name((PurpleBuddy*)node));
}
gnt_entry_set_always_suggest(GNT_ENTRY(entry), TRUE);
- if (screenname)
- *screenname = entry;
+ if (username)
+ *username = entry;
} else if (hint && !strcmp(hint, "group")) {
PurpleBlistNode *node;
for (node = purple_blist_get_root(); node;
@@ -569,7 +575,7 @@ finch_request_fields(const char *title, const char *primary,
{
GntWidget *window, *box;
GList *grlist;
- GntWidget *screenname = NULL, *accountlist = NULL;
+ GntWidget *username = NULL, *accountlist = NULL;
window = setup_request_window(title, primary, secondary, PURPLE_REQUEST_FIELDS);
@@ -617,7 +623,7 @@ finch_request_fields(const char *title, const char *primary,
}
else if (type == PURPLE_REQUEST_FIELD_STRING)
{
- FINCH_SET_DATA(field, create_string_field(field, &screenname));
+ FINCH_SET_DATA(field, create_string_field(field, &username));
}
else if (type == PURPLE_REQUEST_FIELD_INTEGER)
{
@@ -633,7 +639,8 @@ finch_request_fields(const char *title, const char *primary,
}
else if (type == PURPLE_REQUEST_FIELD_ACCOUNT)
{
- accountlist = FINCH_SET_DATA(field, create_account_field(field));
+ accountlist = create_account_field(field);
+ FINCH_SET_DATA(field, accountlist);
}
else
{
@@ -655,8 +662,8 @@ finch_request_fields(const char *title, const char *primary,
setup_default_callback(window, cancel_cb, userdata);
gnt_widget_show(window);
- if (screenname && accountlist) {
- g_signal_connect(screenname, "completion", G_CALLBACK(update_selected_account), accountlist);
+ if (username && accountlist) {
+ g_signal_connect(username, "completion", G_CALLBACK(update_selected_account), accountlist);
}
g_object_set_data(G_OBJECT(window), "fields", allfields);
diff --git a/finch/plugins/grouping.c b/finch/plugins/grouping.c
index 1c95963..cc40841 100644
--- a/finch/plugins/grouping.c
+++ b/finch/plugins/grouping.c
@@ -87,7 +87,7 @@ static gpointer on_offline_find_parent(PurpleBlistNode *node)
switch (purple_blist_node_get_type(node)) {
case PURPLE_BLIST_CONTACT_NODE:
- node = (PurpleBlistNode*)purple_contact_get_priority_buddy((PurpleContact*)node);
+ node = PURPLE_BLIST_NODE(purple_contact_get_priority_buddy(PURPLE_CONTACT(node)));
ret = PURPLE_BUDDY_IS_ONLINE((PurpleBuddy*)node) ? &online : &offline;
break;
case PURPLE_BLIST_BUDDY_NODE:
diff --git a/fix-casts.sh b/fix-casts.sh
new file mode 100755
index 0000000..6556f69
--- /dev/null
+++ b/fix-casts.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+if [ $# -eq 0 ]; then
+ echo "Usage: `basename "$0"` PurpleFoo..."
+ echo
+ echo "This script searches the *current working directory* and replaces casts"
+ echo "with GObject-style type checking and casting macros."
+ echo 'For example, "(PurpleBuddy *)b" becomes "PURPLE_BUDDY(b)".'
+ exit 0
+fi
+
+for struct in $* ; do
+ cast=`echo $struct | sed "s|[A-Z]|_\0|g" | tr "a-z" "A-Z" | sed "s|^_||"`
+ for file in `grep -rl "([[:space:]]*$struct[[:space:]]*\*[[:space:]]*)" . --include=*.c --exclude=purple-client-bindings.c` ; do
+ sed -i "s|([[:space:]]*$struct[[:space:]]*\*[[:space:]]*)[[:space:]]*(|$cast(|g" $file
+ sed -i "s|([[:space:]]*$struct[[:space:]]*\*[[:space:]]*)[[:space:]]*\([^(][^,);]*\)|$cast(\1)|g" $file
+ done
+done
diff --git a/libpurple/Makefile.am b/libpurple/Makefile.am
index 8a11b00..ced412c 100644
--- a/libpurple/Makefile.am
+++ b/libpurple/Makefile.am
@@ -75,7 +75,12 @@ purple_coresources = \
stringref.c \
stun.c \
sound.c \
+ sound-theme.c \
+ sound-theme-loader.c \
sslconn.c \
+ theme.c \
+ theme-loader.c \
+ theme-manager.c \
upnp.c \
util.c \
value.c \
@@ -128,7 +133,12 @@ purple_coreheaders = \
stringref.h \
stun.h \
sound.h \
+ sound-theme.h \
+ sound-theme-loader.h \
sslconn.h \
+ theme.h \
+ theme-loader.h \
+ theme-manager.h \
upnp.h \
util.h \
value.h \
diff --git a/libpurple/Makefile.mingw b/libpurple/Makefile.mingw
index 25fe830..952048c 100644
--- a/libpurple/Makefile.mingw
+++ b/libpurple/Makefile.mingw
@@ -1,7 +1,7 @@
#
# Makefile.mingw
#
-# Description: Makefile for win32 (mingw) version of LibPurple
+# Description: Makefile for win32 (mingw) version of libpurple
#
PIDGIN_TREE_TOP := ..
@@ -67,10 +67,15 @@ C_SRC = \
signals.c \
smiley.c \
sound.c \
+ sound-theme.c \
+ sound-theme-loader.c \
sslconn.c \
status.c \
stringref.c \
stun.c \
+ theme.c \
+ theme-loader.c \
+ theme-manager.c \
upnp.c \
util.c \
value.c \
diff --git a/libpurple/account.c b/libpurple/account.c
index eaf7034..0777fb4 100644
--- a/libpurple/account.c
+++ b/libpurple/account.c
@@ -178,9 +178,7 @@ status_attr_to_xmlnode(const PurpleStatus *status, const PurpleStatusType *type,
{
const char *string_value = purple_value_get_string(attr_value);
const char *default_string_value = purple_value_get_string(default_value);
- if (((string_value == NULL) && (default_string_value == NULL)) ||
- ((string_value != NULL) && (default_string_value != NULL) &&
- !strcmp(string_value, default_string_value)))
+ if (purple_strequal(string_value, default_string_value))
return NULL;
value = g_strdup(purple_value_get_string(attr_value));
}
@@ -511,11 +509,11 @@ parse_settings(xmlnode *node, PurpleAccount *account)
/* Ignore this setting */
continue;
- if (!strcmp(str_type, "string"))
+ if (purple_strequal(str_type, "string"))
type = PURPLE_PREF_STRING;
- else if (!strcmp(str_type, "int"))
+ else if (purple_strequal(str_type, "int"))
type = PURPLE_PREF_INT;
- else if (!strcmp(str_type, "bool"))
+ else if (purple_strequal(str_type, "bool"))
type = PURPLE_PREF_BOOLEAN;
else
/* Ignore this setting */
@@ -660,17 +658,17 @@ parse_proxy_info(xmlnode *node, PurpleAccount *account)
child = xmlnode_get_child(node, "type");
if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL))
{
- if (!strcmp(data, "global"))
+ if (purple_strequal(data, "global"))
purple_proxy_info_set_type(proxy_info, PURPLE_PROXY_USE_GLOBAL);
- else if (!strcmp(data, "none"))
+ else if (purple_strequal(data, "none"))
purple_proxy_info_set_type(proxy_info, PURPLE_PROXY_NONE);
- else if (!strcmp(data, "http"))
+ else if (purple_strequal(data, "http"))
purple_proxy_info_set_type(proxy_info, PURPLE_PROXY_HTTP);
- else if (!strcmp(data, "socks4"))
+ else if (purple_strequal(data, "socks4"))
purple_proxy_info_set_type(proxy_info, PURPLE_PROXY_SOCKS4);
- else if (!strcmp(data, "socks5"))
+ else if (purple_strequal(data, "socks5"))
purple_proxy_info_set_type(proxy_info, PURPLE_PROXY_SOCKS5);
- else if (!strcmp(data, "envvar"))
+ else if (purple_strequal(data, "envvar"))
purple_proxy_info_set_type(proxy_info, PURPLE_PROXY_USE_ENVVAR);
else
{
@@ -2027,7 +2025,7 @@ purple_account_get_status_type(const PurpleAccount *account, const char *id)
{
PurpleStatusType *status_type = (PurpleStatusType *)l->data;
- if (!strcmp(purple_status_type_get_id(status_type), id))
+ if (purple_strequal(purple_status_type_get_id(status_type), id))
return status_type;
}
@@ -2238,9 +2236,9 @@ purple_account_add_buddy(PurpleAccount *account, PurpleBuddy *buddy)
PurplePluginProtocolInfo *prpl_info = NULL;
PurpleConnection *gc = purple_account_get_connection(account);
PurplePlugin *prpl = NULL;
-
+
if (gc != NULL)
- prpl = purple_connection_get_prpl(gc);
+ prpl = purple_connection_get_prpl(gc);
if (prpl != NULL)
prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
@@ -2255,20 +2253,20 @@ purple_account_add_buddies(PurpleAccount *account, GList *buddies)
PurplePluginProtocolInfo *prpl_info = NULL;
PurpleConnection *gc = purple_account_get_connection(account);
PurplePlugin *prpl = NULL;
-
+
if (gc != NULL)
- prpl = purple_connection_get_prpl(gc);
+ prpl = purple_connection_get_prpl(gc);
if (prpl != NULL)
prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
-
+
if (prpl_info) {
GList *cur, *groups = NULL;
/* Make a list of what group each buddy is in */
for (cur = buddies; cur != NULL; cur = cur->next) {
- PurpleBlistNode *node = cur->data;
- groups = g_list_append(groups, node->parent->parent);
+ PurpleBuddy *buddy = cur->data;
+ groups = g_list_append(groups, purple_buddy_get_group(buddy));
}
if (prpl_info->add_buddies != NULL)
@@ -2294,13 +2292,13 @@ purple_account_remove_buddy(PurpleAccount *account, PurpleBuddy *buddy,
PurplePluginProtocolInfo *prpl_info = NULL;
PurpleConnection *gc = purple_account_get_connection(account);
PurplePlugin *prpl = NULL;
-
+
if (gc != NULL)
- prpl = purple_connection_get_prpl(gc);
+ prpl = purple_connection_get_prpl(gc);
if (prpl != NULL)
prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
-
+
if (prpl_info && prpl_info->remove_buddy)
prpl_info->remove_buddy(gc, buddy, group);
}
@@ -2311,13 +2309,13 @@ purple_account_remove_buddies(PurpleAccount *account, GList *buddies, GList *gro
PurplePluginProtocolInfo *prpl_info = NULL;
PurpleConnection *gc = purple_account_get_connection(account);
PurplePlugin *prpl = NULL;
-
+
if (gc != NULL)
- prpl = purple_connection_get_prpl(gc);
+ prpl = purple_connection_get_prpl(gc);
if (prpl != NULL)
prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
-
+
if (prpl_info) {
if (prpl_info->remove_buddies)
prpl_info->remove_buddies(gc, buddies, groups);
@@ -2339,9 +2337,9 @@ purple_account_remove_group(PurpleAccount *account, PurpleGroup *group)
PurplePluginProtocolInfo *prpl_info = NULL;
PurpleConnection *gc = purple_account_get_connection(account);
PurplePlugin *prpl = NULL;
-
+
if (gc != NULL)
- prpl = purple_connection_get_prpl(gc);
+ prpl = purple_connection_get_prpl(gc);
if (prpl != NULL)
prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
@@ -2357,11 +2355,11 @@ purple_account_change_password(PurpleAccount *account, const char *orig_pw,
PurplePluginProtocolInfo *prpl_info = NULL;
PurpleConnection *gc = purple_account_get_connection(account);
PurplePlugin *prpl = NULL;
-
+
purple_account_set_password(account, new_pw);
-
+
if (gc != NULL)
- prpl = purple_connection_get_prpl(gc);
+ prpl = purple_connection_get_prpl(gc);
if (prpl != NULL)
prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
@@ -2375,15 +2373,15 @@ gboolean purple_account_supports_offline_message(PurpleAccount *account, PurpleB
PurpleConnection *gc;
PurplePluginProtocolInfo *prpl_info = NULL;
PurplePlugin *prpl = NULL;
-
+
g_return_val_if_fail(account, FALSE);
g_return_val_if_fail(buddy, FALSE);
gc = purple_account_get_connection(account);
if (gc == NULL)
return FALSE;
-
- prpl = purple_connection_get_prpl(gc);
+
+ prpl = purple_connection_get_prpl(gc);
if (prpl != NULL)
prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
@@ -2518,23 +2516,26 @@ purple_accounts_delete(PurpleAccount *account)
purple_accounts_remove(account);
/* Remove this account's buddies */
- for (gnode = purple_blist_get_root(); gnode != NULL; gnode = gnode->next) {
+ for (gnode = purple_blist_get_root();
+ gnode != NULL;
+ gnode = purple_blist_node_get_sibling_next(gnode))
+ {
if (!PURPLE_BLIST_NODE_IS_GROUP(gnode))
continue;
- cnode = gnode->child;
+ cnode = purple_blist_node_get_first_child(gnode);
while (cnode) {
- PurpleBlistNode *cnode_next = cnode->next;
+ PurpleBlistNode *cnode_next = purple_blist_node_get_sibling_next(cnode);
if(PURPLE_BLIST_NODE_IS_CONTACT(cnode)) {
- bnode = cnode->child;
+ bnode = purple_blist_node_get_first_child(cnode);
while (bnode) {
- PurpleBlistNode *bnode_next = bnode->next;
+ PurpleBlistNode *bnode_next = purple_blist_node_get_sibling_next(bnode);
if (PURPLE_BLIST_NODE_IS_BUDDY(bnode)) {
PurpleBuddy *b = (PurpleBuddy *)bnode;
- if (b->account == account)
+ if (purple_buddy_get_account(b) == account)
purple_blist_remove_buddy(b);
}
bnode = bnode_next;
@@ -2542,7 +2543,7 @@ purple_accounts_delete(PurpleAccount *account)
} else if (PURPLE_BLIST_NODE_IS_CHAT(cnode)) {
PurpleChat *c = (PurpleChat *)cnode;
- if (c->account == account)
+ if (purple_chat_get_account(c) == account)
purple_blist_remove_chat(c);
}
cnode = cnode_next;
@@ -2633,11 +2634,11 @@ purple_accounts_find(const char *name, const char *protocol_id)
for (l = purple_accounts_get_all(); l != NULL; l = l->next) {
account = (PurpleAccount *)l->data;
- if (protocol_id && strcmp(account->protocol_id, protocol_id))
+ if (protocol_id && !purple_strequal(account->protocol_id, protocol_id))
continue;
who = g_strdup(purple_normalize(account, name));
- if (!strcmp(purple_normalize(account, purple_account_get_username(account)), who)) {
+ if (purple_strequal(purple_normalize(account, purple_account_get_username(account)), who)) {
g_free(who);
return account;
}
diff --git a/libpurple/account.h b/libpurple/account.h
index 89f55be..7c6bfe9 100644
--- a/libpurple/account.h
+++ b/libpurple/account.h
@@ -260,7 +260,7 @@ void purple_account_request_add(PurpleAccount *account, const char *remote_user,
* Notifies the user that a remote user has wants to add the local user
* to his or her buddy list and requires authorization to do so.
*
- * This will present a dialog informing the user of this and ask if the
+ * This will present a dialog informing the user of this and ask if the
* user authorizes or denies the remote user from adding him.
*
* @param account The account that was added
diff --git a/libpurple/blist.c b/libpurple/blist.c
index b5bf889..171c1bb 100644
--- a/libpurple/blist.c
+++ b/libpurple/blist.c
@@ -82,7 +82,7 @@ static guint _purple_blist_hbuddy_hash(struct _purple_hbuddy *hb)
static guint _purple_blist_hbuddy_equal(struct _purple_hbuddy *hb1, struct _purple_hbuddy *hb2)
{
- return ((!strcmp(hb1->name, hb2->name)) && hb1->account == hb2->account && hb1->group == hb2->group);
+ return (purple_strequal(hb1->name, hb2->name) && hb1->account == hb2->account && hb1->group == hb2->group);
}
static void _purple_blist_hbuddy_free_key(struct _purple_hbuddy *hb)
@@ -382,11 +382,11 @@ parse_setting(PurpleBlistNode *node, xmlnode *setting)
if (!value)
return;
- if (!type || !strcmp(type, "string"))
+ if (!type || purple_strequal(type, "string"))
purple_blist_node_set_string(node, name, value);
- else if (!strcmp(type, "bool"))
+ else if (purple_strequal(type, "bool"))
purple_blist_node_set_bool(node, name, atoi(value));
- else if (!strcmp(type, "int"))
+ else if (purple_strequal(type, "int"))
purple_blist_node_set_int(node, name, atoi(value));
g_free(value);
@@ -453,9 +453,9 @@ parse_contact(PurpleGroup *group, xmlnode *cnode)
for (x = cnode->child; x; x = x->next) {
if (x->type != XMLNODE_TYPE_TAG)
continue;
- if (!strcmp(x->name, "buddy"))
+ if (purple_strequal(x->name, "buddy"))
parse_buddy(group, contact, x);
- else if (!strcmp(x->name, "setting"))
+ else if (purple_strequal(x->name, "setting"))
parse_setting((PurpleBlistNode*)contact, x);
}
@@ -528,12 +528,12 @@ parse_group(xmlnode *groupnode)
for (cnode = groupnode->child; cnode; cnode = cnode->next) {
if (cnode->type != XMLNODE_TYPE_TAG)
continue;
- if (!strcmp(cnode->name, "setting"))
+ if (purple_strequal(cnode->name, "setting"))
parse_setting((PurpleBlistNode*)group, cnode);
- else if (!strcmp(cnode->name, "contact") ||
- !strcmp(cnode->name, "person"))
+ else if (purple_strequal(cnode->name, "contact") ||
+ purple_strequal(cnode->name, "person"))
parse_contact(group, cnode);
- else if (!strcmp(cnode->name, "chat"))
+ else if (purple_strequal(cnode->name, "chat"))
parse_chat(group, cnode);
}
}
@@ -590,11 +590,11 @@ purple_blist_load()
if (x->type != XMLNODE_TYPE_TAG)
continue;
- if (!strcmp(x->name, "permit")) {
+ if (purple_strequal(x->name, "permit")) {
name = xmlnode_get_data(x);
purple_privacy_permit_add(account, name, TRUE);
g_free(name);
- } else if (!strcmp(x->name, "block")) {
+ } else if (purple_strequal(x->name, "block")) {
name = xmlnode_get_data(x);
purple_privacy_deny_add(account, name, TRUE);
g_free(name);
@@ -699,6 +699,24 @@ purple_blist_get_root()
return purplebuddylist ? purplebuddylist->root : NULL;
}
+GHashTable *
+purple_blist_get_buddies()
+{
+ return purplebuddylist ? purplebuddylist->buddies : NULL;
+}
+
+void *
+purple_blist_get_ui_data()
+{
+ return purplebuddylist->ui_data;
+}
+
+void
+purple_blist_set_ui_data(void *ui_data)
+{
+ purplebuddylist->ui_data = ui_data;
+}
+
void purple_blist_show()
{
PurpleBlistUiOps *ops = purple_blist_get_ui_ops();
@@ -774,12 +792,28 @@ PurpleBlistNode *purple_blist_node_get_sibling_prev(PurpleBlistNode *node)
return node? node->prev : NULL;
}
+void *
+purple_blist_node_get_ui_data(const PurpleBlistNode *node)
+{
+ g_return_val_if_fail(node, NULL);
+
+ return node->ui_data;
+}
+
+void
+purple_blist_node_set_ui_data(PurpleBlistNode *node, void *ui_data) {
+ g_return_if_fail(node);
+
+ node->ui_data = ui_data;
+}
+
void
purple_blist_update_buddy_status(PurpleBuddy *buddy, PurpleStatus *old_status)
{
PurpleBlistUiOps *ops = purple_blist_get_ui_ops();
PurplePresence *presence;
PurpleStatus *status;
+ PurpleBlistNode *cnode;
g_return_if_fail(buddy != NULL);
@@ -794,16 +828,18 @@ purple_blist_update_buddy_status(PurpleBuddy *buddy, PurpleStatus *old_status)
purple_signal_emit(purple_blist_get_handle(), "buddy-signed-on", buddy);
- ((PurpleContact*)((PurpleBlistNode*)buddy)->parent)->online++;
- if (((PurpleContact*)((PurpleBlistNode*)buddy)->parent)->online == 1)
- ((PurpleGroup *)((PurpleBlistNode *)buddy)->parent->parent)->online++;
+ cnode = buddy->node.parent;
+ if (++(PURPLE_CONTACT(cnode)->online) == 1)
+ PURPLE_GROUP(cnode->parent)->online++;
} else if (!purple_status_is_online(status) &&
purple_status_is_online(old_status)) {
+
purple_blist_node_set_int(&buddy->node, "last_seen", time(NULL));
purple_signal_emit(purple_blist_get_handle(), "buddy-signed-off", buddy);
- ((PurpleContact*)((PurpleBlistNode*)buddy)->parent)->online--;
- if (((PurpleContact*)((PurpleBlistNode*)buddy)->parent)->online == 0)
- ((PurpleGroup *)((PurpleBlistNode *)buddy)->parent->parent)->online--;
+
+ cnode = buddy->node.parent;
+ if (--(PURPLE_CONTACT(cnode)->online) == 0)
+ PURPLE_GROUP(cnode->parent)->online--;
} else {
purple_signal_emit(purple_blist_get_handle(),
"buddy-status-changed", buddy, old_status,
@@ -1025,7 +1061,7 @@ void purple_blist_rename_group(PurpleGroup *source, const char *new_name)
g_return_if_fail(source != NULL);
g_return_if_fail(new_name != NULL);
- if (*new_name == '\0' || !strcmp(new_name, source->name))
+ if (*new_name == '\0' || purple_strequal(new_name, source->name))
return;
dest = purple_find_group(new_name);
@@ -1092,7 +1128,7 @@ void purple_blist_rename_group(PurpleGroup *source, const char *new_name)
/* Notify all PRPLs */
/* TODO: Is this condition needed? Seems like it would always be TRUE */
- if(old_name && source && strcmp(source->name, old_name)) {
+ if(old_name && purple_strequal(source->name, old_name)) {
for (accts = purple_group_get_accounts(source); accts; accts = g_slist_remove(accts, accts->data)) {
PurpleAccount *account = accts->data;
PurpleConnection *gc = NULL;
@@ -1101,7 +1137,7 @@ void purple_blist_rename_group(PurpleGroup *source, const char *new_name)
GList *l = NULL, *buddies = NULL;
gc = purple_account_get_connection(account);
-
+
if(gc)
prpl = purple_connection_get_prpl(gc);
@@ -1166,17 +1202,17 @@ PurpleChat *purple_chat_new(PurpleAccount *account, const char *alias, GHashTabl
return chat;
}
-PurpleBuddy *purple_buddy_new(PurpleAccount *account, const char *screenname, const char *alias)
+PurpleBuddy *purple_buddy_new(PurpleAccount *account, const char *name, const char *alias)
{
PurpleBlistUiOps *ops = purple_blist_get_ui_ops();
PurpleBuddy *buddy;
g_return_val_if_fail(account != NULL, FALSE);
- g_return_val_if_fail(screenname != NULL, FALSE);
+ g_return_val_if_fail(name != NULL, FALSE);
buddy = g_new0(PurpleBuddy, 1);
buddy->account = account;
- buddy->name = g_strdup(screenname);
+ buddy->name = g_strdup(name);
buddy->alias = g_strdup(alias);
buddy->presence = purple_presence_new_for_buddy(buddy);
((PurpleBlistNode *)buddy)->type = PURPLE_BLIST_BUDDY_NODE;
@@ -1232,6 +1268,23 @@ purple_buddy_get_icon(const PurpleBuddy *buddy)
return buddy->icon;
}
+gpointer
+purple_buddy_get_protocol_data(const PurpleBuddy *buddy)
+{
+ g_return_val_if_fail(buddy != NULL, NULL);
+
+ return buddy->proto_data;
+}
+
+void
+purple_buddy_set_protocol_data(PurpleBuddy *buddy, gpointer data)
+{
+ g_return_if_fail(buddy != NULL);
+
+ buddy->proto_data = data;
+}
+
+
void purple_blist_add_chat(PurpleChat *chat, PurpleGroup *group, PurpleBlistNode *node)
{
PurpleBlistNode *cnode = (PurpleBlistNode*)chat;
@@ -1339,7 +1392,7 @@ void purple_blist_add_buddy(PurpleBuddy *buddy, PurpleContact *contact, PurpleGr
g = (PurpleGroup*)node->parent->parent;
} else if (contact) {
c = contact;
- g = (PurpleGroup *)((PurpleBlistNode *)c)->parent;
+ g = PURPLE_GROUP(PURPLE_BLIST_NODE(c)->parent);
} else {
g = group;
if (g == NULL)
@@ -1421,16 +1474,14 @@ void purple_blist_add_buddy(PurpleBuddy *buddy, PurpleContact *contact, PurpleGr
}
if (PURPLE_BUDDY_IS_ONLINE(buddy)) {
- ((PurpleContact*)bnode->parent)->online++;
- if (((PurpleContact*)bnode->parent)->online == 1)
- ((PurpleGroup*)bnode->parent->parent)->online++;
+ if (++(PURPLE_CONTACT(bnode->parent)->online) == 1)
+ PURPLE_GROUP(bnode->parent->parent)->online++;
}
if (purple_account_is_connected(buddy->account)) {
- ((PurpleContact*)bnode->parent)->currentsize++;
- if (((PurpleContact*)bnode->parent)->currentsize == 1)
- ((PurpleGroup*)bnode->parent->parent)->currentsize++;
+ if (++(PURPLE_CONTACT(bnode->parent)->currentsize) == 1)
+ PURPLE_GROUP(bnode->parent->parent)->currentsize++;
}
- ((PurpleContact*)bnode->parent)->totalsize++;
+ PURPLE_CONTACT(bnode->parent)->totalsize++;
hb = g_new(struct _purple_hbuddy, 1);
hb->name = g_strdup(purple_normalize(buddy->account, buddy->name));
@@ -1546,7 +1597,7 @@ void purple_blist_add_contact(PurpleContact *contact, PurpleGroup *group, Purple
g_return_if_fail(contact != NULL);
g_return_if_fail(PURPLE_BLIST_NODE_IS_CONTACT((PurpleBlistNode*)contact));
- if ((PurpleBlistNode*)contact == node)
+ if (PURPLE_BLIST_NODE(contact) == node)
return;
if (node && (PURPLE_BLIST_NODE_IS_CONTACT(node) ||
@@ -2056,6 +2107,12 @@ const char *purple_buddy_get_alias(PurpleBuddy *buddy)
return buddy->name;
}
+const char *purple_buddy_get_local_buddy_alias(PurpleBuddy *buddy)
+{
+ g_return_val_if_fail(buddy, NULL);
+ return buddy->alias;
+}
+
const char *purple_buddy_get_server_alias(PurpleBuddy *buddy)
{
g_return_val_if_fail(buddy != NULL, NULL);
@@ -2300,7 +2357,7 @@ PurpleContact *purple_buddy_get_contact(PurpleBuddy *buddy)
{
g_return_val_if_fail(buddy != NULL, NULL);
- return (PurpleContact*)((PurpleBlistNode*)buddy)->parent;
+ return PURPLE_CONTACT(PURPLE_BLIST_NODE(buddy)->parent);
}
PurplePresence *purple_buddy_get_presence(const PurpleBuddy *buddy)
diff --git a/libpurple/blist.h b/libpurple/blist.h
index 829212f..460291a 100644
--- a/libpurple/blist.h
+++ b/libpurple/blist.h
@@ -75,12 +75,37 @@ typedef enum
} PurpleBlistNodeFlags;
+/**
+ * @since 2.6.0
+ */
+#define PURPLE_BLIST_NODE(obj) ((PurpleBlistNode *)(obj))
+
#define PURPLE_BLIST_NODE_HAS_FLAG(b, f) (purple_blist_node_get_flags((PurpleBlistNode*)(b)) & (f))
#define PURPLE_BLIST_NODE_SHOULD_SAVE(b) (! PURPLE_BLIST_NODE_HAS_FLAG(b, PURPLE_BLIST_NODE_FLAG_NO_SAVE))
#define PURPLE_BLIST_NODE_NAME(n) (purple_blist_node_get_type(n) == PURPLE_BLIST_CHAT_NODE ? purple_chat_get_name((PurpleChat*)n) : \
purple_blist_node_get_type(n) == PURPLE_BLIST_BUDDY_NODE ? purple_buddy_get_name((PurpleBuddy*)n) : NULL)
+/**
+ * @since 2.6.0
+ */
+#define PURPLE_GROUP(obj) ((PurpleGroup *)(obj))
+
+/**
+ * @since 2.6.0
+ */
+#define PURPLE_CONTACT(obj) ((PurpleContact *)(obj))
+
+/**
+ * @since 2.6.0
+ */
+#define PURPLE_BUDDY(obj) ((PurpleBuddy *)(obj))
+
+/**
+ * @since 2.6.0
+ */
+#define PURPLE_CHAT(obj) ((PurpleChat *)(obj))
+
#include "account.h"
#include "buddyicon.h"
#include "status.h"
@@ -111,7 +136,7 @@ struct _PurpleBlistNode {
*/
struct _PurpleBuddy {
PurpleBlistNode node; /**< The node that this buddy inherits from */
- char *name; /**< The screenname of the buddy. */
+ char *name; /**< The name of the buddy. */
char *alias; /**< The user-set alias of the buddy */
char *server_alias; /**< The server-specified alias of the buddy. (i.e. MSN "Friendly Names") */
void *proto_data; /**< This allows the prpl to associate whatever data it wants with a buddy */
@@ -156,9 +181,6 @@ struct _PurpleChat {
PurpleAccount *account; /**< The account this chat is attached to */
};
-#endif /* PURPLE_HIDE_STRUCTS && PURPLE_BLIST_STRUCTS */
-
-
/**
* The Buddy List
*/
@@ -168,6 +190,8 @@ struct _PurpleBuddyList {
void *ui_data; /**< UI-specific data. */
};
+#endif /* PURPLE_HIDE_STRUCTS && PURPLE_BLIST_STRUCTS */
+
/**
* Buddy list UI operations.
*
@@ -236,6 +260,33 @@ PurpleBuddyList *purple_get_blist(void);
PurpleBlistNode *purple_blist_get_root(void);
/**
+ * Returns the hash table of every buddy in the list.
+ *
+ * @return The hash table of every buddy in the list.
+ *
+ * @since 2.6.0
+ */
+GHashTable *purple_blist_get_buddies(void);
+
+/**
+ * Returns the UI data for the list.
+ *
+ * @return The UI data for the list.
+ *
+ * @since 2.6.0
+ */
+void *purple_blist_get_ui_data(void);
+
+/**
+ * Sets the UI data for the list.
+ *
+ * @param ui_data The UI data for the list.
+ *
+ * @since 2.6.0
+ */
+void purple_blist_set_ui_data(void *ui_data);
+
+/**
* Returns the next node of a given node. This function is to be used to iterate
* over the tree returned by purple_get_blist.
*
@@ -302,6 +353,25 @@ PurpleBlistNode *purple_blist_node_get_sibling_next(PurpleBlistNode *node);
PurpleBlistNode *purple_blist_node_get_sibling_prev(PurpleBlistNode *node);
/**
+ * Returns the UI data of a given node.
+ *
+ * @param node The node.
+ * @return The UI data.
+ * @since 2.6.0
+ */
+void *purple_blist_node_get_ui_data(const PurpleBlistNode *node);
+
+/**
+ * Sets the UI data of a given node.
+ *
+ * @param node The node.
+ * @param ui_data The UI data.
+ *
+ * @since 2.6.0
+ */
+void purple_blist_node_set_ui_data(PurpleBlistNode *node, void *ui_data);
+
+/**
* Shows the buddy list, creating a new one if necessary.
*/
void purple_blist_show(void);
@@ -331,6 +401,7 @@ void purple_blist_update_buddy_status(PurpleBuddy *buddy, PurpleStatus *old_stat
* Updates a node's custom icon.
*
* @param node The PurpleBlistNode whose custom icon has changed.
+ *
* @since 2.5.0
*/
void purple_blist_update_node_icon(PurpleBlistNode *node);
@@ -423,11 +494,11 @@ void purple_blist_add_chat(PurpleChat *chat, PurpleGroup *group, PurpleBlistNode
* Creates a new buddy
*
* @param account The account this buddy will get added to
- * @param screenname The screenname of the new buddy
+ * @param name The name of the new buddy
* @param alias The alias of the new buddy (or NULL if unaliased)
* @return A newly allocated buddy
*/
-PurpleBuddy *purple_buddy_new(PurpleAccount *account, const char *screenname, const char *alias);
+PurpleBuddy *purple_buddy_new(PurpleAccount *account, const char *name, const char *alias);
/**
* Sets a buddy's icon.
@@ -470,6 +541,32 @@ const char *purple_buddy_get_name(const PurpleBuddy *buddy);
PurpleBuddyIcon *purple_buddy_get_icon(const PurpleBuddy *buddy);
/**
+ * Returns a buddy's protocol-specific data.
+ *
+ * This should only be called from the associated prpl.
+ *
+ * @param buddy The buddy.
+ * @return The protocol data.
+ *
+ * @see purple_buddy_set_protocol_data()
+ * @since 2.6.0
+ */
+gpointer purple_buddy_get_protocol_data(const PurpleBuddy *buddy);
+
+/**
+ * Sets a buddy's protocol-specific data.
+ *
+ * This should only be called from the associated prpl.
+ *
+ * @param buddy The buddy.
+ * @param data The data.
+ *
+ * @see purple_buddy_get_protocol_data()
+ * @since 2.6.0
+ */
+void purple_buddy_set_protocol_data(PurpleBuddy *buddy, gpointer data);
+
+/**
* Returns a buddy's contact.
*
* @param buddy The buddy.
@@ -659,15 +756,18 @@ const char *purple_buddy_get_server_alias(PurpleBuddy *buddy);
*/
const char *purple_buddy_get_contact_alias(PurpleBuddy *buddy);
+#if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_BLIST_C_)
/**
* Returns the correct alias for this user, ignoring server aliases. Used
* when a user-recognizable name is required. In order: buddy's alias; buddy's
* contact alias; buddy's user name.
- *
+ *
* @param buddy The buddy whose alias will be returned.
* @return The appropriate name or alias.
+ * @deprecated Try purple_buddy_get_alias(), if server aliases are okay.
*/
const char *purple_buddy_get_local_alias(PurpleBuddy *buddy);
+#endif
/**
* Returns the correct name to display for a buddy. In order of precedence:
@@ -680,6 +780,16 @@ const char *purple_buddy_get_local_alias(PurpleBuddy *buddy);
const char *purple_buddy_get_alias(PurpleBuddy *buddy);
/**
+ * Returns the local alias for the buddy, or @c NULL if none exists.
+ *
+ * @param buddy The buddy
+ * @return The local alias for the buddy
+ *
+ * @since 2.6.0
+ */
+const char *purple_buddy_get_local_buddy_alias(PurpleBuddy *buddy);
+
+/**
* Returns the correct name to display for a blist chat.
*
* @param chat The chat whose name will be returned.
@@ -688,19 +798,19 @@ const char *purple_buddy_get_alias(PurpleBuddy *buddy);
const char *purple_chat_get_name(PurpleChat *chat);
/**
- * Finds the buddy struct given a screenname and an account
+ * Finds the buddy struct given a name and an account
*
* @param account The account this buddy belongs to
- * @param name The buddy's screenname
+ * @param name The buddy's name
* @return The buddy or NULL if the buddy does not exist
*/
PurpleBuddy *purple_find_buddy(PurpleAccount *account, const char *name);
/**
- * Finds the buddy struct given a screenname, an account, and a group
+ * Finds the buddy struct given a name, an account, and a group
*
* @param account The account this buddy belongs to
- * @param name The buddy's screenname
+ * @param name The buddy's name
* @param group The group to look in
* @return The buddy or NULL if the buddy does not exist in the group
*/
@@ -708,10 +818,10 @@ PurpleBuddy *purple_find_buddy_in_group(PurpleAccount *account, const char *name
PurpleGroup *group);
/**
- * Finds all PurpleBuddy structs given a screenname and an account
+ * Finds all PurpleBuddy structs given a name and an account
*
* @param account The account this buddy belongs to
- * @param name The buddy's screenname (or NULL to return all buddies in the account)
+ * @param name The buddy's name (or NULL to return all buddies in the account)
*
* @return A GSList of buddies (which must be freed), or NULL if the buddy doesn't exist
*/
@@ -751,6 +861,7 @@ PurpleGroup *purple_chat_get_group(PurpleChat *chat);
* @param chat The chat.
*
* @return The account the chat belongs to.
+ *
* @since 2.4.0
*/
PurpleAccount *purple_chat_get_account(PurpleChat *chat);
@@ -761,6 +872,7 @@ PurpleAccount *purple_chat_get_account(PurpleChat *chat);
* @param chat The chat.
*
* @constreturn The hashtable.
+ *
* @since 2.4.0
*/
GHashTable *purple_chat_get_components(PurpleChat *chat);
@@ -979,6 +1091,7 @@ PurpleBlistNodeFlags purple_blist_node_get_flags(PurpleBlistNode *node);
* @param node The node.
*
* @return The type of the node.
+ *
* @since 2.1.0
*/
PurpleBlistNodeType purple_blist_node_get_type(PurpleBlistNode *node);
diff --git a/libpurple/buddyicon.c b/libpurple/buddyicon.c
index f256774..b54476b 100644
--- a/libpurple/buddyicon.c
+++ b/libpurple/buddyicon.c
@@ -153,7 +153,7 @@ purple_buddy_icon_data_cache(PurpleStoredImage *img)
{
const char *dirname;
char *path;
-
+
g_return_if_fail(img != NULL);
if (!purple_buddy_icons_is_caching())
@@ -175,7 +175,7 @@ purple_buddy_icon_data_cache(PurpleStoredImage *img)
}
purple_util_write_data_to_file_absolute(path, purple_imgstore_get_data(img),
- purple_imgstore_get_size(img));
+ purple_imgstore_get_size(img));
g_free(path);
}
@@ -453,7 +453,7 @@ purple_buddy_icon_update(PurpleBuddyIcon *icon)
if (conv != NULL)
purple_conv_im_set_icon(PURPLE_CONV_IM(conv), icon_to_set);
-
+
/* icon's refcount was incremented above */
if (icon) purple_buddy_icon_unref(icon);
}
@@ -757,7 +757,7 @@ purple_buddy_icons_set_account_icon(PurpleAccount *account,
g_hash_table_insert(pointer_icon_cache, account, img);
else
g_hash_table_remove(pointer_icon_cache, account);
-
+
if (purple_account_is_connected(account))
{
PurpleConnection *gc;
@@ -889,7 +889,9 @@ purple_buddy_icons_node_set_custom_icon(PurpleBlistNode *node,
if (PURPLE_BLIST_NODE_IS_CONTACT(node)) {
PurpleBlistNode *child;
- for (child = node->child ; child ; child = child->next)
+ for (child = purple_blist_node_get_first_child(node);
+ child;
+ child = purple_blist_node_get_sibling_next(child))
{
PurpleBuddy *buddy;
PurpleConversation *conv;
@@ -986,7 +988,7 @@ delete_buddy_icon_settings(PurpleBlistNode *node, const char *setting_name)
{
purple_blist_node_remove_setting(node, setting_name);
- if (!strcmp(setting_name, "buddy_icon"))
+ if (purple_strequal(setting_name, "buddy_icon"))
{
purple_blist_node_remove_setting(node, "avatar_hash");
purple_blist_node_remove_setting(node, "icon_checksum");
@@ -1083,7 +1085,7 @@ migrate_buddy_icon(PurpleBlistNode *node, const char *setting_name,
g_free(new_filename);
- if (!strcmp(setting_name, "buddy_icon"))
+ if (purple_strequal(setting_name, "buddy_icon"))
{
const char *hash;
@@ -1098,7 +1100,7 @@ migrate_buddy_icon(PurpleBlistNode *node, const char *setting_name,
PurpleAccount *account = purple_buddy_get_account((PurpleBuddy *)node);
const char *prpl_id = purple_account_get_protocol_id(account);
- if (!strcmp(prpl_id, "prpl-yahoo"))
+ if (purple_strequal(prpl_id, "prpl-yahoo"))
{
int checksum = purple_blist_node_get_int(node, "icon_checksum");
if (checksum != 0)
diff --git a/libpurple/certificate.c b/libpurple/certificate.c
index b548e04..c0049e9 100644
--- a/libpurple/certificate.c
+++ b/libpurple/certificate.c
@@ -51,7 +51,7 @@ purple_certificate_verify (PurpleCertificateVerifier *verifier,
{
PurpleCertificateVerificationRequest *vrq;
PurpleCertificateScheme *scheme;
-
+
g_return_if_fail(subject_name != NULL);
/* If you don't have a cert to check, why are you requesting that it
be verified? */
@@ -97,10 +97,10 @@ purple_certificate_verify_complete(PurpleCertificateVerificationRequest *vrq,
"Failed to verify certificate for %s\n",
vrq->subject_name);
}
-
-
-
-
+
+
+
+
/* Pass the results on to the request's callback */
(vrq->cb)(st, vrq->cb_data);
@@ -154,7 +154,7 @@ void
purple_certificate_destroy (PurpleCertificate *crt)
{
PurpleCertificateScheme *scheme;
-
+
if (NULL == crt) return;
scheme = crt->scheme;
@@ -206,7 +206,7 @@ purple_certificate_check_signature_chain(GList *chain)
"Checking signature chain for uid=%s\n",
uid);
g_free(uid);
-
+
/* If this is a single-certificate chain, say that it is valid */
if (chain->next == NULL) {
purple_debug_info("certificate",
@@ -218,9 +218,9 @@ purple_certificate_check_signature_chain(GList *chain)
crt = (PurpleCertificate *)(chain->data);
/* And start with the second certificate in the chain */
for ( cur = chain->next; cur; cur = cur->next ) {
-
+
issuer = (PurpleCertificate *)(cur->data);
-
+
/* Check the signature for this link */
if (! purple_certificate_signed_by(crt, issuer) ) {
uid = purple_certificate_get_unique_id(issuer);
@@ -228,7 +228,7 @@ purple_certificate_check_signature_chain(GList *chain)
"...Bad or missing signature by %s\nChain is INVALID\n",
uid);
g_free(uid);
-
+
return FALSE;
}
@@ -237,7 +237,7 @@ purple_certificate_check_signature_chain(GList *chain)
"...Good signature by %s\n",
uid);
g_free(uid);
-
+
/* The issuer is now the next crt whose signature is to be
checked */
crt = issuer;
@@ -283,7 +283,7 @@ purple_certificate_get_fingerprint_sha1(PurpleCertificate *crt)
g_return_val_if_fail(crt->scheme, NULL);
scheme = crt->scheme;
-
+
g_return_val_if_fail(scheme->get_fingerprint_sha1, NULL);
fpr = (scheme->get_fingerprint_sha1)(crt);
@@ -354,7 +354,7 @@ purple_certificate_get_times(PurpleCertificate *crt, time_t *activation, time_t
g_return_val_if_fail(crt, FALSE);
scheme = crt->scheme;
-
+
g_return_val_if_fail(scheme, FALSE);
/* If both provided references are NULL, what are you doing calling
@@ -371,7 +371,7 @@ purple_certificate_pool_mkpath(PurpleCertificatePool *pool, const gchar *id)
{
gchar *path;
gchar *esc_scheme_name, *esc_name, *esc_id;
-
+
g_return_val_if_fail(pool, NULL);
g_return_val_if_fail(pool->scheme_name, NULL);
g_return_val_if_fail(pool->name, NULL);
@@ -380,7 +380,7 @@ purple_certificate_pool_mkpath(PurpleCertificatePool *pool, const gchar *id)
esc_scheme_name = pool ? g_strdup(purple_escape_filename(pool->scheme_name)) : NULL;
esc_name = pool ? g_strdup(purple_escape_filename(pool->name)) : NULL;
esc_id = id ? g_strdup(purple_escape_filename(id)) : NULL;
-
+
path = g_build_filename(purple_user_dir(),
"certificates", /* TODO: constantize this? */
esc_scheme_name,
@@ -404,7 +404,7 @@ purple_certificate_pool_usable(PurpleCertificatePool *pool)
if (purple_certificate_find_scheme(pool->scheme_name) == NULL) {
return FALSE;
}
-
+
return TRUE;
}
@@ -441,7 +441,7 @@ gboolean
purple_certificate_pool_store(PurpleCertificatePool *pool, const gchar *id, PurpleCertificate *crt)
{
gboolean ret = FALSE;
-
+
g_return_val_if_fail(pool, FALSE);
g_return_val_if_fail(id, FALSE);
g_return_val_if_fail(pool->put_cert, FALSE);
@@ -461,13 +461,13 @@ purple_certificate_pool_store(PurpleCertificatePool *pool, const gchar *id, Purp
}
return ret;
-}
+}
gboolean
purple_certificate_pool_delete(PurpleCertificatePool *pool, const gchar *id)
{
gboolean ret = FALSE;
-
+
g_return_val_if_fail(pool, FALSE);
g_return_val_if_fail(id, FALSE);
g_return_val_if_fail(pool->delete_cert, FALSE);
@@ -496,7 +496,7 @@ void
purple_certificate_pool_destroy_idlist(GList *idlist)
{
GList *l;
-
+
/* Iterate through and free them strings */
for ( l = idlist; l; l = l->next ) {
g_free(l->data);
@@ -520,7 +520,7 @@ x509_singleuse_verify_cb (PurpleCertificateVerificationRequest *vrq, gint id)
vrq->subject_name, id);
/* Signal what happened back to the caller */
- if (1 == id) {
+ if (1 == id) {
/* Accepted! */
purple_certificate_verify_complete(vrq,
PURPLE_CERTIFICATE_VALID);
@@ -557,11 +557,11 @@ x509_singleuse_start_verify (PurpleCertificateVerificationRequest *vrq)
} else {
cn_match = _("(DOES NOT MATCH)");
}
-
+
/* Make messages */
primary = g_strdup_printf(_("%s has presented the following certificate for just-this-once use:"), vrq->subject_name);
secondary = g_strdup_printf(_("Common name: %s %s\nFingerprint (SHA1): %s"), cn, cn_match, sha_asc);
-
+
/* Make a semi-pretty display */
purple_request_accept_cancel(
vrq->cb_data, /* TODO: Find what the handle ought to be */
@@ -575,7 +575,7 @@ x509_singleuse_start_verify (PurpleCertificateVerificationRequest *vrq)
vrq,
x509_singleuse_verify_cb,
x509_singleuse_verify_cb );
-
+
/* Cleanup */
g_free(primary);
g_free(secondary);
@@ -644,13 +644,13 @@ x509_ca_quiet_put_cert(PurpleCertificate *crt)
/* lazy_init calls this function, so calling lazy_init here is a
Bad Thing */
-
+
g_return_val_if_fail(crt, FALSE);
g_return_val_if_fail(crt->scheme, FALSE);
/* Make sure that this is some kind of X.509 certificate */
/* TODO: Perhaps just check crt->scheme->name instead? */
g_return_val_if_fail(crt->scheme == purple_certificate_find_scheme(x509_ca.scheme_name), FALSE);
-
+
el = g_new0(x509_ca_element, 1);
el->dn = purple_certificate_get_unique_id(crt);
el->crt = purple_certificate_copy(crt);
@@ -675,7 +675,7 @@ x509_ca_lazy_init(void)
const gchar *entry;
GPatternSpec *pempat;
GList *iter = NULL;
-
+
if (x509_ca_initialized) return TRUE;
/* Check that X.509 is registered */
@@ -791,7 +791,7 @@ x509_ca_locate_cert(GList *lst, const gchar *dn)
for (cur = lst; cur; cur = cur->next) {
x509_ca_element *el = cur->data;
- if (el->dn && !strcmp(dn, el->dn)) {
+ if (purple_strequal(dn, el->dn)) {
return el;
}
}
@@ -832,7 +832,7 @@ x509_ca_get_cert(const gchar *id)
} else {
crt = NULL;
}
-
+
return crt;
}
@@ -840,7 +840,7 @@ static gboolean
x509_ca_put_cert(const gchar *id, PurpleCertificate *crt)
{
gboolean ret = FALSE;
-
+
g_return_val_if_fail(x509_ca_lazy_init(), FALSE);
/* TODO: This is a quick way of doing this. At some point the change
@@ -854,7 +854,7 @@ static gboolean
x509_ca_delete_cert(const gchar *id)
{
x509_ca_element *el;
-
+
g_return_val_if_fail(x509_ca_lazy_init(), FALSE);
g_return_val_if_fail(id, FALSE);
@@ -870,7 +870,7 @@ x509_ca_delete_cert(const gchar *id)
/* Unlink it from the memory cache and destroy it */
x509_ca_certs = g_list_remove(x509_ca_certs, el);
x509_ca_element_free(el);
-
+
return TRUE;
}
@@ -878,7 +878,7 @@ static GList *
x509_ca_get_idlist(void)
{
GList *l, *idlist;
-
+
g_return_val_if_fail(x509_ca_lazy_init(), NULL);
idlist = NULL;
@@ -886,7 +886,7 @@ x509_ca_get_idlist(void)
x509_ca_element *el = l->data;
idlist = g_list_prepend(idlist, g_strdup(el->dn));
}
-
+
return idlist;
}
@@ -921,7 +921,7 @@ x509_tls_peers_init(void)
{
gchar *poolpath;
int ret;
-
+
/* Set up key cache here if it isn't already done */
poolpath = purple_certificate_pool_mkpath(&x509_tls_peers, NULL);
ret = purple_build_dir(poolpath, 0700); /* Make it this user only */
@@ -937,13 +937,13 @@ x509_tls_peers_cert_in_pool(const gchar *id)
{
gchar *keypath;
gboolean ret = FALSE;
-
+
g_return_val_if_fail(id, FALSE);
keypath = purple_certificate_pool_mkpath(&x509_tls_peers, id);
ret = g_file_test(keypath, G_FILE_TEST_IS_REGULAR);
-
+
g_free(keypath);
return ret;
}
@@ -954,14 +954,14 @@ x509_tls_peers_get_cert(const gchar *id)
PurpleCertificateScheme *x509;
PurpleCertificate *crt;
gchar *keypath;
-
+
g_return_val_if_fail(id, NULL);
/* Is it in the pool? */
if ( !x509_tls_peers_cert_in_pool(id) ) {
return NULL;
}
-
+
/* Look up the X.509 scheme */
x509 = purple_certificate_find_scheme("x509");
g_return_val_if_fail(x509, NULL);
@@ -990,7 +990,7 @@ x509_tls_peers_put_cert(const gchar *id, PurpleCertificate *crt)
/* Work out the filename and export */
keypath = purple_certificate_pool_mkpath(&x509_tls_peers, id);
ret = purple_certificate_export(keypath, crt);
-
+
g_free(keypath);
return ret;
}
@@ -1012,7 +1012,7 @@ x509_tls_peers_delete_cert(const gchar *id)
}
/* OK, so work out the keypath and delete the thing */
- keypath = purple_certificate_pool_mkpath(&x509_tls_peers, id);
+ keypath = purple_certificate_pool_mkpath(&x509_tls_peers, id);
if ( unlink(keypath) != 0 ) {
purple_debug_error("certificate/tls_peers",
"Unlink of %s failed!\n",
@@ -1047,7 +1047,7 @@ x509_tls_peers_get_idlist(void)
while ( (entry = g_dir_read_name(dir)) != NULL ) {
/* Unescape the filename */
const char *unescaped = purple_unescape_filename(entry);
-
+
/* Copy the entry name into our list (GLib owns the original
string) */
idlist = g_list_prepend(idlist, g_strdup(unescaped));
@@ -1055,7 +1055,7 @@ x509_tls_peers_get_idlist(void)
/* Release the directory */
g_dir_close(dir);
-
+
return idlist;
}
@@ -1143,7 +1143,7 @@ x509_tls_cached_user_auth_cb (x509_tls_cached_ua_ctx *c, gint id)
g_return_if_fail(c);
g_return_if_fail(c->vrq);
-
+
vrq = c->vrq;
x509_tls_cached_ua_ctx_free(c);
@@ -1155,7 +1155,7 @@ x509_tls_cached_user_auth_cb (x509_tls_cached_ua_ctx *c, gint id)
purple_debug_info("certificate/x509/tls_cached",
"User ACCEPTED cert\nCaching first in chain for future use as %s...\n",
cache_id);
-
+
purple_certificate_pool_store(tls_peers, cache_id,
vrq->cert_chain->data);
@@ -1195,7 +1195,7 @@ x509_tls_cached_user_auth(PurpleCertificateVerificationRequest *vrq,
/* Make messages */
primary = g_strdup_printf(_("Accept certificate for %s?"),
vrq->subject_name);
-
+
/* Make a semi-pretty display */
purple_request_action(
vrq->cb_data, /* TODO: Find what the handle ought to be */
@@ -1211,7 +1211,7 @@ x509_tls_cached_user_auth(PurpleCertificateVerificationRequest *vrq,
_("Accept"), x509_tls_cached_user_auth_accept_cb,
_("Reject"), x509_tls_cached_user_auth_reject_cb,
_("_View Certificate..."), x509_tls_cached_show_cert);
-
+
/* Cleanup */
g_free(primary);
}
@@ -1225,7 +1225,7 @@ x509_tls_cached_peer_cert_changed(PurpleCertificateVerificationRequest *vrq)
"Certificate for %s does not match cached. "
"Auto-rejecting!\n",
vrq->subject_name);
-
+
purple_certificate_verify_complete(vrq, PURPLE_CERTIFICATE_INVALID);
return;
}
@@ -1245,7 +1245,7 @@ x509_tls_cached_cert_in_cache(PurpleCertificateVerificationRequest *vrq)
/* The peer's certificate should be the first in the list */
PurpleCertificate *peer_crt =
(PurpleCertificate *) vrq->cert_chain->data;
-
+
PurpleCertificate *cached_crt;
GByteArray *peer_fpr, *cached_fpr;
@@ -1278,7 +1278,7 @@ x509_tls_cached_cert_in_cache(PurpleCertificateVerificationRequest *vrq)
/* vrq now becomes the problem of the user */
x509_tls_cached_unknown_peer(vrq);
}
-
+
purple_certificate_destroy(cached_crt);
g_byte_array_free(peer_fpr, TRUE);
g_byte_array_free(cached_fpr, TRUE);
@@ -1305,7 +1305,7 @@ x509_tls_cached_unknown_peer(PurpleCertificateVerificationRequest *vrq)
"not self-signed" */
if ( purple_certificate_signed_by(peer_crt, peer_crt) ) {
gchar *msg;
-
+
purple_debug_info("certificate/x509/tls_cached",
"Certificate for %s is self-signed.\n",
vrq->subject_name);
@@ -1316,13 +1316,13 @@ x509_tls_cached_unknown_peer(PurpleCertificateVerificationRequest *vrq)
"is self-signed. It cannot be "
"automatically checked."),
vrq->subject_name);
-
+
x509_tls_cached_user_auth(vrq,msg);
g_free(msg);
return;
} /* if (self signed) */
-
+
/* Next, check that the certificate chain is valid */
if ( ! purple_certificate_check_signature_chain(chain) ) {
/* TODO: Tell the user where the chain broke? */
@@ -1390,7 +1390,7 @@ x509_tls_cached_unknown_peer(PurpleCertificateVerificationRequest *vrq)
}
g_free(ca_id);
-
+
/* Check the signature */
if ( !purple_certificate_signed_by(end_crt, ca_crt) ) {
/* TODO: If signed_by ever returns a reason, maybe mention
@@ -1406,7 +1406,7 @@ x509_tls_cached_unknown_peer(PurpleCertificateVerificationRequest *vrq)
"Authority from which it claims to "
"have a signature."),
vrq->subject_name);
-
+
purple_notify_error(NULL, /* TODO: Probably wrong */
_("SSL Certificate Error"),
_("Invalid certificate authority"
@@ -1425,7 +1425,7 @@ x509_tls_cached_unknown_peer(PurpleCertificateVerificationRequest *vrq)
vrq->subject_name) ) {
gchar *sn = purple_certificate_get_subject_name(peer_crt);
gchar *msg;
-
+
purple_debug_info("certificate/x509/tls_cached",
"Name mismatch: Certificate given for %s "
"has a name of %s\n",
@@ -1441,7 +1441,7 @@ x509_tls_cached_unknown_peer(PurpleCertificateVerificationRequest *vrq)
"connecting to the service you "
"believe you are."),
vrq->subject_name, sn);
-
+
x509_tls_cached_user_auth(vrq,msg);
g_free(sn);
@@ -1465,7 +1465,7 @@ x509_tls_cached_unknown_peer(PurpleCertificateVerificationRequest *vrq)
"Unable to locate tls_peers certificate "
"cache.\n");
}
-
+
/* Whew! Done! */
purple_certificate_verify_complete(vrq, PURPLE_CERTIFICATE_VALID);
}
@@ -1481,7 +1481,7 @@ x509_tls_cached_start_verify(PurpleCertificateVerificationRequest *vrq)
purple_debug_info("certificate/x509/tls_cached",
"Starting verify for %s\n",
vrq->subject_name);
-
+
tls_peers = purple_certificate_find_pool(x509_tls_cached.scheme_name,tls_peers_name);
if (!tls_peers) {
@@ -1494,7 +1494,7 @@ x509_tls_cached_start_verify(PurpleCertificateVerificationRequest *vrq)
x509_tls_cached_unknown_peer(vrq);
return;
}
-
+
/* Check if the peer has a certificate cached already */
purple_debug_info("certificate/x509/tls_cached",
"Checking for cached cert...\n");
@@ -1583,7 +1583,7 @@ purple_certificate_find_scheme(const gchar *name)
name);
/* TODO: Signalling and such? */
-
+
return NULL;
}
@@ -1611,7 +1611,7 @@ purple_certificate_register_scheme(PurpleCertificateScheme *scheme)
purple_debug_info("certificate",
"CertificateScheme %s registered\n",
scheme->name);
-
+
return TRUE;
}
@@ -1664,7 +1664,7 @@ purple_certificate_find_verifier(const gchar *scheme_name, const gchar *ver_name
scheme_name, ver_name);
/* TODO: Signalling and such? */
-
+
return NULL;
}
@@ -1742,7 +1742,7 @@ purple_certificate_find_pool(const gchar *scheme_name, const gchar *pool_name)
scheme_name, pool_name);
/* TODO: Signalling and such? */
-
+
return NULL;
}
@@ -1830,11 +1830,11 @@ purple_certificate_unregister_pool(PurpleCertificatePool *pool)
}
cert_pools = g_list_remove(cert_pools, pool);
-
+
/* TODO: Signalling? */
purple_signal_unregister(pool, "certificate-stored");
purple_signal_unregister(pool, "certificate-deleted");
-
+
purple_debug_info("certificate",
"CertificatePool %s unregistered\n",
pool->name);
diff --git a/libpurple/certificate.h b/libpurple/certificate.h
index 232b1a6..672bf93 100644
--- a/libpurple/certificate.h
+++ b/libpurple/certificate.h
@@ -60,7 +60,7 @@ typedef struct _PurpleCertificateVerificationRequest PurpleCertificateVerificati
typedef void (*PurpleCertificateVerifiedCallback)
(PurpleCertificateVerificationStatus st,
gpointer userdata);
-
+
/** A certificate instance
*
* An opaque data structure representing a single certificate under some
@@ -96,7 +96,7 @@ struct _PurpleCertificatePool
/** Internal pool data */
gpointer data;
-
+
/**
* Set up the Pool's internal state
*
@@ -249,7 +249,7 @@ struct _PurpleCertificateScheme
/** Retrieve the certificate activation/expiration times */
gboolean (* get_times)(PurpleCertificate *crt, time_t *activation, time_t *expiration);
-
+
void (*_purple_reserved1)(void);
void (*_purple_reserved2)(void);
void (*_purple_reserved3)(void);
@@ -276,7 +276,7 @@ struct _PurpleCertificateVerifier
/** Name of the Verifier - case insensitive */
gchar *name;
-
+
/**
* Start the verification process
*
@@ -326,14 +326,14 @@ struct _PurpleCertificateVerificationRequest
* For X.509 certificates, this is the Common Name
*/
gchar *subject_name;
-
+
/** List of certificates in the chain to be verified (such as that returned by purple_ssl_get_peer_certificates )
*
* This is most relevant for X.509 certificates used in SSL sessions.
* The list order should be: certificate, issuer, issuer's issuer, etc.
*/
GList *cert_chain;
-
+
/** Internal data used by the Verifier code */
gpointer data;
@@ -437,7 +437,7 @@ purple_certificate_destroy_list (GList * crt_list);
*
* @return TRUE if 'crt' has a valid signature made by 'issuer',
* otherwise FALSE
- * @todo Find a way to give the reason (bad signature, not the issuer, etc.)
+ * @todo Find a way to give the reason (bad signature, not the issuer, etc.)
*/
gboolean
purple_certificate_signed_by(PurpleCertificate *crt, PurpleCertificate *issuer);
@@ -523,7 +523,7 @@ purple_certificate_get_subject_name(PurpleCertificate *crt);
/**
* Check the subject name against that on the certificate
* @param crt Certificate instance
- * @param name Name to check.
+ * @param name Name to check.
* @return TRUE if it is a match, else FALSE
*/
gboolean
diff --git a/libpurple/cipher.c b/libpurple/cipher.c
index 215b66a..92047f3 100644
--- a/libpurple/cipher.c
+++ b/libpurple/cipher.c
@@ -512,7 +512,7 @@ md4_reset(PurpleCipherContext *context, gpointer extra) {
}
static void
-md4_append(PurpleCipherContext *context, const guchar *data, size_t len)
+md4_append(PurpleCipherContext *context, const guchar *data, size_t len)
{
struct MD4_Context *mctx = purple_cipher_context_get_data(context);
const guint32 avail = sizeof(mctx->block) - (mctx->byte_count & 0x3f);
@@ -551,7 +551,7 @@ md4_digest(PurpleCipherContext *context, size_t in_len, guchar *out,
char *p = (char *)mctx->block + offset;
int padding = 56 - (offset + 1);
-
+
if(in_len<16) return FALSE;
if(out_len) *out_len = 16;
*p++ = 0x80;
@@ -659,7 +659,7 @@ hmac_set_opt(PurpleCipherContext *context, const gchar *name, void *value)
hctx = purple_cipher_context_get_data(context);
- if (!strcmp(name, "hash")) {
+ if (purple_strequal(name, "hash")) {
g_free(hctx->name);
if (hctx->hash)
purple_cipher_context_destroy(hctx->hash);
@@ -676,7 +676,7 @@ hmac_get_opt(PurpleCipherContext *context, const gchar *name)
hctx = purple_cipher_context_get_data(context);
- if (!strcmp(name, "hash")) {
+ if (purple_strequal(name, "hash")) {
return hctx->name;
}
@@ -684,7 +684,7 @@ hmac_get_opt(PurpleCipherContext *context, const gchar *name)
}
static void
-hmac_append(PurpleCipherContext *context, const guchar *data, size_t len)
+hmac_append(PurpleCipherContext *context, const guchar *data, size_t len)
{
struct HMAC_Context *hctx = purple_cipher_context_get_data(context);
@@ -778,7 +778,7 @@ hmac_set_key(PurpleCipherContext *context, const guchar * key)
hmac_set_key_with_len(context, key, strlen((char *)key));
}
-static size_t
+static size_t
hmac_get_block_size(PurpleCipherContext *context)
{
struct HMAC_Context *hctx = purple_cipher_context_get_data(context);
@@ -1022,11 +1022,11 @@ data[6] = (right >> 8) &0xff; data[7] = right &0xff;
* 16 encryption rounds.
* To calculate subkeys for decryption the caller
* have to reorder the generated subkeys.
- *
+ *
* rawkey: 8 Bytes of key data
* subkey: Array of at least 32 guint32s. Will be filled
* with calculated subkeys.
- *
+ *
**/
static void
des_key_schedule (const guint8 * rawkey, guint32 * subkey)
@@ -1186,7 +1186,7 @@ des_encrypt(PurpleCipherContext *context, const guchar data[],
buf,
output+offset,
0);
- }
+ }
return 0;
}
@@ -1216,7 +1216,7 @@ des_decrypt(PurpleCipherContext *context, const guchar data[],
buf,
output+offset,
1);
- }
+ }
return 0;
}
@@ -1692,11 +1692,11 @@ sha1_set_opt(PurpleCipherContext *context, const gchar *name, void *value) {
ctx = purple_cipher_context_get_data(context);
- if(!strcmp(name, "sizeHi")) {
+ if(purple_strequal(name, "sizeHi")) {
ctx->sizeHi = GPOINTER_TO_INT(value);
- } else if(!strcmp(name, "sizeLo")) {
+ } else if(purple_strequal(name, "sizeLo")) {
ctx->sizeLo = GPOINTER_TO_INT(value);
- } else if(!strcmp(name, "lenW")) {
+ } else if(purple_strequal(name, "lenW")) {
ctx->lenW = GPOINTER_TO_INT(value);
}
}
@@ -1707,11 +1707,11 @@ sha1_get_opt(PurpleCipherContext *context, const gchar *name) {
ctx = purple_cipher_context_get_data(context);
- if(!strcmp(name, "sizeHi")) {
+ if(purple_strequal(name, "sizeHi")) {
return GINT_TO_POINTER(ctx->sizeHi);
- } else if(!strcmp(name, "sizeLo")) {
+ } else if(purple_strequal(name, "sizeLo")) {
return GINT_TO_POINTER(ctx->sizeLo);
- } else if(!strcmp(name, "lenW")) {
+ } else if(purple_strequal(name, "lenW")) {
return GINT_TO_POINTER(ctx->lenW);
}
@@ -1942,12 +1942,12 @@ rc4_set_opt(PurpleCipherContext *context, const gchar *name, void *value) {
ctx = purple_cipher_context_get_data(context);
- if(!strcmp(name, "key_len")) {
+ if(purple_strequal(name, "key_len")) {
ctx->key_len = GPOINTER_TO_INT(value);
}
}
-static size_t
+static size_t
rc4_get_key_size (PurpleCipherContext *context)
{
struct RC4Context *ctx;
@@ -1967,7 +1967,7 @@ rc4_get_opt(PurpleCipherContext *context, const gchar *name) {
ctx = purple_cipher_context_get_data(context);
- if(!strcmp(name, "key_len")) {
+ if(purple_strequal(name, "key_len")) {
return GINT_TO_POINTER(ctx->key_len);
}
diff --git a/libpurple/cipher.h b/libpurple/cipher.h
index 1212e98..cc0f0a3 100644
--- a/libpurple/cipher.h
+++ b/libpurple/cipher.h
@@ -422,7 +422,7 @@ PurpleCipherBatchMode purple_cipher_context_get_batch_mode(PurpleCipherContext *
size_t purple_cipher_context_get_block_size(PurpleCipherContext *context);
/**
- * Sets the key with a given length on a context
+ * Sets the key with a given length on a context
*
* @param context The context whose key to set
* @param key The key
diff --git a/libpurple/circbuffer.c b/libpurple/circbuffer.c
index 4563ab0..3c6af43 100644
--- a/libpurple/circbuffer.c
+++ b/libpurple/circbuffer.c
@@ -44,7 +44,7 @@ void purple_circ_buffer_destroy(PurpleCircBuffer *buf) {
static void grow_circ_buffer(PurpleCircBuffer *buf, gsize len) {
int in_offset = 0, out_offset = 0;
int start_buflen;
-
+
g_return_if_fail(buf != NULL);
start_buflen = buf->buflen;
@@ -94,7 +94,7 @@ void purple_circ_buffer_append(PurpleCircBuffer *buf, gconstpointer src, gsize l
int len_stored;
g_return_if_fail(buf != NULL);
-
+
/* Grow the buffer, if necessary */
if ((buf->buflen - buf->bufused) < len)
grow_circ_buffer(buf, len);
diff --git a/libpurple/cmds.c b/libpurple/cmds.c
index 7955386..4e82c91 100644
--- a/libpurple/cmds.c
+++ b/libpurple/cmds.c
@@ -236,7 +236,7 @@ PurpleCmdStatus purple_cmd_do_command(PurpleConversation *conv, const gchar *cmd
for (l = cmds; l; l = l->next) {
c = l->data;
- if (strcmp(c->cmd, cmd) != 0)
+ if (!purple_strequal(c->cmd, cmd))
continue;
found = TRUE;
@@ -250,8 +250,8 @@ PurpleCmdStatus purple_cmd_do_command(PurpleConversation *conv, const gchar *cmd
right_type = TRUE;
- if ((c->flags & PURPLE_CMD_FLAG_PRPL_ONLY) && c->prpl_id &&
- (strcmp(c->prpl_id, prpl_id) != 0))
+ if ((c->flags & PURPLE_CMD_FLAG_PRPL_ONLY) &&
+ !purple_strequal(c->prpl_id, prpl_id))
continue;
right_prpl = TRUE;
@@ -320,8 +320,8 @@ GList *purple_cmd_list(PurpleConversation *conv)
if (!(c->flags & PURPLE_CMD_FLAG_CHAT))
continue;
- if (conv && (c->flags & PURPLE_CMD_FLAG_PRPL_ONLY) && c->prpl_id &&
- (strcmp(c->prpl_id, purple_account_get_protocol_id(purple_conversation_get_account(conv))) != 0))
+ if (conv && (c->flags & PURPLE_CMD_FLAG_PRPL_ONLY) &&
+ !purple_strequal(c->prpl_id, purple_account_get_protocol_id(purple_conversation_get_account(conv))))
continue;
ret = g_list_append(ret, c->cmd);
@@ -342,7 +342,7 @@ GList *purple_cmd_help(PurpleConversation *conv, const gchar *cmd)
for (l = cmds; l; l = l->next) {
c = l->data;
- if (cmd && (strcmp(cmd, c->cmd) != 0))
+ if (cmd && !purple_strequal(cmd, c->cmd))
continue;
if (conv && (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM))
@@ -352,8 +352,8 @@ GList *purple_cmd_help(PurpleConversation *conv, const gchar *cmd)
if (!(c->flags & PURPLE_CMD_FLAG_CHAT))
continue;
- if (conv && (c->flags & PURPLE_CMD_FLAG_PRPL_ONLY) && c->prpl_id &&
- (strcmp(c->prpl_id, purple_account_get_protocol_id(purple_conversation_get_account(conv))) != 0))
+ if (conv && (c->flags & PURPLE_CMD_FLAG_PRPL_ONLY) &&
+ !purple_strequal(c->prpl_id, purple_account_get_protocol_id(purple_conversation_get_account(conv))))
continue;
ret = g_list_append(ret, c->help);
diff --git a/libpurple/connection.c b/libpurple/connection.c
index 7e981f0..6a47f3b 100644
--- a/libpurple/connection.c
+++ b/libpurple/connection.c
@@ -191,16 +191,16 @@ _purple_connection_new_unregister(PurpleAccount *account, const char *password,
PurpleConnection *gc;
PurplePlugin *prpl;
PurplePluginProtocolInfo *prpl_info;
-
+
g_return_if_fail(account != NULL);
-
+
prpl = purple_find_prpl(purple_account_get_protocol_id(account));
-
+
if (prpl != NULL)
prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
else {
gchar *message;
-
+
message = g_strdup_printf(_("Missing protocol plugin for %s"),
purple_account_get_username(account));
purple_notify_error(NULL, _("Unregistration Error"), message, NULL);
@@ -212,7 +212,7 @@ _purple_connection_new_unregister(PurpleAccount *account, const char *password,
prpl_info->unregister_user(account, cb, user_data);
return;
}
-
+
if (((password == NULL) || (*password == '\0')) &&
!(prpl_info->options & OPT_PROTO_NO_PASSWORD) &&
!(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL))
@@ -221,10 +221,10 @@ _purple_connection_new_unregister(PurpleAccount *account, const char *password,
"a password.\n", purple_account_get_username(account));
return;
}
-
+
gc = g_new0(PurpleConnection, 1);
PURPLE_DBUS_REGISTER_POINTER(gc, PurpleConnection);
-
+
gc->prpl = prpl;
if ((password != NULL) && (*password != '\0'))
gc->password = g_strdup(password);
@@ -232,11 +232,11 @@ _purple_connection_new_unregister(PurpleAccount *account, const char *password,
purple_connection_set_state(gc, PURPLE_CONNECTING);
connections = g_list_append(connections, gc);
purple_account_set_connection(account, gc);
-
+
purple_signal_emit(purple_connections_get_handle(), "signing-on", gc);
-
+
purple_debug_info("connection", "Unregistering. gc = %p\n", gc);
-
+
prpl_info->unregister_user(account, cb, user_data);
}
@@ -285,7 +285,7 @@ _purple_connection_destroy(PurpleConnection *gc)
buddies = purple_find_buddies(account, NULL);
while (buddies != NULL) {
PurpleBuddy *buddy = buddies->data;
- buddy->proto_data = NULL;
+ purple_buddy_set_protocol_data(buddy, NULL);
buddies = g_slist_delete_link(buddies, buddies);
}
@@ -427,6 +427,13 @@ purple_connection_set_display_name(PurpleConnection *gc, const char *name)
gc->display_name = g_strdup(name);
}
+void
+purple_connection_set_protocol_data(PurpleConnection *connection, void *proto_data) {
+ g_return_if_fail(connection != NULL);
+
+ connection->proto_data = proto_data;
+}
+
PurpleConnectionState
purple_connection_get_state(const PurpleConnection *gc)
{
@@ -467,6 +474,13 @@ purple_connection_get_display_name(const PurpleConnection *gc)
return gc->display_name;
}
+void *
+purple_connection_get_protocol_data(const PurpleConnection *connection) {
+ g_return_val_if_fail(connection != NULL, NULL);
+
+ return connection->proto_data;
+}
+
void
purple_connection_update_progress(PurpleConnection *gc, const char *text,
size_t step, size_t count)
diff --git a/libpurple/connection.h b/libpurple/connection.h
index 8dc476d..ea747eb 100644
--- a/libpurple/connection.h
+++ b/libpurple/connection.h
@@ -42,7 +42,7 @@ typedef enum
PURPLE_CONNECTION_FORMATTING_WBFO = 0x0008, /**< The text buffer must be formatted as a whole */
PURPLE_CONNECTION_NO_NEWLINES = 0x0010, /**< No new lines are allowed in outgoing messages */
PURPLE_CONNECTION_NO_FONTSIZE = 0x0020, /**< Connection does not send/receive font sizes */
- PURPLE_CONNECTION_NO_URLDESC = 0x0040, /**< Connection does not support descriptions with links */
+ PURPLE_CONNECTION_NO_URLDESC = 0x0040, /**< Connection does not support descriptions with links */
PURPLE_CONNECTION_NO_IMAGES = 0x0080, /**< Connection does not support sending of images */
PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY = 0x0100 /**< Connection supports sending and receiving custom smileys */
@@ -56,7 +56,9 @@ typedef enum
} PurpleConnectionState;
-/** Possible errors that can cause a connection to be closed.
+/**
+ * Possible errors that can cause a connection to be closed.
+ *
* @since 2.3.0
*/
typedef enum
@@ -70,7 +72,7 @@ typedef enum
PURPLE_CONNECTION_ERROR_INVALID_USERNAME = 1,
/** The username, password or some other credential was incorrect. Use
* #PURPLE_CONNECTION_ERROR_INVALID_USERNAME instead if the username
- * is known to be invalid.
+ * is known to be invalid.
*/
PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED = 2,
/** libpurple doesn't speak any of the authentication methods the
@@ -92,7 +94,7 @@ typedef enum
PURPLE_CONNECTION_ERROR_NAME_IN_USE = 6,
/** The username/server/other preference for the account isn't valid.
- * For instance, on IRC the screen name cannot contain white space.
+ * For instance, on IRC the username cannot contain white space.
* This reason should not be used for incorrect passwords etc: use
* #PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED for that.
*
@@ -148,71 +150,84 @@ typedef struct
#include "status.h"
#include "sslconn.h"
-/** Connection UI operations. Used to notify the user of changes to
- * connections, such as being disconnected, and to respond to the
- * underlying network connection appearing and disappearing. UIs should
- * call #purple_connections_set_ui_ops() with an instance of this struct.
+/**
+ * Connection UI operations. Used to notify the user of changes to
+ * connections, such as being disconnected, and to respond to the
+ * underlying network connection appearing and disappearing. UIs should
+ * call #purple_connections_set_ui_ops() with an instance of this struct.
*
- * @see @ref ui-ops
+ * @see @ref ui-ops
*/
typedef struct
{
- /** When an account is connecting, this operation is called to notify
- * the UI of what is happening, as well as which @a step out of @a
- * step_count has been reached (which might be displayed as a progress
- * bar).
- * @see #purple_connection_update_progress
+ /**
+ * When an account is connecting, this operation is called to notify
+ * the UI of what is happening, as well as which @a step out of @a
+ * step_count has been reached (which might be displayed as a progress
+ * bar).
+ * @see #purple_connection_update_progress
*/
void (*connect_progress)(PurpleConnection *gc,
const char *text,
size_t step,
size_t step_count);
- /** Called when a connection is established (just before the
- * @ref signed-on signal).
+ /**
+ * Called when a connection is established (just before the
+ * @ref signed-on signal).
*/
void (*connected)(PurpleConnection *gc);
- /** Called when a connection is ended (between the @ref signing-off
- * and @ref signed-off signals).
+
+ /**
+ * Called when a connection is ended (between the @ref signing-off
+ * and @ref signed-off signals).
*/
void (*disconnected)(PurpleConnection *gc);
- /** Used to display connection-specific notices. (Pidgin's Gtk user
- * interface implements this as a no-op; #purple_connection_notice(),
- * which uses this operation, is not used by any of the protocols
- * shipped with libpurple.)
+ /**
+ * Used to display connection-specific notices. (Pidgin's Gtk user
+ * interface implements this as a no-op; #purple_connection_notice(),
+ * which uses this operation, is not used by any of the protocols
+ * shipped with libpurple.)
*/
void (*notice)(PurpleConnection *gc, const char *text);
- /** Called when an error causes a connection to be disconnected.
- * Called before #disconnected.
- * @param text a localized error message.
- * @see #purple_connection_error
- * @deprecated in favour of
- * #PurpleConnectionUiOps.report_disconnect_reason.
+ /**
+ * Called when an error causes a connection to be disconnected.
+ * Called before #disconnected.
+ * @param text a localized error message.
+ * @see #purple_connection_error
+ * @deprecated in favour of
+ * #PurpleConnectionUiOps.report_disconnect_reason.
*/
void (*report_disconnect)(PurpleConnection *gc, const char *text);
- /** Called when libpurple discovers that the computer's network
- * connection is active. On Linux, this uses Network Manager if
- * available; on Windows, it uses Win32's network change notification
- * infrastructure.
+ /**
+ * Called when libpurple discovers that the computer's network
+ * connection is active. On Linux, this uses Network Manager if
+ * available; on Windows, it uses Win32's network change notification
+ * infrastructure.
*/
void (*network_connected)(void);
- /** Called when libpurple discovers that the computer's network
- * connection has gone away.
+
+ /**
+ * Called when libpurple discovers that the computer's network
+ * connection has gone away.
*/
void (*network_disconnected)(void);
- /** Called when an error causes a connection to be disconnected.
+ /**
+ * Called when an error causes a connection to be disconnected.
* Called before #disconnected. This op is intended to replace
* #report_disconnect. If both are implemented, this will be called
* first; however, there's no real reason to implement both.
+ *
* @param reason why the connection ended, if known, or
* #PURPLE_CONNECTION_ERROR_OTHER_ERROR, if not.
* @param text a localized message describing the disconnection
* in more detail to the user.
* @see #purple_connection_error_reason
+ *
* @since 2.3.0
*/
void (*report_disconnect_reason)(PurpleConnection *gc,
@@ -354,6 +369,16 @@ void purple_connection_set_account(PurpleConnection *gc, PurpleAccount *account)
void purple_connection_set_display_name(PurpleConnection *gc, const char *name);
/**
+ * Sets the protocol data for a connection.
+ *
+ * @param connection The PurpleConnection.
+ * @param proto_data The protocol data to set for the connection.
+ *
+ * @since 2.6.0
+ */
+void purple_connection_set_protocol_data(PurpleConnection *connection, void *proto_data);
+
+/**
* Returns the connection state.
*
* @param gc The connection.
@@ -385,6 +410,7 @@ PurpleAccount *purple_connection_get_account(const PurpleConnection *gc);
* @param gc The connection.
*
* @return The protocol plugin.
+ *
* @since 2.4.0
*/
PurplePlugin * purple_connection_get_prpl(const PurpleConnection *gc);
@@ -408,6 +434,17 @@ const char *purple_connection_get_password(const PurpleConnection *gc);
const char *purple_connection_get_display_name(const PurpleConnection *gc);
/**
+ * Gets the protocol data from a connection.
+ *
+ * @param connection The PurpleConnection.
+ *
+ * @return The protocol data for the connection.
+ *
+ * @since 2.6.0
+ */
+void *purple_connection_get_protocol_data(const PurpleConnection *connection);
+
+/**
* Updates the connection progress.
*
* @param gc The connection.
@@ -450,6 +487,7 @@ void purple_connection_error(PurpleConnection *gc, const char *reason);
* @param gc the connection which is closing.
* @param reason why the connection is closing.
* @param description a non-@c NULL localized description of the error.
+ *
* @since 2.3.0
*/
void
@@ -461,6 +499,7 @@ purple_connection_error_reason (PurpleConnection *gc,
* Closes a connection due to an SSL error; this is basically a shortcut to
* turning the #PurpleSslErrorType into a #PurpleConnectionError and a
* human-readable string and then calling purple_connection_error_reason().
+ *
* @since 2.3.0
*/
void
@@ -484,6 +523,7 @@ purple_connection_ssl_error (PurpleConnection *gc,
*
* @return @c TRUE if the account should not be automatically reconnected, and
* @c FALSE otherwise.
+ *
* @since 2.3.0
*/
gboolean
diff --git a/libpurple/conversation.c b/libpurple/conversation.c
index 34fbaa9..6387db9 100644
--- a/libpurple/conversation.c
+++ b/libpurple/conversation.c
@@ -665,7 +665,7 @@ purple_conversation_autoset_title(PurpleConversation *conv)
text = purple_buddy_get_contact_alias(b);
} else if(purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) {
if(account && ((chat = purple_blist_find_chat(account, name)) != NULL))
- text = chat->alias;
+ text = purple_chat_get_name(chat);
}
@@ -912,7 +912,7 @@ purple_conversation_write(PurpleConversation *conv, const char *who,
if (purple_account_get_alias(account) != NULL)
alias = account->alias;
- else if (b != NULL && strcmp(b->name, purple_buddy_get_contact_alias(b)))
+ else if (b != NULL && !purple_strequal(purple_buddy_get_name(b), purple_buddy_get_contact_alias(b)))
alias = purple_buddy_get_contact_alias(b);
else if (purple_connection_get_display_name(gc) != NULL)
alias = purple_connection_get_display_name(gc);
@@ -1480,7 +1480,7 @@ purple_conv_chat_write(PurpleConvChat *chat, const char *who, const char *messag
str = g_strdup(purple_normalize(account, who));
- if (!strcmp(str, purple_normalize(account, chat->nick))) {
+ if (purple_strequal(str, purple_normalize(account, chat->nick))) {
flags |= PURPLE_MESSAGE_SEND;
} else {
flags |= PURPLE_MESSAGE_RECV;
@@ -1601,7 +1601,7 @@ purple_conv_chat_add_users(PurpleConvChat *chat, GList *users, GList *extra_msgs
const char *extra_msg = (extra_msgs ? extra_msgs->data : NULL);
if(!(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) {
- if (!strcmp(chat->nick, purple_normalize(conv->account, user))) {
+ if (purple_strequal(chat->nick, purple_normalize(conv->account, user))) {
const char *alias2 = purple_account_get_alias(conv->account);
if (alias2 != NULL)
alias = alias2;
@@ -1692,7 +1692,7 @@ purple_conv_chat_rename_user(PurpleConvChat *chat, const char *old_user,
prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc));
g_return_if_fail(prpl_info != NULL);
- if (!strcmp(chat->nick, purple_normalize(conv->account, old_user))) {
+ if (purple_strequal(chat->nick, purple_normalize(conv->account, old_user))) {
const char *alias;
/* Note this for later. */
diff --git a/libpurple/conversation.h b/libpurple/conversation.h
index b017086..e280f9f 100644
--- a/libpurple/conversation.h
+++ b/libpurple/conversation.h
@@ -1350,7 +1350,7 @@ void purple_conv_chat_cb_destroy(PurpleConvChatBuddy *cb);
* Retrieves the extended menu items for the conversation.
*
* @param conv The conversation.
- *
+ *
* @return A list of PurpleMenuAction items, harvested by the
* chat-extended-menu signal. The list and the menuaction
* items should be freed by the caller.
diff --git a/libpurple/core.c b/libpurple/core.c
index 7e4abd4..c15d4fd 100644
--- a/libpurple/core.c
+++ b/libpurple/core.c
@@ -46,9 +46,11 @@
#include "signals.h"
#include "smiley.h"
#include "sound.h"
+#include "sound-theme-loader.h"
#include "sslconn.h"
#include "status.h"
#include "stun.h"
+#include "theme-manager.h"
#include "util.h"
#ifdef HAVE_DBUS
@@ -143,6 +145,8 @@ purple_core_init(const char *ui)
purple_plugins_probe(G_MODULE_SUFFIX);
+ purple_theme_manager_init();
+
/* The buddy icon code uses the imgstore, so init it early. */
purple_imgstore_init();
@@ -171,7 +175,7 @@ purple_core_init(const char *ui)
purple_xfers_init();
purple_idle_init();
purple_smileys_init();
-
+ purple_theme_manager_init();
/*
* Call this early on to try to auto-detect our IP address and
* hopefully save some time later.
@@ -181,6 +185,9 @@ purple_core_init(const char *ui)
if (ops != NULL && ops->ui_init != NULL)
ops->ui_init();
+ /* The UI may have registered some theme types, so refresh them */
+ purple_theme_manager_refresh();
+
return TRUE;
}
@@ -233,6 +240,7 @@ purple_core_quit(void)
purple_savedstatuses_uninit();
purple_status_uninit();
purple_sound_uninit();
+ purple_theme_manager_uninit();
purple_xfers_uninit();
purple_proxy_uninit();
purple_dnsquery_uninit();
@@ -350,15 +358,7 @@ purple_core_ensure_single_instance()
const char *user_dir = purple_user_dir();
char *dbus_owner_user_dir = purple_dbus_owner_user_dir();
- if (NULL == user_dir && NULL != dbus_owner_user_dir)
- is_single_instance = TRUE;
- else if (NULL != user_dir && NULL == dbus_owner_user_dir)
- is_single_instance = TRUE;
- else if (NULL == user_dir && NULL == dbus_owner_user_dir)
- is_single_instance = FALSE;
- else
- is_single_instance = strcmp(dbus_owner_user_dir, user_dir);
-
+ is_single_instance = !purple_strequal(dbus_owner_user_dir, user_dir);
g_free(dbus_owner_user_dir);
}
}
@@ -489,7 +489,7 @@ purple_core_migrate(void)
if (g_file_test(name, G_FILE_TEST_IS_SYMLINK))
{
/* We're only going to duplicate a logs symlink. */
- if (!strcmp(entry, "logs"))
+ if (purple_strequal(entry, "logs"))
{
char *link;
#if GLIB_CHECK_VERSION(2,4,0)
@@ -532,7 +532,8 @@ purple_core_migrate(void)
logs_dir = g_build_filename(user_dir, "logs", NULL);
- if (!strcmp(link, "../.purple/logs") || !strcmp(link, logs_dir))
+ if (purple_strequal(link, "../.purple/logs") ||
+ purple_strequal(link, logs_dir))
{
/* If the symlink points to the new directory, we're
* likely just trying again after a failed migration,
@@ -577,7 +578,7 @@ purple_core_migrate(void)
/* Deal with directories... */
if (g_file_test(name, G_FILE_TEST_IS_DIR))
{
- if (!strcmp(entry, "icons"))
+ if (purple_strequal(entry, "icons"))
{
/* This is a special case for the Album plugin, which
* stores data in the icons folder. We're not copying
@@ -646,7 +647,7 @@ purple_core_migrate(void)
g_dir_close(icons_dir);
}
- else if (!strcmp(entry, "plugins"))
+ else if (purple_strequal(entry, "plugins"))
{
/* Do nothing, because we broke plugin compatibility.
* This means that the plugins directory gets left behind. */
diff --git a/libpurple/core.h b/libpurple/core.h
index 1e4c427..958685d 100644
--- a/libpurple/core.h
+++ b/libpurple/core.h
@@ -90,17 +90,17 @@ void purple_core_quit(void);
/**
* <p>
- * Calls purple_core_quit(). This can be used as the function
- * passed to purple_timeout_add() when you want to shutdown Purple
- * in a specified amount of time. When shutting down Purple
+ * Calls purple_core_quit(). This can be used as the function
+ * passed to purple_timeout_add() when you want to shutdown Purple
+ * in a specified amount of time. When shutting down Purple
* from a plugin, you must use this instead of purple_core_quit();
- * for an immediate exit, use a timeout value of 0:
+ * for an immediate exit, use a timeout value of 0:
* </p>
*
* <code>purple_timeout_add(0, purple_core_quitcb, NULL);</code>
*
* <p>
- * This is ensures that code from your plugin is not being
+ * This is ensures that code from your plugin is not being
* executed when purple_core_quit() is called. If the plugin
* called purple_core_quit() directly, you would get a core dump
* after purple_core_quit() executes and control returns to your
diff --git a/libpurple/dbus-bindings.h b/libpurple/dbus-bindings.h
index db5e426..5611ae5 100644
--- a/libpurple/dbus-bindings.h
+++ b/libpurple/dbus-bindings.h
@@ -84,7 +84,7 @@ purple_dbus_message_iter_get_args_valist (DBusMessageIter *iter,
int first_arg_type,
va_list var_args);
-dbus_int32_t* purple_dbusify_GList(GList *list, gboolean free_memory,
+dbus_int32_t* purple_dbusify_GList(GList *list, gboolean free_memory,
dbus_int32_t *len);
dbus_int32_t* purple_dbusify_GSList(GSList *list, gboolean free_memory,
dbus_int32_t *len);
diff --git a/libpurple/dbus-server.h b/libpurple/dbus-server.h
index 6b1649d..e970866 100644
--- a/libpurple/dbus-server.h
+++ b/libpurple/dbus-server.h
@@ -173,7 +173,7 @@ void *purple_dbus_get_handle(void);
/**
* Determines whether this instance owns the DBus service name
- *
+ *
* @since 2.1.0
*/
gboolean purple_dbus_is_owner(void);
diff --git a/libpurple/desktopitem.c b/libpurple/desktopitem.c
index 1ddb5c2..714a4b1 100644
--- a/libpurple/desktopitem.c
+++ b/libpurple/desktopitem.c
@@ -41,12 +41,12 @@
* modify it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
- *
+ *
* The Gnome Library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Library General Public
* License along with the Gnome Library; see the file COPYING.LIB. If not,
* write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
@@ -67,7 +67,7 @@ struct _PurpleDesktopItem {
GList *languages;
PurpleDesktopItemType type;
-
+
/* `modified' means that the ditem has been
* modified since the last save. */
gboolean modified;
@@ -108,30 +108,30 @@ type_from_string (const char *type)
switch (type [0]) {
case 'A':
- if (!strcmp (type, "Application"))
+ if (purple_strequal (type, "Application"))
return PURPLE_DESKTOP_ITEM_TYPE_APPLICATION;
break;
case 'L':
- if (!strcmp (type, "Link"))
+ if (purple_strequal (type, "Link"))
return PURPLE_DESKTOP_ITEM_TYPE_LINK;
break;
case 'F':
- if (!strcmp (type, "FSDevice"))
+ if (purple_strequal (type, "FSDevice"))
return PURPLE_DESKTOP_ITEM_TYPE_FSDEVICE;
break;
case 'M':
- if (!strcmp (type, "MimeType"))
+ if (purple_strequal (type, "MimeType"))
return PURPLE_DESKTOP_ITEM_TYPE_MIME_TYPE;
break;
case 'D':
- if (!strcmp (type, "Directory"))
+ if (purple_strequal (type, "Directory"))
return PURPLE_DESKTOP_ITEM_TYPE_DIRECTORY;
break;
case 'S':
- if (!strcmp (type, "Service"))
+ if (purple_strequal (type, "Service"))
return PURPLE_DESKTOP_ITEM_TYPE_SERVICE;
- else if (!strcmp (type, "ServiceType"))
+ else if (purple_strequal (type, "ServiceType"))
return PURPLE_DESKTOP_ITEM_TYPE_SERVICE_TYPE;
break;
default:
@@ -149,12 +149,12 @@ find_section (PurpleDesktopItem *item, const char *section)
if (section == NULL)
return NULL;
- if (strcmp (section, "Desktop Entry") == 0)
+ if (purple_strequal (section, "Desktop Entry"))
return NULL;
for (li = item->sections; li != NULL; li = li->next) {
sec = li->data;
- if (strcmp (sec->name, section) == 0)
+ if (purple_strequal (sec->name, section))
return sec;
}
@@ -235,7 +235,7 @@ set (PurpleDesktopItem *item, const char *key, const char *value)
item->keys = g_list_append (item->keys,
g_strdup (key));
- g_hash_table_replace (item->main_hash,
+ g_hash_table_replace (item->main_hash,
g_strdup (key),
g_strdup (value));
} else {
@@ -264,7 +264,7 @@ _purple_desktop_item_set_string (PurpleDesktopItem *item,
set (item, attr, value);
- if (strcmp (attr, PURPLE_DESKTOP_ITEM_TYPE) == 0)
+ if (purple_strequal (attr, PURPLE_DESKTOP_ITEM_TYPE))
item->type = type_from_string (value);
}
@@ -280,7 +280,7 @@ _purple_desktop_item_new (void)
retval->main_hash = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify) g_free,
(GDestroyNotify) g_free);
-
+
/* These are guaranteed to be set */
_purple_desktop_item_set_string (retval,
PURPLE_DESKTOP_ITEM_NAME,
@@ -354,16 +354,16 @@ get_encoding (FILE *df)
p++;
if (*p == ' ')
p++;
- if (strcmp (p, "UTF-8") == 0) {
+ if (purple_strequal (p, "UTF-8")) {
return ENCODING_UTF8;
- } else if (strcmp (p, "Legacy-Mixed") == 0) {
+ } else if (purple_strequal (p, "Legacy-Mixed")) {
return ENCODING_LEGACY_MIXED;
} else {
/* According to the spec we're not supposed
* to read a file like this */
return ENCODING_UNKNOWN;
}
- } else if (strcmp ("[KDE Desktop Entry]", buf) == 0) {
+ } else if (purple_strequal ("[KDE Desktop Entry]", buf)) {
old_kde = TRUE;
/* don't break yet, we still want to support
* Encoding even here */
@@ -557,7 +557,7 @@ decode_string (const char *value, Encoding encoding, const char *locale)
char *utf8_string;
if (char_encoding == NULL)
return NULL;
- if (strcmp (char_encoding, "ASCII") == 0) {
+ if (purple_strequal (char_encoding, "ASCII")) {
return decode_string_and_dup (value);
}
utf8_string = g_convert (value, -1, "UTF-8", char_encoding,
@@ -673,7 +673,7 @@ insert_key (PurpleDesktopItem *item,
char *val;
/* we always store everything in UTF-8 */
if (cur_section == NULL &&
- strcmp (key, PURPLE_DESKTOP_ITEM_ENCODING) == 0) {
+ purple_strequal (key, PURPLE_DESKTOP_ITEM_ENCODING)) {
k = g_strdup (key);
val = g_strdup ("UTF-8");
} else {
@@ -690,14 +690,14 @@ insert_key (PurpleDesktopItem *item,
g_free (locale);
return;
}
-
+
g_strchomp (val);
/* For old KDE entries, we can also split by a comma
* on sort order, so convert to semicolons */
if (old_kde &&
cur_section == NULL &&
- strcmp (key, PURPLE_DESKTOP_ITEM_SORT_ORDER) == 0 &&
+ purple_strequal (key, PURPLE_DESKTOP_ITEM_SORT_ORDER) &&
strchr (val, ';') == NULL) {
int i;
for (i = 0; val[i] != '\0'; i++) {
@@ -720,7 +720,7 @@ insert_key (PurpleDesktopItem *item,
/* Take care of the language part */
if (locale != NULL &&
- strcmp (locale, "C") == 0) {
+ purple_strequal (locale, "C")) {
char *p;
/* Whack C locale */
p = strchr (k, '[');
@@ -791,11 +791,10 @@ setup_type (PurpleDesktopItem *item, const char *uri)
PURPLE_DESKTOP_ITEM_TYPE);
if (type == NULL && uri != NULL) {
char *base = g_path_get_basename (uri);
- if (base != NULL &&
- strcmp (base, ".directory") == 0) {
+ if (purple_strequal(base, ".directory")) {
/* This gotta be a directory */
g_hash_table_replace (item->main_hash,
- g_strdup (PURPLE_DESKTOP_ITEM_TYPE),
+ g_strdup (PURPLE_DESKTOP_ITEM_TYPE),
g_strdup ("Directory"));
item->keys = g_list_prepend
(item->keys, g_strdup (PURPLE_DESKTOP_ITEM_TYPE));
@@ -813,7 +812,7 @@ static const char *
lookup_locale (const PurpleDesktopItem *item, const char *key, const char *locale)
{
if (locale == NULL ||
- strcmp (locale, "C") == 0) {
+ purple_strequal (locale, "C")) {
return lookup (item, key);
} else {
const char *ret;
@@ -857,7 +856,7 @@ sanitize (PurpleDesktopItem *item, const char *uri)
type = lookup (item, PURPLE_DESKTOP_ITEM_TYPE);
/* understand old gnome style url exec thingies */
- if (type != NULL && strcmp (type, "URL") == 0) {
+ if (purple_strequal(type, "URL")) {
const char *exec = lookup (item, PURPLE_DESKTOP_ITEM_EXEC);
set (item, PURPLE_DESKTOP_ITEM_TYPE, "Link");
if (exec != NULL) {
@@ -877,7 +876,7 @@ sanitize (PurpleDesktopItem *item, const char *uri)
if (name == NULL)
name = g_strdup (_("No name"));
g_hash_table_replace (item->main_hash,
- g_strdup (PURPLE_DESKTOP_ITEM_NAME),
+ g_strdup (PURPLE_DESKTOP_ITEM_NAME),
name);
item->keys = g_list_prepend
(item->keys, g_strdup (PURPLE_DESKTOP_ITEM_NAME));
@@ -885,7 +884,7 @@ sanitize (PurpleDesktopItem *item, const char *uri)
if (lookup (item, PURPLE_DESKTOP_ITEM_ENCODING) == NULL) {
/* We store everything in UTF-8 so write that down */
g_hash_table_replace (item->main_hash,
- g_strdup (PURPLE_DESKTOP_ITEM_ENCODING),
+ g_strdup (PURPLE_DESKTOP_ITEM_ENCODING),
g_strdup ("UTF-8"));
item->keys = g_list_prepend
(item->keys, g_strdup (PURPLE_DESKTOP_ITEM_ENCODING));
@@ -893,7 +892,7 @@ sanitize (PurpleDesktopItem *item, const char *uri)
if (lookup (item, PURPLE_DESKTOP_ITEM_VERSION) == NULL) {
/* this is the version that we follow, so write it down */
g_hash_table_replace (item->main_hash,
- g_strdup (PURPLE_DESKTOP_ITEM_VERSION),
+ g_strdup (PURPLE_DESKTOP_ITEM_VERSION),
g_strdup ("1.0"));
item->keys = g_list_prepend
(item->keys, g_strdup (PURPLE_DESKTOP_ITEM_VERSION));
@@ -954,7 +953,7 @@ ditem_load (FILE *df,
while ((c = getc (df)) != EOF) {
if (c == '\r') /* Ignore Carriage Return */
continue;
-
+
switch (state) {
case OnSecHeader:
@@ -968,13 +967,11 @@ ditem_load (FILE *df,
cur_section->keys = g_list_reverse
(cur_section->keys);
}
- if (strcmp (CharBuffer,
- "KDE Desktop Entry") == 0) {
+ if (purple_strequal (CharBuffer, "KDE Desktop Entry")) {
/* Main section */
cur_section = NULL;
old_kde = TRUE;
- } else if (strcmp (CharBuffer,
- "Desktop Entry") == 0) {
+ } else if (purple_strequal(CharBuffer, "Desktop Entry")) {
/* Main section */
cur_section = NULL;
} else {
@@ -1025,16 +1022,16 @@ ditem_load (FILE *df,
/* On first pass, don't allow dangling keys */
if (state == FirstBrace)
break;
-
+
if ((c == ' ' && state != KeyDefOnKey) || c == '\t')
break;
-
+
if (c == '\n' || PURPLE_DESKTOP_ITEM_OVERFLOW) { /* Abort Definition */
next = CharBuffer;
state = KeyDef;
break;
}
-
+
if (c == '=' || PURPLE_DESKTOP_ITEM_OVERFLOW){
*next = '\0';
@@ -1067,7 +1064,7 @@ ditem_load (FILE *df,
break;
} /* switch */
-
+
} /* while ((c = getc_unlocked (f)) != EOF) */
if (c == EOF && state == KeyValue) {
*next = '\0';
@@ -1158,7 +1155,7 @@ purple_desktop_item_new_from_file (const char *filename)
printf ("Can't open %s: %s", filename, g_strerror(errno));
return NULL;
}
-
+
retval = ditem_load(dfile, FALSE, filename);
return retval;
@@ -1203,7 +1200,7 @@ purple_desktop_item_copy (const PurpleDesktopItem *item)
/* Languages */
retval->languages = g_list_copy (item->languages);
for (li = retval->languages; li != NULL; li = li->next)
- li->data = g_strdup (li->data);
+ li->data = g_strdup (li->data);
/* Keys */
retval->keys = g_list_copy (item->keys);
diff --git a/libpurple/desktopitem.h b/libpurple/desktopitem.h
index b47ac1b..b9ae357 100644
--- a/libpurple/desktopitem.h
+++ b/libpurple/desktopitem.h
@@ -41,12 +41,12 @@
* modify it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
- *
+ *
* The Gnome Library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Library General Public
* License along with the Gnome Library; see the file COPYING.LIB. If not,
* write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
@@ -155,7 +155,7 @@ const char *purple_desktop_item_get_string (const PurpleDesktopItem *item,
*
* @param item The item to be copied
*
- * @return The new copy
+ * @return The new copy
*/
PurpleDesktopItem *purple_desktop_item_copy (const PurpleDesktopItem *item);
diff --git a/libpurple/eventloop.h b/libpurple/eventloop.h
index 1d363cc..ca95f6c 100644
--- a/libpurple/eventloop.h
+++ b/libpurple/eventloop.h
@@ -119,8 +119,8 @@ struct _PurpleEventLoopUiOps
* @see purple_input_remove
*/
gboolean (*input_remove)(guint handle);
-
-
+
+
/**
* If implemented, should get the current error status for an input.
*
@@ -161,7 +161,7 @@ struct _PurpleEventLoopUiOps
/*@{*/
/**
* Creates a callback timer.
- *
+ *
* The timer will repeat until the function returns @c FALSE. The
* first call will be at the end of the first interval.
*
@@ -185,12 +185,12 @@ guint purple_timeout_add(guint interval, GSourceFunc function, gpointer data);
*
* This function allows UIs to group timers for better power efficiency. For
* this reason, @a interval may be rounded by up to a second.
- *
+ *
* @param interval The time between calls of the function, in
* seconds.
* @param function The function to call.
* @param data data to pass to @a function.
- * @return A handle to the timer which can be passed to
+ * @return A handle to the timer which can be passed to
* purple_timeout_remove() to remove the timer.
*
* @since 2.1.0
diff --git a/libpurple/idle.c b/libpurple/idle.c
index f71ca9f..55e3387 100644
--- a/libpurple/idle.c
+++ b/libpurple/idle.c
@@ -126,14 +126,14 @@ check_idleness(void)
idle_reporting = purple_prefs_get_string("/purple/away/idle_reporting");
auto_away = purple_prefs_get_bool("/purple/away/away_when_idle");
- if (!strcmp(idle_reporting, "system") &&
+ if (purple_strequal(idle_reporting, "system") &&
(idle_ui_ops != NULL) && (idle_ui_ops->get_time_idle != NULL))
{
/* Use system idle time (mouse or keyboard movement, etc.) */
time_idle = idle_ui_ops->get_time_idle();
idle_recheck_interval = 1;
}
- else if (!strcmp(idle_reporting, "purple"))
+ else if (purple_strequal(idle_reporting, "purple"))
{
/* Use 'Purple idle' */
time_idle = time(NULL) - last_active_time;
@@ -214,7 +214,7 @@ check_idleness(void)
/*
- * Check idle and set the timer to fire at the next idle-worth event
+ * Check idle and set the timer to fire at the next idle-worth event
*/
static gboolean
check_idleness_timer(void)
diff --git a/libpurple/internal.h b/libpurple/internal.h
index 039dc7a..085605f 100644
--- a/libpurple/internal.h
+++ b/libpurple/internal.h
@@ -102,7 +102,7 @@
#include <gmodule.h>
#ifdef PURPLE_PLUGINS
-# ifdef HAVE_DLFCN_H
+# ifdef HAVE_DLFCN_H
# include <dlfcn.h>
# endif
#endif
diff --git a/libpurple/log.c b/libpurple/log.c
index 729da5b..0f8da9d 100644
--- a/libpurple/log.c
+++ b/libpurple/log.c
@@ -34,6 +34,7 @@
#include "util.h"
#include "stringref.h"
#include "imgstore.h"
+#include "time.h"
static GSList *loggers = NULL;
@@ -46,6 +47,7 @@ struct _purple_logsize_user {
PurpleAccount *account;
};
static GHashTable *logsize_users = NULL;
+static GHashTable *logsize_users_decayed = NULL;
static void log_get_log_sets_common(GHashTable *sets);
@@ -161,14 +163,27 @@ void purple_log_write(PurpleLog *log, PurpleMessageFlags type,
lu->account = log->account;
if(g_hash_table_lookup_extended(logsize_users, lu, NULL, &ptrsize)) {
+ char *tmp = lu->name;
+
total = GPOINTER_TO_INT(ptrsize);
total += written;
g_hash_table_replace(logsize_users, lu, GINT_TO_POINTER(total));
+
+ /* The hash table takes ownership of lu, so create a new one
+ * for the logsize_users_decayed check below. */
+ lu = g_new(struct _purple_logsize_user, 1);
+ lu->name = g_strdup(tmp);
+ lu->account = log->account;
+ }
+
+ if(g_hash_table_lookup_extended(logsize_users_decayed, lu, NULL, &ptrsize)) {
+ total = GPOINTER_TO_INT(ptrsize);
+ total += written;
+ g_hash_table_replace(logsize_users_decayed, lu, GINT_TO_POINTER(total));
} else {
g_free(lu->name);
g_free(lu);
}
-
}
char *purple_log_read(PurpleLog *log, PurpleLogReadFlags *flags)
@@ -200,7 +215,7 @@ static guint _purple_logsize_user_hash(struct _purple_logsize_user *lu)
static guint _purple_logsize_user_equal(struct _purple_logsize_user *lu1,
struct _purple_logsize_user *lu2)
{
- return (lu1->account == lu2->account && (!strcmp(lu1->name, lu2->name)));
+ return (lu1->account == lu2->account && purple_strequal(lu1->name, lu2->name));
}
static void _purple_logsize_user_free_key(struct _purple_logsize_user *lu)
@@ -250,6 +265,49 @@ int purple_log_get_total_size(PurpleLogType type, const char *name, PurpleAccoun
return size;
}
+gint purple_log_get_activity_score(PurpleLogType type, const char *name, PurpleAccount *account)
+{
+ gpointer ptrscore;
+ int score;
+ GSList *n;
+ struct _purple_logsize_user *lu;
+ time_t now;
+ time(&now);
+
+ lu = g_new(struct _purple_logsize_user, 1);
+ lu->name = g_strdup(purple_normalize(account, name));
+ lu->account = account;
+
+ if(g_hash_table_lookup_extended(logsize_users_decayed, lu, NULL, &ptrscore)) {
+ score = GPOINTER_TO_INT(ptrscore);
+ g_free(lu->name);
+ g_free(lu);
+ } else {
+ double score_double = 0.0;
+ for (n = loggers; n; n = n->next) {
+ PurpleLogLogger *logger = n->data;
+
+ if(logger->list) {
+ GList *logs = (logger->list)(type, name, account);
+
+ while (logs) {
+ PurpleLog *log = (PurpleLog*)(logs->data);
+ /* Activity score counts bytes in the log, exponentially
+ decayed with a half-life of 14 days. */
+ score_double += purple_log_get_size(log) *
+ pow(0.5, difftime(now, log->time)/1209600.0);
+ purple_log_free(log);
+ logs = g_list_delete_link(logs, logs);
+ }
+ }
+ }
+
+ score = (gint)score_double;
+ g_hash_table_replace(logsize_users_decayed, lu, GINT_TO_POINTER(score));
+ }
+ return score;
+}
+
gboolean purple_log_is_deletable(PurpleLog *log)
{
g_return_val_if_fail(log != NULL, FALSE);
@@ -324,7 +382,7 @@ static void logger_pref_cb(const char *name, PurplePrefType type,
GSList *l = loggers;
while (l) {
logger = l->data;
- if (!strcmp(logger->id, value)) {
+ if (purple_strequal(logger->id, value)) {
purple_log_logger_set(logger);
return;
}
@@ -406,7 +464,7 @@ void purple_log_logger_add (PurpleLogLogger *logger)
if (g_slist_find(loggers, logger))
return;
loggers = g_slist_append(loggers, logger);
- if (strcmp(purple_prefs_get_string("/purple/logging/format"), logger->id) == 0) {
+ if (purple_strequal(purple_prefs_get_string("/purple/logging/format"), logger->id)) {
purple_prefs_trigger_callback("/purple/logging/format");
}
}
@@ -588,11 +646,11 @@ void purple_log_init(void)
void *handle = purple_log_get_handle();
purple_prefs_add_none("/purple/logging");
- purple_prefs_add_bool("/purple/logging/log_ims", FALSE);
- purple_prefs_add_bool("/purple/logging/log_chats", FALSE);
+ purple_prefs_add_bool("/purple/logging/log_ims", TRUE);
+ purple_prefs_add_bool("/purple/logging/log_chats", TRUE);
purple_prefs_add_bool("/purple/logging/log_system", FALSE);
- purple_prefs_add_string("/purple/logging/format", "txt");
+ purple_prefs_add_string("/purple/logging/format", "html");
html_logger = purple_log_logger_new("html", _("HTML"), 11,
NULL,
@@ -661,6 +719,9 @@ void purple_log_init(void)
logsize_users = g_hash_table_new_full((GHashFunc)_purple_logsize_user_hash,
(GEqualFunc)_purple_logsize_user_equal,
(GDestroyNotify)_purple_logsize_user_free_key, NULL);
+ logsize_users_decayed = g_hash_table_new_full((GHashFunc)_purple_logsize_user_hash,
+ (GEqualFunc)_purple_logsize_user_equal,
+ (GDestroyNotify)_purple_logsize_user_free_key, NULL);
}
void
@@ -679,6 +740,9 @@ purple_log_uninit(void)
purple_log_logger_remove(old_logger);
purple_log_logger_free(old_logger);
old_logger = NULL;
+
+ g_hash_table_destroy(logsize_users);
+ g_hash_table_destroy(logsize_users_decayed);
}
/****************************************************************************
@@ -1019,7 +1083,7 @@ static void log_get_log_sets_common(GHashTable *sets)
continue;
prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
- if (!strcmp(protocol_unescaped, prpl_info->list_icon((PurpleAccount *)account_iter->data, NULL)))
+ if (purple_strequal(protocol_unescaped, prpl_info->list_icon((PurpleAccount *)account_iter->data, NULL)))
accounts = g_list_prepend(accounts, account_iter->data);
}
g_free(protocol_unescaped);
@@ -1039,7 +1103,7 @@ static void log_get_log_sets_common(GHashTable *sets)
/* Find the account for username in the list of accounts for protocol. */
username_unescaped = purple_unescape_filename(username);
for (account_iter = g_list_first(accounts) ; account_iter != NULL ; account_iter = account_iter->next) {
- if (!strcmp(((PurpleAccount *)account_iter->data)->username, username_unescaped)) {
+ if (purple_strequal(((PurpleAccount *)account_iter->data)->username, username_unescaped)) {
account = account_iter->data;
break;
}
@@ -1068,14 +1132,14 @@ static void log_get_log_sets_common(GHashTable *sets)
/* Chat for .chat or .system at the end of the name to determine the type. */
if (len >= 7) {
gchar *tmp = &name[len - 7];
- if (!strcmp(tmp, ".system")) {
+ if (purple_strequal(tmp, ".system")) {
set->type = PURPLE_LOG_SYSTEM;
*tmp = '\0';
}
}
if (len > 5) {
gchar *tmp = &name[len - 5];
- if (!strcmp(tmp, ".chat")) {
+ if (purple_strequal(tmp, ".chat")) {
set->type = PURPLE_LOG_CHAT;
*tmp = '\0';
}
@@ -1773,29 +1837,29 @@ static GList *old_logger_list(PurpleLogType type, const char *sn, PurpleAccount
sscanf(convostart, "%*s %s %d %d:%d:%d %d",
month, &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec, &tm.tm_year);
/* Ugly hack, in case current locale is not English */
- if (strcmp(month, "Jan") == 0) {
+ if (purple_strequal(month, "Jan")) {
tm.tm_mon= 0;
- } else if (strcmp(month, "Feb") == 0) {
+ } else if (purple_strequal(month, "Feb")) {
tm.tm_mon = 1;
- } else if (strcmp(month, "Mar") == 0) {
+ } else if (purple_strequal(month, "Mar")) {
tm.tm_mon = 2;
- } else if (strcmp(month, "Apr") == 0) {
+ } else if (purple_strequal(month, "Apr")) {
tm.tm_mon = 3;
- } else if (strcmp(month, "May") == 0) {
+ } else if (purple_strequal(month, "May")) {
tm.tm_mon = 4;
- } else if (strcmp(month, "Jun") == 0) {
+ } else if (purple_strequal(month, "Jun")) {
tm.tm_mon = 5;
- } else if (strcmp(month, "Jul") == 0) {
+ } else if (purple_strequal(month, "Jul")) {
tm.tm_mon = 6;
- } else if (strcmp(month, "Aug") == 0) {
+ } else if (purple_strequal(month, "Aug")) {
tm.tm_mon = 7;
- } else if (strcmp(month, "Sep") == 0) {
+ } else if (purple_strequal(month, "Sep")) {
tm.tm_mon = 8;
- } else if (strcmp(month, "Oct") == 0) {
+ } else if (purple_strequal(month, "Oct")) {
tm.tm_mon = 9;
- } else if (strcmp(month, "Nov") == 0) {
+ } else if (purple_strequal(month, "Nov")) {
tm.tm_mon = 10;
- } else if (strcmp(month, "Dec") == 0) {
+ } else if (purple_strequal(month, "Dec")) {
tm.tm_mon = 11;
}
tm.tm_year -= 1900;
@@ -1930,7 +1994,7 @@ static void old_logger_get_log_sets(PurpleLogSetCallback cb, GHashTable *sets)
/* Make sure we're dealing with a log file. */
ext = &name[len - 4];
- if (strcmp(ext, ".log")) {
+ if (!purple_strequal(ext, ".log")) {
g_free(name);
continue;
}
@@ -1943,7 +2007,7 @@ static void old_logger_get_log_sets(PurpleLogSetCallback cb, GHashTable *sets)
set->type = PURPLE_LOG_IM;
if (len > 9) {
char *tmp = &name[len - 9];
- if (!strcmp(tmp, ".chat")) {
+ if (purple_strequal(tmp, ".chat")) {
set->type = PURPLE_LOG_CHAT;
*tmp = '\0';
}
@@ -1952,22 +2016,28 @@ static void old_logger_get_log_sets(PurpleLogSetCallback cb, GHashTable *sets)
set->name = set->normalized_name = name;
/* Search the buddy list to find the account and to determine if this is a buddy. */
- for (gnode = purple_get_blist()->root; !found && gnode != NULL; gnode = gnode->next)
+ for (gnode = purple_blist_get_root();
+ !found && gnode != NULL;
+ gnode = purple_blist_node_get_sibling_next(gnode))
{
if (!PURPLE_BLIST_NODE_IS_GROUP(gnode))
continue;
- for (cnode = gnode->child; !found && cnode != NULL; cnode = cnode->next)
+ for (cnode = purple_blist_node_get_first_child(gnode);
+ !found && cnode != NULL;
+ cnode = purple_blist_node_get_sibling_next(cnode))
{
if (!PURPLE_BLIST_NODE_IS_CONTACT(cnode))
continue;
- for (bnode = cnode->child; !found && bnode != NULL; bnode = bnode->next)
+ for (bnode = purple_blist_node_get_first_child(cnode);
+ !found && bnode != NULL;
+ bnode = purple_blist_node_get_sibling_next(bnode))
{
PurpleBuddy *buddy = (PurpleBuddy *)bnode;
- if (!strcmp(buddy->name, name)) {
- set->account = buddy->account;
+ if (purple_strequal(purple_buddy_get_name(buddy), name)) {
+ set->account = purple_buddy_get_account(buddy);
set->buddy = TRUE;
found = TRUE;
}
diff --git a/libpurple/log.h b/libpurple/log.h
index d8a84f3..59249b5 100644
--- a/libpurple/log.h
+++ b/libpurple/log.h
@@ -194,7 +194,7 @@ extern "C" {
* Creates a new log
*
* @param type The type of log this is.
- * @param name The name of this conversation (screenname, chat name,
+ * @param name The name of this conversation (buddy name, chat name,
* etc.)
* @param account The account the conversation is occurring on
* @param conv The conversation being logged
@@ -294,6 +294,19 @@ int purple_log_get_size(PurpleLog *log);
int purple_log_get_total_size(PurpleLogType type, const char *name, PurpleAccount *account);
/**
+ * Returns the activity score of a log, based on total size in bytes,
+ * which is then decayed based on age
+ *
+ * @param type The type of the log
+ * @param name The name of the log
+ * @param account The account
+ * @return The activity score
+ *
+ * @since 2.6.0
+ */
+int purple_log_get_activity_score(PurpleLogType type, const char *name, PurpleAccount *account);
+
+/**
* Tests whether a log is deletable
*
* A return value of @c FALSE indicates that purple_log_delete() will fail on this
diff --git a/libpurple/nat-pmp.c b/libpurple/nat-pmp.c
index a3717fb..be5bc66 100644
--- a/libpurple/nat-pmp.c
+++ b/libpurple/nat-pmp.c
@@ -126,7 +126,7 @@ get_rtaddrs(int bitmask, struct sockaddr *sa, struct sockaddr *addrs[])
for (i = 0; i < RTAX_MAX; i++)
{
- if (bitmask & (1 << i))
+ if (bitmask & (1 << i))
{
addrs[i] = sa;
#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
@@ -139,7 +139,7 @@ get_rtaddrs(int bitmask, struct sockaddr *sa, struct sockaddr *addrs[])
sa = (struct sockaddr*)(sizeof(struct sockaddr_in6) + (char *)sa);
#endif
#endif
- }
+ }
else
{
addrs[i] = NULL;
@@ -192,7 +192,7 @@ default_gw()
mib[5] = 0;
/* Determine the buffer side needed to get the full routing table */
- if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0)
+ if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0)
{
purple_debug_warning("nat-pmp", "sysctl: net.route.0.0.dump estimate\n");
return NULL;
@@ -205,7 +205,7 @@ default_gw()
}
/* Read the routing table into buf */
- if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0)
+ if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0)
{
purple_debug_warning("nat-pmp", "sysctl: net.route.0.0.dump\n");
return NULL;
@@ -213,12 +213,12 @@ default_gw()
lim = buf + needed;
- for (next = buf; next < lim; next += rtm->rtm_msglen)
+ for (next = buf; next < lim; next += rtm->rtm_msglen)
{
rtm = (struct rt_msghdr *)next;
sa = (struct sockaddr *)(rtm + 1);
-
- if (sa->sa_family == AF_INET)
+
+ if (sa->sa_family == AF_INET)
{
sin = (struct sockaddr_in*) sa;
@@ -240,7 +240,7 @@ default_gw()
memcpy(&mask, rti_info[RTAX_NETMASK], sizeof(mask));
if (rtm->rtm_addrs & RTA_GATEWAY &&
- is_default_route(&addr, &mask))
+ is_default_route(&addr, &mask))
{
if (rti_info[RTAX_GATEWAY]) {
struct sockaddr_in *rti_sin = (struct sockaddr_in *)rti_info[RTAX_GATEWAY];
@@ -263,7 +263,7 @@ default_gw()
}
/*!
- * purple_pmp_get_public_ip() will return the publicly facing IP address of the
+ * purple_pmp_get_public_ip() will return the publicly facing IP address of the
* default NAT gateway. The function will return NULL if:
* - The gateway doesn't support NAT-PMP
* - The gateway errors in some other spectacular fashion
@@ -278,10 +278,10 @@ purple_pmp_get_public_ip()
PurplePmpIpRequest req;
PurplePmpIpResponse resp;
int sendfd;
-
+
if (pmp_info.status == PURPLE_PMP_STATUS_UNABLE_TO_DISCOVER)
return NULL;
-
+
if ((pmp_info.status == PURPLE_PMP_STATUS_DISCOVERED) && (pmp_info.publicip != NULL))
{
#ifdef PMP_DEBUG
@@ -318,7 +318,7 @@ purple_pmp_get_public_ip()
/* The NAT-PMP spec says we should attempt to contact the gateway 9 times, doubling the time we wait each time.
* Even starting with a timeout of 0.1 seconds, that means that we have a total waiting of 204.6 seconds.
* With the recommended timeout of 0.25 seconds, we're talking 511.5 seconds (8.5 minutes).
- *
+ *
* This seems really silly... if this were nonblocking, a couple retries might be in order, but it's not at present.
*/
#ifdef PMP_DEBUG
@@ -327,7 +327,7 @@ purple_pmp_get_public_ip()
#endif
/* TODO: Non-blocking! */
-
+
if (sendto(sendfd, &req, sizeof(req), 0, (struct sockaddr *)(gateway), sizeof(struct sockaddr)) < 0)
{
purple_debug_info("nat-pmp", "There was an error sending the NAT-PMP public IP request! (%s)\n", g_strerror(errno));
@@ -370,7 +370,7 @@ purple_pmp_get_public_ip()
if (!publicsockaddr) {
g_free(gateway);
-
+
pmp_info.status = PURPLE_PMP_STATUS_UNABLE_TO_DISCOVER;
return NULL;
}
@@ -437,7 +437,7 @@ purple_pmp_create_map(PurplePmpType type, unsigned short privateport, unsigned s
/* The NAT-PMP spec says we should attempt to contact the gateway 9 times, doubling the time we wait each time.
* Even starting with a timeout of 0.1 seconds, that means that we have a total waiting of 204.6 seconds.
* With the recommended timeout of 0.25 seconds, we're talking 511.5 seconds (8.5 minutes).
- *
+ *
* This seems really silly... if this were nonblocking, a couple retries might be in order, but it's not at present.
* XXX Make this nonblocking.
* XXX This code looks like the pmp_get_public_ip() code. Can it be consolidated?
diff --git a/libpurple/network.c b/libpurple/network.c
index 508d3c3..c9782b6 100644
--- a/libpurple/network.c
+++ b/libpurple/network.c
@@ -96,6 +96,10 @@ struct _PurpleNetworkListenData {
static NMState nm_get_network_state(void);
#endif
+#if defined(HAVE_NETWORKMANAGER) || defined(_WIN32)
+static gboolean force_online;
+#endif
+
const unsigned char *
purple_network_ip_atoi(const char *ip)
{
@@ -671,6 +675,9 @@ gboolean
purple_network_is_available(void)
{
#ifdef HAVE_NETWORKMANAGER
+ if (force_online)
+ return TRUE;
+
if (!have_nm_state)
{
have_nm_state = TRUE;
@@ -685,12 +692,20 @@ purple_network_is_available(void)
return FALSE;
#elif defined _WIN32
- return (current_network_count > 0);
+ return (current_network_count > 0 || force_online);
#else
return TRUE;
#endif
}
+void
+purple_network_force_online()
+{
+#if defined(HAVE_NETWORKMANAGER) || defined(_WIN32)
+ force_online = TRUE;
+#endif
+}
+
#ifdef HAVE_NETWORKMANAGER
static void
nm_update_state(NMState state)
diff --git a/libpurple/network.h b/libpurple/network.h
index 0ff97c9..21b3a08 100644
--- a/libpurple/network.h
+++ b/libpurple/network.h
@@ -208,6 +208,17 @@ unsigned short purple_network_get_port_from_fd(int fd);
gboolean purple_network_is_available(void);
/**
+ * Makes purple_network_is_available() always return @c TRUE.
+ *
+ * This is what backs the --force-online command line argument in Pidgin,
+ * for example. This is useful for offline testing, especially when
+ * combined with nullprpl.
+ *
+ * @since 2.6.0
+ */
+void purple_network_force_online(void);
+
+/**
* Get the handle for the network system
*
* @return the handle to the network system
diff --git a/libpurple/notify.c b/libpurple/notify.c
index 2b51d9f..349521f 100644
--- a/libpurple/notify.c
+++ b/libpurple/notify.c
@@ -444,7 +444,7 @@ PurpleNotifyUserInfoEntry *
purple_notify_user_info_entry_new(const char *label, const char *value)
{
PurpleNotifyUserInfoEntry *user_info_entry;
-
+
user_info_entry = g_new0(PurpleNotifyUserInfoEntry, 1);
PURPLE_DBUS_REGISTER_POINTER(user_info_entry, PurpleNotifyUserInfoEntry);
user_info_entry->label = g_strdup(label);
@@ -458,7 +458,7 @@ static void
purple_notify_user_info_entry_destroy(PurpleNotifyUserInfoEntry *user_info_entry)
{
g_return_if_fail(user_info_entry != NULL);
-
+
g_free(user_info_entry->label);
g_free(user_info_entry->value);
PURPLE_DBUS_UNREGISTER_POINTER(user_info_entry);
@@ -469,11 +469,11 @@ PurpleNotifyUserInfo *
purple_notify_user_info_new()
{
PurpleNotifyUserInfo *user_info;
-
+
user_info = g_new0(PurpleNotifyUserInfo, 1);
PURPLE_DBUS_REGISTER_POINTER(user_info, PurpleNotifyUserInfo);
user_info->user_info_entries = NULL;
-
+
return user_info;
}
@@ -484,10 +484,10 @@ purple_notify_user_info_destroy(PurpleNotifyUserInfo *user_info)
for (l = user_info->user_info_entries; l != NULL; l = l->next) {
PurpleNotifyUserInfoEntry *user_info_entry = l->data;
-
+
purple_notify_user_info_entry_destroy(user_info_entry);
}
-
+
g_list_free(user_info->user_info_entries);
PURPLE_DBUS_UNREGISTER_POINTER(user_info);
g_free(user_info);
@@ -506,7 +506,7 @@ purple_notify_user_info_get_text_with_newline(PurpleNotifyUserInfo *user_info, c
{
GList *l;
GString *text;
-
+
text = g_string_new("");
for (l = user_info->user_info_entries; l != NULL; l = l->next) {
@@ -532,7 +532,7 @@ purple_notify_user_info_get_text_with_newline(PurpleNotifyUserInfo *user_info, c
if ((user_info_entry->type != PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK) &&
(l->next && ((((PurpleNotifyUserInfoEntry *)(l->next->data))->type != PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK))))
g_string_append(text, newline);
-
+
/* Add an extra newline after a section header */
if (user_info_entry->type == PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_HEADER)
g_string_append(text, newline);
@@ -563,7 +563,7 @@ const gchar *
purple_notify_user_info_entry_get_value(PurpleNotifyUserInfoEntry *user_info_entry)
{
g_return_val_if_fail(user_info_entry != NULL, NULL);
-
+
return user_info_entry->value;
}
@@ -596,7 +596,7 @@ void
purple_notify_user_info_add_pair(PurpleNotifyUserInfo *user_info, const char *label, const char *value)
{
PurpleNotifyUserInfoEntry *entry;
-
+
entry = purple_notify_user_info_entry_new(label, value);
user_info->user_info_entries = g_list_append(user_info->user_info_entries, entry);
}
@@ -623,7 +623,7 @@ void
purple_notify_user_info_add_section_header(PurpleNotifyUserInfo *user_info, const char *label)
{
PurpleNotifyUserInfoEntry *entry;
-
+
entry = purple_notify_user_info_entry_new(label, NULL);
entry->type = PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_HEADER;
@@ -634,10 +634,10 @@ void
purple_notify_user_info_prepend_section_header(PurpleNotifyUserInfo *user_info, const char *label)
{
PurpleNotifyUserInfoEntry *entry;
-
+
entry = purple_notify_user_info_entry_new(label, NULL);
entry->type = PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_HEADER;
-
+
user_info->user_info_entries = g_list_prepend(user_info->user_info_entries, entry);
}
@@ -645,7 +645,7 @@ void
purple_notify_user_info_add_section_break(PurpleNotifyUserInfo *user_info)
{
PurpleNotifyUserInfoEntry *entry;
-
+
entry = purple_notify_user_info_entry_new(NULL, NULL);
entry->type = PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK;
@@ -656,10 +656,10 @@ void
purple_notify_user_info_prepend_section_break(PurpleNotifyUserInfo *user_info)
{
PurpleNotifyUserInfoEntry *entry;
-
+
entry = purple_notify_user_info_entry_new(NULL, NULL);
entry->type = PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK;
-
+
user_info->user_info_entries = g_list_prepend(user_info->user_info_entries, entry);
}
diff --git a/libpurple/notify.h b/libpurple/notify.h
index 3e65a11..d82fe86 100644
--- a/libpurple/notify.h
+++ b/libpurple/notify.h
@@ -291,6 +291,7 @@ void purple_notify_searchresults_column_add(PurpleNotifySearchResults *results,
*/
void purple_notify_searchresults_row_add(PurpleNotifySearchResults *results,
GList *row);
+
#if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_NOTIFY_C_)
/**
* Returns a number of the rows in the search results object.
@@ -558,14 +559,21 @@ void purple_notify_user_info_add_pair(PurpleNotifyUserInfo *user_info, const cha
*/
void purple_notify_user_info_prepend_pair(PurpleNotifyUserInfo *user_info, const char *label, const char *value);
+#if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_NOTIFY_C_)
/**
* Remove a PurpleNotifyUserInfoEntry from a PurpleNotifyUserInfo object
* without freeing the entry.
*
* @param user_info The PurpleNotifyUserInfo
* @param user_info_entry The PurpleNotifyUserInfoEntry
+ *
+ * @deprecated Nothing is using this function and it should be removed
+ * in 3.0.0. Or, if we decide we want to keep it in 3.0.0
+ * then we should make purple_notify_user_info_entry_destroy
+ * public so that entries can be free'd after they're removed.
*/
void purple_notify_user_info_remove_entry(PurpleNotifyUserInfo *user_info, PurpleNotifyUserInfoEntry *user_info_entry);
+#endif
/**
* Create a new PurpleNotifyUserInfoEntry
diff --git a/libpurple/ntlm.h b/libpurple/ntlm.h
index e8eb18c..e61a4f5 100644
--- a/libpurple/ntlm.h
+++ b/libpurple/ntlm.h
@@ -46,7 +46,7 @@ gchar *purple_ntlm_gen_type1(const gchar *hostname, const gchar *domain);
*
* @param type2 String containing the base64 encoded type2 message
* @param flags If not @c NULL, this will store the flags for the message
- *
+ *
* @return The nonce for use in message type3. This is a statically
* allocated 8 byte binary string.
*/
diff --git a/libpurple/plugin.c b/libpurple/plugin.c
index 738d42f..b46b09e 100644
--- a/libpurple/plugin.c
+++ b/libpurple/plugin.c
@@ -218,7 +218,7 @@ purple_plugin_probe(const char *filename)
g_free(basename);
if (plugin != NULL)
{
- if (!strcmp(filename, plugin->path))
+ if (purple_strequal(filename, plugin->path))
return plugin;
else if (!purple_plugin_is_unloadable(plugin))
{
@@ -357,7 +357,7 @@ purple_plugin_probe(const char *filename)
return NULL;
}
else if (plugin->info->ui_requirement &&
- strcmp(plugin->info->ui_requirement, purple_core_get_ui()))
+ !purple_strequal(plugin->info->ui_requirement, purple_core_get_ui()))
{
plugin->error = g_strdup_printf(_("You are using %s, but this plugin requires %s."),
purple_core_get_ui(), plugin->info->ui_requirement);
@@ -1538,7 +1538,7 @@ purple_plugins_find_with_name(const char *name)
for (l = plugins; l != NULL; l = l->next) {
plugin = l->data;
- if (!strcmp(plugin->info->name, name))
+ if (purple_strequal(plugin->info->name, name))
return plugin;
}
@@ -1554,7 +1554,7 @@ purple_plugins_find_with_filename(const char *filename)
for (l = plugins; l != NULL; l = l->next) {
plugin = l->data;
- if (plugin->path != NULL && !strcmp(plugin->path, filename))
+ if (purple_strequal(plugin->path, filename))
return plugin;
}
@@ -1577,7 +1577,7 @@ purple_plugins_find_with_basename(const char *basename)
if (plugin->path != NULL) {
tmp = purple_plugin_get_basename(plugin->path);
- if (!strcmp(tmp, basename))
+ if (purple_strequal(tmp, basename))
{
g_free(tmp);
return plugin;
@@ -1603,7 +1603,7 @@ purple_plugins_find_with_id(const char *id)
{
plugin = l->data;
- if (plugin->info->id != NULL && !strcmp(plugin->info->id, id))
+ if (purple_strequal(plugin->info->id, id))
return plugin;
}
diff --git a/libpurple/plugin.h b/libpurple/plugin.h
index a731a3b..6ce6ada 100644
--- a/libpurple/plugin.h
+++ b/libpurple/plugin.h
@@ -188,7 +188,7 @@ struct _PurplePluginAction {
/** NULL for plugin actions menu, set to the PurpleConnection for
account actions menu */
gpointer context;
-
+
gpointer user_data;
};
@@ -363,7 +363,7 @@ const gchar *purple_plugin_get_id(const PurplePlugin *plugin);
* Returns a plugin's name.
*
* @param plugin The plugin.
- *
+ *
* @return THe name of the plugin, or @c NULL.
*/
const gchar *purple_plugin_get_name(const PurplePlugin *plugin);
diff --git a/libpurple/plugins/Makefile.am b/libpurple/plugins/Makefile.am
index 6cb2c8f..0a8aa53 100644
--- a/libpurple/plugins/Makefile.am
+++ b/libpurple/plugins/Makefile.am
@@ -36,6 +36,7 @@ log_reader_la_LDFLAGS = -module -avoid-version
newline_la_LDFLAGS = -module -avoid-version
notify_example_la_LDFLAGS = -module -avoid-version
offlinemsg_la_LDFLAGS = -module -avoid-version
+one_time_password_la_LDFLAGS = -module -avoid-version
pluginpref_example_la_LDFLAGS = -module -avoid-version
psychic_la_LDFLAGS = -module -avoid-version
signals_test_la_LDFLAGS = -module -avoid-version
@@ -65,6 +66,7 @@ noinst_LTLIBRARIES = \
debug_example.la \
helloworld.la \
notify_example.la \
+ one_time_password.la \
pluginpref_example.la \
signals_test.la \
simple.la
@@ -81,6 +83,7 @@ log_reader_la_SOURCES = log_reader.c
newline_la_SOURCES = newline.c
notify_example_la_SOURCES = notify_example.c
offlinemsg_la_SOURCES = offlinemsg.c
+one_time_password_la_SOURCES = one_time_password.c
pluginpref_example_la_SOURCES = pluginpref_example.c
psychic_la_SOURCES = psychic.c
signals_test_la_SOURCES = signals-test.c
@@ -97,6 +100,7 @@ log_reader_la_LIBADD = $(GLIB_LIBS)
newline_la_LIBADD = $(GLIB_LIBS)
notify_example_la_LIBADD = $(GLIB_LIBS)
offlinemsg_la_LIBADD = $(GLIB_LIBS)
+one_time_password_la_LIBADD = $(GLIB_LIBS)
pluginpref_example_la_LIBADD = $(GLIB_LIBS)
psychic_la_LIBADD = $(GLIB_LIBS)
signals_test_la_LIBADD = $(GLIB_LIBS)
diff --git a/libpurple/plugins/Makefile.mingw b/libpurple/plugins/Makefile.mingw
index 5dc4d67..b3c80a0 100644
--- a/libpurple/plugins/Makefile.mingw
+++ b/libpurple/plugins/Makefile.mingw
@@ -1,7 +1,7 @@
#
# Makefile.mingw
#
-# Description: Makefile for win32 (mingw) version of LibPurple Plugins
+# Description: Makefile for win32 (mingw) version of libpurple Plugins
#
PIDGIN_TREE_TOP := ../..
diff --git a/libpurple/plugins/autoaccept.c b/libpurple/plugins/autoaccept.c
index e9f04db..4112c34 100644
--- a/libpurple/plugins/autoaccept.c
+++ b/libpurple/plugins/autoaccept.c
@@ -95,7 +95,7 @@ file_recv_request_cb(PurpleXfer *xfer, gpointer handle)
char *dirname;
account = xfer->account;
- node = (PurpleBlistNode *)purple_find_buddy(account, xfer->who);
+ node = PURPLE_BLIST_NODE(purple_find_buddy(account, xfer->who));
if (!node)
{
diff --git a/libpurple/plugins/one_time_password.c b/libpurple/plugins/one_time_password.c
new file mode 100644
index 0000000..caf2921
--- /dev/null
+++ b/libpurple/plugins/one_time_password.c
@@ -0,0 +1,151 @@
+/*
+ * One Time Password support plugin for libpurple
+ *
+ * Copyright (C) 2009, Daniel Atallah <datallah@pidgin.im>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02111-1301, USA.
+ */
+#include "internal.h"
+#include "debug.h"
+#include "plugin.h"
+#include "version.h"
+#include "account.h"
+#include "accountopt.h"
+
+#define PLUGIN_ID "core-one_time_password"
+#define PREF_NAME PLUGIN_ID "_enabled"
+
+static void
+signed_on_cb(PurpleConnection *conn, void *data)
+{
+ PurpleAccount *account = purple_connection_get_account(conn);
+
+ if (purple_account_get_bool(account, PREF_NAME, FALSE)) {
+ if(purple_account_get_remember_password(account))
+ purple_debug_error("One Time Password",
+ "Unable to enforce one time password for account %s (%s).\n"
+ "Account is set to remember the password.\n",
+ purple_account_get_username(account),
+ purple_account_get_protocol_name(account));
+ else {
+
+ purple_debug_info("One Time Password", "Clearing password for account %s (%s).\n",
+ purple_account_get_username(account),
+ purple_account_get_protocol_name(account));
+
+ purple_account_set_password(account, NULL);
+ /* TODO: Do we need to somehow clear conn->password ? */
+ }
+ }
+}
+
+static gboolean
+plugin_load(PurplePlugin *plugin)
+{
+ PurplePlugin *prpl;
+ PurplePluginProtocolInfo *prpl_info;
+ PurpleAccountOption *option;
+ GList *l;
+
+ /* Register protocol preference. */
+ for (l = purple_plugins_get_protocols(); l != NULL; l = l->next) {
+ prpl = (PurplePlugin *)l->data;
+ prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+ if (prpl_info != NULL && !(prpl_info->options & OPT_PROTO_NO_PASSWORD)) {
+ option = purple_account_option_bool_new(_("One Time Password"),
+ PREF_NAME, FALSE);
+ prpl_info->protocol_options = g_list_append(prpl_info->protocol_options, option);
+ }
+ }
+
+ /* Register callback. */
+ purple_signal_connect(purple_connections_get_handle(), "signed-on",
+ plugin, PURPLE_CALLBACK(signed_on_cb), NULL);
+
+ return TRUE;
+}
+
+static gboolean
+plugin_unload(PurplePlugin *plugin)
+{
+ PurplePlugin *prpl;
+ PurplePluginProtocolInfo *prpl_info;
+ PurpleAccountOption *option;
+ GList *l, *options;
+
+ /* Remove protocol preference. */
+ for (l = purple_plugins_get_protocols(); l != NULL; l = l->next) {
+ prpl = (PurplePlugin *)l->data;
+ prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+ if (prpl_info != NULL && !(prpl_info->options & OPT_PROTO_NO_PASSWORD)) {
+ options = prpl_info->protocol_options;
+ while (options != NULL) {
+ option = (PurpleAccountOption *) options->data;
+ if (strcmp(PREF_NAME, purple_account_option_get_setting(option)) == 0) {
+ prpl_info->protocol_options = g_list_delete_link(prpl_info->protocol_options, options);
+ purple_account_option_destroy(option);
+ break;
+ }
+ options = options->next;
+ }
+ }
+ }
+
+ /* Callback will be automagically unregistered */
+
+ return TRUE;
+}
+
+static PurplePluginInfo info =
+{
+ PURPLE_PLUGIN_MAGIC,
+ PURPLE_MAJOR_VERSION,
+ PURPLE_MINOR_VERSION,
+ PURPLE_PLUGIN_STANDARD, /**< type */
+ NULL, /**< ui_requirement */
+ 0, /**< flags */
+ NULL, /**< dependencies */
+ PURPLE_PRIORITY_DEFAULT, /**< priority */
+ PLUGIN_ID, /**< id */
+ N_("One Time Password Support"), /**< name */
+ DISPLAY_VERSION, /**< version */
+ /** summary */
+ N_("Enforce that passwords are used only once."),
+ /** description */
+ N_("Allows you to enforce on a per-account basis that passwords not "
+ "being saved are only used in a single successful connection.\n"
+ "Note: The account password must not be saved for this to work."),
+ "Daniel Atallah <datallah@pidgin.im>", /**< author */
+ PURPLE_WEBSITE, /**< homepage */
+ plugin_load, /**< load */
+ plugin_unload, /**< unload */
+ NULL, /**< destroy */
+ NULL, /**< ui_info */
+ NULL, /**< extra_info */
+ NULL, /**< prefs_info */
+ NULL, /**< actions */
+ NULL, /**< reserved 1 */
+ NULL, /**< reserved 2 */
+ NULL, /**< reserved 3 */
+ NULL /**< reserved 4 */
+};
+
+static void
+init_plugin(PurplePlugin *plugin)
+{
+}
+
+PURPLE_INIT_PLUGIN(one_time_password, init_plugin, info)
diff --git a/libpurple/plugins/perl/common/BuddyList.xs b/libpurple/plugins/perl/common/BuddyList.xs
index 5acb72a..0f68d87 100644
--- a/libpurple/plugins/perl/common/BuddyList.xs
+++ b/libpurple/plugins/perl/common/BuddyList.xs
@@ -363,9 +363,9 @@ MODULE = Purple::BuddyList PACKAGE = Purple::BuddyList::Buddy PREFIX = purple_
PROTOTYPES: ENABLE
Purple::BuddyList::Buddy
-purple_buddy_new(account, screenname, alias)
+purple_buddy_new(account, name, alias)
Purple::Account account
- const char *screenname
+ const char *name
const char *alias
const char *
diff --git a/libpurple/plugins/perl/common/Request.xs b/libpurple/plugins/perl/common/Request.xs
index 03ef5bf..3ba745c 100644
--- a/libpurple/plugins/perl/common/Request.xs
+++ b/libpurple/plugins/perl/common/Request.xs
@@ -211,10 +211,11 @@ MODULE = Purple::Request PACKAGE = Purple::Request::Field PREFIX = purple_requ
PROTOTYPES: ENABLE
Purple::Request::Field
-purple_request_field_account_new(id, text, account = NULL)
+purple_request_field_account_new(class, id, text, account = NULL)
const char *id
const char *text
Purple::Account account
+ C_ARGS: id, text, account
Purple::Account
purple_request_field_account_get_default_value(field)
@@ -255,10 +256,11 @@ MODULE = Purple::Request PACKAGE = Purple::Request::Field PREFIX = purple_requ
PROTOTYPES: ENABLE
Purple::Request::Field
-purple_request_field_bool_new(id, text, default_value = TRUE)
+purple_request_field_bool_new(class, id, text, default_value = TRUE)
const char *id
const char *text
gboolean default_value
+ C_ARGS: id, text, default_value
gboolean
purple_request_field_bool_get_default_value(field)
@@ -282,10 +284,11 @@ MODULE = Purple::Request PACKAGE = Purple::Request::Field PREFIX = purple_requ
PROTOTYPES: ENABLE
Purple::Request::Field
-purple_request_field_choice_new(id, text, default_value = 0)
+purple_request_field_choice_new(class, id, text, default_value = 0)
const char *id
const char *text
int default_value
+ C_ARGS: id, text, default_value
void
purple_request_field_choice_add(field, label)
@@ -324,10 +327,11 @@ MODULE = Purple::Request PACKAGE = Purple::Request::Field PREFIX = purple_requ
PROTOTYPES: ENABLE
Purple::Request::Field
-purple_request_field_int_new(id, text, default_value = 0)
+purple_request_field_int_new(clas, id, text, default_value = 0)
const char *id
const char *text
int default_value
+ C_ARGS: id, text, default_value
int
purple_request_field_int_get_default_value(field)
@@ -355,17 +359,19 @@ MODULE = Purple::Request PACKAGE = Purple::Request::Field PREFIX = purple_requ
PROTOTYPES: ENABLE
Purple::Request::Field
-purple_request_field_label_new(id, text)
+purple_request_field_label_new(class, id, text)
const char *id
const char *text
+ C_ARGS: id, text
MODULE = Purple::Request PACKAGE = Purple::Request::Field PREFIX = purple_request_field_
PROTOTYPES: ENABLE
Purple::Request::Field
-purple_request_field_list_new(id, text)
+purple_request_field_list_new(class, id, text)
const char *id
const char *text
+ C_ARGS: id, text
void
purple_request_field_list_add(field, item, data)
@@ -425,10 +431,11 @@ MODULE = Purple::Request PACKAGE = Purple::Request::Field PREFIX = purple_requ
PROTOTYPES: ENABLE
Purple::Request::Field
-purple_request_field_new(id, text, type)
+purple_request_field_new(class, id, text, type)
const char *id
const char *text
Purple::RequestFieldType type
+ C_ARGS: id, text, type
void
purple_request_field_set_label(field, label)
@@ -454,11 +461,12 @@ MODULE = Purple::Request PACKAGE = Purple::Request::Field PREFIX = purple_requ
PROTOTYPES: ENABLE
Purple::Request::Field
-purple_request_field_string_new(id, text, default_value, multiline)
+purple_request_field_string_new(class, id, text, default_value, multiline)
const char *id
const char *text
const char *default_value
gboolean multiline
+ C_ARGS: id, text, default_value, multiline
const char *
purple_request_field_string_get_default_value(field)
@@ -527,8 +535,9 @@ purple_request_field_group_get_title(group)
Purple::Request::Field::Group group
Purple::Request::Field::Group
-purple_request_field_group_new(title)
+purple_request_field_group_new(class, title)
const char *title
+ C_ARGS: title
MODULE = Purple::Request PACKAGE = Purple::Request::Field PREFIX = purple_request_field_
PROTOTYPES: ENABLE
@@ -561,7 +570,8 @@ MODULE = Purple::Request PACKAGE = Purple::Request::Fields PREFIX = purple_req
PROTOTYPES: ENABLE
Purple::Request::Fields
-purple_request_fields_new()
+purple_request_fields_new(class)
+ C_ARGS: /* void */
void
purple_request_fields_add_group(fields, group)
diff --git a/libpurple/plugins/ssl/ssl-gnutls.c b/libpurple/plugins/ssl/ssl-gnutls.c
index 1f65607..de4908e 100644
--- a/libpurple/plugins/ssl/ssl-gnutls.c
+++ b/libpurple/plugins/ssl/ssl-gnutls.c
@@ -256,9 +256,13 @@ ssl_gnutls_connect(PurpleSslConnection *gsc)
gsc->private_data = gnutls_data;
gnutls_init(&gnutls_data->session, GNUTLS_CLIENT);
+#ifdef HAVE_GNUTLS_PRIORITY_FUNCS
if (gnutls_priority_set_direct(gnutls_data->session,
"NORMAL:%SSL3_RECORD_VERSION", NULL))
gnutls_priority_set_direct(gnutls_data->session, "NORMAL", NULL);
+#else
+ gnutls_set_default_priority(gnutls_data->session);
+#endif
gnutls_certificate_type_set_priority(gnutls_data->session,
cert_type_priority);
diff --git a/libpurple/plugins/statenotify.c b/libpurple/plugins/statenotify.c
index dc25596..7feeba9 100644
--- a/libpurple/plugins/statenotify.c
+++ b/libpurple/plugins/statenotify.c
@@ -33,7 +33,7 @@ write_status(PurpleBuddy *buddy, const char *message)
g_return_if_fail(conv->type == PURPLE_CONV_TYPE_IM);
/* Prevent duplicate notifications for buddies in multiple groups */
- if (buddy != purple_find_buddy(buddy->account, buddy->name))
+ if (buddy != purple_find_buddy(account, buddy_name))
return;
who = purple_buddy_get_alias(buddy);
diff --git a/libpurple/plugins/tcl/tcl_cmds.c b/libpurple/plugins/tcl/tcl_cmds.c
index 222f05e..53af859 100644
--- a/libpurple/plugins/tcl/tcl_cmds.c
+++ b/libpurple/plugins/tcl/tcl_cmds.c
@@ -401,9 +401,9 @@ static PurpleBlistNode *tcl_list_to_buddy(Tcl_Interp *interp, int count, Tcl_Obj
return NULL;
if (!strcmp(type, "buddy")) {
- node = (PurpleBlistNode *)purple_find_buddy(account, name);
+ node = PURPLE_BLIST_NODE(purple_find_buddy(account, name));
} else if (!strcmp(type, "group")) {
- node = (PurpleBlistNode *)purple_blist_find_chat(account, name);
+ node = PURPLE_BLIST_NODE(purple_blist_find_chat(account, name));
}
return node;
@@ -1495,9 +1495,12 @@ int tcl_cmd_status(ClientData unused, Tcl_Interp *interp, int objc, Tcl_Obj *CON
enum { CMD_STATUS_ATTR, CMD_STATUS_TYPE } cmd;
PurpleStatus *status;
PurpleStatusType *status_type;
+ int error;
+#if !(defined PURPLE_DISABLE_DEPRECATED)
PurpleValue *value;
const char *attr;
- int error, v;
+ int v;
+#endif
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "subcommand ?args?");
@@ -1509,6 +1512,7 @@ int tcl_cmd_status(ClientData unused, Tcl_Interp *interp, int objc, Tcl_Obj *CON
switch (cmd) {
case CMD_STATUS_ATTR:
+#if !(defined PURPLE_DISABLE_DEPRECATED)
if (objc != 4 && objc != 5) {
Tcl_WrongNumArgs(interp, 2, objv, "status attr_id ?value?");
return TCL_ERROR;
@@ -1554,6 +1558,7 @@ int tcl_cmd_status(ClientData unused, Tcl_Interp *interp, int objc, Tcl_Obj *CON
Tcl_NewStringObj("attribute has unknown type", -1));
return TCL_ERROR;
}
+#endif
break;
case CMD_STATUS_TYPE:
if (objc != 3) {
@@ -1727,6 +1732,7 @@ int tcl_cmd_status_type(ClientData unused, Tcl_Interp *interp, int objc, Tcl_Obj
(purple_status_type_get_primitive(status_type)), -1));
break;
case CMD_STATUS_TYPE_PRIMARY_ATTR:
+#if !(defined PURPLE_DISABLE_DEPRECATED)
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "statustype");
return TCL_ERROR;
@@ -1735,6 +1741,7 @@ int tcl_cmd_status_type(ClientData unused, Tcl_Interp *interp, int objc, Tcl_Obj
return TCL_ERROR;
Tcl_SetObjResult(interp,
Tcl_NewStringObj(purple_status_type_get_primary_attr(status_type), -1));
+#endif
break;
case CMD_STATUS_TYPE_SAVEABLE:
if (objc != 3) {
diff --git a/libpurple/pounce.c b/libpurple/pounce.c
index 0f6e547..2d668c7 100644
--- a/libpurple/pounce.c
+++ b/libpurple/pounce.c
@@ -326,7 +326,7 @@ start_element_handler(GMarkupParseContext *context,
data->buffer = NULL;
}
- if (!strcmp(element_name, "pounce")) {
+ if (purple_strequal(element_name, "pounce")) {
const char *ui = g_hash_table_lookup(atts, "ui");
if (ui == NULL) {
@@ -338,7 +338,7 @@ start_element_handler(GMarkupParseContext *context,
data->events = 0;
}
- else if (!strcmp(element_name, "account")) {
+ else if (purple_strequal(element_name, "account")) {
const char *protocol_id = g_hash_table_lookup(atts, "protocol");
if (protocol_id == NULL) {
@@ -348,7 +348,7 @@ start_element_handler(GMarkupParseContext *context,
else
data->protocol_id = g_strdup(protocol_id);
}
- else if (!strcmp(element_name, "option")) {
+ else if (purple_strequal(element_name, "option")) {
const char *type = g_hash_table_lookup(atts, "type");
if (type == NULL) {
@@ -358,7 +358,7 @@ start_element_handler(GMarkupParseContext *context,
else
data->option_type = g_strdup(type);
}
- else if (!strcmp(element_name, "event")) {
+ else if (purple_strequal(element_name, "event")) {
const char *type = g_hash_table_lookup(atts, "type");
if (type == NULL) {
@@ -368,7 +368,7 @@ start_element_handler(GMarkupParseContext *context,
else
data->event_type = g_strdup(type);
}
- else if (!strcmp(element_name, "action")) {
+ else if (purple_strequal(element_name, "action")) {
const char *type = g_hash_table_lookup(atts, "type");
if (type == NULL) {
@@ -378,7 +378,7 @@ start_element_handler(GMarkupParseContext *context,
else
data->action_name = g_strdup(type);
}
- else if (!strcmp(element_name, "param")) {
+ else if (purple_strequal(element_name, "param")) {
const char *param_name = g_hash_table_lookup(atts, "name");
if (param_name == NULL) {
@@ -404,7 +404,7 @@ end_element_handler(GMarkupParseContext *context, const gchar *element_name,
data->buffer = NULL;
}
- if (!strcmp(element_name, "account")) {
+ if (purple_strequal(element_name, "account")) {
char *tmp;
g_free(data->account_name);
data->account_name = g_strdup(buffer);
@@ -412,43 +412,43 @@ end_element_handler(GMarkupParseContext *context, const gchar *element_name,
data->protocol_id = g_strdup(_purple_oscar_convert(buffer, tmp));
g_free(tmp);
}
- else if (!strcmp(element_name, "pouncee")) {
+ else if (purple_strequal(element_name, "pouncee")) {
g_free(data->pouncee);
data->pouncee = g_strdup(buffer);
}
- else if (!strcmp(element_name, "option")) {
- if (!strcmp(data->option_type, "on-away"))
+ else if (purple_strequal(element_name, "option")) {
+ if (purple_strequal(data->option_type, "on-away"))
data->options |= PURPLE_POUNCE_OPTION_AWAY;
g_free(data->option_type);
data->option_type = NULL;
}
- else if (!strcmp(element_name, "event")) {
- if (!strcmp(data->event_type, "sign-on"))
+ else if (purple_strequal(element_name, "event")) {
+ if (purple_strequal(data->event_type, "sign-on"))
data->events |= PURPLE_POUNCE_SIGNON;
- else if (!strcmp(data->event_type, "sign-off"))
+ else if (purple_strequal(data->event_type, "sign-off"))
data->events |= PURPLE_POUNCE_SIGNOFF;
- else if (!strcmp(data->event_type, "away"))
+ else if (purple_strequal(data->event_type, "away"))
data->events |= PURPLE_POUNCE_AWAY;
- else if (!strcmp(data->event_type, "return-from-away"))
+ else if (purple_strequal(data->event_type, "return-from-away"))
data->events |= PURPLE_POUNCE_AWAY_RETURN;
- else if (!strcmp(data->event_type, "idle"))
+ else if (purple_strequal(data->event_type, "idle"))
data->events |= PURPLE_POUNCE_IDLE;
- else if (!strcmp(data->event_type, "return-from-idle"))
+ else if (purple_strequal(data->event_type, "return-from-idle"))
data->events |= PURPLE_POUNCE_IDLE_RETURN;
- else if (!strcmp(data->event_type, "start-typing"))
+ else if (purple_strequal(data->event_type, "start-typing"))
data->events |= PURPLE_POUNCE_TYPING;
- else if (!strcmp(data->event_type, "typed"))
+ else if (purple_strequal(data->event_type, "typed"))
data->events |= PURPLE_POUNCE_TYPED;
- else if (!strcmp(data->event_type, "stop-typing"))
+ else if (purple_strequal(data->event_type, "stop-typing"))
data->events |= PURPLE_POUNCE_TYPING_STOPPED;
- else if (!strcmp(data->event_type, "message-received"))
+ else if (purple_strequal(data->event_type, "message-received"))
data->events |= PURPLE_POUNCE_MESSAGE_RECEIVED;
g_free(data->event_type);
data->event_type = NULL;
}
- else if (!strcmp(element_name, "action")) {
+ else if (purple_strequal(element_name, "action")) {
if (data->pounce != NULL) {
purple_pounce_action_register(data->pounce, data->action_name);
purple_pounce_action_set_enabled(data->pounce, data->action_name, TRUE);
@@ -457,7 +457,7 @@ end_element_handler(GMarkupParseContext *context, const gchar *element_name,
g_free(data->action_name);
data->action_name = NULL;
}
- else if (!strcmp(element_name, "param")) {
+ else if (purple_strequal(element_name, "param")) {
if (data->pounce != NULL) {
purple_pounce_action_set_attribute(data->pounce, data->action_name,
data->param_name, buffer);
@@ -466,7 +466,7 @@ end_element_handler(GMarkupParseContext *context, const gchar *element_name,
g_free(data->param_name);
data->param_name = NULL;
}
- else if (!strcmp(element_name, "events")) {
+ else if (purple_strequal(element_name, "events")) {
PurpleAccount *account;
account = purple_accounts_find(data->account_name, data->protocol_id);
@@ -499,11 +499,11 @@ end_element_handler(GMarkupParseContext *context, const gchar *element_name,
g_free(data->pouncee);
data->pouncee = NULL;
}
- else if (!strcmp(element_name, "save")) {
+ else if (purple_strequal(element_name, "save")) {
if (data->pounce != NULL)
purple_pounce_set_save(data->pounce, TRUE);
}
- else if (!strcmp(element_name, "pounce")) {
+ else if (purple_strequal(element_name, "pounce")) {
data->pounce = NULL;
data->events = 0;
data->options = 0;
@@ -1023,7 +1023,7 @@ GList *purple_pounces_get_all_for_ui(const char *ui)
for (iter = pounces; iter; iter = iter->next) {
PurplePounce *pounce = iter->data;
- if (pounce->ui_type && strcmp(pounce->ui_type, ui) == 0)
+ if (purple_strequal(pounce->ui_type, ui))
list = g_list_prepend(list, pounce);
}
list = g_list_reverse(list);
@@ -1042,35 +1042,39 @@ free_pounce_handler(gpointer user_data)
static void
buddy_state_cb(PurpleBuddy *buddy, PurplePounceEvent event)
{
- purple_pounce_execute(buddy->account, buddy->name, event);
+ PurpleAccount *account = purple_buddy_get_account(buddy);
+ const gchar *name = purple_buddy_get_name(buddy);
+
+ purple_pounce_execute(account, name, event);
}
static void
buddy_status_changed_cb(PurpleBuddy *buddy, PurpleStatus *old_status,
PurpleStatus *status)
{
+ PurpleAccount *account = purple_buddy_get_account(buddy);
+ const gchar *name = purple_buddy_get_name(buddy);
gboolean old_available, available;
available = purple_status_is_available(status);
old_available = purple_status_is_available(old_status);
if (available && !old_available)
- purple_pounce_execute(buddy->account, buddy->name,
- PURPLE_POUNCE_AWAY_RETURN);
+ purple_pounce_execute(account, name, PURPLE_POUNCE_AWAY_RETURN);
else if (!available && old_available)
- purple_pounce_execute(buddy->account, buddy->name,
- PURPLE_POUNCE_AWAY);
+ purple_pounce_execute(account, name, PURPLE_POUNCE_AWAY);
}
static void
buddy_idle_changed_cb(PurpleBuddy *buddy, gboolean old_idle, gboolean idle)
{
+ PurpleAccount *account = purple_buddy_get_account(buddy);
+ const gchar *name = purple_buddy_get_name(buddy);
+
if (idle && !old_idle)
- purple_pounce_execute(buddy->account, buddy->name,
- PURPLE_POUNCE_IDLE);
+ purple_pounce_execute(account, name, PURPLE_POUNCE_IDLE);
else if (!idle && old_idle)
- purple_pounce_execute(buddy->account, buddy->name,
- PURPLE_POUNCE_IDLE_RETURN);
+ purple_pounce_execute(account, name, PURPLE_POUNCE_IDLE_RETURN);
}
static void
diff --git a/libpurple/prefs.c b/libpurple/prefs.c
index b95d2be..162045c 100644
--- a/libpurple/prefs.c
+++ b/libpurple/prefs.c
@@ -250,33 +250,34 @@ prefs_start_element_handler (GMarkupParseContext *context,
GString *pref_name_full;
GList *tmp;
- if(strcmp(element_name, "pref") && strcmp(element_name, "item"))
+ if(!purple_strequal(element_name, "pref") &&
+ !purple_strequal(element_name, "item"))
return;
for(i = 0; attribute_names[i]; i++) {
- if(!strcmp(attribute_names[i], "name")) {
+ if(purple_strequal(attribute_names[i], "name")) {
pref_name = attribute_values[i];
- } else if(!strcmp(attribute_names[i], "type")) {
- if(!strcmp(attribute_values[i], "bool"))
+ } else if(purple_strequal(attribute_names[i], "type")) {
+ if(purple_strequal(attribute_values[i], "bool"))
pref_type = PURPLE_PREF_BOOLEAN;
- else if(!strcmp(attribute_values[i], "int"))
+ else if(purple_strequal(attribute_values[i], "int"))
pref_type = PURPLE_PREF_INT;
- else if(!strcmp(attribute_values[i], "string"))
+ else if(purple_strequal(attribute_values[i], "string"))
pref_type = PURPLE_PREF_STRING;
- else if(!strcmp(attribute_values[i], "stringlist"))
+ else if(purple_strequal(attribute_values[i], "stringlist"))
pref_type = PURPLE_PREF_STRING_LIST;
- else if(!strcmp(attribute_values[i], "path"))
+ else if(purple_strequal(attribute_values[i], "path"))
pref_type = PURPLE_PREF_PATH;
- else if(!strcmp(attribute_values[i], "pathlist"))
+ else if(purple_strequal(attribute_values[i], "pathlist"))
pref_type = PURPLE_PREF_PATH_LIST;
else
return;
- } else if(!strcmp(attribute_names[i], "value")) {
+ } else if(purple_strequal(attribute_names[i], "value")) {
pref_value = attribute_values[i];
}
}
- if(!strcmp(element_name, "item")) {
+ if(purple_strequal(element_name, "item")) {
struct purple_pref *pref;
pref_name_full = g_string_new("");
@@ -301,7 +302,7 @@ prefs_start_element_handler (GMarkupParseContext *context,
} else {
char *decoded;
- if(!pref_name || !strcmp(pref_name, "/"))
+ if(!pref_name || purple_strequal(pref_name, "/"))
return;
pref_name_full = g_string_new(pref_name);
@@ -352,7 +353,7 @@ prefs_end_element_handler(GMarkupParseContext *context,
const gchar *element_name,
gpointer user_data, GError **error)
{
- if(prefs_stack && !strcmp(element_name, "pref")) {
+ if(prefs_stack && purple_strequal(element_name, "pref")) {
g_free(prefs_stack->data);
prefs_stack = g_list_delete_link(prefs_stack, prefs_stack);
}
@@ -521,7 +522,7 @@ find_pref_parent(const char *name)
char *parent_name = get_path_dirname(name);
struct purple_pref *ret = &prefs;
- if(strcmp(parent_name, "/")) {
+ if(!purple_strequal(parent_name, "/")) {
ret = find_pref(parent_name);
}
@@ -571,7 +572,7 @@ add_pref(PurplePrefType type, const char *name)
my_name = get_path_basename(name);
for(sibling = parent->first_child; sibling; sibling = sibling->sibling) {
- if(!strcmp(sibling->name, my_name)) {
+ if(purple_strequal(sibling->name, my_name)) {
g_free(my_name);
return NULL;
}
@@ -849,10 +850,7 @@ purple_prefs_set_string(const char *name, const char *value)
return;
}
- if((value && !pref->value.string) ||
- (!value && pref->value.string) ||
- (value && pref->value.string &&
- strcmp(pref->value.string, value))) {
+ if (!purple_strequal(pref->value.string, value)) {
g_free(pref->value.string);
pref->value.string = g_strdup(value);
do_callbacks(name, pref);
@@ -909,10 +907,7 @@ purple_prefs_set_path(const char *name, const char *value)
return;
}
- if((value && !pref->value.string) ||
- (!value && pref->value.string) ||
- (value && pref->value.string &&
- strcmp(pref->value.string, value))) {
+ if (!purple_strequal(pref->value.string, value)) {
g_free(pref->value.string);
pref->value.string = g_strdup(value);
do_callbacks(name, pref);
@@ -1106,7 +1101,7 @@ purple_prefs_rename_node(struct purple_pref *oldpref, struct purple_pref *newpre
next = child->sibling;
for(newchild = newpref->first_child; newchild != NULL; newchild = newchild->sibling)
{
- if(!strcmp(child->name, newchild->name))
+ if(purple_strequal(child->name, newchild->name))
{
purple_prefs_rename_node(child, newchild);
break;
diff --git a/libpurple/prefs.h b/libpurple/prefs.h
index aafa0cd..3129719 100644
--- a/libpurple/prefs.h
+++ b/libpurple/prefs.h
@@ -67,8 +67,8 @@ extern "C" {
#endif
/**************************************************************************/
-/** @name Prefs API
- Preferences are named according to a directory-like structure.
+/** @name Prefs API
+ Preferences are named according to a directory-like structure.
Example: "/plugins/core/potato/is_from_idaho" (probably a boolean) */
/**************************************************************************/
/*@{*/
diff --git a/libpurple/privacy.c b/libpurple/privacy.c
index 78accc4..bbb5e01 100644
--- a/libpurple/privacy.c
+++ b/libpurple/privacy.c
@@ -232,8 +232,10 @@ add_all_buddies_to_permit_list(PurpleAccount *account, gboolean local)
while (list != NULL)
{
PurpleBuddy *buddy = list->data;
- if (!g_slist_find_custom(account->permit, buddy->name, (GCompareFunc)g_utf8_collate))
- purple_privacy_permit_add(account, buddy->name, local);
+ const gchar *name = purple_buddy_get_name(buddy);
+
+ if (!g_slist_find_custom(account->permit, name, (GCompareFunc)g_utf8_collate))
+ purple_privacy_permit_add(account, name, local);
list = g_slist_delete_link(list, list);
}
}
@@ -267,7 +269,7 @@ purple_privacy_allow(PurpleAccount *account, const char *who, gboolean local,
for (list = account->permit; list != NULL;) {
char *person = list->data;
list = list->next;
- if (strcmp(norm, person) != 0)
+ if (!purple_strequal(norm, person))
purple_privacy_permit_remove(account, person, local);
}
}
@@ -311,7 +313,7 @@ purple_privacy_deny(PurpleAccount *account, const char *who, gboolean local,
for (list = account->deny; list != NULL; ) {
char *person = list->data;
list = list->next;
- if (strcmp(norm, person) != 0)
+ if (!purple_strequal(norm, person))
purple_privacy_deny_remove(account, person, local);
}
}
diff --git a/libpurple/privacy.h b/libpurple/privacy.h
index 7caeb45..2911758 100644
--- a/libpurple/privacy.h
+++ b/libpurple/privacy.h
@@ -125,7 +125,7 @@ gboolean purple_privacy_deny_remove(PurpleAccount *account, const char *name,
* changed to PURPLE_PRIVACY_ALLOW_USERS, all the
* buddies are added to the allow-list, and the
* user is also added to the allow-list.
- *
+ *
* @param account The account.
* @param who The name of the user.
* @param local Whether the change is local-only.
diff --git a/libpurple/protocols/Makefile.mingw b/libpurple/protocols/Makefile.mingw
index 602758f..5cda7fe 100644
--- a/libpurple/protocols/Makefile.mingw
+++ b/libpurple/protocols/Makefile.mingw
@@ -2,7 +2,7 @@
#
# Author: hermanator12002@yahoo.com
# Date 9/11/02
-# Description: Protocols Makefile for win32 (mingw) port of LibPurple
+# Description: Protocols Makefile for win32 (mingw) port of libpurple
#
PIDGIN_TREE_TOP := ../..
diff --git a/libpurple/protocols/bonjour/bonjour.c b/libpurple/protocols/bonjour/bonjour.c
index 8456ffb..f053940 100644
--- a/libpurple/protocols/bonjour/bonjour.c
+++ b/libpurple/protocols/bonjour/bonjour.c
@@ -261,9 +261,10 @@ bonjour_fake_add_buddy(PurpleConnection *pc, PurpleBuddy *buddy, PurpleGroup *gr
static void bonjour_remove_buddy(PurpleConnection *pc, PurpleBuddy *buddy, PurpleGroup *group) {
- if (buddy->proto_data) {
- bonjour_buddy_delete(buddy->proto_data);
- buddy->proto_data = NULL;
+ BonjourBuddy *bb = purple_buddy_get_protocol_data(buddy);
+ if (bb) {
+ bonjour_buddy_delete(bb);
+ purple_buddy_set_protocol_data(buddy, NULL);
}
}
@@ -303,7 +304,7 @@ bonjour_convo_closed(PurpleConnection *connection, const char *who)
PurpleBuddy *buddy = purple_find_buddy(connection->account, who);
BonjourBuddy *bb;
- if (buddy == NULL || buddy->proto_data == NULL)
+ if (buddy == NULL || (bb = purple_buddy_get_protocol_data(buddy)) == NULL)
{
/*
* This buddy is not in our buddy list, and therefore does not really
@@ -312,7 +313,6 @@ bonjour_convo_closed(PurpleConnection *connection, const char *who)
return;
}
- bb = buddy->proto_data;
bonjour_jabber_close_conversation(bb->conversation);
bb->conversation = NULL;
}
@@ -351,7 +351,7 @@ bonjour_tooltip_text(PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, gboole
{
PurplePresence *presence;
PurpleStatus *status;
- BonjourBuddy *bb = buddy->proto_data;
+ BonjourBuddy *bb = purple_buddy_get_protocol_data(buddy);
const char *status_description;
const char *message;
@@ -417,8 +417,7 @@ bonjour_can_receive_file(PurpleConnection *connection, const char *who)
{
PurpleBuddy *buddy = purple_find_buddy(connection->account, who);
- return (buddy != NULL && buddy->proto_data != NULL);
-
+ return (buddy != NULL && purple_buddy_get_protocol_data(buddy) != NULL);
}
static gboolean
diff --git a/libpurple/protocols/bonjour/bonjour_ft.c b/libpurple/protocols/bonjour/bonjour_ft.c
index effc931..93b9f1f 100644
--- a/libpurple/protocols/bonjour/bonjour_ft.c
+++ b/libpurple/protocols/bonjour/bonjour_ft.c
@@ -386,10 +386,9 @@ bonjour_xfer_init(PurpleXfer *xfer)
buddy = purple_find_buddy(xfer->account, xfer->who);
/* this buddy is offline. */
- if (buddy == NULL || buddy->proto_data == NULL)
+ if (buddy == NULL || (bb = purple_buddy_get_protocol_data(buddy)) == NULL)
return;
- bb = (BonjourBuddy *)buddy->proto_data;
/* Assume it is the first IP. We could do something like keep track of which one is in use or something. */
if (bb->ips)
xf->buddy_ip = g_strdup(bb->ips->data);
@@ -410,6 +409,7 @@ xep_si_parse(PurpleConnection *pc, xmlnode *packet, PurpleBuddy *pb)
const char *type, *id;
BonjourData *bd;
PurpleXfer *xfer;
+ const gchar *name = NULL;
g_return_if_fail(pc != NULL);
g_return_if_fail(packet != NULL);
@@ -421,6 +421,8 @@ xep_si_parse(PurpleConnection *pc, xmlnode *packet, PurpleBuddy *pb)
purple_debug_info("bonjour", "xep-si-parse.\n");
+ name = purple_buddy_get_name(pb);
+
type = xmlnode_get_attrib(packet, "type");
id = xmlnode_get_attrib(packet, "id");
if(type) {
@@ -448,31 +450,34 @@ xep_si_parse(PurpleConnection *pc, xmlnode *packet, PurpleBuddy *pb)
/* TODO: Make sure that it is advertising a bytestreams transfer */
- bonjour_xfer_receive(pc, id, sid, pb->name, filesize, filename, XEP_BYTESTREAMS);
+ bonjour_xfer_receive(pc, id, sid, name, filesize, filename, XEP_BYTESTREAMS);
parsed_receive = TRUE;
}
if (!parsed_receive) {
+ BonjourData *bd = purple_connection_get_protocol_data(pc);
+
purple_debug_info("bonjour", "rejecting unrecognized si SET offer.\n");
- xep_ft_si_reject((BonjourData *)pc->proto_data, id, pb->name, "403", "cancel");
+ xep_ft_si_reject(bd, id, name, "403", "cancel");
/*TODO: Send Cancel (501) */
}
} else if(!strcmp(type, "result")) {
purple_debug_info("bonjour", "si offer Message type - RESULT.\n");
- xfer = bonjour_si_xfer_find(bd, id, pb->name);
+ xfer = bonjour_si_xfer_find(bd, id, name);
if(xfer == NULL) {
+ BonjourData *bd = purple_connection_get_protocol_data(pc);
purple_debug_info("bonjour", "xfer find fail.\n");
- xep_ft_si_reject((BonjourData *)pc->proto_data, id, pb->name, "403", "cancel");
+ xep_ft_si_reject(bd, id, name, "403", "cancel");
} else
bonjour_bytestreams_init(xfer);
} else if(!strcmp(type, "error")) {
purple_debug_info("bonjour", "si offer Message type - ERROR.\n");
- xfer = bonjour_si_xfer_find(bd, id, pb->name);
+ xfer = bonjour_si_xfer_find(bd, id, name);
if(xfer == NULL)
purple_debug_info("bonjour", "xfer find fail.\n");
@@ -501,7 +506,7 @@ xep_bytestreams_parse(PurpleConnection *pc, xmlnode *packet, PurpleBuddy *pb)
purple_debug_info("bonjour", "xep-bytestreams-parse.\n");
type = xmlnode_get_attrib(packet, "type");
- from = pb->name;
+ from = purple_buddy_get_name(pb);
query = xmlnode_get_child(packet,"query");
if(type) {
if(!strcmp(type, "set")) {
@@ -841,8 +846,10 @@ bonjour_bytestreams_connect_cb(gpointer data, gint source, const gchar *error_me
static void
bonjour_bytestreams_connect(PurpleXfer *xfer, PurpleBuddy *pb)
{
+ PurpleAccount *account = NULL;
XepXfer *xf;
char dstaddr[41];
+ const gchar *name = NULL;
unsigned char hashval[20];
char *p;
int i;
@@ -856,7 +863,10 @@ bonjour_bytestreams_connect(PurpleXfer *xfer, PurpleBuddy *pb)
if(!xf)
return;
- p = g_strdup_printf("%s%s%s", xf->sid, pb->name, purple_account_get_username(pb->account));
+ name = purple_buddy_get_name(pb);
+ account = purple_buddy_get_account(pb);
+
+ p = g_strdup_printf("%s%s%s", xf->sid, name, purple_account_get_username(account));
purple_cipher_digest_region("sha1", (guchar *)p, strlen(p),
sizeof(hashval), hashval, NULL);
g_free(p);
diff --git a/libpurple/protocols/bonjour/buddy.c b/libpurple/protocols/bonjour/buddy.c
index edc40fa..890a7e1 100644
--- a/libpurple/protocols/bonjour/buddy.c
+++ b/libpurple/protocols/bonjour/buddy.c
@@ -157,8 +157,8 @@ bonjour_buddy_add_to_purple(BonjourBuddy *bonjour_buddy, PurpleBuddy *buddy)
purple_blist_add_buddy(buddy, NULL, group, NULL);
}
- buddy->proto_data = bonjour_buddy;
name = purple_buddy_get_name(buddy);
+ purple_buddy_set_protocol_data(buddy, bonjour_buddy);
/* Create the alias for the buddy using the first and the last name */
if (bonjour_buddy->nick && *bonjour_buddy->nick)
@@ -210,8 +210,8 @@ void bonjour_buddy_signed_off(PurpleBuddy *pb) {
if (PURPLE_BLIST_NODE_SHOULD_SAVE(pb)) {
purple_prpl_got_user_status(purple_buddy_get_account(pb),
purple_buddy_get_name(pb), "offline", NULL);
- bonjour_buddy_delete(pb->proto_data);
- pb->proto_data = NULL;
+ bonjour_buddy_delete(purple_buddy_get_protocol_data(pb));
+ purple_buddy_set_protocol_data(pb, NULL);
} else {
purple_account_remove_buddy(purple_buddy_get_account(pb), pb, NULL);
purple_blist_remove_buddy(pb);
diff --git a/libpurple/protocols/bonjour/jabber.c b/libpurple/protocols/bonjour/jabber.c
index 51a809c..3ee7dd5 100644
--- a/libpurple/protocols/bonjour/jabber.c
+++ b/libpurple/protocols/bonjour/jabber.c
@@ -240,17 +240,21 @@ static void
_match_buddies_by_address(gpointer key, gpointer value, gpointer data)
{
PurpleBuddy *pb = value;
+ PurpleAccount *account = NULL;
+ BonjourBuddy *bb = NULL;
struct _match_buddies_by_address_t *mbba = data;
+ account = purple_buddy_get_account(pb);
+ bb = purple_buddy_get_protocol_data(pb);
+
/*
* If the current PurpleBuddy's data is not null and the PurpleBuddy's account
* is the same as the account requesting the check then continue to determine
* whether one of the buddies IPs matches the target IP.
*/
- if (mbba->jdata->account == pb->account && pb->proto_data != NULL)
+ if (mbba->jdata->account == account && bb != NULL)
{
const char *ip;
- BonjourBuddy *bb = pb->proto_data;
GSList *tmp = bb->ips;
while(tmp) {
@@ -268,7 +272,7 @@ static void
_send_data_write_cb(gpointer data, gint source, PurpleInputCondition cond)
{
PurpleBuddy *pb = data;
- BonjourBuddy *bb = pb->proto_data;
+ BonjourBuddy *bb = purple_buddy_get_protocol_data(pb);
BonjourJabberConversation *bconv = bb->conversation;
int ret, writelen;
@@ -285,13 +289,16 @@ _send_data_write_cb(gpointer data, gint source, PurpleInputCondition cond)
if (ret < 0 && errno == EAGAIN)
return;
else if (ret <= 0) {
- PurpleConversation *conv;
+ PurpleConversation *conv = NULL;
+ PurpleAccount *account = NULL;
const char *error = g_strerror(errno);
purple_debug_error("bonjour", "Error sending message to buddy %s error: %s\n",
purple_buddy_get_name(pb), error ? error : "(null)");
- conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bb->name, pb->account);
+ account = purple_buddy_get_account(pb);
+
+ conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bb->name, account);
if (conv != NULL)
purple_conversation_write(conv, NULL,
_("Unable to send message."),
@@ -310,7 +317,7 @@ _send_data(PurpleBuddy *pb, char *message)
{
gint ret;
int len = strlen(message);
- BonjourBuddy *bb = pb->proto_data;
+ BonjourBuddy *bb = purple_buddy_get_protocol_data(pb);
BonjourJabberConversation *bconv = bb->conversation;
/* If we're not ready to actually send, append it to the buffer */
@@ -329,12 +336,15 @@ _send_data(PurpleBuddy *pb, char *message)
ret = 0;
else if (ret <= 0) {
PurpleConversation *conv;
+ PurpleAccount *account;
const char *error = g_strerror(errno);
purple_debug_error("bonjour", "Error sending message to buddy %s error: %s\n",
purple_buddy_get_name(pb), error ? error : "(null)");
- conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bb->name, pb->account);
+ account = purple_buddy_get_account(pb);
+
+ conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bb->name, account);
if (conv != NULL)
purple_conversation_write(conv, NULL,
_("Unable to send message."),
@@ -373,11 +383,12 @@ static void bonjour_jabber_stream_ended(BonjourJabberConversation *bconv) {
/* Inform the user that the conversation has been closed */
BonjourBuddy *bb = NULL;
+ const gchar *name = bconv->pb ? purple_buddy_get_name(bconv->pb) : "(unknown)";
- purple_debug_info("bonjour", "Recieved conversation close notification from %s.\n", bconv->pb ? bconv->pb->name : "(unknown)");
+ purple_debug_info("bonjour", "Recieved conversation close notification from %s.\n", name);
if(bconv->pb != NULL)
- bb = bconv->pb->proto_data;
+ bb = purple_buddy_get_protocol_data(bconv->pb);
#if 0
if(bconv->pb != NULL) {
PurpleConversation *conv;
@@ -411,9 +422,11 @@ _client_socket_handler(gpointer data, gint socket, PurpleInputCondition conditio
purple_debug_warning("bonjour", "receive error: %s\n", err ? err : "(null)");
bonjour_jabber_close_conversation(bconv);
- if (bconv->pb != NULL && bconv->pb->proto_data != NULL) {
- BonjourBuddy *bb = bconv->pb->proto_data;
- bb->conversation = NULL;
+ if (bconv->pb != NULL) {
+ BonjourBuddy *bb = purple_buddy_get_protocol_data(bconv->pb);
+
+ if(bb != NULL)
+ bb->conversation = NULL;
}
/* I guess we really don't need to notify the user.
@@ -421,7 +434,8 @@ _client_socket_handler(gpointer data, gint socket, PurpleInputCondition conditio
}
return;
} else if (len == 0) { /* The other end has closed the socket */
- purple_debug_warning("bonjour", "Connection closed (without stream end) by %s.\n", (bconv->pb && bconv->pb->name) ? bconv->pb->name : "(unknown)");
+ const gchar *name = purple_buddy_get_name(bconv->pb);
+ purple_debug_warning("bonjour", "Connection closed (without stream end) by %s.\n", (name) ? name : "(unknown)");
bonjour_jabber_stream_ended(bconv);
return;
} else {
@@ -465,7 +479,7 @@ _start_stream(gpointer data, gint source, PurpleInputCondition condition)
BonjourBuddy *bb = NULL;
if(bconv->pb) {
- bb = bconv->pb->proto_data;
+ bb = purple_buddy_get_protocol_data(bconv->pb);
bname = purple_buddy_get_name(bconv->pb);
}
@@ -644,7 +658,7 @@ _server_socket_handler(gpointer data, int server_socket, PurpleInputCondition co
mbba = g_new0(struct _match_buddies_by_address_t, 1);
mbba->address = address_text;
mbba->jdata = jdata;
- g_hash_table_foreach(purple_get_blist()->buddies, _match_buddies_by_address, mbba);
+ g_hash_table_foreach(purple_blist_get_buddies(), _match_buddies_by_address, mbba);
if (mbba->matched_buddies == NULL) {
purple_debug_info("bonjour", "We don't like invisible buddies, this is not a superheros comic\n");
@@ -729,17 +743,20 @@ static void
_connected_to_buddy(gpointer data, gint source, const gchar *error)
{
PurpleBuddy *pb = data;
- BonjourBuddy *bb = pb->proto_data;
+ BonjourBuddy *bb = purple_buddy_get_protocol_data(pb);
bb->conversation->connect_data = NULL;
if (source < 0) {
- PurpleConversation *conv;
+ PurpleConversation *conv = NULL;
+ PurpleAccount *account = NULL;
purple_debug_error("bonjour", "Error connecting to buddy %s at %s:%d error: %s\n",
purple_buddy_get_name(pb), bb->conversation->ip, bb->port_p2pj, error ? error : "(null)");
- conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bb->name, pb->account);
+ account = purple_buddy_get_account(pb);
+
+ conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bb->name, account);
if (conv != NULL)
purple_conversation_write(conv, NULL,
_("Unable to send the message, the conversation couldn't be started."),
@@ -752,12 +769,15 @@ _connected_to_buddy(gpointer data, gint source, const gchar *error)
if (!bonjour_jabber_send_stream_init(bb->conversation, source)) {
const char *err = g_strerror(errno);
- PurpleConversation *conv;
+ PurpleConversation *conv = NULL;
+ PurpleAccount *account = NULL;
purple_debug_error("bonjour", "Error starting stream with buddy %s at %s:%d error: %s\n",
purple_buddy_get_name(pb), bb->conversation->ip, bb->port_p2pj, err ? err : "(null)");
- conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bb->name, pb->account);
+ account = purple_buddy_get_account(pb);
+
+ conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bb->name, account);
if (conv != NULL)
purple_conversation_write(conv, NULL,
_("Unable to send the message, the conversation couldn't be started."),
@@ -777,14 +797,14 @@ _connected_to_buddy(gpointer data, gint source, const gchar *error)
void
bonjour_jabber_conv_match_by_name(BonjourJabberConversation *bconv) {
- PurpleBuddy *pb;
+ PurpleBuddy *pb = NULL;
+ BonjourBuddy *bb = NULL;
g_return_if_fail(bconv->ip != NULL);
g_return_if_fail(bconv->pb == NULL);
pb = purple_find_buddy(bconv->account, bconv->buddy_name);
- if (pb && pb->proto_data) {
- BonjourBuddy *bb = pb->proto_data;
+ if (pb && (bb = purple_buddy_get_protocol_data(pb))) {
const char *ip;
GSList *tmp = bb->ips;
@@ -834,7 +854,7 @@ bonjour_jabber_conv_match_by_ip(BonjourJabberConversation *bconv) {
mbba = g_new0(struct _match_buddies_by_address_t, 1);
mbba->address = bconv->ip;
mbba->jdata = jdata;
- g_hash_table_foreach(purple_get_blist()->buddies, _match_buddies_by_address, mbba);
+ g_hash_table_foreach(purple_blist_get_buddies(), _match_buddies_by_address, mbba);
/* If there is exactly one match, use it */
if(mbba->matched_buddies != NULL) {
@@ -842,7 +862,7 @@ bonjour_jabber_conv_match_by_ip(BonjourJabberConversation *bconv) {
purple_debug_error("bonjour", "More than one buddy matched for ip %s.\n", bconv->ip);
else {
PurpleBuddy *pb = mbba->matched_buddies->data;
- BonjourBuddy *bb = pb->proto_data;
+ BonjourBuddy *bb = purple_buddy_get_protocol_data(pb);
purple_debug_info("bonjour", "Matched buddy %s to incoming conversation using IP (%s)\n",
purple_buddy_get_name(pb), bconv->ip);
@@ -882,12 +902,10 @@ _find_or_start_conversation(BonjourJabber *jdata, const gchar *to)
g_return_val_if_fail(to != NULL, NULL);
pb = purple_find_buddy(jdata->account, to);
- if (pb == NULL || pb->proto_data == NULL)
+ if (pb == NULL || (bb = purple_buddy_get_protocol_data(pb)) == NULL)
/* You can not send a message to an offline buddy */
return NULL;
- bb = (BonjourBuddy *) pb->proto_data;
-
/* Check if there is a previously open conversation */
if (bb->conversation == NULL)
{
@@ -934,7 +952,7 @@ bonjour_jabber_send_message(BonjourJabber *jdata, const gchar *to, const gchar *
int ret;
pb = _find_or_start_conversation(jdata, to);
- if (pb == NULL || pb->proto_data == NULL) {
+ if (pb == NULL || (bb = purple_buddy_get_protocol_data(pb)) == NULL) {
purple_debug_info("bonjour", "Can't send a message to an offline buddy (%s).\n", to);
/* You can not send a message to an offline buddy */
return -10000;
@@ -942,8 +960,6 @@ bonjour_jabber_send_message(BonjourJabber *jdata, const gchar *to, const gchar *
purple_markup_html_to_xhtml(body, &xhtml, &message);
- bb = pb->proto_data;
-
message_node = xmlnode_new("message");
xmlnode_set_attrib(message_node, "to", bb->name);
xmlnode_set_attrib(message_node, "from", purple_account_get_username(jdata->account));
@@ -993,7 +1009,7 @@ async_bonjour_jabber_close_conversation(BonjourJabberConversation *bconv) {
/* Disconnect this conv. from the buddy here so it can't be disposed of twice.*/
if(bconv->pb != NULL) {
- BonjourBuddy *bb = bconv->pb->proto_data;
+ BonjourBuddy *bb = purple_buddy_get_protocol_data(bconv->pb);
if (bb->conversation == bconv)
bb->conversation = NULL;
}
@@ -1022,7 +1038,7 @@ bonjour_jabber_close_conversation(BonjourJabberConversation *bconv)
tmp_next = xfers->next;
/* We only need to cancel this if it hasn't actually started transferring. */
/* This will change if we ever support IBB transfers. */
- if (strcmp(xfer->who, bconv->pb->name) == 0
+ if (strcmp(xfer->who, purple_buddy_get_name(bconv->pb)) == 0
&& (purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_NOT_STARTED
|| purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_UNKNOWN)) {
purple_xfer_cancel_remote(xfer);
@@ -1081,7 +1097,7 @@ bonjour_jabber_stop(BonjourJabber *jdata)
buddies = purple_find_buddies(jdata->account, NULL);
for (l = buddies; l; l = l->next) {
- BonjourBuddy *bb = ((PurpleBuddy*) l->data)->proto_data;
+ BonjourBuddy *bb = purple_buddy_get_protocol_data((PurpleBuddy*) l->data);
if (bb != NULL) {
bonjour_jabber_close_conversation(bb->conversation);
bb->conversation = NULL;
@@ -1144,15 +1160,20 @@ static gboolean
check_if_blocked(PurpleBuddy *pb)
{
gboolean blocked = FALSE;
- GSList *l;
+ GSList *l = NULL;
PurpleAccount *acc = purple_buddy_get_account(pb);
if(acc == NULL)
return FALSE;
+ acc = purple_buddy_get_account(pb);
+
for(l = acc->deny; l != NULL; l = l->next) {
- if(!purple_utf8_strcasecmp(pb->name, (char *)l->data)) {
- purple_debug_info("bonjour", "%s has been blocked by %s.\n", pb->name, acc->username);
+ const gchar *name = purple_buddy_get_name(pb);
+ const gchar *username = purple_account_get_username(acc);
+
+ if(!purple_utf8_strcasecmp(name, (char *)l->data)) {
+ purple_debug_info("bonjour", "%s has been blocked by %s.\n", name, username);
blocked = TRUE;
break;
}
@@ -1164,16 +1185,19 @@ static void
xep_iq_parse(xmlnode *packet, PurpleBuddy *pb)
{
xmlnode *child;
+ PurpleAccount *account;
+ PurpleConnection *gc;
if(check_if_blocked(pb))
return;
+ account = purple_buddy_get_account(pb);
+ gc = purple_account_get_connection(account);
+
if ((child = xmlnode_get_child(packet, "si")) || (child = xmlnode_get_child(packet, "error")))
- xep_si_parse(purple_account_get_connection(pb->account),
- packet, pb);
+ xep_si_parse(gc, packet, pb);
else
- xep_bytestreams_parse(purple_account_get_connection(pb->account),
- packet, pb);
+ xep_bytestreams_parse(gc, packet, pb);
}
int
diff --git a/libpurple/protocols/bonjour/mdns_avahi.c b/libpurple/protocols/bonjour/mdns_avahi.c
index 724bac5..69e65b5 100644
--- a/libpurple/protocols/bonjour/mdns_avahi.c
+++ b/libpurple/protocols/bonjour/mdns_avahi.c
@@ -124,7 +124,7 @@ _resolver_callback(AvahiServiceResolver *r, AvahiIfIndex interface, AvahiProtoco
g_return_if_fail(r != NULL);
pb = purple_find_buddy(account, name);
- bb = (pb != NULL) ? pb->proto_data : NULL;
+ bb = (pb != NULL) ? purple_buddy_get_protocol_data(pb) : NULL;
switch (event) {
case AVAHI_RESOLVER_FAILURE:
@@ -252,7 +252,7 @@ _browser_callback(AvahiServiceBrowser *b, AvahiIfIndex interface,
purple_debug_info("bonjour", "_browser_callback - Remove service\n");
pb = purple_find_buddy(account, name);
if (pb != NULL) {
- BonjourBuddy *bb = pb->proto_data;
+ BonjourBuddy *bb = purple_buddy_get_protocol_data(pb);
AvahiBuddyImplData *b_impl;
GSList *l;
AvahiSvcResolverData *rd_search;
diff --git a/libpurple/protocols/gg/buddylist.c b/libpurple/protocols/gg/buddylist.c
index 13cf4ba..6e2752e 100644
--- a/libpurple/protocols/gg/buddylist.c
+++ b/libpurple/protocols/gg/buddylist.c
@@ -41,37 +41,46 @@ void ggp_buddylist_send(PurpleConnection *gc)
GGPInfo *info = gc->proto_data;
PurpleAccount *account = purple_connection_get_account(gc);
- PurpleBuddyList *blist;
PurpleBlistNode *gnode, *cnode, *bnode;
PurpleBuddy *buddy;
uin_t *userlist = NULL;
gchar *types = NULL;
int size = 0, ret = 0;
- if ((blist = purple_get_blist()) == NULL)
- return;
-
- for (gnode = blist->root; gnode != NULL; gnode = gnode->next) {
+ for (gnode = purple_blist_get_root();
+ gnode != NULL;
+ gnode = purple_blist_node_get_sibling_next(gnode))
+ {
if (!PURPLE_BLIST_NODE_IS_GROUP(gnode))
continue;
- for (cnode = gnode->child; cnode != NULL; cnode = cnode->next) {
+ for (cnode = purple_blist_node_get_first_child(gnode);
+ cnode != NULL;
+ cnode = purple_blist_node_get_sibling_next(cnode))
+ {
if (!PURPLE_BLIST_NODE_IS_CONTACT(cnode))
continue;
- for (bnode = cnode->child; bnode != NULL; bnode = bnode->next) {
+ for (bnode = purple_blist_node_get_first_child(cnode);
+ bnode != NULL;
+ bnode = purple_blist_node_get_sibling_next(bnode))
+ {
+ const gchar *name = NULL;
+
if (!PURPLE_BLIST_NODE_IS_BUDDY(bnode))
continue;
buddy = (PurpleBuddy *)bnode;
- if (buddy->account != account)
+ if (purple_buddy_get_account(buddy) != account)
continue;
+ name = purple_buddy_get_name(buddy);
+
size++;
userlist = (uin_t *) g_renew(uin_t, userlist, size);
types = (gchar *) g_renew(gchar, types, size);
- userlist[size - 1] = ggp_str_to_uin(buddy->name);
+ userlist[size - 1] = ggp_str_to_uin(name);
types[size - 1] = GG_USER_NORMAL;
purple_debug_info("gg", "ggp_buddylist_send: adding %d\n",
userlist[size - 1]);
@@ -173,36 +182,45 @@ void ggp_buddylist_load(PurpleConnection *gc, char *buddylist)
void ggp_buddylist_offline(PurpleConnection *gc)
{
PurpleAccount *account = purple_connection_get_account(gc);
- PurpleBuddyList *blist;
PurpleBlistNode *gnode, *cnode, *bnode;
PurpleBuddy *buddy;
- if ((blist = purple_get_blist()) == NULL)
- return;
-
- for (gnode = blist->root; gnode != NULL; gnode = gnode->next) {
+ for (gnode = purple_blist_get_root();
+ gnode != NULL;
+ gnode = purple_blist_node_get_sibling_next(gnode))
+ {
if (!PURPLE_BLIST_NODE_IS_GROUP(gnode))
continue;
- for (cnode = gnode->child; cnode != NULL; cnode = cnode->next) {
+ for (cnode = purple_blist_node_get_first_child(gnode);
+ cnode != NULL;
+ cnode = purple_blist_node_get_sibling_next(cnode))
+ {
if (!PURPLE_BLIST_NODE_IS_CONTACT(cnode))
continue;
- for (bnode = cnode->child; bnode != NULL; bnode = bnode->next) {
+ for (bnode = purple_blist_node_get_first_child(cnode);
+ bnode != NULL;
+ bnode = purple_blist_node_get_sibling_next(bnode))
+ {
+ const gchar *name = NULL;
+
if (!PURPLE_BLIST_NODE_IS_BUDDY(bnode))
continue;
buddy = (PurpleBuddy *)bnode;
+
+ name = purple_buddy_get_name(buddy);
- if (buddy->account != account)
+ if (purple_buddy_get_account(buddy) != account)
continue;
purple_prpl_got_user_status(
- account, buddy->name, "offline", NULL);
+ account, name, "offline", NULL);
purple_debug_info("gg",
"ggp_buddylist_offline: gone: %s\n",
- buddy->name);
+ name);
}
}
}
@@ -212,41 +230,46 @@ void ggp_buddylist_offline(PurpleConnection *gc)
/* char *ggp_buddylist_dump(PurpleAccount *account) {{{ */
char *ggp_buddylist_dump(PurpleAccount *account)
{
- PurpleBuddyList *blist;
PurpleBlistNode *gnode, *cnode, *bnode;
PurpleGroup *group;
PurpleBuddy *buddy;
- GString *buddylist;
+ GString *buddylist = g_string_sized_new(1024);
char *ptr;
- if ((blist = purple_get_blist()) == NULL)
- return NULL;
-
- buddylist = g_string_sized_new(1024);
-
- for (gnode = blist->root; gnode != NULL; gnode = gnode->next) {
+ for (gnode = purple_blist_get_root();
+ gnode != NULL;
+ gnode = purple_blist_node_get_sibling_next(gnode))
+ {
if (!PURPLE_BLIST_NODE_IS_GROUP(gnode))
continue;
group = (PurpleGroup *)gnode;
- for (cnode = gnode->child; cnode != NULL; cnode = cnode->next) {
+ for (cnode = purple_blist_node_get_first_child(gnode);
+ cnode != NULL;
+ cnode = purple_blist_node_get_sibling_next(cnode))
+ {
if (!PURPLE_BLIST_NODE_IS_CONTACT(cnode))
continue;
- for (bnode = cnode->child; bnode != NULL; bnode = bnode->next) {
- gchar *name, *alias, *gname;
+ for (bnode = purple_blist_node_get_first_child(cnode);
+ bnode != NULL;
+ bnode = purple_blist_node_get_sibling_next(bnode))
+ {
+ const gchar *name, *alias, *gname;
if (!PURPLE_BLIST_NODE_IS_BUDDY(bnode))
continue;
buddy = (PurpleBuddy *)bnode;
- if (buddy->account != account)
+ if (purple_buddy_get_account(buddy) != account)
continue;
- name = buddy->name;
- alias = buddy->alias ? buddy->alias : buddy->name;
- gname = group->name;
+ name = purple_buddy_get_name(buddy);
+ alias = purple_buddy_get_alias(buddy);
+ if(alias == NULL)
+ alias = name;
+ gname = purple_group_get_name(group);
g_string_append_printf(buddylist,
"%s;%s;%s;%s;%s;%s;%s;%s%s\r\n",
diff --git a/libpurple/protocols/gg/gg.c b/libpurple/protocols/gg/gg.c
index cfe0076..28ad424 100644
--- a/libpurple/protocols/gg/gg.c
+++ b/libpurple/protocols/gg/gg.c
@@ -2052,11 +2052,12 @@ static void ggp_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup
{
PurpleAccount *account;
GGPInfo *info = gc->proto_data;
+ const gchar *name = purple_buddy_get_name(buddy);
- gg_add_notify(info->session, ggp_str_to_uin(buddy->name));
+ gg_add_notify(info->session, ggp_str_to_uin(name));
account = purple_connection_get_account(gc);
- if (strcmp(purple_account_get_username(account), buddy->name) == 0) {
+ if (strcmp(purple_account_get_username(account), name) == 0) {
ggp_status_fake_to_self(account);
}
}
@@ -2066,7 +2067,7 @@ static void ggp_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy,
{
GGPInfo *info = gc->proto_data;
- gg_remove_notify(info->session, ggp_str_to_uin(buddy->name));
+ gg_remove_notify(info->session, ggp_str_to_uin(purple_buddy_get_name(buddy)));
}
static void ggp_join_chat(PurpleConnection *gc, GHashTable *data)
diff --git a/libpurple/protocols/irc/irc.c b/libpurple/protocols/irc/irc.c
index e0013a3..9721536 100644
--- a/libpurple/protocols/irc/irc.c
+++ b/libpurple/protocols/irc/irc.c
@@ -564,7 +564,7 @@ static void irc_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup
{
struct irc_conn *irc = (struct irc_conn *)gc->proto_data;
struct irc_buddy *ib = g_new0(struct irc_buddy, 1);
- ib->name = g_strdup(buddy->name);
+ ib->name = g_strdup(purple_buddy_get_name(buddy));
g_hash_table_insert(irc->buddies, ib->name, ib);
/* if the timer isn't set, this is during signon, so we don't want to flood
@@ -577,7 +577,7 @@ static void irc_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup
static void irc_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
{
struct irc_conn *irc = (struct irc_conn *)gc->proto_data;
- g_hash_table_remove(irc->buddies, buddy->name);
+ g_hash_table_remove(irc->buddies, purple_buddy_get_name(buddy));
}
static void read_input(struct irc_conn *irc, int len)
diff --git a/libpurple/protocols/irc/msgs.c b/libpurple/protocols/irc/msgs.c
index 23fb423..81e107d 100644
--- a/libpurple/protocols/irc/msgs.c
+++ b/libpurple/protocols/irc/msgs.c
@@ -79,6 +79,7 @@ static void irc_connected(struct irc_conn *irc, const char *nick)
PurpleConnection *gc;
PurpleStatus *status;
PurpleBlistNode *gnode, *cnode, *bnode;
+ PurpleAccount *account;
if ((gc = purple_account_get_connection(irc->account)) == NULL
|| PURPLE_CONNECTION_IS_CONNECTED(gc))
@@ -86,6 +87,7 @@ static void irc_connected(struct irc_conn *irc, const char *nick)
purple_connection_set_display_name(gc, nick);
purple_connection_set_state(gc, PURPLE_CONNECTED);
+ account = purple_connection_get_account(gc);
/* If we're away then set our away message */
status = purple_account_get_active_status(irc->account);
@@ -95,20 +97,29 @@ static void irc_connected(struct irc_conn *irc, const char *nick)
}
/* this used to be in the core, but it's not now */
- for (gnode = purple_get_blist()->root; gnode; gnode = gnode->next) {
+ for (gnode = purple_blist_get_root();
+ gnode;
+ gnode = purple_blist_node_get_sibling_next(gnode))
+ {
if(!PURPLE_BLIST_NODE_IS_GROUP(gnode))
continue;
- for(cnode = gnode->child; cnode; cnode = cnode->next) {
+ for(cnode = purple_blist_node_get_first_child(gnode);
+ cnode;
+ cnode = purple_blist_node_get_sibling_next(cnode))
+ {
if(!PURPLE_BLIST_NODE_IS_CONTACT(cnode))
continue;
- for(bnode = cnode->child; bnode; bnode = bnode->next) {
+ for(bnode = purple_blist_node_get_first_child(cnode);
+ bnode;
+ bnode = purple_blist_node_get_sibling_next(bnode))
+ {
PurpleBuddy *b;
if(!PURPLE_BLIST_NODE_IS_BUDDY(bnode))
continue;
b = (PurpleBuddy *)bnode;
- if(b->account == gc->account) {
+ if(purple_buddy_get_account(b) == account) {
struct irc_buddy *ib = g_new0(struct irc_buddy, 1);
- ib->name = g_strdup(b->name);
+ ib->name = g_strdup(purple_buddy_get_name(b));
g_hash_table_insert(irc->buddies, ib->name, ib);
}
}
diff --git a/libpurple/protocols/jabber/Makefile.am b/libpurple/protocols/jabber/Makefile.am
index 5f46e37..e9b776b 100644
--- a/libpurple/protocols/jabber/Makefile.am
+++ b/libpurple/protocols/jabber/Makefile.am
@@ -17,6 +17,8 @@ JABBERSOURCES = auth.c \
disco.h \
google.c \
google.h \
+ ibb.c \
+ ibb.h \
iq.c \
iq.h \
jabber.c \
diff --git a/libpurple/protocols/jabber/Makefile.mingw b/libpurple/protocols/jabber/Makefile.mingw
index 4c49619..524f776 100644
--- a/libpurple/protocols/jabber/Makefile.mingw
+++ b/libpurple/protocols/jabber/Makefile.mingw
@@ -51,6 +51,7 @@ C_SRC = \
data.c \
disco.c \
google.c \
+ ibb.c \
iq.c \
jabber.c \
jutil.c \
diff --git a/libpurple/protocols/jabber/adhoccommands.c b/libpurple/protocols/jabber/adhoccommands.c
index eccc8ff..0781822 100644
--- a/libpurple/protocols/jabber/adhoccommands.c
+++ b/libpurple/protocols/jabber/adhoccommands.c
@@ -47,26 +47,26 @@ void jabber_adhoc_disco_result_cb(JabberStream *js, xmlnode *packet, gpointer da
JabberID *jabberid;
JabberBuddy *jb;
JabberBuddyResource *jbr = NULL;
-
+
if(strcmp(type, "result"))
return;
-
+
query = xmlnode_get_child_with_namespace(packet,"query","http://jabber.org/protocol/disco#items");
if(!query)
return;
node = xmlnode_get_attrib(query,"node");
if(!node || strcmp(node, "http://jabber.org/protocol/commands"))
return;
-
+
if((jabberid = jabber_id_new(from))) {
if(jabberid->resource && (jb = jabber_buddy_find(js, from, TRUE)))
jbr = jabber_buddy_find_resource(jb, jabberid->resource);
jabber_id_free(jabberid);
}
-
+
if(!jbr)
return;
-
+
if(jbr->commands) {
/* since the list we just received is complete, wipe the old one */
while(jbr->commands) {
@@ -78,7 +78,7 @@ void jabber_adhoc_disco_result_cb(JabberStream *js, xmlnode *packet, gpointer da
jbr->commands = g_list_delete_link(jbr->commands, jbr->commands);
}
}
-
+
for(item = query->child; item; item = item->next) {
JabberAdHocCommands *cmd;
if(item->type != XMLNODE_TYPE_TAG)
@@ -86,11 +86,11 @@ void jabber_adhoc_disco_result_cb(JabberStream *js, xmlnode *packet, gpointer da
if(strcmp(item->name, "item"))
continue;
cmd = g_new0(JabberAdHocCommands, 1);
-
+
cmd->jid = g_strdup(xmlnode_get_attrib(item,"jid"));
cmd->node = g_strdup(xmlnode_get_attrib(item,"node"));
cmd->name = g_strdup(xmlnode_get_attrib(item,"name"));
-
+
jbr->commands = g_list_append(jbr->commands,cmd);
}
}
@@ -103,13 +103,13 @@ static void do_adhoc_action_cb(JabberStream *js, xmlnode *result, const char *ac
JabberAdHocActionInfo *actionInfo = user_data;
JabberIq *iq = jabber_iq_new(js, JABBER_IQ_SET);
jabber_iq_set_callback(iq, jabber_adhoc_parse, NULL);
-
+
xmlnode_set_attrib(iq->node, "to", actionInfo->who);
command = xmlnode_new_child(iq->node,"command");
xmlnode_set_namespace(command,"http://jabber.org/protocol/commands");
xmlnode_set_attrib(command,"sessionid",actionInfo->sessionid);
xmlnode_set_attrib(command,"node",actionInfo->node);
-
+
/* cancel is handled differently on ad-hoc commands than regular forms */
if(!strcmp(xmlnode_get_namespace(result),"jabber:x:data") && !strcmp(xmlnode_get_attrib(result, "type"),"cancel")) {
xmlnode_set_attrib(command,"action","cancel");
@@ -118,7 +118,7 @@ static void do_adhoc_action_cb(JabberStream *js, xmlnode *result, const char *ac
xmlnode_set_attrib(command,"action",actionhandle);
xmlnode_insert_child(command,result);
}
-
+
for(action = actionInfo->actionslist; action; action = g_list_next(action)) {
char *handle = action->data;
g_free(handle);
@@ -127,7 +127,7 @@ static void do_adhoc_action_cb(JabberStream *js, xmlnode *result, const char *ac
g_free(actionInfo->sessionid);
g_free(actionInfo->who);
g_free(actionInfo->node);
-
+
jabber_iq_send(iq);
}
@@ -136,12 +136,12 @@ static void jabber_adhoc_parse(JabberStream *js, xmlnode *packet, gpointer data)
const char *status = xmlnode_get_attrib(command,"status");
xmlnode *xdata = xmlnode_get_child_with_namespace(command,"x","jabber:x:data");
const char *type = xmlnode_get_attrib(packet,"type");
-
+
if(type && !strcmp(type,"error")) {
char *msg = jabber_parse_error(js, packet, NULL);
if(!msg)
msg = g_strdup(_("Unknown Error"));
-
+
purple_notify_error(NULL, _("Ad-Hoc Command Failed"),
_("Ad-Hoc Command Failed"), msg);
g_free(msg);
@@ -149,20 +149,20 @@ static void jabber_adhoc_parse(JabberStream *js, xmlnode *packet, gpointer data)
}
if(!type || strcmp(type,"result"))
return;
-
+
if(!status)
return;
-
+
if(!strcmp(status,"completed")) {
/* display result */
xmlnode *note = xmlnode_get_child(command,"note");
-
+
if(note) {
char *data = xmlnode_get_data(note);
purple_notify_info(NULL, xmlnode_get_attrib(packet, "from"), data, NULL);
g_free(data);
}
-
+
if(xdata)
jabber_x_data_request(js, xdata, (jabber_x_data_cb)do_adhoc_ignoreme, NULL);
return;
@@ -175,7 +175,7 @@ static void jabber_adhoc_parse(JabberStream *js, xmlnode *packet, gpointer data)
JabberAdHocActionInfo *actionInfo;
if(!xdata)
return; /* shouldn't happen */
-
+
actions = xmlnode_get_child(command,"actions");
if(!actions) {
JabberXDataAction *defaultaction = g_new0(JabberXDataAction, 1);
@@ -196,13 +196,13 @@ static void jabber_adhoc_parse(JabberStream *js, xmlnode *packet, gpointer data)
}
}
}
-
+
actionInfo = g_new0(JabberAdHocActionInfo, 1);
actionInfo->sessionid = g_strdup(xmlnode_get_attrib(command,"sessionid"));
actionInfo->who = g_strdup(xmlnode_get_attrib(packet,"from"));
actionInfo->node = g_strdup(xmlnode_get_attrib(command,"node"));
actionInfo->actionslist = actionslist;
-
+
jabber_x_data_request_with_actions(js,xdata,actionslist,actionindex,do_adhoc_action_cb,actionInfo);
}
}
@@ -211,8 +211,9 @@ void jabber_adhoc_execute_action(PurpleBlistNode *node, gpointer data) {
if (PURPLE_BLIST_NODE_IS_BUDDY(node)) {
JabberAdHocCommands *cmd = data;
PurpleBuddy *buddy = (PurpleBuddy *) node;
- JabberStream *js = purple_account_get_connection(buddy->account)->proto_data;
-
+ PurpleAccount *account = purple_buddy_get_account(buddy);
+ JabberStream *js = purple_account_get_connection(account)->proto_data;
+
jabber_adhoc_execute(js, cmd);
}
}
@@ -220,7 +221,7 @@ void jabber_adhoc_execute_action(PurpleBlistNode *node, gpointer data) {
static void jabber_adhoc_server_got_list_cb(JabberStream *js, xmlnode *packet, gpointer data) {
xmlnode *query = xmlnode_get_child_with_namespace(packet, "query", "http://jabber.org/protocol/disco#items");
xmlnode *item;
-
+
if(!query)
return;
@@ -233,7 +234,7 @@ static void jabber_adhoc_server_got_list_cb(JabberStream *js, xmlnode *packet, g
g_free(cmd);
js->commands = g_list_delete_link(js->commands, js->commands);
}
-
+
/* re-fill list */
for(item = query->child; item; item = item->next) {
JabberAdHocCommands *cmd;
@@ -245,7 +246,7 @@ static void jabber_adhoc_server_got_list_cb(JabberStream *js, xmlnode *packet, g
cmd->jid = g_strdup(xmlnode_get_attrib(item,"jid"));
cmd->node = g_strdup(xmlnode_get_attrib(item,"node"));
cmd->name = g_strdup(xmlnode_get_attrib(item,"name"));
-
+
js->commands = g_list_append(js->commands,cmd);
}
}
@@ -253,10 +254,10 @@ static void jabber_adhoc_server_got_list_cb(JabberStream *js, xmlnode *packet, g
void jabber_adhoc_server_get_list(JabberStream *js) {
JabberIq *iq = jabber_iq_new_query(js,JABBER_IQ_GET,"http://jabber.org/protocol/disco#items");
xmlnode *query = xmlnode_get_child_with_namespace(iq->node,"query","http://jabber.org/protocol/disco#items");
-
+
xmlnode_set_attrib(iq->node,"to",js->user->domain);
xmlnode_set_attrib(query,"node","http://jabber.org/protocol/commands");
-
+
jabber_iq_set_callback(iq,jabber_adhoc_server_got_list_cb,NULL);
jabber_iq_send(iq);
}
@@ -268,9 +269,9 @@ void jabber_adhoc_execute(JabberStream *js, JabberAdHocCommands *cmd) {
xmlnode_set_namespace(command,"http://jabber.org/protocol/commands");
xmlnode_set_attrib(command,"node",cmd->node);
xmlnode_set_attrib(command,"action","execute");
-
+
jabber_iq_set_callback(iq,jabber_adhoc_parse,NULL);
-
+
jabber_iq_send(iq);
}
@@ -279,7 +280,7 @@ static void jabber_adhoc_server_execute(PurplePluginAction *action) {
if(cmd) {
PurpleConnection *gc = (PurpleConnection *) action->context;
JabberStream *js = gc->proto_data;
-
+
jabber_adhoc_execute(js, cmd);
}
}
@@ -287,7 +288,7 @@ static void jabber_adhoc_server_execute(PurplePluginAction *action) {
void jabber_adhoc_init_server_commands(JabberStream *js, GList **m) {
GList *cmdlst;
JabberBuddy *jb;
-
+
/* also add commands for other clients connected to the same account on another resource */
char *accountname = g_strdup_printf("%s@%s", js->user->node, js->user->domain);
if((jb = jabber_buddy_find(js, accountname, TRUE))) {
@@ -306,7 +307,7 @@ void jabber_adhoc_init_server_commands(JabberStream *js, GList **m) {
}
}
g_free(accountname);
-
+
/* now add server commands */
for(cmdlst = js->commands; cmdlst; cmdlst = g_list_next(cmdlst)) {
JabberAdHocCommands *cmd = cmdlst->data;
diff --git a/libpurple/protocols/jabber/auth.c b/libpurple/protocols/jabber/auth.c
index e93ea16..ae8320f 100644
--- a/libpurple/protocols/jabber/auth.c
+++ b/libpurple/protocols/jabber/auth.c
@@ -384,7 +384,7 @@ static void jabber_auth_start_cyrus(JabberStream *js)
}
/* Remove space which separated this mech from the next */
if (strlen(js->sasl_mechs->str) > 0 && ((js->sasl_mechs->str)[0] == ' ')) {
- g_string_erase(js->sasl_mechs, 0, 1);
+ g_string_erase(js->sasl_mechs, 0, 1);
}
again = TRUE;
}
@@ -397,7 +397,7 @@ static void jabber_auth_start_cyrus(JabberStream *js)
auth = xmlnode_new("auth");
xmlnode_set_namespace(auth, "urn:ietf:params:xml:ns:xmpp-sasl");
xmlnode_set_attrib(auth, "mechanism", js->current_mech);
-
+
xmlnode_set_attrib(auth, "xmlns:ga", "http://www.google.com/talk/protocol/auth");
xmlnode_set_attrib(auth, "ga:client-uses-full-bind-result", "true");
@@ -1057,13 +1057,13 @@ void jabber_auth_handle_failure(JabberStream *js, xmlnode *packet)
}
/* Remove space which separated this mech from the next */
if (strlen(js->sasl_mechs->str) > 0 && ((js->sasl_mechs->str)[0] == ' ')) {
- g_string_erase(js->sasl_mechs, 0, 1);
- }
+ g_string_erase(js->sasl_mechs, 0, 1);
+ }
}
if (strlen(js->sasl_mechs->str)) {
/* If we have remaining mechs to try, do so */
sasl_dispose(&js->sasl);
-
+
jabber_auth_start_cyrus(js);
return;
}
diff --git a/libpurple/protocols/jabber/buddy.c b/libpurple/protocols/jabber/buddy.c
index c7d7a7e..31f20c7 100644
--- a/libpurple/protocols/jabber/buddy.c
+++ b/libpurple/protocols/jabber/buddy.c
@@ -170,7 +170,7 @@ void jabber_buddy_resource_free(JabberBuddyResource *jbr)
g_return_if_fail(jbr != NULL);
jbr->jb->resources = g_list_remove(jbr->jb->resources, jbr);
-
+
while(jbr->commands) {
JabberAdHocCommands *cmd = jbr->commands->data;
g_free(cmd->jid);
@@ -179,7 +179,7 @@ void jabber_buddy_resource_free(JabberBuddyResource *jbr)
g_free(cmd);
jbr->commands = g_list_delete_link(jbr->commands, jbr->commands);
}
-
+
jabber_caps_free_clientinfo(jbr->caps);
g_free(jbr->name);
@@ -422,7 +422,7 @@ void jabber_set_info(PurpleConnection *gc, const char *info)
{
PurpleStoredImage *img;
JabberIq *iq;
- JabberStream *js = gc->proto_data;
+ JabberStream *js = purple_connection_get_protocol_data(gc);
xmlnode *vc_node;
const struct tag_attr *tag_attr;
@@ -495,8 +495,8 @@ void jabber_set_buddy_icon(PurpleConnection *gc, PurpleStoredImage *img)
{
PurplePresence *gpresence;
PurpleStatus *status;
-
- if(((JabberStream*)gc->proto_data)->pep) {
+
+ if(((JabberStream*)purple_connection_get_protocol_data(gc))->pep) {
/* XEP-0084: User Avatars */
if(img) {
/*
@@ -539,37 +539,37 @@ void jabber_set_buddy_icon(PurpleConnection *gc, PurpleStoredImage *img)
guint32 height = ntohl(png->ihdr.height);
xmlnode *publish, *item, *data, *metadata, *info;
char *lengthstring, *widthstring, *heightstring;
-
+
/* compute the sha1 hash */
char *hash = jabber_calculate_data_sha1sum(purple_imgstore_get_data(img), purple_imgstore_get_size(img));
char *base64avatar;
-
+
publish = xmlnode_new("publish");
xmlnode_set_attrib(publish,"node",AVATARNAMESPACEDATA);
-
+
item = xmlnode_new_child(publish, "item");
xmlnode_set_attrib(item, "id", hash);
-
+
data = xmlnode_new_child(item, "data");
xmlnode_set_namespace(data,AVATARNAMESPACEDATA);
-
+
base64avatar = purple_base64_encode(purple_imgstore_get_data(img), purple_imgstore_get_size(img));
xmlnode_insert_data(data,base64avatar,-1);
g_free(base64avatar);
-
+
/* publish the avatar itself */
- jabber_pep_publish((JabberStream*)gc->proto_data, publish);
-
+ jabber_pep_publish((JabberStream*)purple_connection_get_protocol_data(gc), publish);
+
/* next step: publish the metadata */
publish = xmlnode_new("publish");
xmlnode_set_attrib(publish,"node",AVATARNAMESPACEMETA);
-
+
item = xmlnode_new_child(publish, "item");
xmlnode_set_attrib(item, "id", hash);
-
+
metadata = xmlnode_new_child(item, "metadata");
xmlnode_set_namespace(metadata,AVATARNAMESPACEMETA);
-
+
info = xmlnode_new_child(metadata, "info");
xmlnode_set_attrib(info, "id", hash);
xmlnode_set_attrib(info, "type", "image/png");
@@ -582,10 +582,10 @@ void jabber_set_buddy_icon(PurpleConnection *gc, PurpleStoredImage *img)
heightstring = g_strdup_printf("%u", height);
xmlnode_set_attrib(info, "height", heightstring);
g_free(heightstring);
-
+
/* publish the metadata */
- jabber_pep_publish((JabberStream*)gc->proto_data, publish);
-
+ jabber_pep_publish((JabberStream*)purple_connection_get_protocol_data(gc), publish);
+
g_free(hash);
} else {
purple_debug_error("jabber", "jabber_set_buddy_icon received non-png data");
@@ -796,18 +796,18 @@ static void jabber_buddy_info_show_if_ready(JabberBuddyInfo *jbi)
(jbr->client.version ? jbr->client.version : ""));
purple_notify_user_info_add_pair(user_info, _("Client"), tmp);
g_free(tmp);
-
+
if(jbr->client.os) {
purple_notify_user_info_prepend_pair(user_info, _("Operating System"), jbr->client.os);
}
- }
+ }
if(jbir) {
if(jbir->idle_seconds > 0) {
char *idle = purple_str_seconds_to_string(jbir->idle_seconds);
purple_notify_user_info_prepend_pair(user_info, _("Idle"), idle);
g_free(idle);
}
- }
+ }
if(jbr) {
char *purdy = NULL;
const char *status_name = jabber_buddy_state_get_name(jbr->state);
@@ -825,7 +825,7 @@ static void jabber_buddy_info_show_if_ready(JabberBuddyInfo *jbi)
} else {
purple_notify_user_info_prepend_pair(user_info, _("Status"), _("Unknown"));
}
-#if 0
+#if 0
/* #if 0 this for now; I think this would be far more useful if we limited this to a particular set of features
* of particular interest (-vv jumps out as one). As it is now, I don't picture people getting all excited: "Oh sweet crap!
* So-and-so supports 'jabber:x:data' AND 'Collaborative Data Objects'!"
@@ -836,7 +836,7 @@ static void jabber_buddy_info_show_if_ready(JabberBuddyInfo *jbi)
GList *iter;
for(iter = jbr->caps->features; iter; iter = g_list_next(iter)) {
const char *feature = iter->data;
-
+
if(!strcmp(feature, "jabber:iq:last"))
feature = _("Last Activity");
else if(!strcmp(feature, "http://jabber.org/protocol/disco#info"))
@@ -945,7 +945,7 @@ static void jabber_buddy_info_show_if_ready(JabberBuddyInfo *jbi)
if(strlen(tmp->str) > 0)
purple_notify_user_info_prepend_pair(user_info, _("Capabilities"), tmp->str);
-
+
g_string_free(tmp, TRUE);
}
#endif
@@ -965,7 +965,7 @@ static void jabber_buddy_info_show_if_ready(JabberBuddyInfo *jbi)
purple_notify_user_info_prepend_pair(user_info,
_("Client"), tmp);
g_free(tmp);
-
+
if(jbr->client.os) {
purple_notify_user_info_prepend_pair(user_info, _("Operating System"), jbr->client.os);
}
@@ -984,14 +984,14 @@ static void jabber_buddy_info_show_if_ready(JabberBuddyInfo *jbi)
purdy = purple_strdup_withhtml(jbr->status);
if(status_name && purdy && !strcmp(status_name, purdy))
status_name = NULL;
-
+
tmp = g_strdup_printf("%s%s%s", (status_name ? status_name : ""),
((status_name && purdy) ? ": " : ""),
(purdy ? purdy : ""));
purple_notify_user_info_prepend_pair(user_info, _("Status"), tmp);
g_free(tmp);
g_free(purdy);
-
+
if(multiple_resources) {
tmp = g_strdup_printf("%d", jbr->priority);
purple_notify_user_info_prepend_pair(user_info, _("Priority"), tmp);
@@ -1006,7 +1006,7 @@ static void jabber_buddy_info_show_if_ready(JabberBuddyInfo *jbi)
GList *iter;
for(iter = jbr->caps->features; iter; iter = g_list_next(iter)) {
const char *feature = iter->data;
-
+
if(!strcmp(feature, "jabber:iq:last"))
feature = _("Last Activity");
else if(!strcmp(feature, "http://jabber.org/protocol/disco#info"))
@@ -1109,13 +1109,13 @@ static void jabber_buddy_info_show_if_ready(JabberBuddyInfo *jbi)
feature = _("Hop Check");
else if(g_str_has_suffix(feature, "+notify"))
feature = NULL;
-
+
if(feature)
g_string_append_printf(tmp, "%s\n", feature);
}
if(strlen(tmp->str) > 0)
purple_notify_user_info_prepend_pair(user_info, _("Capabilities"), tmp->str);
-
+
g_string_free(tmp, TRUE);
}
#endif
@@ -1183,7 +1183,7 @@ static void jabber_vcard_save_mine(JabberStream *js, xmlnode *packet, gpointer d
void jabber_vcard_fetch_mine(JabberStream *js)
{
JabberIq *iq = jabber_iq_new(js, JABBER_IQ_GET);
-
+
xmlnode *vcard = xmlnode_new_child(iq->node, "vCard");
xmlnode_set_namespace(vcard, "vcard-temp");
jabber_iq_set_callback(iq, jabber_vcard_save_mine, NULL);
@@ -1257,13 +1257,13 @@ static void jabber_vcard_parse(JabberStream *js, xmlnode *packet, gpointer data)
}
g_free(text2);
}
- } else if(text && !strcmp(child->name, "NICKNAME")) {
+ } else if(text && !strcmp(child->name, "NICKNAME")) {
/* Prefer the Nickcname to the Full Name as the serverside alias if it's not just part of the jid.
* Ignore it if it's part of the jid. */
if (strstr(bare_jid, text) == NULL) {
g_free(serverside_alias);
serverside_alias = g_strdup(text);
-
+
purple_notify_user_info_add_pair(user_info, _("Nickname"), text);
}
} else if(text && !strcmp(child->name, "BDAY")) {
@@ -1308,7 +1308,7 @@ static void jabber_vcard_parse(JabberStream *js, xmlnode *packet, gpointer data)
}
g_free(text2);
}
-
+
if (address_line_added)
purple_notify_user_info_add_section_break(user_info);
@@ -1350,8 +1350,8 @@ static void jabber_vcard_parse(JabberStream *js, xmlnode *packet, gpointer data)
escaped = g_markup_escape_text(userid, -1);
mailto = g_strdup_printf("<a href=\"mailto:%s\">%s</a>", escaped, escaped);
purple_notify_user_info_add_pair(user_info, _("Email"), mailto);
-
- g_free(mailto);
+
+ g_free(mailto);
g_free(escaped);
g_free(userid);
}
@@ -1418,7 +1418,7 @@ static void jabber_vcard_parse(JabberStream *js, xmlnode *packet, gpointer data)
if (b) {
purple_blist_node_set_string((PurpleBlistNode*)b, "servernick", serverside_alias);
}
-
+
g_free(serverside_alias);
}
@@ -1440,7 +1440,7 @@ static void do_buddy_avatar_update_fromurl(PurpleUtilFetchUrlData *url_data, gpo
"do_buddy_avatar_update_fromurl got error \"%s\"", error_message);
return;
}
-
+
purple_buddy_icons_set_for_user(purple_connection_get_account(info->js->gc), info->from, (void*)url_text, len, info->id);
g_free(info->from);
g_free(info->id);
@@ -1455,29 +1455,29 @@ static void do_buddy_avatar_update_data(JabberStream *js, const char *from, xmln
size_t size;
if(!items)
return;
-
+
item = xmlnode_get_child(items, "item");
if(!item)
return;
-
+
data = xmlnode_get_child_with_namespace(item,"data",AVATARNAMESPACEDATA);
if(!data)
return;
-
+
checksum = xmlnode_get_attrib(item,"id");
if(!checksum)
return;
-
+
b64data = xmlnode_get_data(data);
if(!b64data)
return;
-
+
img = purple_base64_decode(b64data, &size);
if(!img) {
g_free(b64data);
return;
}
-
+
purple_buddy_icons_set_for_user(purple_connection_get_account(js->gc), from, img, size, checksum);
g_free(b64data);
}
@@ -1488,7 +1488,7 @@ void jabber_buddy_avatar_update_metadata(JabberStream *js, const char *from, xml
xmlnode *item, *metadata;
if(!buddy)
return;
-
+
checksum = purple_buddy_icons_get_checksum_for_user(buddy);
item = xmlnode_get_child(items,"item");
metadata = xmlnode_get_child_with_namespace(item, "metadata", AVATARNAMESPACEMETA);
@@ -1508,7 +1508,7 @@ void jabber_buddy_avatar_update_metadata(JabberStream *js, const char *from, xml
if(info->type == XMLNODE_TYPE_TAG && !strcmp(info->name,"info")) {
const char *type = xmlnode_get_attrib(info,"type");
const char *id = xmlnode_get_attrib(info,"id");
-
+
if(checksum && id && !strcmp(id, checksum)) {
/* we already have that avatar, so we don't have to do anything */
goodinfo = NULL;
@@ -1524,7 +1524,7 @@ void jabber_buddy_avatar_update_metadata(JabberStream *js, const char *from, xml
} else if(goodinfo) {
const char *url = xmlnode_get_attrib(goodinfo, "url");
const char *id = xmlnode_get_attrib(goodinfo,"id");
-
+
/* the avatar might either be stored in a pep node, or on a HTTP/HTTPS URL */
if(!url)
jabber_pep_request_item(js, from, AVATARNAMESPACEDATA, id, do_buddy_avatar_update_data);
@@ -1780,7 +1780,7 @@ static void jabber_buddy_get_info_for_jid(JabberStream *js, const char *jid)
void jabber_buddy_get_info(PurpleConnection *gc, const char *who)
{
- JabberStream *js = gc->proto_data;
+ JabberStream *js = purple_connection_get_protocol_data(gc);
JabberID *jid = jabber_id_new(who);
if (!jid)
@@ -1840,10 +1840,10 @@ static void jabber_buddy_make_invisible(PurpleBlistNode *node, gpointer data)
g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
buddy = (PurpleBuddy *) node;
- gc = purple_account_get_connection(buddy->account);
- js = gc->proto_data;
+ gc = purple_account_get_connection(purple_buddy_get_account(buddy));
+ js = purple_connection_get_protocol_data(gc);
- jabber_buddy_set_invisibility(js, buddy->name, TRUE);
+ jabber_buddy_set_invisibility(js, purple_buddy_get_name(buddy), TRUE);
}
static void jabber_buddy_make_visible(PurpleBlistNode *node, gpointer data)
@@ -1855,10 +1855,10 @@ static void jabber_buddy_make_visible(PurpleBlistNode *node, gpointer data)
g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
buddy = (PurpleBuddy *) node;
- gc = purple_account_get_connection(buddy->account);
- js = gc->proto_data;
+ gc = purple_account_get_connection(purple_buddy_get_account(buddy));
+ js = purple_connection_get_protocol_data(gc);
- jabber_buddy_set_invisibility(js, buddy->name, FALSE);
+ jabber_buddy_set_invisibility(js, purple_buddy_get_name(buddy), FALSE);
}
static void jabber_buddy_cancel_presence_notification(PurpleBlistNode *node,
@@ -1871,11 +1871,11 @@ static void jabber_buddy_cancel_presence_notification(PurpleBlistNode *node,
g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
buddy = (PurpleBuddy *) node;
- gc = purple_account_get_connection(buddy->account);
- js = gc->proto_data;
+ gc = purple_account_get_connection(purple_buddy_get_account(buddy));
+ js = purple_connection_get_protocol_data(gc);
/* I wonder if we should prompt the user before doing this */
- jabber_presence_subscription_set(js, buddy->name, "unsubscribed");
+ jabber_presence_subscription_set(js, purple_buddy_get_name(buddy), "unsubscribed");
}
static void jabber_buddy_rerequest_auth(PurpleBlistNode *node, gpointer data)
@@ -1887,10 +1887,10 @@ static void jabber_buddy_rerequest_auth(PurpleBlistNode *node, gpointer data)
g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
buddy = (PurpleBuddy *) node;
- gc = purple_account_get_connection(buddy->account);
- js = gc->proto_data;
+ gc = purple_account_get_connection(purple_buddy_get_account(buddy));
+ js = purple_connection_get_protocol_data(gc);
- jabber_presence_subscription_set(js, buddy->name, "subscribe");
+ jabber_presence_subscription_set(js, purple_buddy_get_name(buddy), "subscribe");
}
@@ -1903,18 +1903,18 @@ static void jabber_buddy_unsubscribe(PurpleBlistNode *node, gpointer data)
g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
buddy = (PurpleBuddy *) node;
- gc = purple_account_get_connection(buddy->account);
- js = gc->proto_data;
+ gc = purple_account_get_connection(purple_buddy_get_account(buddy));
+ js = purple_connection_get_protocol_data(gc);
- jabber_presence_subscription_set(js, buddy->name, "unsubscribe");
+ jabber_presence_subscription_set(js, purple_buddy_get_name(buddy), "unsubscribe");
}
static void jabber_buddy_login(PurpleBlistNode *node, gpointer data) {
if(PURPLE_BLIST_NODE_IS_BUDDY(node)) {
/* simply create a directed presence of the current status */
PurpleBuddy *buddy = (PurpleBuddy *) node;
- PurpleConnection *gc = purple_account_get_connection(buddy->account);
- JabberStream *js = gc->proto_data;
+ PurpleConnection *gc = purple_account_get_connection(purple_buddy_get_account(buddy));
+ JabberStream *js = purple_connection_get_protocol_data(gc);
PurpleAccount *account = purple_connection_get_account(gc);
PurplePresence *gpresence = purple_account_get_presence(account);
PurpleStatus *status = purple_presence_get_active_status(gpresence);
@@ -1922,14 +1922,14 @@ static void jabber_buddy_login(PurpleBlistNode *node, gpointer data) {
JabberBuddyState state;
char *msg;
int priority;
-
+
purple_status_to_jabber(status, &state, &msg, &priority);
presence = jabber_presence_create_js(js, state, msg, priority);
-
+
g_free(msg);
-
- xmlnode_set_attrib(presence, "to", buddy->name);
-
+
+ xmlnode_set_attrib(presence, "to", purple_buddy_get_name(buddy));
+
jabber_send(js, presence);
xmlnode_free(presence);
}
@@ -1939,13 +1939,14 @@ static void jabber_buddy_logout(PurpleBlistNode *node, gpointer data) {
if(PURPLE_BLIST_NODE_IS_BUDDY(node)) {
/* simply create a directed unavailable presence */
PurpleBuddy *buddy = (PurpleBuddy *) node;
- JabberStream *js = purple_account_get_connection(buddy->account)->proto_data;
+ PurpleConnection *gc = purple_account_get_connection(purple_buddy_get_account(buddy));
+ JabberStream *js = purple_connection_get_protocol_data(gc);
xmlnode *presence;
-
+
presence = jabber_presence_create_js(js, JABBER_BUDDY_STATE_UNAVAILABLE, NULL, 0);
-
- xmlnode_set_attrib(presence, "to", buddy->name);
-
+
+ xmlnode_set_attrib(presence, "to", purple_buddy_get_name(buddy));
+
jabber_send(js, presence);
xmlnode_free(presence);
}
@@ -1953,9 +1954,10 @@ static void jabber_buddy_logout(PurpleBlistNode *node, gpointer data) {
static GList *jabber_buddy_menu(PurpleBuddy *buddy)
{
- PurpleConnection *gc = purple_account_get_connection(buddy->account);
- JabberStream *js = gc->proto_data;
- JabberBuddy *jb = jabber_buddy_find(js, buddy->name, TRUE);
+ PurpleConnection *gc = purple_account_get_connection(purple_buddy_get_account(buddy));
+ JabberStream *js = purple_connection_get_protocol_data(gc);
+ const char *name = purple_buddy_get_name(buddy);
+ JabberBuddy *jb = jabber_buddy_find(js, name, TRUE);
GList *jbrs;
GList *m = NULL;
@@ -2001,7 +2003,7 @@ static GList *jabber_buddy_menu(PurpleBuddy *buddy)
NULL, NULL);
m = g_list_append(m, act);
}
-
+
/*
* This if-condition implements parts of XEP-0100: Gateway Interaction
*
@@ -2010,7 +2012,7 @@ static GList *jabber_buddy_menu(PurpleBuddy *buddy)
* that gateways on the roster can be identified by having no '@' in their jid. This is a faily safe assumption, since
* people don't tend to have a server or other service there.
*/
- if (g_utf8_strchr(buddy->name, -1, '@') == NULL) {
+ if (g_utf8_strchr(name, -1, '@') == NULL) {
act = purple_menu_action_new(_("Log In"),
PURPLE_CALLBACK(jabber_buddy_login),
NULL, NULL);
@@ -2020,7 +2022,7 @@ static GList *jabber_buddy_menu(PurpleBuddy *buddy)
NULL, NULL);
m = g_list_append(m, act);
}
-
+
/* add all ad hoc commands to the action menu */
for(jbrs = jb->resources; jbrs; jbrs = g_list_next(jbrs)) {
JabberBuddyResource *jbr = jbrs->data;
@@ -2478,7 +2480,7 @@ void jabber_user_search(JabberStream *js, const char *directory)
void jabber_user_search_begin(PurplePluginAction *action)
{
PurpleConnection *gc = (PurpleConnection *) action->context;
- JabberStream *js = gc->proto_data;
+ JabberStream *js = purple_connection_get_protocol_data(gc);
purple_request_input(gc, _("Enter a User Directory"), _("Enter a User Directory"),
_("Select a user directory to search"),
diff --git a/libpurple/protocols/jabber/caps.c b/libpurple/protocols/jabber/caps.c
index ad33a47..99213b3 100644
--- a/libpurple/protocols/jabber/caps.c
+++ b/libpurple/protocols/jabber/caps.c
@@ -51,7 +51,7 @@ static guint jabber_caps_hash(gconstpointer key) {
const JabberCapsKey *name = key;
guint nodehash = g_str_hash(name->node);
guint verhash = g_str_hash(name->ver);
-
+
return nodehash ^ verhash;
}
@@ -77,7 +77,7 @@ static void jabber_caps_destroy_value(gpointer value) {
g_free(id->type);
g_free(id->name);
g_free(id);
-
+
valuestruct->identities = g_list_delete_link(valuestruct->identities,valuestruct->identities);
}
while(valuestruct->features) {
@@ -96,7 +96,7 @@ static void jabber_caps_ext_destroy_value(gpointer value) {
g_free(id->type);
g_free(id->name);
g_free(id);
-
+
valuestruct->identities = g_list_delete_link(valuestruct->identities,valuestruct->identities);
}
while(valuestruct->features) {
@@ -124,7 +124,7 @@ static void jabber_caps_load(void) {
xmlnode_free(capsdata);
return;
}
-
+
for(client = capsdata->child; client; client = client->next) {
if(client->type != XMLNODE_TYPE_TAG)
continue;
@@ -147,20 +147,20 @@ static void jabber_caps_load(void) {
const char *category = xmlnode_get_attrib(child, "category");
const char *type = xmlnode_get_attrib(child, "type");
const char *name = xmlnode_get_attrib(child, "name");
-
+
JabberCapsIdentity *id = g_new0(JabberCapsIdentity, 1);
id->category = g_strdup(category);
id->type = g_strdup(type);
id->name = g_strdup(name);
-
+
value->identities = g_list_append(value->identities,id);
} else if(!strcmp(child->name,"ext")) {
const char *identifier = xmlnode_get_attrib(child, "identifier");
if(identifier) {
xmlnode *extchild;
-
+
JabberCapsValueExt *extvalue = g_new0(JabberCapsValueExt, 1);
-
+
for(extchild = child->child; extchild; extchild = extchild->next) {
if(extchild->type != XMLNODE_TYPE_TAG)
continue;
@@ -173,12 +173,12 @@ static void jabber_caps_load(void) {
const char *category = xmlnode_get_attrib(extchild, "category");
const char *type = xmlnode_get_attrib(extchild, "type");
const char *name = xmlnode_get_attrib(extchild, "name");
-
+
JabberCapsIdentity *id = g_new0(JabberCapsIdentity, 1);
id->category = g_strdup(category);
id->type = g_strdup(type);
id->name = g_strdup(name);
-
+
extvalue->identities = g_list_append(extvalue->identities,id);
}
}
@@ -226,7 +226,7 @@ static void jabber_caps_store_client(gpointer key, gpointer value, gpointer user
xmlnode_set_attrib(client,"node",clientinfo->node);
xmlnode_set_attrib(client,"ver",clientinfo->ver);
-
+
for(iter = props->identities; iter; iter = g_list_next(iter)) {
JabberCapsIdentity *id = iter->data;
xmlnode *identity = xmlnode_new_child(client, "identity");
@@ -241,7 +241,7 @@ static void jabber_caps_store_client(gpointer key, gpointer value, gpointer user
xmlnode *feature = xmlnode_new_child(client, "feature");
xmlnode_set_attrib(feature, "var", feat);
}
-
+
g_hash_table_foreach(props->ext,jabber_caps_store_ext,client);
}
@@ -281,20 +281,20 @@ static JabberCapsClientInfo *jabber_caps_collect_info(const char *node, const ch
newid->category = g_strdup(id->category);
newid->type = g_strdup(id->type);
newid->name = g_strdup(id->name);
-
+
result->identities = g_list_append(result->identities,newid);
}
for(iter = caps->features; iter; iter = g_list_next(iter)) {
const char *feat = iter->data;
char *newfeat = g_strdup(feat);
-
+
result->features = g_list_append(result->features,newfeat);
}
-
+
for(iter = ext; iter; iter = g_list_next(iter)) {
const char *extname = iter->data;
JabberCapsValueExt *extinfo = g_hash_table_lookup(caps->ext,extname);
-
+
if(extinfo) {
GList *iter2;
for(iter2 = extinfo->identities; iter2; iter2 = g_list_next(iter2)) {
@@ -303,13 +303,13 @@ static JabberCapsClientInfo *jabber_caps_collect_info(const char *node, const ch
newid->category = g_strdup(id->category);
newid->type = g_strdup(id->type);
newid->name = g_strdup(id->name);
-
+
result->identities = g_list_append(result->identities,newid);
}
for(iter2 = extinfo->features; iter2; iter2 = g_list_next(iter2)) {
const char *feat = iter2->data;
char *newfeat = g_strdup(feat);
-
+
result->features = g_list_append(result->features,newfeat);
}
}
@@ -326,23 +326,23 @@ void jabber_caps_free_clientinfo(JabberCapsClientInfo *clientinfo) {
g_free(id->type);
g_free(id->name);
g_free(id);
-
+
clientinfo->identities = g_list_delete_link(clientinfo->identities,clientinfo->identities);
}
while(clientinfo->features) {
char *feat = clientinfo->features->data;
g_free(feat);
-
+
clientinfo->features = g_list_delete_link(clientinfo->features,clientinfo->features);
}
-
+
g_free(clientinfo);
}
typedef struct _jabber_caps_cbplususerdata {
jabber_caps_get_info_cb cb;
gpointer user_data;
-
+
char *who;
char *node;
char *ver;
diff --git a/libpurple/protocols/jabber/chat.c b/libpurple/protocols/jabber/chat.c
index 46c9f96..4c2a644 100644
--- a/libpurple/protocols/jabber/chat.c
+++ b/libpurple/protocols/jabber/chat.c
@@ -353,7 +353,7 @@ char *jabber_chat_buddy_real_name(PurpleConnection *gc, int id, const char *who)
jcm = g_hash_table_lookup(chat->members, who);
if (jcm != NULL && jcm->jid)
return g_strdup(jcm->jid);
-
+
return g_strdup_printf("%s@%s/%s", chat->room, chat->server, who);
}
@@ -685,7 +685,7 @@ void jabber_chat_part(JabberChat *chat, const char *msg)
xmlnode_insert_data(status, msg, -1);
}
jabber_send(chat->js, presence);
-
+
xmlnode_free(presence);
g_free(room_jid);
}
@@ -811,7 +811,7 @@ PurpleRoomlist *jabber_roomlist_get_list(PurpleConnection *gc)
FALSE, FALSE, NULL,
_("Find Rooms"), PURPLE_CALLBACK(roomlist_ok_cb),
_("Cancel"), PURPLE_CALLBACK(roomlist_cancel_cb),
- purple_connection_get_account(gc), NULL, NULL,
+ purple_connection_get_account(gc), NULL, NULL,
js);
return js->roomlist;
@@ -1033,7 +1033,7 @@ void jabber_chat_disco_traffic(JabberChat *chat)
iq = jabber_iq_new_query(chat->js, JABBER_IQ_GET,
"http://jabber.org/protocol/disco#info");
- xmlnode_set_attrib(iq->node, "to", room_jid);
+ xmlnode_set_attrib(iq->node, "to", room_jid);
query = xmlnode_get_child(iq->node, "query");
diff --git a/libpurple/protocols/jabber/data.c b/libpurple/protocols/jabber/data.c
index 2064f0a..ba1d91b 100644
--- a/libpurple/protocols/jabber/data.c
+++ b/libpurple/protocols/jabber/data.c
@@ -3,17 +3,17 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA
*/
-
+
#include <stdlib.h>
#include <glib.h>
#include <string.h>
@@ -71,7 +71,7 @@ jabber_data_create_from_xml(xmlnode *tag)
data->cid = g_strdup(xmlnode_get_attrib(tag, "cid"));
data->type = g_strdup(xmlnode_get_attrib(tag, "type"));
-
+
raw_data = xmlnode_get_data(tag);
data->data = purple_base64_decode(raw_data, &size);
data->size = size;
@@ -176,7 +176,7 @@ const JabberData *
jabber_data_find_remote_by_cid(const gchar *cid)
{
purple_debug_info("jabber", "lookup remote smiley with cid = %s\n", cid);
-
+
return g_hash_table_lookup(remote_data_by_cid, cid);
}
@@ -186,7 +186,7 @@ jabber_data_associate_local(JabberData *data, const gchar *alt)
purple_debug_info("jabber", "associating local smiley\n alt = %s, cid = %s\n",
alt, jabber_data_get_cid(data));
g_hash_table_insert(local_data_by_alt, g_strdup(alt), data);
- g_hash_table_insert(local_data_by_cid, g_strdup(jabber_data_get_cid(data)),
+ g_hash_table_insert(local_data_by_cid, g_strdup(jabber_data_get_cid(data)),
data);
}
@@ -195,7 +195,7 @@ jabber_data_associate_remote(JabberData *data)
{
purple_debug_info("jabber", "associating remote smiley, cid = %s\n",
jabber_data_get_cid(data));
- g_hash_table_insert(remote_data_by_cid, g_strdup(jabber_data_get_cid(data)),
+ g_hash_table_insert(remote_data_by_cid, g_strdup(jabber_data_get_cid(data)),
data);
}
diff --git a/libpurple/protocols/jabber/data.h b/libpurple/protocols/jabber/data.h
index 40698de..5134de2 100644
--- a/libpurple/protocols/jabber/data.h
+++ b/libpurple/protocols/jabber/data.h
@@ -3,17 +3,17 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA
*/
-
+
#ifndef JABBER_DATA_H
#define JABBER_DATA_H
diff --git a/libpurple/protocols/jabber/disco.c b/libpurple/protocols/jabber/disco.c
index 71f87cf..85e8524 100644
--- a/libpurple/protocols/jabber/disco.c
+++ b/libpurple/protocols/jabber/disco.c
@@ -132,9 +132,7 @@ void jabber_disco_info_parse(JabberStream *js, xmlnode *packet) {
SUPPORT_FEATURE("http://jabber.org/protocol/bytestreams")
SUPPORT_FEATURE("http://jabber.org/protocol/disco#info")
SUPPORT_FEATURE("http://jabber.org/protocol/disco#items")
-#if 0
- SUPPORT_FEATURE("http://jabber.org/protocol/ibb")
-#endif
+ SUPPORT_FEATURE("http://jabber.org/protocol/ibb");
SUPPORT_FEATURE("http://jabber.org/protocol/muc")
SUPPORT_FEATURE("http://jabber.org/protocol/muc#user")
SUPPORT_FEATURE("http://jabber.org/protocol/si")
@@ -142,7 +140,7 @@ void jabber_disco_info_parse(JabberStream *js, xmlnode *packet) {
SUPPORT_FEATURE("http://jabber.org/protocol/xhtml-im")
SUPPORT_FEATURE("urn:xmpp:ping")
SUPPORT_FEATURE("http://www.xmpp.org/extensions/xep-0199.html#ns")
-
+
if(!node) { /* non-caps disco#info, add all enabled extensions */
GList *features;
for(features = jabber_features; features; features = features->next) {
@@ -168,7 +166,7 @@ void jabber_disco_info_parse(JabberStream *js, xmlnode *packet) {
} else if(node[pos] != CAPS0115_NODE[pos])
break;
}
-
+
if(ext != NULL) {
/* look for that ext */
GList *features;
@@ -183,14 +181,14 @@ void jabber_disco_info_parse(JabberStream *js, xmlnode *packet) {
ext = NULL;
}
}
-
+
if(ext == NULL) {
xmlnode *error, *inf;
-
+
/* XXX: gross hack, implement jabber_iq_set_type or something */
xmlnode_set_attrib(iq->node, "type", "error");
iq->type = JABBER_IQ_ERROR;
-
+
error = xmlnode_new_child(query, "error");
xmlnode_set_attrib(error, "code", "404");
xmlnode_set_attrib(error, "type", "cancel");
@@ -273,6 +271,10 @@ void jabber_disco_info_parse(JabberStream *js, xmlnode *packet) {
else if(!strcmp(var, "http://jabber.org/protocol/commands")) {
capabilities |= JABBER_CAP_ADHOC;
}
+ else if(!strcmp(var, "http://jabber.org/protocol/ibb")) {
+ purple_debug_info("jabber", "remote supports IBB\n");
+ capabilities |= JABBER_CAP_IBB;
+ }
}
}
@@ -316,7 +318,7 @@ void jabber_disco_items_parse(JabberStream *js, xmlnode *packet) {
if(type && !strcmp(type, "get")) {
JabberIq *iq = jabber_iq_new_query(js, JABBER_IQ_RESULT,
"http://jabber.org/protocol/disco#items");
-
+
/* preserve node */
xmlnode *iq_query = xmlnode_get_child_with_namespace(iq->node,"query","http://jabber.org/protocol/disco#items");
if(iq_query) {
diff --git a/libpurple/protocols/jabber/google.c b/libpurple/protocols/jabber/google.c
index b509096..70c184f 100644
--- a/libpurple/protocols/jabber/google.c
+++ b/libpurple/protocols/jabber/google.c
@@ -283,6 +283,7 @@ void jabber_google_roster_add_deny(PurpleConnection *gc, const char *who)
xmlnode *group;
PurpleBuddy *b;
JabberBuddy *jb;
+ const char *balias;
js = (JabberStream*)(gc->proto_data);
@@ -309,13 +310,14 @@ void jabber_google_roster_add_deny(PurpleConnection *gc, const char *who)
g = purple_buddy_get_group(b);
group = xmlnode_new_child(item, "group");
- xmlnode_insert_data(group, g->name, -1);
+ xmlnode_insert_data(group, purple_group_get_name(g), -1);
buddies = buddies->next;
}
+ balias = purple_buddy_get_local_buddy_alias(b);
xmlnode_set_attrib(item, "jid", who);
- xmlnode_set_attrib(item, "name", b->alias ? b->alias : "");
+ xmlnode_set_attrib(item, "name", balias ? balias : "");
xmlnode_set_attrib(item, "gr:t", "B");
xmlnode_set_attrib(query, "xmlns:gr", "google:roster");
xmlnode_set_attrib(query, "gr:ext", "2");
@@ -348,6 +350,7 @@ void jabber_google_roster_rem_deny(PurpleConnection *gc, const char *who)
xmlnode *item;
xmlnode *group;
PurpleBuddy *b;
+ const char *balias;
g_return_if_fail(gc != NULL);
g_return_if_fail(who != NULL);
@@ -357,7 +360,7 @@ void jabber_google_roster_rem_deny(PurpleConnection *gc, const char *who)
if (!js || !js->server_caps & JABBER_CAP_GOOGLE_ROSTER)
return;
- buddies = purple_find_buddies(js->gc->account, who);
+ buddies = purple_find_buddies(purple_connection_get_account(js->gc), who);
if(!buddies)
return;
@@ -375,13 +378,14 @@ void jabber_google_roster_rem_deny(PurpleConnection *gc, const char *who)
g = purple_buddy_get_group(b);
group = xmlnode_new_child(item, "group");
- xmlnode_insert_data(group, g->name, -1);
+ xmlnode_insert_data(group, purple_group_get_name(g), -1);
buddies = buddies->next;
}
+ balias = purple_buddy_get_local_buddy_alias(b);
xmlnode_set_attrib(item, "jid", who);
- xmlnode_set_attrib(item, "name", b->alias ? b->alias : "");
+ xmlnode_set_attrib(item, "name", balias ? balias : "");
xmlnode_set_attrib(query, "xmlns:gr", "google:roster");
xmlnode_set_attrib(query, "gr:ext", "2");
diff --git a/libpurple/protocols/jabber/ibb.c b/libpurple/protocols/jabber/ibb.c
new file mode 100644
index 0000000..2efebed
--- /dev/null
+++ b/libpurple/protocols/jabber/ibb.c
@@ -0,0 +1,521 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA
+ */
+
+#include "internal.h"
+#include "ibb.h"
+#include "debug.h"
+#include "xmlnode.h"
+
+#define JABBER_IBB_SESSION_DEFAULT_BLOCK_SIZE 4096
+
+static GHashTable *jabber_ibb_sessions = NULL;
+static GList *open_handlers = NULL;
+
+JabberIBBSession *
+jabber_ibb_session_create(JabberStream *js, const gchar *sid, const gchar *who,
+ gpointer user_data)
+{
+ JabberIBBSession *sess = g_new0(JabberIBBSession, 1);
+ sess->js = js;
+ if (sid) {
+ sess->sid = g_strdup(sid);
+ } else {
+ sess->sid = jabber_get_next_id(js);
+ }
+ sess->who = g_strdup(who);
+ sess->block_size = JABBER_IBB_SESSION_DEFAULT_BLOCK_SIZE;
+ sess->state = JABBER_IBB_SESSION_NOT_OPENED;
+ sess->user_data = user_data;
+
+ g_hash_table_insert(jabber_ibb_sessions, sess->sid, sess);
+
+ return sess;
+}
+
+JabberIBBSession *
+jabber_ibb_session_create_from_xmlnode(JabberStream *js, xmlnode *packet,
+ gpointer user_data)
+{
+ JabberIBBSession *sess = NULL;
+ xmlnode *open = xmlnode_get_child_with_namespace(packet, "open",
+ XEP_0047_NAMESPACE);
+ const gchar *sid = xmlnode_get_attrib(open, "sid");
+ const gchar *block_size = xmlnode_get_attrib(open, "block-size");
+
+ if (!open) {
+ return NULL;
+ }
+
+ if (!sid || !block_size) {
+ purple_debug_error("jabber",
+ "IBB session open tag requires sid and block-size attributes\n");
+ g_free(sess);
+ return NULL;
+ }
+
+ sess = jabber_ibb_session_create(js, sid,
+ xmlnode_get_attrib(packet, "from"), user_data);
+ sess->id = g_strdup(xmlnode_get_attrib(packet, "id"));
+ sess->block_size = atoi(block_size);
+ /* if we create a session from an incoming <open/> request, it means the
+ session is immediatly open... */
+ sess->state = JABBER_IBB_SESSION_OPENED;
+
+ return sess;
+}
+
+void
+jabber_ibb_session_destroy(JabberIBBSession *sess)
+{
+ purple_debug_info("jabber", "IBB: destroying session %p %s\n", sess,
+ sess->sid);
+
+ if (jabber_ibb_session_get_state(sess) == JABBER_IBB_SESSION_OPENED) {
+ jabber_ibb_session_close(sess);
+ }
+
+ if (sess->last_iq_id) {
+ purple_debug_info("jabber", "IBB: removing callback for <iq/> %s\n",
+ sess->last_iq_id);
+ jabber_iq_remove_callback_by_id(jabber_ibb_session_get_js(sess),
+ sess->last_iq_id);
+ g_free(sess->last_iq_id);
+ sess->last_iq_id = NULL;
+ }
+
+ g_hash_table_remove(jabber_ibb_sessions, sess->sid);
+ g_free(sess->id);
+ g_free(sess->sid);
+ g_free(sess->who);
+ g_free(sess);
+}
+
+const gchar *
+jabber_ibb_session_get_sid(const JabberIBBSession *sess)
+{
+ return sess->sid;
+}
+
+JabberStream *
+jabber_ibb_session_get_js(JabberIBBSession *sess)
+{
+ return sess->js;
+}
+
+const gchar *
+jabber_ibb_session_get_who(const JabberIBBSession *sess)
+{
+ return sess->who;
+}
+
+guint16
+jabber_ibb_session_get_send_seq(const JabberIBBSession *sess)
+{
+ return sess->send_seq;
+}
+
+guint16
+jabber_ibb_session_get_recv_seq(const JabberIBBSession *sess)
+{
+ return sess->recv_seq;
+}
+
+JabberIBBSessionState
+jabber_ibb_session_get_state(const JabberIBBSession *sess)
+{
+ return sess->state;
+}
+
+gsize
+jabber_ibb_session_get_block_size(const JabberIBBSession *sess)
+{
+ return sess->block_size;
+}
+
+void
+jabber_ibb_session_set_block_size(JabberIBBSession *sess, gsize size)
+{
+ if (jabber_ibb_session_get_state(sess) == JABBER_IBB_SESSION_NOT_OPENED) {
+ sess->block_size = size;
+ } else {
+ purple_debug_error("jabber",
+ "Can't set block size on an open IBB session\n");
+ }
+}
+
+gpointer
+jabber_ibb_session_get_user_data(JabberIBBSession *sess)
+{
+ return sess->user_data;
+}
+
+void
+jabber_ibb_session_set_opened_callback(JabberIBBSession *sess,
+ JabberIBBOpenedCallback *cb)
+{
+ sess->opened_cb = cb;
+}
+
+void
+jabber_ibb_session_set_data_sent_callback(JabberIBBSession *sess,
+ JabberIBBSentCallback *cb)
+{
+ sess->data_sent_cb = cb;
+}
+
+void
+jabber_ibb_session_set_closed_callback(JabberIBBSession *sess,
+ JabberIBBClosedCallback *cb)
+{
+ sess->closed_cb = cb;
+}
+
+void
+jabber_ibb_session_set_data_received_callback(JabberIBBSession *sess,
+ JabberIBBDataCallback *cb)
+{
+ sess->data_received_cb = cb;
+}
+
+void
+jabber_ibb_session_set_error_callback(JabberIBBSession *sess,
+ JabberIBBErrorCallback *cb)
+{
+ sess->error_cb = cb;
+}
+
+static void
+jabber_ibb_session_opened_cb(JabberStream *js, xmlnode *packet, gpointer data)
+{
+ JabberIBBSession *sess = (JabberIBBSession *) data;
+
+ if (strcmp(xmlnode_get_attrib(packet, "type"), "error") == 0) {
+ sess->state = JABBER_IBB_SESSION_ERROR;
+ } else {
+ sess->state = JABBER_IBB_SESSION_OPENED;
+ }
+
+ if (sess->opened_cb) {
+ sess->opened_cb(sess);
+ }
+}
+
+void
+jabber_ibb_session_open(JabberIBBSession *sess)
+{
+ if (jabber_ibb_session_get_state(sess) != JABBER_IBB_SESSION_NOT_OPENED) {
+ purple_debug_error("jabber",
+ "jabber_ibb_session called on an already open stream\n");
+ } else {
+ JabberIq *set = jabber_iq_new(sess->js, JABBER_IQ_SET);
+ xmlnode *open = xmlnode_new("open");
+ gchar block_size[10];
+
+ xmlnode_set_attrib(set->node, "to", jabber_ibb_session_get_who(sess));
+ xmlnode_set_namespace(open, XEP_0047_NAMESPACE);
+ xmlnode_set_attrib(open, "sid", jabber_ibb_session_get_sid(sess));
+ g_snprintf(block_size, sizeof(block_size), "%" G_GSIZE_FORMAT,
+ jabber_ibb_session_get_block_size(sess));
+ xmlnode_set_attrib(open, "block-size", block_size);
+ xmlnode_insert_child(set->node, open);
+
+ jabber_iq_set_callback(set, jabber_ibb_session_opened_cb, sess);
+
+ jabber_iq_send(set);
+ }
+}
+
+void
+jabber_ibb_session_close(JabberIBBSession *sess)
+{
+ JabberIBBSessionState state = jabber_ibb_session_get_state(sess);
+
+ if (state != JABBER_IBB_SESSION_OPENED && state != JABBER_IBB_SESSION_ERROR) {
+ purple_debug_error("jabber",
+ "jabber_ibb_session_close called on a session that has not been"
+ "opened\n");
+ } else {
+ JabberIq *set = jabber_iq_new(jabber_ibb_session_get_js(sess),
+ JABBER_IQ_SET);
+ xmlnode *close = xmlnode_new("close");
+
+ xmlnode_set_attrib(set->node, "to", jabber_ibb_session_get_who(sess));
+ xmlnode_set_namespace(close, XEP_0047_NAMESPACE);
+ xmlnode_set_attrib(close, "sid", jabber_ibb_session_get_sid(sess));
+ xmlnode_insert_child(set->node, close);
+ jabber_iq_send(set);
+ sess->state = JABBER_IBB_SESSION_CLOSED;
+ }
+}
+
+void
+jabber_ibb_session_accept(JabberIBBSession *sess)
+{
+ JabberIq *result = jabber_iq_new(jabber_ibb_session_get_js(sess),
+ JABBER_IQ_RESULT);
+
+ xmlnode_set_attrib(result->node, "to", jabber_ibb_session_get_who(sess));
+ jabber_iq_set_id(result, sess->id);
+ jabber_iq_send(result);
+ sess->state = JABBER_IBB_SESSION_OPENED;
+}
+
+static void
+jabber_ibb_session_send_acknowledge_cb(JabberStream *js, xmlnode *packet, gpointer data)
+{
+ JabberIBBSession *sess = (JabberIBBSession *) data;
+ xmlnode *error = xmlnode_get_child(packet, "error");
+
+ if (sess) {
+ /* reset callback */
+ if (sess->last_iq_id) {
+ g_free(sess->last_iq_id);
+ sess->last_iq_id = NULL;
+ }
+
+ if (error) {
+ jabber_ibb_session_close(sess);
+ sess->state = JABBER_IBB_SESSION_ERROR;
+
+ if (sess->error_cb) {
+ sess->error_cb(sess);
+ }
+ } else {
+ if (sess->data_sent_cb) {
+ sess->data_sent_cb(sess);
+ }
+ }
+ } else {
+ /* the session has gone away, it was probably cancelled */
+ purple_debug_info("jabber",
+ "got response from send data, but IBB session is no longer active\n");
+ }
+}
+
+void
+jabber_ibb_session_send_data(JabberIBBSession *sess, gconstpointer data,
+ gsize size)
+{
+ JabberIBBSessionState state = jabber_ibb_session_get_state(sess);
+
+ purple_debug_info("jabber", "sending data block of %" G_GSIZE_FORMAT " bytes on IBB stream\n",
+ size);
+
+ if (state != JABBER_IBB_SESSION_OPENED) {
+ purple_debug_error("jabber",
+ "trying to send data on a non-open IBB session\n");
+ } else if (size > jabber_ibb_session_get_block_size(sess)) {
+ purple_debug_error("jabber",
+ "trying to send a too large packet in the IBB session\n");
+ } else {
+ JabberIq *set = jabber_iq_new(jabber_ibb_session_get_js(sess),
+ JABBER_IQ_SET);
+ xmlnode *data_element = xmlnode_new("data");
+ char *base64 = purple_base64_encode(data, size);
+ char seq[10];
+ g_snprintf(seq, sizeof(seq), "%u", jabber_ibb_session_get_send_seq(sess));
+
+ xmlnode_set_attrib(set->node, "to", jabber_ibb_session_get_who(sess));
+ xmlnode_set_namespace(data_element, XEP_0047_NAMESPACE);
+ xmlnode_set_attrib(data_element, "sid", jabber_ibb_session_get_sid(sess));
+ xmlnode_set_attrib(data_element, "seq", seq);
+ xmlnode_insert_data(data_element, base64, -1);
+
+ xmlnode_insert_child(set->node, data_element);
+
+ purple_debug_info("jabber",
+ "IBB: setting send <iq/> callback for session %p %s\n", sess,
+ sess->sid);
+ jabber_iq_set_callback(set, jabber_ibb_session_send_acknowledge_cb, sess);
+ sess->last_iq_id = g_strdup(xmlnode_get_attrib(set->node, "id"));
+ purple_debug_info("jabber", "IBB: set sess->last_iq_id: %s\n",
+ sess->last_iq_id);
+ jabber_iq_send(set);
+
+ g_free(base64);
+ (sess->send_seq)++;
+ }
+}
+
+static void
+jabber_ibb_send_error_response(JabberStream *js, xmlnode *packet)
+{
+ JabberIq *result = jabber_iq_new(js, JABBER_IQ_ERROR);
+ xmlnode *error = xmlnode_new("error");
+ xmlnode *item_not_found = xmlnode_new("item-not-found");
+
+ xmlnode_set_namespace(item_not_found,
+ "urn:ietf:params:xml:ns:xmpp-stanzas");
+ xmlnode_set_attrib(error, "code", "440");
+ xmlnode_set_attrib(error, "type", "cancel");
+ jabber_iq_set_id(result, xmlnode_get_attrib(packet, "id"));
+ xmlnode_set_attrib(result->node, "to",
+ xmlnode_get_attrib(packet, "from"));
+ xmlnode_insert_child(error, item_not_found);
+ xmlnode_insert_child(result->node, error);
+
+ jabber_iq_send(result);
+}
+
+void
+jabber_ibb_parse(JabberStream *js, xmlnode *packet)
+{
+ xmlnode *data = xmlnode_get_child_with_namespace(packet, "data",
+ XEP_0047_NAMESPACE);
+ xmlnode *close = xmlnode_get_child_with_namespace(packet, "close",
+ XEP_0047_NAMESPACE);
+ xmlnode *open = xmlnode_get_child_with_namespace(packet, "open",
+ XEP_0047_NAMESPACE);
+ const gchar *sid =
+ data ? xmlnode_get_attrib(data, "sid") :
+ close ? xmlnode_get_attrib(close, "sid") : NULL;
+ JabberIBBSession *sess =
+ sid ? g_hash_table_lookup(jabber_ibb_sessions, sid) : NULL;
+ const gchar *who = xmlnode_get_attrib(packet, "from");
+
+ if (sess) {
+
+ if (strcmp(who, jabber_ibb_session_get_who(sess)) != 0) {
+ /* the iq comes from a different JID than the remote JID of the
+ session, ignore it */
+ purple_debug_error("jabber",
+ "Got IBB iq from wrong JID, ignoring\n");
+ } else if (data) {
+ const gchar *seq_attr = xmlnode_get_attrib(data, "seq");
+ guint16 seq = (seq_attr ? atoi(seq_attr) : 0);
+
+ /* reject the data, and set the session in error if we get an
+ out-of-order packet */
+ if (seq_attr && seq == jabber_ibb_session_get_recv_seq(sess)) {
+ /* sequence # is the expected... */
+ JabberIq *result = jabber_iq_new(js, JABBER_IQ_RESULT);
+
+ jabber_iq_set_id(result, xmlnode_get_attrib(packet, "id"));
+ xmlnode_set_attrib(result->node, "to",
+ xmlnode_get_attrib(packet, "from"));
+
+ if (sess->data_received_cb) {
+ gchar *base64 = xmlnode_get_data(data);
+ gsize size;
+ gpointer rawdata = purple_base64_decode(base64, &size);
+
+ g_free(base64);
+
+ if (rawdata) {
+ purple_debug_info("jabber",
+ "got %" G_GSIZE_FORMAT " bytes of data on IBB stream\n",
+ size);
+ if (size > jabber_ibb_session_get_block_size(sess)) {
+ purple_debug_error("jabber",
+ "IBB: received a too large packet\n");
+ if (sess->error_cb)
+ sess->error_cb(sess);
+ g_free(rawdata);
+ return;
+ } else {
+ purple_debug_info("jabber",
+ "calling IBB callback for received data\n");
+ sess->data_received_cb(sess, rawdata, size);
+ }
+ g_free(rawdata);
+ } else {
+ purple_debug_error("jabber",
+ "IBB: invalid BASE64 data received\n");
+ if (sess->error_cb)
+ sess->error_cb(sess);
+ return;
+
+ }
+ }
+
+ (sess->recv_seq)++;
+ jabber_iq_send(result);
+
+ } else {
+ purple_debug_error("jabber",
+ "Received an out-of-order/invalid IBB packet\n");
+ sess->state = JABBER_IBB_SESSION_ERROR;
+
+ if (sess->error_cb) {
+ sess->error_cb(sess);
+ }
+ }
+ } else if (close) {
+ sess->state = JABBER_IBB_SESSION_CLOSED;
+ purple_debug_info("jabber", "IBB: received close\n");
+
+ if (sess->closed_cb) {
+ purple_debug_info("jabber", "IBB: calling closed handler\n");
+ sess->closed_cb(sess);
+ }
+
+ } else {
+ /* this should never happen */
+ purple_debug_error("jabber", "Received bogus iq for IBB session\n");
+ }
+ } else if (open) {
+ JabberIq *result;
+ const GList *iterator;
+
+ /* run all open handlers registered until one returns true */
+ for (iterator = open_handlers ; iterator ;
+ iterator = g_list_next(iterator)) {
+ JabberIBBOpenHandler *handler = iterator->data;
+
+ if (handler(js, packet)) {
+ result = jabber_iq_new(js, JABBER_IQ_RESULT);
+ xmlnode_set_attrib(result->node, "to",
+ xmlnode_get_attrib(packet, "from"));
+ jabber_iq_set_id(result, xmlnode_get_attrib(packet, "id"));
+ jabber_iq_send(result);
+ return;
+ }
+ }
+ /* no open callback returned success, reject */
+ jabber_ibb_send_error_response(js, packet);
+ } else {
+ /* send error reply */
+ jabber_ibb_send_error_response(js, packet);
+ }
+}
+
+void
+jabber_ibb_register_open_handler(JabberIBBOpenHandler *cb)
+{
+ open_handlers = g_list_append(open_handlers, cb);
+}
+
+void
+jabber_ibb_unregister_open_handler(JabberIBBOpenHandler *cb)
+{
+ open_handlers = g_list_remove(open_handlers, cb);
+}
+
+void
+jabber_ibb_init(void)
+{
+ jabber_ibb_sessions = g_hash_table_new(g_str_hash, g_str_equal);
+}
+
+void
+jabber_ibb_uninit(void)
+{
+ g_hash_table_destroy(jabber_ibb_sessions);
+ g_list_free(open_handlers);
+ jabber_ibb_sessions = NULL;
+ open_handlers = NULL;
+}
+
diff --git a/libpurple/protocols/jabber/ibb.h b/libpurple/protocols/jabber/ibb.h
new file mode 100644
index 0000000..b06be47
--- /dev/null
+++ b/libpurple/protocols/jabber/ibb.h
@@ -0,0 +1,119 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA
+ */
+
+#ifndef _PURPLE_JABBER_IBB_H_
+#define _PURPLE_JABBER_IBB_H_
+
+#include "jabber.h"
+#include "iq.h"
+
+#define XEP_0047_NAMESPACE "http://jabber.org/protocol/ibb"
+
+typedef struct _JabberIBBSession JabberIBBSession;
+
+typedef void
+(JabberIBBDataCallback)(JabberIBBSession *, const gpointer data, gsize size);
+
+typedef void (JabberIBBOpenedCallback)(JabberIBBSession *);
+typedef void (JabberIBBClosedCallback)(JabberIBBSession *);
+typedef void (JabberIBBErrorCallback)(JabberIBBSession *);
+typedef void (JabberIBBSentCallback)(JabberIBBSession *);
+
+typedef gboolean (JabberIBBOpenHandler)(JabberStream *js, xmlnode *packet);
+
+typedef enum {
+ JABBER_IBB_SESSION_NOT_OPENED,
+ JABBER_IBB_SESSION_OPENED,
+ JABBER_IBB_SESSION_CLOSED,
+ JABBER_IBB_SESSION_ERROR
+} JabberIBBSessionState;
+
+struct _JabberIBBSession {
+ JabberStream *js;
+ gchar *who;
+ gchar *sid;
+ gchar *id;
+ guint16 send_seq;
+ guint16 recv_seq;
+ gsize block_size;
+
+ /* session state */
+ JabberIBBSessionState state;
+
+ /* user data (f.ex. a handle to a PurpleXfer) */
+ gpointer user_data;
+
+ /* callbacks */
+ JabberIBBOpenedCallback *opened_cb;
+ JabberIBBSentCallback *data_sent_cb;
+ JabberIBBClosedCallback *closed_cb;
+ /* callback for receiving data */
+ JabberIBBDataCallback *data_received_cb;
+ JabberIBBErrorCallback *error_cb;
+
+ /* store the last sent IQ (to permit cancel of callback) */
+ gchar *last_iq_id;
+};
+
+JabberIBBSession *jabber_ibb_session_create(JabberStream *js, const gchar *sid,
+ const gchar *who, gpointer user_data);
+JabberIBBSession *jabber_ibb_session_create_from_xmlnode(JabberStream *js,
+ xmlnode *packet, gpointer user_data);
+
+void jabber_ibb_session_destroy(JabberIBBSession *sess);
+
+void jabber_ibb_session_set_opened_callback(JabberIBBSession *sess,
+ JabberIBBOpenedCallback *cb);
+void jabber_ibb_session_set_data_sent_callback(JabberIBBSession *sess,
+ JabberIBBSentCallback *cb);
+void jabber_ibb_session_set_closed_callback(JabberIBBSession *sess,
+ JabberIBBClosedCallback *cb);
+void jabber_ibb_session_set_data_received_callback(JabberIBBSession *sess,
+ JabberIBBDataCallback *cb);
+void jabber_ibb_session_set_error_callback(JabberIBBSession *sess,
+ JabberIBBErrorCallback *cb);
+
+void jabber_ibb_session_open(JabberIBBSession *sess);
+void jabber_ibb_session_close(JabberIBBSession *sess);
+void jabber_ibb_session_accept(JabberIBBSession *sess);
+void jabber_ibb_session_send_data(JabberIBBSession *sess, gconstpointer data,
+ gsize size);
+
+const gchar *jabber_ibb_session_get_sid(const JabberIBBSession *sess);
+JabberStream *jabber_ibb_session_get_js(JabberIBBSession *sess);
+const gchar *jabber_ibb_session_get_who(const JabberIBBSession *sess);
+
+guint16 jabber_ibb_session_get_send_seq(const JabberIBBSession *sess);
+guint16 jabber_ibb_session_get_recv_seq(const JabberIBBSession *sess);
+
+JabberIBBSessionState jabber_ibb_session_get_state(const JabberIBBSession *sess);
+
+gsize jabber_ibb_session_get_block_size(const JabberIBBSession *sess);
+void jabber_ibb_session_set_block_size(JabberIBBSession *sess, gsize size);
+
+gpointer jabber_ibb_session_get_user_data(JabberIBBSession *sess);
+
+/* handle incoming packet */
+void jabber_ibb_parse(JabberStream *js, xmlnode *packet);
+
+/* add a handler for open session */
+void jabber_ibb_register_open_handler(JabberIBBOpenHandler *cb);
+void jabber_ibb_unregister_open_handler(JabberIBBOpenHandler *cb);
+
+void jabber_ibb_init(void);
+void jabber_ibb_uninit(void);
+
+#endif /* _PURPLE_JABBER_IBB_H_ */
diff --git a/libpurple/protocols/jabber/iq.c b/libpurple/protocols/jabber/iq.c
index 11442ed..33126a4 100644
--- a/libpurple/protocols/jabber/iq.c
+++ b/libpurple/protocols/jabber/iq.c
@@ -34,6 +34,7 @@
#include "ping.h"
#include "adhoccommands.h"
#include "data.h"
+#include "ibb.h"
#ifdef _WIN32
#include "utsname.h"
@@ -393,6 +394,13 @@ void jabber_iq_parse(JabberStream *js, xmlnode *packet)
return;
}
+ if (xmlnode_get_child_with_namespace(packet, "data", XEP_0047_NAMESPACE)
+ || xmlnode_get_child_with_namespace(packet, "close", XEP_0047_NAMESPACE)
+ || xmlnode_get_child_with_namespace(packet, "open", XEP_0047_NAMESPACE)) {
+ jabber_ibb_parse(js, packet);
+ return;
+ }
+
/* If we get here, send the default error reply mandated by XMPP-CORE */
if(!strcmp(type, "set") || !strcmp(type, "get")) {
JabberIq *iq = jabber_iq_new(js, JABBER_IQ_ERROR);
diff --git a/libpurple/protocols/jabber/jabber.c b/libpurple/protocols/jabber/jabber.c
index 0c1732f..14b4a82 100644
--- a/libpurple/protocols/jabber/jabber.c
+++ b/libpurple/protocols/jabber/jabber.c
@@ -184,7 +184,7 @@ static void jabber_stream_features_parse(JabberStream *js, xmlnode *packet)
{
if(xmlnode_get_child(packet, "starttls")) {
if(jabber_process_starttls(js, packet))
-
+
return;
} else if(purple_account_get_bool(js->gc->account, "require_tls", FALSE) && !js->gsc) {
purple_connection_error_reason (js->gc,
@@ -467,10 +467,10 @@ void jabber_keepalive(PurpleConnection *gc)
if (js->keepalive_timeout == -1) {
JabberIq *iq = jabber_iq_new(js, JABBER_IQ_GET);
-
+
xmlnode *ping = xmlnode_new_child(iq->node, "ping");
xmlnode_set_namespace(ping, "urn:xmpp:ping");
-
+
js->keepalive_timeout = purple_timeout_add_seconds(120, (GSourceFunc)(jabber_pong_timeout), gc);
jabber_iq_set_callback(iq, jabber_pong_cb, NULL);
jabber_iq_send(iq);
@@ -578,7 +578,7 @@ jabber_login_callback_ssl(gpointer data, PurpleSslConnection *gsc,
jabber_send_raw(js, "<?xml version='1.0' ?>", -1);
jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING);
purple_ssl_input_add(gsc, jabber_recv_cb_ssl, gc);
-
+
/* Tell the app that we're doing encryption */
jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING_ENCRYPTION);
}
@@ -736,14 +736,14 @@ jabber_login(PurpleAccount *account)
_("Invalid XMPP ID"));
return;
}
-
+
if (!js->user->domain || *(js->user->domain) == '\0') {
purple_connection_error_reason (gc,
PURPLE_CONNECTION_ERROR_INVALID_SETTINGS,
_("Invalid XMPP ID. Domain must be set."));
return;
}
-
+
if((my_jb = jabber_buddy_find(js, purple_account_get_username(account), TRUE)))
my_jb->subscription |= JABBER_SUB_BOTH;
@@ -853,10 +853,10 @@ jabber_unregistration_result_cb(JabberStream *js, xmlnode *packet, gpointer data
g_free(buf);
} else {
char *msg = jabber_parse_error(js, packet, NULL);
-
+
if(!msg)
msg = g_strdup(_("Unknown Error"));
-
+
purple_notify_error(NULL, _("Unregistration Failed"),
_("Unregistration Failed"), msg);
g_free(msg);
@@ -899,9 +899,9 @@ jabber_register_cb(JabberRegisterCBData *cbdata, PurpleRequestFields *fields)
if (cbdata->who)
xmlnode_set_attrib(iq->node,"to",cbdata->who);
xmlnode_new_child(query, "remove");
-
+
jabber_iq_set_callback(iq, jabber_unregistration_result_cb, cbdata->who);
-
+
jabber_iq_send(iq);
g_free(cbdata);
return;
@@ -1031,7 +1031,7 @@ void jabber_register_parse(JabberStream *js, xmlnode *packet)
return;
}
}
-
+
if((x = xmlnode_get_child_with_namespace(query, "x", "jabber:x:data"))) {
jabber_x_data_request(js, x, jabber_register_x_data_cb, g_strdup(from));
return;
@@ -1182,7 +1182,7 @@ void jabber_register_start(JabberStream *js)
void jabber_register_gateway(JabberStream *js, const char *gateway) {
JabberIq *iq;
-
+
iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:register");
xmlnode_set_attrib(iq->node, "to", gateway);
jabber_iq_send(iq);
@@ -1257,7 +1257,7 @@ static void jabber_unregister_account_iq_cb(JabberStream *js, xmlnode *packet, g
const char *type = xmlnode_get_attrib(packet,"type");
if(!strcmp(type,"error")) {
char *msg = jabber_parse_error(js, packet, NULL);
-
+
purple_notify_error(js->gc, _("Error unregistering account"),
_("Error unregistering account"), msg);
g_free(msg);
@@ -1291,7 +1291,7 @@ static void jabber_unregister_account_cb(JabberStream *js) {
void jabber_unregister_account(PurpleAccount *account, PurpleAccountUnregistrationCb cb, void *user_data) {
PurpleConnection *gc = purple_account_get_connection(account);
JabberStream *js;
-
+
if(gc->state != PURPLE_CONNECTED) {
if(gc->state != PURPLE_CONNECTING)
jabber_login(account);
@@ -1301,7 +1301,7 @@ void jabber_unregister_account(PurpleAccount *account, PurpleAccountUnregistrati
js->unregistration_user_data = user_data;
return;
}
-
+
js = gc->proto_data;
if (js->unregistration) {
@@ -1602,10 +1602,10 @@ void jabber_add_feature(const char *shortname, const char *namespace, JabberFeat
feat->shortname = g_strdup(shortname);
feat->namespace = g_strdup(namespace);
feat->is_enabled = cb;
-
+
/* try to remove just in case it already exists in the list */
jabber_remove_feature(shortname);
-
+
jabber_features = g_list_append(jabber_features, feat);
}
@@ -1616,7 +1616,7 @@ void jabber_remove_feature(const char *shortname) {
if(!strcmp(feat->shortname, shortname)) {
g_free(feat->shortname);
g_free(feat->namespace);
-
+
g_free(feature->data);
jabber_features = g_list_delete_link(jabber_features, feature);
break;
@@ -1633,13 +1633,14 @@ const char* jabber_list_emblem(PurpleBuddy *b)
{
JabberStream *js;
JabberBuddy *jb = NULL;
+ PurpleConnection *gc = purple_account_get_connection(purple_buddy_get_account(b));
- if(!b->account->gc)
+ if(!gc)
return NULL;
- js = b->account->gc->proto_data;
+ js = gc->proto_data;
if(js)
- jb = jabber_buddy_find(js, b->name, FALSE);
+ jb = jabber_buddy_find(js, purple_buddy_get_name(b), FALSE);
if(!PURPLE_BUDDY_IS_ONLINE(b)) {
if(jb && (jb->subscription & JABBER_SUB_PENDING ||
@@ -1653,9 +1654,11 @@ char *jabber_status_text(PurpleBuddy *b)
{
char *ret = NULL;
JabberBuddy *jb = NULL;
-
- if (b->account->gc && b->account->gc->proto_data)
- jb = jabber_buddy_find(b->account->gc->proto_data, b->name, FALSE);
+ PurpleAccount *account = purple_buddy_get_account(b);
+ PurpleConnection *gc = purple_account_get_connection(account);
+
+ if (gc && gc->proto_data)
+ jb = jabber_buddy_find(gc->proto_data, purple_buddy_get_name(b), FALSE);
if(jb && !PURPLE_BUDDY_IS_ONLINE(b) && (jb->subscription & JABBER_SUB_PENDING || !(jb->subscription & JABBER_SUB_TO))) {
ret = g_strdup(_("Not Authorized"));
@@ -1684,14 +1687,19 @@ char *jabber_status_text(PurpleBuddy *b)
void jabber_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full)
{
JabberBuddy *jb;
+ PurpleAccount *account;
+ PurpleConnection *gc;
g_return_if_fail(b != NULL);
- g_return_if_fail(b->account != NULL);
- g_return_if_fail(b->account->gc != NULL);
- g_return_if_fail(b->account->gc->proto_data != NULL);
- jb = jabber_buddy_find(b->account->gc->proto_data, b->name,
- FALSE);
+ account = purple_buddy_get_account(b);
+ g_return_if_fail(account != NULL);
+
+ gc = purple_account_get_connection(account);
+ g_return_if_fail(gc != NULL);
+ g_return_if_fail(gc->proto_data != NULL);
+
+ jb = jabber_buddy_find(gc->proto_data, purple_buddy_get_name(b), FALSE);
if(jb) {
JabberBuddyResource *jbr = NULL;
@@ -1799,9 +1807,12 @@ GList *jabber_status_types(PurpleAccount *account)
PurpleStatusType *type;
GList *types = NULL;
PurpleValue *priority_value;
+ PurpleValue *buzz_enabled;
priority_value = purple_value_new(PURPLE_TYPE_INT);
purple_value_set_int(priority_value, 1);
+ buzz_enabled = purple_value_new(PURPLE_TYPE_BOOLEAN);
+ purple_value_set_boolean(buzz_enabled, TRUE);
type = purple_status_type_new_with_attrs(PURPLE_STATUS_AVAILABLE,
jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_ONLINE),
NULL, TRUE, TRUE, FALSE,
@@ -1810,12 +1821,14 @@ GList *jabber_status_types(PurpleAccount *account)
"mood", _("Mood"), purple_value_new(PURPLE_TYPE_STRING),
"moodtext", _("Mood Text"), purple_value_new(PURPLE_TYPE_STRING),
"nick", _("Nickname"), purple_value_new(PURPLE_TYPE_STRING),
- "buzz", _("Allow Buzz"), purple_value_new(PURPLE_TYPE_BOOLEAN),
+ "buzz", _("Allow Buzz"), buzz_enabled,
NULL);
types = g_list_append(types, type);
priority_value = purple_value_new(PURPLE_TYPE_INT);
purple_value_set_int(priority_value, 1);
+ buzz_enabled = purple_value_new(PURPLE_TYPE_BOOLEAN);
+ purple_value_set_boolean(buzz_enabled, TRUE);
type = purple_status_type_new_with_attrs(PURPLE_STATUS_AVAILABLE,
jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_CHAT),
_("Chatty"), TRUE, TRUE, FALSE,
@@ -1824,12 +1837,14 @@ GList *jabber_status_types(PurpleAccount *account)
"mood", _("Mood"), purple_value_new(PURPLE_TYPE_STRING),
"moodtext", _("Mood Text"), purple_value_new(PURPLE_TYPE_STRING),
"nick", _("Nickname"), purple_value_new(PURPLE_TYPE_STRING),
- "buzz", _("Allow Buzz"), purple_value_new(PURPLE_TYPE_BOOLEAN),
+ "buzz", _("Allow Buzz"), buzz_enabled,
NULL);
types = g_list_append(types, type);
priority_value = purple_value_new(PURPLE_TYPE_INT);
purple_value_set_int(priority_value, 0);
+ buzz_enabled = purple_value_new(PURPLE_TYPE_BOOLEAN);
+ purple_value_set_boolean(buzz_enabled, TRUE);
type = purple_status_type_new_with_attrs(PURPLE_STATUS_AWAY,
jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_AWAY),
NULL, TRUE, TRUE, FALSE,
@@ -1838,12 +1853,14 @@ GList *jabber_status_types(PurpleAccount *account)
"mood", _("Mood"), purple_value_new(PURPLE_TYPE_STRING),
"moodtext", _("Mood Text"), purple_value_new(PURPLE_TYPE_STRING),
"nick", _("Nickname"), purple_value_new(PURPLE_TYPE_STRING),
- "buzz", _("Allow Buzz"), purple_value_new(PURPLE_TYPE_BOOLEAN),
+ "buzz", _("Allow Buzz"), buzz_enabled,
NULL);
types = g_list_append(types, type);
priority_value = purple_value_new(PURPLE_TYPE_INT);
purple_value_set_int(priority_value, 0);
+ buzz_enabled = purple_value_new(PURPLE_TYPE_BOOLEAN);
+ purple_value_set_boolean(buzz_enabled, TRUE);
type = purple_status_type_new_with_attrs(PURPLE_STATUS_EXTENDED_AWAY,
jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_XA),
NULL, TRUE, TRUE, FALSE,
@@ -1852,7 +1869,7 @@ GList *jabber_status_types(PurpleAccount *account)
"mood", _("Mood"), purple_value_new(PURPLE_TYPE_STRING),
"moodtext", _("Mood Text"), purple_value_new(PURPLE_TYPE_STRING),
"nick", _("Nickname"), purple_value_new(PURPLE_TYPE_STRING),
- "buzz", _("Allow Buzz"), purple_value_new(PURPLE_TYPE_BOOLEAN),
+ "buzz", _("Allow Buzz"), buzz_enabled,
NULL);
types = g_list_append(types, type);
@@ -1866,7 +1883,6 @@ GList *jabber_status_types(PurpleAccount *account)
"mood", _("Mood"), purple_value_new(PURPLE_TYPE_STRING),
"moodtext", _("Mood Text"), purple_value_new(PURPLE_TYPE_STRING),
"nick", _("Nickname"), purple_value_new(PURPLE_TYPE_STRING),
- "buzz", _("Allow Buzz"), purple_value_new(PURPLE_TYPE_BOOLEAN),
NULL);
types = g_list_append(types, type);
@@ -2012,7 +2028,7 @@ GList *jabber_actions(PurplePlugin *plugin, gpointer context)
if(js->pep)
jabber_pep_init_actions(&m);
-
+
if(js->commands)
jabber_adhoc_init_server_commands(js, &m);
@@ -2027,19 +2043,24 @@ PurpleChat *jabber_find_blist_chat(PurpleAccount *account, const char *name)
if(!(jid = jabber_id_new(name)))
return NULL;
- for(gnode = purple_get_blist()->root; gnode; gnode = gnode->next) {
- for(cnode = gnode->child; cnode; cnode = cnode->next) {
+ for(gnode = purple_blist_get_root(); gnode;
+ gnode = purple_blist_node_get_sibling_next(gnode)) {
+ for(cnode = purple_blist_node_get_first_child(gnode);
+ cnode;
+ cnode = purple_blist_node_get_sibling_next(cnode)) {
PurpleChat *chat = (PurpleChat*)cnode;
const char *room, *server;
+ GHashTable *components;
if(!PURPLE_BLIST_NODE_IS_CHAT(cnode))
continue;
- if(chat->account != account)
+ if (purple_chat_get_account(chat) != account)
continue;
- if(!(room = g_hash_table_lookup(chat->components, "room")))
+ components = purple_chat_get_components(chat);
+ if(!(room = g_hash_table_lookup(components, "room")))
continue;
- if(!(server = g_hash_table_lookup(chat->components, "server")))
+ if(!(server = g_hash_table_lookup(components, "server")))
continue;
if(jid->node && jid->domain &&
@@ -2059,7 +2080,7 @@ void jabber_convo_closed(PurpleConnection *gc, const char *who)
JabberID *jid;
JabberBuddy *jb;
JabberBuddyResource *jbr;
-
+
if(!(jid = jabber_id_new(who)))
return;
@@ -2320,7 +2341,7 @@ static PurpleCmdRet jabber_cmd_chat_affiliate(PurpleConversation *conv,
if (!chat || !args || !args[0] || !args[1])
return PURPLE_CMD_RET_FAILED;
- if (strcmp(args[1], "owner") != 0 &&
+ if (strcmp(args[1], "owner") != 0 &&
strcmp(args[1], "admin") != 0 &&
strcmp(args[1], "member") != 0 &&
strcmp(args[1], "outcast") != 0 &&
@@ -2449,63 +2470,92 @@ static gboolean _jabber_send_buzz(JabberStream *js, const char *username, char *
JabberBuddy *jb;
JabberBuddyResource *jbr;
- GList *iter;
+ PurpleConnection *gc = js->gc;
+ PurpleBuddy *buddy =
+ purple_find_buddy(purple_connection_get_account(gc), username);
+ const gchar *alias =
+ buddy ? purple_buddy_get_contact_alias(buddy) : username;
if(!username)
return FALSE;
jb = jabber_buddy_find(js, username, FALSE);
if(!jb) {
- *error = g_strdup_printf(_("Unable to buzz, because there is nothing known about user %s."), username);
+ *error = g_strdup_printf(_("Unable to buzz, because there is nothing "
+ "known about %s."), alias);
return FALSE;
}
jbr = jabber_buddy_find_resource(jb, NULL);
- if(!jbr) {
- *error = g_strdup_printf(_("Unable to buzz, because user %s might be offline."), username);
- return FALSE;
- }
-
- if(!jbr->caps) {
- *error = g_strdup_printf(_("Unable to buzz, because there is nothing known about user %s."), username);
+ if (!jbr) {
+ *error = g_strdup_printf(_("Unable to buzz, because %s might be offline."),
+ alias);
return FALSE;
}
- for(iter = jbr->caps->features; iter; iter = g_list_next(iter)) {
- if(!strcmp(iter->data, "http://www.xmpp.org/extensions/xep-0224.html#ns")) {
- xmlnode *buzz, *msg = xmlnode_new("message");
- gchar *to;
+ if (jabber_resource_has_capability(jbr, XEP_0224_NAMESPACE)) {
+ xmlnode *buzz, *msg = xmlnode_new("message");
+ gchar *to;
- to = g_strdup_printf("%s/%s", username, jbr->name);
- xmlnode_set_attrib(msg, "to", to);
- g_free(to);
+ to = g_strdup_printf("%s/%s", username, jbr->name);
+ xmlnode_set_attrib(msg, "to", to);
+ g_free(to);
- /* avoid offline storage */
- xmlnode_set_attrib(msg, "type", "headline");
+ /* avoid offline storage */
+ xmlnode_set_attrib(msg, "type", "headline");
- buzz = xmlnode_new_child(msg, "attention");
- xmlnode_set_namespace(buzz, "http://www.xmpp.org/extensions/xep-0224.html#ns");
+ buzz = xmlnode_new_child(msg, "attention");
+ xmlnode_set_namespace(buzz, XEP_0224_NAMESPACE);
- jabber_send(js, msg);
- xmlnode_free(msg);
+ jabber_send(js, msg);
+ xmlnode_free(msg);
- return TRUE;
- }
+ return TRUE;
+ } else {
+ *error = g_strdup_printf(_("Unable to buzz, because %s does "
+ "not support it or does not wish to receive buzzes now."), alias);
+ return FALSE;
}
-
- *error = g_strdup_printf(_("Unable to buzz, because the user %s does not support it."), username);
- return FALSE;
}
static PurpleCmdRet jabber_cmd_buzz(PurpleConversation *conv,
const char *cmd, char **args, char **error, void *data)
{
JabberStream *js = conv->account->gc->proto_data;
+ const gchar *who;
- if(!args || !args[0])
- return PURPLE_CMD_RET_FAILED;
+ if (!args || !args[0]) {
+ /* use the buddy from conversation, if it's a one-to-one conversation */
+ if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) {
+ who = purple_conversation_get_name(conv);
+ } else {
+ return PURPLE_CMD_RET_FAILED;
+ }
+ } else {
+ who = args[0];
+ }
+
+ if (_jabber_send_buzz(js, who, error)) {
+ const gchar *alias;
+ gchar *str;
+ PurpleBuddy *buddy =
+ purple_find_buddy(purple_connection_get_account(conv->account->gc),
+ who);
- return _jabber_send_buzz(js, args[0], error) ? PURPLE_CMD_RET_OK : PURPLE_CMD_RET_FAILED;
+ if (buddy != NULL)
+ alias = purple_buddy_get_contact_alias(buddy);
+ else
+ alias = who;
+
+ str = g_strdup_printf(_("Buzzing %s..."), alias);
+ purple_conversation_write(conv, NULL, str,
+ PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NOTIFY, time(NULL));
+ g_free(str);
+
+ return PURPLE_CMD_RET_OK;
+ } else {
+ return PURPLE_CMD_RET_FAILED;
+ }
}
GList *jabber_attention_types(PurpleAccount *account)
@@ -2618,8 +2668,9 @@ void jabber_register_commands(void)
"prpl-jabber", jabber_cmd_ping,
_("ping &lt;jid&gt;: Ping a user/component/server."),
NULL);
- purple_cmd_register("buzz", "s", PURPLE_CMD_P_PRPL,
- PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_PRPL_ONLY,
+ purple_cmd_register("buzz", "w", PURPLE_CMD_P_PRPL,
+ PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_PRPL_ONLY |
+ PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS,
"prpl-jabber", jabber_cmd_buzz,
_("buzz: Buzz a user to get their attention"), NULL);
}
diff --git a/libpurple/protocols/jabber/jabber.h b/libpurple/protocols/jabber/jabber.h
index 5692525..d616119 100644
--- a/libpurple/protocols/jabber/jabber.h
+++ b/libpurple/protocols/jabber/jabber.h
@@ -203,7 +203,7 @@ struct _JabberStream
gboolean unregistration;
PurpleAccountUnregistrationCb unregistration_cb;
void *unregistration_user_data;
-
+
gboolean vcard_fetched;
/* does the local server support PEP? */
@@ -211,16 +211,16 @@ struct _JabberStream
/* Is Buzz enabled? */
gboolean allowBuzz;
-
+
/* A list of JabberAdHocCommands supported by the server */
GList *commands;
-
+
/* last presence update to check for differences */
JabberBuddyState old_state;
char *old_msg;
int old_priority;
char *old_avatarhash;
-
+
/* same for user tune */
char *old_artist;
char *old_title;
@@ -228,9 +228,9 @@ struct _JabberStream
char *old_uri;
int old_length;
char *old_track;
-
+
char *certificate_CN;
-
+
/* A purple timeout tag for the keepalive */
int keepalive_timeout;
diff --git a/libpurple/protocols/jabber/libxmpp.c b/libpurple/protocols/jabber/libxmpp.c
index cc8c408..46b56c2 100644
--- a/libpurple/protocols/jabber/libxmpp.c
+++ b/libpurple/protocols/jabber/libxmpp.c
@@ -44,6 +44,7 @@
#include "usertune.h"
#include "caps.h"
#include "data.h"
+#include "ibb.h"
static PurplePluginProtocolInfo prpl_info =
{
@@ -137,7 +138,7 @@ static gboolean load_plugin(PurplePlugin *plugin)
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;
}
@@ -146,11 +147,13 @@ 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");
-
+
jabber_data_uninit();
-
+ jabber_si_uninit();
+ jabber_ibb_uninit();
+
return TRUE;
}
@@ -203,30 +206,30 @@ init_plugin(PurplePlugin *plugin)
#endif
PurpleAccountUserSplit *split;
PurpleAccountOption *option;
-
+
/* Translators: 'domain' is used here in the context of Internet domains, e.g. pidgin.im */
split = purple_account_user_split_new(_("Domain"), NULL, '@');
purple_account_user_split_set_reverse(split, FALSE);
prpl_info.user_splits = g_list_append(prpl_info.user_splits, split);
-
+
split = purple_account_user_split_new(_("Resource"), NULL, '/');
purple_account_user_split_set_reverse(split, FALSE);
prpl_info.user_splits = g_list_append(prpl_info.user_splits, split);
-
+
option = purple_account_option_bool_new(_("Require SSL/TLS"), "require_tls", FALSE);
prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
option);
-
+
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);
@@ -272,21 +275,26 @@ init_plugin(PurplePlugin *plugin)
#endif
#endif
jabber_register_commands();
-
+
jabber_iq_init();
jabber_pep_init();
-
+
jabber_tune_init();
jabber_caps_init();
-
+
jabber_data_init();
-
+
+
+ jabber_ibb_init();
+ jabber_si_init();
+
jabber_add_feature("avatarmeta", AVATARNAMESPACEMETA, jabber_pep_namespace_only_when_pep_enabled_cb);
jabber_add_feature("avatardata", AVATARNAMESPACEDATA, jabber_pep_namespace_only_when_pep_enabled_cb);
- jabber_add_feature("buzz", "http://www.xmpp.org/extensions/xep-0224.html#ns",
+ jabber_add_feature("buzz", XEP_0224_NAMESPACE,
jabber_buzz_isenabled);
jabber_add_feature("bob", XEP_0231_NAMESPACE,
jabber_custom_smileys_isenabled);
+ jabber_add_feature("ibb", XEP_0047_NAMESPACE, NULL);
jabber_pep_register_handler("avatar", AVATARNAMESPACEMETA, jabber_buddy_avatar_update_metadata);
}
diff --git a/libpurple/protocols/jabber/message.c b/libpurple/protocols/jabber/message.c
index b0abd03..ed7fdc9 100644
--- a/libpurple/protocols/jabber/message.c
+++ b/libpurple/protocols/jabber/message.c
@@ -118,7 +118,7 @@ static void handle_chat(JabberMessage *jm)
}
}
serv_got_typing_stopped(jm->js->gc, from);
-
+
} else {
serv_got_typing_stopped(jm->js->gc, from);
}
@@ -138,7 +138,7 @@ static void handle_chat(JabberMessage *jm)
g_free(jbr->thread_id);
jbr->thread_id = g_strdup(jbr->thread_id);
}
-
+
if (jm->js->googletalk && jm->xhtml == NULL) {
char *tmp = jm->body;
jm->body = jabber_google_format_to_html(jm->body);
@@ -289,8 +289,6 @@ static void handle_error(JabberMessage *jm)
static void handle_buzz(JabberMessage *jm) {
PurpleBuddy *buddy;
PurpleAccount *account;
- PurpleConversation *c;
- char *username;
/* Delayed buzz MUST NOT be accepted */
if(jm->delayed)
@@ -305,15 +303,8 @@ static void handle_buzz(JabberMessage *jm) {
if ((buddy = purple_find_buddy(account, jm->from)) == NULL)
return; /* Do not accept buzzes from unknown people */
- c = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, jm->from, account);
- if (c == NULL)
- c = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, jm->from);
-
- username = g_markup_escape_text(purple_buddy_get_alias(buddy), -1);
/* xmpp only has 1 attention type, so index is 0 */
- purple_prpl_got_attention(jm->js->gc, username, 0);
-
- g_free(username);
+ purple_prpl_got_attention(jm->js->gc, jm->from, 0);
}
/* used internally by the functions below */
@@ -328,14 +319,14 @@ jabber_message_get_refs_from_xmlnode_internal(const xmlnode *message,
GHashTable *table)
{
xmlnode *child;
-
+
for (child = xmlnode_get_child(message, "img") ; child ;
child = xmlnode_get_next_twin(child)) {
const gchar *src = xmlnode_get_attrib(child, "src");
-
+
if (g_str_has_prefix(src, "cid:")) {
const gchar *cid = src + 4;
-
+
/* if we haven't "fetched" this yet... */
if (!g_hash_table_lookup(table, cid)) {
/* take a copy of the cid and let the SmileyRef own it... */
@@ -343,14 +334,14 @@ jabber_message_get_refs_from_xmlnode_internal(const xmlnode *message,
JabberSmileyRef *ref = g_new0(JabberSmileyRef, 1);
const gchar *alt = xmlnode_get_attrib(child, "alt");
ref->cid = temp_cid;
- /* if there is no "alt" string, use the cid...
+ /* if there is no "alt" string, use the cid...
include the entire src, eg. "cid:.." to avoid linkification */
if (alt && alt[0] != '\0') {
/* workaround for when "alt" is set to the value of the
CID (which Jabbim seems to do), to avoid it showing up
as an mailto: link */
if (purple_email_is_valid(alt)) {
- ref->alt = g_strdup_printf("smiley:%s", alt);
+ ref->alt = g_strdup_printf("smiley:%s", alt);
} else {
ref->alt = g_strdup(alt);
}
@@ -361,7 +352,7 @@ jabber_message_get_refs_from_xmlnode_internal(const xmlnode *message,
}
}
}
-
+
for (child = message->child ; child ; child = child->next) {
jabber_message_get_refs_from_xmlnode_internal(child, table);
}
@@ -372,9 +363,9 @@ jabber_message_get_refs_steal(gpointer key, gpointer value, gpointer user_data)
{
GList **refs = (GList **) user_data;
JabberSmileyRef *ref = (JabberSmileyRef *) value;
-
+
*refs = g_list_append(*refs, ref);
-
+
return TRUE;
}
@@ -383,9 +374,9 @@ jabber_message_get_refs_from_xmlnode(const xmlnode *message)
{
GList *refs = NULL;
GHashTable *unique_refs = g_hash_table_new(g_str_hash, g_str_equal);
-
+
jabber_message_get_refs_from_xmlnode_internal(message, unique_refs);
- (void) g_hash_table_foreach_steal(unique_refs,
+ (void) g_hash_table_foreach_steal(unique_refs,
jabber_message_get_refs_steal, (gpointer) &refs);
g_hash_table_destroy(unique_refs);
return refs;
@@ -518,7 +509,7 @@ jabber_message_get_data_cb(JabberStream *js, xmlnode *packet, gpointer data)
static void
jabber_message_send_data_request(JabberStream *js, PurpleConversation *conv,
- const gchar *cid, const gchar *who,
+ const gchar *cid, const gchar *who,
const gchar *alt)
{
JabberIq *request = jabber_iq_new(js, JABBER_IQ_GET);
@@ -580,7 +571,7 @@ void jabber_message_parse(JabberStream *js, xmlnode *packet)
char *text = xmlnode_get_data(child);
if (!text) {
xmlnode *enclosed_text_node;
-
+
if ((enclosed_text_node = xmlnode_get_child(child, "text")))
text = xmlnode_get_data(enclosed_text_node);
}
@@ -632,7 +623,7 @@ void jabber_message_parse(JabberStream *js, xmlnode *packet)
smiley_refs = jabber_message_get_refs_from_xmlnode(child);
purple_debug_info("jabber", "found %d smileys\n",
g_list_length(smiley_refs));
-
+
if (jm->type == JABBER_MESSAGE_GROUPCHAT) {
JabberID *jid = jabber_id_new(jm->from);
JabberChat *chat = NULL;
@@ -676,7 +667,7 @@ void jabber_message_parse(JabberStream *js, xmlnode *packet)
const gchar *cid = ref->cid;
const gchar *alt = ref->alt;
- purple_debug_info("jabber",
+ purple_debug_info("jabber",
"about to add custom smiley %s to the conv\n", alt);
if (purple_conv_custom_smiley_add(conv, alt, "cid", cid,
TRUE)) {
@@ -684,8 +675,8 @@ void jabber_message_parse(JabberStream *js, xmlnode *packet)
jabber_data_find_remote_by_cid(cid);
/* if data is already known, we add write it immediatly */
if (data) {
- purple_debug_info("jabber",
- "data is already known\n");
+ purple_debug_info("jabber",
+ "data is already known\n");
purple_conv_custom_smiley_write(conv, alt,
jabber_data_get_data(data),
jabber_data_get_size(data));
@@ -731,7 +722,7 @@ void jabber_message_parse(JabberStream *js, xmlnode *packet)
jm->type = JABBER_MESSAGE_EVENT;
for(items = xmlnode_get_child(child,"items"); items; items = items->next)
jm->eventitems = g_list_append(jm->eventitems, items);
- } else if(!strcmp(child->name, "attention") && !strcmp(xmlns,"http://www.xmpp.org/extensions/xep-0224.html#ns")) {
+ } else if(!strcmp(child->name, "attention") && !strcmp(xmlns, XEP_0224_NAMESPACE)) {
jm->hasBuzz = TRUE;
} else if(!strcmp(child->name, "delay") && !strcmp(xmlns,"urn:xmpp:delay")) {
const char *timestamp = xmlnode_get_attrib(child, "stamp");
@@ -910,9 +901,9 @@ jabber_conv_support_custom_smileys(const PurpleConnection *gc,
{
JabberStream *js = (JabberStream *) gc->proto_data;
JabberBuddy *jb;
-
+
if (!js) {
- purple_debug_error("jabber",
+ purple_debug_error("jabber",
"jabber_conv_support_custom_smileys: could not find stream\n");
return FALSE;
}
@@ -965,7 +956,7 @@ void jabber_message_send(JabberMessage *jm)
if(type)
xmlnode_set_attrib(message, "type", type);
-
+
if (jm->id)
xmlnode_set_attrib(message, "id", jm->id);
@@ -1022,7 +1013,7 @@ void jabber_message_send(JabberMessage *jm)
PurpleConversation *conv =
purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, jm->to,
account);
-
+
if (jabber_conv_support_custom_smileys(jm->js->gc, conv, jm->to)) {
GList *found_smileys = jabber_message_xhtml_find_smileys(jm->xhtml);
@@ -1037,19 +1028,19 @@ void jabber_message_send(JabberMessage *jm)
const gchar *shortcut = purple_smiley_get_shortcut(smiley);
const JabberData *data =
jabber_data_find_local_by_alt(shortcut);
-
+
/* the object has not been sent before */
if (!data) {
PurpleStoredImage *image =
purple_smiley_get_stored_image(smiley);
const gchar *ext = purple_imgstore_get_extension(image);
JabberStream *js = jm->js;
-
+
JabberData *new_data =
jabber_data_create_from_data(purple_imgstore_get_data(image),
purple_imgstore_get_size(image),
jabber_message_get_mimetype_from_ext(ext), js);
- purple_debug_info("jabber",
+ purple_debug_info("jabber",
"cache local smiley alt = %s, cid = %s\n",
shortcut, jabber_data_get_cid(new_data));
jabber_data_associate_local(new_data, shortcut);
@@ -1124,7 +1115,7 @@ int jabber_message_send_im(PurpleConnection *gc, const char *who, const char *ms
}
buf = g_strdup_printf("<html xmlns='http://jabber.org/protocol/xhtml-im'><body xmlns='http://www.w3.org/1999/xhtml'>%s</body></html>", msg);
-
+
purple_markup_html_to_xhtml(buf, &xhtml, &jm->body);
g_free(buf);
diff --git a/libpurple/protocols/jabber/message.h b/libpurple/protocols/jabber/message.h
index 550dd1f..b14aa99 100644
--- a/libpurple/protocols/jabber/message.h
+++ b/libpurple/protocols/jabber/message.h
@@ -26,6 +26,8 @@
#include "jabber.h"
#include "xmlnode.h"
+#define XEP_0224_NAMESPACE "urn:xmpp:attention:0"
+
typedef struct _JabberMessage {
JabberStream *js;
enum {
diff --git a/libpurple/protocols/jabber/pep.c b/libpurple/protocols/jabber/pep.c
index fae2223..843e69b 100644
--- a/libpurple/protocols/jabber/pep.c
+++ b/libpurple/protocols/jabber/pep.c
@@ -32,7 +32,7 @@ static GHashTable *pep_handlers = NULL;
void jabber_pep_init(void) {
if(!pep_handlers) {
pep_handlers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
-
+
/* register PEP handlers */
jabber_mood_init();
jabber_nick_init();
@@ -57,31 +57,31 @@ static void do_pep_iq_request_item_callback(JabberStream *js, xmlnode *packet, g
xmlnode *pubsub = xmlnode_get_child_with_namespace(packet,"pubsub","http://jabber.org/protocol/pubsub");
xmlnode *items = NULL;
JabberPEPHandler *cb = data;
-
+
if(pubsub)
items = xmlnode_get_child(pubsub, "items");
-
+
cb(js, from, items);
}
void jabber_pep_request_item(JabberStream *js, const char *to, const char *node, const char *id, JabberPEPHandler cb) {
JabberIq *iq = jabber_iq_new(js, JABBER_IQ_GET);
xmlnode *pubsub, *items, *item;
-
+
xmlnode_set_attrib(iq->node,"to",to);
pubsub = xmlnode_new_child(iq->node,"pubsub");
-
+
xmlnode_set_namespace(pubsub,"http://jabber.org/protocol/pubsub");
-
+
items = xmlnode_new_child(pubsub, "items");
xmlnode_set_attrib(items,"node",node);
-
+
item = xmlnode_new_child(items, "item");
if(id)
xmlnode_set_attrib(item, "id", id);
-
+
jabber_iq_set_callback(iq,do_pep_iq_request_item_callback,(gpointer)cb);
-
+
jabber_iq_send(iq);
}
@@ -94,15 +94,15 @@ void jabber_handle_event(JabberMessage *jm) {
JabberPEPHandler *jph;
GList *itemslist;
char *jid = jabber_get_bare_jid(jm->from);
-
+
for(itemslist = jm->eventitems; itemslist; itemslist = itemslist->next) {
xmlnode *items = (xmlnode*)itemslist->data;
const char *nodename = xmlnode_get_attrib(items,"node");
-
+
if(nodename && (jph = g_hash_table_lookup(pep_handlers, nodename)))
jph(jm->js, jid, items);
}
-
+
/* discard items we don't have a handler for */
g_free(jid);
}
diff --git a/libpurple/protocols/jabber/presence.c b/libpurple/protocols/jabber/presence.c
index a30b9a8..d22e6a0 100644
--- a/libpurple/protocols/jabber/presence.c
+++ b/libpurple/protocols/jabber/presence.c
@@ -136,7 +136,7 @@ void jabber_presence_send(PurpleAccount *account, PurpleStatus *status)
}
purple_status_to_jabber(status, &state, &stripped, &priority);
-
+
/* check for buzz support */
allowBuzz = purple_status_get_attr_boolean(status,"buzz");
/* changing the buzz state has to trigger a re-broadcasting of the presence for caps */
@@ -145,7 +145,7 @@ void jabber_presence_send(PurpleAccount *account, PurpleStatus *status)
tune = purple_presence_get_status(p, "tune");
stripped = jabber_google_presence_outgoing(tune);
}
-
+
#define CHANGED(a,b) ((!a && b) || (a && a[0] == '\0' && b && b[0] != '\0') || \
(a && !b) || (a && a[0] != '\0' && b && b[0] == '\0') || (a && b && strcmp(a,b)))
/* check if there are any differences to the <presence> and send them in that case */
@@ -166,9 +166,9 @@ void jabber_presence_send(PurpleAccount *account, PurpleStatus *status)
g_hash_table_foreach(js->chats, chats_send_presence_foreach, presence);
xmlnode_free(presence);
-
+
/* update old values */
-
+
if(js->old_msg)
g_free(js->old_msg);
if(js->old_avatarhash)
@@ -191,7 +191,7 @@ void jabber_presence_send(PurpleAccount *account, PurpleStatus *status)
length = (!purple_status_get_attr_value(tune, PURPLE_TUNE_TIME)) ? -1 :
purple_status_get_attr_int(tune, PURPLE_TUNE_TIME);
}
-
+
if(CHANGED(artist, js->old_artist) || CHANGED(title, js->old_title) || CHANGED(source, js->old_source) ||
CHANGED(uri, js->old_uri) || CHANGED(track, js->old_track) || (length != js->old_length)) {
PurpleJabberTuneInfo tuneinfo = {
@@ -203,7 +203,7 @@ void jabber_presence_send(PurpleAccount *account, PurpleStatus *status)
(char*)uri
};
jabber_tune_set(js->gc, &tuneinfo);
-
+
/* update old values */
g_free(js->old_artist);
g_free(js->old_title);
@@ -264,27 +264,27 @@ xmlnode *jabber_presence_create_js(JabberStream *js, JabberBuddyState state, con
xmlnode_set_namespace(c, "http://jabber.org/protocol/caps");
xmlnode_set_attrib(c, "node", CAPS0115_NODE);
xmlnode_set_attrib(c, "ver", VERSION);
-
+
if(js != NULL) {
/* add the extensions */
char extlist[1024];
unsigned remaining = 1023; /* one less for the \0 */
GList *feature;
-
+
extlist[0] = '\0';
for(feature = jabber_features; feature && remaining > 0; feature = feature->next) {
JabberFeature *feat = (JabberFeature*)feature->data;
unsigned featlen;
-
+
if(feat->is_enabled != NULL && feat->is_enabled(js, feat->shortname, feat->namespace) == FALSE)
continue; /* skip this feature */
-
+
featlen = strlen(feat->shortname);
-
+
/* cut off when we don't have any more space left in our buffer (too bad) */
if(featlen > remaining)
break;
-
+
strncat(extlist,feat->shortname,remaining);
remaining -= featlen;
if(feature->next) { /* no space at the end */
@@ -296,7 +296,7 @@ xmlnode *jabber_presence_create_js(JabberStream *js, JabberBuddyState state, con
if(remaining < 1023)
xmlnode_set_attrib(c, "ext", extlist);
}
-
+
return presence;
}
@@ -745,7 +745,7 @@ void jabber_presence_parse(JabberStream *js, xmlnode *packet)
const char *node = xmlnode_get_attrib(caps,"node");
const char *ver = xmlnode_get_attrib(caps,"ver");
const char *ext = xmlnode_get_attrib(caps,"ext");
-
+
if(node && ver) {
JabberPresenceCapabilities *userdata = g_new0(JabberPresenceCapabilities, 1);
userdata->js = js;
diff --git a/libpurple/protocols/jabber/roster.c b/libpurple/protocols/jabber/roster.c
index cab8df2..9febc1e 100644
--- a/libpurple/protocols/jabber/roster.c
+++ b/libpurple/protocols/jabber/roster.c
@@ -80,15 +80,16 @@ static void add_purple_buddies_to_groups(JabberStream *js, const char *jid,
buddies = g_slist_remove(buddies, b);
- if((l = g_slist_find_custom(g2, g->name, (GCompareFunc)strcmp))) {
- const char *servernick;
+ if((l = g_slist_find_custom(g2, purple_group_get_name(g), (GCompareFunc)strcmp))) {
+ const char *servernick, *balias;
/* Previously stored serverside / buddy-supplied alias */
if((servernick = purple_blist_node_get_string((PurpleBlistNode*)b, "servernick")))
serv_got_alias(js->gc, jid, servernick);
/* Alias from our roster retrieval */
- if(alias && (!b->alias || strcmp(b->alias, alias)))
+ balias = purple_buddy_get_local_buddy_alias(b);
+ if(alias && (!balias || strcmp(balias, alias)))
purple_serv_got_private_alias(js->gc, jid, alias);
g_free(l->data);
g2 = g_slist_delete_link(g2, l);
@@ -104,7 +105,7 @@ static void add_purple_buddies_to_groups(JabberStream *js, const char *jid,
if (pool) {
b = pool->data;
pool = g_list_delete_link(pool, pool);
- } else {
+ } else {
b = purple_buddy_new(js->gc->account, jid, alias);
}
@@ -119,11 +120,13 @@ static void add_purple_buddies_to_groups(JabberStream *js, const char *jid,
/* If we just learned about ourself, then fake our status,
* because we won't be receiving a normal presence message
* about ourself. */
- if(!strcmp(b->name, my_bare_jid)) {
+ if(!strcmp(purple_buddy_get_name(b), my_bare_jid)) {
PurplePresence *gpresence;
PurpleStatus *status;
+ PurpleAccount *account;
- gpresence = purple_account_get_presence(js->gc->account);
+ account = purple_connection_get_account(js->gc);
+ gpresence = purple_account_get_presence(account);
status = purple_presence_get_active_status(gpresence);
jabber_presence_fake_to_self(js, status);
}
@@ -273,6 +276,7 @@ static void jabber_roster_update(JabberStream *js, const char *name,
GSList *groups = NULL, *l;
JabberIq *iq;
xmlnode *query, *item, *group;
+ const char *balias;
if (js->currently_parsing_roster_push)
return;
@@ -289,7 +293,7 @@ static void jabber_roster_update(JabberStream *js, const char *name,
while(buddies) {
b = buddies->data;
g = purple_buddy_get_group(b);
- groups = g_slist_append(groups, g->name);
+ groups = g_slist_append(groups, (char *)purple_group_get_name(g));
buddies = g_slist_remove(buddies, b);
}
}
@@ -301,7 +305,8 @@ static void jabber_roster_update(JabberStream *js, const char *name,
xmlnode_set_attrib(item, "jid", name);
- xmlnode_set_attrib(item, "name", b->alias ? b->alias : "");
+ balias = purple_buddy_get_local_buddy_alias(b);
+ xmlnode_set_attrib(item, "name", balias ? balias : "");
for(l = groups; l; l = l->next) {
group = xmlnode_new_child(item, "group");
@@ -310,7 +315,7 @@ static void jabber_roster_update(JabberStream *js, const char *name,
if(!grps)
g_slist_free(groups);
-
+
if (js->server_caps & JABBER_CAP_GOOGLE_ROSTER) {
jabber_google_roster_outgoing(js, query, item);
xmlnode_set_attrib(query, "xmlns:gr", "google:roster");
@@ -327,14 +332,16 @@ void jabber_roster_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy,
JabberBuddy *jb;
JabberBuddyResource *jbr;
char *my_bare_jid;
+ const char *name;
if(!js->roster_parsed)
return;
- if(!(who = jabber_get_bare_jid(buddy->name)))
+ name = purple_buddy_get_name(buddy);
+ if(!(who = jabber_get_bare_jid(name)))
return;
- jb = jabber_buddy_find(js, buddy->name, FALSE);
+ jb = jabber_buddy_find(js, name, FALSE);
jabber_roster_update(js, who, NULL);
@@ -375,6 +382,7 @@ void jabber_roster_group_change(PurpleConnection *gc, const char *name,
GSList *buddies, *groups = NULL;
PurpleBuddy *b;
PurpleGroup *g;
+ const char *gname;
if(!old_group || !new_group || !strcmp(old_group, new_group))
return;
@@ -383,10 +391,11 @@ void jabber_roster_group_change(PurpleConnection *gc, const char *name,
while(buddies) {
b = buddies->data;
g = purple_buddy_get_group(b);
- if(!strcmp(g->name, old_group))
+ gname = purple_group_get_name(g);
+ if(!strcmp(gname, old_group))
groups = g_slist_append(groups, (char*)new_group); /* ick */
else
- groups = g_slist_append(groups, g->name);
+ groups = g_slist_append(groups, (char*)gname);
buddies = g_slist_remove(buddies, b);
}
jabber_roster_update(gc->proto_data, name, groups);
@@ -397,15 +406,17 @@ void jabber_roster_group_rename(PurpleConnection *gc, const char *old_name,
PurpleGroup *group, GList *moved_buddies)
{
GList *l;
+ const char *gname = purple_group_get_name(group);
for(l = moved_buddies; l; l = l->next) {
PurpleBuddy *buddy = l->data;
- jabber_roster_group_change(gc, buddy->name, old_name, group->name);
+ jabber_roster_group_change(gc, purple_buddy_get_name(buddy), old_name, gname);
}
}
void jabber_roster_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy,
PurpleGroup *group) {
- GSList *buddies = purple_find_buddies(gc->account, buddy->name);
+ const char *name = purple_buddy_get_name(buddy);
+ GSList *buddies = purple_find_buddies(purple_connection_get_account(gc), name);
buddies = g_slist_remove(buddies, buddy);
if(buddies != NULL) {
@@ -416,11 +427,11 @@ void jabber_roster_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy,
while(buddies) {
tmpbuddy = buddies->data;
tmpgroup = purple_buddy_get_group(tmpbuddy);
- groups = g_slist_append(groups, tmpgroup->name);
+ groups = g_slist_append(groups, (char *)purple_group_get_name(tmpgroup));
buddies = g_slist_remove(buddies, tmpbuddy);
}
- jabber_roster_update(gc->proto_data, buddy->name, groups);
+ jabber_roster_update(gc->proto_data, name, groups);
g_slist_free(groups);
} else {
JabberIq *iq = jabber_iq_new_query(gc->proto_data, JABBER_IQ_SET,
@@ -428,7 +439,7 @@ void jabber_roster_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy,
xmlnode *query = xmlnode_get_child(iq->node, "query");
xmlnode *item = xmlnode_new_child(query, "item");
- xmlnode_set_attrib(item, "jid", buddy->name);
+ xmlnode_set_attrib(item, "jid", name);
xmlnode_set_attrib(item, "subscription", "remove");
jabber_iq_send(iq);
diff --git a/libpurple/protocols/jabber/si.c b/libpurple/protocols/jabber/si.c
index 02a7922..d4560a0 100644
--- a/libpurple/protocols/jabber/si.c
+++ b/libpurple/protocols/jabber/si.c
@@ -32,6 +32,7 @@
#include "buddy.h"
#include "disco.h"
#include "jabber.h"
+#include "ibb.h"
#include "iq.h"
#include "si.h"
@@ -63,8 +64,15 @@ typedef struct _JabberSIXfer {
size_t rxlen;
gsize rxmaxlen;
int local_streamhost_fd;
+
+ JabberIBBSession *ibb_session;
+ guint ibb_timeout_handle;
+ FILE *fp;
} JabberSIXfer;
+/* some forward declarations */
+static void jabber_si_xfer_ibb_send_init(JabberStream *js, PurpleXfer *xfer);
+
static PurpleXfer*
jabber_si_xfer_find(JabberStream *js, const char *sid, const char *from)
{
@@ -178,6 +186,32 @@ connect_timeout_cb(gpointer data)
return FALSE;
}
+static void
+jabber_si_bytestreams_ibb_timeout_remove(JabberSIXfer *jsx)
+{
+ if (jsx->ibb_timeout_handle) {
+ purple_timeout_remove(jsx->ibb_timeout_handle);
+ jsx->ibb_timeout_handle = 0;
+ }
+}
+
+static gboolean
+jabber_si_bytestreams_ibb_timeout_cb(gpointer data)
+{
+ PurpleXfer *xfer = (PurpleXfer *) data;
+ JabberSIXfer *jsx = xfer->data;
+
+ if (jsx && !jsx->ibb_session) {
+ purple_debug_info("jabber",
+ "jabber_si_bytestreams_ibb_timeout called and IBB session not set "
+ " up yet, cancel transfer");
+ jabber_si_bytestreams_ibb_timeout_remove(jsx);
+ purple_xfer_cancel_local(xfer);
+ }
+
+ return FALSE;
+}
+
static void jabber_si_bytestreams_attempt_connect(PurpleXfer *xfer)
{
JabberSIXfer *jsx = xfer->data;
@@ -200,7 +234,28 @@ static void jabber_si_bytestreams_attempt_connect(PurpleXfer *xfer)
jabber_iq_send(iq);
- purple_xfer_cancel_local(xfer);
+ /* if IBB is available, revert to that before giving up... */
+ if (jsx->stream_method & STREAM_METHOD_IBB) {
+ /* if we are the initializer, init IBB */
+ purple_debug_info("jabber",
+ "jabber_si_bytestreams_attempt_connect: "
+ "no streamhosts found, trying IBB\n");
+ /* if we are the sender, open an IBB session, but not if we already
+ did it, since we could have received the error <iq/> from the
+ receiver already... */
+ if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND
+ && !jsx->ibb_session) {
+ jabber_si_xfer_ibb_send_init(jsx->js, xfer);
+ } else {
+ /* setup a timeout to cancel waiting for IBB open */
+ jsx->ibb_timeout_handle = purple_timeout_add_seconds(30,
+ jabber_si_bytestreams_ibb_timeout_cb, xfer);
+ }
+ /* if we are the receiver, just wait for IBB open, callback is
+ already set up... */
+ } else {
+ purple_xfer_cancel_local(xfer);
+ }
return;
}
@@ -654,8 +709,32 @@ jabber_si_connect_proxy_cb(JabberStream *js, xmlnode *packet,
jsx = xfer->data;
if(!(type = xmlnode_get_attrib(packet, "type")) || strcmp(type, "result")) {
- if (type && !strcmp(type, "error"))
- purple_xfer_cancel_remote(xfer);
+ purple_debug_info("jabber",
+ "jabber_si_xfer_connect_proxy_cb: type = %s\n",
+ type);
+ if (type && !strcmp(type, "error")) {
+ /* if IBB is available, open IBB session */
+ purple_debug_info("jabber",
+ "jabber_si_xfer_connect_proxy_cb: got error, method: %d\n",
+ jsx->stream_method);
+ if (jsx->stream_method & STREAM_METHOD_IBB) {
+ purple_debug_info("jabber", "IBB is possible, try it\n");
+ /* if we are the sender and haven't already opened an IBB
+ session, do so now (we might already have failed to open
+ the bytestream proxy ourselves when receiving this <iq/> */
+ if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND
+ && !jsx->ibb_session) {
+ jabber_si_xfer_ibb_send_init(js, xfer);
+ } else {
+ jsx->ibb_timeout_handle = purple_timeout_add_seconds(30,
+ jabber_si_bytestreams_ibb_timeout_cb, xfer);
+ }
+ /* if we are receiver, just wait for IBB open stanza, callback
+ is already set up */
+ } else {
+ purple_xfer_cancel_remote(xfer);
+ }
+ }
return;
}
@@ -682,8 +761,22 @@ jabber_si_connect_proxy_cb(JabberStream *js, xmlnode *packet,
purple_debug_info("jabber", "Got local SOCKS5 streamhost-used.\n");
purple_xfer_start(xfer, xfer->fd, NULL, -1);
} else {
- purple_debug_info("jabber", "streamhost-used does not match any proxy that was offered to target\n");
- purple_xfer_cancel_local(xfer);
+ /* if available, try to revert to IBB... */
+ if (jsx->stream_method & STREAM_METHOD_IBB) {
+ purple_debug_info("jabber",
+ "jabber_si_connect_proxy_cb: trying to revert to IBB\n");
+ if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) {
+ jabber_si_xfer_ibb_send_init(jsx->js, xfer);
+ } else {
+ jsx->ibb_timeout_handle = purple_timeout_add_seconds(30,
+ jabber_si_bytestreams_ibb_timeout_cb, xfer);
+ }
+ /* if we are the receiver, we are already set up...*/
+ } else {
+ purple_debug_info("jabber",
+ "streamhost-used does not match any proxy that was offered to target\n");
+ purple_xfer_cancel_local(xfer);
+ }
}
g_free(my_jid);
return;
@@ -810,8 +903,26 @@ jabber_si_xfer_bytestreams_listen_cb(int sock, gpointer data)
/* We have no way of transferring, cancel the transfer */
if (streamhost_count == 0) {
jabber_iq_free(iq);
- /* We should probably notify the target, but this really shouldn't ever happen */
- purple_xfer_cancel_local(xfer);
+
+ /* if available, revert to IBB */
+ if (jsx->stream_method & STREAM_METHOD_IBB) {
+ purple_debug_info("jabber",
+ "jabber_si_xfer_bytestreams_listen_cb: trying to revert to IBB\n");
+ if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) {
+ /* if we are the sender, init the IBB session... */
+ jabber_si_xfer_ibb_send_init(jsx->js, xfer);
+ } else {
+ jsx->ibb_timeout_handle = purple_timeout_add_seconds(30,
+ jabber_si_bytestreams_ibb_timeout_cb, xfer);
+ }
+ /* if we are the receiver, we should just wait... the IBB open
+ handler has already been set up... */
+ } else {
+ /* We should probably notify the target,
+ but this really shouldn't ever happen */
+ purple_xfer_cancel_local(xfer);
+ }
+
return;
}
@@ -841,11 +952,242 @@ jabber_si_xfer_bytestreams_send_init(PurpleXfer *xfer)
}
+static void
+jabber_si_xfer_ibb_error_cb(JabberIBBSession *sess)
+{
+ PurpleXfer *xfer = (PurpleXfer *) jabber_ibb_session_get_user_data(sess);
+ JabberStream *js = jabber_ibb_session_get_js(sess);
+ PurpleConnection *gc = js->gc;
+ PurpleAccount *account = purple_connection_get_account(gc);
+
+ purple_debug_error("jabber", "an error occured during IBB file transfer\n");
+ purple_xfer_error(purple_xfer_get_type(xfer), account,
+ jabber_ibb_session_get_who(sess),
+ _("An error occured on the in-band bytestream transfer\n"));
+ purple_xfer_cancel_remote(xfer);
+}
+
+static void
+jabber_si_xfer_ibb_closed_cb(JabberIBBSession *sess)
+{
+ PurpleXfer *xfer = (PurpleXfer *) jabber_ibb_session_get_user_data(sess);
+ JabberStream *js = jabber_ibb_session_get_js(sess);
+ PurpleConnection *gc = js->gc;
+ PurpleAccount *account = purple_connection_get_account(gc);
+
+ purple_debug_info("jabber", "the remote user closed the transfer\n");
+ if (purple_xfer_get_bytes_remaining(xfer) > 0) {
+ purple_xfer_error(purple_xfer_get_type(xfer), account,
+ jabber_ibb_session_get_who(sess), _("Transfer was closed."));
+ purple_xfer_cancel_remote(xfer);
+ } else {
+ purple_xfer_set_completed(xfer, TRUE);
+ purple_xfer_end(xfer);
+ }
+}
+
+static void
+jabber_si_xfer_ibb_recv_data_cb(JabberIBBSession *sess, gpointer data,
+ gsize size)
+{
+ PurpleXfer *xfer = (PurpleXfer *) jabber_ibb_session_get_user_data(sess);
+ JabberSIXfer *jsx = (JabberSIXfer *) xfer->data;
+
+ if (size <= purple_xfer_get_bytes_remaining(xfer)) {
+ purple_debug_info("jabber", "about to write %" G_GSIZE_FORMAT " bytes from IBB stream\n",
+ size);
+ if(!fwrite(data, size, 1, jsx->fp)) {
+ purple_debug_error("jabber", "error writing to file\n");
+ purple_xfer_cancel_remote(xfer);
+ return;
+ }
+ purple_xfer_set_bytes_sent(xfer, purple_xfer_get_bytes_sent(xfer) + size);
+ purple_xfer_update_progress(xfer);
+
+ if (purple_xfer_get_bytes_remaining(xfer) == 0) {
+ purple_xfer_set_completed(xfer, TRUE);
+ purple_xfer_end(xfer);
+ }
+ } else {
+ /* trying to write past size of file transfers negotiated size,
+ reject transfer to protect against malicious behaviour */
+ purple_debug_error("jabber",
+ "IBB file transfer send more data than expected\n");
+ purple_xfer_cancel_remote(xfer);
+ }
+
+}
+
+static gboolean
+jabber_si_xfer_ibb_open_cb(JabberStream *js, xmlnode *packet)
+{
+ const gchar *who = xmlnode_get_attrib(packet, "from");
+ xmlnode *open = xmlnode_get_child(packet, "open");
+ const gchar *sid = xmlnode_get_attrib(open, "sid");
+ PurpleXfer *xfer = jabber_si_xfer_find(js, sid, who);
+ if (xfer) {
+ JabberSIXfer *jsx = (JabberSIXfer *) xfer->data;
+ JabberIBBSession *sess =
+ jabber_ibb_session_create_from_xmlnode(js, packet, xfer);
+ const char *filename;
+
+ jabber_si_bytestreams_ibb_timeout_remove(jsx);
+
+ if (sess) {
+ /* open the file to write to */
+ filename = purple_xfer_get_local_filename(xfer);
+ jsx->fp = g_fopen(filename, "wb");
+ if (jsx->fp == NULL) {
+ purple_debug_error("jabber", "failed to open file %s for writing: %s\n",
+ filename, g_strerror(errno));
+ purple_xfer_cancel_remote(xfer);
+ return FALSE;
+ }
+
+ /* setup callbacks here...*/
+ jabber_ibb_session_set_data_received_callback(sess,
+ jabber_si_xfer_ibb_recv_data_cb);
+ jabber_ibb_session_set_closed_callback(sess,
+ jabber_si_xfer_ibb_closed_cb);
+ jabber_ibb_session_set_error_callback(sess,
+ jabber_si_xfer_ibb_error_cb);
+
+ jsx->ibb_session = sess;
+
+ /* start the transfer */
+ purple_xfer_start(xfer, 0, NULL, 0);
+ return TRUE;
+ } else {
+ /* failed to create IBB session */
+ purple_debug_error("jabber", "failed to create IBB session\n");
+ purple_xfer_cancel_remote(xfer);
+ return FALSE;
+ }
+ } else {
+ /* we got an IBB <open/> for an unknown file transfer, pass along... */
+ purple_debug_info("jabber",
+ "IBB open did not match any SI file transfer\n");
+ return FALSE;
+ }
+}
+
+static void
+jabber_si_xfer_ibb_send_data(JabberIBBSession *sess)
+{
+ PurpleXfer *xfer = (PurpleXfer *) jabber_ibb_session_get_user_data(sess);
+ JabberSIXfer *jsx = (JabberSIXfer *) xfer->data;
+ gsize remaining = purple_xfer_get_bytes_remaining(xfer);
+ gsize packet_size = remaining < jabber_ibb_session_get_block_size(sess) ?
+ remaining : jabber_ibb_session_get_block_size(sess);
+ gpointer data = g_malloc(packet_size);
+ int res;
+
+ purple_debug_info("jabber", "IBB: about to read %" G_GSIZE_FORMAT " bytes from file %p\n",
+ packet_size, jsx->fp);
+ res = fread(data, packet_size, 1, jsx->fp);
+
+ if (res == 1) {
+ jabber_ibb_session_send_data(sess, data, packet_size);
+ purple_xfer_set_bytes_sent(xfer,
+ purple_xfer_get_bytes_sent(xfer) + packet_size);
+ purple_xfer_update_progress(xfer);
+ } else {
+ purple_debug_error("jabber",
+ "jabber_si_xfer_ibb_send_data: error reading from file\n");
+ purple_xfer_cancel_local(xfer);
+ }
+}
+
+static void
+jabber_si_xfer_ibb_sent_cb(JabberIBBSession *sess)
+{
+ PurpleXfer *xfer = (PurpleXfer *) jabber_ibb_session_get_user_data(sess);
+ gsize remaining = purple_xfer_get_bytes_remaining(xfer);
+
+ if (remaining == 0) {
+ /* close the session */
+ jabber_ibb_session_close(sess);
+ purple_xfer_set_completed(xfer, TRUE);
+ purple_xfer_end(xfer);
+ } else {
+ /* send more... */
+ jabber_si_xfer_ibb_send_data(sess);
+ }
+}
+
+static void
+jabber_si_xfer_ibb_opened_cb(JabberIBBSession *sess)
+{
+ PurpleXfer *xfer = (PurpleXfer *) jabber_ibb_session_get_user_data(sess);
+ JabberSIXfer *jsx = (JabberSIXfer *) xfer->data;
+ JabberStream *js = jabber_ibb_session_get_js(sess);
+ PurpleConnection *gc = js->gc;
+ PurpleAccount *account = purple_connection_get_account(gc);
+
+ if (jabber_ibb_session_get_state(sess) == JABBER_IBB_SESSION_OPENED) {
+ const char *filename = purple_xfer_get_local_filename(xfer);
+ jsx->fp = g_fopen(filename, "rb");
+ if (jsx->fp == NULL) {
+ purple_debug_error("jabber", "Failed to open file %s for reading: %s\n",
+ filename, g_strerror(errno));
+ purple_xfer_error(purple_xfer_get_type(xfer), account,
+ jabber_ibb_session_get_who(sess),
+ _("Failed to open the file"));
+ purple_xfer_cancel_local(xfer);
+ return;
+ }
+
+ purple_xfer_start(xfer, 0, NULL, 0);
+ purple_xfer_set_bytes_sent(xfer, 0);
+ purple_xfer_update_progress(xfer);
+ jabber_si_xfer_ibb_send_data(sess);
+ } else {
+ /* error */
+ purple_xfer_error(purple_xfer_get_type(xfer), account,
+ jabber_ibb_session_get_who(sess),
+ _("Failed to open in-band bytestream"));
+ purple_xfer_end(xfer);
+ }
+}
+
+static void
+jabber_si_xfer_ibb_send_init(JabberStream *js, PurpleXfer *xfer)
+{
+ JabberSIXfer *jsx = (JabberSIXfer *) xfer->data;
+
+ purple_xfer_ref(xfer);
+
+ jsx->ibb_session = jabber_ibb_session_create(js, jsx->stream_id,
+ purple_xfer_get_remote_user(xfer), xfer);
+
+ if (jsx->ibb_session) {
+ /* should set callbacks here... */
+ jabber_ibb_session_set_opened_callback(jsx->ibb_session,
+ jabber_si_xfer_ibb_opened_cb);
+ jabber_ibb_session_set_data_sent_callback(jsx->ibb_session,
+ jabber_si_xfer_ibb_sent_cb);
+ jabber_ibb_session_set_closed_callback(jsx->ibb_session,
+ jabber_si_xfer_ibb_closed_cb);
+ jabber_ibb_session_set_error_callback(jsx->ibb_session,
+ jabber_si_xfer_ibb_error_cb);
+
+ /* open the IBB session */
+ jabber_ibb_session_open(jsx->ibb_session);
+
+ } else {
+ /* failed to create IBB session */
+ purple_debug_error("jabber",
+ "failed to initiate IBB session for file transfer\n");
+ purple_xfer_cancel_local(xfer);
+ }
+}
+
static void jabber_si_xfer_send_method_cb(JabberStream *js, xmlnode *packet,
gpointer data)
{
PurpleXfer *xfer = data;
xmlnode *si, *feature, *x, *field, *value;
+ gboolean found_method = FALSE;
if(!(si = xmlnode_get_child_with_namespace(packet, "si", "http://jabber.org/protocol/si"))) {
purple_xfer_cancel_remote(xfer);
@@ -864,20 +1206,33 @@ static void jabber_si_xfer_send_method_cb(JabberStream *js, xmlnode *packet,
for(field = xmlnode_get_child(x, "field"); field; field = xmlnode_get_next_twin(field)) {
const char *var = xmlnode_get_attrib(field, "var");
+ JabberSIXfer *jsx = (JabberSIXfer *) xfer->data;
if(var && !strcmp(var, "stream-method")) {
if((value = xmlnode_get_child(field, "value"))) {
char *val = xmlnode_get_data(value);
if(val && !strcmp(val, "http://jabber.org/protocol/bytestreams")) {
jabber_si_xfer_bytestreams_send_init(xfer);
- g_free(val);
- return;
+ jsx->stream_method |= STREAM_METHOD_BYTESTREAMS;
+ found_method = TRUE;
+ } else if (val && !strcmp(val, XEP_0047_NAMESPACE)) {
+ jsx->stream_method |= STREAM_METHOD_IBB;
+ if (!found_method) {
+ /* we haven't tried to init a bytestream session, yet
+ start IBB right away... */
+ jabber_si_xfer_ibb_send_init(js, xfer);
+ found_method = TRUE;
+ }
}
g_free(val);
}
}
}
- purple_xfer_cancel_remote(xfer);
+
+ if (!found_method) {
+ purple_xfer_cancel_remote(xfer);
+ }
+
}
static void jabber_si_xfer_send_request(PurpleXfer *xfer)
@@ -914,14 +1269,14 @@ static void jabber_si_xfer_send_request(PurpleXfer *xfer)
field = xmlnode_new_child(x, "field");
xmlnode_set_attrib(field, "var", "stream-method");
xmlnode_set_attrib(field, "type", "list-single");
+ /* maybe we should add an option to always skip bytestreams for people
+ behind troublesome firewalls */
option = xmlnode_new_child(field, "option");
value = xmlnode_new_child(option, "value");
xmlnode_insert_data(value, "http://jabber.org/protocol/bytestreams", -1);
- /*
option = xmlnode_new_child(field, "option");
value = xmlnode_new_child(option, "value");
xmlnode_insert_data(value, "http://jabber.org/protocol/ibb", -1);
- */
jabber_iq_set_callback(iq, jabber_si_xfer_send_method_cb, xfer);
@@ -935,38 +1290,66 @@ static void jabber_si_xfer_send_request(PurpleXfer *xfer)
static void jabber_si_xfer_free(PurpleXfer *xfer)
{
JabberSIXfer *jsx = xfer->data;
- JabberStream *js = jsx->js;
- js->file_transfers = g_list_remove(js->file_transfers, xfer);
+ if (jsx) {
+ JabberStream *js = jsx->js;
+
+ js->file_transfers = g_list_remove(js->file_transfers, xfer);
+
+ if (jsx->connect_data != NULL)
+ purple_proxy_connect_cancel(jsx->connect_data);
+ if (jsx->listen_data != NULL)
+ purple_network_listen_cancel(jsx->listen_data);
+ if (jsx->iq_id != NULL)
+ jabber_iq_remove_callback_by_id(js, jsx->iq_id);
+ if (jsx->local_streamhost_fd >= 0)
+ close(jsx->local_streamhost_fd);
+ if (jsx->connect_timeout > 0)
+ purple_timeout_remove(jsx->connect_timeout);
+ if (jsx->ibb_timeout_handle > 0)
+ purple_timeout_remove(jsx->ibb_timeout_handle);
+
+ if (jsx->streamhosts) {
+ g_list_foreach(jsx->streamhosts, jabber_si_free_streamhost, NULL);
+ g_list_free(jsx->streamhosts);
+ }
- if (jsx->connect_data != NULL)
- purple_proxy_connect_cancel(jsx->connect_data);
- if (jsx->listen_data != NULL)
- purple_network_listen_cancel(jsx->listen_data);
- if (jsx->iq_id != NULL)
- jabber_iq_remove_callback_by_id(js, jsx->iq_id);
- if (jsx->local_streamhost_fd >= 0)
- close(jsx->local_streamhost_fd);
- if (jsx->connect_timeout > 0)
- purple_timeout_remove(jsx->connect_timeout);
+ if (jsx->ibb_session) {
+ purple_debug_info("jabber",
+ "jabber_si_xfer_free: destroying IBB session\n");
+ jabber_ibb_session_destroy(jsx->ibb_session);
+ }
- if (jsx->streamhosts) {
- g_list_foreach(jsx->streamhosts, jabber_si_free_streamhost, NULL);
- g_list_free(jsx->streamhosts);
- }
+ if (jsx->fp) {
+ purple_debug_info("jabber",
+ "jabber_si_xfer_free: closing file for IBB transfer\n");
+ fclose(jsx->fp);
+ }
- g_free(jsx->stream_id);
- g_free(jsx->iq_id);
- /* XXX: free other stuff */
- g_free(jsx->rxqueue);
- g_free(jsx);
- xfer->data = NULL;
+ g_free(jsx->stream_id);
+ g_free(jsx->iq_id);
+ /* XXX: free other stuff */
+ g_free(jsx->rxqueue);
+ g_free(jsx);
+ xfer->data = NULL;
- purple_debug_info("jabber", "jabber_si_xfer_free(): freeing jsx %p", jsx);
+ purple_debug_info("jabber", "jabber_si_xfer_free(): freeing jsx %p\n", jsx);
+ }
}
+/*
+ * These four functions should only be called from the PurpleXfer functions
+ * (typically purple_xfer_cancel_(remote|local), purple_xfer_end, or
+ * purple_xfer_request_denied.
+ */
static void jabber_si_xfer_cancel_send(PurpleXfer *xfer)
{
+ JabberSIXfer *jsx = (JabberSIXfer *) xfer->data;
+
+ /* if there is an IBB session active, send close on that */
+ if (jsx->ibb_session) {
+ jabber_ibb_session_close(jsx->ibb_session);
+ }
jabber_si_xfer_free(xfer);
purple_debug(PURPLE_DEBUG_INFO, "jabber", "in jabber_si_xfer_cancel_send\n");
}
@@ -981,6 +1364,11 @@ static void jabber_si_xfer_request_denied(PurpleXfer *xfer)
static void jabber_si_xfer_cancel_recv(PurpleXfer *xfer)
{
+ JabberSIXfer *jsx = (JabberSIXfer *) xfer->data;
+ /* if there is an IBB session active, send close */
+ if (jsx->ibb_session) {
+ jabber_ibb_session_close(jsx->ibb_session);
+ }
jabber_si_xfer_free(xfer);
purple_debug(PURPLE_DEBUG_INFO, "jabber", "in jabber_si_xfer_cancel_recv\n");
}
@@ -995,9 +1383,16 @@ static void jabber_si_xfer_end(PurpleXfer *xfer)
static void jabber_si_xfer_send_disco_cb(JabberStream *js, const char *who,
JabberCapabilities capabilities, gpointer data)
{
- PurpleXfer *xfer = data;
+ PurpleXfer *xfer = (PurpleXfer *) data;
+ JabberSIXfer *jsx = (JabberSIXfer *) xfer->data;
+
+ if (capabilities & JABBER_CAP_IBB) {
+ purple_debug_info("jabber",
+ "jabber_si_xfer_send_disco_cb: remote JID supports IBB\n");
+ jsx->stream_method |= STREAM_METHOD_IBB;
+ }
- if(capabilities & JABBER_CAP_SI_FILE_XFER) {
+ if (capabilities & JABBER_CAP_SI_FILE_XFER) {
jabber_si_xfer_send_request(xfer);
} else {
char *msg = g_strdup_printf(_("Unable to send file to %s, user does not support file transfers"), who);
@@ -1124,17 +1519,21 @@ static void jabber_si_xfer_init(PurpleXfer *xfer)
x = xmlnode_new_child(feature, "x");
xmlnode_set_namespace(x, "jabber:x:data");
xmlnode_set_attrib(x, "type", "submit");
-
field = xmlnode_new_child(x, "field");
xmlnode_set_attrib(field, "var", "stream-method");
- value = xmlnode_new_child(field, "value");
- if(jsx->stream_method & STREAM_METHOD_BYTESTREAMS)
+ /* we should maybe "remember" if bytestreams has failed before (in the
+ same session) with this JID, and only present IBB as an option to
+ avoid unnessesary timeout */
+ /* maybe we should have an account option to always just try IBB
+ for people who know their firewalls are very restrictive */
+ if (jsx->stream_method & STREAM_METHOD_BYTESTREAMS) {
+ value = xmlnode_new_child(field, "value");
xmlnode_insert_data(value, "http://jabber.org/protocol/bytestreams", -1);
- /*
- else if(jsx->stream_method & STREAM_METHOD_IBB)
- xmlnode_insert_data(value, "http://jabber.org/protocol/ibb", -1);
- */
+ } else if(jsx->stream_method & STREAM_METHOD_IBB) {
+ value = xmlnode_new_child(field, "value");
+ xmlnode_insert_data(value, "http://jabber.org/protocol/ibb", -1);
+ }
jabber_iq_send(iq);
}
@@ -1156,6 +1555,9 @@ PurpleXfer *jabber_si_new_xfer(PurpleConnection *gc, const char *who)
jsx->js = js;
jsx->local_streamhost_fd = -1;
+ jsx->ibb_session = NULL;
+ jsx->fp = NULL;
+
purple_xfer_set_init_fnc(xfer, jabber_si_xfer_init);
purple_xfer_set_cancel_send_fnc(xfer, jabber_si_xfer_cancel_send);
purple_xfer_set_end_fnc(xfer, jabber_si_xfer_end);
@@ -1227,6 +1629,8 @@ void jabber_si_parse(JabberStream *js, xmlnode *packet)
jsx = g_new0(JabberSIXfer, 1);
jsx->local_streamhost_fd = -1;
+ jsx->ibb_session = NULL;
+
for(field = xmlnode_get_child(x, "field"); field; field = xmlnode_get_next_twin(field)) {
const char *var = xmlnode_get_attrib(field, "var");
if(var && !strcmp(var, "stream-method")) {
@@ -1237,10 +1641,8 @@ void jabber_si_parse(JabberStream *js, xmlnode *packet)
if((val = xmlnode_get_data(value))) {
if(!strcmp(val, "http://jabber.org/protocol/bytestreams")) {
jsx->stream_method |= STREAM_METHOD_BYTESTREAMS;
- /*
} else if(!strcmp(val, "http://jabber.org/protocol/ibb")) {
jsx->stream_method |= STREAM_METHOD_IBB;
- */
}
g_free(val);
}
@@ -1278,4 +1680,15 @@ void jabber_si_parse(JabberStream *js, xmlnode *packet)
}
}
+void
+jabber_si_init(void)
+{
+ jabber_ibb_register_open_handler(jabber_si_xfer_ibb_open_cb);
+}
+
+void
+jabber_si_uninit(void)
+{
+ jabber_ibb_unregister_open_handler(jabber_si_xfer_ibb_open_cb);
+}
diff --git a/libpurple/protocols/jabber/si.h b/libpurple/protocols/jabber/si.h
index c7f0ff9..120046f 100644
--- a/libpurple/protocols/jabber/si.h
+++ b/libpurple/protocols/jabber/si.h
@@ -30,5 +30,7 @@ void jabber_bytestreams_parse(JabberStream *js, xmlnode *packet);
void jabber_si_parse(JabberStream *js, xmlnode *packet);
PurpleXfer *jabber_si_new_xfer(PurpleConnection *gc, const char *who);
void jabber_si_xfer_send(PurpleConnection *gc, const char *who, const char *file);
+void jabber_si_init(void);
+void jabber_si_uninit(void);
#endif /* _PURPLE_JABBER_SI_H_ */
diff --git a/libpurple/protocols/jabber/usermood.c b/libpurple/protocols/jabber/usermood.c
index 3ff09d0..217d092 100644
--- a/libpurple/protocols/jabber/usermood.c
+++ b/libpurple/protocols/jabber/usermood.c
@@ -103,7 +103,7 @@ static void jabber_mood_cb(JabberStream *js, const char *from, xmlnode *items) {
/* ignore the mood of people not on our buddy list */
if (!buddy || !item)
return;
-
+
mood = xmlnode_get_child_with_namespace(item, "mood", "http://jabber.org/protocol/mood");
if (!mood)
return;
@@ -179,10 +179,10 @@ static void do_mood_set_mood(PurplePluginAction *action) {
field = purple_request_field_choice_new("mood",
_("Mood"), 0);
-
+
for(i = 0; moodstrings[i]; ++i)
purple_request_field_choice_add(field, _(moodstrings[i]));
-
+
purple_request_field_set_required(field, TRUE);
purple_request_field_group_add_field(group, field);
@@ -190,7 +190,7 @@ static void do_mood_set_mood(PurplePluginAction *action) {
_("Description"), NULL,
FALSE);
purple_request_field_group_add_field(group, field);
-
+
purple_request_fields(gc, _("Edit User Mood"),
_("Edit User Mood"),
_("Please select your mood from the list."),
@@ -199,7 +199,7 @@ static void do_mood_set_mood(PurplePluginAction *action) {
_("Cancel"), NULL,
purple_connection_get_account(gc), NULL, NULL,
gc);
-
+
}
void jabber_mood_init_action(GList **m) {
@@ -222,7 +222,7 @@ void jabber_mood_set(JabberStream *js, const char *mood, const char *text) {
xmlnode *textnode = xmlnode_new_child(moodnode, "text");
xmlnode_insert_data(textnode, text, -1);
}
-
+
jabber_pep_publish(js, publish);
/* publish is freed by jabber_pep_publish -> jabber_iq_send -> jabber_iq_free
(yay for well-defined memory management rules) */
diff --git a/libpurple/protocols/jabber/usernick.c b/libpurple/protocols/jabber/usernick.c
index 618d493..ff269ce 100644
--- a/libpurple/protocols/jabber/usernick.c
+++ b/libpurple/protocols/jabber/usernick.c
@@ -34,11 +34,11 @@ static void jabber_nick_cb(JabberStream *js, const char *from, xmlnode *items) {
JabberBuddy *buddy = jabber_buddy_find(js, from, FALSE);
xmlnode *nick;
char *nickname = NULL;
-
+
/* ignore the tune of people not on our buddy list */
if (!buddy || !item)
return;
-
+
nick = xmlnode_get_child_with_namespace(item, "nick", "http://jabber.org/protocol/nick");
if (!nick)
return;
@@ -49,15 +49,15 @@ static void jabber_nick_cb(JabberStream *js, const char *from, xmlnode *items) {
static void do_nick_set(JabberStream *js, const char *nick) {
xmlnode *publish, *nicknode;
-
+
publish = xmlnode_new("publish");
xmlnode_set_attrib(publish,"node","http://jabber.org/protocol/nick");
nicknode = xmlnode_new_child(xmlnode_new_child(publish, "item"), "nick");
xmlnode_set_namespace(nicknode, "http://jabber.org/protocol/nick");
-
+
if(nick && nick[0] != '\0')
xmlnode_insert_data(nicknode, nick, -1);
-
+
jabber_pep_publish(js, publish);
/* publish is freed by jabber_pep_publish -> jabber_iq_send -> jabber_iq_free
(yay for well-defined memory management rules) */
@@ -66,13 +66,13 @@ static void do_nick_set(JabberStream *js, const char *nick) {
static void do_nick_got_own_nick_cb(JabberStream *js, const char *from, xmlnode *items) {
char *oldnickname = NULL;
xmlnode *item = xmlnode_get_child(items,"item");
-
+
if(item) {
xmlnode *nick = xmlnode_get_child_with_namespace(item,"nick","http://jabber.org/protocol/nick");
if(nick)
oldnickname = xmlnode_get_data(nick);
}
-
+
purple_request_input(js->gc, _("Set User Nickname"), _("Please specify a new nickname for you."),
_("This information is visible to all contacts on your contact list, so choose something appropriate."),
oldnickname, FALSE, FALSE, NULL, _("Set"), PURPLE_CALLBACK(do_nick_set), _("Cancel"), NULL,
@@ -84,7 +84,7 @@ static void do_nick_set_nick(PurplePluginAction *action) {
PurpleConnection *gc = (PurpleConnection *) action->context;
JabberStream *js = gc->proto_data;
char *jid = g_strdup_printf("%s@%s", js->user->node, js->user->domain);
-
+
/* since the nickname might have been changed by another resource of this account, we always have to request the old one
from the server to present as the default for the new one */
jabber_pep_request_item(js, jid, "http://jabber.org/protocol/nick", NULL, do_nick_got_own_nick_cb);
diff --git a/libpurple/protocols/jabber/usertune.c b/libpurple/protocols/jabber/usertune.c
index 92d06d3..73139d5 100644
--- a/libpurple/protocols/jabber/usertune.c
+++ b/libpurple/protocols/jabber/usertune.c
@@ -116,12 +116,12 @@ void jabber_tune_init(void) {
void jabber_tune_set(PurpleConnection *gc, const PurpleJabberTuneInfo *tuneinfo) {
xmlnode *publish, *tunenode;
JabberStream *js = gc->proto_data;
-
+
publish = xmlnode_new("publish");
xmlnode_set_attrib(publish,"node","http://jabber.org/protocol/tune");
tunenode = xmlnode_new_child(xmlnode_new_child(publish, "item"), "tune");
xmlnode_set_namespace(tunenode, "http://jabber.org/protocol/tune");
-
+
if(tuneinfo) {
if(tuneinfo->artist && tuneinfo->artist[0] != '\0')
xmlnode_insert_data(xmlnode_new_child(tunenode, "artist"),tuneinfo->artist,-1);
@@ -139,7 +139,7 @@ void jabber_tune_set(PurpleConnection *gc, const PurpleJabberTuneInfo *tuneinfo)
if(tuneinfo->track && tuneinfo->track[0] != '\0')
xmlnode_insert_data(xmlnode_new_child(tunenode, "track"),tuneinfo->track,-1);
}
-
+
jabber_pep_publish(js, publish);
/* publish is freed by jabber_pep_publish -> jabber_iq_send -> jabber_iq_free
(yay for well-defined memory management rules) */
diff --git a/libpurple/protocols/jabber/xdata.c b/libpurple/protocols/jabber/xdata.c
index 9eff9a8..1d2571c 100644
--- a/libpurple/protocols/jabber/xdata.c
+++ b/libpurple/protocols/jabber/xdata.c
@@ -372,7 +372,7 @@ void *jabber_x_data_request_with_actions(JabberStream *js, xmlnode *packet, GLis
if(field && xmlnode_get_child(fn, "required"))
purple_request_field_set_required(field,TRUE);
}
-
+
if(actions != NULL) {
PurpleRequestField *actionfield;
GList *action;
@@ -382,7 +382,7 @@ void *jabber_x_data_request_with_actions(JabberStream *js, xmlnode *packet, GLis
for(action = actions; action; action = g_list_next(action)) {
JabberXDataAction *a = action->data;
-
+
purple_request_field_choice_add(actionfield, a->name);
data->actions = g_list_append(data->actions, g_strdup(a->handle));
}
diff --git a/libpurple/protocols/msn/directconn.c b/libpurple/protocols/msn/directconn.c
index 7c5b1a5..1ebc6f8 100644
--- a/libpurple/protocols/msn/directconn.c
+++ b/libpurple/protocols/msn/directconn.c
@@ -201,24 +201,6 @@ msn_directconn_write(MsnDirectConn *directconn,
g_free(buffer);
-#if 0
- /* Let's write the length of the data. */
- ret = write(directconn->fd, &len, sizeof(len));
-
- /* Let's write the data. */
- ret = write(directconn->fd, data, len);
-
- char *str;
- str = g_strdup_printf("/home/revo/msntest/w%.4d.bin", directconn->c);
-
- FILE *tf = g_fopen(str, "w");
- fwrite(&len, 1, sizeof(len), tf);
- fwrite(data, 1, len, tf);
- fclose(tf);
-
- g_free(str);
-#endif
-
directconn->c++;
return ret;
@@ -341,7 +323,7 @@ read_cb(gpointer data, gint source, PurpleInputCondition cond)
MsnMessage *msg;
#ifdef DEBUG_DC
- str = g_strdup_printf("/home/revo/msntest/r%.4d.bin", directconn->c);
+ str = g_strdup_printf("%s/msntest/r%.4d.bin", g_get_home_dir(), directconn->c);
FILE *tf = g_fopen(str, "w");
fwrite(body, 1, len, tf);
diff --git a/libpurple/protocols/msn/msn.c b/libpurple/protocols/msn/msn.c
index 53a663e..5cbfd8e 100644
--- a/libpurple/protocols/msn/msn.c
+++ b/libpurple/protocols/msn/msn.c
@@ -457,23 +457,27 @@ show_send_to_mobile_cb(PurpleBlistNode *node, gpointer ignored)
PurpleConnection *gc;
MsnSession *session;
MsnMobileData *data;
+ PurpleAccount *account;
+ const char *name;
g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
buddy = (PurpleBuddy *) node;
- gc = purple_account_get_connection(buddy->account);
+ account = purple_buddy_get_account(buddy);
+ gc = purple_account_get_connection(account);
+ name = purple_buddy_get_name(buddy);
session = gc->proto_data;
data = g_new0(MsnMobileData, 1);
data->gc = gc;
- data->passport = buddy->name;
+ data->passport = name;
purple_request_input(gc, NULL, _("Send a mobile message."), NULL,
NULL, TRUE, FALSE, NULL,
_("Page"), G_CALLBACK(send_to_mobile_cb),
_("Close"), G_CALLBACK(close_mobile_page_cb),
- purple_connection_get_account(gc), purple_buddy_get_name(buddy), NULL,
+ account, name, NULL,
data);
}
@@ -505,6 +509,7 @@ initiate_chat_cb(PurpleBlistNode *node, gpointer data)
{
PurpleBuddy *buddy;
PurpleConnection *gc;
+ PurpleAccount *account;
MsnSession *session;
MsnSwitchBoard *swboard;
@@ -514,13 +519,14 @@ initiate_chat_cb(PurpleBlistNode *node, gpointer data)
g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
buddy = (PurpleBuddy *) node;
- gc = purple_account_get_connection(buddy->account);
+ account = purple_buddy_get_account(buddy);
+ gc = purple_account_get_connection(account);
session = gc->proto_data;
swboard = msn_switchboard_new(session);
msn_switchboard_request(swboard);
- msn_switchboard_request_add_user(swboard, buddy->name);
+ msn_switchboard_request_add_user(swboard, purple_buddy_get_name(buddy));
/* TODO: This might move somewhere else, after USR might be */
swboard->chat_id = msn_switchboard_get_chat_id();
@@ -528,9 +534,9 @@ initiate_chat_cb(PurpleBlistNode *node, gpointer data)
swboard->flag = MSN_SB_FLAG_IM;
/* Local alias > Display name > Username */
- if ((alias = purple_account_get_alias(buddy->account)) == NULL)
+ if ((alias = purple_account_get_alias(account)) == NULL)
if ((alias = purple_connection_get_display_name(gc)) == NULL)
- alias = purple_account_get_username(buddy->account);
+ alias = purple_account_get_username(account);
purple_conv_chat_add_user(PURPLE_CONV_CHAT(swboard->conv),
alias, NULL, PURPLE_CBFLAGS_NONE, TRUE);
@@ -613,7 +619,7 @@ msn_list_icon(PurpleAccount *a, PurpleBuddy *b)
static const char *
msn_list_emblems(PurpleBuddy *b)
{
- MsnUser *user = b->proto_data;
+ MsnUser *user = purple_buddy_get_protocol_data(b);
if (user != NULL) {
if (user->clientid & MSN_CLIENT_CAP_BOT)
@@ -694,7 +700,7 @@ msn_tooltip_text(PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, gboolean f
PurplePresence *presence = purple_buddy_get_presence(buddy);
PurpleStatus *status = purple_presence_get_active_status(presence);
- user = buddy->proto_data;
+ user = purple_buddy_get_protocol_data(buddy);
if (purple_presence_is_online(presence))
{
@@ -937,7 +943,7 @@ msn_buddy_menu(PurpleBuddy *buddy)
g_return_val_if_fail(buddy != NULL, NULL);
- user = buddy->proto_data;
+ user = purple_buddy_get_protocol_data(buddy);
if (user != NULL)
{
@@ -950,8 +956,8 @@ msn_buddy_menu(PurpleBuddy *buddy)
}
}
- if (g_ascii_strcasecmp(buddy->name,
- purple_account_get_username(buddy->account)))
+ if (g_ascii_strcasecmp(purple_buddy_get_name(buddy),
+ purple_account_get_username(purple_buddy_get_account(buddy))))
{
act = purple_menu_action_new(_("Initiate _Chat"),
PURPLE_CALLBACK(initiate_chat_cb),
@@ -1430,14 +1436,15 @@ msn_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
{
MsnSession *session;
MsnUserList *userlist;
- const char *who;
+ const char *who, *gname;
MsnUser *user;
session = gc->proto_data;
userlist = session->userlist;
- who = msn_normalize(gc->account, buddy->name);
+ who = msn_normalize(purple_connection_get_account(gc), purple_buddy_get_name(buddy));
- purple_debug_info("msn", "Add user:%s to group:%s\n", who, (group && group->name) ? group->name : "(null)");
+ gname = group ? purple_group_get_name(group) : NULL;
+ purple_debug_info("msn", "Add user:%s to group:%s\n", who, gname ? gname : "(null)");
if (!session->logged_in)
{
#if 0
@@ -1464,12 +1471,12 @@ msn_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
if ((user != NULL) && (user->networkid != MSN_NETWORK_UNKNOWN)) {
/* We already know this buddy and their network. This function knows
what to do with users already in the list and stuff... */
- msn_userlist_add_buddy(userlist, who, group ? group->name : NULL);
+ msn_userlist_add_buddy(userlist, who, gname);
} else {
char **tokens;
char *fqy;
/* We need to check the network for this buddy first */
- msn_userlist_save_pending_buddy(userlist, who, group ? group->name : NULL);
+ msn_userlist_save_pending_buddy(userlist, who, gname);
tokens = g_strsplit(who, "@", 2);
fqy = g_strdup_printf("<ml><d n=\"%s\"><c n=\"%s\"/></d></ml>",
tokens[1],
@@ -1494,7 +1501,7 @@ msn_rem_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
return;
/* XXX - Does buddy->name need to be msn_normalize'd here? --KingAnt */
- msn_userlist_rem_buddy(userlist, buddy->name);
+ msn_userlist_rem_buddy(userlist, purple_buddy_get_name(buddy));
}
static void
@@ -1747,20 +1754,22 @@ msn_rename_group(PurpleConnection *gc, const char *old_name,
PurpleGroup *group, GList *moved_buddies)
{
MsnSession *session;
+ const char *gname;
session = gc->proto_data;
g_return_if_fail(session != NULL);
g_return_if_fail(session->userlist != NULL);
+ gname = purple_group_get_name(group);
if (msn_userlist_find_group_with_name(session->userlist, old_name) != NULL)
{
- msn_contact_rename_group(session, old_name, group->name);
+ msn_contact_rename_group(session, old_name, gname);
}
else
{
/* not found */
- msn_add_group(session, NULL, group->name);
+ msn_add_group(session, NULL, gname);
}
}
@@ -1820,20 +1829,22 @@ msn_remove_group(PurpleConnection *gc, PurpleGroup *group)
{
MsnSession *session;
MsnCmdProc *cmdproc;
+ const char *gname;
session = gc->proto_data;
cmdproc = session->notification->cmdproc;
+ gname = purple_group_get_name(group);
- purple_debug_info("msn", "Remove group %s\n", group->name);
+ purple_debug_info("msn", "Remove group %s\n", gname);
/*we can't delete the default group*/
- if(!strcmp(group->name, MSN_INDIVIDUALS_GROUP_NAME)||
- !strcmp(group->name, MSN_NON_IM_GROUP_NAME))
+ if(!strcmp(gname, MSN_INDIVIDUALS_GROUP_NAME)||
+ !strcmp(gname, MSN_NON_IM_GROUP_NAME))
{
purple_debug_info("msn", "This group can't be removed, returning.\n");
return ;
}
- msn_del_group(session, group->name);
+ msn_del_group(session, gname);
}
/**
@@ -1850,17 +1861,19 @@ msn_tooltip_extract_info_text(PurpleNotifyUserInfo *user_info, MsnGetInfoData *i
if (b)
{
char *tmp;
+ const char *alias;
- if (b->alias && b->alias[0])
+ alias = purple_buddy_get_local_buddy_alias(b);
+ if (alias && alias[0])
{
- char *aliastext = g_markup_escape_text(b->alias, -1);
+ char *aliastext = g_markup_escape_text(alias, -1);
purple_notify_user_info_add_pair(user_info, _("Alias"), aliastext);
g_free(aliastext);
}
- if (b->server_alias)
+ if ((alias = purple_buddy_get_server_alias(b)) != NULL)
{
- char *nicktext = g_markup_escape_text(b->server_alias, -1);
+ char *nicktext = g_markup_escape_text(alias, -1);
tmp = g_strdup_printf("<font sml=\"msn\">%s</font>", nicktext);
purple_notify_user_info_add_pair(user_info, _("Nickname"), tmp);
g_free(tmp);
diff --git a/libpurple/protocols/msn/notification.c b/libpurple/protocols/msn/notification.c
index a7ffdf5..d941e5f 100644
--- a/libpurple/protocols/msn/notification.c
+++ b/libpurple/protocols/msn/notification.c
@@ -665,13 +665,14 @@ msn_notification_dump_contact(MsnSession *session)
if (user->passport && !strcmp(user->passport, "messenger@microsoft.com"))
continue;
- if ((user->list_op & MSN_LIST_OP_MASK) == (MSN_LIST_AL_OP | MSN_LIST_BL_OP)) {
+ if ((user->list_op & MSN_LIST_OP_MASK & ~MSN_LIST_FL_OP)
+ == (MSN_LIST_AL_OP | MSN_LIST_BL_OP)) {
/* The server will complain if we send it a user on both the
Allow and Block lists. So assume they're on the Block list
and remove them from the Allow list in the membership lists to
stop this from happening again. */
purple_debug_warning("msn",
- "User %s is on both Allow and Block list,"
+ "User %s is on both Allow and Block list; "
"removing from Allow list.\n",
user->passport);
msn_userlist_rem_buddy_from_list(session->userlist, user->passport, MSN_LIST_AL);
diff --git a/libpurple/protocols/msn/session.c b/libpurple/protocols/msn/session.c
index 1bbfd0e..424a37c 100644
--- a/libpurple/protocols/msn/session.c
+++ b/libpurple/protocols/msn/session.c
@@ -271,16 +271,21 @@ msn_session_sync_users(MsnSession *session)
* being logged in. This no longer happens, so we manually iterate
* over the whole buddy list to identify sync issues.
*/
- for (gnode = purple_get_blist()->root; gnode; gnode = gnode->next) {
+ for (gnode = purple_blist_get_root(); gnode;
+ gnode = purple_blist_node_get_sibling_next(gnode)) {
PurpleGroup *group = (PurpleGroup *)gnode;
const char *group_name;
if(!PURPLE_BLIST_NODE_IS_GROUP(gnode))
continue;
- group_name = group->name;
- for(cnode = gnode->child; cnode; cnode = cnode->next) {
+ group_name = purple_group_get_name(group);
+ for(cnode = purple_blist_node_get_first_child(gnode);
+ cnode;
+ cnode = purple_blist_node_get_sibling_next(cnode)) {
if(!PURPLE_BLIST_NODE_IS_CONTACT(cnode))
continue;
- for(bnode = cnode->child; bnode; bnode = bnode->next) {
+ for(bnode = purple_blist_node_get_first_child(cnode);
+ bnode;
+ bnode = purple_blist_node_get_sibling_next(bnode)) {
PurpleBuddy *b;
if(!PURPLE_BLIST_NODE_IS_BUDDY(bnode))
continue;
diff --git a/libpurple/protocols/msn/user.c b/libpurple/protocols/msn/user.c
index d5b5430..2ec31db 100644
--- a/libpurple/protocols/msn/user.c
+++ b/libpurple/protocols/msn/user.c
@@ -294,9 +294,8 @@ msn_user_add_group_id(MsnUser *user, const char* group_id)
b = purple_buddy_new(account, passport, NULL);
purple_blist_add_buddy(b, NULL, g, NULL);
}
- b->proto_data = user;
+ purple_buddy_set_protocol_data(b, user);
/*Update the blist Node info*/
-// purple_blist_node_set_string(&(b->node), "", "");
}
/*check if the msn user is online*/
diff --git a/libpurple/protocols/msn/userlist.c b/libpurple/protocols/msn/userlist.c
index 3f20bbd..a98919d 100644
--- a/libpurple/protocols/msn/userlist.c
+++ b/libpurple/protocols/msn/userlist.c
@@ -931,31 +931,37 @@ void
msn_userlist_load(MsnSession *session)
{
PurpleBlistNode *gnode, *cnode, *bnode;
- PurpleConnection *gc = purple_account_get_connection(session->account);
+ PurpleAccount *account = session->account;
+ PurpleConnection *gc = purple_account_get_connection(account);
GSList *l;
MsnUser * user;
g_return_if_fail(gc != NULL);
- for (gnode = purple_get_blist()->root; gnode; gnode = gnode->next)
+ for (gnode = purple_blist_get_root(); gnode;
+ gnode = purple_blist_node_get_sibling_next(gnode))
{
if (!PURPLE_BLIST_NODE_IS_GROUP(gnode))
continue;
- for (cnode = gnode->child; cnode; cnode = cnode->next)
+ for (cnode = purple_blist_node_get_first_child(gnode);
+ cnode;
+ cnode = purple_blist_node_get_sibling_next(cnode))
{
if (!PURPLE_BLIST_NODE_IS_CONTACT(cnode))
continue;
- for (bnode = cnode->child; bnode; bnode = bnode->next)
+ for (bnode = purple_blist_node_get_first_child(cnode);
+ bnode;
+ bnode = purple_blist_node_get_sibling_next(bnode))
{
PurpleBuddy *b;
if (!PURPLE_BLIST_NODE_IS_BUDDY(bnode))
continue;
b = (PurpleBuddy *)bnode;
- if (b->account == gc->account)
+ if (purple_buddy_get_account(b) == account)
{
user = msn_userlist_find_add_user(session->userlist,
- b->name,NULL);
- b->proto_data = user;
+ purple_buddy_get_name(b), NULL);
+ purple_buddy_set_protocol_data(b, user);
msn_user_set_op(user, MSN_LIST_FL_OP);
}
}
diff --git a/libpurple/protocols/myspace/README b/libpurple/protocols/myspace/README
index b890160..f9f062c 100644
--- a/libpurple/protocols/myspace/README
+++ b/libpurple/protocols/myspace/README
@@ -1,9 +1,8 @@
-MySpaceIM Protocol Plugin for Libpurple by Jeff Connelly 20070807
-
+MySpaceIM Protocol Plugin for libpurple by Jeff Connelly 2007-08-07
Greetings. This package contains a plugin for libpurple (as used in
-Pidgin, formerly Gaim) to connect to the new MySpaceIM instant messaging
-network and send/receive messages. Functionality is only basic as of yet,
+Pidgin, formerly Gaim) to connect to the new MySpaceIM instant messaging
+network and send/receive messages. Functionality is only basic as of yet,
and this code should be considered alpha quality.
This code was initially developed under Google Summer of Code 2007.
@@ -15,10 +14,10 @@ Usage:
Login using your _email address_ you use to login to myspace.com. You can't
login using your numeric ID or alias.
-To test it out, send a message to yourself (by your username or numeric
-uid (email not yet supported)) or tom (6221). In either case you should
-get a reply. You should also be able to talk to other MySpaceIM users if
-you desire. Replies will always be shown as coming from a user's username,
+To test it out, send a message to yourself (by your username or numeric
+uid (email not yet supported)) or tom (6221). In either case you should
+get a reply. You should also be able to talk to other MySpaceIM users if
+you desire. Replies will always be shown as coming from a user's username,
even if you IM by email or userid.
Feedback welcome. You can IM my test account at "msimprpl" if you feel like it.
@@ -26,4 +25,3 @@ Feedback welcome. You can IM my test account at "msimprpl" if you feel like it.
Enjoy,
-Jeff Connelly
msimprpl@xyzzy.cjb.net
-
diff --git a/libpurple/protocols/myspace/myspace.c b/libpurple/protocols/myspace/myspace.c
index 3cf45c0..40ec871 100644
--- a/libpurple/protocols/myspace/myspace.c
+++ b/libpurple/protocols/myspace/myspace.c
@@ -202,7 +202,7 @@ msim_postprocess_outgoing(MsimSession *session, MsimMessage *msg,
/* Next, see if on buddy list and know uid. */
buddy = purple_find_buddy(session->account, username);
if (buddy) {
- uid = purple_blist_node_get_int(&buddy->node, "UserID");
+ uid = purple_blist_node_get_int(PURPLE_BLIST_NODE(buddy), "UserID");
} else {
uid = 0;
}
@@ -311,7 +311,7 @@ msim_uid2username_from_blist(PurpleAccount *account, guint wanted_uid)
/* See finch/gnthistory.c */
buddy = cur->data;
- uid = purple_blist_node_get_int(&buddy->node, "UserID");
+ uid = purple_blist_node_get_int(PURPLE_BLIST_NODE(buddy), "UserID");
name = purple_buddy_get_name(buddy);
if (uid == wanted_uid)
@@ -383,12 +383,17 @@ msim_status_text(PurpleBuddy *buddy)
MsimSession *session;
MsimUser *user;
const gchar *display_name, *headline;
+ PurpleAccount *account;
+ PurpleConnection *gc;
g_return_val_if_fail(buddy != NULL, NULL);
user = msim_get_user_from_buddy(buddy);
- session = (MsimSession *)buddy->account->gc->proto_data;
+ account = purple_buddy_get_account(buddy);
+ gc = purple_account_get_connection(account);
+ session = (MsimSession *)gc->proto_data;
+
g_return_val_if_fail(MSIM_SESSION_VALID(session), NULL);
display_name = headline = NULL;
@@ -435,8 +440,10 @@ msim_tooltip_text(PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info,
if (PURPLE_BUDDY_IS_ONLINE(buddy)) {
MsimSession *session;
-
- session = (MsimSession *)buddy->account->gc->proto_data;
+ PurpleAccount *account = purple_buddy_get_account(buddy);
+ PurpleConnection *gc = purple_account_get_connection(account);
+
+ session = (MsimSession *)gc->proto_data;
g_return_if_fail(MSIM_SESSION_VALID(session));
@@ -1036,11 +1043,11 @@ msim_add_contact_from_server_cb(MsimSession *session, const MsimMessage *user_lo
* of numbers in the buddy list.
*/
if (display_name != NULL) {
- purple_blist_node_set_string(&buddy->node, "DisplayName", display_name);
+ purple_blist_node_set_string(PURPLE_BLIST_NODE(buddy), "DisplayName", display_name);
serv_got_alias(session->gc, username, display_name);
} else {
serv_got_alias(session->gc, username,
- purple_blist_node_get_string(&buddy->node, "DisplayName"));
+ purple_blist_node_get_string(PURPLE_BLIST_NODE(buddy), "DisplayName"));
}
}
g_free(display_name);
@@ -1050,7 +1057,7 @@ msim_add_contact_from_server_cb(MsimSession *session, const MsimMessage *user_lo
user->id = uid;
/* Keep track of the user ID across sessions */
- purple_blist_node_set_int(&buddy->node, "UserID", uid);
+ purple_blist_node_set_int(PURPLE_BLIST_NODE(buddy), "UserID", uid);
/* Stores a few fields in the MsimUser, relevant to the buddy itself.
* AvatarURL, Headline, ContactID. */
@@ -1374,7 +1381,7 @@ msim_incoming_status(MsimSession *session, MsimMessage *msg)
user->id = msim_msg_get_integer(msg, "f");
/* Keep track of the user ID across sessions */
- purple_blist_node_set_int(&buddy->node, "UserID", user->id);
+ purple_blist_node_set_int(PURPLE_BLIST_NODE(buddy), "UserID", user->id);
msim_store_user_info(session, msg, NULL);
} else {
@@ -2628,10 +2635,14 @@ msim_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
MsimMessage *msg;
MsimMessage *msg_persist;
MsimMessage *body;
+ const char *name, *gname;
session = (MsimSession *)gc->proto_data;
+ name = purple_buddy_get_name(buddy);
+ gname = group ? purple_group_get_name(group) : NULL;
+
purple_debug_info("msim", "msim_add_buddy: want to add %s to %s\n",
- buddy->name, (group && group->name) ? group->name : "(no group)");
+ name, gname ? gname : "(no group)");
msg = msim_msg_new(
"addbuddy", MSIM_TYPE_BOOLEAN, TRUE,
@@ -2640,7 +2651,7 @@ msim_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
"reason", MSIM_TYPE_STRING, g_strdup(""),
NULL);
- if (!msim_postprocess_outgoing(session, msg, buddy->name, "newprofileid", "reason")) {
+ if (!msim_postprocess_outgoing(session, msg, name, "newprofileid", "reason")) {
purple_notify_error(NULL, NULL, _("Failed to add buddy"), _("'addbuddy' command failed."));
msim_msg_free(msg);
return;
@@ -2652,7 +2663,7 @@ msim_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
body = msim_msg_new(
"ContactID", MSIM_TYPE_STRING, g_strdup("<uid>"),
- "GroupName", MSIM_TYPE_STRING, g_strdup(group->name),
+ "GroupName", MSIM_TYPE_STRING, g_strdup(gname),
"Position", MSIM_TYPE_INTEGER, 1000,
"Visibility", MSIM_TYPE_INTEGER, 1,
"NickName", MSIM_TYPE_STRING, g_strdup(""),
@@ -2673,7 +2684,7 @@ msim_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
"body", MSIM_TYPE_DICTIONARY, body,
NULL);
- if (!msim_postprocess_outgoing(session, msg_persist, buddy->name, "body", NULL))
+ if (!msim_postprocess_outgoing(session, msg_persist, name, "body", NULL))
{
purple_notify_error(NULL, NULL, _("Failed to add buddy"), _("persist command failed"));
msim_msg_free(msg_persist);
@@ -2682,7 +2693,14 @@ msim_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
msim_msg_free(msg_persist);
/* Add to allow list, remove from block list */
- msim_update_blocklist_for_buddy(session, buddy->name, TRUE, FALSE);
+ msim_update_blocklist_for_buddy(session, name, TRUE, FALSE);
+}
+
+static void
+msim_buddy_free(PurpleBuddy *buddy)
+{
+ msim_user_free(purple_buddy_get_protocol_data(buddy));
+ purple_buddy_set_protocol_data(buddy, NULL);
}
/**
@@ -2694,8 +2712,10 @@ msim_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
MsimSession *session;
MsimMessage *delbuddy_msg;
MsimMessage *persist_msg;
+ const char *name;
session = (MsimSession *)gc->proto_data;
+ name = purple_buddy_get_name(buddy);
delbuddy_msg = msim_msg_new(
"delbuddy", MSIM_TYPE_BOOLEAN, TRUE,
@@ -2703,7 +2723,7 @@ msim_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
/* 'delprofileid' with uid will be inserted here. */
NULL);
- if (!msim_postprocess_outgoing(session, delbuddy_msg, buddy->name, "delprofileid", NULL)) {
+ if (!msim_postprocess_outgoing(session, delbuddy_msg, name, "delprofileid", NULL)) {
purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("'delbuddy' command failed"));
msim_msg_free(delbuddy_msg);
return;
@@ -2722,7 +2742,7 @@ msim_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
"body", MSIM_TYPE_STRING, g_strdup("ContactID=<uid>"),
NULL);
- if (!msim_postprocess_outgoing(session, persist_msg, buddy->name, "body", NULL)) {
+ if (!msim_postprocess_outgoing(session, persist_msg, name, "body", NULL)) {
purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("persist command failed"));
msim_msg_free(persist_msg);
return;
@@ -2734,15 +2754,12 @@ msim_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
* doesn't seem like it would be necessary, but the official client
* does it)
*/
- if (!msim_update_blocklist_for_buddy(session, buddy->name, FALSE, FALSE)) {
+ if (!msim_update_blocklist_for_buddy(session, name, FALSE, FALSE)) {
purple_notify_error(NULL, NULL,
_("Failed to remove buddy"), _("blocklist command failed"));
return;
}
- if (buddy->proto_data) {
- msim_user_free(buddy->proto_data);
- buddy->proto_data = NULL;
- }
+ msim_buddy_free(buddy);
}
/**
@@ -2832,13 +2849,6 @@ msim_rem_deny(PurpleConnection *gc, const char *name)
msim_update_blocklist_for_buddy(session, name, FALSE, FALSE);
}
-static void
-msim_buddy_free(PurpleBuddy *buddy)
-{
- msim_user_free(buddy->proto_data);
- buddy->proto_data = NULL;
-}
-
/**
* Returns a string of a username in canonical form. Basically removes all the
* spaces, lowercases the string, and looks up user IDs to usernames.
diff --git a/libpurple/protocols/myspace/user.c b/libpurple/protocols/myspace/user.c
index 86115d9..bdd53d0 100644
--- a/libpurple/protocols/myspace/user.c
+++ b/libpurple/protocols/myspace/user.c
@@ -52,17 +52,14 @@ msim_get_user_from_buddy(PurpleBuddy *buddy)
return NULL;
}
- if (!buddy->proto_data) {
+ if (!(user = purple_buddy_get_protocol_data(buddy))) {
/* No MsimUser for this buddy; make one. */
user = g_new0(MsimUser, 1);
user->buddy = buddy;
- user->id = purple_blist_node_get_int((PurpleBlistNode*)buddy, "UserID");
- buddy->proto_data = (gpointer)user;
+ purple_buddy_set_protocol_data(buddy, user);
}
- user = (MsimUser *)(buddy->proto_data);
-
return user;
}
@@ -111,6 +108,7 @@ msim_append_user_info(MsimSession *session, PurpleNotifyUserInfo *user_info, Msi
{
PurplePresence *presence;
gchar *str;
+ guint uid;
guint cv;
/* Useful to identify the account the tooltip refers to.
@@ -119,6 +117,8 @@ msim_append_user_info(MsimSession *session, PurpleNotifyUserInfo *user_info, Msi
purple_notify_user_info_add_pair(user_info, _("User"), user->username);
}
+ uid = purple_blist_node_get_int((PurpleBlistNode *)user->buddy, "UserID");
+
/* a/s/l...the vitals */
if (user->age) {
char age[16];
@@ -209,9 +209,9 @@ msim_downloaded_buddy_icon(PurpleUtilFetchUrlData *url_data,
gsize len,
const gchar *error_message)
{
- MsimUser *user;
-
- user = (MsimUser *)user_data;
+ MsimUser *user = (MsimUser *)user_data;
+ const char *name = purple_buddy_get_name(user->buddy);
+ PurpleAccount *account;
purple_debug_info("msim_downloaded_buddy_icon",
"Downloaded %" G_GSIZE_FORMAT " bytes\n", len);
@@ -219,12 +219,12 @@ msim_downloaded_buddy_icon(PurpleUtilFetchUrlData *url_data,
if (!url_text) {
purple_debug_info("msim_downloaded_buddy_icon",
"failed to download icon for %s",
- user->buddy->name);
+ name);
return;
}
- purple_buddy_icons_set_for_user(user->buddy->account,
- user->buddy->name,
+ account = purple_buddy_get_account(user->buddy);
+ purple_buddy_icons_set_for_user(account, name,
g_memdup((gchar *)url_text, len), len,
/* Use URL itself as buddy icon "checksum" (TODO: ETag) */
user->image_url); /* checksum */
@@ -247,7 +247,9 @@ msim_downloaded_buddy_icon(PurpleUtilFetchUrlData *url_data,
static void msim_set_artist_or_title(MsimUser *user, const char *new_artist, const char *new_title)
{
PurplePresence *presence;
+ PurpleAccount *account;
const char *prev_artist, *prev_title;
+ const char *name;
if (user->buddy == NULL)
/* User not on buddy list so nothing to do */
@@ -261,8 +263,11 @@ static void msim_set_artist_or_title(MsimUser *user, const char *new_artist, con
if (new_title && !*new_title)
new_title = NULL;
+ account = purple_buddy_get_account(user->buddy);
+ name = purple_buddy_get_name(user->buddy);
+
if (!new_artist && !new_title) {
- purple_prpl_got_user_status_deactive(user->buddy->account, user->buddy->name, "tune");
+ purple_prpl_got_user_status_deactive(account, name, "tune");
return;
}
@@ -282,7 +287,7 @@ static void msim_set_artist_or_title(MsimUser *user, const char *new_artist, con
if (!new_title)
new_title = prev_title;
- purple_prpl_got_user_status(user->buddy->account, user->buddy->name, "tune",
+ purple_prpl_got_user_status(account, name, "tune",
PURPLE_TUNE_TITLE, new_title,
PURPLE_TUNE_ARTIST, new_artist,
NULL);
@@ -299,14 +304,16 @@ static void msim_set_artist_or_title(MsimUser *user, const char *new_artist, con
static void
msim_store_user_info_each(const gchar *key_str, gchar *value_str, MsimUser *user)
{
+ const char *name = user->buddy ? purple_buddy_get_name(user->buddy) : NULL;
+
if (g_str_equal(key_str, "UserID") || g_str_equal(key_str, "ContactID")) {
/* Save to buddy list, if it exists, for quick cached uid lookup with msim_uid2username_from_blist(). */
user->id = atol(value_str);
g_free(value_str);
if (user->buddy)
{
- purple_debug_info("msim", "associating uid %s with username %s\n", key_str, user->buddy->name);
- purple_blist_node_set_int(&user->buddy->node, "UserID", user->id);
+ purple_debug_info("msim", "associating uid %s with username %s\n", key_str, name);
+ purple_blist_node_set_int(PURPLE_BLIST_NODE(user->buddy), "UserID", user->id);
}
/* Need to store in MsimUser, too? What if not on blist? */
} else if (g_str_equal(key_str, "Age")) {
@@ -359,9 +366,8 @@ msim_store_user_info_each(const gchar *key_str, gchar *value_str, MsimUser *user
/* Instead of showing 'no photo' picture, show nothing. */
if (g_str_equal(user->image_url, "http://x.myspace.com/images/no_pic.gif"))
{
- purple_buddy_icons_set_for_user(user->buddy->account,
- user->buddy->name,
- NULL, 0, NULL);
+ purple_buddy_icons_set_for_user(purple_buddy_get_account(user->buddy),
+ name, NULL, 0, NULL);
return;
}
diff --git a/libpurple/protocols/myspace/zap.c b/libpurple/protocols/myspace/zap.c
index fdecee6..a1501b2 100644
--- a/libpurple/protocols/myspace/zap.c
+++ b/libpurple/protocols/myspace/zap.c
@@ -173,13 +173,13 @@ msim_send_zap_from_menu(PurpleBlistNode *node, gpointer zap_num_ptr)
buddy = (PurpleBuddy *)node;
/* Find the session */
- account = buddy->account;
+ account = purple_buddy_get_account(buddy);
gc = purple_account_get_connection(account);
session = (MsimSession *)gc->proto_data;
zap = GPOINTER_TO_INT(zap_num_ptr);
- purple_prpl_send_attention(session->gc, buddy->name, zap);
+ purple_prpl_send_attention(session->gc, purple_buddy_get_name(buddy), zap);
}
/** Return menu, if any, for a buddy list node. */
diff --git a/libpurple/protocols/novell/novell.c b/libpurple/protocols/novell/novell.c
index 55d4a53..50ca789 100644
--- a/libpurple/protocols/novell/novell.c
+++ b/libpurple/protocols/novell/novell.c
@@ -293,7 +293,7 @@ _get_details_resp_setup_buddy(NMUser * user, NMERR_T ret_code,
nm_user_record_get_display_id(user_record));
alias = purple_buddy_get_alias(buddy);
- if (alias == NULL || *alias == '\0' || (strcmp(alias, buddy->name) == 0)) {
+ if (alias == NULL || *alias == '\0' || (strcmp(alias, purple_buddy_get_name(buddy)) == 0)) {
purple_blist_alias_buddy(buddy,
nm_user_record_get_full_name(user_record));
@@ -1175,10 +1175,12 @@ _update_buddy_status(NMUser *user, PurpleBuddy * buddy, int novellstatus, int gm
const char *status_id;
const char *text = NULL;
const char *dn;
+ const char *name;
int idle = 0;
gboolean loggedin = TRUE;
- account = buddy->account;
+ account = purple_buddy_get_account(buddy);
+ name = purple_buddy_get_name(buddy);
switch (novellstatus) {
case NM_STATUS_AVAILABLE:
@@ -1205,7 +1207,7 @@ _update_buddy_status(NMUser *user, PurpleBuddy * buddy, int novellstatus, int gm
}
/* Get status text for the user */
- dn = nm_lookup_dn(user, buddy->name);
+ dn = nm_lookup_dn(user, name);
if (dn) {
NMUserRecord *user_record = nm_find_user_record(user, dn);
if (user_record) {
@@ -1213,9 +1215,9 @@ _update_buddy_status(NMUser *user, PurpleBuddy * buddy, int novellstatus, int gm
}
}
- purple_prpl_got_user_status(account, buddy->name, status_id,
+ purple_prpl_got_user_status(account, name, status_id,
"message", text, NULL);
- purple_prpl_got_user_idle(account, buddy->name,
+ purple_prpl_got_user_idle(account, name,
(novellstatus == NM_STATUS_AWAY_IDLE), idle);
}
@@ -1230,44 +1232,46 @@ _remove_purple_buddies(NMUser *user)
PurpleBlistNode *bnode;
PurpleGroup *group;
PurpleBuddy *buddy;
- PurpleBuddyList *blist;
GSList *rem_list = NULL;
GSList *l;
NMFolder *folder = NULL;
const char *gname = NULL;
- if ((blist = purple_get_blist())) {
- for (gnode = blist->root; gnode; gnode = gnode->next) {
- if (!PURPLE_BLIST_NODE_IS_GROUP(gnode))
+ for (gnode = purple_blist_get_root(); gnode;
+ gnode = purple_blist_node_get_sibling_next(gnode)) {
+ if (!PURPLE_BLIST_NODE_IS_GROUP(gnode))
+ continue;
+ group = (PurpleGroup *) gnode;
+ gname = purple_group_get_name(group);
+ for (cnode = purple_blist_node_get_first_child(gnode);
+ cnode;
+ cnode = purple_blist_node_get_sibling_next(cnode)) {
+ if (!PURPLE_BLIST_NODE_IS_CONTACT(cnode))
continue;
- group = (PurpleGroup *) gnode;
- for (cnode = gnode->child; cnode; cnode = cnode->next) {
- if (!PURPLE_BLIST_NODE_IS_CONTACT(cnode))
+ for (bnode = purple_blist_node_get_first_child(cnode);
+ bnode;
+ bnode = purple_blist_node_get_sibling_next(bnode)) {
+ if (!PURPLE_BLIST_NODE_IS_BUDDY(bnode))
continue;
- for (bnode = cnode->child; bnode; bnode = bnode->next) {
- if (!PURPLE_BLIST_NODE_IS_BUDDY(bnode))
- continue;
- buddy = (PurpleBuddy *) bnode;
- if (buddy->account == user->client_data) {
- gname = group->name;
- if (strcmp(group->name, NM_ROOT_FOLDER_NAME) == 0)
- gname = "";
- folder = nm_find_folder(user, gname);
- if (folder == NULL ||
- !nm_folder_find_contact_by_display_id(folder, buddy->name)) {
- rem_list = g_slist_append(rem_list, buddy);
- }
+ buddy = (PurpleBuddy *) bnode;
+ if (purple_buddy_get_account(buddy) == user->client_data) {
+ if (strcmp(gname, NM_ROOT_FOLDER_NAME) == 0)
+ gname = "";
+ folder = nm_find_folder(user, gname);
+ if (folder == NULL ||
+ !nm_folder_find_contact_by_display_id(folder, purple_buddy_get_name(buddy))) {
+ rem_list = g_slist_append(rem_list, buddy);
}
}
}
}
+ }
- if (rem_list) {
- for (l = rem_list; l; l = l->next) {
- purple_blist_remove_buddy(l->data);
- }
- g_slist_free(rem_list);
+ if (rem_list) {
+ for (l = rem_list; l; l = l->next) {
+ purple_blist_remove_buddy(l->data);
}
+ g_slist_free(rem_list);
}
}
@@ -1613,14 +1617,14 @@ _initiate_conference_cb(PurpleBlistNode *node, gpointer ignored)
g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
buddy = (PurpleBuddy *) node;
- gc = purple_account_get_connection(buddy->account);
+ gc = purple_account_get_connection(purple_buddy_get_account(buddy));
user = gc->proto_data;
if (user == NULL)
return;
/* We should already have a userrecord for the buddy */
- user_record = nm_find_user_record(user, buddy->name);
+ user_record = nm_find_user_record(user, purple_buddy_get_name(buddy));
if (user_record == NULL)
return;
@@ -2538,7 +2542,7 @@ novell_add_buddy(PurpleConnection * gc, PurpleBuddy *buddy, PurpleGroup * group)
NMContact *contact;
NMUser *user;
NMERR_T rc = NM_OK;
- const char *alias, *gname;
+ const char *alias, *gname, *bname;
if (gc == NULL || buddy == NULL || group == NULL)
return;
@@ -2554,22 +2558,22 @@ novell_add_buddy(PurpleConnection * gc, PurpleBuddy *buddy, PurpleGroup * group)
return;
contact = nm_create_contact();
- nm_contact_set_dn(contact, buddy->name);
+ nm_contact_set_dn(contact, purple_buddy_get_name(buddy));
/* Remove the PurpleBuddy (we will add it back after adding it
* to the server side list). Save the alias if there is one.
*/
alias = purple_buddy_get_alias(buddy);
- if (alias && strcmp(alias, buddy->name))
+ bname = purple_buddy_get_name(buddy);
+ if (alias && strcmp(alias, bname))
nm_contact_set_display_name(contact, alias);
purple_blist_remove_buddy(buddy);
buddy = NULL;
- if (strcmp(group->name, NM_ROOT_FOLDER_NAME) == 0) {
+ gname = purple_group_get_name(group);
+ if (strcmp(gname, NM_ROOT_FOLDER_NAME) == 0) {
gname = "";
- } else {
- gname = group->name;
}
folder = nm_find_folder(user, gname);
@@ -2603,11 +2607,10 @@ novell_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group
return;
user = (NMUser *) gc->proto_data;
- if (user && (dn = nm_lookup_dn(user, buddy->name))) {
- if (strcmp(group->name, NM_ROOT_FOLDER_NAME) == 0) {
+ if (user && (dn = nm_lookup_dn(user, purple_buddy_get_name(buddy)))) {
+ gname = purple_group_get_name(group);
+ if (strcmp(gname, NM_ROOT_FOLDER_NAME) == 0) {
gname = "";
- } else {
- gname = group->name;
}
folder = nm_find_folder(user, gname);
if (folder) {
@@ -2637,7 +2640,7 @@ novell_remove_group(PurpleConnection * gc, PurpleGroup *group)
user = (NMUser *) gc->proto_data;
if (user) {
- NMFolder *folder = nm_find_folder(user, group->name);
+ NMFolder *folder = nm_find_folder(user, purple_group_get_name(group));
if (folder) {
rc = nm_send_remove_folder(user, folder,
@@ -2684,9 +2687,11 @@ novell_alias_buddy(PurpleConnection * gc, const char *name, const char *alias)
}
if (group) {
+ const char *balias;
buddy = purple_find_buddy_in_group(user->client_data,
name, group);
- if (buddy && strcmp(buddy->alias, alias))
+ balias = buddy ? purple_buddy_get_local_buddy_alias(buddy) : NULL;
+ if (balias && strcmp(balias, alias))
purple_blist_alias_buddy(buddy, alias);
}
@@ -2777,8 +2782,9 @@ novell_rename_group(PurpleConnection * gc, const char *old_name,
user = gc->proto_data;
if (user) {
+ const char *gname = purple_group_get_name(group);
/* Does new folder exist already? */
- if (nm_find_folder(user, group->name)) {
+ if (nm_find_folder(user, gname)) {
/* purple_blist_rename_group() adds the buddies
* to the new group and removes the old group...
* so there is nothing more to do here.
@@ -2793,7 +2799,7 @@ novell_rename_group(PurpleConnection * gc, const char *old_name,
folder = nm_find_folder(user, old_name);
if (folder) {
- rc = nm_send_rename_folder(user, folder, group->name,
+ rc = nm_send_rename_folder(user, folder, gname,
_rename_folder_resp_cb, NULL);
_check_for_disconnect(user, rc);
}
@@ -2819,12 +2825,12 @@ novell_tooltip_text(PurpleBuddy * buddy, PurpleNotifyUserInfo * user_info, gbool
if (buddy == NULL)
return;
- gc = purple_account_get_connection(buddy->account);
+ gc = purple_account_get_connection(purple_buddy_get_account(buddy));
if (gc == NULL || (user = gc->proto_data) == NULL)
return;
if (PURPLE_BUDDY_IS_ONLINE(buddy)) {
- user_record = nm_find_user_record(user, buddy->name);
+ user_record = nm_find_user_record(user, purple_buddy_get_name(buddy));
if (user_record) {
status = nm_user_record_get_status(user_record);
text = nm_user_record_get_status_text(user_record);
@@ -2923,14 +2929,16 @@ novell_status_text(PurpleBuddy * buddy)
{
const char *text = NULL;
const char *dn = NULL;
+ PurpleAccount *account;
- if (buddy && buddy->account) {
- PurpleConnection *gc = purple_account_get_connection(buddy->account);
+ account = buddy ? purple_buddy_get_account(buddy) : NULL;
+ if (buddy && account) {
+ PurpleConnection *gc = purple_account_get_connection(account);
if (gc && gc->proto_data) {
NMUser *user = gc->proto_data;
- dn = nm_lookup_dn(user, buddy->name);
+ dn = nm_lookup_dn(user, purple_buddy_get_name(buddy));
if (dn) {
NMUserRecord *user_record = nm_find_user_record(user, dn);
diff --git a/libpurple/protocols/null/README b/libpurple/protocols/null/README
index a63e506..1e5d962 100644
--- a/libpurple/protocols/null/README
+++ b/libpurple/protocols/null/README
@@ -28,11 +28,10 @@ BUILDING AND INSTALLING
-----------------------
To build, just run ./configure as usual in the root directory of the pidgin
-source distribution. Then cd libpurple/protocols/null and type make. To
-install, copy libnull.la and .libs/libnull.so into your ~/.purple/plugins
-directory. Then run Pidgin.
+source distribution. Then cd libpurple/protocols/null and then make. To
+install, run make install. Then run Pidgin.
-To build nullprpl on Windows (with Cygwin/MinGW), use Makefile.mingw.
+To build nullprpl on Windows (with Cygwin/MinGW), use: make -f Makefile.mingw
-----
USAGE
diff --git a/libpurple/protocols/null/nullprpl.c b/libpurple/protocols/null/nullprpl.c
index 6515b56..21d2f63 100644
--- a/libpurple/protocols/null/nullprpl.c
+++ b/libpurple/protocols/null/nullprpl.c
@@ -220,25 +220,7 @@ static GList *nullprpl_actions(PurplePlugin *plugin, gpointer context)
*/
static const char *nullprpl_list_icon(PurpleAccount *acct, PurpleBuddy *buddy)
{
- /* shamelessly steal (er, borrow) the meanwhile protocol icon. it's cute! */
- return "meanwhile";
-}
-
-static const char *nullprpl_list_emblem(PurpleBuddy *buddy)
-{
- const char* emblem;
-
- if (get_nullprpl_gc(buddy->name)) {
- PurplePresence *presence = purple_buddy_get_presence(buddy);
- PurpleStatus *status = purple_presence_get_active_status(presence);
- emblem = purple_status_get_name(status);
- } else {
- emblem = "offline";
- }
-
- purple_debug_info("nullprpl", "using emblem %s for %s's buddy %s\n",
- emblem, buddy->account->username, buddy->name);
- return emblem;
+ return "null";
}
static char *nullprpl_status_text(PurpleBuddy *buddy) {
@@ -304,22 +286,22 @@ static GList *nullprpl_status_types(PurpleAccount *acct)
acct->username,
NULL_STATUS_ONLINE, NULL_STATUS_AWAY, NULL_STATUS_OFFLINE);
- type = purple_status_type_new(PURPLE_STATUS_AVAILABLE, NULL_STATUS_ONLINE,
- NULL_STATUS_ONLINE, TRUE);
- purple_status_type_add_attr(type, "message", _("Online"),
- purple_value_new(PURPLE_TYPE_STRING));
+ type = purple_status_type_new_with_attrs(PURPLE_STATUS_AVAILABLE,
+ NULL_STATUS_ONLINE, NULL, TRUE, TRUE, FALSE,
+ "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
+ NULL);
types = g_list_prepend(types, type);
- type = purple_status_type_new(PURPLE_STATUS_AWAY, NULL_STATUS_AWAY,
- NULL_STATUS_AWAY, TRUE);
- purple_status_type_add_attr(type, "message", _("Away"),
- purple_value_new(PURPLE_TYPE_STRING));
+ type = purple_status_type_new_with_attrs(PURPLE_STATUS_AWAY,
+ NULL_STATUS_AWAY, NULL, TRUE, TRUE, FALSE,
+ "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
+ NULL);
types = g_list_prepend(types, type);
-
- type = purple_status_type_new(PURPLE_STATUS_OFFLINE, NULL_STATUS_OFFLINE,
- NULL_STATUS_OFFLINE, TRUE);
- purple_status_type_add_attr(type, "message", _("Offline"),
- purple_value_new(PURPLE_TYPE_STRING));
+
+ type = purple_status_type_new_with_attrs(PURPLE_STATUS_OFFLINE,
+ NULL_STATUS_OFFLINE, NULL, TRUE, TRUE, FALSE,
+ "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
+ NULL);
types = g_list_prepend(types, type);
return g_list_reverse(types);
@@ -1073,7 +1055,7 @@ static PurplePluginProtocolInfo prpl_info =
PURPLE_ICON_SCALE_DISPLAY, /* scale_rules */
},
nullprpl_list_icon, /* list_icon */
- nullprpl_list_emblem, /* list_emblem */
+ NULL, /* list_emblem */
nullprpl_status_text, /* status_text */
nullprpl_tooltip_text, /* tooltip_text */
nullprpl_status_types, /* status_types */
@@ -1130,24 +1112,24 @@ static PurplePluginProtocolInfo prpl_info =
NULL, /* whiteboard_prpl_ops */
NULL, /* send_raw */
NULL, /* roomlist_room_serialize */
- NULL, /* padding... */
- NULL,
- NULL,
- sizeof(PurplePluginProtocolInfo), /* struct_size */
- NULL
+ NULL, /* unregister_user */
+ NULL, /* send_attention */
+ NULL, /* attention_types */
+ sizeof(PurplePluginProtocolInfo), /* struct_size */
+ NULL, /* get_account_text_table */
};
static void nullprpl_init(PurplePlugin *plugin)
{
/* see accountopt.h for information about user splits and protocol options */
PurpleAccountUserSplit *split = purple_account_user_split_new(
- _("Example user split (unused)"), /* text shown to user */
- "default", /* default value */
- '@'); /* field separator */
+ _("Example user split"), /* text shown to user */
+ "default", /* default value */
+ '@'); /* field separator */
PurpleAccountOption *option = purple_account_option_string_new(
- _("Example option (unused)"), /* text shown to user */
- "example", /* pref name */
- "default"); /* default value */
+ _("Example option"), /* text shown to user */
+ "example", /* pref name */
+ "default"); /* default value */
purple_debug_info("nullprpl", "starting up\n");
@@ -1156,13 +1138,13 @@ static void nullprpl_init(PurplePlugin *plugin)
/* register whisper chat command, /msg */
purple_cmd_register("msg",
- "ws", /* args: recipient and message */
+ "ws", /* args: recipient and message */
PURPLE_CMD_P_DEFAULT, /* priority */
PURPLE_CMD_FLAG_CHAT,
"prpl-null",
send_whisper,
"msg &lt;username&gt; &lt;message&gt;: send a private message, aka a whisper",
- NULL); /* userdata */
+ NULL); /* userdata */
/* get ready to store offline messages */
goffline_messages = g_hash_table_new_full(g_str_hash, /* hash fn */
@@ -1189,12 +1171,12 @@ static PurplePluginInfo info =
NULL, /* dependencies */
PURPLE_PRIORITY_DEFAULT, /* priority */
NULLPRPL_ID, /* id */
- "Nullprpl", /* name */
- "0.3", /* version */
- "Null Protocol Plugin", /* summary */
- "Null Protocol Plugin", /* description */
- "Ryan Barrett <nullprpl@ryanb.org>", /* author */
- "http://snarfed.org/space/pidgin+null+protocol+plugin", /* homepage */
+ "Null - Testing Plugin", /* name */
+ DISPLAY_VERSION, /* version */
+ N_("Null Protocol Plugin"), /* summary */
+ N_("Null Protocol Plugin"), /* description */
+ NULL, /* author */
+ PURPLE_WEBSITE, /* homepage */
NULL, /* load */
NULL, /* unload */
nullprpl_destroy, /* destroy */
diff --git a/libpurple/protocols/oscar/bstream.c b/libpurple/protocols/oscar/bstream.c
index 9119fe0..01e8db9 100644
--- a/libpurple/protocols/oscar/bstream.c
+++ b/libpurple/protocols/oscar/bstream.c
@@ -311,3 +311,37 @@ int byte_stream_putuid(ByteStream *bs, OscarData *od)
return byte_stream_putle32(bs, atoi(purple_account_get_username(account)));
}
+
+void byte_stream_put_bart_asset(ByteStream *bs, guint16 type, ByteStream *data)
+{
+ byte_stream_put16(bs, type);
+
+ if (data != NULL && data->len > 0) {
+ /* Flags. 0x04 means "this asset has data attached to it" */
+ byte_stream_put8(bs, 0x04); /* Flags */
+ byte_stream_put8(bs, data->len); /* Length */
+ byte_stream_rewind(data);
+ byte_stream_putbs(bs, data, data->len); /* Data */
+ } else {
+ byte_stream_put8(bs, 0x00); /* No flags */
+ byte_stream_put8(bs, 0x00); /* Length */
+ /* No data */
+ }
+}
+
+void byte_stream_put_bart_asset_str(ByteStream *bs, guint16 type, const char *datastr)
+{
+ ByteStream data;
+ size_t len = datastr != NULL ? strlen(datastr) : 0;
+
+ if (len > 0) {
+ byte_stream_new(&data, 2 + len + 2);
+ byte_stream_put16(&data, len); /* Length */
+ byte_stream_putstr(&data, datastr); /* String */
+ byte_stream_put16(&data, 0x0000); /* Unknown */
+ byte_stream_put_bart_asset(bs, type, &data);
+ byte_stream_destroy(&data);
+ } else {
+ byte_stream_put_bart_asset(bs, type, NULL);
+ }
+}
diff --git a/libpurple/protocols/oscar/family_admin.c b/libpurple/protocols/oscar/family_admin.c
index b111c3d..c276f12 100644
--- a/libpurple/protocols/oscar/family_admin.c
+++ b/libpurple/protocols/oscar/family_admin.c
@@ -21,9 +21,8 @@
/*
* Family 0x0007 - Account Administration.
*
- * Used for stuff like changing the formating of your screen name, changing your
+ * Used for stuff like changing the formating of your username, changing your
* email address, requesting an account confirmation email, getting account info,
- *
*/
#include "oscar.h"
@@ -32,7 +31,7 @@
* Subtype 0x0002 - Request a bit of account info.
*
* Info should be one of the following:
- * 0x0001 - Screen name formatting
+ * 0x0001 - Username formatting
* 0x0011 - Email address
* 0x0013 - Unknown
*/
@@ -111,7 +110,7 @@ infochange(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *fr
}
/**
- * Subtype 0x0004 - Set screenname formatting.
+ * Subtype 0x0004 - Set the formatting of username (change spaces and capitalization).
*/
void
aim_admin_setnick(OscarData *od, FlapConnection *conn, const char *newnick)
diff --git a/libpurple/protocols/oscar/family_alert.c b/libpurple/protocols/oscar/family_alert.c
index f945dec..df6f909 100644
--- a/libpurple/protocols/oscar/family_alert.c
+++ b/libpurple/protocols/oscar/family_alert.c
@@ -22,10 +22,10 @@
* Family 0x0018 - Email notification
*
* Used for being alerted when the email address(es) associated with
- * your screen name get new electronic-m. For normal AIM accounts, you
- * get the email address screenname@netscape.net. AOL accounts have
- * screenname@aol.com, and can also activate a netscape.net account.
- *
+ * your username get new electronic-m. For normal AIM accounts, you
+ * get the email address username@netscape.net. AOL accounts have
+ * username@aol.com, and can also activate a netscape.net account.
+ * Note: This information might be out of date.
*/
#include "oscar.h"
@@ -88,7 +88,7 @@ aim_email_sendcookies(OscarData *od)
* but this is coded so it will handle that, and handle it well.
* This tells you if you have unread mail or not, the URL you
* should use to access that mail, and the domain name for the
- * email account (screenname@domainname.com). If this is the
+ * email account (username@domainname.com). If this is the
* first 0x0007 SNAC you've received since you signed on, or if
* this is just a periodic status update, this will also contain
* the number of unread emails that you have.
diff --git a/libpurple/protocols/oscar/family_auth.c b/libpurple/protocols/oscar/family_auth.c
index ca7a069..9b8bbb5 100644
--- a/libpurple/protocols/oscar/family_auth.c
+++ b/libpurple/protocols/oscar/family_auth.c
@@ -229,7 +229,7 @@ aim_send_login(OscarData *od, FlapConnection *conn, const char *sn, const char *
/* Truncate ICQ and AOL passwords, if necessary */
password_len = strlen(password);
- if (aim_snvalid_icq(sn) && (password_len > MAXICQPASSLEN))
+ if (oscar_util_valid_name_icq(sn) && (password_len > MAXICQPASSLEN))
password_len = MAXICQPASSLEN;
else if (truncate_pass && password_len > 8)
password_len = 8;
@@ -293,11 +293,11 @@ parse(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame,
tlvlist = aim_tlvlist_read(bs);
/*
- * No matter what, we should have a screen name.
+ * No matter what, we should have a username.
*/
if (aim_tlv_gettlv(tlvlist, 0x0001, 1)) {
- info->sn = aim_tlv_getstr(tlvlist, 0x0001, 1);
- purple_connection_set_display_name(od->gc, info->sn);
+ info->bn = aim_tlv_getstr(tlvlist, 0x0001, 1);
+ purple_connection_set_display_name(od->gc, info->bn);
}
/*
@@ -394,7 +394,7 @@ parse(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame,
#if 0
/*
- * Unknown. Seen on an @mac.com screen name with value of 0x003f
+ * Unknown. Seen on an @mac.com username with value of 0x003f
*/
if (aim_tlv_gettlv(tlvlist, 0x0055, 1)) {
/* Unhandled */
@@ -421,7 +421,7 @@ parse(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame,
* - connect
* - server sends flap version
* - client sends flap version
- * - client sends screen name (17/6)
+ * - client sends username (17/6)
* - server sends hash key (17/7)
* - client sends auth request (17/2 -- aim_send_login)
* - server yells
@@ -460,7 +460,7 @@ goddamnicq(OscarData *od, FlapConnection *conn, const char *sn)
* Subtype 0x0006
*
* In AIM 3.5 protocol, the first stage of login is to request login from the
- * Authorizer, passing it the screen name for verification. If the name is
+ * Authorizer, passing it the username for verification. If the name is
* invalid, a 0017/0003 is spit back, with the standard error contents. If
* valid, a 0017/0007 comes back, which is the signal to send it the main
* login command (0017/0002).
@@ -527,7 +527,7 @@ keyparse(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *fram
/*
* If the truncate_pass TLV exists then we should truncate the
* user's password to 8 characters. This flag is sent to us
- * when logging in with an AOL user's screen name.
+ * when logging in with an AOL user's username.
*/
truncate_pass = aim_tlv_gettlv(tlvlist, 0x0026, 1) != NULL;
@@ -597,7 +597,7 @@ auth_shutdown(OscarData *od, aim_module_t *mod)
{
if (od->authinfo != NULL)
{
- g_free(od->authinfo->sn);
+ g_free(od->authinfo->bn);
g_free(od->authinfo->bosip);
g_free(od->authinfo->errorurl);
g_free(od->authinfo->email);
diff --git a/libpurple/protocols/oscar/family_bart.c b/libpurple/protocols/oscar/family_bart.c
index d699f91..ee38845 100644
--- a/libpurple/protocols/oscar/family_bart.c
+++ b/libpurple/protocols/oscar/family_bart.c
@@ -90,26 +90,26 @@ uploadack(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *fra
* Subtype 0x0004 - Request someone's icon.
*
* @param od The oscar session.
- * @param sn The screen name of the person who's icon you are requesting.
+ * @param bn The name of the buddy whose icon you are requesting.
* @param iconcsum The MD5 checksum of the icon you are requesting.
* @param iconcsumlen Length of the MD5 checksum given above. Should be 10 bytes.
* @return Return 0 if no errors, otherwise return the error number.
*/
int
-aim_bart_request(OscarData *od, const char *sn, guint8 iconcsumtype, const guint8 *iconcsum, guint16 iconcsumlen)
+aim_bart_request(OscarData *od, const char *bn, guint8 iconcsumtype, const guint8 *iconcsum, guint16 iconcsumlen)
{
FlapConnection *conn;
ByteStream bs;
aim_snacid_t snacid;
- if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_BART)) || !sn || !strlen(sn) || !iconcsum || !iconcsumlen)
+ if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_BART)) || !bn || !strlen(bn) || !iconcsum || !iconcsumlen)
return -EINVAL;
- byte_stream_new(&bs, 1+strlen(sn) + 4 + 1+iconcsumlen);
+ byte_stream_new(&bs, 1+strlen(bn) + 4 + 1+iconcsumlen);
- /* Screen name */
- byte_stream_put8(&bs, strlen(sn));
- byte_stream_putstr(&bs, sn);
+ /* Buddy name */
+ byte_stream_put8(&bs, strlen(bn));
+ byte_stream_putstr(&bs, bn);
/* Some numbers. You like numbers, right? */
byte_stream_put8(&bs, 0x01);
@@ -138,11 +138,11 @@ parseicon(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *fra
{
int ret = 0;
aim_rxcallback_t userfunc;
- char *sn;
+ char *bn;
guint16 flags, iconlen;
guint8 iconcsumtype, iconcsumlen, *iconcsum, *icon;
- sn = byte_stream_getstr(bs, byte_stream_get8(bs));
+ bn = byte_stream_getstr(bs, byte_stream_get8(bs));
flags = byte_stream_get16(bs);
iconcsumtype = byte_stream_get8(bs);
iconcsumlen = byte_stream_get8(bs);
@@ -151,9 +151,9 @@ parseicon(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *fra
icon = byte_stream_getraw(bs, iconlen);
if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
- ret = userfunc(od, conn, frame, sn, iconcsumtype, iconcsum, iconcsumlen, icon, iconlen);
+ ret = userfunc(od, conn, frame, bn, iconcsumtype, iconcsum, iconcsumlen, icon, iconlen);
- g_free(sn);
+ g_free(bn);
g_free(iconcsum);
g_free(icon);
diff --git a/libpurple/protocols/oscar/family_bos.c b/libpurple/protocols/oscar/family_bos.c
index e34eba4..2790b2e 100644
--- a/libpurple/protocols/oscar/family_bos.c
+++ b/libpurple/protocols/oscar/family_bos.c
@@ -94,8 +94,7 @@ aim_bos_setgroupperm(OscarData *od, FlapConnection *conn, guint32 mask)
* AIM_VISIBILITYCHANGE_DENYADD: Hides you from provided list of names
* AIM_VISIBILITYCHANGE_DENYREMOVE: Lets list see you again
*
- * list should be a list of
- * screen names in the form "Screen Name One&ScreenNameTwo&" etc.
+ * list should be a list of "Buddy Name One&BuddyNameTwo&" etc.
*
* Equivelents to options in WinAIM:
* - Allow all users to contact me: Send an AIM_VISIBILITYCHANGE_DENYADD
diff --git a/libpurple/protocols/oscar/family_buddy.c b/libpurple/protocols/oscar/family_buddy.c
index b20e0fc..3b98664 100644
--- a/libpurple/protocols/oscar/family_buddy.c
+++ b/libpurple/protocols/oscar/family_buddy.c
@@ -121,7 +121,7 @@ aim_buddylist_addbuddy(OscarData *od, FlapConnection *conn, const char *sn)
*
* This just builds the "set buddy list" command then queues it.
*
- * buddy_list = "Screen Name One&ScreenNameTwo&";
+ * buddy_list = "Buddy Name One&BuddyNameTwo&";
*
* XXX Clean this up.
*
@@ -222,7 +222,7 @@ buddychange(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *f
ret = userfunc(od, conn, frame, &userinfo);
if (snac->subtype == SNAC_SUBTYPE_BUDDY_ONCOMING && userinfo.flags & AIM_FLAG_AWAY)
- aim_locate_autofetch_away_message(od, userinfo.sn);
+ aim_locate_autofetch_away_message(od, userinfo.bn);
aim_info_free(&userinfo);
diff --git a/libpurple/protocols/oscar/family_feedbag.c b/libpurple/protocols/oscar/family_feedbag.c
index dcc32b7..0ef5370 100644
--- a/libpurple/protocols/oscar/family_feedbag.c
+++ b/libpurple/protocols/oscar/family_feedbag.c
@@ -243,7 +243,7 @@ static int aim_ssi_itemlist_cmp(struct aim_ssi_item *cur1, struct aim_ssi_item *
if (!cur1->name && cur2->name)
return 6;
- if (cur1->name && cur2->name && aim_sncmp(cur1->name, cur2->name))
+ if (cur1->name && cur2->name && oscar_util_name_compare(cur1->name, cur2->name))
return 7;
if (cur1->gid != cur2->gid)
@@ -285,8 +285,8 @@ struct aim_ssi_item *aim_ssi_itemlist_find(struct aim_ssi_item *list, guint16 gi
}
/**
- * Locally find an item given a group name, screen name, and type. If group name
- * and screen name are null, then just return the first item of the given type.
+ * Locally find an item given a group name, buddy name, and type. If group name
+ * and buddy name are null, then just return the first item of the given type.
*
* @param list A pointer to the current list of items.
* @param gn The group name of the desired item.
@@ -294,31 +294,31 @@ struct aim_ssi_item *aim_ssi_itemlist_find(struct aim_ssi_item *list, guint16 gi
* @param type The type of the desired item.
* @return Return a pointer to the item if found, else return NULL.
*/
-struct aim_ssi_item *aim_ssi_itemlist_finditem(struct aim_ssi_item *list, const char *gn, const char *sn, guint16 type)
+struct aim_ssi_item *aim_ssi_itemlist_finditem(struct aim_ssi_item *list, const char *gn, const char *bn, guint16 type)
{
struct aim_ssi_item *cur;
if (!list)
return NULL;
- if (gn && sn) { /* For finding buddies in groups */
+ if (gn && bn) { /* For finding buddies in groups */
for (cur=list; cur; cur=cur->next)
- if ((cur->type == type) && (cur->name) && !(aim_sncmp(cur->name, sn))) {
+ if ((cur->type == type) && (cur->name) && !(oscar_util_name_compare(cur->name, bn))) {
struct aim_ssi_item *curg;
for (curg=list; curg; curg=curg->next)
- if ((curg->type == AIM_SSI_TYPE_GROUP) && (curg->gid == cur->gid) && (curg->name) && !(aim_sncmp(curg->name, gn)))
+ if ((curg->type == AIM_SSI_TYPE_GROUP) && (curg->gid == cur->gid) && (curg->name) && !(oscar_util_name_compare(curg->name, gn)))
return cur;
}
} else if (gn) { /* For finding groups */
for (cur=list; cur; cur=cur->next) {
- if ((cur->type == type) && (cur->bid == 0x0000) && (cur->name) && !(aim_sncmp(cur->name, gn))) {
+ if ((cur->type == type) && (cur->bid == 0x0000) && (cur->name) && !(oscar_util_name_compare(cur->name, gn))) {
return cur;
}
}
- } else if (sn) { /* For finding permits, denies, and ignores */
+ } else if (bn) { /* For finding permits, denies, and ignores */
for (cur=list; cur; cur=cur->next) {
- if ((cur->type == type) && (cur->name) && !(aim_sncmp(cur->name, sn))) {
+ if ((cur->type == type) && (cur->name) && !(oscar_util_name_compare(cur->name, bn))) {
return cur;
}
}
@@ -336,14 +336,14 @@ struct aim_ssi_item *aim_ssi_itemlist_finditem(struct aim_ssi_item *list, const
* Check if the given buddy exists in any group in the buddy list.
*
* @param list A pointer to the current list of items.
- * @param sn The group name of the desired item.
+ * @param bn The group name of the desired item.
* @return Return a pointer to the name of the item if found, else return NULL;
*/
-struct aim_ssi_item *aim_ssi_itemlist_exists(struct aim_ssi_item *list, const char *sn)
+struct aim_ssi_item *aim_ssi_itemlist_exists(struct aim_ssi_item *list, const char *bn)
{
- if (!sn)
+ if (!bn)
return NULL;
- return aim_ssi_itemlist_finditem(list, NULL, sn, AIM_SSI_TYPE_BUDDY);
+ return aim_ssi_itemlist_finditem(list, NULL, bn, AIM_SSI_TYPE_BUDDY);
}
/**
@@ -353,12 +353,12 @@ struct aim_ssi_item *aim_ssi_itemlist_exists(struct aim_ssi_item *list, const ch
* @param bn The buddy name of the desired item.
* @return Return a pointer to the name of the item if found, else return NULL;
*/
-char *aim_ssi_itemlist_findparentname(struct aim_ssi_item *list, const char *sn)
+char *aim_ssi_itemlist_findparentname(struct aim_ssi_item *list, const char *bn)
{
struct aim_ssi_item *cur, *curg;
- if (!list || !sn)
+ if (!list || !bn)
return NULL;
- if (!(cur = aim_ssi_itemlist_exists(list, sn)))
+ if (!(cur = aim_ssi_itemlist_exists(list, bn)))
return NULL;
if (!(curg = aim_ssi_itemlist_find(list, cur->gid, 0x0000)))
return NULL;
@@ -406,14 +406,14 @@ guint32 aim_ssi_getpresence(struct aim_ssi_item *list)
*
* @param list A pointer to the current list of items.
* @param gn The group of the buddy.
- * @param sn The name of the buddy.
+ * @param bn The name of the buddy.
* @return A pointer to a NULL terminated string that is the buddy's
* alias, or NULL if the buddy has no alias. You should free
* this returned value!
*/
-char *aim_ssi_getalias(struct aim_ssi_item *list, const char *gn, const char *sn)
+char *aim_ssi_getalias(struct aim_ssi_item *list, const char *gn, const char *bn)
{
- struct aim_ssi_item *cur = aim_ssi_itemlist_finditem(list, gn, sn, AIM_SSI_TYPE_BUDDY);
+ struct aim_ssi_item *cur = aim_ssi_itemlist_finditem(list, gn, bn, AIM_SSI_TYPE_BUDDY);
if (cur) {
aim_tlv_t *tlv = aim_tlv_gettlv(cur->data, 0x0131, 1);
if (tlv && tlv->length)
@@ -427,14 +427,14 @@ char *aim_ssi_getalias(struct aim_ssi_item *list, const char *gn, const char *sn
*
* @param list A pointer to the current list of items.
* @param gn The group of the buddy.
- * @param sn The name of the buddy.
+ * @param bn The name of the buddy.
* @return A pointer to a NULL terminated string that is the buddy's
* comment, or NULL if the buddy has no comment. You should free
* this returned value!
*/
-char *aim_ssi_getcomment(struct aim_ssi_item *list, const char *gn, const char *sn)
+char *aim_ssi_getcomment(struct aim_ssi_item *list, const char *gn, const char *bn)
{
- struct aim_ssi_item *cur = aim_ssi_itemlist_finditem(list, gn, sn, AIM_SSI_TYPE_BUDDY);
+ struct aim_ssi_item *cur = aim_ssi_itemlist_finditem(list, gn, bn, AIM_SSI_TYPE_BUDDY);
if (cur) {
aim_tlv_t *tlv = aim_tlv_gettlv(cur->data, 0x013c, 1);
if (tlv && tlv->length) {
@@ -449,12 +449,12 @@ char *aim_ssi_getcomment(struct aim_ssi_item *list, const char *gn, const char *
*
* @param list A pointer to the current list of items.
* @param gn The group of the buddy.
- * @param sn The name of the buddy.
+ * @param bn The name of the buddy.
* @return 1 if you are waiting for authorization; 0 if you are not
*/
-gboolean aim_ssi_waitingforauth(struct aim_ssi_item *list, const char *gn, const char *sn)
+gboolean aim_ssi_waitingforauth(struct aim_ssi_item *list, const char *gn, const char *bn)
{
- struct aim_ssi_item *cur = aim_ssi_itemlist_finditem(list, gn, sn, AIM_SSI_TYPE_BUDDY);
+ struct aim_ssi_item *cur = aim_ssi_itemlist_finditem(list, gn, bn, AIM_SSI_TYPE_BUDDY);
if (cur) {
if (aim_tlv_gettlv(cur->data, 0x0066, 1))
return TRUE;
@@ -678,7 +678,7 @@ int aim_ssi_cleanlist(OscarData *od)
cur2 = cur->next;
while (cur2) {
next2 = cur2->next;
- if ((cur->type == cur2->type) && (cur->gid == cur2->gid) && (cur->name != NULL) && (cur2->name != NULL) && (!aim_sncmp(cur->name, cur2->name))) {
+ if ((cur->type == cur2->type) && (cur->gid == cur2->gid) && (cur->name != NULL) && (cur2->name != NULL) && (!oscar_util_name_compare(cur->name, cur2->name))) {
aim_ssi_itemlist_del(&od->ssi.local, cur2);
}
cur2 = next2;
@@ -916,16 +916,16 @@ int aim_ssi_deldeny(OscarData *od, const char *name)
* @param od The oscar odion.
* @param oldgn The group that the buddy is currently in.
* @param newgn The group that the buddy should be moved in to.
- * @param sn The name of the buddy to be moved.
+ * @param bn The name of the buddy to be moved.
* @return Return 0 if no errors, otherwise return the error number.
*/
-int aim_ssi_movebuddy(OscarData *od, const char *oldgn, const char *newgn, const char *sn)
+int aim_ssi_movebuddy(OscarData *od, const char *oldgn, const char *newgn, const char *bn)
{
struct aim_ssi_item *buddy;
GSList *data;
/* Find the buddy */
- buddy = aim_ssi_itemlist_finditem(od->ssi.local, oldgn, sn, AIM_SSI_TYPE_BUDDY);
+ buddy = aim_ssi_itemlist_finditem(od->ssi.local, oldgn, bn, AIM_SSI_TYPE_BUDDY);
if (buddy == NULL)
return -EINVAL;
@@ -933,10 +933,10 @@ int aim_ssi_movebuddy(OscarData *od, const char *oldgn, const char *newgn, const
data = aim_tlvlist_copy(buddy->data);
/* Delete the old item */
- aim_ssi_delbuddy(od, sn, oldgn);
+ aim_ssi_delbuddy(od, bn, oldgn);
/* Add the new item using the EXACT SAME TLV list */
- aim_ssi_addbuddy(od, sn, newgn, data, NULL, NULL, NULL, FALSE);
+ aim_ssi_addbuddy(od, bn, newgn, data, NULL, NULL, NULL, FALSE);
return 0;
}
@@ -946,19 +946,19 @@ int aim_ssi_movebuddy(OscarData *od, const char *oldgn, const char *newgn, const
*
* @param od The oscar odion.
* @param gn The group that the buddy is currently in.
- * @param sn The screen name of the buddy.
+ * @param bn The name of the buddy.
* @param alias The new alias for the buddy, or NULL if you want to remove
* a buddy's comment.
* @return Return 0 if no errors, otherwise return the error number.
*/
-int aim_ssi_aliasbuddy(OscarData *od, const char *gn, const char *sn, const char *alias)
+int aim_ssi_aliasbuddy(OscarData *od, const char *gn, const char *bn, const char *alias)
{
struct aim_ssi_item *tmp;
- if (!od || !gn || !sn)
+ if (!od || !gn || !bn)
return -EINVAL;
- if (!(tmp = aim_ssi_itemlist_finditem(od->ssi.local, gn, sn, AIM_SSI_TYPE_BUDDY)))
+ if (!(tmp = aim_ssi_itemlist_finditem(od->ssi.local, gn, bn, AIM_SSI_TYPE_BUDDY)))
return -EINVAL;
/* Either add or remove the 0x0131 TLV from the TLV chain */
@@ -976,19 +976,19 @@ int aim_ssi_aliasbuddy(OscarData *od, const char *gn, const char *sn, const char
*
* @param od The oscar odion.
* @param gn The group that the buddy is currently in.
- * @param sn The screen name of the buddy.
+ * @param bn The name of the buddy.
* @param alias The new comment for the buddy, or NULL if you want to remove
* a buddy's comment.
* @return Return 0 if no errors, otherwise return the error number.
*/
-int aim_ssi_editcomment(OscarData *od, const char *gn, const char *sn, const char *comment)
+int aim_ssi_editcomment(OscarData *od, const char *gn, const char *bn, const char *comment)
{
struct aim_ssi_item *tmp;
- if (!od || !gn || !sn)
+ if (!od || !gn || !bn)
return -EINVAL;
- if (!(tmp = aim_ssi_itemlist_finditem(od->ssi.local, gn, sn, AIM_SSI_TYPE_BUDDY)))
+ if (!(tmp = aim_ssi_itemlist_finditem(od->ssi.local, gn, bn, AIM_SSI_TYPE_BUDDY)))
return -EINVAL;
/* Either add or remove the 0x0131 TLV from the TLV chain */
@@ -1681,20 +1681,20 @@ int aim_ssi_modend(OscarData *od)
* Authorizes a contact so they can add you to their contact list.
*
*/
-int aim_ssi_sendauth(OscarData *od, char *sn, char *msg)
+int aim_ssi_sendauth(OscarData *od, char *bn, char *msg)
{
FlapConnection *conn;
ByteStream bs;
aim_snacid_t snacid;
- if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_FEEDBAG)) || !sn)
+ if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_FEEDBAG)) || !bn)
return -EINVAL;
- byte_stream_new(&bs, 1+strlen(sn) + 2+(msg ? strlen(msg)+1 : 0) + 2);
+ byte_stream_new(&bs, 1+strlen(bn) + 2+(msg ? strlen(msg)+1 : 0) + 2);
- /* Screen name */
- byte_stream_put8(&bs, strlen(sn));
- byte_stream_putstr(&bs, sn);
+ /* Username */
+ byte_stream_put8(&bs, strlen(bn));
+ byte_stream_putstr(&bs, bn);
/* Message (null terminated) */
byte_stream_put16(&bs, msg ? strlen(msg) : 0);
@@ -1722,13 +1722,13 @@ static int receiveauthgrant(OscarData *od, FlapConnection *conn, aim_module_t *m
int ret = 0;
aim_rxcallback_t userfunc;
guint16 tmp;
- char *sn, *msg;
+ char *bn, *msg;
- /* Read screen name */
+ /* Read buddy name */
if ((tmp = byte_stream_get8(bs)))
- sn = byte_stream_getstr(bs, tmp);
+ bn = byte_stream_getstr(bs, tmp);
else
- sn = NULL;
+ bn = NULL;
/* Read message (null terminated) */
if ((tmp = byte_stream_get16(bs)))
@@ -1740,9 +1740,9 @@ static int receiveauthgrant(OscarData *od, FlapConnection *conn, aim_module_t *m
tmp = byte_stream_get16(bs);
if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
- ret = userfunc(od, conn, frame, sn, msg);
+ ret = userfunc(od, conn, frame, bn, msg);
- g_free(sn);
+ g_free(bn);
g_free(msg);
return ret;
@@ -1755,20 +1755,20 @@ static int receiveauthgrant(OscarData *od, FlapConnection *conn, aim_module_t *m
* granted, denied, or dropped.
*
*/
-int aim_ssi_sendauthrequest(OscarData *od, char *sn, const char *msg)
+int aim_ssi_sendauthrequest(OscarData *od, char *bn, const char *msg)
{
FlapConnection *conn;
ByteStream bs;
aim_snacid_t snacid;
- if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_FEEDBAG)) || !sn)
+ if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_FEEDBAG)) || !bn)
return -EINVAL;
- byte_stream_new(&bs, 1+strlen(sn) + 2+(msg ? strlen(msg)+1 : 0) + 2);
+ byte_stream_new(&bs, 1+strlen(bn) + 2+(msg ? strlen(msg)+1 : 0) + 2);
- /* Screen name */
- byte_stream_put8(&bs, strlen(sn));
- byte_stream_putstr(&bs, sn);
+ /* Username */
+ byte_stream_put8(&bs, strlen(bn));
+ byte_stream_putstr(&bs, bn);
/* Message (null terminated) */
byte_stream_put16(&bs, msg ? strlen(msg) : 0);
@@ -1796,13 +1796,13 @@ static int receiveauthrequest(OscarData *od, FlapConnection *conn, aim_module_t
int ret = 0;
aim_rxcallback_t userfunc;
guint16 tmp;
- char *sn, *msg;
+ char *bn, *msg;
- /* Read screen name */
+ /* Read buddy name */
if ((tmp = byte_stream_get8(bs)))
- sn = byte_stream_getstr(bs, tmp);
+ bn = byte_stream_getstr(bs, tmp);
else
- sn = NULL;
+ bn = NULL;
/* Read message (null terminated) */
if ((tmp = byte_stream_get16(bs)))
@@ -1814,9 +1814,9 @@ static int receiveauthrequest(OscarData *od, FlapConnection *conn, aim_module_t
tmp = byte_stream_get16(bs);
if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
- ret = userfunc(od, conn, frame, sn, msg);
+ ret = userfunc(od, conn, frame, bn, msg);
- g_free(sn);
+ g_free(bn);
g_free(msg);
return ret;
@@ -1832,20 +1832,20 @@ static int receiveauthrequest(OscarData *od, FlapConnection *conn, aim_module_t
* if reply=0x01 then grant
*
*/
-int aim_ssi_sendauthreply(OscarData *od, char *sn, guint8 reply, const char *msg)
+int aim_ssi_sendauthreply(OscarData *od, char *bn, guint8 reply, const char *msg)
{
FlapConnection *conn;
ByteStream bs;
aim_snacid_t snacid;
- if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_FEEDBAG)) || !sn)
+ if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_FEEDBAG)) || !bn)
return -EINVAL;
- byte_stream_new(&bs, 1+strlen(sn) + 1 + 2+(msg ? (strlen(msg)+1) : 0) + 2);
+ byte_stream_new(&bs, 1+strlen(bn) + 1 + 2+(msg ? (strlen(msg)+1) : 0) + 2);
- /* Screen name */
- byte_stream_put8(&bs, strlen(sn));
- byte_stream_putstr(&bs, sn);
+ /* Username */
+ byte_stream_put8(&bs, strlen(bn));
+ byte_stream_putstr(&bs, bn);
/* Grant or deny */
byte_stream_put8(&bs, reply);
@@ -1880,13 +1880,13 @@ static int receiveauthreply(OscarData *od, FlapConnection *conn, aim_module_t *m
aim_rxcallback_t userfunc;
guint16 tmp;
guint8 reply;
- char *sn, *msg;
+ char *bn, *msg;
- /* Read screen name */
+ /* Read buddy name */
if ((tmp = byte_stream_get8(bs)))
- sn = byte_stream_getstr(bs, tmp);
+ bn = byte_stream_getstr(bs, tmp);
else
- sn = NULL;
+ bn = NULL;
/* Read reply */
reply = byte_stream_get8(bs);
@@ -1901,9 +1901,9 @@ static int receiveauthreply(OscarData *od, FlapConnection *conn, aim_module_t *m
tmp = byte_stream_get16(bs);
if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
- ret = userfunc(od, conn, frame, sn, reply, msg);
+ ret = userfunc(od, conn, frame, bn, reply, msg);
- g_free(sn);
+ g_free(bn);
g_free(msg);
return ret;
@@ -1917,18 +1917,18 @@ static int receiveadded(OscarData *od, FlapConnection *conn, aim_module_t *mod,
int ret = 0;
aim_rxcallback_t userfunc;
guint16 tmp;
- char *sn;
+ char *bn;
- /* Read screen name */
+ /* Read buddy name */
if ((tmp = byte_stream_get8(bs)))
- sn = byte_stream_getstr(bs, tmp);
+ bn = byte_stream_getstr(bs, tmp);
else
- sn = NULL;
+ bn = NULL;
if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
- ret = userfunc(od, conn, frame, sn);
+ ret = userfunc(od, conn, frame, bn);
- g_free(sn);
+ g_free(bn);
return ret;
}
diff --git a/libpurple/protocols/oscar/family_icbm.c b/libpurple/protocols/oscar/family_icbm.c
index 3bd9fae..c217e0f 100644
--- a/libpurple/protocols/oscar/family_icbm.c
+++ b/libpurple/protocols/oscar/family_icbm.c
@@ -61,16 +61,16 @@
* @param bs The bstream to write the ICBM header to.
* @param c c is for cookie, and cookie is for me.
* @param channel The ICBM channel (1 through 4).
- * @param sn Null-terminated scrizeen nizame.
+ * @param bn Null-terminated scrizeen nizame.
* @return The number of bytes written. It's really not useful.
*/
-static int aim_im_puticbm(ByteStream *bs, const guchar *c, guint16 channel, const char *sn)
+static int aim_im_puticbm(ByteStream *bs, const guchar *c, guint16 channel, const char *bn)
{
byte_stream_putraw(bs, c, 8);
byte_stream_put16(bs, channel);
- byte_stream_put8(bs, strlen(sn));
- byte_stream_putstr(bs, sn);
- return 8+2+1+strlen(sn);
+ byte_stream_put8(bs, strlen(bn));
+ byte_stream_putstr(bs, bn);
+ return 8+2+1+strlen(bn);
}
/**
@@ -324,7 +324,7 @@ int aim_im_sendch1_ext(OscarData *od, struct aim_sendimext_args *args)
aim_icbm_makecookie(cookie);
/* ICBM header */
- aim_im_puticbm(&data, cookie, 0x0001, args->destsn);
+ aim_im_puticbm(&data, cookie, 0x0001, args->destbn);
/* Message TLV (type 0x0002) */
byte_stream_put16(&data, 0x0002);
@@ -410,7 +410,7 @@ int aim_im_sendch1_ext(OscarData *od, struct aim_sendimext_args *args)
}
/* XXX - should be optional */
- snacid = aim_cachesnac(od, SNAC_FAMILY_ICBM, 0x0006, 0x0000, args->destsn, strlen(args->destsn)+1);
+ snacid = aim_cachesnac(od, SNAC_FAMILY_ICBM, 0x0006, 0x0000, args->destbn, strlen(args->destbn)+1);
flap_connection_send_snac(od, conn, SNAC_FAMILY_ICBM, 0x0006, 0x0000, snacid, &data);
byte_stream_destroy(&data);
@@ -431,11 +431,11 @@ int aim_im_sendch1_ext(OscarData *od, struct aim_sendimext_args *args)
* that requires an explicit message length. Use aim_im_sendch1_ext().
*
*/
-int aim_im_sendch1(OscarData *od, const char *sn, guint16 flags, const char *msg)
+int aim_im_sendch1(OscarData *od, const char *bn, guint16 flags, const char *msg)
{
struct aim_sendimext_args args;
- args.destsn = sn;
+ args.destbn = bn;
args.flags = flags;
args.msg = msg;
args.msglen = strlen(msg);
@@ -451,7 +451,7 @@ int aim_im_sendch1(OscarData *od, const char *sn, guint16 flags, const char *msg
/*
* Subtype 0x0006 - Send a chat invitation.
*/
-int aim_im_sendch2_chatinvite(OscarData *od, const char *sn, const char *msg, guint16 exchange, const char *roomname, guint16 instance)
+int aim_im_sendch2_chatinvite(OscarData *od, const char *bn, const char *msg, guint16 exchange, const char *roomname, guint16 instance)
{
FlapConnection *conn;
ByteStream bs;
@@ -465,18 +465,18 @@ int aim_im_sendch2_chatinvite(OscarData *od, const char *sn, const char *msg, gu
if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_ICBM)))
return -EINVAL;
- if (!sn || !msg || !roomname)
+ if (!bn || !msg || !roomname)
return -EINVAL;
aim_icbm_makecookie(cookie);
- byte_stream_new(&bs, 1142+strlen(sn)+strlen(roomname)+strlen(msg));
+ byte_stream_new(&bs, 1142+strlen(bn)+strlen(roomname)+strlen(msg));
- snacid = aim_cachesnac(od, SNAC_FAMILY_ICBM, 0x0006, 0x0000, sn, strlen(sn)+1);
+ snacid = aim_cachesnac(od, SNAC_FAMILY_ICBM, 0x0006, 0x0000, bn, strlen(bn)+1);
/* XXX should be uncached by an unwritten 'invite accept' handler */
priv = g_malloc(sizeof(struct aim_invite_priv));
- priv->sn = g_strdup(sn);
+ priv->bn = g_strdup(bn);
priv->roomname = g_strdup(roomname);
priv->exchange = exchange;
priv->instance = instance;
@@ -487,7 +487,7 @@ int aim_im_sendch2_chatinvite(OscarData *od, const char *sn, const char *msg, gu
g_free(priv);
/* ICBM Header */
- aim_im_puticbm(&bs, cookie, 0x0002, sn);
+ aim_im_puticbm(&bs, cookie, 0x0002, bn);
/*
* TLV t(0005)
@@ -532,7 +532,7 @@ int aim_im_sendch2_chatinvite(OscarData *od, const char *sn, const char *msg, gu
* This is also performance sensitive. (If you can believe it...)
*
*/
-int aim_im_sendch2_icon(OscarData *od, const char *sn, const guint8 *icon, int iconlen, time_t stamp, guint16 iconsum)
+int aim_im_sendch2_icon(OscarData *od, const char *bn, const guint8 *icon, int iconlen, time_t stamp, guint16 iconsum)
{
FlapConnection *conn;
ByteStream bs;
@@ -542,17 +542,17 @@ int aim_im_sendch2_icon(OscarData *od, const char *sn, const guint8 *icon, int i
if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_ICBM)))
return -EINVAL;
- if (!sn || !icon || (iconlen <= 0) || (iconlen >= MAXICONLEN))
+ if (!bn || !icon || (iconlen <= 0) || (iconlen >= MAXICONLEN))
return -EINVAL;
aim_icbm_makecookie(cookie);
- byte_stream_new(&bs, 8+2+1+strlen(sn)+2+2+2+8+16+2+2+2+2+2+2+2+4+4+4+iconlen+strlen(AIM_ICONIDENT)+2+2);
+ byte_stream_new(&bs, 8+2+1+strlen(bn)+2+2+2+8+16+2+2+2+2+2+2+2+4+4+4+iconlen+strlen(AIM_ICONIDENT)+2+2);
snacid = aim_cachesnac(od, SNAC_FAMILY_ICBM, 0x0006, 0x0000, NULL, 0);
/* ICBM header */
- aim_im_puticbm(&bs, cookie, 0x0002, sn);
+ aim_im_puticbm(&bs, cookie, 0x0002, bn);
/*
* TLV t(0005)
@@ -623,7 +623,7 @@ int aim_im_sendch2_rtfmsg(OscarData *od, struct aim_sendrtfmsg_args *args)
if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_ICBM)))
return -EINVAL;
- if (!args || !args->destsn || !args->rtfmsg)
+ if (!args || !args->destbn || !args->rtfmsg)
return -EINVAL;
servdatalen = 2+2+16+2+4+1+2 + 2+2+4+4+4 + 2+4+2+strlen(args->rtfmsg)+1 + 4+4+4+strlen(rtfcap)+1;
@@ -635,7 +635,7 @@ int aim_im_sendch2_rtfmsg(OscarData *od, struct aim_sendrtfmsg_args *args)
snacid = aim_cachesnac(od, SNAC_FAMILY_ICBM, 0x0006, 0x0000, NULL, 0);
/* ICBM header */
- aim_im_puticbm(&bs, cookie, 0x0002, args->destsn);
+ aim_im_puticbm(&bs, cookie, 0x0002, args->destbn);
/* TLV t(0005) - Encompasses everything below. */
byte_stream_put16(&bs, 0x0005);
@@ -708,12 +708,12 @@ aim_im_sendch2_cancel(PeerConnection *peer_conn)
if (conn == NULL)
return;
- byte_stream_new(&bs, 118+strlen(peer_conn->sn));
+ byte_stream_new(&bs, 118+strlen(peer_conn->bn));
snacid = aim_cachesnac(od, SNAC_FAMILY_ICBM, 0x0006, 0x0000, NULL, 0);
/* ICBM header */
- aim_im_puticbm(&bs, peer_conn->cookie, 0x0002, peer_conn->sn);
+ aim_im_puticbm(&bs, peer_conn->cookie, 0x0002, peer_conn->bn);
aim_tlvlist_add_noval(&outer_tlvlist, 0x0003);
@@ -757,12 +757,12 @@ aim_im_sendch2_connected(PeerConnection *peer_conn)
if (conn == NULL)
return;
- byte_stream_new(&bs, 11+strlen(peer_conn->sn) + 4+2+8+16);
+ byte_stream_new(&bs, 11+strlen(peer_conn->bn) + 4+2+8+16);
snacid = aim_cachesnac(od, SNAC_FAMILY_ICBM, 0x0006, 0x0000, NULL, 0);
/* ICBM header */
- aim_im_puticbm(&bs, peer_conn->cookie, 0x0002, peer_conn->sn);
+ aim_im_puticbm(&bs, peer_conn->cookie, 0x0002, peer_conn->bn);
byte_stream_put16(&bs, 0x0005);
byte_stream_put16(&bs, 0x001a);
@@ -783,7 +783,7 @@ aim_im_sendch2_connected(PeerConnection *peer_conn)
* "I want to connect through a proxy server"
*/
void
-aim_im_sendch2_odc_requestdirect(OscarData *od, guchar *cookie, const char *sn, const guint8 *ip, guint16 port, guint16 requestnumber)
+aim_im_sendch2_odc_requestdirect(OscarData *od, guchar *cookie, const char *bn, const guint8 *ip, guint16 port, guint16 requestnumber)
{
FlapConnection *conn;
ByteStream bs;
@@ -795,12 +795,12 @@ aim_im_sendch2_odc_requestdirect(OscarData *od, guchar *cookie, const char *sn,
if (conn == NULL)
return;
- byte_stream_new(&bs, 246+strlen(sn));
+ byte_stream_new(&bs, 246+strlen(bn));
snacid = aim_cachesnac(od, SNAC_FAMILY_ICBM, 0x0006, 0x0000, NULL, 0);
/* ICBM header */
- aim_im_puticbm(&bs, cookie, 0x0002, sn);
+ aim_im_puticbm(&bs, cookie, 0x0002, bn);
aim_tlvlist_add_noval(&outer_tlvlist, 0x0003);
@@ -835,7 +835,7 @@ aim_im_sendch2_odc_requestdirect(OscarData *od, guchar *cookie, const char *sn,
* remote user to connect to us via a proxy server.
*/
void
-aim_im_sendch2_odc_requestproxy(OscarData *od, guchar *cookie, const char *sn, const guint8 *ip, guint16 pin, guint16 requestnumber)
+aim_im_sendch2_odc_requestproxy(OscarData *od, guchar *cookie, const char *bn, const guint8 *ip, guint16 pin, guint16 requestnumber)
{
FlapConnection *conn;
ByteStream bs;
@@ -848,12 +848,12 @@ aim_im_sendch2_odc_requestproxy(OscarData *od, guchar *cookie, const char *sn, c
if (conn == NULL)
return;
- byte_stream_new(&bs, 246+strlen(sn));
+ byte_stream_new(&bs, 246+strlen(bn));
snacid = aim_cachesnac(od, SNAC_FAMILY_ICBM, 0x0006, 0x0000, NULL, 0);
/* ICBM header */
- aim_im_puticbm(&bs, cookie, 0x0002, sn);
+ aim_im_puticbm(&bs, cookie, 0x0002, bn);
aim_tlvlist_add_noval(&outer_tlvlist, 0x0003);
@@ -898,7 +898,7 @@ aim_im_sendch2_odc_requestproxy(OscarData *od, guchar *cookie, const char *sn, c
*
*/
void
-aim_im_sendch2_sendfile_requestdirect(OscarData *od, guchar *cookie, const char *sn, const guint8 *ip, guint16 port, guint16 requestnumber, const gchar *filename, guint32 size, guint16 numfiles)
+aim_im_sendch2_sendfile_requestdirect(OscarData *od, guchar *cookie, const char *bn, const guint8 *ip, guint16 port, guint16 requestnumber, const gchar *filename, guint32 size, guint16 numfiles)
{
FlapConnection *conn;
ByteStream bs;
@@ -915,7 +915,7 @@ aim_im_sendch2_sendfile_requestdirect(OscarData *od, guchar *cookie, const char
snacid = aim_cachesnac(od, SNAC_FAMILY_ICBM, 0x0006, 0x0000, NULL, 0);
/* ICBM header */
- aim_im_puticbm(&bs, cookie, 0x0002, sn);
+ aim_im_puticbm(&bs, cookie, 0x0002, bn);
aim_tlvlist_add_noval(&outer_tlvlist, 0x0003);
@@ -981,7 +981,7 @@ aim_im_sendch2_sendfile_requestdirect(OscarData *od, guchar *cookie, const char
* remote user to connect to us via a proxy server.
*/
void
-aim_im_sendch2_sendfile_requestproxy(OscarData *od, guchar *cookie, const char *sn, const guint8 *ip, guint16 pin, guint16 requestnumber, const gchar *filename, guint32 size, guint16 numfiles)
+aim_im_sendch2_sendfile_requestproxy(OscarData *od, guchar *cookie, const char *bn, const guint8 *ip, guint16 pin, guint16 requestnumber, const gchar *filename, guint32 size, guint16 numfiles)
{
FlapConnection *conn;
ByteStream bs;
@@ -999,7 +999,7 @@ aim_im_sendch2_sendfile_requestproxy(OscarData *od, guchar *cookie, const char *
snacid = aim_cachesnac(od, SNAC_FAMILY_ICBM, 0x0006, 0x0000, NULL, 0);
/* ICBM header */
- aim_im_puticbm(&bs, cookie, 0x0002, sn);
+ aim_im_puticbm(&bs, cookie, 0x0002, bn);
aim_tlvlist_add_noval(&outer_tlvlist, 0x0003);
@@ -1073,29 +1073,29 @@ aim_im_sendch2_sendfile_requestproxy(OscarData *od, guchar *cookie, const char *
* Subtype 0x0006 - Request the status message of the given ICQ user.
*
* @param od The oscar session.
- * @param sn The UIN of the user of whom you wish to request info.
+ * @param bn The UIN of the user of whom you wish to request info.
* @param type The type of info you wish to request. This should be the current
* state of the user, as one of the AIM_ICQ_STATE_* defines.
* @return Return 0 if no errors, otherwise return the error number.
*/
-int aim_im_sendch2_geticqaway(OscarData *od, const char *sn, int type)
+int aim_im_sendch2_geticqaway(OscarData *od, const char *bn, int type)
{
FlapConnection *conn;
ByteStream bs;
aim_snacid_t snacid;
guchar cookie[8];
- if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_ICBM)) || !sn)
+ if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_ICBM)) || !bn)
return -EINVAL;
aim_icbm_makecookie(cookie);
- byte_stream_new(&bs, 8+2+1+strlen(sn) + 4+0x5e + 4);
+ byte_stream_new(&bs, 8+2+1+strlen(bn) + 4+0x5e + 4);
snacid = aim_cachesnac(od, SNAC_FAMILY_ICBM, 0x0006, 0x0000, NULL, 0);
/* ICBM header */
- aim_im_puticbm(&bs, cookie, 0x0002, sn);
+ aim_im_puticbm(&bs, cookie, 0x0002, bn);
/* TLV t(0005) - Encompasses almost everything below. */
byte_stream_put16(&bs, 0x0005); /* T */
@@ -1176,12 +1176,12 @@ int aim_im_sendch2_geticqaway(OscarData *od, const char *sn, int type)
* but thats ok, because it gives me time to try to figure out what kind of drugs the AOL people
* were taking when they merged the two protocols.
*
- * @param sn The destination screen name.
+ * @param bn The destination buddy name.
* @param type The type of message. 0x0007 for authorization denied. 0x0008 for authorization granted.
* @param message The message you want to send, it should be null terminated.
* @return Return 0 if no errors, otherwise return the error number.
*/
-int aim_im_sendch4(OscarData *od, const char *sn, guint16 type, const char *message)
+int aim_im_sendch4(OscarData *od, const char *bn, guint16 type, const char *message)
{
FlapConnection *conn;
ByteStream bs;
@@ -1191,17 +1191,17 @@ int aim_im_sendch4(OscarData *od, const char *sn, guint16 type, const char *mess
if (!od || !(conn = flap_connection_findbygroup(od, 0x0002)))
return -EINVAL;
- if (!sn || !type || !message)
+ if (!bn || !type || !message)
return -EINVAL;
- byte_stream_new(&bs, 8+3+strlen(sn)+12+strlen(message)+1+4);
+ byte_stream_new(&bs, 8+3+strlen(bn)+12+strlen(message)+1+4);
snacid = aim_cachesnac(od, SNAC_FAMILY_ICBM, 0x0006, 0x0000, NULL, 0);
aim_icbm_makecookie(cookie);
/* ICBM header */
- aim_im_puticbm(&bs, cookie, 0x0004, sn);
+ aim_im_puticbm(&bs, cookie, 0x0004, bn);
/*
* TLV t(0005)
@@ -1246,8 +1246,8 @@ static int outgoingim(OscarData *od, FlapConnection *conn, aim_module_t *mod, Fl
guchar cookie[8];
guint16 channel;
GSList *tlvlist;
- char *sn;
- int snlen;
+ char *bn;
+ int bnlen;
guint16 icbmflags = 0;
guint8 flag1 = 0, flag2 = 0;
gchar *msg = NULL;
@@ -1264,8 +1264,8 @@ static int outgoingim(OscarData *od, FlapConnection *conn, aim_module_t *mod, Fl
return 0;
}
- snlen = byte_stream_get8(bs);
- sn = byte_stream_getstr(bs, snlen);
+ bnlen = byte_stream_get8(bs);
+ bn = byte_stream_getstr(bs, bnlen);
tlvlist = aim_tlvlist_read(bs);
@@ -1296,9 +1296,9 @@ static int outgoingim(OscarData *od, FlapConnection *conn, aim_module_t *mod, Fl
}
if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
- ret = userfunc(od, conn, frame, channel, sn, msg, icbmflags, flag1, flag2);
+ ret = userfunc(od, conn, frame, channel, bn, msg, icbmflags, flag1, flag2);
- g_free(sn);
+ g_free(bn);
g_free(msg);
aim_tlvlist_free(tlvlist);
@@ -1480,7 +1480,7 @@ static int incomingim_ch1_parsemsgs(OscarData *od, aim_userinfo_t *userinfo, gui
msglen = byte_stream_get16(&mbs);
if (msglen > byte_stream_empty(&mbs))
{
- purple_debug_misc("oscar", "Received an IM containing an invalid message part from %s. They are probably trying to do something malicious.\n", userinfo->sn);
+ purple_debug_misc("oscar", "Received an IM containing an invalid message part from %s. They are probably trying to do something malicious.\n", userinfo->bn);
break;
}
@@ -1589,7 +1589,7 @@ static int incomingim_ch1(OscarData *od, FlapConnection *conn, aim_module_t *mod
if (length > byte_stream_empty(bs))
{
- purple_debug_misc("oscar", "Received an IM containing an invalid message part from %s. They are probably trying to do something malicious.\n", userinfo->sn);
+ purple_debug_misc("oscar", "Received an IM containing an invalid message part from %s. They are probably trying to do something malicious.\n", userinfo->bn);
break;
}
@@ -1625,14 +1625,14 @@ static int incomingim_ch1(OscarData *od, FlapConnection *conn, aim_module_t *mod
if (magic1 != 0x501)
{
- purple_debug_misc("oscar", "Received an IM containing an invalid message part from %s. They are probably trying to do something malicious.\n", userinfo->sn);
+ purple_debug_misc("oscar", "Received an IM containing an invalid message part from %s. They are probably trying to do something malicious.\n", userinfo->bn);
break;
}
args.featureslen = byte_stream_get16(bs);
if (args.featureslen > byte_stream_empty(bs))
{
- purple_debug_misc("oscar", "Received an IM containing an invalid message part from %s. They are probably trying to do something malicious.\n", userinfo->sn);
+ purple_debug_misc("oscar", "Received an IM containing an invalid message part from %s. They are probably trying to do something malicious.\n", userinfo->bn);
break;
}
if (args.featureslen == 0)
@@ -1654,7 +1654,7 @@ static int incomingim_ch1(OscarData *od, FlapConnection *conn, aim_module_t *mod
magic1 = byte_stream_get16(bs); /* 01 01 */
if (magic1 != 0x101) /* Bad, message comes before attributes */
{
- purple_debug_misc("oscar", "Received an IM containing an invalid message part from %s. They are probably trying to do something malicious.\n", userinfo->sn);
+ purple_debug_misc("oscar", "Received an IM containing an invalid message part from %s. They are probably trying to do something malicious.\n", userinfo->bn);
break;
}
msglen = byte_stream_get16(bs);
@@ -1721,7 +1721,7 @@ static int incomingim_ch1(OscarData *od, FlapConnection *conn, aim_module_t *mod
if (length > byte_stream_empty(bs))
{
- purple_debug_misc("oscar", "Received an IM containing an invalid message part from %s. They are probably trying to do something malicious.\n", userinfo->sn);
+ purple_debug_misc("oscar", "Received an IM containing an invalid message part from %s. They are probably trying to do something malicious.\n", userinfo->bn);
break;
}
g_free(args.extdata);
@@ -1796,7 +1796,7 @@ incomingim_ch2_buddylist(OscarData *od, FlapConnection *conn, aim_module_t *mod,
bnlen = byte_stream_get16(servdata);
bn = byte_stream_getstr(servdata, bnlen);
- purple_debug_misc("oscar", "got a buddy list from %s: group %s, buddy %s\n", userinfo->sn, gn, bn);
+ purple_debug_misc("oscar", "got a buddy list from %s: group %s, buddy %s\n", userinfo->bn, gn, bn);
g_free(bn);
}
@@ -2285,7 +2285,7 @@ static int incomingim(OscarData *od, FlapConnection *conn, aim_module_t *mod, Fl
}
/*
- * Subtype 0x0008 - Send a warning to sn.
+ * Subtype 0x0008 - Send a warning to bn.
*
* Flags:
* AIM_WARN_ANON Send as an anonymous (doesn't count as much)
@@ -2293,21 +2293,21 @@ static int incomingim(OscarData *od, FlapConnection *conn, aim_module_t *mod, Fl
* returns -1 on error (couldn't alloc packet), 0 on success.
*
*/
-int aim_im_warn(OscarData *od, FlapConnection *conn, const char *sn, guint32 flags)
+int aim_im_warn(OscarData *od, FlapConnection *conn, const char *bn, guint32 flags)
{
ByteStream bs;
aim_snacid_t snacid;
- if (!od || !conn || !sn)
+ if (!od || !conn || !bn)
return -EINVAL;
- byte_stream_new(&bs, strlen(sn)+3);
+ byte_stream_new(&bs, strlen(bn)+3);
- snacid = aim_cachesnac(od, SNAC_FAMILY_ICBM, 0x0008, 0x0000, sn, strlen(sn)+1);
+ snacid = aim_cachesnac(od, SNAC_FAMILY_ICBM, 0x0008, 0x0000, bn, strlen(bn)+1);
byte_stream_put16(&bs, (flags & AIM_WARN_ANON) ? 0x0001 : 0x0000);
- byte_stream_put8(&bs, strlen(sn));
- byte_stream_putstr(&bs, sn);
+ byte_stream_put8(&bs, strlen(bn));
+ byte_stream_putstr(&bs, bn);
flap_connection_send_snac(od, conn, SNAC_FAMILY_ICBM, 0x0008, 0x0000, snacid, &bs);
@@ -2349,7 +2349,7 @@ static int missedcall(OscarData *od, FlapConnection *conn, aim_module_t *mod, Fl
* AIM_TRANSFER_DENY_NOTACCEPTING -- "client is not accepting transfers"
*
*/
-int aim_im_denytransfer(OscarData *od, const char *sn, const guchar *cookie, guint16 code)
+int aim_im_denytransfer(OscarData *od, const char *bn, const guchar *cookie, guint16 code)
{
FlapConnection *conn;
ByteStream bs;
@@ -2359,15 +2359,15 @@ int aim_im_denytransfer(OscarData *od, const char *sn, const guchar *cookie, gui
if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_ICBM)))
return -EINVAL;
- byte_stream_new(&bs, 8+2+1+strlen(sn)+6);
+ byte_stream_new(&bs, 8+2+1+strlen(bn)+6);
snacid = aim_cachesnac(od, SNAC_FAMILY_ICBM, 0x000b, 0x0000, NULL, 0);
byte_stream_putraw(&bs, cookie, 8);
byte_stream_put16(&bs, 0x0002); /* channel */
- byte_stream_put8(&bs, strlen(sn));
- byte_stream_putstr(&bs, sn);
+ byte_stream_put8(&bs, strlen(bn));
+ byte_stream_putstr(&bs, bn);
aim_tlvlist_add_16(&tlvlist, 0x0003, code);
aim_tlvlist_write(&bs, &tlvlist);
@@ -2380,7 +2380,7 @@ int aim_im_denytransfer(OscarData *od, const char *sn, const guchar *cookie, gui
return 0;
}
-static void parse_status_note_text(OscarData *od, guchar *cookie, char *sn, ByteStream *bs)
+static void parse_status_note_text(OscarData *od, guchar *cookie, char *bn, ByteStream *bs)
{
struct aim_icq_info *info;
struct aim_icq_info *prev_info;
@@ -2534,10 +2534,10 @@ static void parse_status_note_text(OscarData *od, guchar *cookie, char *sn, Byte
g_free(status_note_text);
g_free(stripped_status_note_text);
- buddy = purple_find_buddy(account, sn);
+ buddy = purple_find_buddy(account, bn);
if (buddy == NULL)
{
- purple_debug_misc("oscar", "clientautoresp: buddy %s was not found.\n", sn);
+ purple_debug_misc("oscar", "clientautoresp: buddy %s was not found.\n", bn);
g_free(status_note);
return;
}
@@ -2548,7 +2548,7 @@ static void parse_status_note_text(OscarData *od, guchar *cookie, char *sn, Byte
presence = purple_buddy_get_presence(buddy);
status = purple_presence_get_active_status(presence);
- purple_prpl_got_user_status(account, sn,
+ purple_prpl_got_user_status(account, bn,
purple_status_get_id(status),
"message", status_note, NULL);
@@ -2565,26 +2565,26 @@ static int clientautoresp(OscarData *od, FlapConnection *conn, aim_module_t *mod
int ret = 0;
aim_rxcallback_t userfunc;
guint16 channel, reason;
- char *sn;
+ char *bn;
guchar *cookie;
- guint8 snlen;
+ guint8 bnlen;
cookie = byte_stream_getraw(bs, 8);
channel = byte_stream_get16(bs);
- snlen = byte_stream_get8(bs);
- sn = byte_stream_getstr(bs, snlen);
+ bnlen = byte_stream_get8(bs);
+ bn = byte_stream_getstr(bs, bnlen);
reason = byte_stream_get16(bs);
if (channel == 0x0002)
{
if (reason == 0x0003) /* channel-specific */
/* parse status note text */
- parse_status_note_text(od, cookie, sn, bs);
+ parse_status_note_text(od, cookie, bn, bs);
byte_stream_get16(bs); /* Unknown */
byte_stream_get16(bs); /* Unknown */
if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
- ret = userfunc(od, conn, frame, channel, sn, reason, cookie);
+ ret = userfunc(od, conn, frame, channel, bn, reason, cookie);
} else if (channel == 0x0004) { /* ICQ message */
switch (reason) {
@@ -2629,20 +2629,20 @@ static int clientautoresp(OscarData *od, FlapConnection *conn, aim_module_t *mod
msg = byte_stream_getraw(bs, len);
if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
- ret = userfunc(od, conn, frame, channel, sn, reason, state, msg);
+ ret = userfunc(od, conn, frame, channel, bn, reason, state, msg);
g_free(msg);
} break;
default: {
if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
- ret = userfunc(od, conn, frame, channel, sn, reason);
+ ret = userfunc(od, conn, frame, channel, bn, reason);
} break;
} /* end switch */
}
g_free(cookie);
- g_free(sn);
+ g_free(bn);
return ret;
}
@@ -2660,17 +2660,17 @@ static int msgack(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFr
aim_rxcallback_t userfunc;
guint16 ch;
guchar *cookie;
- char *sn;
+ char *bn;
int ret = 0;
cookie = byte_stream_getraw(bs, 8);
ch = byte_stream_get16(bs);
- sn = byte_stream_getstr(bs, byte_stream_get8(bs));
+ bn = byte_stream_getstr(bs, byte_stream_get8(bs));
if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
- ret = userfunc(od, conn, frame, ch, sn);
+ ret = userfunc(od, conn, frame, ch, bn);
- g_free(sn);
+ g_free(bn);
g_free(cookie);
return ret;
@@ -2707,7 +2707,7 @@ int aim_im_reqofflinemsgs(OscarData *od)
* and Purple 0.60 and newer.
*
*/
-int aim_im_sendmtn(OscarData *od, guint16 type1, const char *sn, guint16 type2)
+int aim_im_sendmtn(OscarData *od, guint16 type1, const char *bn, guint16 type2)
{
FlapConnection *conn;
ByteStream bs;
@@ -2716,10 +2716,10 @@ int aim_im_sendmtn(OscarData *od, guint16 type1, const char *sn, guint16 type2)
if (!od || !(conn = flap_connection_findbygroup(od, 0x0002)))
return -EINVAL;
- if (!sn)
+ if (!bn)
return -EINVAL;
- byte_stream_new(&bs, 11+strlen(sn)+2);
+ byte_stream_new(&bs, 11+strlen(bn)+2);
snacid = aim_cachesnac(od, SNAC_FAMILY_ICBM, 0x0014, 0x0000, NULL, 0);
@@ -2738,10 +2738,10 @@ int aim_im_sendmtn(OscarData *od, guint16 type1, const char *sn, guint16 type2)
byte_stream_put16(&bs, type1);
/*
- * Dest sn
+ * Dest buddy name
*/
- byte_stream_put8(&bs, strlen(sn));
- byte_stream_putstr(&bs, sn);
+ byte_stream_put8(&bs, strlen(bn));
+ byte_stream_putstr(&bs, bn);
/*
* Type 2 (should be 0x0000, 0x0001, or 0x0002 for mtn)
@@ -2766,20 +2766,20 @@ static int mtn_receive(OscarData *od, FlapConnection *conn, aim_module_t *mod, F
{
int ret = 0;
aim_rxcallback_t userfunc;
- char *sn;
- guint8 snlen;
+ char *bn;
+ guint8 bnlen;
guint16 type1, type2;
byte_stream_advance(bs, 8); /* Unknown - All 0's */
type1 = byte_stream_get16(bs);
- snlen = byte_stream_get8(bs);
- sn = byte_stream_getstr(bs, snlen);
+ bnlen = byte_stream_get8(bs);
+ bn = byte_stream_getstr(bs, bnlen);
type2 = byte_stream_get16(bs);
if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
- ret = userfunc(od, conn, frame, type1, sn, type2);
+ ret = userfunc(od, conn, frame, type1, bn, type2);
- g_free(sn);
+ g_free(bn);
return ret;
}
diff --git a/libpurple/protocols/oscar/family_locate.c b/libpurple/protocols/oscar/family_locate.c
index 0646a2b..8bcb8c0 100644
--- a/libpurple/protocols/oscar/family_locate.c
+++ b/libpurple/protocols/oscar/family_locate.c
@@ -100,7 +100,7 @@ static const struct {
0x82, 0x22, 0x44, 0x45, 0x45, 0x53, 0x54, 0x00}},
/* Supports "new status message features" (Who advertises this one?) */
- /* OSCAR_CAPABILITY_HOST_STATUS_TEXT_AWARE */
+ /* OSCAR_CAPABILITY_HOST_STATUS_TEXT_AWARE */
{OSCAR_CAPABILITY_GENERICUNKNOWN,
{0x09, 0x46, 0x01, 0x0a, 0x4c, 0x7f, 0x11, 0xd1,
0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
@@ -112,7 +112,7 @@ static const struct {
0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
/* Client only asserts caps for services in which it is participating */
- /* OSCAR_CAPABILITY_SMARTCAPS */
+ /* OSCAR_CAPABILITY_SMARTCAPS */
{OSCAR_CAPABILITY_GENERICUNKNOWN,
{0x09, 0x46, 0x01, 0xff, 0x4c, 0x7f, 0x11, 0xd1,
0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
@@ -253,11 +253,11 @@ aim_locate_adduserinfo(OscarData *od, aim_userinfo_t *userinfo)
FlapConnection *conn;
aim_rxcallback_t userfunc;
- cur = aim_locate_finduserinfo(od, userinfo->sn);
+ cur = aim_locate_finduserinfo(od, userinfo->bn);
if (cur == NULL) {
cur = (aim_userinfo_t *)g_new0(aim_userinfo_t, 1);
- cur->sn = g_strdup(userinfo->sn);
+ cur->bn = g_strdup(userinfo->bn);
cur->next = od->locate.userinfo;
od->locate.userinfo = cur;
}
@@ -366,35 +366,35 @@ aim_locate_adduserinfo(OscarData *od, aim_userinfo_t *userinfo)
}
/**
- * Remove this screen name from our queue. If this info was requested
+ * Remove this buddy name from our queue. If this info was requested
* by our info request queue, then pop the next element off of the queue.
*
* @param od The aim session.
- * @param sn Screen name of the info we just received.
+ * @param bn Buddy name of the info we just received.
* @return True if the request was explicit (client requested the info),
* false if the request was implicit (libfaim request the info).
*/
static int
-aim_locate_gotuserinfo(OscarData *od, FlapConnection *conn, const char *sn)
+aim_locate_gotuserinfo(OscarData *od, FlapConnection *conn, const char *bn)
{
struct userinfo_node *cur, *del;
int was_explicit = TRUE;
- while ((od->locate.requested != NULL) && (aim_sncmp(sn, od->locate.requested->sn) == 0)) {
+ while ((od->locate.requested != NULL) && (oscar_util_name_compare(bn, od->locate.requested->bn) == 0)) {
del = od->locate.requested;
od->locate.requested = del->next;
was_explicit = FALSE;
- g_free(del->sn);
+ g_free(del->bn);
g_free(del);
}
cur = od->locate.requested;
while ((cur != NULL) && (cur->next != NULL)) {
- if (aim_sncmp(sn, cur->next->sn) == 0) {
+ if (oscar_util_name_compare(bn, cur->next->bn) == 0) {
del = cur->next;
cur->next = del->next;
was_explicit = FALSE;
- g_free(del->sn);
+ g_free(del->bn);
g_free(del);
} else
cur = cur->next;
@@ -404,34 +404,34 @@ aim_locate_gotuserinfo(OscarData *od, FlapConnection *conn, const char *sn)
}
void
-aim_locate_autofetch_away_message(OscarData *od, const char *sn)
+aim_locate_autofetch_away_message(OscarData *od, const char *bn)
{
struct userinfo_node *cur;
/* Make sure we haven't already made an info request for this buddy */
for (cur = od->locate.requested; cur != NULL; cur = cur->next)
- if (aim_sncmp(sn, cur->sn) == 0)
+ if (oscar_util_name_compare(bn, cur->bn) == 0)
return;
/* Add a new node to our request queue */
cur = (struct userinfo_node *)g_malloc(sizeof(struct userinfo_node));
- cur->sn = g_strdup(sn);
+ cur->bn = g_strdup(bn);
cur->next = od->locate.requested;
od->locate.requested = cur;
- aim_locate_getinfoshort(od, cur->sn, 0x00000002);
+ aim_locate_getinfoshort(od, cur->bn, 0x00000002);
}
-aim_userinfo_t *aim_locate_finduserinfo(OscarData *od, const char *sn) {
+aim_userinfo_t *aim_locate_finduserinfo(OscarData *od, const char *bn) {
aim_userinfo_t *cur = NULL;
- if (sn == NULL)
+ if (bn == NULL)
return NULL;
cur = od->locate.userinfo;
while (cur != NULL) {
- if (aim_sncmp(cur->sn, sn) == 0)
+ if (oscar_util_name_compare(cur->bn, bn) == 0)
return cur;
cur = cur->next;
}
@@ -552,7 +552,7 @@ dumptlv(OscarData *od, guint16 type, ByteStream *bs, guint8 len)
void
aim_info_free(aim_userinfo_t *info)
{
- g_free(info->sn);
+ g_free(info->bn);
g_free(info->iconcsum);
g_free(info->info);
g_free(info->info_encoding);
@@ -572,7 +572,7 @@ int
aim_info_extract(OscarData *od, ByteStream *bs, aim_userinfo_t *outinfo)
{
int curtlv, tlvcnt;
- guint8 snlen;
+ guint8 bnlen;
if (!bs || !outinfo)
return -EINVAL;
@@ -581,11 +581,11 @@ aim_info_extract(OscarData *od, ByteStream *bs, aim_userinfo_t *outinfo)
memset(outinfo, 0x00, sizeof(aim_userinfo_t));
/*
- * Screen name. Stored as an unterminated string prepended with a
+ * Username. Stored as an unterminated string prepended with a
* byte containing its length.
*/
- snlen = byte_stream_get8(bs);
- outinfo->sn = byte_stream_getstr(bs, snlen);
+ bnlen = byte_stream_get8(bs);
+ outinfo->bn = byte_stream_getstr(bs, bnlen);
/*
* Warning Level. Stored as an unsigned short.
@@ -881,7 +881,7 @@ aim_info_extract(OscarData *od, ByteStream *bs, aim_userinfo_t *outinfo)
*/
#ifdef LOG_UNKNOWN_TLV
purple_debug_misc("oscar", "userinfo: **warning: unexpected TLV:\n");
- purple_debug_misc("oscar", "userinfo: sn =%s\n", outinfo->sn);
+ purple_debug_misc("oscar", "userinfo: bn =%s\n", outinfo->bn);
dumptlv(od, type, bs, length);
#endif
}
@@ -906,8 +906,8 @@ aim_putuserinfo(ByteStream *bs, aim_userinfo_t *info)
if (!bs || !info)
return -EINVAL;
- byte_stream_put8(bs, strlen(info->sn));
- byte_stream_putstr(bs, info->sn);
+ byte_stream_put8(bs, strlen(info->bn));
+ byte_stream_putstr(bs, info->bn);
byte_stream_put16(bs, info->warnlevel);
@@ -922,7 +922,7 @@ aim_putuserinfo(ByteStream *bs, aim_userinfo_t *info)
/* XXX - So, ICQ_OSCAR_SUPPORT is never defined anywhere... */
#ifdef ICQ_OSCAR_SUPPORT
- if (atoi(info->sn) != 0) {
+ if (atoi(info->bn) != 0) {
if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS)
aim_tlvlist_add_16(&tlvlist, 0x0006, info->icqinfo.status);
if (info->present & AIM_USERINFO_PRESENT_ICQIPADDR)
@@ -953,35 +953,35 @@ error(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame,
aim_rxcallback_t userfunc;
aim_snac_t *snac2;
guint16 reason;
- char *sn;
+ char *bn;
int was_explicit;
if (!(snac2 = aim_remsnac(od, snac->id))) {
- purple_debug_misc("oscar", "faim: locate.c, error(): received response from unknown request!\n");
+ purple_debug_misc("oscar", "locate error: received response from unknown request!\n");
return 0;
}
if ((snac2->family != SNAC_FAMILY_LOCATE) && (snac2->type != 0x0015)) {
- purple_debug_misc("oscar", "faim: locate.c, error(): received response from invalid request! %d\n", snac2->family);
+ purple_debug_misc("oscar", "locate error: received response from invalid request! %d\n", snac2->family);
return 0;
}
- if (!(sn = snac2->data)) {
- purple_debug_misc("oscar", "faim: locate.c, error(): received response from request without a screen name!\n");
+ if (!(bn = snac2->data)) {
+ purple_debug_misc("oscar", "locate error: received response from request without a buddy name!\n");
return 0;
}
reason = byte_stream_get16(bs);
/*
- * Remove this screen name from our queue. If the client requested
+ * Remove this buddy name from our queue. If the client requested
* this buddy's info explicitly, then notify them that we do not have
* info for this buddy.
*/
- was_explicit = aim_locate_gotuserinfo(od, conn, sn);
+ was_explicit = aim_locate_gotuserinfo(od, conn, bn);
if (was_explicit == TRUE)
if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
- ret = userfunc(od, conn, frame, reason, sn);
+ ret = userfunc(od, conn, frame, reason, bn);
if (snac2)
g_free(snac2->data);
@@ -1157,29 +1157,29 @@ aim_locate_setcaps(OscarData *od, guint32 caps)
/*
* Subtype 0x0005 - Request info of another AIM user.
*
- * @param sn The screenname whose info you wish to request.
+ * @param bn The buddy name whose info you wish to request.
* @param infotype The type of info you wish to request.
* 0x0001 - Info/profile
* 0x0003 - Away message
* 0x0004 - Capabilities
*/
int
-aim_locate_getinfo(OscarData *od, const char *sn, guint16 infotype)
+aim_locate_getinfo(OscarData *od, const char *bn, guint16 infotype)
{
FlapConnection *conn;
ByteStream bs;
aim_snacid_t snacid;
- if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_LOCATE)) || !sn)
+ if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_LOCATE)) || !bn)
return -EINVAL;
- byte_stream_new(&bs, 2+1+strlen(sn));
+ byte_stream_new(&bs, 2+1+strlen(bn));
snacid = aim_cachesnac(od, SNAC_FAMILY_LOCATE, 0x0005, 0x0000, NULL, 0);
byte_stream_put16(&bs, infotype);
- byte_stream_put8(&bs, strlen(sn));
- byte_stream_putstr(&bs, sn);
+ byte_stream_put8(&bs, strlen(bn));
+ byte_stream_putstr(&bs, bn);
flap_connection_send_snac(od, conn, SNAC_FAMILY_LOCATE, 0x0005, 0x0000, snacid, &bs);
@@ -1229,18 +1229,18 @@ userinfo(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *fram
aim_tlvlist_free(tlvlist);
aim_locate_adduserinfo(od, userinfo);
- userinfo2 = aim_locate_finduserinfo(od, userinfo->sn);
+ userinfo2 = aim_locate_finduserinfo(od, userinfo->bn);
aim_info_free(userinfo);
g_free(userinfo);
/*
- * Remove this screen name from our queue. If the client requested
+ * Remove this buddy name from our queue. If the client requested
* this buddy's info explicitly, then notify them that we have info
* for this buddy.
*/
if (userinfo2 != NULL)
{
- was_explicit = aim_locate_gotuserinfo(od, conn, userinfo2->sn);
+ was_explicit = aim_locate_gotuserinfo(od, conn, userinfo2->bn);
if (was_explicit == TRUE)
if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
ret = userfunc(od, conn, frame, userinfo2);
@@ -1307,7 +1307,7 @@ int aim_locate_setdirinfo(OscarData *od, const char *first, const char *middle,
/*
* Subtype 0x000b - Huh? What is this?
*/
-int aim_locate_000b(OscarData *od, const char *sn)
+int aim_locate_000b(OscarData *od, const char *bn)
{
FlapConnection *conn;
ByteStream bs;
@@ -1315,15 +1315,15 @@ int aim_locate_000b(OscarData *od, const char *sn)
return -EINVAL;
- if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_LOCATE)) || !sn)
+ if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_LOCATE)) || !bn)
return -EINVAL;
- byte_stream_new(&bs, 1+strlen(sn));
+ byte_stream_new(&bs, 1+strlen(bn));
snacid = aim_cachesnac(od, SNAC_FAMILY_LOCATE, 0x000b, 0x0000, NULL, 0);
- byte_stream_put8(&bs, strlen(sn));
- byte_stream_putstr(&bs, sn);
+ byte_stream_put8(&bs, strlen(bn));
+ byte_stream_putstr(&bs, bn);
flap_connection_send_snac(od, conn, SNAC_FAMILY_LOCATE, 0x000b, 0x0000, snacid, &bs);
@@ -1380,7 +1380,7 @@ aim_locate_setinterests(OscarData *od, const char *interest1, const char *intere
* Subtype 0x0015 - Request the info of a user using the short method. This is
* what iChat uses. It normally is VERY leniently rate limited.
*
- * @param sn The screen name whose info you wish to request.
+ * @param bn The buddy name whose info you wish to request.
* @param flags The bitmask which specifies the type of info you wish to request.
* 0x00000001 - Info/profile.
* 0x00000002 - Away message.
@@ -1389,21 +1389,21 @@ aim_locate_setinterests(OscarData *od, const char *interest1, const char *intere
* @return Return 0 if no errors, otherwise return the error number.
*/
int
-aim_locate_getinfoshort(OscarData *od, const char *sn, guint32 flags)
+aim_locate_getinfoshort(OscarData *od, const char *bn, guint32 flags)
{
FlapConnection *conn;
ByteStream bs;
aim_snacid_t snacid;
- if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_LOCATE)) || !sn)
+ if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_LOCATE)) || !bn)
return -EINVAL;
- byte_stream_new(&bs, 4 + 1 + strlen(sn));
+ byte_stream_new(&bs, 4 + 1 + strlen(bn));
byte_stream_put32(&bs, flags);
- byte_stream_put8(&bs, strlen(sn));
- byte_stream_putstr(&bs, sn);
+ byte_stream_put8(&bs, strlen(bn));
+ byte_stream_putstr(&bs, bn);
- snacid = aim_cachesnac(od, SNAC_FAMILY_LOCATE, 0x0015, 0x0000, sn, strlen(sn)+1);
+ snacid = aim_cachesnac(od, SNAC_FAMILY_LOCATE, 0x0015, 0x0000, bn, strlen(bn)+1);
flap_connection_send_snac_with_priority(od, conn, SNAC_FAMILY_LOCATE, 0x0015, 0x0000, snacid, &bs, FALSE);
byte_stream_destroy(&bs);
diff --git a/libpurple/protocols/oscar/family_odir.c b/libpurple/protocols/oscar/family_odir.c
index a31768a..be1638f 100644
--- a/libpurple/protocols/oscar/family_odir.c
+++ b/libpurple/protocols/oscar/family_odir.c
@@ -31,7 +31,7 @@
/**
* Subtype 0x0002 - Submit a User Search Request
*
- * Search for an AIM screen name based on their email address.
+ * Search for an AIM buddy based on their email address.
*
* @param od The oscar session.
* @param region Should be "us-ascii" unless you know what you're doing.
@@ -70,7 +70,7 @@ int aim_odir_email(OscarData *od, const char *region, const char *email)
/**
* Subtype 0x0002 - Submit a User Search Request
*
- * Search for an AIM screen name based on various info
+ * Search for an AIM buddy based on various info
* about the person.
*
* @param od The oscar session.
@@ -202,7 +202,7 @@ static int parseresults(OscarData *od, FlapConnection *conn, aim_module_t *mod,
new->country = aim_tlv_getstr(tlvlist, 0x0006, 1);
new->state = aim_tlv_getstr(tlvlist, 0x0007, 1);
new->city = aim_tlv_getstr(tlvlist, 0x0008, 1);
- new->sn = aim_tlv_getstr(tlvlist, 0x0009, 1);
+ new->bn = aim_tlv_getstr(tlvlist, 0x0009, 1);
new->interest = aim_tlv_getstr(tlvlist, 0x000b, 1);
new->nick = aim_tlv_getstr(tlvlist, 0x000c, 1);
new->zip = aim_tlv_getstr(tlvlist, 0x000d, 1);
@@ -228,7 +228,7 @@ static int parseresults(OscarData *od, FlapConnection *conn, aim_module_t *mod,
g_free(del->country);
g_free(del->state);
g_free(del->city);
- g_free(del->sn);
+ g_free(del->bn);
g_free(del->interest);
g_free(del->nick);
g_free(del->zip);
diff --git a/libpurple/protocols/oscar/family_oservice.c b/libpurple/protocols/oscar/family_oservice.c
index 746f3b2..ee8f1c6 100644
--- a/libpurple/protocols/oscar/family_oservice.c
+++ b/libpurple/protocols/oscar/family_oservice.c
@@ -825,7 +825,7 @@ hostversions(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *
int
aim_srv_setextrainfo(OscarData *od,
gboolean seticqstatus, guint32 icqstatus,
- gboolean setavailmsg, const char *availmsg, const char *itmsurl)
+ gboolean setstatusmsg, const char *statusmsg, const char *itmsurl)
{
FlapConnection *conn;
ByteStream bs;
@@ -851,30 +851,17 @@ aim_srv_setextrainfo(OscarData *od,
}
#endif
- if (setavailmsg)
+ if (setstatusmsg)
{
- int availmsglen, itmsurllen;
+ size_t statusmsglen, itmsurllen;
ByteStream tmpbs;
- availmsglen = (availmsg != NULL) ? strlen(availmsg) : 0;
+ statusmsglen = (statusmsg != NULL) ? strlen(statusmsg) : 0;
itmsurllen = (itmsurl != NULL) ? strlen(itmsurl) : 0;
- byte_stream_new(&tmpbs, availmsglen + 8 + itmsurllen + 8);
- byte_stream_put16(&tmpbs, 0x0002);
- byte_stream_put8(&tmpbs, 0x04); /* Flags */
- byte_stream_put8(&tmpbs, availmsglen + 4);
- byte_stream_put16(&tmpbs, availmsglen);
- if (availmsglen > 0)
- byte_stream_putstr(&tmpbs, availmsg);
- byte_stream_put16(&tmpbs, 0x0000);
-
- byte_stream_put16(&tmpbs, 0x0009);
- byte_stream_put8(&tmpbs, 0x04); /* Flags */
- byte_stream_put8(&tmpbs, itmsurllen + 4);
- byte_stream_put16(&tmpbs, itmsurllen);
- if (itmsurllen > 0)
- byte_stream_putstr(&tmpbs, itmsurl);
- byte_stream_put16(&tmpbs, 0x0000);
+ byte_stream_new(&tmpbs, statusmsglen + 8 + itmsurllen + 8);
+ byte_stream_put_bart_asset_str(&tmpbs, 0x0002, statusmsg);
+ byte_stream_put_bart_asset_str(&tmpbs, 0x0009, itmsurl);
aim_tlvlist_add_raw(&tlvlist, 0x001d,
byte_stream_curpos(&tmpbs), tmpbs.data);
diff --git a/libpurple/protocols/oscar/odc.c b/libpurple/protocols/oscar/odc.c
index a4f29d0..8c02578 100644
--- a/libpurple/protocols/oscar/odc.c
+++ b/libpurple/protocols/oscar/odc.c
@@ -62,7 +62,7 @@ peer_odc_close(PeerConnection *conn)
PurpleConversation *conv;
account = purple_connection_get_account(conn->od->gc);
- conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, conn->sn);
+ conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, conn->bn);
purple_conversation_write(conv, NULL, tmp, PURPLE_MESSAGE_SYSTEM, time(NULL));
g_free(tmp);
}
@@ -90,11 +90,11 @@ peer_odc_send(PeerConnection *conn, OdcFrame *frame)
purple_debug_info("oscar", "Outgoing ODC frame to %s with "
"type=0x%04x, flags=0x%04x, payload length=%u\n",
- conn->sn, frame->type, frame->flags, frame->payload.len);
+ conn->bn, frame->type, frame->flags, frame->payload.len);
account = purple_connection_get_account(conn->od->gc);
username = purple_account_get_username(account);
- memcpy(frame->sn, username, strlen(username));
+ memcpy(frame->bn, username, strlen(username));
memcpy(frame->cookie, conn->cookie, 8);
length = 76;
@@ -116,7 +116,7 @@ peer_odc_send(PeerConnection *conn, OdcFrame *frame)
byte_stream_put16(&bs, frame->flags);
byte_stream_put16(&bs, 0x0000);
byte_stream_put16(&bs, 0x0000);
- byte_stream_putraw(&bs, frame->sn, 32);
+ byte_stream_putraw(&bs, frame->bn, 32);
byte_stream_putraw(&bs, frame->payload.data, frame->payload.len);
peer_connection_send(conn, &bs);
@@ -366,7 +366,7 @@ peer_odc_handle_payload(PeerConnection *conn, const char *msg, size_t len, int e
g_datalist_clear(&attributes);
/* Append the message up to the tag */
- utf8 = purple_plugin_oscar_decode_im_part(account, conn->sn,
+ utf8 = purple_plugin_oscar_decode_im_part(account, conn->bn,
encoding, 0x0000, tmp, start - tmp);
if (utf8 != NULL) {
g_string_append(newmsg, utf8);
@@ -386,7 +386,7 @@ peer_odc_handle_payload(PeerConnection *conn, const char *msg, size_t len, int e
/* Append any remaining message data */
if (tmp <= msgend)
{
- utf8 = purple_plugin_oscar_decode_im_part(account, conn->sn,
+ utf8 = purple_plugin_oscar_decode_im_part(account, conn->bn,
encoding, 0x0000, tmp, msgend - tmp);
if (utf8 != NULL) {
g_string_append(newmsg, utf8);
@@ -400,7 +400,7 @@ peer_odc_handle_payload(PeerConnection *conn, const char *msg, size_t len, int e
imflags |= PURPLE_MESSAGE_IMAGES;
if (autoreply)
imflags |= PURPLE_MESSAGE_AUTO_RESP;
- serv_got_im(gc, conn->sn, newmsg->str, imflags, time(NULL));
+ serv_got_im(gc, conn->bn, newmsg->str, imflags, time(NULL));
g_string_free(newmsg, TRUE);
/* unref any images we allocated */
@@ -503,11 +503,11 @@ peer_odc_recv_frame(PeerConnection *conn, ByteStream *bs)
byte_stream_advance(bs, 4);
frame->flags = byte_stream_get16(bs);
byte_stream_advance(bs, 4);
- byte_stream_getrawbuf(bs, frame->sn, 32);
+ byte_stream_getrawbuf(bs, frame->bn, 32);
purple_debug_info("oscar", "Incoming ODC frame from %s with "
"type=0x%04x, flags=0x%04x, payload length=%u\n",
- frame->sn, frame->type, frame->flags, frame->payload.len);
+ frame->bn, frame->type, frame->flags, frame->payload.len);
if (!conn->ready)
{
@@ -558,7 +558,7 @@ peer_odc_recv_frame(PeerConnection *conn, ByteStream *bs)
/* Tell the local user that we are connected */
account = purple_connection_get_account(gc);
- conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, conn->sn);
+ conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, conn->bn);
purple_conversation_write(conv, NULL, _("Direct IM established"),
PURPLE_MESSAGE_SYSTEM, time(NULL));
}
@@ -576,16 +576,16 @@ peer_odc_recv_frame(PeerConnection *conn, ByteStream *bs)
/* I had to leave this. It's just too funny. It reminds me of my sister. */
purple_debug_info("oscar", "ohmigod! %s has started typing "
"(DirectIM). He's going to send you a message! "
- "*squeal*\n", conn->sn);
- serv_got_typing(gc, conn->sn, 0, PURPLE_TYPING);
+ "*squeal*\n", conn->bn);
+ serv_got_typing(gc, conn->bn, 0, PURPLE_TYPING);
}
else if (frame->flags & 0x0004)
{
- serv_got_typing(gc, conn->sn, 0, PURPLE_TYPED);
+ serv_got_typing(gc, conn->bn, 0, PURPLE_TYPED);
}
else
{
- serv_got_typing_stopped(gc, conn->sn);
+ serv_got_typing_stopped(gc, conn->bn);
}
if (frame->payload.len > 0)
@@ -598,12 +598,12 @@ peer_odc_recv_frame(PeerConnection *conn, ByteStream *bs)
size1 = purple_str_size_to_units(frame->payload.len);
size2 = purple_str_size_to_units(DIRECTIM_MAX_FILESIZE);
- tmp = g_strdup_printf(_("%s tried to send you a %s file, but we only allow files up to %s over Direct IM. Try using file transfer instead.\n"), conn->sn, size1, size2);
+ tmp = g_strdup_printf(_("%s tried to send you a %s file, but we only allow files up to %s over Direct IM. Try using file transfer instead.\n"), conn->bn, size1, size2);
g_free(size1);
g_free(size2);
account = purple_connection_get_account(conn->od->gc);
- conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, conn->sn);
+ conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, conn->bn);
purple_conversation_write(conv, NULL, tmp, PURPLE_MESSAGE_SYSTEM, time(NULL));
g_free(tmp);
diff --git a/libpurple/protocols/oscar/oft.c b/libpurple/protocols/oscar/oft.c
index d2ba5be..d82622a 100644
--- a/libpurple/protocols/oscar/oft.c
+++ b/libpurple/protocols/oscar/oft.c
@@ -544,7 +544,7 @@ peer_oft_recv_frame(PeerConnection *conn, ByteStream *bs)
frame.name = byte_stream_getraw(bs, frame.name_length);
purple_debug_info("oscar", "Incoming OFT frame from %s with "
- "type=0x%04x\n", conn->sn, frame.type);
+ "type=0x%04x\n", conn->bn, frame.type);
/* TODOFT: peer_oft_dirconvert_fromstupid(frame->name); */
diff --git a/libpurple/protocols/oscar/oscar.c b/libpurple/protocols/oscar/oscar.c
index d190b6b..da934f3 100644
--- a/libpurple/protocols/oscar/oscar.c
+++ b/libpurple/protocols/oscar/oscar.c
@@ -204,7 +204,7 @@ static void purple_icons_fetch(PurpleConnection *gc);
void oscar_set_info(PurpleConnection *gc, const char *info);
static void oscar_set_info_and_status(PurpleAccount *account, gboolean setinfo, const char *rawinfo, gboolean setstatus, PurpleStatus *status);
static void oscar_set_extendedstatus(PurpleConnection *gc);
-static void oscar_format_screenname(PurpleConnection *gc, const char *nick);
+static void oscar_format_username(PurpleConnection *gc, const char *nick);
static gboolean purple_ssi_rerequestdata(gpointer data);
static void oscar_free_name_data(struct name_data *data) {
@@ -362,7 +362,7 @@ oscar_utf8_try_convert(PurpleAccount *account, const gchar *msg)
const char *charset = NULL;
char *ret = NULL;
- if(aim_snvalid_icq(purple_account_get_username(account)))
+ if(oscar_util_valid_name_icq(purple_account_get_username(account)))
charset = purple_account_get_string(account, "encoding", NULL);
if(charset && *charset)
@@ -414,7 +414,7 @@ purple_plugin_oscar_convert_to_utf8(const gchar *data, gsize datalen, const char
* charsetstr1 is always set to what the correct encoding should be.
*/
gchar *
-purple_plugin_oscar_decode_im_part(PurpleAccount *account, const char *sourcesn, guint16 charset, guint16 charsubset, const gchar *data, gsize datalen)
+purple_plugin_oscar_decode_im_part(PurpleAccount *account, const char *sourcebn, guint16 charset, guint16 charsubset, const gchar *data, gsize datalen)
{
gchar *ret = NULL;
const gchar *charsetstr1, *charsetstr2;
@@ -428,7 +428,7 @@ purple_plugin_oscar_decode_im_part(PurpleAccount *account, const char *sourcesn,
charsetstr1 = "UTF-16BE";
charsetstr2 = "UTF-8";
} else if (charset == AIM_CHARSET_CUSTOM) {
- if ((sourcesn != NULL) && aim_snvalid_icq(sourcesn))
+ if ((sourcebn != NULL) && oscar_util_valid_name_icq(sourcebn))
charsetstr1 = purple_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING);
else
charsetstr1 = "ISO-8859-1";
@@ -458,7 +458,7 @@ purple_plugin_oscar_decode_im_part(PurpleAccount *account, const char *sourcesn,
str[datalen] = '\0';
salvage = purple_utf8_salvage(str);
tmp = g_strdup_printf(_("(There was an error receiving this message. Either you and %s have different encodings selected, or %s has a buggy client.)"),
- sourcesn, sourcesn);
+ sourcebn, sourcebn);
ret = g_strdup_printf("%s %s", salvage, tmp);
g_free(tmp);
g_free(str);
@@ -473,11 +473,11 @@ purple_plugin_oscar_decode_im_part(PurpleAccount *account, const char *sourcesn,
*/
static void
purple_plugin_oscar_convert_to_best_encoding(PurpleConnection *gc,
- const char *destsn, const gchar *from,
+ const char *destbn, const gchar *from,
gchar **msg, int *msglen_int,
guint16 *charset, guint16 *charsubset)
{
- OscarData *od = gc->proto_data;
+ OscarData *od = purple_connection_get_protocol_data(gc);
PurpleAccount *account = purple_connection_get_account(gc);
GError *err = NULL;
aim_userinfo_t *userinfo = NULL;
@@ -499,13 +499,13 @@ purple_plugin_oscar_convert_to_best_encoding(PurpleConnection *gc,
* capability, and they are online, then attempt to send
* as UTF-16BE.
*/
- if ((destsn != NULL) && aim_snvalid_icq(destsn))
- userinfo = aim_locate_finduserinfo(od, destsn);
+ if ((destbn != NULL) && oscar_util_valid_name_icq(destbn))
+ userinfo = aim_locate_finduserinfo(od, destbn);
if ((userinfo != NULL) && (userinfo->capabilities & OSCAR_CAPABILITY_UNICODE))
{
PurpleBuddy *b;
- b = purple_find_buddy(account, destsn);
+ b = purple_find_buddy(account, destbn);
if ((b != NULL) && (PURPLE_BUDDY_IS_ONLINE(b)))
{
*msg = g_convert(from, -1, "UTF-16BE", "UTF-8", NULL, &msglen, &err);
@@ -529,7 +529,7 @@ purple_plugin_oscar_convert_to_best_encoding(PurpleConnection *gc,
* ICQ then attempt to send as the user specified character encoding.
*/
charsetstr = "ISO-8859-1";
- if ((destsn != NULL) && aim_snvalid_icq(destsn))
+ if ((destbn != NULL) && oscar_util_valid_name_icq(destbn))
charsetstr = purple_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING);
/*
@@ -808,16 +808,16 @@ static void oscar_user_info_append_status(PurpleConnection *gc, PurpleNotifyUser
gchar *message = NULL, *itmsurl = NULL, *tmp;
gboolean is_away;
- od = gc->proto_data;
+ od = purple_connection_get_protocol_data(gc);
if (userinfo == NULL)
- userinfo = aim_locate_finduserinfo(od, b->name);
+ userinfo = aim_locate_finduserinfo(od, purple_buddy_get_name(b));
if ((user_info == NULL) || ((b == NULL) && (userinfo == NULL)))
return;
if (b == NULL)
- b = purple_find_buddy(purple_connection_get_account(gc), userinfo->sn);
+ b = purple_find_buddy(purple_connection_get_account(gc), userinfo->bn);
if (b) {
presence = purple_buddy_get_presence(b);
@@ -884,7 +884,7 @@ static void oscar_user_info_append_status(PurpleConnection *gc, PurpleNotifyUser
if (b) {
if (purple_presence_is_online(presence)) {
- if (aim_snvalid_icq(b->name) || is_away || !message || !(*message)) {
+ if (oscar_util_valid_name_icq(purple_buddy_get_name(b)) || is_away || !message || !(*message)) {
/* Append the status name for online ICQ statuses, away AIM statuses, and for all buddies with no message.
* If the status name and the message are the same, only show one. */
const char *status_name = purple_status_get_name(status);
@@ -899,21 +899,20 @@ static void oscar_user_info_append_status(PurpleConnection *gc, PurpleNotifyUser
message = tmp;
}
+ } else if (aim_ssi_waitingforauth(od->ssi.local,
+ aim_ssi_itemlist_findparentname(od->ssi.local, purple_buddy_get_name(b)),
+ purple_buddy_get_name(b)))
+ {
+ /* Note if an offline buddy is not authorized */
+ tmp = g_strdup_printf("%s%s%s",
+ _("Not Authorized"),
+ (message && *message) ? ": " : "",
+ (message && *message) ? message : "");
+ g_free(message);
+ message = tmp;
} else {
- if (aim_ssi_waitingforauth(od->ssi.local,
- aim_ssi_itemlist_findparentname(od->ssi.local, b->name),
- b->name)) {
- /* Note if an offline buddy is not authorized */
- tmp = g_strdup_printf("%s%s%s",
- _("Not Authorized"),
- (message && *message) ? ": " : "",
- (message && *message) ? message : "");
- g_free(message);
- message = tmp;
- } else {
- g_free(message);
- message = g_strdup(_("Offline"));
- }
+ g_free(message);
+ message = g_strdup(_("Offline"));
}
}
@@ -931,27 +930,30 @@ static void oscar_user_info_append_extra_info(PurpleConnection *gc, PurpleNotify
PurpleGroup *g = NULL;
struct buddyinfo *bi = NULL;
char *tmp;
+ const char *bname, *gname = NULL;
- od = gc->proto_data;
+ od = purple_connection_get_protocol_data(gc);
account = purple_connection_get_account(gc);
if ((user_info == NULL) || ((b == NULL) && (userinfo == NULL)))
return;
+ bname = purple_buddy_get_name(b);
if (userinfo == NULL)
- userinfo = aim_locate_finduserinfo(od, b->name);
+ userinfo = aim_locate_finduserinfo(od, bname);
if (b == NULL)
- b = purple_find_buddy(account, userinfo->sn);
+ b = purple_find_buddy(account, userinfo->bn);
if (b != NULL) {
g = purple_buddy_get_group(b);
+ gname = purple_group_get_name(g);
presence = purple_buddy_get_presence(b);
status = purple_presence_get_active_status(presence);
}
if (userinfo != NULL)
- bi = g_hash_table_lookup(od->buddyinfo, purple_normalize(account, userinfo->sn));
+ bi = g_hash_table_lookup(od->buddyinfo, purple_normalize(account, userinfo->bn));
if ((bi != NULL) && (bi->ipaddr != 0)) {
tmp = g_strdup_printf("%hhu.%hhu.%hhu.%hhu",
@@ -969,8 +971,8 @@ static void oscar_user_info_append_extra_info(PurpleConnection *gc, PurpleNotify
g_free(tmp);
}
- if ((b != NULL) && (b->name != NULL) && (g != NULL) && (g->name != NULL)) {
- tmp = aim_ssi_getcomment(od->ssi.local, g->name, b->name);
+ if ((b != NULL) && (bname != NULL) && (g != NULL) && (gname != NULL)) {
+ tmp = aim_ssi_getcomment(od->ssi.local, gname, bname);
if (tmp != NULL) {
char *tmp2 = g_markup_escape_text(tmp, strlen(tmp));
g_free(tmp);
@@ -1017,7 +1019,7 @@ static char *extract_name(const char *name) {
static struct chat_connection *
find_oscar_chat(PurpleConnection *gc, int id)
{
- OscarData *od = (OscarData *)gc->proto_data;
+ OscarData *od = purple_connection_get_protocol_data(gc);
GSList *cur;
struct chat_connection *cc;
@@ -1034,7 +1036,7 @@ find_oscar_chat(PurpleConnection *gc, int id)
static struct chat_connection *
find_oscar_chat_by_conn(PurpleConnection *gc, FlapConnection *conn)
{
- OscarData *od = (OscarData *)gc->proto_data;
+ OscarData *od = purple_connection_get_protocol_data(gc);
GSList *cur;
struct chat_connection *cc;
@@ -1051,7 +1053,7 @@ find_oscar_chat_by_conn(PurpleConnection *gc, FlapConnection *conn)
static struct chat_connection *
find_oscar_chat_by_conv(PurpleConnection *gc, PurpleConversation *conv)
{
- OscarData *od = (OscarData *)gc->proto_data;
+ OscarData *od = purple_connection_get_protocol_data(gc);
GSList *cur;
struct chat_connection *cc;
@@ -1076,7 +1078,7 @@ oscar_chat_destroy(struct chat_connection *cc)
static void
oscar_chat_kill(PurpleConnection *gc, struct chat_connection *cc)
{
- OscarData *od = (OscarData *)gc->proto_data;
+ OscarData *od = purple_connection_get_protocol_data(gc);
/* Notify the conversation window that we've left the chat */
serv_got_chat_left(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(cc->conv)));
@@ -1292,10 +1294,10 @@ flap_connection_established_admin(OscarData *od, FlapConnection *conn)
od->chpass = FALSE;
}
if (od->setnick) {
- purple_debug_info("oscar", "formatting screen name\n");
- aim_admin_setnick(od, conn, od->newsn);
- g_free(od->newsn);
- od->newsn = NULL;
+ purple_debug_info("oscar", "formatting username\n");
+ aim_admin_setnick(od, conn, od->newformatting);
+ g_free(od->newformatting);
+ od->newformatting = NULL;
od->setnick = FALSE;
}
if (od->conf) {
@@ -1391,7 +1393,7 @@ idle_reporting_pref_cb(const char *name, PurplePrefType type,
guint32 presence;
gc = data;
- od = gc->proto_data;
+ od = purple_connection_get_protocol_data(gc);
report_idle = strcmp((const char *)value, "none") != 0;
presence = aim_ssi_getpresence(od->ssi.local);
@@ -1414,7 +1416,7 @@ recent_buddies_pref_cb(const char *name, PurplePrefType type,
guint32 presence;
gc = data;
- od = gc->proto_data;
+ od = purple_connection_get_protocol_data(gc);
presence = aim_ssi_getpresence(od->ssi.local);
if (value)
@@ -1431,8 +1433,9 @@ oscar_login(PurpleAccount *account)
FlapConnection *newconn;
gc = purple_account_get_connection(account);
- od = gc->proto_data = oscar_data_new();
+ od = oscar_data_new();
od->gc = gc;
+ purple_connection_set_protocol_data(gc, od);
oscar_data_addhandler(od, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, purple_connerr, 0);
oscar_data_addhandler(od, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, flap_connection_established, 0);
@@ -1499,7 +1502,7 @@ oscar_login(PurpleAccount *account)
purple_debug_misc("oscar", "oscar_login: gc = %p\n", gc);
- if (!aim_snvalid(purple_account_get_username(account))) {
+ if (!oscar_util_valid_name(purple_account_get_username(account))) {
gchar *buf;
buf = g_strdup_printf(_("Unable to login: Could not sign on as %s because the username is invalid. Usernames must be a valid email address, or start with a letter and contain only letters, numbers and spaces, or contain only numbers."), purple_account_get_username(account));
purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_INVALID_SETTINGS, buf);
@@ -1507,7 +1510,7 @@ oscar_login(PurpleAccount *account)
return;
}
- if (aim_snvalid_icq((purple_account_get_username(account)))) {
+ if (oscar_util_valid_name_icq((purple_account_get_username(account)))) {
od->icq = TRUE;
} else {
gc->flags |= PURPLE_CONNECTION_HTML;
@@ -1578,7 +1581,7 @@ oscar_close(PurpleConnection *gc)
{
OscarData *od;
- od = (OscarData *)gc->proto_data;
+ od = purple_connection_get_protocol_data(gc);
while (od->oscar_chats)
{
@@ -1594,7 +1597,7 @@ oscar_close(PurpleConnection *gc)
g_free(cr);
}
oscar_data_destroy(od);
- gc->proto_data = NULL;
+ purple_connection_set_protocol_data(gc, NULL);
purple_prefs_disconnect_by_handle(gc);
@@ -1605,7 +1608,7 @@ static int
purple_parse_auth_resp(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
{
PurpleConnection *gc = od->gc;
- PurpleAccount *account = gc->account;
+ PurpleAccount *account = purple_connection_get_account(gc);
char *host; int port;
int i;
FlapConnection *newconn;
@@ -1619,13 +1622,13 @@ purple_parse_auth_resp(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
va_end(ap);
purple_debug_info("oscar",
- "inside auth_resp (Username: %s)\n", info->sn);
+ "inside auth_resp (Username: %s)\n", info->bn);
if (info->errorcode || !info->bosip || !info->cookielen || !info->cookie) {
char buf[256];
switch (info->errorcode) {
case 0x01:
- /* Unregistered screen name */
+ /* Unregistered username */
purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_INVALID_USERNAME, _("Invalid username."));
break;
case 0x05:
@@ -1644,7 +1647,7 @@ purple_parse_auth_resp(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _("The AOL Instant Messenger service is temporarily unavailable."));
break;
case 0x18:
- /* screen name connecting too frequently */
+ /* username connecting too frequently */
purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, _("You have been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer."));
break;
case 0x1c:
@@ -1722,7 +1725,7 @@ static void
purple_parse_auth_securid_request_yes_cb(gpointer user_data, const char *msg)
{
PurpleConnection *gc = user_data;
- OscarData *od = gc->proto_data;
+ OscarData *od = purple_connection_get_protocol_data(gc);
aim_auth_securid_send(od, msg);
}
@@ -1774,7 +1777,7 @@ struct pieceofcrap {
static void damn_you(gpointer data, gint source, PurpleInputCondition c)
{
struct pieceofcrap *pos = data;
- OscarData *od = pos->gc->proto_data;
+ OscarData *od = purple_connection_get_protocol_data(pos->gc);
char in = '\0';
int x = 0;
unsigned char m[17];
@@ -1840,7 +1843,7 @@ straight_to_hell(gpointer data, gint source, const gchar *error_message)
pos->fd = source;
if (source < 0) {
- GHashTable *ui_info = purple_core_get_ui_info();
+ GHashTable *ui_info = purple_core_get_ui_info();
buf = g_strdup_printf(_("You may be disconnected shortly. "
"Check %s for updates."),
((ui_info && g_hash_table_lookup(ui_info, "website")) ? (char *)g_hash_table_lookup(ui_info, "website") : PURPLE_WEBSITE));
@@ -2099,7 +2102,7 @@ static int purple_parse_oncoming(OscarData *od, FlapConnection *conn, FlapFrame
va_end(ap);
g_return_val_if_fail(info != NULL, 1);
- g_return_val_if_fail(info->sn != NULL, 1);
+ g_return_val_if_fail(info->bn != NULL, 1);
if (info->present & AIM_USERINFO_PRESENT_FLAGS) {
if (info->flags & AIM_FLAG_AWAY)
@@ -2113,7 +2116,7 @@ static int purple_parse_oncoming(OscarData *od, FlapConnection *conn, FlapFrame
}
}
- if (aim_snvalid_icq(info->sn)) {
+ if (oscar_util_valid_name_icq(info->bn)) {
if (type & AIM_ICQ_STATE_CHAT)
status_id = OSCAR_STATUS_ID_FREE4CHAT;
else if (type & AIM_ICQ_STATE_DND)
@@ -2139,9 +2142,9 @@ static int purple_parse_oncoming(OscarData *od, FlapConnection *conn, FlapFrame
if (info->flags & AIM_FLAG_WIRELESS)
{
- purple_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_MOBILE, NULL);
+ purple_prpl_got_user_status(account, info->bn, OSCAR_STATUS_ID_MOBILE, NULL);
} else {
- purple_prpl_got_user_status_deactive(account, info->sn, OSCAR_STATUS_ID_MOBILE);
+ purple_prpl_got_user_status_deactive(account, info->bn, OSCAR_STATUS_ID_MOBILE);
}
if (info->status != NULL && info->status[0] != '\0')
@@ -2164,11 +2167,11 @@ static int purple_parse_oncoming(OscarData *od, FlapConnection *conn, FlapFrame
*/
tmp2 = "";
- purple_prpl_got_user_status(account, info->sn, status_id,
+ purple_prpl_got_user_status(account, info->bn, status_id,
"message", tmp2, "itmsurl", itmsurl, NULL);
}
else
- purple_prpl_got_user_status(account, info->sn, status_id, "message", tmp2, NULL);
+ purple_prpl_got_user_status(account, info->bn, status_id, "message", tmp2, NULL);
g_free(tmp);
@@ -2180,7 +2183,7 @@ static int purple_parse_oncoming(OscarData *od, FlapConnection *conn, FlapFrame
signon = info->onlinesince;
else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN)
signon = time(NULL) - info->sessionlen;
- purple_prpl_got_user_login_time(account, info->sn, signon);
+ purple_prpl_got_user_login_time(account, info->bn, signon);
/* Idle time stuff */
/* info->idletime is the number of minutes that this user has been idle */
@@ -2188,15 +2191,15 @@ static int purple_parse_oncoming(OscarData *od, FlapConnection *conn, FlapFrame
time_idle = time(NULL) - info->idletime * 60;
if (time_idle > 0)
- purple_prpl_got_user_idle(account, info->sn, TRUE, time_idle);
+ purple_prpl_got_user_idle(account, info->bn, TRUE, time_idle);
else
- purple_prpl_got_user_idle(account, info->sn, FALSE, 0);
+ purple_prpl_got_user_idle(account, info->bn, FALSE, 0);
/* Server stored icon stuff */
- bi = g_hash_table_lookup(od->buddyinfo, purple_normalize(account, info->sn));
+ bi = g_hash_table_lookup(od->buddyinfo, purple_normalize(account, info->bn));
if (!bi) {
bi = g_new0(struct buddyinfo, 1);
- g_hash_table_insert(od->buddyinfo, g_strdup(purple_normalize(account, info->sn)), bi);
+ g_hash_table_insert(od->buddyinfo, g_strdup(purple_normalize(account, info->bn)), bi);
}
bi->typingnot = FALSE;
bi->ico_informed = FALSE;
@@ -2208,20 +2211,20 @@ static int purple_parse_oncoming(OscarData *od, FlapConnection *conn, FlapFrame
PurpleBuddy *b = NULL;
b16 = purple_base16_encode(info->iconcsum, info->iconcsumlen);
- b = purple_find_buddy(account, info->sn);
+ b = purple_find_buddy(account, info->bn);
if (b != NULL)
saved_b16 = purple_buddy_icons_get_checksum_for_user(b);
if (!b16 || !saved_b16 || strcmp(b16, saved_b16)) {
/* Invalidate the old icon for this user */
- purple_buddy_icons_set_for_user(account, info->sn, NULL, 0, NULL);
+ purple_buddy_icons_set_for_user(account, info->bn, NULL, 0, NULL);
/* Fetch the new icon (if we're not already doing so) */
- if (g_slist_find_custom(od->requesticon, info->sn,
- (GCompareFunc)aim_sncmp) == NULL)
+ if (g_slist_find_custom(od->requesticon, info->bn,
+ (GCompareFunc)oscar_util_name_compare) == NULL)
{
od->requesticon = g_slist_prepend(od->requesticon,
- g_strdup(purple_normalize(account, info->sn)));
+ g_strdup(purple_normalize(account, info->bn)));
purple_icons_fetch(gc);
}
}
@@ -2248,9 +2251,9 @@ static int purple_parse_offgoing(OscarData *od, FlapConnection *conn, FlapFrame
info = va_arg(ap, aim_userinfo_t *);
va_end(ap);
- purple_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_OFFLINE, NULL);
- purple_prpl_got_user_status_deactive(account, info->sn, OSCAR_STATUS_ID_MOBILE);
- g_hash_table_remove(od->buddyinfo, purple_normalize(gc->account, info->sn));
+ purple_prpl_got_user_status(account, info->bn, OSCAR_STATUS_ID_OFFLINE, NULL);
+ purple_prpl_got_user_status_deactive(account, info->bn, OSCAR_STATUS_ID_MOBILE);
+ g_hash_table_remove(od->buddyinfo, purple_normalize(gc->account, info->bn));
return 1;
}
@@ -2268,15 +2271,15 @@ static int incomingim_chan1(OscarData *od, FlapConnection *conn, aim_userinfo_t
GData *attribs;
purple_debug_misc("oscar", "Received IM from %s with %d parts\n",
- userinfo->sn, args->mpmsg.numparts);
+ userinfo->bn, args->mpmsg.numparts);
if (args->mpmsg.numparts == 0)
return 1;
- bi = g_hash_table_lookup(od->buddyinfo, purple_normalize(account, userinfo->sn));
+ bi = g_hash_table_lookup(od->buddyinfo, purple_normalize(account, userinfo->bn));
if (!bi) {
bi = g_new0(struct buddyinfo, 1);
- g_hash_table_insert(od->buddyinfo, g_strdup(purple_normalize(account, userinfo->sn)), bi);
+ g_hash_table_insert(od->buddyinfo, g_strdup(purple_normalize(account, userinfo->bn)), bi);
}
if (args->icbmflags & AIM_IMFLAGS_AWAY)
@@ -2288,7 +2291,7 @@ static int incomingim_chan1(OscarData *od, FlapConnection *conn, aim_userinfo_t
bi->typingnot = FALSE;
if ((args->icbmflags & AIM_IMFLAGS_HASICON) && (args->iconlen) && (args->iconsum) && (args->iconstamp)) {
- purple_debug_misc("oscar", "%s has an icon\n", userinfo->sn);
+ purple_debug_misc("oscar", "%s has an icon\n", userinfo->bn);
if ((args->iconlen != bi->ico_len) || (args->iconsum != bi->ico_csum) || (args->iconstamp != bi->ico_time)) {
bi->ico_need = TRUE;
bi->ico_len = args->iconlen;
@@ -2304,8 +2307,8 @@ static int incomingim_chan1(OscarData *od, FlapConnection *conn, aim_userinfo_t
size_t len = purple_imgstore_get_size(img);
purple_debug_info("oscar",
"Sending buddy icon to %s (%" G_GSIZE_FORMAT " bytes)\n",
- userinfo->sn, len);
- aim_im_sendch2_icon(od, userinfo->sn, data, len,
+ userinfo->bn, len);
+ aim_im_sendch2_icon(od, userinfo->bn, data, len,
purple_buddy_icons_get_account_icon_timestamp(account),
aimutil_iconsum(data, len));
}
@@ -2314,7 +2317,7 @@ static int incomingim_chan1(OscarData *od, FlapConnection *conn, aim_userinfo_t
message = g_string_new("");
curpart = args->mpmsg.parts;
while (curpart != NULL) {
- tmp = purple_plugin_oscar_decode_im_part(account, userinfo->sn, curpart->charset,
+ tmp = purple_plugin_oscar_decode_im_part(account, userinfo->bn, curpart->charset,
curpart->charsubset, curpart->data, curpart->datalen);
if (tmp != NULL) {
g_string_append(message, tmp);
@@ -2334,7 +2337,7 @@ static int incomingim_chan1(OscarData *od, FlapConnection *conn, aim_userinfo_t
* Note: There *may* be some clients which send messages as HTML formatted -
* they need to be special-cased somehow.
*/
- if (aim_snvalid_icq(purple_account_get_username(account)) && aim_snvalid_icq(userinfo->sn)) {
+ if (oscar_util_valid_name_icq(purple_account_get_username(account)) && oscar_util_valid_name_icq(userinfo->bn)) {
/* being recevied by ICQ from ICQ - escape HTML so it is displayed as sent */
gchar *tmp2 = g_markup_escape_text(tmp, -1);
g_free(tmp);
@@ -2372,7 +2375,7 @@ static int incomingim_chan1(OscarData *od, FlapConnection *conn, aim_userinfo_t
g_datalist_clear(&attribs);
}
- serv_got_im(gc, userinfo->sn, tmp, flags,
+ serv_got_im(gc, userinfo->bn, tmp, flags,
(args->icbmflags & AIM_IMFLAGS_OFFLINE) ? args->timestamp : time(NULL));
g_free(tmp);
@@ -2391,13 +2394,13 @@ incomingim_chan2(OscarData *od, FlapConnection *conn, aim_userinfo_t *userinfo,
gc = od->gc;
account = purple_connection_get_account(gc);
- od = gc->proto_data;
+ od = purple_connection_get_protocol_data(gc);
if (args == NULL)
return 0;
purple_debug_misc("oscar", "Incoming rendezvous message of type %u, "
- "user %s, status %hu\n", args->type, userinfo->sn, args->status);
+ "user %s, status %hu\n", args->type, userinfo->bn, args->status);
if (args->msg != NULL)
{
@@ -2443,7 +2446,7 @@ incomingim_chan2(OscarData *od, FlapConnection *conn, aim_userinfo_t *userinfo,
g_strdup_printf("%d", args->info.chat.roominfo.exchange));
serv_got_chat_invite(gc,
utf8name,
- userinfo->sn,
+ userinfo->bn,
message,
components);
}
@@ -2453,14 +2456,14 @@ incomingim_chan2(OscarData *od, FlapConnection *conn, aim_userinfo_t *userinfo,
{
if (args->status == AIM_RENDEZVOUS_PROPOSE)
{
- peer_connection_got_proposition(od, userinfo->sn, message, args);
+ peer_connection_got_proposition(od, userinfo->bn, message, args);
}
else if (args->status == AIM_RENDEZVOUS_CANCEL)
{
/* The other user canceled a peer request */
PeerConnection *conn;
- conn = peer_connection_find_by_cookie(od, userinfo->sn, args->cookie);
+ conn = peer_connection_find_by_cookie(od, userinfo->bn, args->cookie);
/*
* If conn is NULL it means we haven't tried to create
* a connection with that user. They may be trying to
@@ -2491,7 +2494,7 @@ incomingim_chan2(OscarData *od, FlapConnection *conn, aim_userinfo_t *userinfo,
else if (args->type & OSCAR_CAPABILITY_BUDDYICON)
{
- purple_buddy_icons_set_for_user(account, userinfo->sn,
+ purple_buddy_icons_set_for_user(account, userinfo->bn,
g_memdup(args->info.icon.icon, args->info.icon.length),
args->info.icon.length,
NULL);
@@ -2528,9 +2531,10 @@ purple_auth_request(struct name_data *data, char *msg)
PurpleAccount *account;
PurpleBuddy *buddy;
PurpleGroup *group;
+ const char *bname, *gname;
gc = data->gc;
- od = gc->proto_data;
+ od = purple_connection_get_protocol_data(gc);
account = purple_connection_get_account(gc);
buddy = purple_find_buddy(account, data->name);
if (buddy != NULL)
@@ -2540,15 +2544,17 @@ purple_auth_request(struct name_data *data, char *msg)
if (group != NULL)
{
+ bname = purple_buddy_get_name(buddy);
+ gname = purple_group_get_name(group);
purple_debug_info("oscar", "ssi: adding buddy %s to group %s\n",
- buddy->name, group->name);
+ bname, gname);
aim_ssi_sendauthrequest(od, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list."));
- if (!aim_ssi_itemlist_finditem(od->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY))
+ if (!aim_ssi_itemlist_finditem(od->ssi.local, gname, bname, AIM_SSI_TYPE_BUDDY))
{
- aim_ssi_addbuddy(od, buddy->name, group->name, NULL, purple_buddy_get_alias_only(buddy), NULL, NULL, TRUE);
+ aim_ssi_addbuddy(od, bname, gname, NULL, purple_buddy_get_alias_only(buddy), NULL, NULL, TRUE);
/* Mobile users should always be online */
- if (buddy->name[0] == '+') {
+ if (bname[0] == '+') {
purple_prpl_got_user_status(account,
purple_buddy_get_name(buddy),
OSCAR_STATUS_ID_AVAILABLE, NULL);
@@ -2588,8 +2594,8 @@ purple_auth_sendrequest_menu(PurpleBlistNode *node, gpointer ignored)
g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
buddy = (PurpleBuddy *) node;
- gc = purple_account_get_connection(buddy->account);
- purple_auth_sendrequest(gc, buddy->name);
+ gc = purple_account_get_connection(purple_buddy_get_account(buddy));
+ purple_auth_sendrequest(gc, purple_buddy_get_name(buddy));
}
/* When other people ask you for authorization */
@@ -2598,7 +2604,7 @@ purple_auth_grant(gpointer cbdata)
{
struct name_data *data = cbdata;
PurpleConnection *gc = data->gc;
- OscarData *od = gc->proto_data;
+ OscarData *od = purple_connection_get_protocol_data(gc);
aim_ssi_sendauthreply(od, data->name, 0x01, NULL);
@@ -2610,7 +2616,7 @@ static void
purple_auth_dontgrant(struct name_data *data, char *msg)
{
PurpleConnection *gc = data->gc;
- OscarData *od = gc->proto_data;
+ OscarData *od = purple_connection_get_protocol_data(gc);
aim_ssi_sendauthreply(od, data->name, 0x00, msg ? msg : _("No reason given."));
}
@@ -2724,21 +2730,21 @@ incomingim_chan4(OscarData *od, FlapConnection *conn, aim_userinfo_t *userinfo,
case 0x06: { /* Someone requested authorization */
if (i >= 6) {
struct name_data *data = g_new(struct name_data, 1);
- gchar *sn = g_strdup_printf("%u", args->uin);
+ gchar *bn = g_strdup_printf("%u", args->uin);
gchar *reason = NULL;
if (msg2[5] != NULL)
- reason = purple_plugin_oscar_decode_im_part(account, sn, AIM_CHARSET_CUSTOM, 0x0000, msg2[5], strlen(msg2[5]));
+ reason = purple_plugin_oscar_decode_im_part(account, bn, AIM_CHARSET_CUSTOM, 0x0000, msg2[5], strlen(msg2[5]));
purple_debug_info("oscar",
"Received an authorization request from UIN %u\n",
args->uin);
data->gc = gc;
- data->name = sn;
+ data->name = bn;
data->nick = NULL;
- purple_account_request_authorization(account, sn, NULL, NULL,
- reason, purple_find_buddy(account, sn) != NULL,
+ purple_account_request_authorization(account, bn, NULL, NULL,
+ reason, purple_find_buddy(account, bn) != NULL,
purple_auth_grant,
purple_auth_dontgrant_msgprompt, data);
g_free(reason);
@@ -2940,7 +2946,7 @@ static int purple_parse_misses(OscarData *od, FlapConnection *conn, FlapFrame *f
"You missed %hu messages from %s because they were invalid.",
nummissed),
nummissed,
- userinfo->sn);
+ userinfo->bn);
break;
case 1: /* Message too large */
buf = g_strdup_printf(
@@ -2949,7 +2955,7 @@ static int purple_parse_misses(OscarData *od, FlapConnection *conn, FlapFrame *f
"You missed %hu messages from %s because they were too large.",
nummissed),
nummissed,
- userinfo->sn);
+ userinfo->bn);
break;
case 2: /* Rate exceeded */
buf = g_strdup_printf(
@@ -2958,7 +2964,7 @@ static int purple_parse_misses(OscarData *od, FlapConnection *conn, FlapFrame *f
"You missed %hu messages from %s because the rate limit has been exceeded.",
nummissed),
nummissed,
- userinfo->sn);
+ userinfo->bn);
break;
case 3: /* Evil Sender */
buf = g_strdup_printf(
@@ -2967,7 +2973,7 @@ static int purple_parse_misses(OscarData *od, FlapConnection *conn, FlapFrame *f
"You missed %hu messages from %s because his/her warning level is too high.",
nummissed),
nummissed,
- userinfo->sn);
+ userinfo->bn);
break;
case 4: /* Evil Receiver */
buf = g_strdup_printf(
@@ -2976,7 +2982,7 @@ static int purple_parse_misses(OscarData *od, FlapConnection *conn, FlapFrame *f
"You missed %hu messages from %s because your warning level is too high.",
nummissed),
nummissed,
- userinfo->sn);
+ userinfo->bn);
break;
default:
buf = g_strdup_printf(
@@ -2985,11 +2991,11 @@ static int purple_parse_misses(OscarData *od, FlapConnection *conn, FlapFrame *f
"You missed %hu messages from %s for an unknown reason.",
nummissed),
nummissed,
- userinfo->sn);
+ userinfo->bn);
break;
}
- if (!purple_conv_present_error(userinfo->sn, account, buf))
+ if (!purple_conv_present_error(userinfo->bn, account, buf))
purple_notify_error(od->gc, NULL, buf, NULL);
g_free(buf);
@@ -3107,7 +3113,7 @@ static int purple_parse_genericerr(OscarData *od, FlapConnection *conn, FlapFram
static int purple_parse_msgerr(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
PurpleConnection *gc = od->gc;
#ifdef TODOFT
- OscarData *od = gc->proto_data;
+ OscarData *od = purple_connection_get_protocol_data(gc);
PurpleXfer *xfer;
#endif
va_list ap;
@@ -3135,7 +3141,7 @@ static int purple_parse_msgerr(OscarData *od, FlapConnection *conn, FlapFrame *f
}
#endif
- /* Data is assumed to be the destination sn */
+ /* Data is assumed to be the destination bn */
buf = g_strdup_printf(_("Unable to send message: %s"), (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason."));
if (!purple_conv_present_error(data, purple_connection_get_account(gc), buf)) {
g_free(buf);
@@ -3152,25 +3158,25 @@ static int purple_parse_mtn(OscarData *od, FlapConnection *conn, FlapFrame *fr,
PurpleConnection *gc = od->gc;
va_list ap;
guint16 type1, type2;
- char *sn;
+ char *bn;
va_start(ap, fr);
type1 = (guint16) va_arg(ap, unsigned int);
- sn = va_arg(ap, char *);
+ bn = va_arg(ap, char *);
type2 = (guint16) va_arg(ap, unsigned int);
va_end(ap);
switch (type2) {
case 0x0000: { /* Text has been cleared */
- serv_got_typing_stopped(gc, sn);
+ serv_got_typing_stopped(gc, bn);
} break;
case 0x0001: { /* Paused typing */
- serv_got_typing(gc, sn, 0, PURPLE_TYPED);
+ serv_got_typing(gc, bn, 0, PURPLE_TYPED);
} break;
case 0x0002: { /* Typing */
- serv_got_typing(gc, sn, 0, PURPLE_TYPING);
+ serv_got_typing(gc, bn, 0, PURPLE_TYPING);
} break;
default: {
@@ -3178,7 +3184,7 @@ static int purple_parse_mtn(OscarData *od, FlapConnection *conn, FlapFrame *fr,
* It looks like iChat sometimes sends typing notification
* with type1=0x0001 and type2=0x000f. Not sure why.
*/
- purple_debug_info("oscar", "Received unknown typing notification message from %s. Type1 is 0x%04x and type2 is 0x%04hx.\n", sn, type1, type2);
+ purple_debug_info("oscar", "Received unknown typing notification message from %s. Type1 is 0x%04x and type2 is 0x%04hx.\n", bn, type1, type2);
} break;
}
@@ -3239,7 +3245,7 @@ static int purple_parse_userinfo(OscarData *od, FlapConnection *conn, FlapFrame
oscar_user_info_append_extra_info(gc, user_info, NULL, userinfo);
- if ((userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) && !aim_snvalid_sms(userinfo->sn)) {
+ if ((userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) && !oscar_util_valid_name_sms(userinfo->bn)) {
/* An SMS contact is always online; its Online Since valid is not useful */
time_t t = userinfo->onlinesince;
oscar_user_info_add_pair(user_info, _("Online Since"), purple_date_format_full(localtime(&t)));
@@ -3273,11 +3279,11 @@ static int purple_parse_userinfo(OscarData *od, FlapConnection *conn, FlapFrame
purple_notify_user_info_add_section_break(user_info);
tmp = g_strdup_printf("<a href=\"http://profiles.aim.com/%s\">%s</a>",
- purple_normalize(account, userinfo->sn), _("View web profile"));
+ purple_normalize(account, userinfo->bn), _("View web profile"));
purple_notify_user_info_add_pair(user_info, NULL, tmp);
g_free(tmp);
- purple_notify_userinfo(gc, userinfo->sn, user_info, NULL, NULL);
+ purple_notify_userinfo(gc, userinfo->bn, user_info, NULL, NULL);
purple_notify_user_info_destroy(user_info);
return 1;
@@ -3299,14 +3305,14 @@ static int purple_got_infoblock(OscarData *od, FlapConnection *conn, FlapFrame *
userinfo = va_arg(ap, aim_userinfo_t *);
va_end(ap);
- b = purple_find_buddy(account, userinfo->sn);
+ b = purple_find_buddy(account, userinfo->bn);
if (b == NULL)
return 1;
- if (!aim_snvalid_icq(userinfo->sn))
+ if (!oscar_util_valid_name_icq(userinfo->bn))
{
- if (strcmp(purple_buddy_get_name(b), userinfo->sn) != 0)
- serv_got_alias(gc, purple_buddy_get_name(b), userinfo->sn);
+ if (strcmp(purple_buddy_get_name(b), userinfo->bn) != 0)
+ serv_got_alias(gc, purple_buddy_get_name(b), userinfo->bn);
else
serv_got_alias(gc, purple_buddy_get_name(b), NULL);
}
@@ -3323,7 +3329,7 @@ static int purple_got_infoblock(OscarData *od, FlapConnection *conn, FlapFrame *
userinfo->away,
userinfo->away_len);
g_free(charset);
- purple_prpl_got_user_status(account, userinfo->sn,
+ purple_prpl_got_user_status(account, userinfo->bn,
purple_status_get_id(status),
"message", message, NULL);
g_free(message);
@@ -3444,7 +3450,7 @@ static int purple_conv_chat_join(OscarData *od, FlapConnection *conn, FlapFrame
return 1;
for (i = 0; i < count; i++)
- purple_conv_chat_add_user(PURPLE_CONV_CHAT(c->conv), info[i].sn, NULL, PURPLE_CBFLAGS_NONE, TRUE);
+ purple_conv_chat_add_user(PURPLE_CONV_CHAT(c->conv), info[i].bn, NULL, PURPLE_CBFLAGS_NONE, TRUE);
return 1;
}
@@ -3467,7 +3473,7 @@ static int purple_conv_chat_leave(OscarData *od, FlapConnection *conn, FlapFrame
return 1;
for (i = 0; i < count; i++)
- purple_conv_chat_remove_user(PURPLE_CONV_CHAT(c->conv), info[i].sn, NULL);
+ purple_conv_chat_remove_user(PURPLE_CONV_CHAT(c->conv), info[i].bn, NULL);
return 1;
}
@@ -3536,7 +3542,7 @@ static int purple_conv_chat_incoming_msg(OscarData *od, FlapConnection *conn, Fl
if (utf8 == NULL)
/* The conversion failed! */
utf8 = g_strdup(_("[Unable to display a message from this user because it contained invalid characters.]"));
- serv_got_chat_in(gc, ccon->id, info->sn, 0, utf8, time((time_t)NULL));
+ serv_got_chat_in(gc, ccon->id, info->bn, 0, utf8, time((time_t)NULL));
g_free(utf8);
return 1;
@@ -3544,11 +3550,15 @@ static int purple_conv_chat_incoming_msg(OscarData *od, FlapConnection *conn, Fl
static int purple_email_parseupdate(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
va_list ap;
- PurpleConnection *gc = od->gc;
+ PurpleConnection *gc;
+ PurpleAccount *account;
struct aim_emailinfo *emailinfo;
int havenewmail;
char *alertitle, *alerturl;
+ gc = od->gc;
+ account = purple_connection_get_account(gc);
+
va_start(ap, fr);
emailinfo = va_arg(ap, struct aim_emailinfo *);
havenewmail = va_arg(ap, int);
@@ -3556,12 +3566,13 @@ static int purple_email_parseupdate(OscarData *od, FlapConnection *conn, FlapFra
alerturl = va_arg(ap, char *);
va_end(ap);
- if ((emailinfo != NULL) && purple_account_get_check_mail(gc->account)) {
- gchar *to = g_strdup_printf("%s%s%s", purple_account_get_username(purple_connection_get_account(gc)),
- emailinfo->domain ? "@" : "",
- emailinfo->domain ? emailinfo->domain : "");
- if (emailinfo->unread && havenewmail)
- purple_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL);
+ if (account != NULL && emailinfo != NULL && emailinfo->unread && havenewmail) {
+ gchar *to = g_strdup_printf("%s%s%s",
+ purple_account_get_username(account),
+ emailinfo->domain ? "@" : "",
+ emailinfo->domain ? emailinfo->domain : "");
+ purple_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL,
+ (const char **)&to, (const char **)&emailinfo->url, NULL, NULL);
g_free(to);
}
@@ -3574,12 +3585,12 @@ static int purple_email_parseupdate(OscarData *od, FlapConnection *conn, FlapFra
static int purple_icon_parseicon(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
PurpleConnection *gc = od->gc;
va_list ap;
- char *sn;
+ char *bn;
guint8 iconcsumtype, *iconcsum, *icon;
guint16 iconcsumlen, iconlen;
va_start(ap, fr);
- sn = va_arg(ap, char *);
+ bn = va_arg(ap, char *);
iconcsumtype = va_arg(ap, int);
iconcsum = va_arg(ap, guint8 *);
iconcsumlen = va_arg(ap, int);
@@ -3594,7 +3605,7 @@ static int purple_icon_parseicon(OscarData *od, FlapConnection *conn, FlapFrame
if ((iconlen > 0) && (iconlen != 90)) {
char *b16 = purple_base16_encode(iconcsum, iconcsumlen);
purple_buddy_icons_set_for_user(purple_connection_get_account(gc),
- sn, g_memdup(icon, iconlen), iconlen, b16);
+ bn, g_memdup(icon, iconlen), iconlen, b16);
g_free(b16);
}
@@ -3604,7 +3615,7 @@ static int purple_icon_parseicon(OscarData *od, FlapConnection *conn, FlapFrame
static void
purple_icons_fetch(PurpleConnection *gc)
{
- OscarData *od = gc->proto_data;
+ OscarData *od = purple_connection_get_protocol_data(gc);
aim_userinfo_t *userinfo;
FlapConnection *conn;
@@ -3651,14 +3662,14 @@ purple_icons_fetch(PurpleConnection *gc)
static int purple_parse_msgack(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
va_list ap;
guint16 type;
- char *sn;
+ char *bn;
va_start(ap, fr);
type = (guint16) va_arg(ap, unsigned int);
- sn = va_arg(ap, char *);
+ bn = va_arg(ap, char *);
va_end(ap);
- purple_debug_info("oscar", "Sent message to %s.\n", sn);
+ purple_debug_info("oscar", "Sent message to %s.\n", bn);
return 1;
}
@@ -3718,7 +3729,7 @@ static int purple_parse_evilnotify(OscarData *od, FlapConnection *conn, FlapFram
userinfo = va_arg(ap, aim_userinfo_t *);
va_end(ap);
- purple_prpl_got_account_warning_level(account, (userinfo && userinfo->sn) ? userinfo->sn : NULL, (newevil/10.0) + 0.5);
+ purple_prpl_got_account_warning_level(account, (userinfo && userinfo->bn) ? userinfo->bn : NULL, (newevil/10.0) + 0.5);
#endif
return 1;
@@ -3733,7 +3744,7 @@ static int purple_selfinfo(OscarData *od, FlapConnection *conn, FlapFrame *fr, .
info = va_arg(ap, aim_userinfo_t *);
va_end(ap);
- purple_connection_set_display_name(od->gc, info->sn);
+ purple_connection_set_display_name(od->gc, info->bn);
/*
* What's with the + 0.5?
@@ -3842,13 +3853,13 @@ static int purple_bosrights(OscarData *od, FlapConnection *conn, FlapFrame *fr,
PurpleAccount *account;
PurpleStatus *status;
PurplePresence *presence;
- const char *message, *itmsurl;
+ const char *username, *message, *itmsurl;
char *tmp;
va_list ap;
guint16 maxpermits, maxdenies;
gc = od->gc;
- od = (OscarData *)gc->proto_data;
+ od = purple_connection_get_protocol_data(gc);
account = purple_connection_get_account(gc);
va_start(ap, fr);
@@ -3871,12 +3882,13 @@ static int purple_bosrights(OscarData *od, FlapConnection *conn, FlapFrame *fr,
if (purple_account_get_user_info(account) != NULL)
serv_set_info(gc, purple_account_get_user_info(account));
- if (!od->icq && strcmp(purple_account_get_username(account), purple_connection_get_display_name(gc)) != 0)
+ username = purple_account_get_username(account);
+ if (!od->icq && strcmp(username, purple_connection_get_display_name(gc)) != 0)
/*
- * Format the screen name for AIM accounts if it's different
+ * Format the username for AIM accounts if it's different
* than what's currently set.
*/
- oscar_format_screenname(gc, account->username);
+ oscar_format_username(gc, username);
/* Set our available message based on the current status */
status = purple_account_get_active_status(account);
@@ -3910,13 +3922,13 @@ static int purple_bosrights(OscarData *od, FlapConnection *conn, FlapFrame *fr,
/*
* The "if" statement here is a pathetic attempt to not attempt to
* connect to the alerts servce (aka email notification) if this
- * screen name does not support it. I think mail notification
+ * username does not support it. I think mail notification
* works for @mac.com accounts but does not work for the newer
* @anythingelse.com accounts. If that's true then this change
* breaks mail notification for @mac.com accounts, but it gets rid
* of an annoying error at signon for @anythingelse.com accounts.
*/
- if ((od->authinfo->email != NULL) && ((strchr(gc->account->username, '@') == NULL)))
+ if (od->authinfo->email != NULL && strchr(username, '@') == NULL)
aim_srv_requestnew(od, SNAC_FAMILY_ALERT);
return 1;
@@ -3980,9 +3992,9 @@ static int purple_icqinfo(OscarData *od, FlapConnection *conn, FlapFrame *fr, ..
user_info = purple_notify_user_info_new();
g_snprintf(who, sizeof(who), "%u", info->uin);
- buddy = purple_find_buddy(purple_connection_get_account(gc), who);
+ buddy = purple_find_buddy(account, who);
if (buddy != NULL)
- bi = g_hash_table_lookup(od->buddyinfo, purple_normalize(buddy->account, buddy->name));
+ bi = g_hash_table_lookup(od->buddyinfo, purple_normalize(account, purple_buddy_get_name(buddy)));
else
bi = NULL;
@@ -3999,7 +4011,7 @@ static int purple_icqinfo(OscarData *od, FlapConnection *conn, FlapFrame *fr, ..
}
oscar_user_info_convert_and_add(account, user_info, _("First Name"), info->first);
oscar_user_info_convert_and_add(account, user_info, _("Last Name"), info->last);
- if (info->email && info->email[0] && (utf8 = oscar_utf8_try_convert(gc->account, info->email))) {
+ if (info->email && info->email[0] && (utf8 = oscar_utf8_try_convert(account, info->email))) {
buf = g_strdup_printf("<a href=\"mailto:%s\">%s</a>", utf8, utf8);
purple_notify_user_info_add_pair(user_info, _("Email Address"), buf);
g_free(buf);
@@ -4008,7 +4020,7 @@ static int purple_icqinfo(OscarData *od, FlapConnection *conn, FlapFrame *fr, ..
if (info->numaddresses && info->email2) {
int i;
for (i = 0; i < info->numaddresses; i++) {
- if (info->email2[i] && info->email2[i][0] && (utf8 = oscar_utf8_try_convert(gc->account, info->email2[i]))) {
+ if (info->email2[i] && info->email2[i][0] && (utf8 = oscar_utf8_try_convert(account, info->email2[i]))) {
buf = g_strdup_printf("<a href=\"mailto:%s\">%s</a>", utf8, utf8);
purple_notify_user_info_add_pair(user_info, _("Email Address"), buf);
g_free(buf);
@@ -4043,7 +4055,7 @@ static int purple_icqinfo(OscarData *od, FlapConnection *conn, FlapFrame *fr, ..
snprintf(age, sizeof(age), "%hhd", info->age);
purple_notify_user_info_add_pair(user_info, _("Age"), age);
}
- if (info->personalwebpage && info->personalwebpage[0] && (utf8 = oscar_utf8_try_convert(gc->account, info->personalwebpage))) {
+ if (info->personalwebpage && info->personalwebpage[0] && (utf8 = oscar_utf8_try_convert(account, info->personalwebpage))) {
buf = g_strdup_printf("<a href=\"%s\">%s</a>", utf8, utf8);
purple_notify_user_info_add_pair(user_info, _("Personal Web Page"), buf);
g_free(buf);
@@ -4079,7 +4091,7 @@ static int purple_icqinfo(OscarData *od, FlapConnection *conn, FlapFrame *fr, ..
oscar_user_info_convert_and_add(account, user_info, _("Division"), info->workdivision);
oscar_user_info_convert_and_add(account, user_info, _("Position"), info->workposition);
- if (info->workwebpage && info->workwebpage[0] && (utf8 = oscar_utf8_try_convert(gc->account, info->workwebpage))) {
+ if (info->workwebpage && info->workwebpage[0] && (utf8 = oscar_utf8_try_convert(account, info->workwebpage))) {
char *webpage = g_strdup_printf("<a href=\"%s\">%s</a>", utf8, utf8);
purple_notify_user_info_add_pair(user_info, _("Web Page"), webpage);
g_free(webpage);
@@ -4113,7 +4125,7 @@ static int purple_icqalias(OscarData *od, FlapConnection *conn, FlapFrame *fr, .
if (info->uin && info->nick && info->nick[0] && (utf8 = oscar_utf8_try_convert(account, info->nick))) {
g_snprintf(who, sizeof(who), "%u", info->uin);
serv_got_alias(gc, who, utf8);
- if ((b = purple_find_buddy(gc->account, who))) {
+ if ((b = purple_find_buddy(account, who))) {
purple_blist_node_set_string((PurpleBlistNode*)b, "servernick", utf8);
}
g_free(utf8);
@@ -4243,7 +4255,7 @@ static int purple_info_change(OscarData *od, FlapConnection *conn, FlapFrame *fr
PurpleConnection *gc = od->gc;
va_list ap;
guint16 perms, err;
- char *url, *sn, *email;
+ char *url, *bn, *email;
int change;
va_start(ap, fr);
@@ -4251,15 +4263,15 @@ static int purple_info_change(OscarData *od, FlapConnection *conn, FlapFrame *fr
perms = (guint16) va_arg(ap, unsigned int);
err = (guint16) va_arg(ap, unsigned int);
url = va_arg(ap, char *);
- sn = va_arg(ap, char *);
+ bn = va_arg(ap, char *);
email = va_arg(ap, char *);
va_end(ap);
purple_debug_misc("oscar",
- "account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n",
+ "account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, bn=%s, email=%s\n",
change ? "change" : "request", perms, err,
(url != NULL) ? url : "(null)",
- (sn != NULL) ? sn : "(null)",
+ (bn != NULL) ? bn : "(null)",
(email != NULL) ? email : "(null)");
if ((err > 0) && (url != NULL)) {
@@ -4301,7 +4313,7 @@ oscar_keepalive(PurpleConnection *gc)
OscarData *od;
FlapConnection *conn;
- od = (OscarData *)gc->proto_data;
+ od = purple_connection_get_protocol_data(gc);
conn = flap_connection_getbytype(od, SNAC_FAMILY_LOCATE);
if (conn != NULL)
flap_connection_send_keepalive(od, conn);
@@ -4313,7 +4325,7 @@ oscar_send_typing(PurpleConnection *gc, const char *name, PurpleTypingState stat
OscarData *od;
PeerConnection *conn;
- od = (OscarData *)gc->proto_data;
+ od = purple_connection_get_protocol_data(gc);
conn = peer_connection_find_by_type(od, name, OSCAR_CAPABILITY_DIRECTIM);
if ((conn != NULL) && (conn->ready))
@@ -4323,7 +4335,7 @@ oscar_send_typing(PurpleConnection *gc, const char *name, PurpleTypingState stat
else {
/* Don't send if this turkey is in our deny list */
GSList *list;
- for (list=gc->account->deny; (list && aim_sncmp(name, list->data)); list=list->next);
+ for (list=gc->account->deny; (list && oscar_util_name_compare(name, list->data)); list=list->next);
if (!list) {
struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, purple_normalize(gc->account, name));
if (bi && bi->typingnot) {
@@ -4409,7 +4421,7 @@ purple_odc_send_im(PeerConnection *conn, const char *message, PurpleMessageFlags
/* Convert the message to a good encoding */
purple_plugin_oscar_convert_to_best_encoding(conn->od->gc,
- conn->sn, msg->str, &tmp, &tmplen, &charset, &charsubset);
+ conn->bn, msg->str, &tmp, &tmplen, &charset, &charsubset);
g_string_free(msg, TRUE);
msg = g_string_new_len(tmp, tmplen);
g_free(tmp);
@@ -4435,11 +4447,11 @@ oscar_send_im(PurpleConnection *gc, const char *name, const char *message, Purpl
char *tmp1, *tmp2;
gboolean is_sms, is_html;
- od = (OscarData *)gc->proto_data;
+ od = purple_connection_get_protocol_data(gc);
account = purple_connection_get_account(gc);
ret = 0;
- is_sms = aim_snvalid_sms(name);
+ is_sms = oscar_util_valid_name_sms(name);
if (od->icq && is_sms) {
/*
@@ -4478,7 +4490,7 @@ oscar_send_im(PurpleConnection *gc, const char *name, const char *message, Purpl
"You must be Direct Connected to send IM Images."),
PURPLE_MESSAGE_ERROR, time(NULL));
- buddy = purple_find_buddy(gc->account, name);
+ buddy = purple_find_buddy(account, name);
bi = g_hash_table_lookup(od->buddyinfo, purple_normalize(account, name));
if (!bi) {
@@ -4553,17 +4565,17 @@ oscar_send_im(PurpleConnection *gc, const char *name, const char *message, Purpl
purple_imgstore_unref(img);
}
- args.destsn = name;
+ args.destbn = name;
/*
* If we're IMing an SMS user or an ICQ user from an ICQ account, then strip HTML.
*/
- if (aim_snvalid_sms(name)) {
+ if (oscar_util_valid_name_sms(name)) {
/* Messaging an SMS (mobile) user */
tmp2 = purple_markup_strip_html(tmp1);
is_html = FALSE;
- } else if (aim_snvalid_icq(purple_account_get_username(account))) {
- if (aim_snvalid_icq(name)) {
+ } else if (oscar_util_valid_name_icq(purple_account_get_username(account))) {
+ if (oscar_util_valid_name_icq(name)) {
/* From ICQ to ICQ */
tmp2 = purple_markup_strip_html(tmp1);
is_html = FALSE;
@@ -4623,9 +4635,9 @@ oscar_send_im(PurpleConnection *gc, const char *name, const char *message, Purpl
* AIM users can only request AIM info.
*/
void oscar_get_info(PurpleConnection *gc, const char *name) {
- OscarData *od = (OscarData *)gc->proto_data;
+ OscarData *od = purple_connection_get_protocol_data(gc);
- if (od->icq && aim_snvalid_icq(name))
+ if (od->icq && oscar_util_valid_name_icq(name))
aim_icq_getallinfo(od, name);
else
aim_locate_getinfoshort(od, name, 0x00000003);
@@ -4635,14 +4647,14 @@ void oscar_get_info(PurpleConnection *gc, const char *name) {
static void oscar_set_dir(PurpleConnection *gc, const char *first, const char *middle, const char *last,
const char *maiden, const char *city, const char *state, const char *country, int web) {
/* XXX - some of these things are wrong, but i'm lazy */
- OscarData *od = (OscarData *)gc->proto_data;
+ OscarData *od = purple_connection_get_protocol_data(gc);
aim_locate_setdirinfo(od, first, middle, last,
maiden, NULL, NULL, city, state, NULL, 0, web);
}
#endif
void oscar_set_idle(PurpleConnection *gc, int time) {
- OscarData *od = (OscarData *)gc->proto_data;
+ OscarData *od = purple_connection_get_protocol_data(gc);
aim_srv_setidle(od, time);
}
@@ -4688,7 +4700,7 @@ oscar_set_extendedstatus(PurpleConnection *gc)
const gchar *status_id;
guint32 data = 0x00000000;
- od = gc->proto_data;
+ od = purple_connection_get_protocol_data(gc);
account = purple_connection_get_account(gc);
status = purple_account_get_active_status(account);
status_id = purple_status_get_id(status);
@@ -4722,20 +4734,21 @@ oscar_set_info_and_status(PurpleAccount *account, gboolean setinfo, const char *
gboolean setstatus, PurpleStatus *status)
{
PurpleConnection *gc = purple_account_get_connection(account);
- OscarData *od = gc->proto_data;
+ OscarData *od = purple_connection_get_protocol_data(gc);
PurpleStatusType *status_type;
PurpleStatusPrimitive primitive;
- char *htmlinfo;
char *info_encoding = NULL;
char *info = NULL;
gsize infolen = 0;
- const char *htmlaway;
char *away_encoding = NULL;
char *away = NULL;
gsize awaylen = 0;
+ char *status_text = NULL;
+ const char *itmsurl = NULL;
+
status_type = purple_status_get_type(status);
primitive = purple_status_type_get_primitive(status_type);
@@ -4753,7 +4766,7 @@ oscar_set_info_and_status(PurpleAccount *account, gboolean setinfo, const char *
}
else if (rawinfo != NULL)
{
- htmlinfo = purple_strdup_withhtml(rawinfo);
+ char *htmlinfo = purple_strdup_withhtml(rawinfo);
info = purple_prpl_oscar_convert_to_infotext(htmlinfo, &infolen, &info_encoding);
g_free(htmlinfo);
@@ -4770,102 +4783,86 @@ oscar_set_info_and_status(PurpleAccount *account, gboolean setinfo, const char *
}
}
- if (!setstatus)
- {
- /* Do nothing! */
- }
- else if (primitive == PURPLE_STATUS_AVAILABLE || primitive == PURPLE_STATUS_INVISIBLE)
+ if (setstatus)
{
- const char *status_html, *itmsurl;
- char *status_text = NULL;
+ const char *status_html;
status_html = purple_status_get_attr_string(status, "message");
- if (status_html != NULL)
+
+ if (primitive == PURPLE_STATUS_AVAILABLE || primitive == PURPLE_STATUS_INVISIBLE)
{
- status_text = purple_markup_strip_html(status_html);
- /* If the status_text is longer than 251 characters then truncate it */
- if (strlen(status_text) > MAXAVAILMSGLEN)
+ /* This is needed for us to un-set any previous away message. */
+ away = g_strdup("");
+ }
+ else
+ {
+ gchar *linkified;
+
+ /* We do this for icq too so that they work for old third party clients */
+ linkified = purple_markup_linkify(status_html);
+ away = purple_prpl_oscar_convert_to_infotext(linkified, &awaylen, &away_encoding);
+ g_free(linkified);
+
+ if (awaylen > od->rights.maxawaymsglen)
{
- char *tmp = g_utf8_find_prev_char(status_text, &status_text[MAXAVAILMSGLEN - 2]);
- strcpy(tmp, "...");
+ gchar *errstr;
+
+ errstr = g_strdup_printf(dngettext(PACKAGE, "The maximum away message length of %d byte "
+ "has been exceeded. It has been truncated for you.",
+ "The maximum away message length of %d bytes "
+ "has been exceeded. It has been truncated for you.",
+ od->rights.maxawaymsglen), od->rights.maxawaymsglen);
+ purple_notify_warning(gc, NULL, _("Away message too long."), errstr);
+ g_free(errstr);
}
}
- itmsurl = purple_status_get_attr_string(status, "itmsurl");
+ }
- aim_srv_setextrainfo(od, FALSE, 0, TRUE, status_text, itmsurl);
- g_free(status_text);
+ aim_locate_setprofile(od,
+ info_encoding, info, MIN(infolen, od->rights.maxsiglen),
+ away_encoding, away, MIN(awaylen, od->rights.maxawaymsglen));
+ g_free(info);
+ g_free(away);
- /* This is needed for us to un-set any previous away message. */
- away = g_strdup("");
- }
- else
+ if (setstatus)
{
- char *status_text = NULL;
-
- htmlaway = purple_status_get_attr_string(status, "message");
- if ((htmlaway == NULL) || (*htmlaway == '\0'))
- htmlaway = purple_status_type_get_name(status_type);
-
- /* ICQ 6.x seems to use an available message for all statuses so set one */
- if (od->icq)
+ const char *status_html;
+
+ status_html = purple_status_get_attr_string(status, "message");
+ if (od->icq && (status_html == NULL || status_html[0] == '\0'))
+ status_html = purple_status_type_get_name(status_type);
+ if (status_html != NULL)
{
- status_text = purple_markup_strip_html(htmlaway);
+ status_text = purple_markup_strip_html(status_html);
/* If the status_text is longer than 251 characters then truncate it */
if (strlen(status_text) > MAXAVAILMSGLEN)
{
char *tmp = g_utf8_find_prev_char(status_text, &status_text[MAXAVAILMSGLEN - 2]);
strcpy(tmp, "...");
}
- aim_srv_setextrainfo(od, FALSE, 0, TRUE, status_text, NULL);
}
- g_free(status_text);
-
- /* Set a proper away message for icq too so that they work for old third party clients */
-
- away = purple_prpl_oscar_convert_to_infotext(htmlaway, &awaylen, &away_encoding);
-
- if (awaylen > od->rights.maxawaymsglen)
- {
- gchar *errstr;
- errstr = g_strdup_printf(dngettext(PACKAGE, "The maximum away message length of %d byte "
- "has been exceeded. It has been truncated for you.",
- "The maximum away message length of %d bytes "
- "has been exceeded. It has been truncated for you.",
- od->rights.maxawaymsglen), od->rights.maxawaymsglen);
- purple_notify_warning(gc, NULL, _("Away message too long."), errstr);
- g_free(errstr);
- }
- }
+ itmsurl = purple_status_get_attr_string(status, "itmsurl");
- if (setstatus)
+ /* TODO: Combine these two calls! */
+ aim_srv_setextrainfo(od, FALSE, 0, TRUE, status_text, itmsurl);
oscar_set_extendedstatus(gc);
-
- aim_locate_setprofile(od, info_encoding, info, MIN(infolen, od->rights.maxsiglen),
- away_encoding, away, MIN(awaylen, od->rights.maxawaymsglen));
- g_free(info);
- g_free(away);
+ }
}
static void
-oscar_set_status_icq(PurpleAccount *account, PurpleStatus *status)
+oscar_set_status_icq(PurpleAccount *account)
{
PurpleConnection *gc = purple_account_get_connection(account);
- OscarData *od = NULL;
-
- if (gc)
- od = (OscarData *)gc->proto_data;
- if (!od)
- return;
-
- if (purple_status_type_get_primitive(purple_status_get_type(status)) == PURPLE_STATUS_INVISIBLE)
- account->perm_deny = PURPLE_PRIVACY_ALLOW_USERS;
- else
- account->perm_deny = PURPLE_PRIVACY_DENY_USERS;
- if ((od->ssi.received_data) && (aim_ssi_getpermdeny(od->ssi.local) != account->perm_deny))
- aim_ssi_setpermdeny(od, account->perm_deny, 0xffffffff);
+ /* Our permit/deny setting affects our invisibility */
+ oscar_set_permit_deny(gc);
+ /*
+ * TODO: I guess we should probably wait and do this after we get
+ * confirmation from the above SSI call? Right now other people
+ * see our status blip to "invisible" before we appear offline.
+ */
oscar_set_extendedstatus(gc);
}
@@ -4884,14 +4881,14 @@ oscar_set_status(PurpleAccount *account, PurpleStatus *status)
oscar_set_info_and_status(account, FALSE, NULL, TRUE, status);
/* Set the ICQ status for ICQ accounts only */
- if (aim_snvalid_icq(purple_account_get_username(account)))
- oscar_set_status_icq(account, status);
+ if (oscar_util_valid_name_icq(purple_account_get_username(account)))
+ oscar_set_status_icq(account);
}
#ifdef CRAZY_WARN
void
oscar_warn(PurpleConnection *gc, const char *name, gboolean anonymous) {
- OscarData *od = (OscarData *)gc->proto_data;
+ OscarData *od = purple_connection_get_protocol_data(gc);
aim_im_warn(od, od->conn, name, anonymous ? AIM_WARN_ANON : 0);
}
#endif
@@ -4900,14 +4897,17 @@ void
oscar_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) {
OscarData *od;
PurpleAccount *account;
+ const char *bname, *gname;
- od = (OscarData *)gc->proto_data;
+ od = purple_connection_get_protocol_data(gc);
account = purple_connection_get_account(gc);
+ bname = purple_buddy_get_name(buddy);
+ gname = purple_group_get_name(group);
- if (!aim_snvalid(buddy->name)) {
+ if (!oscar_util_valid_name(bname)) {
gchar *buf;
- buf = g_strdup_printf(_("Could not add the buddy %s because the username is invalid. Usernames must be a valid email address, or start with a letter and contain only letters, numbers and spaces, or contain only numbers."), buddy->name);
- if (!purple_conv_present_error(buddy->name, account, buf))
+ buf = g_strdup_printf(_("Could not add the buddy %s because the username is invalid. Usernames must be a valid email address, or start with a letter and contain only letters, numbers and spaces, or contain only numbers."), bname);
+ if (!purple_conv_present_error(bname, account, buf))
purple_notify_error(gc, NULL, _("Unable to Add"), buf);
g_free(buf);
@@ -4917,39 +4917,40 @@ oscar_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) {
return;
}
- if ((od->ssi.received_data) && !(aim_ssi_itemlist_finditem(od->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY))) {
+ if ((od->ssi.received_data) && !(aim_ssi_itemlist_finditem(od->ssi.local, gname, bname, AIM_SSI_TYPE_BUDDY))) {
purple_debug_info("oscar",
- "ssi: adding buddy %s to group %s\n", buddy->name, group->name);
- aim_ssi_addbuddy(od, buddy->name, group->name, NULL, purple_buddy_get_alias_only(buddy), NULL, NULL, 0);
+ "ssi: adding buddy %s to group %s\n", bname, gname);
+ aim_ssi_addbuddy(od, bname, gname, NULL, purple_buddy_get_alias_only(buddy), NULL, NULL, 0);
/* Mobile users should always be online */
- if (buddy->name[0] == '+') {
+ if (bname[0] == '+') {
purple_prpl_got_user_status(account,
- purple_buddy_get_name(buddy),
- OSCAR_STATUS_ID_AVAILABLE, NULL);
+ bname, OSCAR_STATUS_ID_AVAILABLE, NULL);
purple_prpl_got_user_status(account,
- purple_buddy_get_name(buddy),
- OSCAR_STATUS_ID_MOBILE, NULL);
+ bname, OSCAR_STATUS_ID_MOBILE, NULL);
}
}
/* XXX - Should this be done from AIM accounts, as well? */
if (od->icq)
- aim_icq_getalias(od, buddy->name);
+ aim_icq_getalias(od, bname);
}
void oscar_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) {
- OscarData *od = (OscarData *)gc->proto_data;
+ OscarData *od = purple_connection_get_protocol_data(gc);
if (od->ssi.received_data) {
+ const char *gname = purple_group_get_name(group);
+ const char *bname = purple_buddy_get_name(buddy);
purple_debug_info("oscar",
- "ssi: deleting buddy %s from group %s\n", buddy->name, group->name);
- aim_ssi_delbuddy(od, buddy->name, group->name);
+ "ssi: deleting buddy %s from group %s\n", bname, gname);
+ aim_ssi_delbuddy(od, bname, gname);
}
}
void oscar_move_buddy(PurpleConnection *gc, const char *name, const char *old_group, const char *new_group) {
- OscarData *od = (OscarData *)gc->proto_data;
+ OscarData *od = purple_connection_get_protocol_data(gc);
+
if (od->ssi.received_data && strcmp(old_group, new_group)) {
purple_debug_info("oscar",
"ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group);
@@ -4958,7 +4959,8 @@ void oscar_move_buddy(PurpleConnection *gc, const char *name, const char *old_gr
}
void oscar_alias_buddy(PurpleConnection *gc, const char *name, const char *alias) {
- OscarData *od = (OscarData *)gc->proto_data;
+ OscarData *od = purple_connection_get_protocol_data(gc);
+
if (od->ssi.received_data) {
char *gname = aim_ssi_itemlist_findparentname(od->ssi.local, name);
if (gname) {
@@ -4973,10 +4975,11 @@ void oscar_alias_buddy(PurpleConnection *gc, const char *name, const char *alias
* FYI, the OSCAR SSI code removes empty groups automatically.
*/
void oscar_rename_group(PurpleConnection *gc, const char *old_name, PurpleGroup *group, GList *moved_buddies) {
- OscarData *od = (OscarData *)gc->proto_data;
+ OscarData *od = purple_connection_get_protocol_data(gc);
if (od->ssi.received_data) {
- if (aim_ssi_itemlist_finditem(od->ssi.local, group->name, NULL, AIM_SSI_TYPE_GROUP)) {
+ const char *gname = purple_group_get_name(group);
+ if (aim_ssi_itemlist_finditem(od->ssi.local, gname, NULL, AIM_SSI_TYPE_GROUP)) {
GList *cur, *groups = NULL;
PurpleAccount *account = purple_connection_get_account(gc);
@@ -4986,25 +4989,25 @@ void oscar_rename_group(PurpleConnection *gc, const char *old_name, PurpleGroup
/* node is PurpleBuddy, parent is a PurpleContact.
* We must go two levels up to get the Group */
groups = g_list_append(groups,
- node->parent->parent);
+ purple_buddy_get_group((PurpleBuddy*)node));
}
purple_account_remove_buddies(account, moved_buddies, groups);
purple_account_add_buddies(account, moved_buddies);
g_list_free(groups);
purple_debug_info("oscar",
- "ssi: moved all buddies from group %s to %s\n", old_name, group->name);
+ "ssi: moved all buddies from group %s to %s\n", old_name, gname);
} else {
- aim_ssi_rename_group(od, old_name, group->name);
+ aim_ssi_rename_group(od, old_name, gname);
purple_debug_info("oscar",
- "ssi: renamed group %s to %s\n", old_name, group->name);
+ "ssi: renamed group %s to %s\n", old_name, gname);
}
}
}
void oscar_remove_group(PurpleConnection *gc, PurpleGroup *group)
{
- aim_ssi_delgroup(gc->proto_data, group->name);
+ aim_ssi_delgroup(purple_connection_get_protocol_data(gc), purple_group_get_name(group));
}
static gboolean purple_ssi_rerequestdata(gpointer data) {
@@ -5035,7 +5038,7 @@ static int purple_ssi_parseerr(OscarData *od, FlapConnection *conn, FlapFrame *f
return 1;
}
- oscar_set_extendedstatus(gc);
+ oscar_set_status_icq(purple_connection_get_account(gc));
return 1;
}
@@ -5085,7 +5088,7 @@ static int purple_ssi_parselist(OscarData *od, FlapConnection *conn, FlapFrame *
guint32 timestamp;
gc = od->gc;
- od = gc->proto_data;
+ od = purple_connection_get_protocol_data(gc);
account = purple_connection_get_account(gc);
va_start(ap, fr);
@@ -5113,33 +5116,44 @@ static int purple_ssi_parselist(OscarData *od, FlapConnection *conn, FlapFrame *
/* Buddies */
cur = NULL;
if ((blist = purple_get_blist()) != NULL) {
- for (gnode = blist->root; gnode; gnode = gnode->next) {
+ for (gnode = purple_blist_get_root(); gnode;
+ gnode = purple_blist_node_get_sibling_next(gnode)) {
+ const char *gname;
if(!PURPLE_BLIST_NODE_IS_GROUP(gnode))
continue;
g = (PurpleGroup *)gnode;
- for (cnode = gnode->child; cnode; cnode = cnode->next) {
+ gname = purple_group_get_name(g);
+ for (cnode = purple_blist_node_get_first_child(gnode);
+ cnode;
+ cnode = purple_blist_node_get_sibling_next(cnode)) {
if(!PURPLE_BLIST_NODE_IS_CONTACT(cnode))
continue;
- for (bnode = cnode->child; bnode; bnode = bnode->next) {
+ for (bnode = purple_blist_node_get_first_child(cnode);
+ bnode;
+ bnode = purple_blist_node_get_sibling_next(bnode)) {
+ const char *bname;
if(!PURPLE_BLIST_NODE_IS_BUDDY(bnode))
continue;
b = (PurpleBuddy *)bnode;
- if (b->account == gc->account) {
- if (aim_ssi_itemlist_exists(od->ssi.local, b->name)) {
+ bname = purple_buddy_get_name(b);
+ if (purple_buddy_get_account(b) == account) {
+ if (aim_ssi_itemlist_exists(od->ssi.local, bname)) {
/* If the buddy is an ICQ user then load his nickname */
const char *servernick = purple_blist_node_get_string((PurpleBlistNode*)b, "servernick");
char *alias;
+ const char *balias;
if (servernick)
- serv_got_alias(gc, b->name, servernick);
+ serv_got_alias(gc, bname, servernick);
/* Store local alias on server */
- alias = aim_ssi_getalias(od->ssi.local, g->name, b->name);
- if (!alias && b->alias && strlen(b->alias))
- aim_ssi_aliasbuddy(od, g->name, b->name, b->alias);
+ alias = aim_ssi_getalias(od->ssi.local, gname, bname);
+ balias = purple_buddy_get_local_buddy_alias(b);
+ if (!alias && balias && *balias)
+ aim_ssi_aliasbuddy(od, gname, bname, balias);
g_free(alias);
} else {
purple_debug_info("oscar",
- "ssi: removing buddy %s from local list\n", b->name);
+ "ssi: removing buddy %s from local list\n", bname);
/* We can't actually remove now because it will screw up our looping */
cur = g_slist_prepend(cur, b);
}
@@ -5156,8 +5170,8 @@ static int purple_ssi_parselist(OscarData *od, FlapConnection *conn, FlapFrame *
}
/* Permit list */
- if (gc->account->permit) {
- next = gc->account->permit;
+ if (account->permit) {
+ next = account->permit;
while (next != NULL) {
cur = next;
next = next->next;
@@ -5170,8 +5184,8 @@ static int purple_ssi_parselist(OscarData *od, FlapConnection *conn, FlapFrame *
}
/* Deny list */
- if (gc->account->deny) {
- next = gc->account->deny;
+ if (account->deny) {
+ next = account->deny;
while (next != NULL) {
cur = next;
next = next->next;
@@ -5215,7 +5229,7 @@ static int purple_ssi_parselist(OscarData *od, FlapConnection *conn, FlapFrame *
if (g_utf8_validate(gname, -1, NULL))
gname_utf8 = g_strdup(gname);
else
- gname_utf8 = oscar_utf8_try_convert(gc->account, gname);
+ gname_utf8 = oscar_utf8_try_convert(account, gname);
} else
gname_utf8 = NULL;
@@ -5235,18 +5249,18 @@ static int purple_ssi_parselist(OscarData *od, FlapConnection *conn, FlapFrame *
} else
alias_utf8 = NULL;
- b = purple_find_buddy_in_group(gc->account, curitem->name, g);
+ b = purple_find_buddy_in_group(account, curitem->name, g);
if (b) {
/* Get server stored alias */
purple_blist_alias_buddy(b, alias_utf8);
} else {
- b = purple_buddy_new(gc->account, curitem->name, alias_utf8);
+ b = purple_buddy_new(account, curitem->name, alias_utf8);
purple_debug_info("oscar",
- "ssi: adding buddy %s to group %s to local list\n", curitem->name, g->name);
+ "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname);
purple_blist_add_buddy(b, NULL, g, NULL);
}
- if (!aim_sncmp(curitem->name, account->username)) {
+ if (!oscar_util_name_compare(curitem->name, purple_account_get_username(account))) {
char *comment = aim_ssi_getcomment(od->ssi.local, gname, curitem->name);
if (comment != NULL)
{
@@ -5256,7 +5270,7 @@ static int purple_ssi_parselist(OscarData *od, FlapConnection *conn, FlapFrame *
}
/* Mobile users should always be online */
- if (b->name[0] == '+') {
+ if (curitem->name[0] == '+') {
purple_prpl_got_user_status(account,
purple_buddy_get_name(b),
OSCAR_STATUS_ID_AVAILABLE, NULL);
@@ -5279,7 +5293,7 @@ static int purple_ssi_parselist(OscarData *od, FlapConnection *conn, FlapFrame *
if (g_utf8_validate(gname, -1, NULL))
gname_utf8 = g_strdup(gname);
else
- gname_utf8 = oscar_utf8_try_convert(gc->account, gname);
+ gname_utf8 = oscar_utf8_try_convert(account, gname);
} else
gname_utf8 = NULL;
@@ -5294,7 +5308,7 @@ static int purple_ssi_parselist(OscarData *od, FlapConnection *conn, FlapFrame *
if (curitem->name) {
/* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */
GSList *list;
- for (list=account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next);
+ for (list=account->permit; (list && oscar_util_name_compare(curitem->name, list->data)); list=list->next);
if (!list) {
purple_debug_info("oscar",
"ssi: adding permit buddy %s to local list\n", curitem->name);
@@ -5306,7 +5320,7 @@ static int purple_ssi_parselist(OscarData *od, FlapConnection *conn, FlapFrame *
case 0x0003: { /* Deny buddy */
if (curitem->name) {
GSList *list;
- for (list=account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next);
+ for (list=account->deny; (list && oscar_util_name_compare(curitem->name, list->data)); list=list->next);
if (!list) {
purple_debug_info("oscar",
"ssi: adding deny buddy %s to local list\n", curitem->name);
@@ -5316,15 +5330,19 @@ static int purple_ssi_parselist(OscarData *od, FlapConnection *conn, FlapFrame *
} break;
case 0x0004: { /* Permit/deny setting */
- if (curitem->data) {
- guint8 permdeny;
- if ((permdeny = aim_ssi_getpermdeny(od->ssi.local)) && (permdeny != account->perm_deny)) {
+ /*
+ * We don't inherit the permit/deny setting from the server
+ * for ICQ because, for ICQ, this setting controls who can
+ * see your online status when you are invisible. Thus it is
+ * a part of your status and not really related to blocking.
+ */
+ if (!od->icq && curitem->data) {
+ guint8 perm_deny = aim_ssi_getpermdeny(od->ssi.local);
+ if (perm_deny != 0 && perm_deny != account->perm_deny)
+ {
purple_debug_info("oscar",
- "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny);
- account->perm_deny = permdeny;
- if (od->icq && account->perm_deny == PURPLE_PRIVACY_ALLOW_USERS) {
- purple_presence_set_status_active(account->presence, OSCAR_STATUS_ID_INVISIBLE, TRUE);
- }
+ "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, perm_deny);
+ account->perm_deny = perm_deny;
}
}
} break;
@@ -5335,7 +5353,7 @@ static int purple_ssi_parselist(OscarData *od, FlapConnection *conn, FlapFrame *
} /* End of switch on curitem->type */
} /* End of for loop */
- oscar_set_extendedstatus(gc);
+ oscar_set_status_icq(account);
/* Activate SSI */
/* Sending the enable causes other people to be able to see you, and you to see them */
@@ -5469,13 +5487,11 @@ purple_ssi_parseaddmod(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
purple_blist_add_buddy(b, NULL, g, NULL);
/* Mobile users should always be online */
- if (b->name[0] == '+') {
+ if (name[0] == '+') {
purple_prpl_got_user_status(account,
- purple_buddy_get_name(b),
- OSCAR_STATUS_ID_AVAILABLE, NULL);
+ name, OSCAR_STATUS_ID_AVAILABLE, NULL);
purple_prpl_got_user_status(account,
- purple_buddy_get_name(b),
- OSCAR_STATUS_ID_MOBILE, NULL);
+ name, OSCAR_STATUS_ID_MOBILE, NULL);
}
}
@@ -5498,36 +5514,36 @@ purple_ssi_parseaddmod(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
static int purple_ssi_authgiven(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
PurpleConnection *gc = od->gc;
va_list ap;
- char *sn, *msg;
+ char *bn, *msg;
gchar *dialog_msg, *nombre;
struct name_data *data;
PurpleBuddy *buddy;
va_start(ap, fr);
- sn = va_arg(ap, char *);
+ bn = va_arg(ap, char *);
msg = va_arg(ap, char *);
va_end(ap);
purple_debug_info("oscar",
- "ssi: %s has given you permission to add him to your buddy list\n", sn);
+ "ssi: %s has given you permission to add him to your buddy list\n", bn);
- buddy = purple_find_buddy(gc->account, sn);
+ buddy = purple_find_buddy(purple_connection_get_account(gc), bn);
if (buddy && (purple_buddy_get_alias_only(buddy)))
- nombre = g_strdup_printf("%s (%s)", sn, purple_buddy_get_alias_only(buddy));
+ nombre = g_strdup_printf("%s (%s)", bn, purple_buddy_get_alias_only(buddy));
else
- nombre = g_strdup(sn);
+ nombre = g_strdup(bn);
dialog_msg = g_strdup_printf(_("The user %s has given you permission to add him or her to your buddy list. Do you want to add this user?"), nombre);
g_free(nombre);
data = g_new(struct name_data, 1);
data->gc = gc;
- data->name = g_strdup(sn);
+ data->name = g_strdup(bn);
data->nick = (buddy ? g_strdup(purple_buddy_get_alias_only(buddy)) : NULL);
purple_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg,
PURPLE_DEFAULT_ACTION_NONE,
- purple_connection_get_acco