propagate from branch 'im.pidgin.pidgin' (head 77d17906f1c30148a4fe40231aa31cce3990820a) cpw.masca.webkit

Sat, 06 Aug 2011 03:45:56 +0000

author
Jorge Villaseñor <masca@cpw.pidgin.im>
date
Sat, 06 Aug 2011 03:45:56 +0000
branch
cpw.masca.webkit
changeset 32503
ab886d3a38ae
parent 32502
e64e49502c79 (current diff)
parent 31944
77d17906f1c3 (diff)
child 32504
8243b910ed4c

propagate from branch 'im.pidgin.pidgin' (head 77d17906f1c30148a4fe40231aa31cce3990820a)
to branch 'im.pidgin.cpw.masca.webkit' (head e64e49502c79c4b1ead4bb0d36aa0d939ea1819c)

configure.ac file | annotate | diff | comparison | revisions
libpurple/protocols/jabber/google.c file | annotate | diff | comparison | revisions
libpurple/protocols/jabber/google.h file | annotate | diff | comparison | revisions
libpurple/protocols/msn/README file | annotate | diff | comparison | revisions
libpurple/protocols/msn/dialog.c file | annotate | diff | comparison | revisions
libpurple/protocols/msn/dialog.h file | annotate | diff | comparison | revisions
libpurple/protocols/msn/sync.c file | annotate | diff | comparison | revisions
libpurple/protocols/msn/sync.h file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/Makefile.am file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/Makefile.mingw file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/cmdproc.c file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/cmdproc.h file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/command.c file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/command.h file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/dialog.c file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/dialog.h file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/directconn.c file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/directconn.h file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/error.c file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/error.h file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/group.c file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/group.h file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/history.c file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/history.h file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/httpconn.c file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/httpconn.h file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/msg.c file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/msg.h file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/msn-utils.c file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/msn-utils.h file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/msn.c file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/msn.h file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/nexus.c file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/nexus.h file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/notification.c file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/notification.h file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/object.c file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/object.h file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/page.c file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/page.h file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/servconn.c file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/servconn.h file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/session.c file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/session.h file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/slp.c file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/slp.h file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/slpcall.c file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/slpcall.h file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/slplink.c file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/slplink.h file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/slpmsg.c file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/slpmsg.h file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/slpsession.c file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/slpsession.h file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/state.c file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/state.h file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/switchboard.c file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/switchboard.h file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/sync.c file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/sync.h file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/table.c file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/table.h file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/transaction.c file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/transaction.h file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/user.c file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/user.h file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/userlist.c file | annotate | diff | comparison | revisions
libpurple/protocols/msnp9/userlist.h file | annotate | diff | comparison | revisions
libpurple/protocols/oscar/family_advert.c file | annotate | diff | comparison | revisions
libpurple/protocols/oscar/family_invite.c file | annotate | diff | comparison | revisions
libpurple/protocols/oscar/family_odir.c file | annotate | diff | comparison | revisions
libpurple/protocols/oscar/family_translate.c file | annotate | diff | comparison | revisions
libpurple/protocols/qq/AUTHORS file | annotate | diff | comparison | revisions
libpurple/protocols/qq/ChangeLog file | annotate | diff | comparison | revisions
libpurple/protocols/qq/Makefile.am file | annotate | diff | comparison | revisions
libpurple/protocols/qq/Makefile.mingw file | annotate | diff | comparison | revisions
libpurple/protocols/qq/buddy_info.c file | annotate | diff | comparison | revisions
libpurple/protocols/qq/buddy_info.h file | annotate | diff | comparison | revisions
libpurple/protocols/qq/buddy_list.c file | annotate | diff | comparison | revisions
libpurple/protocols/qq/buddy_list.h file | annotate | diff | comparison | revisions
libpurple/protocols/qq/buddy_memo.c file | annotate | diff | comparison | revisions
libpurple/protocols/qq/buddy_memo.h file | annotate | diff | comparison | revisions
libpurple/protocols/qq/buddy_opt.c file | annotate | diff | comparison | revisions
libpurple/protocols/qq/buddy_opt.h file | annotate | diff | comparison | revisions
libpurple/protocols/qq/char_conv.c file | annotate | diff | comparison | revisions
libpurple/protocols/qq/char_conv.h file | annotate | diff | comparison | revisions
libpurple/protocols/qq/file_trans.c file | annotate | diff | comparison | revisions
libpurple/protocols/qq/file_trans.h file | annotate | diff | comparison | revisions
libpurple/protocols/qq/group.c file | annotate | diff | comparison | revisions
libpurple/protocols/qq/group.h file | annotate | diff | comparison | revisions
libpurple/protocols/qq/group_im.c file | annotate | diff | comparison | revisions
libpurple/protocols/qq/group_im.h file | annotate | diff | comparison | revisions
libpurple/protocols/qq/group_info.c file | annotate | diff | comparison | revisions
libpurple/protocols/qq/group_info.h file | annotate | diff | comparison | revisions
libpurple/protocols/qq/group_internal.c file | annotate | diff | comparison | revisions
libpurple/protocols/qq/group_internal.h file | annotate | diff | comparison | revisions
libpurple/protocols/qq/group_join.c file | annotate | diff | comparison | revisions
libpurple/protocols/qq/group_join.h file | annotate | diff | comparison | revisions
libpurple/protocols/qq/group_opt.c file | annotate | diff | comparison | revisions
libpurple/protocols/qq/group_opt.h file | annotate | diff | comparison | revisions
libpurple/protocols/qq/im.c file | annotate | diff | comparison | revisions
libpurple/protocols/qq/im.h file | annotate | diff | comparison | revisions
libpurple/protocols/qq/packet_parse.c file | annotate | diff | comparison | revisions
libpurple/protocols/qq/packet_parse.h file | annotate | diff | comparison | revisions
libpurple/protocols/qq/qq.c file | annotate | diff | comparison | revisions
libpurple/protocols/qq/qq.h file | annotate | diff | comparison | revisions
libpurple/protocols/qq/qq_base.c file | annotate | diff | comparison | revisions
libpurple/protocols/qq/qq_base.h file | annotate | diff | comparison | revisions
libpurple/protocols/qq/qq_crypt.c file | annotate | diff | comparison | revisions
libpurple/protocols/qq/qq_crypt.h file | annotate | diff | comparison | revisions
libpurple/protocols/qq/qq_define.c file | annotate | diff | comparison | revisions
libpurple/protocols/qq/qq_define.h file | annotate | diff | comparison | revisions
libpurple/protocols/qq/qq_network.c file | annotate | diff | comparison | revisions
libpurple/protocols/qq/qq_network.h file | annotate | diff | comparison | revisions
libpurple/protocols/qq/qq_process.c file | annotate | diff | comparison | revisions
libpurple/protocols/qq/qq_process.h file | annotate | diff | comparison | revisions
libpurple/protocols/qq/qq_trans.c file | annotate | diff | comparison | revisions
libpurple/protocols/qq/qq_trans.h file | annotate | diff | comparison | revisions
libpurple/protocols/qq/send_file.c file | annotate | diff | comparison | revisions
libpurple/protocols/qq/send_file.h file | annotate | diff | comparison | revisions
libpurple/protocols/qq/utils.c file | annotate | diff | comparison | revisions
libpurple/protocols/qq/utils.h file | annotate | diff | comparison | revisions
libpurple/tests/test_qq.c file | annotate | diff | comparison | revisions
pidgin/Makefile.am file | annotate | diff | comparison | revisions
pidgin/eggtrayicon.c file | annotate | diff | comparison | revisions
pidgin/eggtrayicon.h file | annotate | diff | comparison | revisions
pidgin/gtkcelllayout.c file | annotate | diff | comparison | revisions
pidgin/gtkcelllayout.h file | annotate | diff | comparison | revisions
pidgin/gtkcellrendererprogress.c file | annotate | diff | comparison | revisions
pidgin/gtkcellrendererprogress.h file | annotate | diff | comparison | revisions
pidgin/gtkcellview.c file | annotate | diff | comparison | revisions
pidgin/gtkcellview.h file | annotate | diff | comparison | revisions
pidgin/gtkcellviewmenuitem.c file | annotate | diff | comparison | revisions
pidgin/gtkcellviewmenuitem.h file | annotate | diff | comparison | revisions
pidgin/gtkconv.c file | annotate | diff | comparison | revisions
pidgin/gtkconv.h file | annotate | diff | comparison | revisions
pidgin/gtkdialogs.c file | annotate | diff | comparison | revisions
pidgin/gtkdocklet-x11.c file | annotate | diff | comparison | revisions
pidgin/gtkexpander.c file | annotate | diff | comparison | revisions
pidgin/gtkexpander.h file | annotate | diff | comparison | revisions
pidgin/gtklog.c file | annotate | diff | comparison | revisions
pidgin/gtknotify.c file | annotate | diff | comparison | revisions
pidgin/gtkthemes.c file | annotate | diff | comparison | revisions
pidgin/pidgincombobox.c file | annotate | diff | comparison | revisions
pidgin/pidgincombobox.h file | annotate | diff | comparison | revisions
pidgin/pixmaps/emblems/16/mobile.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emblems/16/music.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emblems/16/qq-member.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emblems/scalable/mobile.svg file | annotate | diff | comparison | revisions
pidgin/pixmaps/emblems/scalable/music.svg file | annotate | diff | comparison | revisions
pidgin/pixmaps/emblems/scalable/qq-member.svg file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/default/24/afraid.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/default/24/amorous.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/default/24/eat.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/default/24/excited.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/default/24/happy.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/default/24/hot.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/default/24/hungry.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/default/24/in-love.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/default/24/in_love.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/default/24/love.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/default/24/nailbiting.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/default/24/nervous.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/default/24/qq.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/default/24/scalable/qq.svg file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/default/24/shock.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/default/24/shocked.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/default/24/sleeping.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/default/24/sleepy.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/default/24/smile-big.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/default/24/smile.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/default/24/sweat.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/default/24/tremble.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/default/24/yawn.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/small/16/cool.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/small/16/excited.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/small/16/grin.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/small/16/happy.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/small/16/in_love.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/small/16/love.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/small/16/mobile.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/small/16/music.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/small/16/scalable/mobile.svg file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/small/16/scalable/music.svg file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/small/16/shock.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/small/16/shocked.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/small/16/sleeping.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/small/16/sleepy.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/small/16/smile-big.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/small/16/smile.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/emotes/small/16/yawn.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/protocols/16/qq.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/protocols/16/scalable/qq.svg file | annotate | diff | comparison | revisions
pidgin/pixmaps/protocols/22/qq.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/protocols/22/scalable/qq.svg file | annotate | diff | comparison | revisions
pidgin/pixmaps/protocols/48/qq.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/protocols/scalable/qq.svg file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/16/tray-away.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/16/tray-busy.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/16/tray-connecting.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/16/tray-extended-away.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/16/tray-invisible.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/16/tray-message.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/16/tray-new-im.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/16/tray-offline.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/16/tray-online.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/22/tray-away.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/22/tray-busy.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/22/tray-connecting.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/22/tray-extended-away.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/22/tray-invisible.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/22/tray-message.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/22/tray-new-im.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/22/tray-offline.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/22/tray-online.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/32/tray-away.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/32/tray-busy.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/32/tray-connecting.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/32/tray-extended-away.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/32/tray-invisible.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/32/tray-message.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/32/tray-new-im.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/32/tray-offline.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/32/tray-online.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/48/tray-away.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/48/tray-busy.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/48/tray-connecting.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/48/tray-extended-away.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/48/tray-invisible.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/48/tray-message.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/48/tray-new-im.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/48/tray-offline.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/48/tray-online.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/16x16/status/pidgin-tray-available.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/16x16/status/pidgin-tray-away.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/16x16/status/pidgin-tray-busy.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/16x16/status/pidgin-tray-connect.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/16x16/status/pidgin-tray-email.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/16x16/status/pidgin-tray-invisible.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/16x16/status/pidgin-tray-offline.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/16x16/status/pidgin-tray-pending.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/16x16/status/pidgin-tray-xa.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/22x22/status/pidgin-tray-available.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/22x22/status/pidgin-tray-away.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/22x22/status/pidgin-tray-busy.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/22x22/status/pidgin-tray-connect.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/22x22/status/pidgin-tray-email.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/22x22/status/pidgin-tray-invisible.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/22x22/status/pidgin-tray-offline.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/22x22/status/pidgin-tray-pending.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/22x22/status/pidgin-tray-xa.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/32x32/status/pidgin-tray-available.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/32x32/status/pidgin-tray-away.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/32x32/status/pidgin-tray-busy.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/32x32/status/pidgin-tray-connect.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/32x32/status/pidgin-tray-email.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/32x32/status/pidgin-tray-invisible.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/32x32/status/pidgin-tray-offline.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/32x32/status/pidgin-tray-pending.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/32x32/status/pidgin-tray-xa.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/48x48/status/pidgin-tray-available.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/48x48/status/pidgin-tray-away.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/48x48/status/pidgin-tray-busy.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/48x48/status/pidgin-tray-connect.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/48x48/status/pidgin-tray-email.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/48x48/status/pidgin-tray-invisible.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/48x48/status/pidgin-tray-offline.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/48x48/status/pidgin-tray-pending.png file | annotate | diff | comparison | revisions
pidgin/pixmaps/tray/hicolor/48x48/status/pidgin-tray-xa.png file | annotate | diff | comparison | revisions
pidgin/win32/IdleTracker/Makefile.mingw file | annotate | diff | comparison | revisions
pidgin/win32/IdleTracker/idletrack.c file | annotate | diff | comparison | revisions
pidgin/win32/IdleTracker/idletrack.h file | annotate | diff | comparison | revisions
pidgin/win32/nsis/langmacros.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/afrikaans.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/albanian.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/arabic.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/basque.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/bulgarian.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/catalan.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/czech.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/danish.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/dutch.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/english.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/finnish.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/french.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/galician.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/german.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/hebrew.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/hungarian.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/italian.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/japanese.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/korean.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/kurdish.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/lithuanian.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/norwegian.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/norwegian_nynorsk.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/persian.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/polish.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/portuguese-br.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/portuguese.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/romanian.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/russian.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/serbian-latin.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/simp-chinese.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/slovak.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/slovenian.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/spanish.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/swedish.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/trad-chinese.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/valencian.nsh file | annotate | diff | comparison | revisions
pidgin/win32/nsis/translations/vietnamese.nsh file | annotate | diff | comparison | revisions
--- a/.mtn-ignore	Thu Jun 16 04:37:03 2011 +0000
+++ b/.mtn-ignore	Sat Aug 06 03:45:56 2011 +0000
@@ -1,8 +1,8 @@
+(.*/)?TAGS$
 (.*/)?\.svn
+.*/?.*\.pc$
 .*/?Makefile(\.in)?$
 .*/?Makefile\.am\.mingw$
-(.*/)?TAGS$
-.*/?.*\.pc$
 .*/perl/common/[^/]+\.c$
 .*/perl/common/blib.*
 .*/perl/common/pm_to_blib$
@@ -11,8 +11,9 @@
 .*\.dll$
 .*\.exe$
 .*\.loT$
-intltool-.*
 Doxyfile(\.mingw)?$
+VERSION$
+\.tx
 aclocal.m4
 autogen.args
 compile
@@ -24,31 +25,15 @@
 config.status
 config.sub
 configure$
+depcomp
+doc/finch.1$
+doc/html
+doc/pidgin.1$
 finch/finch$
 finch/libgnt/gntmarshal.c
 finch/libgnt/gntmarshal.h
-depcomp
-doc/finch.1$
-doc/pidgin.1$
-doc/html
-package_revision.h
-package_revision_raw.txt
-pidgin.apspec$
-pidgin.desktop$
-pidgin.spec$
-pidgin-.*.tar.gz
-pidgin-.*.tar.bz2
-pidgin-*.*.*-win32bin$
-pidgin/pidgin$
-pidgin/pixmaps/emotes/default/24/theme
-pidgin/pixmaps/emotes/none/theme
-pidgin/pixmaps/emotes/small/16/theme
-pidgin/plugins/musicmessaging/music-messaging-bindings.c
-pidgin/plugins/perl/common/Makefile.PL$
-pidgin/plugins/perl/common/Makefile.old
-pidgin/win32/pidgin_dll_rc.rc$
-pidgin/win32/pidgin_exe_rc.rc$
 install-sh
+intltool-.*
 libpurple/dbus-bindings.c
 libpurple/dbus-signals.c
 libpurple/dbus-types.c
@@ -62,10 +47,10 @@
 libpurple/plugins/perl/common/const-c.inc
 libpurple/plugins/perl/common/const-xs.inc
 libpurple/plugins/perl/common/lib
-libpurple/purple.h$
 libpurple/purple-client-bindings.c
 libpurple/purple-client-bindings.h
 libpurple/purple-client-example
+libpurple/purple.h$
 libpurple/tests/check_libpurple
 libpurple/tests/libpurple..
 libpurple/version.h$
@@ -75,6 +60,34 @@
 ltmain.sh
 missing
 mkinstalldirs
+package_revision.h
+package_revision_raw.txt
+pidgin-*.*.*-dbgsym$
+pidgin-*.*.*-dbgsym.zip$
+pidgin-*.*.*-win32-bin.zip$
+pidgin-*.*.*-win32bin$
+pidgin-.*.tar.bz2
+pidgin-.*.tar.gz
+pidgin.apspec$
+pidgin.desktop$
+pidgin.spec$
+pidgin/pidgin$
+pidgin/pixmaps/emotes/default/24/theme
+pidgin/pixmaps/emotes/none/theme
+pidgin/pixmaps/emotes/small/16/theme
+pidgin/plugins/musicmessaging/music-messaging-bindings.c
+pidgin/plugins/perl/common/Makefile.PL$
+pidgin/plugins/perl/common/Makefile.old
+pidgin/win32/nsis/gtk-runtime-*.*.*.*.zip
+pidgin/win32/nsis/gtk_runtime_stage$
+pidgin/win32/nsis/langmacros.nsh
+pidgin/win32/nsis/nsis_translations.desktop
+pidgin/win32/nsis/pidgin-spellcheck-preselect.nsh
+pidgin/win32/nsis/pidgin-spellcheck.nsh
+pidgin/win32/nsis/pidgin-translations.nsh$
+pidgin/win32/nsis/translations
+pidgin/win32/pidgin_dll_rc.rc$
+pidgin/win32/pidgin_exe_rc.rc$
 po/Makefile.in.in
 po/POTFILES$
 po/missing
@@ -83,4 +96,3 @@
 po/stamp-it
 stamp-h1
 win32-install-dir(\.release)?
-VERSION$
--- a/AUTHORS	Thu Jun 16 04:37:03 2011 +0000
+++ b/AUTHORS	Sat Aug 06 03:45:56 2011 +0000
@@ -12,54 +12,58 @@
 Paul 'darkrain42' Aurich - Developer
 John 'rekkanoryo' Bailey - Developer
 Ethan 'Paco-Paco' Blanton - Developer
-Thomas Butter - Developer
-Ka-Hing Cheung - Developer
 Sadrul Habib Chowdhury - Developer
 Mark 'KingAnt' Doliner - Developer
-Sean Egan - Developer
 Casey Harkins - Developer
+Ivan Komarov - Developer
 Gary 'grim' Kramlich - Developer
 Richard 'rlaager' Laager - Developer
+Marcus 'malu' Lundblad - Developer
 Sulabh 'sulabh_m' Mahajan - Developer
 Richard 'wabz' Nelson - Developer
-Christopher 'siege' O'Brien - Developer
-Bartosz Oler - Developer
 Etan 'deryni' Reisner - Developer
-Tim 'marv' Ringenbach - Developer
 Michael 'Maiku' Ruprecht - Developer, voice and video
 Elliott 'QuLogic' Sales de Andrade - Developer
 Luke 'LSchiere' Schierer - Support
-Megan 'Cae' Schneider - support/QA
 Evan Schoenberg - Developer
 Kevin 'SimGuy' Stange - Developer & Webmaster
 Will 'resiak' Thompson - Developer
 Stu 'nosnilmot' Tomlinson - Developer
-Nathan 'faceprint' Walp - Developer
+Jorge 'Masca' Villaseñor - Developer
 
 Crazy Patch Writers:
 -------------------
-Marcus 'malu' Lundblad
-Dennis 'EvilDennisR' Ristuccia
+Jakub 'haakon' Adam
+Krzysztof Klinikowski
 Peter 'Fmoo' Ruibal
 Gabriel 'Nix' Schulhof
-Jorge 'Masca' Villaseñor
+Tomasz Wasilczyk
 
 Retired Developers:
 ------------------
 Herman Bloggs - Win32 Port
+Thomas Butter - Developer
+Ka-Hing Cheung - Developer
 Jim Duchek <jim@linuxpimps.com> - maintainer
+Sean Egan - Developer
 Rob Flynn <gaim@robflynn.com> - maintainer
 Adam Fritzler - libfaim maintainer
 Christian 'ChipX86' Hammond - Developer & Webmaster
 Syd Logan - hacker and designated driver [lazy bum]
+Christopher 'siege' O'Brien - Developer
+Bartosz Oler - Developer
+Tim 'marv' Ringenbach - Developer
+Megan 'Cae' Schneider - support/QA
 Jim Seymour - XMPP developer
 Mark Spencer <markster@marko.net> - original author
+Nathan 'faceprint' Walp - Developer
 Eric Warmenhoven <eric@warmenhoven.org> - lead developer
 
 Retired Crazy Patch Writers:
 ---------------------------
 Felipe 'shx' Contreras
 Decklin Foster
+Dennis 'EvilDennisR' Ristuccia - Senior Contributor/QA
 Peter 'Bleeter' Lawler
 Robert 'Robot101' McQueen
 Benjamin Miller
@@ -137,4 +141,4 @@
 Thanks to Jeroen van der Vegt for the initial smiley plugin and images.
 
 The OpenQ Team
-	Wrote the QQ plugin (see AUTHORS in the qq directory)
+	Wrote the QQ plugin dropped in 2.8.0 (see libpurple/qq/AUTHORS in 2.7.11)
--- a/COPYRIGHT	Thu Jun 16 04:37:03 2011 +0000
+++ b/COPYRIGHT	Sat Aug 06 03:45:56 2011 +0000
@@ -15,10 +15,12 @@
 piece of code, then that code should be traced through our version
 control system to see from where it came and who has modified it.
 
-Copyright (C) 1998-2009 by the following:
+Copyright (C) 1998-2011 by the following:
 
 Saleem Abdulrasool
+Jakub Adam
 Dave Ahlswede
+Thijs Alkemade
 Manuel Amador
 Matt Amato
 Josef Andrysek
@@ -46,9 +48,12 @@
 Stefan Becker
 Carlos Bederian
 Dave Bell
+Matthew W.S. Bell
 Igor Belyi
+David Benjamin
 Brian Bernas
 Paul Betts
+Runa Bhattacharjee
 Jonas Birmé
 George-Cristian Bîrzan
 Eric Blade
@@ -63,7 +68,10 @@
 Paolo Borelli
 Julien Bossart
 Craig Boston
+Éric Boumaour
 Chris Boyle
+Stanislav Brabec
+Quentin Brandon
 Derrick J Brashear
 Mauro Sérgio Ferreira Brasil
 Luke Bratch
@@ -73,14 +81,17 @@
 Jeffery Brown
 Philip Brown
 Dan Bruce
+Guillaume Brunerie
 Norbert Buchmuller
 Johannes Buchner
 Sean Burke
+Gabriel Burt
 Thomas Butter
 Trevor Caira
 Andrea Canciani
 Damien Carbery
 Michael Carlson
+Rodrigo Tobar Carrizo
 Keegan Carruthers-Smith
 Ludovico Cavedon
 Steve Cavilia
@@ -88,8 +99,10 @@
 Matěj Cepl
 Cerulean Studios, LLC
 Jonathan Champ
+Markos Chandras
 Matthew Chapman
 Christophe Chapuis
+Tirtha Chatterjee
 Patrick Cheung
 Ka-Hing Cheung
 Sadrul Habib Chowdhury
@@ -117,11 +130,14 @@
 Jeramey Crawford
 Michael Culbertson
 Steven Danna
+Simon Danner
 Chris Davies
 Josh Davis
 Martijn Dekker
 Florian Delizy
+Jiri Denemark
 Vinicius Depizzol
+Marc Dequènes
 Philip Derrin
 Taso N. Devetzis
 Balwinder Singh Dheeman
@@ -142,16 +158,20 @@
 Ignacio J. Elia
 Brian Enigma
 Mattias Eriksson
+Pat Erley
 Stefan Esser
 Steffen Eschenbacher
 Marc Etcheverry
 David Everly
 Larry Ewing
+Facebook, Inc.
+Fartash Faghri
 Gábor Farkas
 Jesse Farmer
 Gavan Fantom (gavan)
 Leonardo Fernandes
 David Fiander
+Ryan Flegel
 Rob Flynn <gaim@robflynn.com>
 Rob Foehl (rwf)
 Chris Foote
@@ -171,6 +191,7 @@
 Ignacy Gawedzki
 Georgi Georgiev
 Brian Geppert
+Emanuele Giaquinta
 Thomas Gibson-Robinson
 Ike Gingerich
 Gustavo Giráldez
@@ -212,6 +233,7 @@
 Andrew Hoffman
 Iain Holmes
 Joshua Honeycutt
+Jeffrey Honig
 Nigel Horne
 Jensen Hornick
 Juanjo Molinero Horno
@@ -227,6 +249,7 @@
 Instant Messaging Freedom, Inc.
 Vitaliy Ischenko
 Intel Corporation
+Andrew Ivanov
 Scott Jackson
 Hans Petter Jansson
 David Jedelsky
@@ -236,22 +259,26 @@
 Yuriy Kaminskiy
 Anders Kaseorg
 Praveen Karadakal
-Jaromír Karmazín
+Tomáš Kebert
 John Kelm
 Jochen Kemnade
 Yann Kerherve
 Gordian Klein
+Marten Klencke
 Krzysztof Klinikowski
 Akuke Kok
 Kir Kolyshkin
+Ivan Komarov
 F.W. Kong
 Konstantin Korikov
 Cole Kowalski
+Nikita Kozlov
 Matt Kramer
 Gary Kramlich
 Jan Kratochvil
 Andrej Krivulčík
 Patrik Kullman
+Sangeeta Kumari
 Tuomas Kuosmanen
 Tero Kuusela
 Richard Laager
@@ -261,6 +288,7 @@
 Joe LaPenna
 Steve Láposi
 Daniel Larsson
+Julia Lawall
 Peter Lawler
 Vadim Lebedev
 Ho-seok Lee
@@ -290,17 +318,21 @@
 Paolo Maggi
 Sulabh Mahajan
 Willian T. Mahan
+Jonathan Maltz
+Rok Mandeljc
 Tobias Markmann
 Kris Marsh
 Fidel Martinez
 Lalo Martins
 John Matthews
 Simo Mattila
+Robert Matusewicz
 Michal Matyska
 Ryan McCabe
 Peter McCurdy
 Kurt McKee
 Torrey McMahon
+Greg McNew
 Robert McQueen
 Mihály Mészáros
 Robert Mibus
@@ -310,6 +342,7 @@
 Paul Miller
 Arkadiusz Miskiewicz
 David Mohr
+Kartik Mohta
 Andrew Molloy
 Tomasz Mon
 Michael Monreal
@@ -319,9 +352,12 @@
 John Moody
 Tim Mooney
 Sergio Moretto
+Nader Morshed
+Keith Moyer
 Andrei Mozzhuhin
 Christian Muise
 MXit Lifestyle (Pty) Ltd.
+Alexander Nartov
 Richard Nelson
 Dennis Nezic
 Matthew A. Nicholson
@@ -339,6 +375,8 @@
 Gudmundur Bjarni Olafsson
 Bartosz Oler
 Oliver
+The openSUSE Project
+Jürgen Orschiedt
 Stefan Ott
 Shawn Outman
 Nathan Owens (pianocomp81)
@@ -350,14 +388,18 @@
 Riley Patterson
 Havoc Pennington
 Ted Percival
+Hugo Pereira Da Costa
 Eduardo Pérez
 Matt Perry
+Ani Peter
 Luke Petre
 Diego Petten
 Nathan Peterson
 Dmitry Petroff
 Sebastián E. Peyrott
+Amitakhya Phukan
 Andrea Piccinelli
+Mateusz Piękos
 Celso Pinto
 Joao Luís Marques Pinto
 Aleksander Piotrowski
@@ -366,8 +408,10 @@
 Eric Polino <aluink@gmail.com>
 Ari Pollak
 Stephen Pope
+Cristi Posoiu
 Nathan Poznick
 Jory A. Pratt
+David Preece
 Brent Priddy
 Justin Pryzby
 Florian Quèze
@@ -376,8 +420,13 @@
 Yosef Radchenko
 David Raeman
 R. Ramkumar
+Rajesh Ranjan
 Mart Raudsepp
 Etan Reisner
+David Reiss
+Luoh Ren-Shan
+Noa Resare
+Daniele Ricci
 Kristian Rietveld
 Pekka Riikonen
 Tim Ringenbach
@@ -389,6 +438,7 @@
 Luciano Miguel Ferreira Rocha
 Andrew Rodland
 Miguel Rodríguez (migrax)
+Adi Roiban
 Martin Rosinski
 Bob Rossi
 Jason Roth
@@ -462,6 +512,8 @@
 Marcus Sundberg
 Mårten Svantesson (fursten)
 Amir Szekely (kichik)
+Gábor Szuromi (kukkerman)
+Jakub Szypulka
 Robert T.
 Greg Taeger
 Rob Taft
@@ -491,9 +543,12 @@
 Kyle Turman
 Jon Turney
 Junichi Uekawa
+Max Ulidtko
+Dmitry Utkin
 Igor Vlasenko
 István Váradi
 Martijn van Beers
+Gideon van Melle
 Arjan van de Ven
 Philip Van Hoof
 Kristof Vansant
@@ -503,6 +558,8 @@
 Andrew Victor
 Jorge Villaseñor (Masca)
 Bjoern Voigt
+Peter Volkov
+Marius Wachtler
 Wan Hing Wah
 Philip Walford
 Nathan Walp
@@ -510,6 +567,7 @@
 Eric Warmenhoven
 Adam J. Warrington
 Denis Washington
+Tomasz Wasilczyk
 Zsombor Welker
 Andrew Wellington
 Adam Wendt
@@ -518,8 +576,10 @@
 Zac West
 Daniel Westermann-Clark
 Andrew Whewell
+Stephen Whitmore
 Simon Wilkinson
 Dan Willemsen
+Dan Williams
 Justin Williams (Jaywalker)
 Jason Willis
 Alex Willmer
@@ -534,9 +594,12 @@
 Justin Wood
 Ximian
 Ma Xuan
+Yonas Yanfa
 Jared Yanovich
 Timmy Yee
 Li Yuan
+Yuriy Yevgrafov
+Jan Zachorowski
 Nickolai Zeldovich
 Tom Zickel
 Marco Ziech
--- a/ChangeLog	Thu Jun 16 04:37:03 2011 +0000
+++ b/ChangeLog	Sat Aug 06 03:45:56 2011 +0000
@@ -1,25 +1,935 @@
 Pidgin and Finch: The Pimpin' Penguin IM Clients That're Good for the Soul
 
-version 2.6.6 (??/??/20??):
+version 2.9.1 (MM/DD/YYYY):
+	Pidgin:
+	* Make the max size of incoming smileys a pref instead of hardcoding it.
+	  (Quentin Brandon)(#5231)
+
+	Gadu-Gadu:
+	* Fixed searching for buddies in public directory. (Tomasz Wasilczyk)
+	  (#5242)
+	* Better status message handling. (Tomasz Wasilczyk) (#14314)
+	* Merged two buddy blocking methods. (Tomasz Wasilczyk) (#5303)
+
+	XMPP:
+	* Do not generate malformed XML ("</>") when setting an empty mood.
+	  (#14342)
+
+version 2.9.0 (06/23/2011):
+	Pidgin:
+	* Fix a potential remote denial-of-service bug related to displaying
+	  buddy icons.
+	* Significantly improved performance of larger IRC channels (regression
+	  introduced in 2.8.0).
+	* Fix Conversation->Add on AIM and MSN.
+	* Entries in the chat user list are sorted properly again.  This was
+	  inadvertenly broken in 2.8.0.
+
+	Finch:
+	* Fix logging in to ICQ.
+
+	libpurple:
+	* media: Actually use the specified TCP port from the TURN configuration to
+	  create a TCP relay candidate.
+
+	AIM and ICQ:
+	* Fix crashes on some non-mainstream OSes when attempting to
+	  printf("%s", NULL).  (Clemens Huebner) (#14297)
+
+	Plugins:
+	* The Evolution Integration plugin compiles again.
+
+version 2.8.0 (06/07/2011):
+	General:
+	* Implement simple silence suppression for voice calls, preventing
+	  wasted bandwidth for silent periods during a call. (Jakub Adam)
+	  (half of #13180)
+	* Added the DigiCert High Assurance CA-3 intermediate CA, needed for
+	  validation of the Facebook XMPP interface's certificate.
+	* Removed the QQ protocol plugin.  It hasn't worked in a long time and
+	  isn't being maintained, therefore we no longer want it.
+
+	Pidgin:
+	* Duplicate code cleanup.  (Gabriel Schulhof) (#10599)
+	* Voice/Video call window adapts correctly to adding or removing
+	  streams on the fly. (Jakub Adam) (half of #13535)
+	* Don't cancel an ongoing call when rejecting the addition of a
+	  stream to the existing call. (Jakub Adam) (#13537)
+	* Pidgin plugins can now override tab completion and detect clicks on
+	  usernames in the chat userlist. (kawaii.neko) (#12599)
+	* Fix the tooltip being destroyed when it is full of information and
+	  cover the mouse (dliang) (#10510)
+
+	libpurple:
+	* media: Allow obtaining active local and remote candidates. (Jakub
+	  Adam) (#11830)
+	* media: Allow getting/setting video capabilities. (Jakub Adam) (half
+	  of #13095)
+	* Simple Silence Suppression is optional per-account. (Jakub Adam)
+	  (half of #13180)
+	* Fix purple-url-handler being unable to find an account.
+	* media: Allow adding/removing streams on the fly. (Jakub Adam)
+	  (half of #13535)
+	* Support new connection states in NetworkManager 0.9. (Dan Williams)
+	  (#13505)
+	* When removing a buddy, delete the pounces associated with it.
+	  (Kartik Mohta) (#1131)
+	* media: Allow libpurple and plugins to set SDES properties for RTP
+	  conferences. (Jakub Adam) (#12981)
+	* proxy: Add new "Tor/Privacy" proxy type that can be used to
+	  restrict operations that could leak potentially sensitive data
+	  (e.g. DNS queries).  (#11110, #13928)
+	* media: Add support for using TCP relaying with TURN (will only work with
+	  libnice 0.1.0 and later).
+
+	AIM:
+	* Fix setting icons with dimensions greater than 64x64 pixels by scaling
+	  them down to at most 64x64. (#12874, #13165)
+
+	Gadu-Gadu:
+	* Allow showing your status only to buddies. (Mateusz Piękos) (#13358)
+	* Updated internal libgadu to version 1.10.1. (Robert Matusewicz,
+	  Krzysztof Klinikowski) (#13525)
+	* Updated internal libgadu to version 1.11.0. (Tomasz Wasilczyk)
+	  (#14248)
+	* Suppress blank messages that happen when receiving inline
+	  images. (Tomasz Wasilczyk) (#13554)
+	* Fix sending inline images to remote users, don't crash when
+	  trying to send large (> 256kB) images. (Tomasz Wasilczyk) (#13580)
+	* Support typing notifications. (Jan Zachorowski, Tomasz Wasilczyk,
+	  Krzysztof Klinikowski) (#13362, #13590)
+	* Require libgadu 1.11.0 to avoid using internal libgadu.
+	* Optional SSL connection support for GNUTLS users (not on Windows
+	  yet!). (Tomasz Wasilczyk) (#13613, #13894)
+	* Don't count received messages or statuses when determining whether
+	  to send a keepalive packet. (Jan Zachorowski) (#13699)
+	* Fix a crash when receiving images on Windows or an incorrect
+	  timestamp in the log when receiving images on Linux. (Tomasz
+	  Wasilczyk) (#10268)
+	* Support XML events, resulting in immediate update of other users'
+	  buddy icons. (Tomasz Wasilczyk) (#13739)
+	* Accept poorly formatted URLs from other third-party clients in
+	  the same manner as the official client.  (Tomasz Wasilczyk)
+	  (#13886)
+
+	ICQ:
+	* Fix setting icons with dimensions greater than 64x64 pixels by scaling
+	  them down to at most 64x64. (#12874, #13165)
+	* Fix unsetting your mood when "None" is selected.  (Dustin Gathmann)
+	  (#11895)
+	* Ignore Daylight Saving Time when performing calculations related to
+	  birthdays. (Dustin Gathmann) (#13533)
+	* It is now possible to specify multiple encodings on the Advanced
+	  tab of an ICQ account's settings by using a comma-delimited list.
+	  (Dmitry Utkin) (#13496)
+
+	IRC:
+	* Add "authserv" service command.  (tomos) (#13337)
+
+	MSN:
+	* Fix a hard-to-exploit crash in the MSN protocol when using the
+	  HTTP connection method (Reported by Marius Wachtler).
+
+	MXit:
+	* Support for an Invite Message when adding a buddy.
+	* Fixed bug in splitting-up of messages that contain a lot of links.
+	* Fixed crash caused by timer not being disabled on disconnect.
+	  (introduced in 2.7.11)
+	* Clearing of the conversation window now works.
+	* When receiving an invite you can display the sender's profile
+	  information, avatar image, invite message.
+	* The Change PIN option was moved into separate action.
+	* New profile attributes added and shown.
+	* Update to protocol v6.3.
+	* Added the ability to view and invite your Suggested Friends,
+	  and to search for contacts.
+	* Also display the Status Message of offline contacts in their
+	  profile information.
+
+	XMPP:
+	* Remember the previously entered user directory when searching.
+	  (Keith Moyer) (#12451)
+	* Correctly handle a buddy's unsetting his/her vCard-based avatar.
+	  (Matthew W.S. Bell) (#13370)
+	* Squash one more situation that resulted in duplicate entries in
+	  the roster (this one where the server reports the buddy as being
+	  in the same (empty) group.  (Reported by Danny Mayer)
+
+	Plugins:
+	* The Voice/Video Settings plugin now includes the ability to test
+	  microphone settings. (Jakub Adam) (#13182)
+	* Fix a crash when handling some saved settings in the Voice/Video
+	  Settings plugin. (Pat Erley) (13290, #13774)
+
+	Windows-Specific Changes:
+	* Fix building libpurple with Visual C++ .NET 2005. This was
+	  accidentally broken in 2.7.11. (Florian Quèze)
+	* Build internal libgadu using packed structs, fixing several
+	  long-standing Gadu-Gadu issues. (#11958, #6297)
+
+version 2.7.11 (03/10/2011):
+	General:
+	* Our bundled libgadu should now build on HP-UX.
+	* Fix some instances of file transfers never completing. (Cristi Posoiu)
+	  (#12472)
+
+	Pidgin:
+	* Sort by Status no longer causes buddies to move around when you
+	  click them.
+	* Fix embedding in the system tray on older GTK+ releases (such as on
+	  CentOS 5.5 and older Fedora).
+	* No longer require libstartup-notification for startup notification
+	  support.  GTK+ has included support for years, so use it instead. (David
+	  Benjamin) (#13245)
+
+	AIM:
+	* Fix a bug where some buddies from your buddy list might not show up.
+	  Affected non-English ICQ users the most. (#13386)
+	* Send keepalives for all types of network connections.  Will hopefully
+	  make chat rooms more reliable. (#1449)
+
+	MSN:
+	* Fix bug that prevented added buddies to your buddy list in certain
+	  circumstances.  (#13298)
+
+	MXit:
+	* MXit plugin and reported client version now follow the libpurple
+	  version.
+	* Don't try to request profile information for non-user contacts.
+	* Allow Re-Invite for contacts in Deleted or Rejected state.
+	* Ensure we don't send packets too fast to the MXit server and trigger
+	  its flood-detection mechanism.  Also increased the internal packet queue
+	  to 32 packets.
+
+	XMPP:
+	* Fix building on platforms with an older glib (inadvertantly broken in
+	  2.7.10).  (#13329)
+	* Don't treat the on-join status storms as 'new arrivals'.  (Thijs
+	  Alkemade) (#a14527)
+	* Extend the /join command to support room JIDs, enabling you to join
+	  a room on any server.  (Solarius, Matěj Cepl, Tirtha 'wyuka'
+	  Chatterjee) (#4526)
+	* Add support for receiving a limited amount of history when joining a
+	  room (not currently supported by Pidgin and Finch).  (Thijs Alkemade)
+	  (#10986, #a14219)
+
+	Yahoo!/Yahoo! JAPAN:
+	* Fix CVE-2011-1091, denials of service caused by NULL pointer
+	  dereferences due to improper handling of malformed YMSG packets.  Thanks
+	  to Marius Wachtler for reporting this and reviewing the fix!
+
+version 2.7.10 (02/06/2011):
+	General:
+	* Force video sources to all have the same capabilities.  This reduces the
+	  number of times video must be scaled down, saving CPU time. (Jakub Adam)
+	  (half of #13095)
+	* Starting multiple video calls and ending one no longer causes the other
+	  calls to stop sending audio and video. (Jakub Adam) (#12758, #13237)
+	* Perl bindings now respect LDFLAGS. (Peter Volkov, Markos Chandras)
+	  (#12638)
+	* Added AddTrust External Root CA.  (#11554)
+	* Resolve some issues validating X.509 certificates signed off the CAcert
+	  Class 3 intermediate cert when using the GnuTLS SSL/TLS plugin.
+
+	Gadu-Gadu:
+	* Don't drop whole messages when text is colored. (Jan Zachorowski)
+	  (#13259)
+
+	Groupwise:
+	* Don't show two windows when using "Get Info" on a buddy. (Gabriel Burt;
+	  Novell, Inc.) (#13108)
+
+	IRC:
+	* Don't send ISON messages longer than 512 bytes. (Jeffrey Honig) (#9692)
+
+	libpurple:
+	* Stop sending audio when placing a call on hold. (Jakub Adam) (#13032)
+	* Stop translating gpointers to ints in the dbus API.  This removes
+	  functions from the dbus API.  (The openSUSE Project) (#12507)
+	* Fix D-Bus introspection calls that omit the interface parameter.  (Tom
+	  Samstag) (#13073)
+	* Fixed bugs in purple_str_to_time() that caused the most recent 'make
+	  check' failures.  (Nader Morshed) (#13131)
+	* Correct an issue that caused some UIs other than Pidgin or Finch to
+	  leave a buddy in the "is typing" state.  (Jan Kaluza)
+	* Fix potential information disclosure issues in the Cipher code.  (Julia
+	  Lawall)
+
+	Pidgin:
+	* Support using the Page Up and Page Down keys on the numeric keypad in
+	  the conversation window.  (Ryan Flegel) (#13127)
+	* Fix a few memory leaks. (Nader Morshed) (#13162)
+	* Support rendering strikethrough when received as in-line CSS. (#13168)
+	* Editable comboboxes are now more friendly to some GTK+ themes. (Hugo
+	  Pereira Da Costa) (#13164).
+
+	Plugins:
+	* The Voice/Video Settings plugin no longer resets selected devices to
+	  defaults. (Jakub Adam) (#13044)
+	* The Voice/Video Settings plugin no longer crashes when a stored device
+	  name is not found in the list of available devices. (Jakub Adam)
+	  (#13238)
+	* The Autoaccept plugin now allows disabling filename escaping. (Rok
+	  Mandeljc) (half of #11459)
+	* The Autoaccept plugin now allows choosing Reject/Ask/Accept for
+	  non-buddies. (Rok Mandeljc) (half of #11459)
+
+	QQ:
+	* QQ2008 is now the default protocol version. (Michael Terry) (#11635)
+
+	XMPP:
+	* Don't crash when receiving an unexpected/invalid jingle transport type.
+	  (Nikita Kozlov) (#13136)
+	* Handle Connection: Close headers for BOSH, when the server does not
+	  terminate the connection itself. (#13008)
+	* Improved parsing for DIGEST-MD5, which should resolve issues
+	  connecting to some jabberd2 servers.  This corrects an issue parsing
+	  one-character or empty elements. (Noa Resare) (#a14514)
+
+	Yahoo!/Yahoo! JAPAN:
+	* Fix a crash when an account disconnects before a p2p session is
+	  completely set up. (Jan Kaluza) (#12432)
+
+version 2.7.9 (12/26/2010):
+	MSN:
+	* Fix CVE-2010-4528, a crash when receiving short packets related to
+	  P2Pv2 messages.
+
+version 2.7.8 (12/19/2010):
+	General:
+	* Fix the exceptions in purple-remote on Python 2.6+. (Ari Pollak)
+	  (#12151)
+
+	Pidgin:
+	* When a conversation has reached the maximum limit on the number
+	  of smileys, display the text representation of the smiley properly
+	  when it contains HTML-escapable characters (e.g. "<3" was previously
+	  displayed as "&lt;3").
+	* Drop dependency on GdkGC and use Cairo instead.
+	* New UI hack to assist in first-time setup of Facebook accounts with
+	  icon from Jakub Szypulka.
+	* Don't hide the buddy list if there is no notification area in which
+	  to put the icon. (#12129)
+
+	libpurple:
+	* Fix multipart parsing when '=' is included in the boundary for
+	  purple_mime_document_parse. (Jakub Adam) (#11598)
+
+	AIM and ICQ:
+	* Buddies who unset their status message will now be correctly shown
+	  without a message in your buddy list. (#12988)
+
+	Gadu-Gadu:
+	* Updated our bundled libgadu and minimum requirement for external
+	  libgadu to 1.9.0. (#12789)
+
+	MSN:
+	* Stop showing ourselves in the list of endpoints that can be
+	  disconnected.
+	* Allow full-size display names, by not escaping (most) non-English
+	  characters. (#8508)
+	* Fix receiving messages from users on Yahoo and other federated
+	  services. (#13022)
+	* Correctly remove old endpoints from the list when they sign out.
+	* Add option to disable connections from multiple locations. (#13017)
+	* Correctly update your own display name in the buddy list. (#13064) 
+	* Correctly show ourselves as offline in the buddy list when going
+	  invisible. (#12945)
+	* Correctly update your own icon in the buddy list. (#12973)
+	* Remove struct packing for better portability. (#12856)
+
+	XMPP:
+	* Terminate Jingle sessions with unsupported content types. (#13048)
+
+version 2.7.7 (11/23/2010):
+	General:
+	* Allow multiple CA certificates to share the same Distinguished Name
+	  (DN).  Partially fixes remaining MSN issues from #12906.
+	* The GNUTLS SSL plugin now discards any certificate (and all subsequent
+	  certificates) in a chain if it did not sign the previous certificate.
+	  Partially fixes remaining MSN issues from #12906.
+	* Open requests related to a file transfer are now closed when the request
+	  is cancelled locally. (#11666)
+
+	AIM and ICQ:
+	* AIM should now connect if "Use clientLogin" is turned off and the
+	  "Server" field is set to anything other than "login.oscar.aol.com" or
+	  "slogin.oscar.aol.com". (#12948)
+	* Fix a crash on connection loss. (#5927)
+
+version 2.7.6 (11/21/2010):
+	General:
+	* Included Microsoft Internet Authority 2010 and Microsoft Secure Server
+	  Authority 2010 intermediate CA certificates to our bundle.  This fixes
+	  the "Unable to validate certificate" error for omega.contacts.msn.com.
+	  (#12906)
+
+	Pidgin:
+	* Avoid a use-after-free race condition in the media code (when
+	  there's an error reported by GStreamer). (#12806, Jakub Adam)
+
+	AIM and ICQ:
+	* SSL option has been changed to a tri-state menu with choices for
+	  "Don't Use Encryption", "Use Encryption if Available", and "Require
+	  Encryption".
+	* Fix some possible clientLogin URL issues introduced in version 2.7.5.
+	* Don't show a "<URL>: Ok" connection error when using clientLogin.
+	* Cleaned up some debug output for improved readability.
+
+	MSN:
+	* Added support for MSNP16, including Multiple Points of Presence (MPOP)
+	  which allows multiple simultaneous sign-ins. (#8247)
+	* Added extended capabilities support (none implemented).
+	* Merged the work done on the Google SoC (major rewrite of SLP code)
+	* Reworked the data transfer architecture.
+	  (http://developer.pidgin.im/wiki/SlpArchitecture)
+	* Lots of little changes.
+	* Don't process zero-length DC messages. (#12660)
+	* Fixed a bunch of memory leaks.
+	* Prevent a use-after-free condition.
+
+	XMPP:
+	* Avoid a double-free in the Google Relay (V/V) code.
+	* Avoid double error message when failing a file transfer. (#12757)
+	* Password-related information is printed out for SASL authentication
+	  when the PURPLE_UNSAFE_DEBUG environment variable is set.
+	* Authentication mechanisms can now be added by UI's or other plugins
+	  with some work. This is outside the API/ABI rules! (#12715)
+	* Fixed a few printf("%s", NULL) crashes for broken OSes.
+
+	Windows-Specific Changes:
+	* Build the Pidgin Theme Editor plugin (finally).
+	* Untarring (for themes) now works for non-ASCII destination paths.
+
+version 2.7.5 (10/31/2010):
+	General:
+	* Added Verisign Class 3 Public CA - G2 root CA.
+
+	Pidgin:
+	* Properly differentiate between bn and bn_IN in the Translation
+	  Information dialog.
+
+	AIM and/or ICQ:
+	* Display the "Authorize buddy?" minidialog when the requestor has an
+	  empty nickname. (#12810)
+	* New ICQ accounts default to proper ICQ servers.  Old accounts using one
+	  of the old default servers will be silently migrated to use the proper
+	  servers.
+	* ICQ accounts using clientLogin now use the correct ICQ servers.  This is
+	  separate from the server settings mentioned above.
+	* '<' should no longer cause ICQ status messages to be truncated in some
+	  locations. (#11964, #12593)
+	* Fix sending messages to chat rooms. (#12768)
+
+	Bonjour:
+	* Don't crash when attempting to log into a Bonjour account and init
+	  failed.
+
+	Windows-Specific Changes:
+	* Quote the path stored in the registry when the "run at startup" option
+	  in the Windows Pidgin Options plugin is used. (#12781)
+
+version 2.7.4 (10/20/2010):
+	General:
+	* Fix search path for Tk when compiling on Debian Squeeze. (#12465)
+	* purple-remote now expects and produces UTF-8. (Guillaume Brunerie)
+	  (#12049)
+	* Add Deutsche Telekom, Thawte Primary, and Go Daddy Class 2 root CAs
+	  (#12667, #12668, and #12594)
+	* Fix CVE-2010-3711 by properly validating return values from the
+	  purple_base64_decode() function before using them.
+	* Fix two local crash bugs by properly validating return values from the
+	  purple_base16_decode() function before using them.
+
+	libpurple:
+	* Fall back to an ordinary request if a UI does not support showing a
+	  request with an icon.  Fixes receiving MSN file transfer requests
+	  including a thumbnail in Finch. (#12561)
+	* Fix an invalid memory access when removing UPnP mappings that could
+	  cause sporadic crashes, most notably when MSN Direct Connections are
+	  enabled. (#12387)
+	* Add a sentence to the certificate warning for expired certificates
+	  suggesting the user check their computer's date and time. (#12654)
+
+	Pidgin:
+	* Add support for the Gadu-Gadu protocol in the gevolution plugin to
+	  provide Evolution integration with contacts with GG IDs. (#10709)
+	* Remap the "Set User Mood" shortcut to Control-D, which does not
+	  conflict with the previous shortcut for Get Buddy Info on the
+	  selected buddy.
+	* Add a plugin action menu (under Tools) for the Voice and Video
+	  Settings plugin.
+	* Use GRegex for the debug window where available. This brings regex
+	  filtering to the debug window on Windows. (Eion Robb) (#12601)
+	* Add Google Chrome to the list of possible browsers on non-Windows
+	  systems.
+	* Add Chromium to the list of possible browsers on non-Windows systems.
+	* The "Manual" browser option is now stored as a string.  It is no
+	  longer necessary to specify a full path to the browser command.
+	  (Rodrigo Tobar Carrizo) (#12024)
+	* The Send To menu can now be used if the active account in the
+	  conversation becomes disabled or inactive. (Keith Moyer) (#12471)
+	* xdg-open is now the default browser for new users on non-Windows
+	  platforms. (Stanislav Brabec) (#12505)
+	* The "Authorize buddy?" mini-dialog now shows the nickname of
+	  the buddy requesting authorization as well as the icon of
+	  the IM protocol he is using. (#5038)
+
+	Finch:
+	* Add support for drop-down account options (like the SILC cipher
+	  and HMAC options or the QQ protocol version).
+
+	XMPP:
+	* Unify the connection security-related settings into one dropdown.
+	* Fix a crash when multiple accounts are simultaneously performing
+	  SASL authentication when built with Cyrus SASL support.  (thanks
+	  to Jan Kaluza) (#11560)
+	* Restore the ability to connect to XMPP servers that do not offer
+	  Stream ID. (#12331)
+	* Added support for using Google's relay servers when making voice and
+	  video calls to Google clients.
+	* Fix detecting file transfer proxies advertised by the server.
+	* Advertise support for Google Talk's JID Domain Discovery extension
+	  in all cases again (changed in 2.7.0), not just when the domain
+	  is "gmail.com" or "googlemail.com" (it's also needed for Google
+	  Talk used for accounts on arbitrary domains not using Google Apps
+	  for Your Domain). (#a14153)
+	* Improved handling of adding oneself to your buddy list when using
+	  Non-SASL (legacy) authentication. (#12499)
+	* Generate a connection error instead of just stalling when the
+	  _xmppconnect TXT record returns results, but none of them result
+	  in a valid BOSH URI. (#a14367, #12744)
+
+	AIM and ICQ:
+	* Add support for managing Visible/Invisible lists. (#10967)
+	* Fix a problem with receiving HTML messages from
+	  QIP/Miranda/Trillian. (#12044)
+	* Hopefully fixed all encoding-related problems, both
+	  for sending and receiving messages. (#10833 and the like)
+	* Fix a problem with receiving messages from pyicqt. (#12284)
+	* Don't set a custom status text when going Invisible to avoid
+	  being detected as Invisible. (#10633)
+
+	Yahoo/Yahoo JAPAN:
+	* Stop doing unnecessary lookups of certain alias information.  This
+	  solves deadlocks when a given Yahoo account has a ridiculously large
+	  (>500 buddies) list and may improve login speed for those on slow
+	  connections. (#12532)
+	* Fix sending SMS messages.  The lookup host changed on us.  (Thanks to
+	  todo) (#12688).
+	* Improvements for some file transfer scenarios, but not all.
+
+	Windows:
+	* Bonjour support now requires Apple Bonjour Print Services version
+	  2.0.0 or newer (http://support.apple.com/kb/dl999).
+
+	libpurple:
+	* Fall back to an ordinary request if a UI does not support showing a
+	  request with an icon.  Fixes receiving MSN file transfer requests
+	  including a thumbnail in Finch.
+
+	Pidgin:
+	* Add support for the Gadu-Gadu protocol in the gevolution plugin to
+	  provide Evolution integration with contacts with GG IDs. (#10709)
+	* Remap the "Set User Mood" shortcut to Control-D, which does not
+	  conflict with the previous shortcut for Get Buddy Info on the
+	  selected buddy.
+	* Add a plugin action menu (under Tools) for the Voice and Video
+	  Settings plugin.
+
+	Finch:
+	* Add support for drop-down account options (like the SILC cipher
+	  and HMAC options or the QQ protocol version).
+
+	XMPP:
+	* Unify the connection security-related settings into one dropdown.
+	* Fix a crash when multiple accounts are simultaneously performing
+	  SASL authentication when built with Cyrus SASL support.  (thanks
+	  to Jan Kaluza) (#11560)
+	* Restore the ability to connect to XMPP servers that do not offer
+	  Stream ID. (#12331)
+	* Added support for using Google's relay servers when making voice and
+	  video calls to Google clients.
+
+	Yahoo/Yahoo JAPAN:
+	* Stop doing unnecessary lookups of certain alias information.  This
+	  solves deadlocks when a given Yahoo account has a ridiculously large
+	  (>500 buddies) list and may improve login speed for those on slow
+	  connections. (#12532)
+
+version 2.7.3 (08/10/2010):
+	General:
+	* Use silent build rules for automake >1.11. You can enable verbose
+	  builds with the --disable-silent-rules configure option, or using
+	  make V=1.
+
+	libpurple:
+	* Fix the TURN server settings (broken in 2.7.0).
+
+	Pidgin:
+	* Re-focus the input area after clicking the attention toolbar button.
+	* Re-arrange media window to make it more netbook-friendly.
+
+	Finch:
+	* Rebindable 'suggest-next-page' and 'suggest-prev-page' actions for
+	  textboxes (GntEntry) to scroll through list of suggestions.
+	* Rebindable 'dropdown' action for comboboxes (GntComboBox) to show the
+	  dropdown list of options.
+
+	IRC:
+	* Fix non-ASCII arguments to /mode et al.  (thanks to Max Ulidtko)
+
+	MSN:
+	* Support for web-based buddy icons, used when a buddy logs in to the
+	  messenger on the Live website.
+	* Fix file transfers with some clients that don't support direct
+	  connections (e.g., papyon, telepathy-butterfly, etc.) (#12150)
+
+	MXit:
+	* Fix filename for the Shocked emoticon. (#12364)
+	* Implement the new naming conventions where possible. (MXitId, etc)
+	* Display a message in the Groupchat window when you invite somebody.
+	* Birthday field in profile cannot be edited when server says it is
+	  locked.
+	* If a buddy is offline, show in their profile when last they were online.
+	* Handle pushed profile update packets (ie, when changing your avatar via
+	  the Gallery bot).
+	* If a buddy is offline and we see from their profile that they have
+	  updated their avatar, request the new avatar image from the server.
+	* Fix a possible crash if a link is clicked while disconnected.
+	* Unescape any escaped characters in a chatroom nickname.
+	* Add the new MXit moods and emoticons.
+	* MXit emoticons added to the small emoticon theme.
+
+	XMPP:
+	* Allow connecting to servers that only advertise GSSAPI and expect
+	  a fallback to legacy IQ authentication (broken in 2.7.0).
+	* Fix a crash when receiving custom emoticons that don't adhere to
+	  the specification.
+	* When initiating a file transfer, don't show resources that are certain
+	  to not support file transfers in the resource selection dialog.
+	* Fix connecting to servers using BOSH and authenticating with
+	  DIGEST-MD5 when libpurple was built with Cyrus SASL support.
+
+	Yahoo/Yahoo JAPAN:
+	* Renamed "Use account proxy for SSL connections" to "Use account proxy
+	  for HTTP and HTTPS requests" and tied the option to HTTP requests too.
+	* Properly detect HTTP proxy server use when the HTTP proxy is the
+	  global proxy server, an account-level non-HTTP proxy server is
+	  configured, and the "Use account proxy for HTTP and HTTPS requests"
+	  account option is turned off.  This fixes connecting for some HTTP
+	  proxy servers.
+	* Fall back to connecting to scsa.msg.yahoo.com (not configurable) if
+	  the HTTP-based connect server lookup fails.  This does not work for
+	  Yahoo JAPAN accounts.
+	* Fix file transfers that get stuck with "Waiting for transfer to
+	  begin".
+
+version 2.7.2 (07/21/2010):
+	AIM and ICQ:
+	* Fix a crash bug related to X-Status messages that can be triggered by
+	  remote users.  This is CVE-2010-2528.
+	* Fix a rare crash bug caused by certain incoming SMS messages
+	  (discovered by Jan Kaluza--thanks Jan!).
+	* Change HTML sent from ICQ accounts so that official ICQ clients
+	  hopefully display it correctly.
+
+	MSN:
+	* Fix a crash related to fast buddy icon transfers.
+
+version 2.7.1 (05/29/2010):
+	General:
+	* Build fixes on OpenSolaris.  (Brian Lu)
+	* Add configure option --enable-trayicon-compat which installs tray
+	  icons into directories that are compatible with older versions of
+	  hicolor-icon-theme (0.9).
+
+	Pidgin:
+	* Restore the tray icon's blinking functionality.
+	* Fix a crash setting moods when an account is disconnected.
+
+	Bonjour:
+	* Fix a crash on disconnect.
+
+	ICQ:
+	* Fix bug that caused HTML to be displayed in incoming messages.
+
+	MSN:
+	* Fix unnecessary bandwidth consumption for buddy icon requests when
+	  buddies have capital letters in their passport addresses.
+	* Support for direct connections, enabling faster file transfers,
+	  smiley and buddy icon loading.  (Gábor Szuromi)
+
+	XMPP:
+	* Allow connecting to servers that advertise EXTERNAL (broken in
+	  2.7.0)
+
+	MXit:
+	* Replace the MXit-specific mood management with the new standard Moods
+	  API.
+	* Add the standard MXit emoticons.
+	* Improve the handling of users being kicked from MultiMX rooms.
+	* MXit doesn't allow you to see your buddy's Email Address or Title,
+	  so remove those two fields from the "Buddy Information" page.
+	* Show buddy's Registration Country in their profile.
+	* Increment protocol version to v6.0
+	* If an invite you sent was rejected with a reason, display that
+	  message in the buddy tooltip.
+	* CAPTCHA value is a required field during account activation.
+	  (Resolves issue on Maemo)
+	* When your avatar image is changed, don't forget the user's profile
+	  information.
+
+	Windows-Specific Changes:
+	* Fix a regression introduced in 2.7.0 that caused Window Flashing not
+	  to work.
+
+version 2.7.0 (05/12/2010):
+	General:
+	* Changed GTK+ minimum version requirement to 2.10.0.
+	* Changed GLib minimum version requirement to 2.12.0.
+	* Using the --disable-nls argument to configure now works properly.
+	  You will no longer be forced to have intltool to configure and build.
+	* Fix two related crashes in the GnuTLS and NSS plugins when they
+	  suffer internal errors immediately upon attempting to establish
+	  an SSL connection.
+	* Fix NSS to work when reinitialized after being used.  (Thanks to
+	  Ludovico Cavedon for the testcase)
+	* Added support for PURPLE_GNUTLS_PRIORITIES environment variable.
+	  This can be used to specify GnuTLS priorities on a per-host basis.
+	  The format is "host=priority;host2=priority;...".  The default
+	  priority can be overridden by using "*" as the host.  See the
+	  GnuTLS manual for documentation on the format of the priority
+	  strings.
+	* Fix autoconf detection of Python.  (Brad Smith)
+	* Fix a crash when a Windows proxy (from IE) does not have a port.
+	  (Marten Klencke)
+
+	Pidgin:
+	* Moved the "Debugging Information" section of the About box to a
+	  "Build Information" dialog accessible on the Help menu.
+	* Moved the Developer and Crazy Patch Writer information from the About
+	  box to a "Developer Information" dialog accessible on the Help menu.
+	* Moved the Translator information from the About box to a "Translator
+	  Information" dialog accessible on the Help menu.
+	* Use GtkStatusIcon for the docklet, providing better integration in
+	  notification area.
+	* Added UI for sending attentions (buzz, nudge) on supporting protocols.
+	* Make the search dialog unobtrusive in the conversation window (by
+	  making it look and behave like the search dialog in Firefox)
+	* The Recent Log Activity sort method for the Buddy List now
+	  distinguishes between no activity and a small amount of activity
+	  in the distant past.  (Greg McNew)
+	* Added a menu set mood globally for all mood-supporting accounts
+	  (currently XMPP and ICQ).
+	* Default binding of Ctrl+Shift+v to 'Paste as Plain Text' in
+	  conversation windows. This can be changed in .gtkrc-2.0. For example,
+	  Ctrl+v can be bound to 'Paste as Plain Text' by default.
+	* Plugins can now handle markup in buddy names by attaching to the
+	  "drawing-buddy" signal. (Daniele Ricci, Andrea Piccinelli)
+	* Be more accommodating when scaling down large images for use as
+	  buddy icons.
+	* The 'Message Timestamp Formats' plugin allows changing the timestamp
+	  format from the timestamps' context menu in conversation log.
+	* The 'Message Timestamp Formats' plugin allows forcing 12-hour
+	  timestamps.  (Jonathan Maltz)
+	* Fix pastes from Chrome (rich-text pastes and probably URLs
+	  having garbage appended to them).
+	* Show file transfer thumbnails for images on supporting protocols
+	  (currently only supported on MSN).
+
+	Bonjour:
+	* Added support for IPv6. (Thanks to T_X for testing)
+
+	Gadu-Gadu:
+	* Updated our bundled libgadu to 1.9.0-rc2 (many thanks to Krzysztof
+	  Klinikowski for the work and testing put in here!)
+	* Minimum requirement for external libgadu is now also 1.9.0-rc2.
+
+	AIM and ICQ:
+	* X-Status (Custom ICQ status icon) support.  Since most of the icons
+	  available reflect moods, this is labeled "Set Mood" on the
+	  Accounts->ICQ Account menu. (Andrew Ivanov, Tomáš Kebert,
+	  Yuriy Yevgrafov, and trac users bob007, salieff, and nops)
+	* Allow setting and displaying icons between 1x1 and 100x100 pixels for
+	  ICQ.  Previously only icons between 48x48 and 52x64 were allowed.
+	* When using the clientLogin authentication method, prompt for a
+	  password on reconnect when "Remember Password" is not checked and
+	  authentication fails due to an incorrect password.  (This is the same
+	  behavior as the legacy authentication method)
+	* Support sending and receiving HTML-formatted messages for ICQ.
+	* Use the proper URL for "View web profile" link for ICQ buddies.
+	  (Alexander Nartov)
+
+	MSN:
+	* Support for version 9 of the MSN protocol has been removed.  This
+	  version is no longer supported on the servers.
+	* Support file transfer thumbnails (previews) for images.
+	* Fix CVE-2010-1624 (custom emoticon remote crash).
+
+	XMPP:
+	* Direct messages to a specific resource only upon receipt of a message
+	  with content (as opposed to a typing notification, etc).  (Thanks to
+	  rjoly for testing)
+	* Present a better error message when authentication fails while trying
+	  to connect to Facebook.  (David Reiss, Facebook)
+	* When sending data using in-band-bytestreams, interpret the block-size
+	  attribute as the size of the BASE64-encoded representation of the
+	  data.
+	* Validate the hash on incoming BoB data objects (for custom smileys
+	  etc.), cache based per JID when the CID is not a valid hash (as
+	  specified by the BoB XEP).
+	* Send whitespace keepalives if we haven't sent data in a while (2
+	  minutes).  This fixes an issue with Openfire disconnecting a
+	  libpurple-baesd client that has just been quiet for about 6
+	  minutes.
+	* Only support Google Talk's JID Domain Discovery extension
+	  (allowing a user to log in with "@gmail.com" or "@googlemail.com"
+	  interchangeably) for those two domains.  This change was made
+	  due to interoperability issues with some BOSH Connection Managers
+	  and namespaced attributes.
+
+	Yahoo/Yahoo JAPAN:
+	* Attempt to better handle transparent proxies interfering with
+	  HTTP-based login.
+	* Fix handling of P2P packets, thus fixing the loss of some messages.
+	* Retrieve the pager server address from Yahoo!'s servers directly.
+	* Removed the "Pager server" account option, as it is no longer needed.
+	* The authentication code is now less order-sensitive with the
+	  components of the server's response.
+	* The authentication process now acts more like the official client.
+
+	Finch:
+	* New action 'history-search', with default binding ctrl+r, to search
+	  the entered string in the input history.
+
+	Windows-Specific Changes
+	* Updated GTK+ to 2.16.6
+	* Private GTK+ Runtime now used (GTK+ Installer no longer supported)
+	* Minimum required GTK+ version increased to 2.14.7
+	* Windows 95, Windows 98, Windows 98 Second Edition, Windows ME
+	  (Millennium Edition), and Windows NT 4.0 longer supported due to GTK+
+	  requirements changes.
+	* Crash Report files (pidgin.RPT) are now generated in the ~/.purple
+	  directory instead of the installation directory.
+	* NSS SSL Library upgraded to 3.12.5 (thanks to Berke Viktor)
+	* GtkSpell upgraded to 2.0.16, changing the spellchecking backend to
+	  enchant.  This means that myspell and hunspell (OpenOffice)
+	  dictionaries can be used (previous versions' aspell dictionaries
+	  will not work).
+
+version 2.6.6 (02/18/2010):
+	libpurple:
+	* Fix 'make check' on OS X. (David Fang)
+	* Fix a quirk in purple_markup_html_to_xhtml that caused some messages
+	  to be improperly converted to XHTML.
+	* Set "controlling-mode" correctly when initializing a media session.
+	  Fixes receiving voice calls from Psi.
+	* When looking up DNS records, use the type of record returned by the
+	  server (instead of the type we asked for) to determine how to process
+	  the record.
+	* Fix an issue with parsing XML attributes that contain "&lt;br&gt;".
+	  See ChangeLog.API for more details.
+
+	General:
+	* Correctly disable all missing dependencies when using the
+	  --disable-missing-dependencies option.  (Gabriel Schulhof)
+
 	Gadu-Gadu:
 	* Fix display of avatars after a server-side change. (Krzysztof
 	  Klinikowski)
 
+	AIM:
+	* Allow setting and displaying icons between 1x1 and 100x100 pixels.
+	  Previously only icons between 48x48 and 50x50 were allowed.
+
 	MSN:
+	* Fix CVE-2010-0277, a possible remote crash when parsing an incoming
+	  SLP message.  (Discovered by Fabian Yamaguchi)
 	* File transfer requests will no longer cause a crash if you delete the
 	  file before the other side accepts.
-	* Recieved files will no longer hold an extra lock after completion,
+	* Received files will no longer hold an extra lock after completion,
 	  meaning they can be moved or deleted without complaints from your OS.
 	* Buddies who sign in from a second location will no longer cause an
 	  unnecessary chat window to open.
 	* Support setting an animated GIF as a buddy icon.
+	* Numerous code cleanups and memory savings.
+
+	MySpace:
+	* Fix a leak and crash when retrieving buddy icons.
 
 	XMPP:
+	* Less likely to send messages to a contact's idle/inactive resource.
+	  Previously, if a message was received from a specific resource,
+	  responses would be sent to that resource until either it went offline
+	  or a message is received from another resource.  Now, messages are
+	  sent to the bare JID upon receipt of any presence change from the
+	  contact.
 	* Added support for the SCRAM-SHA-1 SASL mechanism.  This is only
 	  available when built without Cyrus SASL support.
 	* When getting info on a domain-only (server) JID, show uptime
-	  (when given by the result of the "last query") and don't show status as
-	  offline.
+	  (when given by the result of the "last query") and don't show status
+	  as offline.
+	* Fix getting info on your own JID.
+	* Wrap XHTML messages in <p>, as described in XEP-0071, for
+	  compatibility with some clients.
+	* Don't do an SRV lookup for a STUN server associated with the account
+	  if one is already set globally in prefs.
+	* Don't send custom smileys larger than the recommended maximum object
+	  size specified in the BoB XEP.   This prevents a client from being
+	  disconnected by servers that dislike overly-large stanzas.
+	* Fix receiving messages without markup over an Openfire BOSH
+	  connection (forcibly put the stanzas in the jabber:client namespace).
+	* The default value for the file transfer proxies is automatically
+	  updated when an account connects, if it is still the old (broken)
+	  default (from 'proxy.jabber.org' to 'proxy.eu.jabber.org').
+	* Fix an issue where libpurple created duplicate buddies if the roster
+	  contains a buddy in two groups that differ only by case
+	  (e.g. "XMPP" and "xmpp") (or not at all).
+
+	Yahoo:
+	* Don't send <span> and </span> tags.  (Fartash Faghri)
+	* Support PingBox.  PingBoxes will appear as pbx/PingBoxName.  (Kartik
+	  Mohta)
+
+	Pidgin:
+	* Fix CVE-2010-0423, a denial of service attack due to the parsing
+	  of large numbers of smileys.  (Discovered by Antti Hayrynen)
+	* Correctly size conversation and status box entries when the
+	  interior-focus style property is diabled. (Gabriel Schulhof)
+	* Correctly handle a multiline text field being required in a
+	  request form.  (Thanks to Florian Zeitz for finding this problem)
+	* Search friends by email-addresses in the buddy list. (Luoh Ren-Shan)
+	* Allow dropping an image on Custom Smiley window to add a new one.
+	* Prompt for confirmation when clearing a whiteboard (doodle) session.
+	  (Kartik Mohta)
+	* Use the "hand" cursor when hovering over usernames in chat history to
+	  indicate that the username is an actionable item.
+	* Double-clicking usernames in chat history will open an IM with that
+	  user.
+	* Put an icon on the "Filter" button in the debug window.
+	* Don't treat "/messages/like/this " as commands.
+	* Explicitly mark user interaction when inserting smilies from the
+	  toolbar so "Undo" correctly removes these smilies.
+	* Clicking "New" or "Saved" in the status selector menu while typing a
+	  status message no longer keeps the status entry area stuck in "typing"
+	  mode forever.
+	* Show tooltips for ellipsized conversation tabs.  On older systems,
+	  tooltips will show for all tabs.
+	* The File Transfers and Debug Window windows are no longer created as
+	  dialogs.  These windows should now have minimize buttons in many
+	  environments in which they were previously missing
+	  (including Windows).
+	* Smiley themes with Windows line endings no longer cause theme
+	  descriptions not to be displayed in the theme selector.
+
+	Finch:
+	* Fix CVE-2010-0420, a possible remote crash when handling chat room
+	  buddy names.
+	* Rebindable 'move-first' and 'move-last' actions for tree widgets. So
+	  it is possible to jump to the first or last entry in the buddy list
+	  (and other such lists) by pressing home or end key (defaults)
+	  respectively.
 
 version 2.6.5 (01/08/2010):
 	libpurple:
@@ -47,11 +957,11 @@
 	* Actually emit the hold signal for media calls.
 	* Fix building the GnuTLS plugin with older versions of GnuTLS.
 	* Fix DNS TXT query resolution.
-	* Don't send Proxy-Authorization headers to HTTP proxy servers until we've
-	  received a "407 Proxy Authentication Required" response from the server.
-	  (thecrux)
-	* Added "MXit" protocol plugin, supported and maintained by the MXit folks
-	  themselves (MXit Lifestyle (Pty) Ltd.)
+	* Don't send Proxy-Authorization headers to HTTP proxy servers until
+	  we've received a "407 Proxy Authentication Required" response from
+	  the server.  (thecrux)
+	* Added "MXit" protocol plugin, supported and maintained by the MXit
+	  folks themselves (MXit Lifestyle (Pty) Ltd.)
 
 	General:
 	* New 'plugins' sub-command to 'debug' command (i.e. '/debug plugins')
@@ -82,14 +992,14 @@
 	  as it has probably been reset.
 
 	XMPP:
-	* Users connecting to Google Talk now have an "Initiate Chat" context menu
-	  option for their buddies.  (Eion Robb)
+	* Users connecting to Google Talk now have an "Initiate Chat" context
+	  menu option for their buddies.  (Eion Robb)
 	* Fix a crash when attempting to validate an invalid JID.
 	* Resolve an issue when connecting to iChat Server when no resource
 	  is specified.
 	* Try to automatically find a STUN server by using an SRV lookup on the
-	  account's domain, and use that for voice and video if found and the user
-	  didn't set one manually in prefs.
+	  account's domain, and use that for voice and video if found and the
+	  user didn't set one manually in prefs.
 	* Fix a crash when adding a buddy without an '@'.
 	* Don't show the option to send a file to a buddy if we know for certain
 	  they don't support any file transfer method supported by libpurple.
@@ -113,23 +1023,23 @@
 	* The userlist in a multiuser chat can be styled via gtkrc by using the
 	  widget name "pidgin_conv_userlist". (Heiko Schmitt)
 	* Add a hold button to the media window.
-	* Fix a bug where the conversation backlog stops scrolling in a very busy
-	  chat room.
+	* Fix a bug where the conversation backlog stops scrolling in a very
+	  busy chat room.
 	* In the Conversation "Send To" menu, offline buddies appear grayed
 	  out (but are still selectable).  Previously, only offline buddies on
 	  accounts that do not support offline messaging appeared grayed out.
 
 	Pidgin Preference and Preference Window Changes:
 	* Removed the "Use font from theme" and "Conversation Font" preferences
-	  for everyone except Windows users.  The font can be controlled from the
-	  Pidgin GTK+ Theme Control plugin.
+	  for everyone except Windows users.  The font can be controlled from
+	  the Pidgin GTK+ Theme Control plugin.
 	* Tabs in the Preferences window are now on the left side.
 	* The Browser tab is now visible for GNOME users.
 	* Added a Proxy tab shown no matter what environment Pidgin runs in.
-	* The Browser and Proxy tabs show appropriate GNOME-specific messages and
-	  allow launching the correct applications to change the relevant GNOME
-	  preferences if found.  These were previously together on the Network
-	  tab.
+	* The Browser and Proxy tabs show appropriate GNOME-specific messages
+	  and allow launching the correct applications to change the relevant
+	  GNOME preferences if found.  These were previously together on the
+	  Network tab.
 	* Moved the port range spin buttons on the Network tab to be beside the
 	  checkbox that enables/disables them.
 	* Reorganized preferences on the Status/Idle tab to have one less
@@ -139,10 +1049,10 @@
 	* Moved Buddy List Theme and Status Icon Theme selectors from Interface
 	  tab to Themes tab.
 	* Moved Sound Theme selector from Sounds tab to Themes tab.
-	* Changed the Smiley Theme selector to be consistent with the other theme
-	  selectors.
-	* Rearranged tabs such that Interface is first and all remaining tabs are
-	  alphabetized in English.
+	* Changed the Smiley Theme selector to be consistent with the other
+	  theme selectors.
+	* Rearranged tabs such that Interface is first and all remaining tabs
+	  are alphabetized in English.
 
 version 2.6.3 (10/16/2009):
 	General:
@@ -182,16 +1092,17 @@
 	  properly.  In addition, it is no longer possible to add buddies of
 	  the form "room@conference.example.net/User", where
 	  room@conference.example.net is a MUC.
-	* Don't crash when receiving "smileyfied" XHTML-IM from clients that don't
-	  support bits of binary (ie. when getting an empty <data/> in return)
+	* Don't crash when receiving "smileyfied" XHTML-IM from clients that
+	  don't support bits of binary (ie. when getting an empty <data/> in
+	  return)
 	* Fix bug where SSL/TLS was not required even though the
 	  "require SSL/TLS" preference checked when connecting to servers
 	  that use the older iq-based authentication.  (CVE-2009-3026)
 
 	Yahoo!/Yahoo! JAPAN:
-	* Accounts now have "Use account proxy for SSL connections" option.  This
-	  option force-overrides the account specific proxy settings for SSL
-	  connections only and instead uses the global proxy configuration.
+	* Accounts now have "Use account proxy for SSL connections" option.
+	  This option force-overrides the account specific proxy settings for
+	  SSL connections only and instead uses the global proxy configuration.
 
 	Finch:
 	* Properly detect libpanel on OpenBSD.  (Brad Smith)
@@ -233,8 +1144,8 @@
 	* Various memory leaks fixed as reported by Josh Mueller.
 	* Properly handle an IRC buddy appearing in multiple groups.
 	* Escape HTML entities in usernames when written with the HTML logger.
-	* Do not display MySpace status changes as incoming IMs.  (Mark Doliner and
-	  Justin Williams)
+	* Do not display MySpace status changes as incoming IMs.  (Mark Doliner
+	  and Justin Williams)
 
 	DNS:
 	* DNS servers are re-read when DNS queries fail in case the system has
@@ -245,32 +1156,34 @@
 	  address configured.
 	* Fix a leak when the UI provides its own DNS resolving UI op.
 	  (Aman Gupta)
-	* Don't fork a DNS resolver process to resolve IP addresses.  (Aman Gupta)
-	* Internationalized Domain Names are supported when libpurple is compiled
-	  against the GNU IDN library.
+	* Don't fork a DNS resolver process to resolve IP addresses.
+	  (Aman Gupta)
+	* Internationalized Domain Names are supported when libpurple is
+	  compiled against the GNU IDN library.
 
 	Environment Variables:
 	* GnuTLS logging (disabled by default) can be controlled through the
 	  PURPLE_GNUTLS_DEBUG environment variable, which is an integer between
 	  0 and 9 (higher is more verbose). Higher values may reveal sensitive
 	  information.
-	* PURPLE_VERBOSE_DEBUG environment variable.  Currently, this is an "on" or
-	  "off" variable.  Set it to any value to turn it on and unset it to turn
-	  it off.  This will optionally be used to only show less useful debug
-	  information on an as-needed basis.
-	* PURPLE_LEAKCHECK_HELP environment variable.  Currently, this is an "on"
+	* PURPLE_VERBOSE_DEBUG environment variable.  Currently, this is an "on"
 	  or "off" variable.  Set it to any value to turn it on and unset it to
-	  turn it off.  This will be used to perform various actions that are
-	  useful when running libpurple inside of Valgrind or similar programs.
-	  Currently, it keeps plugins in memory, allowing Valgrind to perform
-	  symbol resolution of leak traces at shutdown.
+	  turn it off.  This will optionally be used to only show less useful
+	  debug information on an as-needed basis.
+	* PURPLE_LEAKCHECK_HELP environment variable.  Currently, this is an
+	  "on" or "off" variable.  Set it to any value to turn it on and unset
+	  it to turn it off.  This will be used to perform various actions
+	  that are useful when running libpurple inside of Valgrind or similar
+	  programs.  Currently, it keeps plugins in memory, allowing Valgrind
+	  to perform symbol resolution of leak traces at shutdown.
 
 	AIM and ICQ:
 	* Preliminary support for a new authentication scheme called
 	  "clientLogin."
 	* Fixed a bug where your away message sometimes would not get set when
 	  you first sign on.
-	* Make sure links in your away messages show up as links to other people.
+	* Make sure links in your away messages show up as links to other
+	  people.
 	* For ICQ, Never change the privacy setting specified by the user.
 
 	Gadu-Gadu:
@@ -289,15 +1202,16 @@
 	  Topper, and Elliott Sales de Andrade)
 	* Show the invite message for buddies that requested authorization
 	  from you on MSN.
-	* Support sending an invite message to buddies when requesting authorization
-	  from them on MSN.
-	* Timeout switchboard connections aggressively (60 seconds).
+	* Support sending an invite message to buddies when requesting
+	  authorization from them on MSN.
+	* Timeout switchboard connections after 60 seconds (msn-pecan devs).
 
 	XMPP:
-	* Voice & Video support with Jingle (XEP-0166, 0167, 0176, & 0177), voice
-	  support with GTalk and voice and video support with the GMail web
-	  client. (Mike "Maiku" Ruprecht)
-	* Added a Service Discovery Browser plugin for Pidgin. (Andrei Mozzhuhin)
+	* Voice & Video support with Jingle (XEP-0166, 0167, 0176, & 0177),
+	  voice support with GTalk and voice and video support with the GMail
+	  web client. (Mike "Maiku" Ruprecht)
+	* Added a Service Discovery Browser plugin for Pidgin.
+	  (Andrei Mozzhuhin)
 	* Support for in-band bytestreams for file transfers (XEP-0047). (Marcus
 	  Lundblad)
 	* Support for sending and receiving attentions (equivalent to "buzz"
@@ -314,28 +1228,30 @@
 	* Better support for receiving remote users' nicknames.
 	* /affiliate and /role will now list the room members with the specified
 	  affiliation/role if possible. (Andrei Mozzhuhin)
-	* Put section breaks between resources in "Get Info" to improve readability.
-	* Silently remove invalid XML 1.0 entities (e.g. ASCII control characters)
-	  from sent messages.
+	* Put section breaks between resources in "Get Info" to improve
+	  readability.
+	* Silently remove invalid XML 1.0 entities (e.g. ASCII control
+	  characters) from sent messages.
 	* XHTML markup is only included in outgoing messages when the message
 	  contains formatting.
-	* Show when the user was last logged in when doing "Get Info" on an offline
-	  buddy, provided the server supports it.
+	* Show when the user was last logged in when doing "Get Info" on an
+	  offline buddy, provided the server supports it.
 	* Support custom smileys in MUCs (only when all participants support the
-	  "Bits of Binary" extension, and a maximum of 10 participants are in the
-	  chat to avoid getting too many fetch requests).
+	  "Bits of Binary" extension, and a maximum of 10 participants are in
+	  the chat to avoid getting too many fetch requests).
 	* Fix an issue with Jabber (pre-XMPP) servers and the user's preference
 	  to require SSL not being respected.
 	* Fix an issue where Cyrus SASL DIGEST MD5 authentication might fail if
 	  the username, password, or realm (the JID domain) contain non-ASCII
 	  characters.
-	* Show emblem for mobile, handheld, and web clients and bots (if the other
-	  client supports it).
-	* Google Talk mail notifications should now work for people for whom they
-	  inexplicably did not.  (Thanks to yukam for determining the reason)
+	* Show emblem for mobile, handheld, and web clients and bots (if the
+	  other client supports it).
+	* Google Talk mail notifications should now work for people for whom
+	  they inexplicably did not.  (Thanks to yukam for determining the
+	  reason)
 	* New XMPP and Google Talk accounts require SSL by default.
-	* Display kicks (and the reasons given) in chat rooms when an occupant is
-	  kicked.
+	* Display kicks (and the reasons given) in chat rooms when an occupant
+	  is kicked.
 	* Fix issues with case-sensitivity of XMPP roster and case-insensitive
 	  Purple groups.
 	* For contacts who advertise Entity Capabilities, only send rich text
--- a/ChangeLog.API	Thu Jun 16 04:37:03 2011 +0000
+++ b/ChangeLog.API	Sat Aug 06 03:45:56 2011 +0000
@@ -1,12 +1,214 @@
 Pidgin and Finch: The Pimpin' Penguin IM Clients That're Good for the Soul
 
-version 2.6.6 (??/??/2010):
+version 2.9.0:
+	libpurple:
+		Added:
+		* Hash table to PurpleConvChat struct, used to make
+		  purple_conv_chat_cb_find O(1).
+		* ui_data pointer to PurpleConvChatBuddy struct.
+		* deleting-chat-buddy signal (conversation signals)
+		* pidgin_pixbuf_from_data
+		* pidgin_pixbuf_anim_from_data
+		* pidgin_pixbuf_new_from_file
+		* pidgin_pixbuf_new_from_file_at_size
+		* pidgin_pixbuf_new_from_file_at_scale
+
+		Deprecated:
+		* purple_conv_chat_set_users
+		* PurpleConvChat in_room list
+
+version 2.8.0 (06/07/2011):
+	libpurple:
+		Added:
+		* account-authorization-requested-with-message signal (Stefan Ott)
+		  (#8690)
+		* cleared-message-history signal (conversation signals)
+		* purple_account_add_buddy_with_invite
+		* purple_account_add_buddies_with_invite
+		* purple_dnsquery_a_account
+		* purple_notify_user_info_add_pair_plaintext
+		* purple_media_get_active_local_candidates
+		* purple_media_get_active_remote_candidates
+		* purple_media_manager_get_video_caps (Jakub Adam) (#13095)
+		* purple_media_manager_set_video_caps (Jakub Adam) (#13095)
+		* purple_pounce_destroy_all_by_buddy (Kartik Mohta) (#1131)
+		* purple_proxy_connect_socks5_account
+		* purple_srv_resolve_account
+		* purple_txt_resolve_account
+		* Added add_buddy_with_invite to PurplePluginProtocolInfo
+		* Added add_buddies_with_invite to PurplePluginProtocolInfo
+		* Added PurpleSrvTxtQueryUiOps which allow UIs to specify their
+		  own mechanisms to resolve SRV and/or TXT queries. It works
+		  similar to PurpleDnsQueryUiOps
+		* purple_marshal_BOOLEAN__POINTER_BOOLEAN (kawaii.neko) (#12599)
+
+		Deprecated:
+		* purple_account_add_buddy
+		* purple_account_add_buddies_with_invite
+		* purple_dnsquery_a
+		* purple_proxy_connect_socks5
+		* purple_srv_resolve
+		* purple_txt_resolve
+		* add_buddy from PurplePluginProtocolInfo struct
+		* add_buddies from PurplePluginProtocolInfo struct
+
+	Pidgin:
+		Added:
+		* pidgin_make_scrollable (Gabriel Schulhof) (#10599)
+		* chat-nick-clicked signal (kawaii.neko) (#12599)
+		* chat-nick-autocomplete signal (kawaii.neko) (#12599)
+
+version 2.7.11 (03/10/2011):
+	* libpurple:
+		Added:
+		* Four entries in the GHashTable passed when joining
+		  an XMPP chat room which allow the UI to request a limited
+		  amount of history.  See XEP-0045 7.1.16 for details; the
+		  entries are named history_maxchars, history_maxstanzas,
+		  history_seconds, and history_since.  history_since must be
+		  interpretable by purple_str_to_time, and the prpl takes care
+		  of formatting the time properly.
+	* Perl:
+		Added:
+		* Purple::find_conversation_with_account
+		* Purple::Conversation::Chat::send_with_flags
+		* Purple::Conversation::IM::send_with_flags
+
+version 2.7.10 (02/06/2011):
+	* No changes
+
+version 2.7.9 (12/26/2010):
+	* No changes
+
+version 2.7.8 (12/19/2010):
+	* No changes
+
+version 2.7.7 (11/23/2010):
+	* No changes
+
+version 2.7.6 (11/21/2010):
+	* No changes
+
+version 2.7.5 (10/31/2010):
+	* No changes
+
+version 2.7.4 (10/20/2010):
+	Perl:
+		Added:
+		* Purple::BuddyList::Chat::get_components
+
+		Changed:
+		* Purple::BuddyList::Chat::new now works properly.  Thanks
+		  to Rafael in devel@conference.pidgin.im for reporting and
+		  testing.
+
+version 2.7.3 (08/10/2010):
+	libpurple:
+		Fixed:
+		* purple_account_[gs]et_public_alias no longer crash when
+		  called for a protocol that doesn't support the underlying
+		  calls and the caller does not specify a failure callback.
+
+	Perl:
+		Added:
+		* Exposed log-subsystem signals.
+
+	Pidgin:
+		Changed:
+		* Changing the visibility (gtk_widget_hide/show) of
+		  the widgets in the GtkIMHtmlToolbar should now affect
+		  the visibility of the entries in the 'lean' view
+		  (the default toolbar view).
+
+		Deprecated:
+		* pidgin_check_if_dir
+
+	libgnt:
+		Added:
+		* gnt_tree_row_get_key, gnt_tree_row_get_next,
+		  gnt_tree_row_get_prev, gnt_tree_row_get_child and
+		  gnt_tree_row_get_parent.
+
+version 2.7.2 (07/21/2010):
+	* No changes
+
+version 2.7.1 (05/29/2010):
+	* No changes
+
+version 2.7.0 (05/12/2010):
+	libpurple:
+		Added:
+		* Account signals (see account-signals.dox); useful for D-Bus
+		   * account-signed-on
+		   * account-signed-off
+		   * account-connection-error
+		* purple_account_get_name_for_display
+		* purple_account_get_privacy_type
+		* purple_account_get_public_alias
+		* purple_account_set_privacy_type
+		* purple_account_set_public_alias
+		* buddy-caps-changed blist signal
+		* Added media_caps to the PurpleBuddy struct
+		* purple_buddy_get_media_caps
+		* purple_buddy_set_media_caps
+		* purple_certificates_import for importing multiple
+		  certificates from a single file (and corresponding
+		  import_certificates member of PurpleCertificateScheme struct)
+		* autojoin connection signal
+		* purple_contact_get_group
+		* sent-attention conversation signal
+		* got-attention conversation signal
+		* ui-caps-changed media manager signal
+		* purple_media_candidate_copy
+		* purple_media_codec_copy
+		* purple_media_manager_get_backend_type
+		* purple_media_manager_set_backend_type
+		* PurpleMood struct in status.h
+		* purple_network_get_all_local_system_ips, which returns all
+		  local IPs on the system.  On systems with the getifaddrs()
+		  function, this will return both IPv4 and IPv6 addresses
+		  (excluding link-local and loopback addresses).  On others,
+		  it returns just IPv4 addresses.
+		* purple_network_listen_family and
+		  purple_network_listen_range_family.  These will replace the
+		  versions without _family in 3.0.0 and allow the caller to
+		  specifically request either an IPv4 or IPv6 socket.  IPv6 is
+		  only supported if the getaddrinfo() function is available
+		  at build-time (not the case on Windows, currently).
+		* purple_prpl_got_media_caps
+		* purple_request_action_with_icon
+		* purple_request_action_with_icon_varg
+		* purple_socket_get_family
+		* purple_socket_speaks_ipv4
+		* purple_unescape_text
+		* purple_uuid_random
+		* purple_xfer_get_thumbnail
+		* purple_xfer_get_thumbnail_mimetype
+		* purple_xfer_set_thumbnail
+		* purple_xfer_prepare_thumbnail
+
+	Pidgin:
+		Added:
+		* pidgin_dialogs_buildinfo (should not be used by anything but Pidgin)
+		* pidgin_dialogs_developers (should not be used by anything but Pidgin)
+		* pidgin_dialogs_translators (should not be used by anything but Pidgin)
+		* gtk_imhtmltoolbar_switch_active_conversation
+		* 'paste' signal for GtkIMHtml (more in gtkimhtml-signals.dox)
+		* 'drawing-buddy' signal for gtkblist (more in gtkblist-signals.dox)
+
+version 2.6.6 (02/18/2010):
 	libpurple:
 		Changed:
 		* purple_xfer_cancel_local is now called instead of
 		  purple_xfer_request_denied if an error is found when selecting
 		  a file to send. Request denied is still used when a receive
 		  request is not allowed.
+		* xmlnode_from_str now properly handles parsing an attribute which
+		  contain "&lt;br&gt;", which were previously transformed into a
+		  newline character (libxml2 unescapes all entities except
+		  representations of '&', and libpurple's purple_unescape_html
+		  converts "<br>" to a newline).
+
 	Perl:
 		Changed:
 		* Corrected the package names for the PurpleProxyType and
@@ -109,6 +311,7 @@
 		* xmlnode_from_file
 		* xmlnode_get_parent
 		* xmlnode_set_attrib_full
+		* PURPLE_STATUS_MOOD as a new PurpleStatusPrimitive
 
 		Changed:
 		* xmlnode_remove_attrib now removes all attributes with the
@@ -518,7 +721,7 @@
 		* Added gnt_window_set_maximize and gnt_window_get_maximize, and
 		  GntWindowFlags enum.
 
-version 2.2.2 (??/??/????):
+version 2.2.2 (10/23/2007):
 	libpurple:
 		Changed:
 		* The size parameter of purple_util_write_data_to_file_absolute
--- a/ChangeLog.win32	Thu Jun 16 04:37:03 2011 +0000
+++ b/ChangeLog.win32	Sat Aug 06 03:45:56 2011 +0000
@@ -1,5 +1,25 @@
+Starting with Pidgin version 2.7.1, this ChangeLog file will no longer be
+updated.  It will be kept in the source tree for historical reasons only.
 
-version 2.6.6 (??/??/2010):
+version 2.7.1 (05/29/2010):
+	* No changes
+
+version 2.7.0 (05/12/2010):
+	* Updated GTK+ to 2.16.6
+	* Private GTK+ Runtime now used (GTK+ Installer no longer supported)
+	* Minimum required GTK+ version increased to 2.14.7
+	* Windows 95, Windows 98, Windows 98 Second Edition, Windows ME
+	  (Millennium Edition), and Windows NT 4.0 longer supported due to GTK+
+	  requirements changes.
+	* Crash Report files (pidgin.RPT) are now generated in the ~/.purple
+	  directory instead of the installation directory.
+	* NSS SSL Library upgraded to 3.12.5 (thanks to Berke Viktor)
+	* GtkSpell upgraded to 2.0.16, changing the spellchecking backend to
+	  enchant.  This means that myspell and hunspell (OpenOffice)
+	  dictionaries can be used (previous versions' aspell dictionaries
+	  will not work).
+
+version 2.6.6 (02/18/2010):
 	* Installer translations for: Norwegian nynorsk
 
 version 2.6.5 (01/08/2010):
--- a/Doxyfile.in	Thu Jun 16 04:37:03 2011 +0000
+++ b/Doxyfile.in	Sat Aug 06 03:45:56 2011 +0000
@@ -1,4 +1,4 @@
-# Doxyfile 1.5.3
+# Doxyfile 1.7.1
 
 # This file describes the settings to be used by the documentation system
 # doxygen (www.doxygen.org) for a project
@@ -14,175 +14,169 @@
 # Project related configuration options
 #---------------------------------------------------------------------------
 
-# This tag specifies the encoding used for all characters in the config file that 
-# follow. The default is UTF-8 which is also the encoding used for all text before 
-# the first occurrence of this tag. Doxygen uses libiconv (or the iconv built into 
-# libc) for the transcoding. See http://www.gnu.org/software/libiconv for the list of 
-# possible encodings.
+# This tag specifies the encoding used for all characters in the config file
+# that follow. The default is UTF-8 which is also the encoding used for all
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the
+# iconv built into libc) for the transcoding. See
+# http://www.gnu.org/software/libiconv for the list of possible encodings.
 
 DOXYFILE_ENCODING      = UTF-8
 
-# The PROJECT_NAME tag is a single word (or a sequence of words surrounded 
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
 # by quotes) that should identify the project.
 
 PROJECT_NAME           = @PACKAGE@
 
-# The PROJECT_NUMBER tag can be used to enter a project or revision number. 
-# This could be handy for archiving the generated documentation or 
+# The PROJECT_NUMBER tag can be used to enter a project or revision number.
+# This could be handy for archiving the generated documentation or
 # if some version control system is used.
 
 PROJECT_NUMBER         = @VERSION@
 
-# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 
-# base path where the generated documentation will be put. 
-# If a relative path is entered, it will be relative to the location 
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
+# base path where the generated documentation will be put.
+# If a relative path is entered, it will be relative to the location
 # where doxygen was started. If left blank the current directory will be used.
 
 OUTPUT_DIRECTORY       = doc
 
-# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 
-# 4096 sub-directories (in 2 levels) under the output directory of each output 
-# format and will distribute the generated files over these directories. 
-# Enabling this option can be useful when feeding doxygen a huge amount of 
-# source files, where putting all generated files in the same directory would 
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
+# 4096 sub-directories (in 2 levels) under the output directory of each output
+# format and will distribute the generated files over these directories.
+# Enabling this option can be useful when feeding doxygen a huge amount of
+# source files, where putting all generated files in the same directory would
 # otherwise cause performance problems for the file system.
 
 CREATE_SUBDIRS         = NO
 
-# The OUTPUT_LANGUAGE tag is used to specify the language in which all 
-# documentation generated by doxygen is written. Doxygen will use this 
-# information to generate all constant output in the proper language. 
-# The default language is English, other supported languages are: 
-# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, 
-# Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hungarian, 
-# Italian, Japanese, Japanese-en (Japanese with English messages), Korean, 
-# Korean-en, Lithuanian, Norwegian, Polish, Portuguese, Romanian, Russian, 
-# Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian.
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# The default language is English, other supported languages are:
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
+# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,
+# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English
+# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian,
+# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak,
+# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
 
 OUTPUT_LANGUAGE        = English
 
-# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will 
-# include brief member descriptions after the members that are listed in 
-# the file and class documentation (similar to JavaDoc). 
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
+# include brief member descriptions after the members that are listed in
+# the file and class documentation (similar to JavaDoc).
 # Set to NO to disable this.
 
 BRIEF_MEMBER_DESC      = YES
 
-# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend 
-# the brief description of a member or function before the detailed description. 
-# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the 
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
+# the brief description of a member or function before the detailed description.
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
 # brief descriptions will be completely suppressed.
 
 REPEAT_BRIEF           = YES
 
-# This tag implements a quasi-intelligent brief description abbreviator 
-# that is used to form the text in various listings. Each string 
-# in this list, if found as the leading text of the brief description, will be 
-# stripped from the text and the result after processing the whole list, is 
-# used as the annotated text. Otherwise, the brief description is used as-is. 
-# If left blank, the following values are used ("$name" is automatically 
-# replaced with the name of the entity): "The $name class" "The $name widget" 
-# "The $name file" "is" "provides" "specifies" "contains" 
+# This tag implements a quasi-intelligent brief description abbreviator
+# that is used to form the text in various listings. Each string
+# in this list, if found as the leading text of the brief description, will be
+# stripped from the text and the result after processing the whole list, is
+# used as the annotated text. Otherwise, the brief description is used as-is.
+# If left blank, the following values are used ("$name" is automatically
+# replaced with the name of the entity): "The $name class" "The $name widget"
+# "The $name file" "is" "provides" "specifies" "contains"
 # "represents" "a" "an" "the"
 
-ABBREVIATE_BRIEF       = 
+ABBREVIATE_BRIEF       =
 
-# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then 
-# Doxygen will generate a detailed section even if there is only a brief 
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# Doxygen will generate a detailed section even if there is only a brief
 # description.
 
 ALWAYS_DETAILED_SEC    = NO
 
-# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all 
-# inherited members of a class in the documentation of that class as if those 
-# members were ordinary class members. Constructors, destructors and assignment 
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
 # operators of the base classes will not be shown.
 
 INLINE_INHERITED_MEMB  = NO
 
-# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full 
-# path before files name in the file list and in the header files. If set 
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
+# path before files name in the file list and in the header files. If set
 # to NO the shortest path that makes the file name unique will be used.
 
 FULL_PATH_NAMES        = NO
 
-# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag 
-# can be used to strip a user-defined part of the path. Stripping is 
-# only done if one of the specified strings matches the left-hand part of 
-# the path. The tag can be used to show relative paths in the file list. 
-# If left blank the directory from which doxygen is run is used as the 
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
+# can be used to strip a user-defined part of the path. Stripping is
+# only done if one of the specified strings matches the left-hand part of
+# the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the
 # path to strip.
 
-STRIP_FROM_PATH        = 
+STRIP_FROM_PATH        =
 
-# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of 
-# the path mentioned in the documentation of a class, which tells 
-# the reader which header file to include in order to use a class. 
-# If left blank only the name of the header file containing the class 
-# definition is used. Otherwise one should specify the include paths that 
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
+# the path mentioned in the documentation of a class, which tells
+# the reader which header file to include in order to use a class.
+# If left blank only the name of the header file containing the class
+# definition is used. Otherwise one should specify the include paths that
 # are normally passed to the compiler using the -I flag.
 
-STRIP_FROM_INC_PATH    = 
+STRIP_FROM_INC_PATH    =
 
-# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter 
-# (but less readable) file names. This can be useful is your file systems 
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
+# (but less readable) file names. This can be useful is your file systems
 # doesn't support long names like on DOS, Mac, or CD-ROM.
 
 SHORT_NAMES            = NO
 
-# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen 
-# will interpret the first line (until the first dot) of a JavaDoc-style 
-# comment as the brief description. If set to NO, the JavaDoc 
-# comments will behave just like regular Qt-style comments 
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
+# will interpret the first line (until the first dot) of a JavaDoc-style
+# comment as the brief description. If set to NO, the JavaDoc
+# comments will behave just like regular Qt-style comments
 # (thus requiring an explicit @brief command for a brief description.)
 
 JAVADOC_AUTOBRIEF      = YES
 
-# If the QT_AUTOBRIEF tag is set to YES then Doxygen will 
-# interpret the first line (until the first dot) of a Qt-style 
-# comment as the brief description. If set to NO, the comments 
-# will behave just like regular Qt-style comments (thus requiring 
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
+# interpret the first line (until the first dot) of a Qt-style
+# comment as the brief description. If set to NO, the comments
+# will behave just like regular Qt-style comments (thus requiring
 # an explicit \brief command for a brief description.)
 
 QT_AUTOBRIEF           = NO
 
-# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen 
-# treat a multi-line C++ special comment block (i.e. a block of //! or /// 
-# comments) as a brief description. This used to be the default behaviour. 
-# The new default is to treat a multi-line C++ comment block as a detailed 
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
+# treat a multi-line C++ special comment block (i.e. a block of //! or ///
+# comments) as a brief description. This used to be the default behaviour.
+# The new default is to treat a multi-line C++ comment block as a detailed
 # description. Set this tag to YES if you prefer the old behaviour instead.
 
 MULTILINE_CPP_IS_BRIEF = NO
 
-# If the DETAILS_AT_TOP tag is set to YES then Doxygen 
-# will output the detailed description near the top, like JavaDoc.
-# If set to NO, the detailed description appears after the member 
-# documentation.
-
-DETAILS_AT_TOP         = NO
-
-# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented 
-# member inherits the documentation from any documented member that it 
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
+# member inherits the documentation from any documented member that it
 # re-implements.
 
 INHERIT_DOCS           = YES
 
-# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce 
-# a new page for each member. If set to NO, the documentation of a member will 
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
+# a new page for each member. If set to NO, the documentation of a member will
 # be part of the file/class/namespace that contains it.
 
 SEPARATE_MEMBER_PAGES  = NO
 
-# The TAB_SIZE tag can be used to set the number of spaces in a tab. 
+# The TAB_SIZE tag can be used to set the number of spaces in a tab.
 # Doxygen uses this value to replace tabs by spaces in code fragments.
 
 TAB_SIZE               = 4
 
-# This tag can be used to specify a number of aliases that acts 
-# as commands in the documentation. An alias has the form "name=value". 
-# For example adding "sideeffect=\par Side Effects:\n" will allow you to 
-# put the command \sideeffect (or @sideeffect) in the documentation, which 
-# will result in a user-defined paragraph with heading "Side Effects:". 
+# This tag can be used to specify a number of aliases that acts
+# as commands in the documentation. An alias has the form "name=value".
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to
+# put the command \sideeffect (or @sideeffect) in the documentation, which
+# will result in a user-defined paragraph with heading "Side Effects:".
 # You can put \n's in the value part of an alias to insert newlines.
 
 ALIASES                = "signal=- @ref  " \
@@ -195,25 +189,49 @@
                          "endsignals=  " \
                          "constreturn=@note The return value of this function must not be modified or freed. @return  "
 
-# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C 
-# sources only. Doxygen will then generate output that is more tailored for C. 
-# For instance, some of the names that are used will be different. The list 
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
+# sources only. Doxygen will then generate output that is more tailored for C.
+# For instance, some of the names that are used will be different. The list
 # of all members will be omitted, etc.
 
 OPTIMIZE_OUTPUT_FOR_C  = YES
 
-# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java 
-# sources only. Doxygen will then generate output that is more tailored for Java. 
-# For instance, namespaces will be presented as packages, qualified scopes 
-# will look different, etc.
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
+# sources only. Doxygen will then generate output that is more tailored for
+# Java. For instance, namespaces will be presented as packages, qualified
+# scopes will look different, etc.
 
 OPTIMIZE_OUTPUT_JAVA   = NO
 
-# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to 
-# include (a tag file for) the STL sources as input, then you should 
-# set this tag to YES in order to let doxygen match functions declarations and 
-# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. 
-# func(std::string) {}). This also make the inheritance and collaboration 
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
+# sources only. Doxygen will then generate output that is more tailored for
+# Fortran.
+
+OPTIMIZE_FOR_FORTRAN   = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
+# sources. Doxygen will then generate output that is tailored for
+# VHDL.
+
+OPTIMIZE_OUTPUT_VHDL   = NO
+
+# Doxygen selects the parser to use depending on the extension of the files it
+# parses. With this tag you can assign which parser to use for a given extension.
+# Doxygen has a built-in mapping, but you can override or extend it using this
+# tag. The format is ext=language, where ext is a file extension, and language
+# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C,
+# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make
+# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C
+# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions
+# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen.
+
+EXTENSION_MAPPING      =
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
+# to include (a tag file for) the STL sources as input, then you should
+# set this tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
+# func(std::string) {}). This also make the inheritance and collaboration
 # diagrams that involve STL classes more complete and accurate.
 
 BUILTIN_STL_SUPPORT    = NO
@@ -223,266 +241,352 @@
 
 CPP_CLI_SUPPORT        = NO
 
-# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC 
-# tag is set to YES, then doxygen will reuse the documentation of the first 
-# member in the group (if any) for the other members of the group. By default 
+# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
+# Doxygen will parse them like normal C++ but will assume all classes use public
+# instead of private inheritance when no explicit protection keyword is present.
+
+SIP_SUPPORT            = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate getter
+# and setter methods for a property. Setting this option to YES (the default)
+# will make doxygen to replace the get and set methods by a property in the
+# documentation. This will only work if the methods are indeed getting or
+# setting a simple type. If this is not the case, or you want to show the
+# methods anyway, you should set this option to NO.
+
+IDL_PROPERTY_SUPPORT   = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES, then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
 # all members of a group must be documented explicitly.
 
 DISTRIBUTE_GROUP_DOC   = NO
 
-# Set the SUBGROUPING tag to YES (the default) to allow class member groups of 
-# the same type (for instance a group of public functions) to be put as a 
-# subgroup of that type (e.g. under the Public Functions section). Set it to 
-# NO to prevent subgrouping. Alternatively, this can be done per class using 
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
+# the same type (for instance a group of public functions) to be put as a
+# subgroup of that type (e.g. under the Public Functions section). Set it to
+# NO to prevent subgrouping. Alternatively, this can be done per class using
 # the \nosubgrouping command.
 
 SUBGROUPING            = YES
 
+# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
+# is documented as struct, union, or enum with the name of the typedef. So
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
+# with name TypeT. When disabled the typedef will appear as a member of a file,
+# namespace, or class. And the struct will be named TypeS. This can typically
+# be useful for C code in case the coding convention dictates that all compound
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+
+TYPEDEF_HIDES_STRUCT   = NO
+
+# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
+# determine which symbols to keep in memory and which to flush to disk.
+# When the cache is full, less often used symbols will be written to disk.
+# For small to medium size projects (<1000 input files) the default value is
+# probably good enough. For larger projects a too small cache size can cause
+# doxygen to be busy swapping symbols to and from disk most of the time
+# causing a significant performance penality.
+# If the system has enough physical memory increasing the cache will improve the
+# performance by keeping more symbols in memory. Note that the value works on
+# a logarithmic scale so increasing the size by one will rougly double the
+# memory usage. The cache size is given by this formula:
+# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
+# corresponding to a cache size of 2^16 = 65536 symbols
+
+SYMBOL_CACHE_SIZE      = 0
+
 #---------------------------------------------------------------------------
 # Build related configuration options
 #---------------------------------------------------------------------------
 
-# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in 
-# documentation are documented, even if no documentation was available. 
-# Private class members and static file members will be hidden unless 
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
+# documentation are documented, even if no documentation was available.
+# Private class members and static file members will be hidden unless
 # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
 
 EXTRACT_ALL            = NO
 
-# If the EXTRACT_PRIVATE tag is set to YES all private members of a class 
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
 # will be included in the documentation.
 
 EXTRACT_PRIVATE        = NO
 
-# If the EXTRACT_STATIC tag is set to YES all static members of a file 
+# If the EXTRACT_STATIC tag is set to YES all static members of a file
 # will be included in the documentation.
 
 EXTRACT_STATIC         = NO
 
-# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) 
-# defined locally in source files will be included in the documentation. 
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
+# defined locally in source files will be included in the documentation.
 # If set to NO only classes defined in header files are included.
 
 EXTRACT_LOCAL_CLASSES  = YES
 
-# This flag is only useful for Objective-C code. When set to YES local 
-# methods, which are defined in the implementation section but not in 
-# the interface are included in the documentation. 
+# This flag is only useful for Objective-C code. When set to YES local
+# methods, which are defined in the implementation section but not in
+# the interface are included in the documentation.
 # If set to NO (the default) only methods in the interface are included.
 
 EXTRACT_LOCAL_METHODS  = YES
 
-# If this flag is set to YES, the members of anonymous namespaces will be extracted 
-# and appear in the documentation as a namespace called 'anonymous_namespace{file}', 
-# where file will be replaced with the base name of the file that contains the anonymous 
-# namespace. By default anonymous namespace are hidden.
+# If this flag is set to YES, the members of anonymous namespaces will be
+# extracted and appear in the documentation as a namespace called
+# 'anonymous_namespace{file}', where file will be replaced with the base
+# name of the file that contains the anonymous namespace. By default
+# anonymous namespace are hidden.
 
 EXTRACT_ANON_NSPACES   = NO
 
-# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all 
-# undocumented members of documented classes, files or namespaces. 
-# If set to NO (the default) these members will be included in the 
-# various overviews, but no documentation section is generated. 
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
+# undocumented members of documented classes, files or namespaces.
+# If set to NO (the default) these members will be included in the
+# various overviews, but no documentation section is generated.
 # This option has no effect if EXTRACT_ALL is enabled.
 
 HIDE_UNDOC_MEMBERS     = NO
 
-# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all 
-# undocumented classes that are normally visible in the class hierarchy. 
-# If set to NO (the default) these classes will be included in the various 
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy.
+# If set to NO (the default) these classes will be included in the various
 # overviews. This option has no effect if EXTRACT_ALL is enabled.
 
 HIDE_UNDOC_CLASSES     = NO
 
-# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all 
-# friend (class|struct|union) declarations. 
-# If set to NO (the default) these declarations will be included in the 
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
+# friend (class|struct|union) declarations.
+# If set to NO (the default) these declarations will be included in the
 # documentation.
 
 HIDE_FRIEND_COMPOUNDS  = NO
 
-# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any 
-# documentation blocks found inside the body of a function. 
-# If set to NO (the default) these blocks will be appended to the 
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
+# documentation blocks found inside the body of a function.
+# If set to NO (the default) these blocks will be appended to the
 # function's detailed documentation block.
 
 HIDE_IN_BODY_DOCS      = NO
 
-# The INTERNAL_DOCS tag determines if documentation 
-# that is typed after a \internal command is included. If the tag is set 
-# to NO (the default) then the documentation will be excluded. 
+# The INTERNAL_DOCS tag determines if documentation
+# that is typed after a \internal command is included. If the tag is set
+# to NO (the default) then the documentation will be excluded.
 # Set it to YES to include the internal documentation.
 
 INTERNAL_DOCS          = NO
 
-# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate 
-# file names in lower-case letters. If set to YES upper-case letters are also 
-# allowed. This is useful if you have classes or files whose names only differ 
-# in case and if your file system supports case sensitive file names. Windows 
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
+# file names in lower-case letters. If set to YES upper-case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
 # and Mac users are advised to set this option to NO.
 
 CASE_SENSE_NAMES       = YES
 
-# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen 
-# will show members with their full class and namespace scopes in the 
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
+# will show members with their full class and namespace scopes in the
 # documentation. If set to YES the scope will be hidden.
 
 HIDE_SCOPE_NAMES       = NO
 
-# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen 
-# will put a list of the files that are included by a file in the documentation 
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
+# will put a list of the files that are included by a file in the documentation
 # of that file.
 
 SHOW_INCLUDE_FILES     = YES
 
-# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] 
+# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen
+# will list include files with double quotes in the documentation
+# rather than with sharp brackets.
+
+FORCE_LOCAL_INCLUDES   = NO
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
 # is inserted in the documentation for inline members.
 
 INLINE_INFO            = YES
 
-# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen 
-# will sort the (detailed) documentation of file and class members 
-# alphabetically by member name. If set to NO the members will appear in 
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
+# will sort the (detailed) documentation of file and class members
+# alphabetically by member name. If set to NO the members will appear in
 # declaration order.
 
 SORT_MEMBER_DOCS       = YES
 
-# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the 
-# brief documentation of file, namespace and class members alphabetically 
-# by member name. If set to NO (the default) the members will appear in 
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
+# brief documentation of file, namespace and class members alphabetically
+# by member name. If set to NO (the default) the members will appear in
 # declaration order.
 
 SORT_BRIEF_DOCS        = NO
 
-# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be 
-# sorted by fully-qualified names, including namespaces. If set to 
-# NO (the default), the class list will be sorted only by class name, 
-# not including the namespace part. 
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen
+# will sort the (brief and detailed) documentation of class members so that
+# constructors and destructors are listed first. If set to NO (the default)
+# the constructors will appear in the respective orders defined by
+# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS.
+# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO
+# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
+
+SORT_MEMBERS_CTORS_1ST = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
+# hierarchy of group names into alphabetical order. If set to NO (the default)
+# the group names will appear in their defined order.
+
+SORT_GROUP_NAMES       = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
+# sorted by fully-qualified names, including namespaces. If set to
+# NO (the default), the class list will be sorted only by class name,
+# not including the namespace part.
 # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
-# Note: This option applies only to the class list, not to the 
+# Note: This option applies only to the class list, not to the
 # alphabetical list.
 
 SORT_BY_SCOPE_NAME     = YES
 
-# The GENERATE_TODOLIST tag can be used to enable (YES) or 
-# disable (NO) the todo list. This list is created by putting \todo 
+# The GENERATE_TODOLIST tag can be used to enable (YES) or
+# disable (NO) the todo list. This list is created by putting \todo
 # commands in the documentation.
 
 GENERATE_TODOLIST      = YES
 
-# The GENERATE_TESTLIST tag can be used to enable (YES) or 
-# disable (NO) the test list. This list is created by putting \test 
+# The GENERATE_TESTLIST tag can be used to enable (YES) or
+# disable (NO) the test list. This list is created by putting \test
 # commands in the documentation.
 
 GENERATE_TESTLIST      = YES
 
-# The GENERATE_BUGLIST tag can be used to enable (YES) or 
-# disable (NO) the bug list. This list is created by putting \bug 
+# The GENERATE_BUGLIST tag can be used to enable (YES) or
+# disable (NO) the bug list. This list is created by putting \bug
 # commands in the documentation.
 
 GENERATE_BUGLIST       = YES
 
-# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or 
-# disable (NO) the deprecated list. This list is created by putting 
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
+# disable (NO) the deprecated list. This list is created by putting
 # \deprecated commands in the documentation.
 
 GENERATE_DEPRECATEDLIST= YES
 
-# The ENABLED_SECTIONS tag can be used to enable conditional 
+# The ENABLED_SECTIONS tag can be used to enable conditional
 # documentation sections, marked by \if sectionname ... \endif.
 
-ENABLED_SECTIONS       = 
+ENABLED_SECTIONS       =
 
-# The MAX_INITIALIZER_LINES tag determines the maximum number of lines 
-# the initial value of a variable or define consists of for it to appear in 
-# the documentation. If the initializer consists of more lines than specified 
-# here it will be hidden. Use a value of 0 to hide initializers completely. 
-# The appearance of the initializer of individual variables and defines in the 
-# documentation can be controlled using \showinitializer or \hideinitializer 
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
+# the initial value of a variable or define consists of for it to appear in
+# the documentation. If the initializer consists of more lines than specified
+# here it will be hidden. Use a value of 0 to hide initializers completely.
+# The appearance of the initializer of individual variables and defines in the
+# documentation can be controlled using \showinitializer or \hideinitializer
 # command in the documentation regardless of this setting.
 
 MAX_INITIALIZER_LINES  = 30
 
-# Set the SHOW_USED_FILES tag to NO to disable the list of files generated 
-# at the bottom of the documentation of classes and structs. If set to YES the 
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
+# at the bottom of the documentation of classes and structs. If set to YES the
 # list will mention the files that were used to generate the documentation.
 
 SHOW_USED_FILES        = YES
 
-# If the sources in your project are distributed over multiple directories 
-# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy 
+# If the sources in your project are distributed over multiple directories
+# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
 # in the documentation. The default is NO.
 
 SHOW_DIRECTORIES       = YES
 
-# The FILE_VERSION_FILTER tag can be used to specify a program or script that 
-# doxygen should invoke to get the current version for each file (typically from the 
-# version control system). Doxygen will invoke the program by executing (via 
-# popen()) the command <command> <input-file>, where <command> is the value of 
-# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file 
-# provided by doxygen. Whatever the program writes to standard output 
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
+# This will remove the Files entry from the Quick Index and from the
+# Folder Tree View (if specified). The default is YES.
+
+SHOW_FILES             = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the
+# Namespaces page.
+# This will remove the Namespaces entry from the Quick Index
+# and from the Folder Tree View (if specified). The default is YES.
+
+SHOW_NAMESPACES        = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from
+# the version control system). Doxygen will invoke the program by executing (via
+# popen()) the command <command> <input-file>, where <command> is the value of
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
+# provided by doxygen. Whatever the program writes to standard output
 # is used as the file version. See the manual for examples.
 
-FILE_VERSION_FILTER    = 
+FILE_VERSION_FILTER    =
+
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed
+# by doxygen. The layout file controls the global structure of the generated
+# output files in an output format independent way. The create the layout file
+# that represents doxygen's defaults, run doxygen with the -l option.
+# You can optionally specify a file name after the option, if omitted
+# DoxygenLayout.xml will be used as the name of the layout file.
+
+LAYOUT_FILE            =
 
 #---------------------------------------------------------------------------
 # configuration options related to warning and progress messages
 #---------------------------------------------------------------------------
 
-# The QUIET tag can be used to turn on/off the messages that are generated 
+# The QUIET tag can be used to turn on/off the messages that are generated
 # by doxygen. Possible values are YES and NO. If left blank NO is used.
 
 QUIET                  = NO
 
-# The WARNINGS tag can be used to turn on/off the warning messages that are 
-# generated by doxygen. Possible values are YES and NO. If left blank 
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated by doxygen. Possible values are YES and NO. If left blank
 # NO is used.
 
 WARNINGS               = YES
 
-# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings 
-# for undocumented members. If EXTRACT_ALL is set to YES then this flag will 
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
 # automatically be disabled.
 
 WARN_IF_UNDOCUMENTED   = NO
 
-# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for 
-# potential errors in the documentation, such as not documenting some 
-# parameters in a documented function, or documenting parameters that 
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some
+# parameters in a documented function, or documenting parameters that
 # don't exist or using markup commands wrongly.
 
 WARN_IF_DOC_ERROR      = YES
 
-# This WARN_NO_PARAMDOC option can be abled to get warnings for 
-# functions that are documented, but have no documentation for their parameters 
-# or return value. If set to NO (the default) doxygen will only warn about 
-# wrong or incomplete parameter documentation, but not about the absence of 
+# This WARN_NO_PARAMDOC option can be abled to get warnings for
+# functions that are documented, but have no documentation for their parameters
+# or return value. If set to NO (the default) doxygen will only warn about
+# wrong or incomplete parameter documentation, but not about the absence of
 # documentation.
 
 WARN_NO_PARAMDOC       = YES
 
-# The WARN_FORMAT tag determines the format of the warning messages that 
-# doxygen can produce. The string should contain the $file, $line, and $text 
-# tags, which will be replaced by the file and line number from which the 
-# warning originated and the warning text. Optionally the format may contain 
-# $version, which will be replaced by the version of the file (if it could 
+# The WARN_FORMAT tag determines the format of the warning messages that
+# doxygen can produce. The string should contain the $file, $line, and $text
+# tags, which will be replaced by the file and line number from which the
+# warning originated and the warning text. Optionally the format may contain
+# $version, which will be replaced by the version of the file (if it could
 # be obtained via FILE_VERSION_FILTER)
 
 WARN_FORMAT            = "$file:$line: $text  "
 
-# The WARN_LOGFILE tag can be used to specify a file to which warning 
-# and error messages should be written. If left blank the output is written 
+# The WARN_LOGFILE tag can be used to specify a file to which warning
+# and error messages should be written. If left blank the output is written
 # to stderr.
 
-WARN_LOGFILE           = 
+WARN_LOGFILE           =
 
 #---------------------------------------------------------------------------
 # configuration options related to the input files
 #---------------------------------------------------------------------------
 
-# The INPUT tag can be used to specify the files and/or directories that contain 
-# documented source files. You may enter file names like "myfile.cpp" or 
-# directories like "/usr/src/myproject". Separate the files or directories 
+# The INPUT tag can be used to specify the files and/or directories that contain
+# documented source files. You may enter file names like "myfile.cpp" or
+# directories like "/usr/src/myproject". Separate the files or directories
 # with spaces.
 
 INPUT                  = @top_srcdir@/libpurple \
@@ -491,104 +595,109 @@
                          @top_srcdir@/pidgin \
                          @top_srcdir@/doc
 
-# This tag can be used to specify the character encoding of the source files that 
-# doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default 
-# input encoding. Doxygen uses libiconv (or the iconv built into libc) for the transcoding. 
-# See http://www.gnu.org/software/libiconv for the list of possible encodings.
+# This tag can be used to specify the character encoding of the source files
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
+# also the default input encoding. Doxygen uses libiconv (or the iconv built
+# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
+# the list of possible encodings.
 
 INPUT_ENCODING         = UTF-8
 
-# If the value of the INPUT tag contains directories, you can use the 
-# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
-# and *.h) to filter out the source-files in the directories. If left 
-# blank the following patterns are tested: 
-# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx 
-# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank the following patterns are tested:
+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
+# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
 
 FILE_PATTERNS          = *.h \
                          *.dox
 
-# The RECURSIVE tag can be used to turn specify whether or not subdirectories 
-# should be searched for input files as well. Possible values are YES and NO. 
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories
+# should be searched for input files as well. Possible values are YES and NO.
 # If left blank NO is used.
 
 RECURSIVE              = NO
 
-# The EXCLUDE tag can be used to specify files and/or directories that should 
-# excluded from the INPUT source files. This way you can easily exclude a 
+# The EXCLUDE tag can be used to specify files and/or directories that should
+# excluded from the INPUT source files. This way you can easily exclude a
 # subdirectory from a directory tree whose root is specified with the INPUT tag.
 
 EXCLUDE                = libpurple/purple-client.h \
                          libpurple/purple-client-bindings.h
 
-# The EXCLUDE_SYMLINKS tag can be used select whether or not files or 
-# directories that are symbolic links (a Unix filesystem feature) are excluded 
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
+# directories that are symbolic links (a Unix filesystem feature) are excluded
 # from the input.
 
 EXCLUDE_SYMLINKS       = NO
 
-# If the value of the INPUT tag contains directories, you can use the 
-# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude 
-# certain files from those directories. Note that the wildcards are matched 
-# against the file with absolute path, so to exclude all test directories 
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories. Note that the wildcards are matched
+# against the file with absolute path, so to exclude all test directories
 # for example use the pattern */test/*
 
-EXCLUDE_PATTERNS       = 
+EXCLUDE_PATTERNS       =
 
-# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names 
-# (namespaces, classes, functions, etc.) that should be excluded from the output. 
-# The symbol name can be a fully qualified name, a word, or if the wildcard * is used, 
-# a substring. Examples: ANamespace, AClass, AClass::ANamespace, ANamespace::*Test
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
+# (namespaces, classes, functions, etc.) that should be excluded from the
+# output. The symbol name can be a fully qualified name, a word, or if the
+# wildcard * is used, a substring. Examples: ANamespace, AClass,
+# AClass::ANamespace, ANamespace::*Test
 
-EXCLUDE_SYMBOLS        = 
+EXCLUDE_SYMBOLS        =
 
-# The EXAMPLE_PATH tag can be used to specify one or more files or 
-# directories that contain example code fragments that are included (see 
+# The EXAMPLE_PATH tag can be used to specify one or more files or
+# directories that contain example code fragments that are included (see
 # the \include command).
 
-EXAMPLE_PATH           = 
+EXAMPLE_PATH           =
 
-# If the value of the EXAMPLE_PATH tag contains directories, you can use the 
-# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
-# and *.h) to filter out the source-files in the directories. If left 
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
 # blank all files are included.
 
-EXAMPLE_PATTERNS       = 
+EXAMPLE_PATTERNS       =
 
-# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be 
-# searched for input files to be used with the \include or \dontinclude 
-# commands irrespective of the value of the RECURSIVE tag. 
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
+# searched for input files to be used with the \include or \dontinclude
+# commands irrespective of the value of the RECURSIVE tag.
 # Possible values are YES and NO. If left blank NO is used.
 
 EXAMPLE_RECURSIVE      = NO
 
-# The IMAGE_PATH tag can be used to specify one or more files or 
-# directories that contain image that are included in the documentation (see 
+# The IMAGE_PATH tag can be used to specify one or more files or
+# directories that contain image that are included in the documentation (see
 # the \image command).
 
-IMAGE_PATH             = 
+IMAGE_PATH             =
 
-# The INPUT_FILTER tag can be used to specify a program that doxygen should 
-# invoke to filter for each input file. Doxygen will invoke the filter program 
-# by executing (via popen()) the command <filter> <input-file>, where <filter> 
-# is the value of the INPUT_FILTER tag, and <input-file> is the name of an 
-# input file. Doxygen will then use the output that the filter program writes 
-# to standard output.  If FILTER_PATTERNS is specified, this tag will be 
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command <filter> <input-file>, where <filter>
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
+# input file. Doxygen will then use the output that the filter program writes
+# to standard output.
+# If FILTER_PATTERNS is specified, this tag will be
 # ignored.
 
-INPUT_FILTER           = 
+INPUT_FILTER           =
 
-# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern 
-# basis.  Doxygen will compare the file name with each pattern and apply the 
-# filter if there is a match.  The filters are a list of the form: 
-# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further 
-# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER 
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
+# basis.
+# Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match.
+# The filters are a list of the form:
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
+# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
 # is applied to all files.
 
-FILTER_PATTERNS        = 
+FILTER_PATTERNS        =
 
-# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using 
-# INPUT_FILTER) will be used to filter the input files when producing source 
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER) will be used to filter the input files when producing source
 # files to browse (i.e. when SOURCE_BROWSER is set to YES).
 
 FILTER_SOURCE_FILES    = NO
@@ -597,34 +706,32 @@
 # configuration options related to source browsing
 #---------------------------------------------------------------------------
 
-# If the SOURCE_BROWSER tag is set to YES then a list of source files will 
-# be generated. Documented entities will be cross-referenced with these sources. 
-# Note: To get rid of all source code in the generated output, make sure also 
-# VERBATIM_HEADERS is set to NO. If you have enabled CALL_GRAPH or CALLER_GRAPH 
-# then you must also enable this option. If you don't then doxygen will produce 
-# a warning and turn it on anyway
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will
+# be generated. Documented entities will be cross-referenced with these sources.
+# Note: To get rid of all source code in the generated output, make sure also
+# VERBATIM_HEADERS is set to NO.
 
 SOURCE_BROWSER         = YES
 
-# Setting the INLINE_SOURCES tag to YES will include the body 
+# Setting the INLINE_SOURCES tag to YES will include the body
 # of functions and classes directly in the documentation.
 
 INLINE_SOURCES         = NO
 
-# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct 
-# doxygen to hide any special comment blocks from generated source code 
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
+# doxygen to hide any special comment blocks from generated source code
 # fragments. Normal C and C++ comments will always remain visible.
 
 STRIP_CODE_COMMENTS    = YES
 
-# If the REFERENCED_BY_RELATION tag is set to YES (the default) 
-# then for each documented function all documented 
+# If the REFERENCED_BY_RELATION tag is set to YES
+# then for each documented function all documented
 # functions referencing it will be listed.
 
 REFERENCED_BY_RELATION = YES
 
-# If the REFERENCES_RELATION tag is set to YES (the default) 
-# then for each documented function all documented entities 
+# If the REFERENCES_RELATION tag is set to YES
+# then for each documented function all documented entities
 # called/used by that function will be listed.
 
 REFERENCES_RELATION    = YES
@@ -632,20 +739,21 @@
 # If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
 # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
 # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
-# link to the source code.  Otherwise they will link to the documentstion.
+# link to the source code.
+# Otherwise they will link to the documentation.
 
 REFERENCES_LINK_SOURCE = YES
 
-# If the USE_HTAGS tag is set to YES then the references to source code 
-# will point to the HTML generated by the htags(1) tool instead of doxygen 
-# built-in source browser. The htags tool is part of GNU's global source 
-# tagging system (see http://www.gnu.org/software/global/global.html). You 
+# If the USE_HTAGS tag is set to YES then the references to source code
+# will point to the HTML generated by the htags(1) tool instead of doxygen
+# built-in source browser. The htags tool is part of GNU's global source
+# tagging system (see http://www.gnu.org/software/global/global.html). You
 # will need version 4.8.6 or higher.
 
 USE_HTAGS              = NO
 
-# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen 
-# will generate a verbatim copy of the header file for each class for 
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
+# will generate a verbatim copy of the header file for each class for
 # which an include is specified. Set to NO to disable this.
 
 VERBATIM_HEADERS       = YES
@@ -654,21 +762,21 @@
 # configuration options related to the alphabetical class index
 #---------------------------------------------------------------------------
 
-# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index 
-# of all compounds will be generated. Enable this if the project 
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
+# of all compounds will be generated. Enable this if the project
 # contains a lot of classes, structs, unions or interfaces.
 
 ALPHABETICAL_INDEX     = YES
 
-# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then 
-# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns 
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
 # in which this list will be split (can be a number in the range [1..20])
 
 COLS_IN_ALPHA_INDEX    = 3
 
-# In case all classes in a project start with a common prefix, all 
-# classes will be put under the same header in the alphabetical index. 
-# The IGNORE_PREFIX tag can be used to specify one or more prefixes that 
+# In case all classes in a project start with a common prefix, all
+# classes will be put under the same header in the alphabetical index.
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
 # should be ignored while generating the index headers.
 
 IGNORE_PREFIX          = Purple \
@@ -679,264 +787,465 @@
 # configuration options related to the HTML output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_HTML tag is set to YES (the default) Doxygen will 
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
 # generate HTML output.
 
 GENERATE_HTML          = YES
 
-# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
 # put in front of it. If left blank `html' will be used as the default path.
 
 HTML_OUTPUT            = html
 
-# The HTML_FILE_EXTENSION tag can be used to specify the file extension for 
-# each generated HTML page (for example: .htm,.php,.asp). If it is left blank 
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
 # doxygen will generate files with .html extension.
 
 HTML_FILE_EXTENSION    = .html
 
-# The HTML_HEADER tag can be used to specify a personal HTML header for 
-# each generated HTML page. If it is left blank doxygen will generate a 
+# The HTML_HEADER tag can be used to specify a personal HTML header for
+# each generated HTML page. If it is left blank doxygen will generate a
 # standard header.
 
 HTML_HEADER            = @top_srcdir@/doc/TracHeader.html
 
-# The HTML_FOOTER tag can be used to specify a personal HTML footer for 
-# each generated HTML page. If it is left blank doxygen will generate a 
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for
+# each generated HTML page. If it is left blank doxygen will generate a
 # standard footer.
 
 HTML_FOOTER            = @top_srcdir@/doc/TracFooter.html
 
-# The HTML_STYLESHEET tag can be used to specify a user-defined cascading 
-# style sheet that is used by each HTML page. It can be used to 
-# fine-tune the look of the HTML output. If the tag is left blank doxygen 
-# will generate a default style sheet. Note that doxygen will try to copy 
-# the style sheet file to the HTML output directory, so don't put your own 
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
+# style sheet that is used by each HTML page. It can be used to
+# fine-tune the look of the HTML output. If the tag is left blank doxygen
+# will generate a default style sheet. Note that doxygen will try to copy
+# the style sheet file to the HTML output directory, so don't put your own
 # stylesheet in the HTML output directory as well, or it will be erased!
 
-HTML_STYLESHEET        = 
+HTML_STYLESHEET        =
+
+# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output.
+# Doxygen will adjust the colors in the stylesheet and background images
+# according to this color. Hue is specified as an angle on a colorwheel,
+# see http://en.wikipedia.org/wiki/Hue for more information.
+# For instance the value 0 represents red, 60 is yellow, 120 is green,
+# 180 is cyan, 240 is blue, 300 purple, and 360 is red again.
+# The allowed range is 0 to 359.
+
+HTML_COLORSTYLE_HUE    = 220
+
+# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of
+# the colors in the HTML output. For a value of 0 the output will use
+# grayscales only. A value of 255 will produce the most vivid colors.
+
+HTML_COLORSTYLE_SAT    = 100
 
-# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, 
-# files or namespaces will be aligned in HTML using tables. If set to 
+# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to
+# the luminance component of the colors in the HTML output. Values below
+# 100 gradually make the output lighter, whereas values above 100 make
+# the output darker. The value divided by 100 is the actual gamma applied,
+# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2,
+# and 100 does not change the gamma.
+
+HTML_COLORSTYLE_GAMMA  = 80
+
+# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
+# page will contain the date and time when the page was generated. Setting
+# this to NO can help when comparing the output of multiple runs.
+
+HTML_TIMESTAMP         = YES
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
+# files or namespaces will be aligned in HTML using tables. If set to
 # NO a bullet list will be used.
 
 HTML_ALIGN_MEMBERS     = YES
 
-# If the GENERATE_HTMLHELP tag is set to YES, additional index files 
-# will be generated that can be used as input for tools like the 
-# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) 
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
+# documentation will contain sections that can be hidden and shown after the
+# page has loaded. For this to work a browser that supports
+# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox
+# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
+
+HTML_DYNAMIC_SECTIONS  = NO
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files
+# will be generated that can be used as input for Apple's Xcode 3
+# integrated development environment, introduced with OSX 10.5 (Leopard).
+# To create a documentation set, doxygen will generate a Makefile in the
+# HTML output directory. Running make will produce the docset in that
+# directory and running "make install" will install the docset in
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
+# it at startup.
+# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html
+# for more information.
+
+GENERATE_DOCSET        = NO
+
+# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
+# feed. A documentation feed provides an umbrella under which multiple
+# documentation sets from a single provider (such as a company or product suite)
+# can be grouped.
+
+DOCSET_FEEDNAME        = "Doxygen generated docs"
+
+# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
+# should uniquely identify the documentation set bundle. This should be a
+# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
+# will append .docset to the name.
+
+DOCSET_BUNDLE_ID       = org.doxygen.Project
+
+# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify
+# the documentation publisher. This should be a reverse domain-name style
+# string, e.g. com.mycompany.MyDocSet.documentation.
+
+DOCSET_PUBLISHER_ID    = org.doxygen.Publisher
+
+# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher.
+
+DOCSET_PUBLISHER_NAME  = Publisher
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files
+# will be generated that can be used as input for tools like the
+# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
 # of the generated HTML documentation.
 
 GENERATE_HTMLHELP      = YES
 
-# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML 
-# documentation will contain sections that can be hidden and shown after the 
-# page has loaded. For this to work a browser that supports 
-# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox 
-# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
-
-HTML_DYNAMIC_SECTIONS  = NO
-
-# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can 
-# be used to specify the file name of the resulting .chm file. You 
-# can add a path in front of the file if the result should not be 
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
+# be used to specify the file name of the resulting .chm file. You
+# can add a path in front of the file if the result should not be
 # written to the html output directory.
 
-CHM_FILE               = 
+CHM_FILE               =
 
-# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can 
-# be used to specify the location (absolute path including file name) of 
-# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run 
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
+# be used to specify the location (absolute path including file name) of
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
 # the HTML help compiler on the generated index.hhp.
 
-HHC_LOCATION           = 
+HHC_LOCATION           =
 
-# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag 
-# controls if a separate .chi index file is generated (YES) or that 
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
+# controls if a separate .chi index file is generated (YES) or that
 # it should be included in the master .chm file (NO).
 
 GENERATE_CHI           = NO
 
-# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag 
-# controls whether a binary table of contents is generated (YES) or a 
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
+# is used to encode HtmlHelp index (hhk), content (hhc) and project file
+# content.
+
+CHM_INDEX_ENCODING     =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
+# controls whether a binary table of contents is generated (YES) or a
 # normal table of contents (NO) in the .chm file.
 
 BINARY_TOC             = NO
 
-# The TOC_EXPAND flag can be set to YES to add extra items for group members 
+# The TOC_EXPAND flag can be set to YES to add extra items for group members
 # to the contents of the HTML help documentation and to the tree view.
 
 TOC_EXPAND             = YES
 
-# The DISABLE_INDEX tag can be used to turn on/off the condensed index at 
-# top of each HTML page. The value NO (the default) enables the index and 
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and
+# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated
+# that can be used as input for Qt's qhelpgenerator to generate a
+# Qt Compressed Help (.qch) of the generated HTML documentation.
+
+GENERATE_QHP           = NO
+
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can
+# be used to specify the file name of the resulting .qch file.
+# The path specified is relative to the HTML output folder.
+
+QCH_FILE               =
+
+# The QHP_NAMESPACE tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#namespace
+
+QHP_NAMESPACE          = org.doxygen.Project
+
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#virtual-folders
+
+QHP_VIRTUAL_FOLDER     = doc
+
+# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to
+# add. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#custom-filters
+
+QHP_CUST_FILTER_NAME   =
+
+# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the
+# custom filter to add. For more information please see
+# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">
+# Qt Help Project / Custom Filters</a>.
+
+QHP_CUST_FILTER_ATTRS  =
+
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
+# project's
+# filter section matches.
+# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">
+# Qt Help Project / Filter Attributes</a>.
+
+QHP_SECT_FILTER_ATTRS  =
+
+# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
+# be used to specify the location of Qt's qhelpgenerator.
+# If non-empty doxygen will try to run qhelpgenerator on the generated
+# .qhp file.
+
+QHG_LOCATION           =
+
+# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files
+#  will be generated, which together with the HTML files, form an Eclipse help
+# plugin. To install this plugin and make it available under the help contents
+# menu in Eclipse, the contents of the directory containing the HTML and XML
+# files needs to be copied into the plugins directory of eclipse. The name of
+# the directory within the plugins directory should be the same as
+# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before
+# the help appears.
+
+GENERATE_ECLIPSEHELP   = NO
+
+# A unique identifier for the eclipse help plugin. When installing the plugin
+# the directory name containing the HTML and XML files should also have
+# this name.
+
+ECLIPSE_DOC_ID         = org.doxygen.Project
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
+# top of each HTML page. The value NO (the default) enables the index and
 # the value YES disables it.
 
 DISABLE_INDEX          = NO
 
-# This tag can be used to set the number of enum values (range [1..20]) 
+# This tag can be used to set the number of enum values (range [1..20])
 # that doxygen will group on one line in the generated HTML documentation.
 
 ENUM_VALUES_PER_LINE   = 4
 
-# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
-# generated containing a tree-like index structure (just like the one that 
-# is generated for HTML Help). For this to work a browser that supports 
-# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, 
-# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are 
-# probably better off using the HTML help feature.
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
+# structure should be generated to display hierarchical information.
+# If the tag value is set to YES, a side panel will be generated
+# containing a tree-like index structure (just like the one that
+# is generated for HTML Help). For this to work a browser that supports
+# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser).
+# Windows users are probably better off using the HTML help feature.
 
 GENERATE_TREEVIEW      = YES
 
-# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be 
-# used to set the initial width (in pixels) of the frame in which the tree 
+# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories,
+# and Class Hierarchy pages using a tree view instead of an ordered list.
+
+USE_INLINE_TREES       = NO
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
+# used to set the initial width (in pixels) of the frame in which the tree
 # is shown.
 
 TREEVIEW_WIDTH         = 250
 
+# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open
+# links to external symbols imported via tag files in a separate window.
+
+EXT_LINKS_IN_WINDOW    = NO
+
+# Use this tag to change the font size of Latex formulas included
+# as images in the HTML documentation. The default is 10. Note that
+# when you change the font size after a successful doxygen run you need
+# to manually remove any form_*.png images from the HTML output directory
+# to force them to be regenerated.
+
+FORMULA_FONTSIZE       = 10
+
+# Use the FORMULA_TRANPARENT tag to determine whether or not the images
+# generated for formulas are transparent PNGs. Transparent PNGs are
+# not supported properly for IE 6.0, but are supported on all modern browsers.
+# Note that when changing this option you need to delete any form_*.png files
+# in the HTML output before the changes have effect.
+
+FORMULA_TRANSPARENT    = YES
+
+# When the SEARCHENGINE tag is enabled doxygen will generate a search box
+# for the HTML output. The underlying search engine uses javascript
+# and DHTML and should work on any modern browser. Note that when using
+# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets
+# (GENERATE_DOCSET) there is already a search function so this one should
+# typically be disabled. For large projects the javascript based search engine
+# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution.
+
+SEARCHENGINE           = YES
+
+# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
+# implemented using a PHP enabled web server instead of at the web client
+# using Javascript. Doxygen will generate the search PHP script and index
+# file to put on the web server. The advantage of the server
+# based approach is that it scales better to large projects and allows
+# full text search. The disadvances is that it is more difficult to setup
+# and does not have live searching capabilities.
+
+SERVER_BASED_SEARCH    = NO
+
 #---------------------------------------------------------------------------
 # configuration options related to the LaTeX output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will 
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
 # generate Latex output.
 
 GENERATE_LATEX         = NO
 
-# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
 # put in front of it. If left blank `latex' will be used as the default path.
 
 LATEX_OUTPUT           = latex
 
-# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be 
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
 # invoked. If left blank `latex' will be used as the default command name.
+# Note that when enabling USE_PDFLATEX this option is only used for
+# generating bitmaps for formulas in the HTML output, but not in the
+# Makefile that is written to the output directory.
 
 LATEX_CMD_NAME         = latex
 
-# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to 
-# generate index for LaTeX. If left blank `makeindex' will be used as the 
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
+# generate index for LaTeX. If left blank `makeindex' will be used as the
 # default command name.
 
 MAKEINDEX_CMD_NAME     = makeindex
 
-# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact 
-# LaTeX documents. This may be useful for small projects and may help to 
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
+# LaTeX documents. This may be useful for small projects and may help to
 # save some trees in general.
 
 COMPACT_LATEX          = NO
 
-# The PAPER_TYPE tag can be used to set the paper type that is used 
-# by the printer. Possible values are: a4, a4wide, letter, legal and 
+# The PAPER_TYPE tag can be used to set the paper type that is used
+# by the printer. Possible values are: a4, a4wide, letter, legal and
 # executive. If left blank a4wide will be used.
 
 PAPER_TYPE             = a4wide
 
-# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX 
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
 # packages that should be included in the LaTeX output.
 
-EXTRA_PACKAGES         = 
+EXTRA_PACKAGES         =
 
-# The LATEX_HEADER tag can be used to specify a personal LaTeX header for 
-# the generated latex document. The header should contain everything until 
-# the first chapter. If it is left blank doxygen will generate a 
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
+# the generated latex document. The header should contain everything until
+# the first chapter. If it is left blank doxygen will generate a
 # standard header. Notice: only use this tag if you know what you are doing!
 
-LATEX_HEADER           = 
+LATEX_HEADER           =
 
-# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated 
-# is prepared for conversion to pdf (using ps2pdf). The pdf file will 
-# contain links (just like the HTML output) instead of page references 
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will
+# contain links (just like the HTML output) instead of page references
 # This makes the output suitable for online browsing using a pdf viewer.
 
 PDF_HYPERLINKS         = NO
 
-# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of 
-# plain latex in the generated Makefile. Set this option to YES to get a 
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
+# plain latex in the generated Makefile. Set this option to YES to get a
 # higher quality PDF documentation.
 
 USE_PDFLATEX           = NO
 
-# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. 
-# command to the generated LaTeX files. This will instruct LaTeX to keep 
-# running if errors occur, instead of asking the user for help. 
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
+# command to the generated LaTeX files. This will instruct LaTeX to keep
+# running if errors occur, instead of asking the user for help.
 # This option is also used when generating formulas in HTML.
 
 LATEX_BATCHMODE        = NO
 
-# If LATEX_HIDE_INDICES is set to YES then doxygen will not 
-# include the index chapters (such as File Index, Compound Index, etc.) 
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not
+# include the index chapters (such as File Index, Compound Index, etc.)
 # in the output.
 
 LATEX_HIDE_INDICES     = NO
 
+# If LATEX_SOURCE_CODE is set to YES then doxygen will include
+# source code with syntax highlighting in the LaTeX output.
+# Note that which sources are shown also depends on other settings
+# such as SOURCE_BROWSER.
+
+LATEX_SOURCE_CODE      = NO
+
 #---------------------------------------------------------------------------
 # configuration options related to the RTF output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output 
-# The RTF output is optimized for Word 97 and may not look very pretty with 
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
+# The RTF output is optimized for Word 97 and may not look very pretty with
 # other RTF readers or editors.
 
 GENERATE_RTF           = NO
 
-# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
 # put in front of it. If left blank `rtf' will be used as the default path.
 
 RTF_OUTPUT             = rtf
 
-# If the COMPACT_RTF tag is set to YES Doxygen generates more compact 
-# RTF documents. This may be useful for small projects and may help to 
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
+# RTF documents. This may be useful for small projects and may help to
 # save some trees in general.
 
 COMPACT_RTF            = NO
 
-# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated 
-# will contain hyperlink fields. The RTF file will 
-# contain links (just like the HTML output) instead of page references. 
-# This makes the output suitable for online browsing using WORD or other 
-# programs which support those fields. 
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
+# will contain hyperlink fields. The RTF file will
+# contain links (just like the HTML output) instead of page references.
+# This makes the output suitable for online browsing using WORD or other
+# programs which support those fields.
 # Note: wordpad (write) and others do not support links.
 
 RTF_HYPERLINKS         = NO
 
-# Load stylesheet definitions from file. Syntax is similar to doxygen's 
-# config file, i.e. a series of assignments. You only have to provide 
+# Load stylesheet definitions from file. Syntax is similar to doxygen's
+# config file, i.e. a series of assignments. You only have to provide
 # replacements, missing definitions are set to their default value.
 
-RTF_STYLESHEET_FILE    = 
+RTF_STYLESHEET_FILE    =
 
-# Set optional variables used in the generation of an rtf document. 
+# Set optional variables used in the generation of an rtf document.
 # Syntax is similar to doxygen's config file.
 
-RTF_EXTENSIONS_FILE    = 
+RTF_EXTENSIONS_FILE    =
 
 #---------------------------------------------------------------------------
 # configuration options related to the man page output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_MAN tag is set to YES (the default) Doxygen will 
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
 # generate man pages
 
 GENERATE_MAN           = NO
 
-# The MAN_OUTPUT tag is used to specify where the man pages will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# The MAN_OUTPUT tag is used to specify where the man pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
 # put in front of it. If left blank `man' will be used as the default path.
 
 MAN_OUTPUT             = man
 
-# The MAN_EXTENSION tag determines the extension that is added to 
+# The MAN_EXTENSION tag determines the extension that is added to
 # the generated man pages (default is the subroutine's section .3)
 
 MAN_EXTENSION          = .3
 
-# If the MAN_LINKS tag is set to YES and Doxygen generates man output, 
-# then it will generate one additional man file for each entity 
-# documented in the real man page(s). These additional files 
-# only source the real man page, but without them the man command 
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
+# then it will generate one additional man file for each entity
+# documented in the real man page(s). These additional files
+# only source the real man page, but without them the man command
 # would be unable to find the correct page. The default is NO.
 
 MAN_LINKS              = NO
@@ -945,33 +1254,33 @@
 # configuration options related to the XML output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_XML tag is set to YES Doxygen will 
-# generate an XML file that captures the structure of 
+# If the GENERATE_XML tag is set to YES Doxygen will
+# generate an XML file that captures the structure of
 # the code including all documentation.
 
 GENERATE_XML           = YES
 
-# The XML_OUTPUT tag is used to specify where the XML pages will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# The XML_OUTPUT tag is used to specify where the XML pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
 # put in front of it. If left blank `xml' will be used as the default path.
 
 XML_OUTPUT             = xml
 
-# The XML_SCHEMA tag can be used to specify an XML schema, 
-# which can be used by a validating XML parser to check the 
+# The XML_SCHEMA tag can be used to specify an XML schema,
+# which can be used by a validating XML parser to check the
 # syntax of the XML files.
 
-XML_SCHEMA             = 
+XML_SCHEMA             =
 
-# The XML_DTD tag can be used to specify an XML DTD, 
-# which can be used by a validating XML parser to check the 
+# The XML_DTD tag can be used to specify an XML DTD,
+# which can be used by a validating XML parser to check the
 # syntax of the XML files.
 
-XML_DTD                = 
+XML_DTD                =
 
-# If the XML_PROGRAMLISTING tag is set to YES Doxygen will 
-# dump the program listings (including syntax highlighting 
-# and cross-referencing information) to the XML output. Note that 
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
+# dump the program listings (including syntax highlighting
+# and cross-referencing information) to the XML output. Note that
 # enabling this will significantly increase the size of the XML output.
 
 XML_PROGRAMLISTING     = YES
@@ -980,10 +1289,10 @@
 # configuration options for the AutoGen Definitions output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will 
-# generate an AutoGen Definitions (see autogen.sf.net) file 
-# that captures the structure of the code including all 
-# documentation. Note that this feature is still experimental 
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
+# generate an AutoGen Definitions (see autogen.sf.net) file
+# that captures the structure of the code including all
+# documentation. Note that this feature is still experimental
 # and incomplete at the moment.
 
 GENERATE_AUTOGEN_DEF   = NO
@@ -992,319 +1301,346 @@
 # configuration options related to the Perl module output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_PERLMOD tag is set to YES Doxygen will 
-# generate a Perl module file that captures the structure of 
-# the code including all documentation. Note that this 
-# feature is still experimental and incomplete at the 
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will
+# generate a Perl module file that captures the structure of
+# the code including all documentation. Note that this
+# feature is still experimental and incomplete at the
 # moment.
 
 GENERATE_PERLMOD       = NO
 
-# If the PERLMOD_LATEX tag is set to YES Doxygen will generate 
-# the necessary Makefile rules, Perl scripts and LaTeX code to be able 
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able
 # to generate PDF and DVI output from the Perl module output.
 
 PERLMOD_LATEX          = NO
 
-# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be 
-# nicely formatted so it can be parsed by a human reader.  This is useful 
-# if you want to understand what is going on.  On the other hand, if this 
-# tag is set to NO the size of the Perl module output will be much smaller 
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
+# nicely formatted so it can be parsed by a human reader.
+# This is useful
+# if you want to understand what is going on.
+# On the other hand, if this
+# tag is set to NO the size of the Perl module output will be much smaller
 # and Perl will parse it just the same.
 
 PERLMOD_PRETTY         = YES
 
-# The names of the make variables in the generated doxyrules.make file 
-# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. 
-# This is useful so different doxyrules.make files included by the same 
+# The names of the make variables in the generated doxyrules.make file
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
+# This is useful so different doxyrules.make files included by the same
 # Makefile don't overwrite each other's variables.
 
-PERLMOD_MAKEVAR_PREFIX = 
+PERLMOD_MAKEVAR_PREFIX =
 
 #---------------------------------------------------------------------------
-# Configuration options related to the preprocessor   
+# Configuration options related to the preprocessor
 #---------------------------------------------------------------------------
 
-# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will 
-# evaluate all C-preprocessor directives found in the sources and include 
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
+# evaluate all C-preprocessor directives found in the sources and include
 # files.
 
 ENABLE_PREPROCESSING   = YES
 
-# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro 
-# names in the source code. If set to NO (the default) only conditional 
-# compilation will be performed. Macro expansion can be done in a controlled 
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
+# names in the source code. If set to NO (the default) only conditional
+# compilation will be performed. Macro expansion can be done in a controlled
 # way by setting EXPAND_ONLY_PREDEF to YES.
 
 MACRO_EXPANSION        = NO
 
-# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES 
-# then the macro expansion is limited to the macros specified with the 
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
+# then the macro expansion is limited to the macros specified with the
 # PREDEFINED and EXPAND_AS_DEFINED tags.
 
 EXPAND_ONLY_PREDEF     = NO
 
-# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files 
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
 # in the INCLUDE_PATH (see below) will be search if a #include is found.
 
 SEARCH_INCLUDES        = YES
 
-# The INCLUDE_PATH tag can be used to specify one or more directories that 
-# contain include files that are not input files but should be processed by 
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by
 # the preprocessor.
 
-INCLUDE_PATH           = 
+INCLUDE_PATH           =
 
-# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard 
-# patterns (like *.h and *.hpp) to filter out the header-files in the 
-# directories. If left blank, the patterns specified with FILE_PATTERNS will 
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will
 # be used.
 
-INCLUDE_FILE_PATTERNS  = 
+INCLUDE_FILE_PATTERNS  =
 
-# The PREDEFINED tag can be used to specify one or more macro names that 
-# are defined before the preprocessor is started (similar to the -D option of 
-# gcc). The argument of the tag is a list of macros of the form: name 
-# or name=definition (no spaces). If the definition and the = are 
-# omitted =1 is assumed. To prevent a macro definition from being 
-# undefined via #undef or recursively expanded use the := operator 
+# The PREDEFINED tag can be used to specify one or more macro names that
+# are defined before the preprocessor is started (similar to the -D option of
+# gcc). The argument of the tag is a list of macros of the form: name
+# or name=definition (no spaces). If the definition and the = are
+# omitted =1 is assumed. To prevent a macro definition from being
+# undefined via #undef or recursively expanded use the := operator
 # instead of the = operator.
 
-PREDEFINED             = 
+PREDEFINED             =
 
-# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then 
-# this tag can be used to specify a list of macro names that should be expanded. 
-# The macro definition that is found in the sources will be used. 
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
+# this tag can be used to specify a list of macro names that should be expanded.
+# The macro definition that is found in the sources will be used.
 # Use the PREDEFINED tag if you want to use a different macro definition.
 
-EXPAND_AS_DEFINED      = 
+EXPAND_AS_DEFINED      =
 
-# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then 
-# doxygen's preprocessor will remove all function-like macros that are alone 
-# on a line, have an all uppercase name, and do not end with a semicolon. Such 
-# function macros are typically used for boiler-plate code, and will confuse 
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
+# doxygen's preprocessor will remove all function-like macros that are alone
+# on a line, have an all uppercase name, and do not end with a semicolon. Such
+# function macros are typically used for boiler-plate code, and will confuse
 # the parser if not removed.
 
 SKIP_FUNCTION_MACROS   = YES
 
 #---------------------------------------------------------------------------
-# Configuration::additions related to external references   
+# Configuration::additions related to external references
 #---------------------------------------------------------------------------
 
-# The TAGFILES option can be used to specify one or more tagfiles. 
-# Optionally an initial location of the external documentation 
-# can be added for each tagfile. The format of a tag file without 
-# this location is as follows: 
-#   TAGFILES = file1 file2 ... 
-# Adding location for the tag files is done as follows: 
-#   TAGFILES = file1=loc1 "file2 = loc2" ... 
-# where "loc1" and "loc2" can be relative or absolute paths or 
-# URLs. If a location is present for each tag, the installdox tool 
+# The TAGFILES option can be used to specify one or more tagfiles.
+# Optionally an initial location of the external documentation
+# can be added for each tagfile. The format of a tag file without
+# this location is as follows:
+#
+# TAGFILES = file1 file2 ...
+# Adding location for the tag files is done as follows:
+#
+# TAGFILES = file1=loc1 "file2 = loc2" ...
+# where "loc1" and "loc2" can be relative or absolute paths or
+# URLs. If a location is present for each tag, the installdox tool
 # does not have to be run to correct the links.
 # Note that each tag file must have a unique name
 # (where the name does NOT include the path)
-# If a tag file is not located in the directory in which doxygen 
+# If a tag file is not located in the directory in which doxygen
 # is run, you must also specify the path to the tagfile here.
 
-TAGFILES               = 
+TAGFILES               =
 
-# When a file name is specified after GENERATE_TAGFILE, doxygen will create 
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create
 # a tag file that is based on the input files it reads.
 
-GENERATE_TAGFILE       = 
+GENERATE_TAGFILE       =
 
-# If the ALLEXTERNALS tag is set to YES all external classes will be listed 
-# in the class index. If set to NO only the inherited external classes 
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed
+# in the class index. If set to NO only the inherited external classes
 # will be listed.
 
 ALLEXTERNALS           = NO
 
-# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed 
-# in the modules index. If set to NO, only the current project's groups will 
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will
 # be listed.
 
 EXTERNAL_GROUPS        = YES
 
-# The PERL_PATH should be the absolute path and name of the perl script 
+# The PERL_PATH should be the absolute path and name of the perl script
 # interpreter (i.e. the result of `which perl').
 
 PERL_PATH              = /usr/bin/perl
 
 #---------------------------------------------------------------------------
-# Configuration options related to the dot tool   
+# Configuration options related to the dot tool
 #---------------------------------------------------------------------------
 
-# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will 
-# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base 
-# or super classes. Setting the tag to NO turns the diagrams off. Note that 
-# this option is superseded by the HAVE_DOT option below. This is only a 
-# fallback. It is recommended to install and use dot, since it yields more 
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
+# or super classes. Setting the tag to NO turns the diagrams off. Note that
+# this option is superseded by the HAVE_DOT option below. This is only a
+# fallback. It is recommended to install and use dot, since it yields more
 # powerful graphs.
 
 CLASS_DIAGRAMS         = YES
 
-# You can define message sequence charts within doxygen comments using the \msc 
-# command. Doxygen will then run the mscgen tool (see http://www.mcternan.me.uk/mscgen/) to 
-# produce the chart and insert it in the documentation. The MSCGEN_PATH tag allows you to 
-# specify the directory where the mscgen tool resides. If left empty the tool is assumed to 
-# be found in the default search path.
+# You can define message sequence charts within doxygen comments using the \msc
+# command. Doxygen will then run the mscgen tool (see
+# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where
+# the mscgen tool resides. If left empty the tool is assumed to be found in the
+# default search path.
 
-MSCGEN_PATH            = 
+MSCGEN_PATH            =
 
-# If set to YES, the inheritance and collaboration graphs will hide 
-# inheritance and usage relations if the target is undocumented 
+# If set to YES, the inheritance and collaboration graphs will hide
+# inheritance and usage relations if the target is undocumented
 # or is not a class.
 
 HIDE_UNDOC_RELATIONS   = YES
 
-# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is 
-# available from the path. This tool is part of Graphviz, a graph visualization 
-# toolkit from AT&T and Lucent Bell Labs. The other options in this section 
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz, a graph visualization
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section
 # have no effect if this option is set to NO (the default)
 
 HAVE_DOT               = @enable_dot@
 
-# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen 
-# will generate a graph for each documented class showing the direct and 
-# indirect inheritance relations. Setting this tag to YES will force the 
+# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is
+# allowed to run in parallel. When set to 0 (the default) doxygen will
+# base this on the number of processors available in the system. You can set it
+# explicitly to a value larger than 0 to get control over the balance
+# between CPU load and processing speed.
+
+DOT_NUM_THREADS        = 0
+
+# By default doxygen will write a font called FreeSans.ttf to the output
+# directory and reference it in all dot files that doxygen generates. This
+# font does not include all possible unicode characters however, so when you need
+# these (or just want a differently looking font) you can specify the font name
+# using DOT_FONTNAME. You need need to make sure dot is able to find the font,
+# which can be done by putting it in a standard location or by setting the
+# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory
+# containing the font.
+
+DOT_FONTNAME           = FreeSans.ttf
+
+# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
+# The default size is 10pt.
+
+DOT_FONTSIZE           = 10
+
+# By default doxygen will tell dot to use the output directory to look for the
+# FreeSans.ttf font (which doxygen will put there itself). If you specify a
+# different font using DOT_FONTNAME you can set the path where dot
+# can find it using this tag.
+
+DOT_FONTPATH           =
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect inheritance relations. Setting this tag to YES will force the
 # the CLASS_DIAGRAMS tag to NO.
 
 CLASS_GRAPH            = YES
 
-# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen 
-# will generate a graph for each documented class showing the direct and 
-# indirect implementation dependencies (inheritance, containment, and 
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect implementation dependencies (inheritance, containment, and
 # class references variables) of the class with other documented classes.
 
 COLLABORATION_GRAPH    = YES
 
-# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen 
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
 # will generate a graph for groups, showing the direct groups dependencies
 
 GROUP_GRAPHS           = YES
 
-# If the UML_LOOK tag is set to YES doxygen will generate inheritance and 
-# collaboration diagrams in a style similar to the OMG's Unified Modeling 
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
+# collaboration diagrams in a style similar to the OMG's Unified Modeling
 # Language.
 
 UML_LOOK               = YES
 
-# If set to YES, the inheritance and collaboration graphs will show the 
+# If set to YES, the inheritance and collaboration graphs will show the
 # relations between templates and their instances.
 
 TEMPLATE_RELATIONS     = YES
 
-# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT 
-# tags are set to YES then doxygen will generate a graph for each documented 
-# file showing the direct and indirect include dependencies of the file with 
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
+# tags are set to YES then doxygen will generate a graph for each documented
+# file showing the direct and indirect include dependencies of the file with
 # other documented files.
 
 INCLUDE_GRAPH          = YES
 
-# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and 
-# HAVE_DOT tags are set to YES then doxygen will generate a graph for each 
-# documented header file showing the documented files that directly or 
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
+# documented header file showing the documented files that directly or
 # indirectly include this file.
 
 INCLUDED_BY_GRAPH      = YES
 
-# If the CALL_GRAPH, SOURCE_BROWSER and HAVE_DOT tags are set to YES then doxygen will 
-# generate a call dependency graph for every global function or class method. 
-# Note that enabling this option will significantly increase the time of a run. 
-# So in most cases it will be better to enable call graphs for selected 
-# functions only using the \callgraph command.
+# If the CALL_GRAPH and HAVE_DOT options are set to YES then
+# doxygen will generate a call dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable call graphs
+# for selected functions only using the \callgraph command.
 
 CALL_GRAPH             = YES
 
-# If the CALLER_GRAPH, SOURCE_BROWSER and HAVE_DOT tags are set to YES then doxygen will 
-# generate a caller dependency graph for every global function or class method. 
-# Note that enabling this option will significantly increase the time of a run. 
-# So in most cases it will be better to enable caller graphs for selected 
-# functions only using the \callergraph command.
+# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
+# doxygen will generate a caller dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable caller
+# graphs for selected functions only using the \callergraph command.
 
 CALLER_GRAPH           = NO
 
-# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen 
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
 # will graphical hierarchy of all classes instead of a textual one.
 
 GRAPHICAL_HIERARCHY    = YES
 
-# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES 
-# then doxygen will show the dependencies a directory has on other directories 
+# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
+# then doxygen will show the dependencies a directory has on other directories
 # in a graphical way. The dependency relations are determined by the #include
 # relations between the files in the directories.
 
 DIRECTORY_GRAPH        = YES
 
-# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images 
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
 # generated by dot. Possible values are png, jpg, or gif
 # If left blank png will be used.
 
 DOT_IMAGE_FORMAT       = png
 
-# The tag DOT_PATH can be used to specify the path where the dot tool can be 
+# The tag DOT_PATH can be used to specify the path where the dot tool can be
 # found. If left blank, it is assumed the dot tool can be found in the path.
 
-DOT_PATH               = 
+DOT_PATH               =
 
-# The DOTFILE_DIRS tag can be used to specify one or more directories that 
-# contain dot files that are included in the documentation (see the 
+# The DOTFILE_DIRS tag can be used to specify one or more directories that
+# contain dot files that are included in the documentation (see the
 # \dotfile command).
 
-DOTFILE_DIRS           = 
+DOTFILE_DIRS           =
 
-# The MAX_DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of 
-# nodes that will be shown in the graph. If the number of nodes in a graph 
-# becomes larger than this value, doxygen will truncate the graph, which is 
-# visualized by representing a node as a red box. Note that doxygen if the number 
-# of direct children of the root node in a graph is already larger than 
-# MAX_DOT_GRAPH_NOTES then the graph will not be shown at all. Also note 
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
+# nodes that will be shown in the graph. If the number of nodes in a graph
+# becomes larger than this value, doxygen will truncate the graph, which is
+# visualized by representing a node as a red box. Note that doxygen if the
+# number of direct children of the root node in a graph is already larger than
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
 # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
 
 DOT_GRAPH_MAX_NODES    = 50
 
-# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the 
-# graphs generated by dot. A depth value of 3 means that only nodes reachable 
-# from the root by following a path via at most 3 edges will be shown. Nodes 
-# that lay further from the root node will be omitted. Note that setting this 
-# option to 1 or 2 may greatly reduce the computation time needed for large 
-# code bases. Also note that the size of a graph can be further restricted by 
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
+# graphs generated by dot. A depth value of 3 means that only nodes reachable
+# from the root by following a path via at most 3 edges will be shown. Nodes
+# that lay further from the root node will be omitted. Note that setting this
+# option to 1 or 2 may greatly reduce the computation time needed for large
+# code bases. Also note that the size of a graph can be further restricted by
 # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
 
 MAX_DOT_GRAPH_DEPTH    = 2
 
-# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent 
-# background. This is disabled by default, which results in a white background. 
-# Warning: Depending on the platform used, enabling this option may lead to 
-# badly anti-aliased labels on the edges of a graph (i.e. they become hard to 
-# read).
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
+# background. This is disabled by default, because dot on Windows does not
+# seem to support this out of the box. Warning: Depending on the platform used,
+# enabling this option may lead to badly anti-aliased labels on the edges of
+# a graph (i.e. they become hard to read).
 
 DOT_TRANSPARENT        = NO
 
-# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output 
-# files in one run (i.e. multiple -o and -T options on the command line). This 
-# makes dot run faster, but since only newer versions of dot (>1.8.10) 
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
+# files in one run (i.e. multiple -o and -T options on the command line). This
+# makes dot run faster, but since only newer versions of dot (>1.8.10)
 # support this, this feature is disabled by default.
 
 DOT_MULTI_TARGETS      = YES
 
-# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will 
-# generate a legend page explaining the meaning of the various boxes and 
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
+# generate a legend page explaining the meaning of the various boxes and
 # arrows in the dot generated graphs.
 
 GENERATE_LEGEND        = YES
 
-# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will 
-# remove the intermediate dot files that are used to generate 
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
+# remove the intermediate dot files that are used to generate
 # the various graphs.
 
 DOT_CLEANUP            = YES
-
-#---------------------------------------------------------------------------
-# Configuration::additions related to the search engine   
-#---------------------------------------------------------------------------
-
-# The SEARCHENGINE tag specifies whether or not a search engine should be 
-# used. If set to NO the values of all tags below this one will be ignored.
-
-SEARCHENGINE           = YES
--- a/Makefile.am	Thu Jun 16 04:37:03 2011 +0000
+++ b/Makefile.am	Sat Aug 06 03:45:56 2011 +0000
@@ -55,7 +55,6 @@
 
 # For all releases, check the ChangeLogs.
 	head ChangeLog | grep "^version $(PACKAGE_VERSION) (`date +%m/%d/%Y`):$$" >/dev/null
-	head ChangeLog.win32 | grep "^version $(PACKAGE_VERSION) (`date +%m/%d/%Y`):$$" >/dev/null
 	head po/ChangeLog | grep "^version $(PACKAGE_VERSION)$$" >/dev/null
 
 # Ensure we're working from a tag...
@@ -71,11 +70,20 @@
 	gpg --verify pidgin-$(PACKAGE_VERSION).tar.gz.asc pidgin-$(PACKAGE_VERSION).tar.gz
 	gpg --verify pidgin-$(PACKAGE_VERSION).tar.bz2.asc pidgin-$(PACKAGE_VERSION).tar.bz2
 
+if INSTALL_I18N
+PO_DIR=po
+DESKTOP_FILE=pidgin.desktop
+
 if ENABLE_GTK
 appsdir = $(datadir)/applications
 apps_in_files = pidgin.desktop.in
 apps_DATA = $(apps_in_files:.desktop.in=.desktop)
 @INTLTOOL_DESKTOP_RULE@
+endif #ENABLE_GTK
+
+endif #INSTALL_I18N
+
+if ENABLE_GTK
 GTK_DIR=pidgin
 endif
 
@@ -83,10 +91,6 @@
 GNT_DIR=finch
 endif
 
-if INSTALL_I18N
-PO_DIR=po
-endif
-
 # This is phony, so that we always try to rebuild it.  If it succeeds
 # in calculating changes, it produces its target; otherwise, its
 # target does not exist.
@@ -95,18 +99,18 @@
 # creates, and also make sure that the shell command exits
 # successfully; the rm -f ensures both
 package_revision_raw.txt:
-	REAL_BLDDIR=$$PWD/$(top_builddir); \
+	$(AM_V_GEN)REAL_BLDDIR=$$PWD/$(top_builddir); \
 	(cd $(srcdir) && $$REAL_BLDDIR/mtn --root=. automate get_base_revision_id) 2>/dev/null >$@ \
 	|| (cd $(srcdir) && mtn --root=. automate get_base_revision_id) 2>/dev/null >$@ \
 	|| rm -f $@
 package_revision.h: package_revision_raw.txt
-	if test -f $<; then \
+	$(AM_V_GEN)if test -f $<; then \
 	  echo "#define REVISION \"`cat $<`\"" > $@; \
 	fi
-	if test ! -f $@ -a -f $(srcdir)/$@; then \
+	$(AM_V_at)if test ! -f $@ -a -f $(srcdir)/$@; then \
 	  cp $(srcdir)/$@ $@; \
 	fi
-	test -f $@ || echo "#define REVISION \"unknown\"" > $@
+	$(AM_V_at)test -f $@ || echo "#define REVISION \"unknown\"" > $@
 
 # This is a magic directive copy-and-pasted, then modified, from the
 # automake 1.9 manual, section 13.4, "Checking the distribution".
@@ -131,7 +135,7 @@
 if HAVE_XSLTPROC
 	@echo "Generating devhelp index..."
 	@xsltproc $(top_srcdir)/doxy2devhelp.xsl doc/xml/index.xml > doc/html/pidgin.devhelp
-	@echo "(Symlink doc/html to ~/.local/share/gtk-doc/html/pidgin to make devhelp see the documentation)"
+	@echo "(Symlink $$(pwd)/doc/html to ~/.local/share/gtk-doc/html/pidgin to make devhelp see the documentation)"
 else
 	@echo "Not generating devhelp index: xsltproc was not found by configure"
 endif
@@ -146,5 +150,5 @@
 distuninstallcheck_listfiles = \
 	find . -type f -print | grep -v perl | grep -v Purple.3pm
 
-DISTCLEANFILES= pidgin.desktop libpurple/gconf/purple.schemas intltool-extract \
+DISTCLEANFILES= $(DESKTOP_FILE) libpurple/gconf/purple.schemas intltool-extract \
 			intltool-merge intltool-update
--- a/Makefile.mingw	Thu Jun 16 04:37:03 2011 +0000
+++ b/Makefile.mingw	Sat Aug 06 03:45:56 2011 +0000
@@ -31,31 +31,34 @@
     exit; \
 }' VERSION)
 
-GTK_INSTALL_VERSION = $(shell \
-  source ../gtk_installer/version.sh; \
-  echo $$gtk_version \
-)
+GTK_INSTALL_VERSION = 2.16.6.0
 
 STRIPPED_RELEASE_DIR = $(PIDGIN_TREE_TOP)/pidgin-$(PIDGIN_VERSION)-win32bin
+DEBUG_SYMBOLS_DIR = $(PIDGIN_TREE_TOP)/pidgin-$(PIDGIN_VERSION)-dbgsym
 
 
 # Any *.dll or *.exe files included in win32-install-dir that we don't compile
 # should be included in this list so they don't get stripped
 EXTERNAL_DLLS = \
 	comerr32.dll \
+	exchndl.dll \
 	freebl3.dll \
 	gssapi32.dll \
 	k5sprt32.dll \
 	krb5_32.dll \
-	libgtkspell.dll \
+	libenchant.dll \
+	libenchant_ispell.dll \
+	libenchant_myspell.dll \
+	libgtkspell-0.dll \
 	libmeanwhile-1.dll \
+	libnspr4.dll \
+	libplc4.dll \
+	libplds4.dll \
 	libsasl.dll \
-	libxml2.dll \
-	nspr4.dll \
+	libxml2-2.dll \
 	nss3.dll \
 	nssckbi.dll \
-	plc4.dll \
-	plds4.dll \
+	nssutil3.dll \
 	saslANONYMOUS.dll \
 	saslCRAMMD5.dll \
 	saslDIGESTMD5.dll \
@@ -66,12 +69,15 @@
 	libsilcclient-1-1-2.dll \
 	smime3.dll \
 	softokn3.dll \
+	sqlite3.dll \
 	ssl3.dll
 
 #build an expression for `find` to use to ignore the above files
 EXTERNAL_DLLS_FIND_EXP = $(patsubst %,-o -name %,$(EXTERNAL_DLLS))
 
-.PHONY: all docs install installer installer_nogtk installer_debug installers clean uninstall create_release_install_dir
+include $(PIDGIN_COMMON_RULES)
+
+.PHONY: all docs install installer installer_offline installer_zip debug_symbols_zip installers clean uninstall create_release_install_dir generate_installer_includes $(PIDGIN_REVISION_H) $(PIDGIN_REVISION_RAW_TXT)
 
 all: $(PIDGIN_CONFIG_H) $(PIDGIN_REVISION_H)
 	$(MAKE) -C $(PURPLE_TOP) -f $(MINGW_MAKEFILE)
@@ -88,33 +94,74 @@
 endif
 	$(MAKE) -C share/ca-certs -f $(MINGW_MAKEFILE) install
 	$(MAKE) -C share/sounds -f $(MINGW_MAKEFILE) install
+	mkdir -p $(PIDGIN_INSTALL_DIR)/spellcheck
+	cp $(GTKSPELL_TOP)/bin/libgtkspell-0.dll $(PIDGIN_INSTALL_DIR)/spellcheck
+	cp $(ENCHANT_TOP)/bin/libenchant.dll $(PIDGIN_INSTALL_DIR)/spellcheck
+	cp -R $(ENCHANT_TOP)/lib $(PIDGIN_INSTALL_DIR)/spellcheck
+	cp $(WIN32_DEV_TOP)/pidgin-inst-deps-20100315/exchndl.dll $(PIDGIN_INSTALL_DIR)
+
+pidgin/win32/nsis/gtk-runtime-$(GTK_BUNDLE_VERSION).zip:
+	pidgin/win32/nsis/generate_gtk_zip.sh `pwd`
+
+generate_installer_includes: create_release_install_dir pidgin/win32/nsis/gtk-runtime-$(GTK_BUNDLE_VERSION).zip debug_symbols_zip $(PIDGIN_TREE_TOP)/pidgin/win32/nsis/nsis_translations.desktop
+	rm -f pidgin/win32/nsis/pidgin-translations.nsh pidgin/win32/nsis/pidgin-spellcheck.nsh pidgin/win32/nsis/pidgin-spellcheck-preselect.nsh
+	find $(STRIPPED_RELEASE_DIR)/locale -maxdepth 1 -mindepth 1 \
+	 -exec basename {} ';' \
+	 | LC_ALL=C sort | sed -e s/^/\!insertmacro\ LANG_SECTION\ \"/ -e s/$$/\"/ \
+	 > pidgin/win32/nsis/pidgin-translations.nsh
+	#Convert the available.lst lines to "!insertmacro SPELLCHECK_SECTION lang lang_name lang_file"
+	sed -e "/^#/d" -e "s/^[^,]\{1,\},[^,]\{1,\},/\"/" \
+	 -e "s/,/\"\ \"/" -e "s/,/\"\ \"/" -e "s/[\ \t]*$$/\"/" \
+	 -e "s/^/\!insertmacro\ SPELLCHECK_SECTION\ /" \
+         pidgin/win32/nsis/available.lst \
+         > pidgin/win32/nsis/pidgin-spellcheck.nsh
+	#Convert the lines to "!insertmacro CHECK_SPELLCHECK_SECTION lang"
+	iconv -f latin1 -t utf-8 pidgin/win32/nsis/pidgin-spellcheck.nsh | \
+	 sed -e "s/SPELLCHECK_SECTION/CHECK_SPELLCHECK_SECTION/" \
+	 -e "s/ \"[^\"]*\"\ \"[^\"]*\"[\t\ ]*$$//" | \
+         iconv -f utf-8 -t latin1 \
+        > pidgin/win32/nsis/pidgin-spellcheck-preselect.nsh
+	#Generate the Installer translations
+	echo "!define GCOMPRIS_NSIS_INCLUDE_PATH \".\"" > $(PIDGIN_TREE_TOP)/pidgin/win32/nsis/langmacros.nsh
+	echo "@INSERT_TRANSLATIONS@" >> $(PIDGIN_TREE_TOP)/pidgin/win32/nsis/langmacros.nsh
+	$(PERL) $(PIDGIN_TREE_TOP)/pidgin/win32/nsis/create_nsis_translations.pl \
+		$(PIDGIN_TREE_TOP)/pidgin/win32/nsis/nsis_translations.desktop \
+		$(PIDGIN_TREE_TOP)/pidgin/win32/nsis/langmacros.nsh \
+		$(PIDGIN_TREE_TOP)/pidgin/win32/nsis/translations
 
 create_release_install_dir: install
 	rm -rf $(STRIPPED_RELEASE_DIR)
-	cp -R $(PIDGIN_INSTALL_DIR) $(STRIPPED_RELEASE_DIR)
+	mkdir $(STRIPPED_RELEASE_DIR)
+	tar -cf - $(PIDGIN_INSTALL_DIR) --exclude=Gtk --exclude=spellcheck/share \
+	 | tar --strip 2 -xC $(STRIPPED_RELEASE_DIR) -f -
 	find $(STRIPPED_RELEASE_DIR) \( -name '*.dll' -o -name '*.exe' \) \
-	 -not \( -false $(EXTERNAL_DLLS_FIND_EXP) \) -exec $(STRIP) --strip-unneeded {} ';'
+	 -not \( -false $(EXTERNAL_DLLS_FIND_EXP) \) \
+	 -exec $(STRIP) --strip-unneeded {} ';'
 
-installer: create_release_install_dir
-	$(MAKENSIS) $(MAKENSISOPT)V3 $(MAKENSISOPT)DPIDGIN_VERSION="$(PIDGIN_VERSION)" $(MAKENSISOPT)DPIDGIN_PRODUCT_VERSION="$(PIDGIN_PRODUCT_VERSION)" $(MAKENSISOPT)DWITH_GTK $(MAKENSISOPT)DPIDGIN_INSTALL_DIR="$(STRIPPED_RELEASE_DIR)" $(MAKENSISOPT)DGTK_INSTALL_VERSION="$(GTK_INSTALL_VERSION)" pidgin/win32/nsis/pidgin-installer.nsi
+installer: generate_installer_includes
+	$(MAKENSIS) $(MAKENSISOPT)V3 $(MAKENSISOPT)DPIDGIN_VERSION="$(PIDGIN_VERSION)" $(MAKENSISOPT)DPIDGIN_PRODUCT_VERSION="$(PIDGIN_PRODUCT_VERSION)" $(MAKENSISOPT)DPIDGIN_INSTALL_DIR="$(STRIPPED_RELEASE_DIR)" $(MAKENSISOPT)DGTK_INSTALL_VERSION="$(GTK_INSTALL_VERSION)" pidgin/win32/nsis/pidgin-installer.nsi
 	mv pidgin/win32/nsis/pidgin-$(PIDGIN_VERSION).exe ./
 
-installer_nogtk: create_release_install_dir
-	$(MAKENSIS) $(MAKENSISOPT)V3 $(MAKENSISOPT)DPIDGIN_VERSION="$(PIDGIN_VERSION)" $(MAKENSISOPT)DPIDGIN_PRODUCT_VERSION="$(PIDGIN_PRODUCT_VERSION)" $(MAKENSISOPT)DPIDGIN_INSTALL_DIR="$(STRIPPED_RELEASE_DIR)" $(MAKENSISOPT)DGTK_INSTALL_VERSION="$(GTK_INSTALL_VERSION)" pidgin/win32/nsis/pidgin-installer.nsi
-	mv pidgin/win32/nsis/pidgin-$(PIDGIN_VERSION)-no-gtk.exe ./
-
-installer_debug: install
-	$(MAKENSIS) $(MAKENSISOPT)V3 $(MAKENSISOPT)DPIDGIN_VERSION="$(PIDGIN_VERSION)" $(MAKENSISOPT)DPIDGIN_PRODUCT_VERSION="$(PIDGIN_PRODUCT_VERSION)" $(MAKENSISOPT)DPIDGIN_INSTALL_DIR="$(PIDGIN_INSTALL_DIR)" $(MAKENSISOPT)DDEBUG $(MAKENSISOPT)DGTK_INSTALL_VERSION="$(GTK_INSTALL_VERSION)" pidgin/win32/nsis/pidgin-installer.nsi
-	mv pidgin/win32/nsis/pidgin-$(PIDGIN_VERSION)-debug.exe ./
+installer_offline: generate_installer_includes
+	$(MAKENSIS) $(MAKENSISOPT)V3 $(MAKENSISOPT)DPIDGIN_VERSION="$(PIDGIN_VERSION)" $(MAKENSISOPT)DPIDGIN_PRODUCT_VERSION="$(PIDGIN_PRODUCT_VERSION)" $(MAKENSISOPT)DOFFLINE_INSTALLER $(MAKENSISOPT)DPIDGIN_INSTALL_DIR="$(STRIPPED_RELEASE_DIR)" $(MAKENSISOPT)DGTK_INSTALL_VERSION="$(GTK_INSTALL_VERSION)" pidgin/win32/nsis/pidgin-installer.nsi
+	mv pidgin/win32/nsis/pidgin-$(PIDGIN_VERSION)-offline.exe ./
 
 installer_zip: create_release_install_dir
 	rm -f pidgin-$(PIDGIN_VERSION)-win32-bin.zip
 	zip -9 -r pidgin-$(PIDGIN_VERSION)-win32-bin.zip $(STRIPPED_RELEASE_DIR)
 
-installers: installer installer_nogtk installer_debug installer_zip
+debug_symbols_zip: install
+	rm -rf $(DEBUG_SYMBOLS_DIR) $(DEBUG_SYMBOLS_DIR).zip
+	mkdir $(DEBUG_SYMBOLS_DIR)
+	tar -cf - `find $(PIDGIN_INSTALL_DIR) \( -name '*.dll' -o -name '*.exe' \) \
+	 -not \( -false $(EXTERNAL_DLLS_FIND_EXP) \) -print` \
+	 | tar --strip 2 --xform s/$$/.dbgsym/ -xC $(DEBUG_SYMBOLS_DIR) -f -
+	zip -9 -r $(DEBUG_SYMBOLS_DIR).zip $(DEBUG_SYMBOLS_DIR) 
+
+installers: installer installer_offline debug_symbols_zip installer_zip
 
 Doxyfile.mingw: Doxyfile.in
-	sed -e "s/@PACKAGE@/pidgin/" -e "s/@VERSION@/$(PIDGIN_VERSION)/" -e "s/@top_srcdir@/$(PIDGIN_TREE_TOP)/g" -e "s/@enable_dot@/NO/" Doxyfile.in > Doxyfile.mingw
+	sed -e "s/@PACKAGE@/pidgin/" -e "s/@VERSION@/$(PIDGIN_VERSION)/" -e "s/@top_srcdir@/$(PIDGIN_TREE_TOP)/g" -e "s/@enable_dot@/NO/" $< > $@
 
 docs: Doxyfile.mingw
 	@echo "Running doxygen..."
@@ -125,13 +172,12 @@
 	$(MAKE) -C $(PIDGIN_TOP) -f $(MINGW_MAKEFILE) clean
 	$(MAKE) -C $(PURPLE_TOP) -f $(MINGW_MAKEFILE) clean
 	$(MAKE) -C share/ca-certs -f $(MINGW_MAKEFILE) clean
-	rm -f $(PIDGIN_CONFIG_H) $(PIDGIN_REVISION_H) $(PIDGIN_REVISION_RAW_TXT) ./VERSION pidgin-$(PIDGIN_VERSION)*.exe pidgin-$(PIDGIN_VERSION)-win32-bin.zip
+	rm -f $(PIDGIN_CONFIG_H) $(PIDGIN_REVISION_H) $(PIDGIN_REVISION_RAW_TXT) ./VERSION pidgin-$(PIDGIN_VERSION)*.exe pidgin-$(PIDGIN_VERSION)-win32-bin.zip $(DEBUG_SYMBOLS_DIR).zip
 	rm -rf doc/html Doxyfile.mingw
 
 uninstall:
-	rm -rf $(PURPLE_INSTALL_PERL_DIR) $(PIDGIN_INSTALL_PLUGINS_DIR) $(PURPLE_INSTALL_PO_DIR) $(PIDGIN_INSTALL_DIR) $(STRIPPED_RELEASE_DIR)
+	rm -rf $(PURPLE_INSTALL_PERL_DIR) $(PIDGIN_INSTALL_PLUGINS_DIR) $(PURPLE_INSTALL_PO_DIR) $(PIDGIN_INSTALL_DIR) $(STRIPPED_RELEASE_DIR) $(DEBUG_SYMBOLS_DIR)
 	rm -f ./VERSION
 
 include $(PIDGIN_COMMON_TARGETS)
 
-.PHONY: $(PIDGIN_REVISION_H) $(PIDGIN_REVISION_RAW_TXT)
--- a/NEWS	Thu Jun 16 04:37:03 2011 +0000
+++ b/NEWS	Sat Aug 06 03:45:56 2011 +0000
@@ -2,7 +2,137 @@
 
 Our development blog is available at: http://planet.pidgin.im
 
-2.6.6 (??/??/2010):
+2.8.0 (06/07/2011):
+	Paul: I fixed a few things in this release, and committed some
+	patches, but am being vague because I can't remember any specifics.
+	Hopefully you enjoy this, and happy May!
+
+	John: Wow, this release has taken forever.  But there are a crapload
+	of patches that have been committed this time around, a lot of them by
+	me.  The infamous MSN bugs are still outstanding, but otherwise this
+	release has brought some excellent progress.  Oh, and we dropped the
+	hasn't-quite-worked-in-ages QQ plugin, too.  Enjoy!
+
+	Jorge: I managed to get one patch applied! Wii for end of semester!
+
+2.7.11 (03/10/2011):
+	John: Yet another release.  This time around we finally fixed that
+	annoying MSN buddy adding problem and a security issue in Yahoo.  You
+	know the drill--upgrade already!
+
+2.7.10 (02/06/2011):
+	John: It's release time again.  This release contains a bunch of stuff
+	committed from Trac.  This is another "thank a patch writer" release.
+	Unfortunately, no one has fixed our wonderful MSN issues yet.  There is
+	a tiny security fix in this release, as well.
+
+2.7.9 (12/26/2010):
+	John: Just a quick release for a security fix here.  Elliott has not
+	yet had a chance to work on the MSN breakage that's been present in
+	the last couple releases, but we hope he can do it before 2.7.10!
+
+2.7.8 (12/19/2010):
+	Elliott: OK, so I know a few things broke with the last release, and
+	it's too bad we had to rush it for that silly certificate thing that
+	the MSN people can't configure properly.  I've certainly done a lot of
+	small fixes this time, but it's too bad we haven't been able to get the
+	transfers with the official client fixed yet.  I promise it'll be in
+	the next release (barring any quick security issues).
+
+	John: So, it's been about a month since we last released.  Again, we've
+	assembled a bugfix release for your enjoyment.  While a few commonly
+	reported bugs remain, particularly in MSN, we're working on it for the
+	next release.  In the meantime, Merry Christmas and enjoy!
+
+2.7.7 (11/23/2010):
+	John: Well, this time around, we should finally have the certificate
+	issue really and fully fixed for all of you MSN users.  Also, we have
+	a few AIM-related fixes in this release, most notably the fix for the
+	new "SSL Handshake Failure" message some of you got after upgrading.
+	That one was an oversight on our part.  Enjoy the fixes!
+
+2.7.6 (11/21/2010):
+	Jorge: In this release I have merged two branches where I have spent
+	most of my time in the last months, the MSNP16 and SLP-rewrite.  I 
+	hope you all will enjoy the hability to be connected on multiple
+	instances at the same time. I also hope that the SLP rewrite
+	fix a lot of old bugs that we have in the tracker. I am really 
+	happy with this rewrite because there was untoched code from almost
+	5 years ago. I hope you like this release!
+
+	John: In this release, we give you some new features and a bunch of
+	bug fixes.  This includes shipping intermediate certificates to fix
+	certificate validation for MSN's servers.  Upgrade and enjoy!
+
+2.7.5 (10/31/2010):
+	John: A bugfix release for all of you!  This time we fixed a bunch of
+	bugs ranging from annoying regressions to long-standing bugs we didn't
+	realize until now were bugs.  Enjoy!
+
+2.7.4 (10/20/2010):
+	John: This release came at this particular time due to some security
+	issues Daniel discovered for us when investigating a bug.  There are
+	a ton of other changes, including some partial Yahoo file transfer
+	fixes and a bunch of other little things.  Enjoy!
+
+2.7.3 (08/10/2010):
+	Mark: Lots of little incremental[1] bug fixes and enhancements in this
+	release.
+
+	[1] No whales were harmed[2] during the creation of this release.
+	[2] Probably.
+
+	John: Finally got some fixes out there for you Yahoo users behind some
+	particularly annoying firewalls and proxies, among other fixes.  Enjoy!
+
+2.7.2 (07/21/2010):
+	Mark: We discovered a security issue in Pidgin 2.7.0 and 2.7.1 and
+	decided to release a patched version quickly.  This release contains
+	the fix for that crash, and a few other minor fixes.
+
+2.7.1 (05/29/2010):
+	Elliott: Hey, I'm first!  How did that happen?!  Maybe because of the
+	interesting changes in this release.  Sure there were quite a few bug
+	fixes, but I know what you've all been waiting for is the direct
+	connections in MSN.  Trust me, it's really really fast!!
+
+	John: Whoa, short turnaround for us.  This is just 17 days after our
+	previous release!  This fixes a number of bugs that you've all been
+	reporting a ton of duplicate tickets about and even gives you the new
+	direct connection file transfer support for MSN.  Enjoy!
+
+	Marcus: Quite a bit quicker to get this release out, compared with the
+	previous one :).  Fixes a number of bugs, and I'm sure the MSN direct
+	connections will please many users.  Enjoy!
+
+2.7.0 (05/12/2010):
+	John: We FINALLY got the ICQ X-Status stuff merged in!  And a few other
+	patches that have been sitting on Trac forever.  Couple that with some
+	new features and we have an excellent release for all of you!
+
+	Marcus: Finally time for a new release, seems like it took
+	quite a while this time.  But then again, there are some new features
+	in there, like file transfer preview (thumbnails) support (only on MSN
+	so far), plus a lot of bug fixes.  Enjoy!
+
+	Paul: Yay, a new release!  I don't think I added very much useful to
+	this release, other than fixing a paste bug from Chrome (no weird
+	characters appended to the end of your URI).  Enjoy!
+
+	Jorge: This is my first NEWS!  I'm not sure I added something nice
+	to this release.  I know it took a lot of time to bring this one
+	out, however I'm really excited by this release.  I hope everyone
+	likes the new features this release brings.
+
+	Elliott: This release took so long, I had to go check the ChangeLog
+	just to see what happened.  I doubt many people will notice, but we
+	dropped support for many old things, like GTK+<2.10 and MSNP9.  In more
+	exciting news, we have file transfer previews on MSN, and support for
+	setting moods on ICQ and XMPP (which has been waiting forever.)
+
+2.6.6 (02/18/2010):
+	Mark: This release includes some great little changes and fixes a few
+	security-related bugs.  See the ChangeLog for details.
 
 2.6.5 (01/08/2010):
 	Paul: This release fixes a pretty serious bug in the MSN code, so we're
--- a/configure.ac	Thu Jun 16 04:37:03 2011 +0000
+++ b/configure.ac	Sat Aug 06 03:45:56 2011 +0000
@@ -43,19 +43,19 @@
 #
 # Make sure to update finch/libgnt/configure.ac with libgnt version changes.
 #
-m4_define([purple_lt_current], [6])
+m4_define([purple_lt_current], [9])
 m4_define([purple_major_version], [2])
-m4_define([purple_minor_version], [6])
-m4_define([purple_micro_version], [6])
+m4_define([purple_minor_version], [9])
+m4_define([purple_micro_version], [1])
 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], [6])
+m4_define([gnt_lt_current], [8])
 m4_define([gnt_major_version], [2])
-m4_define([gnt_minor_version], [6])
-m4_define([gnt_micro_version], [6])
+m4_define([gnt_minor_version], [8])
+m4_define([gnt_micro_version], [9])
 m4_define([gnt_version_suffix], [devel])
 m4_define([gnt_version],
           [gnt_major_version.gnt_minor_version.gnt_micro_version])
@@ -72,9 +72,11 @@
 ])
 fi
 
-AC_CANONICAL_SYSTEM
-AM_CONFIG_HEADER(config.h)
+AC_CANONICAL_HOST
+AC_CONFIG_HEADERS([config.h])
 AM_INIT_AUTOMAKE([1.9 -Wno-portability dist-bzip2])
+dnl TODO: Always use AM_SILENT_RULES when we depend on automake >= 1.11
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 
 PURPLE_MAJOR_VERSION=purple_major_version
 PURPLE_MINOR_VERSION=purple_minor_version
@@ -112,64 +114,11 @@
 AC_PROG_LIBTOOL
 LIBTOOL="$LIBTOOL --silent"
 AC_PROG_INSTALL
-AC_PROG_INTLTOOL
 PKG_PROG_PKG_CONFIG
 AC_FUNC_ALLOCA
-GETTEXT_PACKAGE=pidgin
-AC_SUBST(GETTEXT_PACKAGE)
 
-
-# before gettexting, in case iconv matters
-case "$host_os" in
-darwin*)
-	AC_CHECK_LIB(resolv, res_query)
-
-	AC_CHECK_HEADER(CoreFoundation/CoreFoundation.h, [
-		AC_CHECK_HEADER(IOKit/IOKitLib.h, [
-			AC_DEFINE(HAVE_IOKIT, 1, [Define if we have IOKit])
-			LIBS="$LIBS -framework IOKit -framework CoreFoundation"
-		], [])
-	], [])
-
-	AC_MSG_CHECKING([for fink])
-	if test -d /sw; then
-		AC_MSG_RESULT([found, adding /sw to search paths])
-		CPPFLAGS="$CPPFLAGS -I/sw/include"
-		LDFLAGS="$LDFLAGS -L/sw/lib"
-	else
-		AC_MSG_RESULT([not found])
-	fi
-	;;
-*)
-	;;
-esac
-
-ALL_LINGUAS="af am ar az be@latin bg bn bs ca ca@valencia cs da de dz el en_AU en_CA en_GB eo es et eu fa fi fr ga gl gu he hi hu hy id it ja ka km kn ko ku lo lt mk mn ms_MY my_MM nb ne nl nn oc pa pl pt_BR pt ps ro ru si sk sl sq sr sr@latin sv sw ta te th tr uk ur vi xh zh_CN zh_HK zh_TW"
-AM_GLIB_GNU_GETTEXT
-
-dnl If we don't have msgfmt, then po/ is going to fail -- ensure that
-dnl AM_GLIB_GNU_GETTEXT found it.
-
-if test x$MSGFMT = xno -o x$MSGFMT$GMSGFMT$INTLTOOL_MSGFMT = x
-then
-	AC_ERROR([
-
-The msgfmt command is required to build libpurple.  If it is installed
-on your system, ensure that it is in your path.  If it is not, install
-GNU gettext to continue.
-
-If you have msgfmt installed, but for some reason this error message
-is still displayed, you have encountered what appears to be a bug in
-third-party configure macros.  Try setting the MSGFMT environment
-variable to the absolute path to your msgfmt binary and trying
-configure again, like this:
-
-MSGFMT=/path/to/msgfmt ./configure ...
-])
-fi
-
-dnl we don't use autobreak on cygwin!!
-dnl AC_CYGWIN
+dnl Check for Sun compiler
+AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
 
 dnl Checks for header files.
 AC_HEADER_STDC
@@ -198,11 +147,11 @@
 
 dnl Check for inet_aton
 AC_CHECK_FUNC(inet_aton, , [AC_CHECK_LIB(resolv, inet_aton, ,
-				         [AC_ERROR(inet_aton not found)])])
+				         [AC_MSG_ERROR([inet_aton not found])])])
 AC_CHECK_LIB(resolv, __res_query)
 AC_CHECK_LIB(nsl, gethostent)
 AC_CHECK_FUNC(socket, ,
-	[AC_CHECK_LIB(socket, socket, , [AC_ERROR([socket not found])])])
+	[AC_CHECK_LIB(socket, socket, , [AC_MSG_ERROR([socket not found])])])
 dnl If all goes well, by this point the previous two checks will have
 dnl pulled in -lsocket and -lnsl if we need them.
 AC_CHECK_FUNC(getaddrinfo,
@@ -211,21 +160,21 @@
 	[AC_CHECK_LIB(socket, getaddrinfo,
 		[AC_DEFINE([HAVE_GETADDRINFO]) LIBS="-lsocket -lsnl $LIBS"], , , -lnsl)])
 AC_CHECK_FUNCS(inet_ntop)
+AC_CHECK_FUNCS(getifaddrs)
 dnl Check for socklen_t (in Unix98)
 AC_MSG_CHECKING(for socklen_t)
-AC_TRY_COMPILE([
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 	#include <sys/types.h>
 	#include <sys/socket.h>
 	socklen_t x;
-], [],
-[
+]], [[]])], [
 	AC_MSG_RESULT(yes)
 ], [
-	AC_TRY_COMPILE([
+	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 		#include <sys/types.h>
 		#include <sys/socket.h>
 		int accept(int, struct sockaddr *, size_t *);
-	], [], [
+	]], [[]])], [
 		AC_MSG_RESULT(size_t)
 		AC_DEFINE(socklen_t, size_t, [socklen_t size])
 	], [
@@ -240,6 +189,12 @@
 	[Define if struct sockaddr has an sa_len member])],[:],
 	[#include <sys/socket.h>])
 
+dnl Check for v6-only sockets
+AC_CHECK_DECL([IPV6_V6ONLY],
+	[AC_DEFINE([HAVE_IPV6_V6ONLY],[1],
+	[Define if the IPV6_V6ONLY setsockopt option exists])],
+	[], [#include <netinet/in.h>])
+
 dnl to prevent the g_stat()/g_unlink() crash,
 dnl (09:50:07) Robot101: LSchiere2: it's easy. +LC_SYS_LARGEFILE somewhere in configure.ac
 AC_SYS_LARGEFILE
@@ -248,7 +203,7 @@
 AC_CHECK_FUNC(dlopen, LIBDL="", [AC_CHECK_LIB(dl, dlopen, LIBDL="-ldl")])
 
 AC_MSG_CHECKING(for fileno())
-AC_TRY_RUN([
+AC_RUN_IFELSE([AC_LANG_SOURCE([[
 #include <stdio.h>
 
 int main(int argc, char *argv[])
@@ -259,7 +214,7 @@
 
 	return !(fd > 0);
 }
-], [
+]])], [
 	AC_MSG_RESULT(yes)
 	AC_DEFINE([HAVE_FILENO], [1],
 	          [Define to 1 if your stdio has int fileno(FILE *).])
@@ -272,7 +227,7 @@
 ])
 
 AC_MSG_CHECKING(for the %z format string in strftime())
-AC_TRY_RUN([
+AC_RUN_IFELSE([AC_LANG_SOURCE([[
 #ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
 #endif
@@ -296,7 +251,7 @@
 	         (buf[4] >= '0' && buf[4] <= '9')
 	        );
 }
-], [
+]])], [
 	AC_MSG_RESULT(yes)
 	AC_DEFINE([HAVE_STRFTIME_Z_FORMAT], [1],
 		[Define to 1 if you have a strftime() that supports the %z format string.])
@@ -306,17 +261,78 @@
 	# Fallback for Cross Compiling...
 	# This will enable the compatibility code.
 	AC_MSG_RESULT(no)
-]
-)
+])
+
+# before gettexting, in case iconv matters
+case "$host_os" in
+darwin*)
+	AC_CHECK_LIB(resolv, res_query)
+
+	AC_CHECK_HEADER(CoreFoundation/CoreFoundation.h, [
+		AC_CHECK_HEADER(IOKit/IOKitLib.h, [
+			AC_DEFINE(HAVE_IOKIT, 1, [Define if we have IOKit])
+			LIBS="$LIBS -framework IOKit -framework CoreFoundation"
+		], [])
+	], [])
+
+	AC_MSG_CHECKING([for fink])
+	if test -d /sw; then
+		AC_MSG_RESULT([found, adding /sw to search paths])
+		CPPFLAGS="$CPPFLAGS -I/sw/include"
+		LDFLAGS="$LDFLAGS -L/sw/lib"
+	else
+		AC_MSG_RESULT([not found])
+	fi
+	;;
+*)
+	;;
+esac
 
 dnl #######################################################################
-dnl # Check for GLib 2.0 (required)
+dnl # Disable creation and installation of translation files
 dnl #######################################################################
-PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.4.0 gobject-2.0 gmodule-2.0 gthread-2.0], , [
+AC_ARG_ENABLE(nls, AC_HELP_STRING([--disable-nls], [disable installation of translation files]), enable_i18n="$enableval", enable_i18n=yes)
+
+if test x$enable_i18n = xyes; then
+	AC_PROG_INTLTOOL
+	GETTEXT_PACKAGE=pidgin
+	AC_SUBST(GETTEXT_PACKAGE)
+
+	ALL_LINGUAS="af am ar az be@latin bg bn bn_IN bs ca ca@valencia cs da de dz el en_AU en_CA en_GB eo es et eu fa fi fr ga gl gu he hi hr hu hy id it ja ka km kn ko ku lo lt mai mhr mk mn mr ms_MY my_MM nb ne nl nn oc or pa pl pt_BR pt ps ro ru si sk sl sq sr sr@latin sv sw ta te th tr uk ur vi xh zh_CN zh_HK zh_TW"
+	AM_GLIB_GNU_GETTEXT
+
+	dnl If we don't have msgfmt, then po/ is going to fail -- ensure that
+	dnl AM_GLIB_GNU_GETTEXT found it.
+
+	if test x$MSGFMT = xno -o x$MSGFMT$GMSGFMT$INTLTOOL_MSGFMT = x
+	then
+		AC_MSG_ERROR([
+
+The msgfmt command is required to build libpurple.  If it is installed
+on your system, ensure that it is in your path.  If it is not, install
+GNU gettext to continue.
+
+If you have msgfmt installed, but for some reason this error message
+is still displayed, you have encountered what appears to be a bug in
+third-party configure macros.  Try setting the MSGFMT environment
+variable to the absolute path to your msgfmt binary and trying
+configure again, like this:
+
+MSGFMT=/path/to/msgfmt ./configure ...
+	])
+	fi
+fi #enable_i18n
+
+AM_CONDITIONAL(INSTALL_I18N, test "x$enable_i18n" = "xyes")
+
+dnl #######################################################################
+dnl # Check for GLib 2.16 (required)
+dnl #######################################################################
+PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.16.0 gobject-2.0 gmodule-2.0 gthread-2.0], , [
 	AC_MSG_RESULT(no)
 	AC_MSG_ERROR([
 
-You must have GLib 2.4.0 or newer development headers installed to build.
+You must have GLib 2.16.0 or newer development headers installed to build.
 
 If you have these installed already you may need to install pkg-config so
 I can find them.
@@ -352,7 +368,7 @@
 	[enable_consoleui=$enableval force_finch=$enableval], [enable_consoleui=yes force_finch=no])
 
 dnl #######################################################################
-dnl # Check for GTK+ 2.0 and other things used by the GTK UI
+dnl # Check for GTK+ 2.10 and other things used by the GTK UI
 dnl #######################################################################
 AC_ARG_ENABLE(screensaver,
 	[AC_HELP_STRING([--disable-screensaver],
@@ -399,11 +415,11 @@
 fi
 
 if test "x$enable_gtkui" = "xyes" ; then
-	PKG_CHECK_MODULES(GTK, [gtk+-2.0 >= 2.4.0], , [
+	PKG_CHECK_MODULES(GTK, [gtk+-2.0 >= 2.10.0], , [
 		AC_MSG_RESULT(no)
 		AC_MSG_ERROR([
 
-You must have GTK+ 2.4.0 or newer development headers installed to compile
+You must have GTK+ 2.10.0 or newer development headers installed to compile
 Pidgin.  If you want to build only Finch then specify --disable-gtkui when
 running configure.
 ])])
@@ -426,6 +442,7 @@
 					X11_LIBS="$x_libpath_add"
 					X11_CFLAGS="$x_incpath_add"
 				else
+					with_x="no"
 					if test "x$force_deps" = "xyes" ; then
 						AC_MSG_ERROR([
 X11 development headers not found.
@@ -456,10 +473,10 @@
 			if test "x$XSS_LIBS" != "x"; then
 				oldCPPFLAGS="$CPPFLAGS"
 				CPPFLAGS="$CPPFLAGS $x_incpath_add"
-				AC_TRY_COMPILE([
+				AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 					#include <X11/Xlib.h>
 					#include <X11/extensions/scrnsaver.h>
-					], [], [], [enable_screensaver=no])
+					]], [[]])], [], [enable_screensaver=no])
 				CPPFLAGS="$oldCPPFLAGS"
 			else
 				enable_screensaver=no
@@ -523,31 +540,12 @@
 	fi
 
 	dnl #######################################################################
-	dnl # Check for startup notification
-	dnl #######################################################################
-	if test "x$enable_startup_notification" = "xyes"; then
-		PKG_CHECK_MODULES(STARTUP_NOTIFICATION, [libstartup-notification-1.0 >= 0.5], , [
-			AC_MSG_RESULT(no)
-			if test "x$force_deps" = "xyes" ; then
-				AC_MSG_ERROR([
-Startup notification development headers not found.
-Use --disable-startup-notification if you do not need it.
-])
-			fi])
-
-		if test "x$enable_startup_notification" = "xyes"; then
-			AC_DEFINE(HAVE_STARTUP_NOTIFICATION, 1, [Define if we're using libstartup-notification.])
-			AC_SUBST(STARTUP_NOTIFICATION_CFLAGS)
-			AC_SUBST(STARTUP_NOTIFICATION_LIBS)
-		fi
-	fi
-
-	dnl #######################################################################
 	dnl # Check for GtkSpell
 	dnl #######################################################################
 	if test "x$enable_gtkspell" = "xyes" ; then
 		PKG_CHECK_MODULES(GTKSPELL, gtkspell-2.0 >= 2.0.2, , [
 			AC_MSG_RESULT(no)
+			enable_gtkspell="no"
 			if test "x$force_deps" = "xyes" ; then
 				AC_MSG_ERROR([
 GtkSpell development headers not found.
@@ -567,15 +565,12 @@
 	if test "x$enable_gevolution" = "xyes"; then
 		evo_deps="libebook-1.2 libedata-book-1.2"
 		PKG_CHECK_MODULES(EVOLUTION_ADDRESSBOOK, $evo_deps, , [
-			AC_MSG_RESULT(yes)
 			enable_gevolution="no"
 		])
 		if test "x$enable_gevolution" = "xno"; then
 			evo_deps="libebook-1.0 libedata-book-1.0"
 			PKG_CHECK_MODULES(EVOLUTION_ADDRESSBOOK, $evo_deps, [
 				enable_gevolution="yes"
-			], [
-				AC_MSG_RESULT(yes)
 			])
 		fi
 		if test "x$enable_gevolution" = "xyes"; then
@@ -598,6 +593,7 @@
 	if test "x$enable_cap" = "xyes"; then
 		PKG_CHECK_MODULES(SQLITE3, sqlite3 >= 3.3,,[
 			AC_MSG_RESULT(no)
+			enable_cap="no"
 			if test "x$force_deps" = "xyes" ; then
 				AC_MSG_ERROR([
 sqlite3 development headers not found.
@@ -641,16 +637,20 @@
 		for location in $ac_ncurses_includes $NCURSES_HEADERS /usr/include/ncursesw /usr/include
 		do
 			f="$location/ncurses.h"
+			orig_CFLAGS="$CFLAGS"
+			orig_CPPFLAGS="$CPPFLAGS"
+			CFLAGS="$CFLAGS -I$location"
+			CPPFLAGS="$CPPFLAGS -I$location"
 			AC_CHECK_HEADER($f,[
 				AC_MSG_CHECKING([if $f supports wide characters])
-				AC_TRY_COMPILE([
+				AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 					#define _XOPEN_SOURCE_EXTENDED
 					#include <$f>
-				], [
+				]], [[
 					#ifndef get_wch
 					# error get_wch not found!
 					#endif
-				], [
+				]])], [
 					dir=$location
 					if test x"$dir" != x"." ; then
 						GNT_CFLAGS="-I$dir/"
@@ -659,9 +659,13 @@
 					fi
 
 					found_ncurses_h=yes
+					CFLAGS="$orig_CFLAGS"
+					CPPFLAGS="$orig_CPPFLAGS"
 					AC_MSG_RESULT([yes])
 					break
 				], [
+					CFLAGS="$orig_CFLAGS"
+					CPPFLAGS="$orig_CPPFLAGS"
 					AC_MSG_RESULT([no])
 				])
 			])
@@ -748,6 +752,7 @@
 			[], [$GSTREAMER_LIBS])
 	], [
 		AC_MSG_RESULT(no)
+		enable_gst="no"
 		if test "x$force_deps" = "xyes" ; then
 			AC_MSG_ERROR([
 GStreamer development headers not found.
@@ -828,6 +833,7 @@
 		AC_SUBST(IDN_LIBS)
 	], [
 		AC_MSG_RESULT(no)
+		enable_idn="no"
 		if test "x$force_deps" = "xyes" ; then
 			AC_MSG_ERROR([
 GNU Libidn development headers not found.
@@ -900,11 +906,14 @@
 	AC_CHECK_LIB(avahi-client, avahi_client_new, [avahilibs=yes], [avahilibs=no], $AVAHI_LIBS)
 fi
 
-if test "x$enable_avahi" = "xyes" -a "x$force_deps" = "xyes" -a \( "x$avahiincludes" = "xno" -o "x$avahilibs" = "xno" \); then
-	AC_MSG_ERROR([
+if test "x$enable_avahi" = "xyes" -a \( "x$avahiincludes" = "xno" -o "x$avahilibs" = "xno" \); then
+	enable_avahi="no"
+	if test "x$force_deps" = "xyes"; then
+		AC_MSG_ERROR([
 avahi development headers not found.
 Use --disable-avahi if you do not need avahi (Bonjour) support.
 ])
+	fi
 fi
 AC_SUBST(AVAHI_CFLAGS)
 AC_SUBST(AVAHI_LIBS)
@@ -989,10 +998,10 @@
 	CPPFLAGS_save="$CPPFLAGS"
 	CPPFLAGS="$CPPFLAGS $SILC_CFLAGS"
 		AC_MSG_CHECKING(for silcmime.h)
-		AC_TRY_COMPILE([
+		AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 #include <silcincludes.h>
 #include <silcmime.h>
-		], [], [
+		]], [[]])], [
 		AC_MSG_RESULT(yes)
 		AC_DEFINE(HAVE_SILCMIME_H, 1, [Define if we have silcmime.h])
 		], [
@@ -1014,7 +1023,7 @@
 	gadu_manual_check="no"
 fi
 if test "x$gadu_manual_check" = "xno"; then
-	PKG_CHECK_MODULES(GADU, libgadu, [
+	PKG_CHECK_MODULES(GADU, [libgadu >= 1.11.0], [
 		gadu_includes="yes"
 		gadu_libs="yes"
 	], [
@@ -1041,14 +1050,33 @@
 	AC_MSG_CHECKING(for libgadu GPL compatibility)
 	CPPFLAGS_save="$CPPFLAGS"
 	CPPFLAGS="$CPPFLAGS $GADU_CFLAGS"
-	AC_TRY_COMPILE([#include <libgadu.h>], [
+	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <libgadu.h>]], [[
 #if defined(__GG_LIBGADU_HAVE_OPENSSL) || defined(GG_CONFIG_HAVE_OPENSSL)
 #error "libgadu is not compatible with the GPL when compiled with OpenSSL support."
 #endif
-	], [
-		AC_MSG_RESULT(yes)
-		AC_DEFINE([HAVE_LIBGADU], [1],
-			[Define to 1 if you have libgadu.])
+	]])], [
+		AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <libgadu.h>]], [[
+#if GG_DEFAULT_PROTOCOL_VERSION < 0x2e
+#error "Your libgadu version is too old. libpurple requires 1.11.0 or higher."
+#endif
+		]])], [
+			AC_MSG_RESULT(yes)
+			AC_DEFINE([HAVE_LIBGADU], [1],
+				[Define to 1 if you have libgadu.])
+		], [
+			AC_MSG_RESULT(no)
+			echo
+			echo
+			echo "Your supplied copy of libgadu is too old."
+			echo "Install version 1.11.0 or newer."
+			echo "Then rerun this ./configure"
+			echo
+			echo "Falling back to using our own copy of libgadu"
+			echo
+			GADU_LIBS=""
+			GADU_CFLAGS=""
+			gadu_libs=no
+		])
 	], [
 		AC_MSG_RESULT(no)
 		echo
@@ -1069,12 +1097,13 @@
 
 AM_CONDITIONAL(USE_INTERNAL_LIBGADU, test "x$gadu_libs" != "xyes")
 
+if test "x$gadu_libs" = "x"; then
+	gadu_libs=no
+fi
+
 AC_SUBST(GADU_LIBS)
 AC_SUBST(GADU_CFLAGS)
 
-# change the next line to not make MSNP15 the default (s/disable/enable/; s/yes/no/;)
-AC_ARG_ENABLE(msnp15,[AC_HELP_STRING([--disable-msnp15], [Disable the newer MSNP15 protocol])],enable_msnp15=$enableval,enable_msnp15=yes)
-
 AC_ARG_ENABLE(distrib,,,enable_distrib=no)
 AM_CONDITIONAL(DISTRIB, test "x$enable_distrib" = "xyes")
 DYNAMIC_PRPLS=all
@@ -1084,7 +1113,7 @@
 fi
 
 if test "x$STATIC_PRPLS" = "xall" ; then
-	STATIC_PRPLS="bonjour gg irc jabber msn myspace mxit novell oscar qq sametime silc simple yahoo zephyr"
+	STATIC_PRPLS="bonjour gg irc jabber msn myspace mxit novell oscar sametime silc simple yahoo zephyr"
 fi
 if test "x$have_meanwhile" != "xyes" ; then
 	STATIC_PRPLS=`echo $STATIC_PRPLS | $sedpath 's/sametime//'`
@@ -1092,9 +1121,6 @@
 if test "x$avahiincludes" != "xyes" -o "x$avahilibs" != "xyes"; then
 	STATIC_PRPLS=`echo $STATIC_PRPLS | $sedpath 's/bonjour//'`
 fi
-if test "x$enable_msnp15" != "xyes" ; then
-	STATIC_PRPLS=`echo $STATIC_PRPLS | $sedpath 's/msn/msnp9/'`
-fi
 if test "x$silcincludes" != "xyes" -o "x$silcclient" != "xyes"; then
 	STATIC_PRPLS=`echo $STATIC_PRPLS | $sedpath 's/silc/silc10/'`
 fi
@@ -1125,8 +1151,6 @@
 			STATIC_LINK_LIBS="$STATIC_LINK_LIBS \$(top_builddir)/libpurple/protocols/$i/lib${i}purple.la"
 		elif test "x$i" = "xsilc10"; then
 			STATIC_LINK_LIBS="$STATIC_LINK_LIBS \$(top_builddir)/libpurple/protocols/$i/libsilcpurple.la"
-		elif test "x$i" = "xmsnp9"; then
-			STATIC_LINK_LIBS="$STATIC_LINK_LIBS \$(top_builddir)/libpurple/protocols/$i/libmsn.la"
 		else
 			STATIC_LINK_LIBS="$STATIC_LINK_LIBS \$(top_builddir)/libpurple/protocols/$i/lib$i.la"
 		fi
@@ -1139,14 +1163,12 @@
 		irc)		static_irc=yes ;;
 		jabber)		static_jabber=yes ;;
 		msn)		static_msn=yes ;;
-		msnp9)		static_msn=yes ;;
 		myspace)	static_myspace=yes ;;
 		mxit)		static_mxit=yes ;;
 		novell)		static_novell=yes ;;
 		oscar)		static_oscar=yes ;;
 		aim)		static_oscar=yes ;;
 		icq)		static_oscar=yes ;;
-		qq)			static_qq=yes ;;
 		sametime)	static_sametime=yes ;;
 		silc)		static_silc=yes ;;
 		silc10)		static_silc=yes ;;
@@ -1165,7 +1187,6 @@
 AM_CONDITIONAL(STATIC_MXIT, test "x$static_mxit" = "xyes")
 AM_CONDITIONAL(STATIC_NOVELL, test "x$static_novell" = "xyes")
 AM_CONDITIONAL(STATIC_OSCAR, test "x$static_oscar" = "xyes")
-AM_CONDITIONAL(STATIC_QQ, test "x$static_qq" = "xyes")
 AM_CONDITIONAL(STATIC_SAMETIME, test "x$static_sametime" = "xyes" -a "x$have_meanwhile" = "xyes")
 AM_CONDITIONAL(STATIC_SILC, test "x$static_silc" = "xyes" -a "x$have_silc" = "xyes")
 AM_CONDITIONAL(STATIC_SIMPLE, test "x$static_simple" = "xyes")
@@ -1177,7 +1198,7 @@
 
 AC_ARG_WITH(dynamic_prpls, [AC_HELP_STRING([--with-dynamic-prpls], [specify which protocols to build dynamically])], [DYNAMIC_PRPLS=`echo $withval | $sedpath 's/,/ /g'`])
 if test "x$DYNAMIC_PRPLS" = "xall" ; then
-	DYNAMIC_PRPLS="bonjour gg irc jabber msn myspace mxit novell oscar qq sametime silc simple yahoo zephyr"
+	DYNAMIC_PRPLS="bonjour gg irc jabber msn myspace mxit novell oscar sametime silc simple yahoo zephyr"
 fi
 if test "x$have_meanwhile" != "xyes"; then
 	DYNAMIC_PRPLS=`echo $DYNAMIC_PRPLS | $sedpath 's/sametime//'`
@@ -1185,9 +1206,6 @@
 if test "x$avahiincludes" != "xyes" -o "x$avahilibs" != "xyes"; then
 	DYNAMIC_PRPLS=`echo $DYNAMIC_PRPLS | $sedpath 's/bonjour//'`
 fi
-if test "x$enable_msnp15" != "xyes" ; then
-	DYNAMIC_PRPLS=`echo $DYNAMIC_PRPLS | $sedpath 's/msn/msnp9/'`
-fi
 if test "x$silcincludes" != "xyes" -o "x$silcclient" != "xyes"; then
 	DYNAMIC_PRPLS=`echo $DYNAMIC_PRPLS | $sedpath 's/silc/silc10/'`
 fi
@@ -1202,7 +1220,6 @@
 		irc)		dynamic_irc=yes ;;
 		jabber)		dynamic_jabber=yes ;;
 		msn)		dynamic_msn=yes ;;
-		msnp9)		dynamic_msn=yes ;;
 		myspace)	dynamic_myspace=yes ;;
 		mxit)		dynamic_mxit=yes ;;
 		novell)		dynamic_novell=yes ;;
@@ -1210,7 +1227,6 @@
 		oscar)		dynamic_oscar=yes ;;
 		aim)		dynamic_oscar=yes ;;
 		icq)		dynamic_oscar=yes ;;
-		qq)			dynamic_qq=yes ;;
 		sametime)	dynamic_sametime=yes ;;
 		silc)		dynamic_silc=yes ;;
 		silc10)		dynamic_silc=yes ;;
@@ -1273,9 +1289,9 @@
 		orig_CFLAGS="$CFLAGS"
 		CFLAGS="$CFLAGS $newflag"
 		AC_MSG_CHECKING(for $newflag option to gcc)
-		AC_TRY_COMPILE([], [
+		AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
 			int main() {return 0;}
-		], [
+		]])], [
 			AC_MSG_RESULT(yes)
 			CFLAGS="$orig_CFLAGS"
 			DEBUG_CFLAGS="$DEBUG_CFLAGS $newflag"
@@ -1287,7 +1303,7 @@
 
 	if test "x$enable_fortify" = "xyes"; then
 		AC_MSG_CHECKING(for FORTIFY_SOURCE support)
-		AC_TRY_COMPILE([#include <features.h>], [
+		AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <features.h>]], [[
 			int main() {
 			#if !(__GNUC_PREREQ (4, 1) \
 				|| (defined __GNUC_RH_RELEASE__ && __GNUC_PREREQ (4, 0)) \
@@ -1299,7 +1315,7 @@
 			#endif
 				return 0;
 			}
-		], [
+		]])], [
 			AC_MSG_RESULT(yes)
 			DEBUG_CFLAGS="$DEBUG_CFLAGS -Wp,-D_FORTIFY_SOURCE=2"
 		], [
@@ -1310,6 +1326,10 @@
 	DEBUG_CFLAGS="-Wall $DEBUG_CFLAGS"
 	CFLAGS="-g $CFLAGS"
 fi
+
+if test "x$SUNCC" = "xyes"; then
+        CFLAGS="$CFLAGS -features=extensions" 
+fi
 AC_SUBST(CFLAGS)
 
 AC_PATH_PROG(pidginpath, pidgin)
@@ -1381,7 +1401,7 @@
 						   [which python interpreter to use for dbus code generation]),
 			PYTHON=$withval)
 
-if test "x$enable_dbus" = "xyes" ; then
+if test "x$enable_dbus" = "xyes" || test "x$enable_consoleui" = "xyes" ; then
 	if test -z "$PYTHON" -o "x$PYTHON" = "xyes"; then
 		AC_PATH_PROG([PYTHON], [python], [no])
 	fi
@@ -1390,9 +1410,7 @@
 		AC_MSG_WARN([python interpreter not found in your path])
 		enable_dbus=no
 	fi
-fi
 
-if test "x$enable_dbus" = "xyes" ; then
 	if $PYTHON -c "import sys; sys.exit(sys.version[[:3]] >= '2.4')" ; then
 		AC_MSG_WARN([python version >= 2.4 required])
 		enable_dbus=no
@@ -1442,7 +1460,7 @@
 			done
 
 			if test -z $DBUS_SERVICES_DIR ; then
-				AC_MSG_ERROR([D-Bus services directory was not found!  Please use --with-dbus-services and specify it's location.])
+				AC_MSG_ERROR([D-Bus services directory was not found!  Please use --with-dbus-services and specify its location.])
 			fi
 		else
 			DBUS_SERVICES_DIR="$datadir/dbus-1/services"
@@ -1463,22 +1481,24 @@
 
 dnl Check for Python headers (currently useful only for libgnt)
 dnl (Thanks to XChat)
-AC_PATH_PROG(pythonpath, python)
-if test "_$pythonpath" != _ ; then
+if test "x$enable_consoleui" = "xyes" -a ! -z "$PYTHON" -a x"$PYTHON" != x"no" ; then
 	AC_MSG_CHECKING(for Python compile flags)
-	PY_PREFIX=`$pythonpath -c 'import sys ; print sys.prefix'`
-	PY_EXEC_PREFIX=`$pythonpath -c 'import sys ; print sys.exec_prefix'`
+	PY_PREFIX=`$PYTHON -c 'import sys ; print sys.prefix'`
+	PY_EXEC_PREFIX=`$PYTHON -c 'import sys ; print sys.exec_prefix'`
 	changequote(<<, >>)dnl
-	PY_VERSION=`$pythonpath -c 'import sys ; print sys.version[0:3]'`
-	PY_MAJOR=`$pythonpath -c 'import sys ; print sys.version[0:2]'`
+	PY_VERSION=`$PYTHON -c 'import sys ; print sys.version[0:3]'`
+	PY_MAJOR=`$PYTHON -c 'import sys ; print sys.version[0:2]'`
 	changequote([, ])dnl
 	if test -f $PY_PREFIX/include/python$PY_VERSION/Python.h -a "$PY_MAJOR" = "2."; then
+		AC_MSG_RESULT()
 		AC_CHECK_LIB(pthread, pthread_create, )
 		AC_CHECK_LIB(util, openpty, )
 		AC_CHECK_LIB(db, dbopen, )
 		PY_LIBS="-L$PY_EXEC_PREFIX/lib/python$PY_VERSION/config -lpython$PY_VERSION"
 		PY_CFLAGS="-I$PY_PREFIX/include/python$PY_VERSION"
 		AC_DEFINE(USE_PYTHON, [1], [Define if python headers are available.])
+		dnl Because the above AC_CHECK_LIB get in the way...
+		AC_MSG_CHECKING(for Python compile flags)
 		AC_MSG_RESULT(ok)
 	else
 		AC_MSG_RESULT([Can't find Python.h])
@@ -1660,6 +1680,9 @@
 
 SSL_CERTIFICATES_DIR=""
 if ! test -z "$ssl_certificates_dir" ; then
+	if test "x$ssl_certificates_dir" = "xyes" ; then
+		AC_MSG_ERROR([--with-system-ssl-certs requires that a location is specified, eg. --with-system-ssl-certs=/etc/pki/tls/certs])
+	fi
 	if ! test -d "$ssl_certificates_dir" ; then
 		AC_MSG_ERROR([$ssl_certificates_dir does not exist, if this is the correct location please make sure that it exists.])
 	fi
@@ -1767,13 +1790,13 @@
 AC_SUBST(GNUTLS_LIBS)
 
 if test "x$enable_gnutls" = "xyes"; then
-	AC_MSG_CHECKING(for gnutls_priority_set_direct)
+	AC_MSG_CHECKING(for gnutls_priority_set_direct and gnutls_priority_set)
 	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);]])],
+                                        [[gnutls_session s; gnutls_priority_set_direct(s, NULL, NULL); gnutls_priority_set(s, NULL);]])],
 	               [AC_DEFINE([HAVE_GNUTLS_PRIORITY_FUNCS], 1,
                                   [Define if your gnutls has gnutls_priority_set_direct and friends])
 	                AC_MSG_RESULT(yes)],
@@ -2136,6 +2159,7 @@
 		if test -f $dir/tclConfig.sh; then
 			TCLCONFIG=$dir/tclConfig.sh
 			AC_MSG_RESULT([yes ($TCLCONFIG)])
+			break
 		fi
 	done
 	if test "$TCLCONFIG" = "no"; then
@@ -2161,8 +2185,8 @@
 			CPPFLAGS="$CPPFLAGS $TCL_INCLUDE_SPEC -I$TCL_PREFIX/include"
 			oldLIBS=$LIBS
 			LIBS="$LIBS $TCL_LIB_SPEC"
-			AC_TRY_LINK([#include <tcl.h>],
-				[Tcl_Interp *interp=NULL; Tcl_Init(interp)],
+			AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <tcl.h>]],
+				[[Tcl_Interp *interp=NULL; Tcl_Init(interp)]])],
 				[AC_MSG_RESULT([yes]);enable_tcl=yes],
 				[AC_MSG_RESULT([no]);enable_tcl=no])
 			CPPFLAGS="$oldCPPFLAGS"
@@ -2198,6 +2222,7 @@
 	TKCONFIG=no
 	TKCONFIGDIRS="/usr/lib \
 			/usr/lib64 \
+			/usr/lib/tk8.5 \
 			/usr/lib/tk8.4 \
 			/usr/lib/tk8.3 \
 			/usr/lib/tk8.2 \
@@ -2206,6 +2231,7 @@
 		if test -f $dir/tkConfig.sh; then
 			TKCONFIG=$dir/tkConfig.sh
 			AC_MSG_RESULT([yes ($TKCONFIG)])
+			break
 		fi
 	done
 	if test "$TKCONFIG" = "no"; then
@@ -2225,8 +2251,8 @@
 		CPPFLAGS="$CPPFLAGS $TCL_CFLAGS"
 		oldLIBS=$LIBS
 		LIBS="$LIBS $TCL_LIB_SPEC $TK_LIB_SPEC"
-		AC_TRY_LINK([#include <tk.h>],
-				[Tcl_Interp *interp=NULL; Tcl_Init(interp); Tk_Init(interp);],
+		AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <tk.h>]],
+				[[Tcl_Interp *interp=NULL; Tcl_Init(interp); Tk_Init(interp);]])],
 				[AC_MSG_RESULT([yes]);enable_tk=yes],
 				[AC_MSG_RESULT([no]);enable_tk=no])
 		CPPFLAGS="$oldCPPFLAGS"
@@ -2278,7 +2304,7 @@
 			SASL_LIBS=-"lsasl2"
 		], [
 			AM_CONDITIONAL(USE_CYRUS_SASL, false)
-			AC_ERROR(Cyrus SASL library not found)
+			AC_MSG_ERROR([Cyrus SASL library not found])
 		])
 else
 	AM_CONDITIONAL(USE_CYRUS_SASL, false)
@@ -2311,7 +2337,7 @@
 			[KRB4_LIBS="-lkrb4 -ldes425 -lkrb5 -lk5crypto -lcom_err"],
 			[AC_CHECK_LIB(krb, krb_rd_req,
 				[KRB4_LIBS="-lkrb -ldes"],
-				[AC_ERROR(Kerberos 4 libraries not found)],
+				[AC_MSG_ERROR([Kerberos 4 libraries not found])],
 				-ldes)],
 			-ldes425 -lkrb5 -lk5crypto -lcom_err)
 	orig_LIBS="$LIBS"
@@ -2345,7 +2371,7 @@
 	LDFLAGS="$LDFLAGS $ZEPHYR_LDFLAGS"
 	AC_CHECK_LIB(zephyr, ZInitialize,
 		[ZEPHYR_LIBS="-lzephyr"],
-		[AC_ERROR(Zephyr libraries not found)],
+		[AC_MSG_ERROR([Zephyr libraries not found])],
 		-lzephyr)
 	orig_LIBS="$LIBS"
 	LIBS="$orig_LIBS"
@@ -2354,7 +2380,7 @@
 
 AC_MSG_CHECKING(for me pot o' gold)
 AC_MSG_RESULT(no)
-AC_CHECK_FUNCS(gethostid lrand48)
+AC_CHECK_FUNCS(gethostid lrand48 timegm)
 AC_CHECK_FUNCS(memcpy memmove random strchr strerror vprintf)
 AC_CHECK_HEADERS(malloc.h paths.h sgtty.h stdarg.h sys/cdefs.h)
 AC_CHECK_HEADERS(sys/file.h sys/filio.h sys/ioctl.h sys/msgbuf.h)
@@ -2376,18 +2402,18 @@
 AC_VAR_TIMEZONE_EXTERNALS
 
 AC_CACHE_CHECK(for tm_gmtoff in struct tm, ac_cv_struct_tm_gmtoff,
-        AC_TRY_COMPILE([
+        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
                 #include <time.h>
-        ], [
+        ]], [[
                 struct tm tm;
                 tm.tm_gmtoff = 1;
-        ], ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no))
+        ]])], [ac_cv_struct_tm_gmtoff=yes], [ac_cv_struct_tm_gmtoff=no]))
 if test $ac_cv_struct_tm_gmtoff = yes; then
         AC_DEFINE(HAVE_TM_GMTOFF, 1, [Define if you have a tm_gmtoff member in struct tm])
 fi
 
 AC_CACHE_CHECK([whether va_lists can be copied by value], ac_cv_va_val_copy,[
-	AC_TRY_RUN([#include <stdarg.h>
+	AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdarg.h>
 #include <stdlib.h>
 	void f (int i, ...) {
 	va_list args1, args2;
@@ -2400,7 +2426,7 @@
 	int main() {
 	  f (0, 42);
 	  return 0;
-	}],
+	}]])],
 	[ac_cv_va_val_copy=yes],
 	[ac_cv_va_val_copy=no],
 	[ac_cv_va_val_copy=yes])
@@ -2426,11 +2452,11 @@
 AM_CONDITIONAL(INSTALL_PIXMAPS, test "x$enable_pixmaps" = "xyes")
 
 dnl #######################################################################
-dnl # Disable installation of translation files
+dnl # Tweak status tray icon installation directory
 dnl #######################################################################
-AC_ARG_ENABLE(nls, AC_HELP_STRING([--disable-nls], [disable installation of translation files]), enable_i18n="$enableval", enable_i18n=yes)
+AC_ARG_ENABLE(trayicon-compat, AC_HELP_STRING([--enable-trayicon-compat], [install tray icons in location compatible with older releases of hicolor-icon-theme]), enable_traycompat="$enableval", enable_traycompat=no)
 
-AM_CONDITIONAL(INSTALL_I18N, test "x$enable_i18n" = "xyes")
+AM_CONDITIONAL(ENABLE_TRAYCOMPAT, test "x$enable_traycompat" = "xyes")
 
 dnl #######################################################################
 dnl # Check for Doxygen and dot (part of GraphViz)
@@ -2498,7 +2524,7 @@
 
 AM_CONDITIONAL(PURPLE_AVAILABLE, true)
 
-AC_OUTPUT([Makefile
+AC_CONFIG_FILES([Makefile
 		   Doxyfile
 		   doc/Makefile
 		   doc/pidgin.1
@@ -2508,6 +2534,8 @@
 		   pidgin/Makefile
 		   pidgin/pidgin.pc
 		   pidgin/pidgin-uninstalled.pc
+		   pidgin/pidgin-2.pc
+		   pidgin/pidgin-2-uninstalled.pc
 		   pidgin/pixmaps/Makefile
 		   pidgin/pixmaps/emotes/default/24/Makefile
 		   pidgin/pixmaps/emotes/none/Makefile
@@ -2522,10 +2550,13 @@
 		   pidgin/plugins/perl/Makefile
 		   pidgin/plugins/perl/common/Makefile.PL
 		   pidgin/plugins/ticker/Makefile
+		   libpurple/ciphers/Makefile
 		   libpurple/example/Makefile
 		   libpurple/gconf/Makefile
 		   libpurple/purple.pc
 		   libpurple/purple-uninstalled.pc
+		   libpurple/purple-2.pc
+		   libpurple/purple-2-uninstalled.pc
 		   libpurple/plugins/Makefile
 		   libpurple/plugins/mono/Makefile
 		   libpurple/plugins/mono/api/Makefile
@@ -2541,13 +2572,11 @@
 		   libpurple/protocols/irc/Makefile
 		   libpurple/protocols/jabber/Makefile
 		   libpurple/protocols/msn/Makefile
-		   libpurple/protocols/msnp9/Makefile
 		   libpurple/protocols/myspace/Makefile
 		   libpurple/protocols/mxit/Makefile
 		   libpurple/protocols/novell/Makefile
 		   libpurple/protocols/null/Makefile
 		   libpurple/protocols/oscar/Makefile
-		   libpurple/protocols/qq/Makefile
 		   libpurple/protocols/sametime/Makefile
 		   libpurple/protocols/silc/Makefile
 		   libpurple/protocols/silc10/Makefile
@@ -2568,6 +2597,7 @@
 		   po/Makefile.in
 		   pidgin.spec
 		  ])
+AC_OUTPUT
 
 echo
 echo $PACKAGE $VERSION
@@ -2596,7 +2626,9 @@
 echo Build with Cyrus SASL support. : $enable_cyrus_sasl
 echo Use kerberos 4 with zephyr.... : $kerberos
 echo Use external libzephyr........ : $zephyr
+echo Use external libgadu.......... : $gadu_libs
 echo Install pixmaps............... : $enable_pixmaps
+echo Old tray icon compatibility... : $enable_traycompat
 echo Install translations.......... : $enable_i18n
 echo Has you....................... : yes
 echo
@@ -2620,7 +2652,13 @@
 if test "x$enable_pixmaps" = "xno" ; then
 	echo
 	echo Warning: You have disabled the installation of pixmap data, but Pidgin
-	echo still requires installed pixmaps.  Be sure you know what you\'re doing.
+	echo still requires installed pixmaps.  Be sure you know what you are doing.
+fi
+if test "x$enable_i18n" = "xno" ; then
+	echo
+	echo Warning: You have disabled the building and installation of translation
+	echo data.  This will prevent building pidgin.desktop and the GConf schemas.
+	echo Be sure you know what you are doing.
 fi
 echo
 echo configure complete, now type \'make\'
--- a/doc/PERL-HOWTO.dox	Thu Jun 16 04:37:03 2011 +0000
+++ b/doc/PERL-HOWTO.dox	Sat Aug 06 03:45:56 2011 +0000
@@ -72,8 +72,8 @@
 sub plugin_load {
 	$plugin = shift;
 
-	# Testing was done using Oscar, but this should work regardless of the protocol chosen
-	my $protocol = "prpl-oscar";
+	# Testing was done using AIM, but this should work regardless of the protocol chosen
+	my $protocol = "prpl-aim";
 	my $account_name = "test";
 
 	# Create a new Account
@@ -149,7 +149,7 @@
 sub plugin_load {
 	my $plugin = shift;
 
-	my $protocol = "prpl-oscar";
+	my $protocol = "prpl-aim";
 	my $account_name = "test";
 
 	# This is how we get an account to use in the following tests.  You should replace the username
@@ -232,7 +232,7 @@
 @code
 sub plugin_load {
 	my $plugin = shift;
-	my $protocol = "prpl-oscar";
+	my $protocol = "prpl-aim";
 	my $account_name = "test";
 
 	$account = Purple::Accounts::find($account_name, $protocol);
--- a/doc/account-signals.dox	Thu Jun 16 04:37:03 2011 +0000
+++ b/doc/account-signals.dox	Sat Aug 06 03:45:56 2011 +0000
@@ -14,9 +14,13 @@
   @signal account-actions-changed
   @signal account-alias-changed
   @signal account-authorization-requested
+  @signal account-authorization-requested-with-message
   @signal account-authorization-denied
   @signal account-authorization-granted
   @signal account-error-changed
+  @signal account-signed-on
+  @signal account-signed-off
+  @signal account-connection-error
  @endsignals
 
  @see account.h
@@ -155,6 +159,23 @@
   @since 2.3.0
  @endsignaldef
 
+ @signaldef account-authorization-requested-with-message
+  @signalproto
+int (*account_authorization_requested)(PurpleAccount *account, const char *user, const char *message);
+  @endsignalproto
+  @signaldesc
+   Emitted when a user requests authorization.
+  @param account The account.
+  @param user    The name of the user requesting authorization.
+  @param message The authorization request message
+  @return PURPLE_ACCOUNT_RESPONSE_IGNORE to silently ignore the request,
+          PURPLE_ACCOUNT_RESPONSE_DENY to block the request (the sender might
+          get informed, PURPLE_ACCOUNT_RESPONSE_ACCEPT if the request should be
+          granted. If PURPLE_ACCOUNT_RESPONSE_PASS is returned, then the user
+          will be prompted with the request.
+  @since 2.8.0
+ @endsignaldef
+
  @signaldef account-authorization-denied
   @signalproto
 void (*account_authorization_denied)(PurpleAccount *account, const char *user);
@@ -196,5 +217,36 @@
   @since 2.3.0
  @endsignaldef
 
+ @signaldef account-signed-on
+  @signalproto
+void (*signed_on)(PurpleAccount *account);
+  @endsignalproto
+  @signaldesc
+   Emitted when an account has signed on.
+  @param account The account that has signed on.
+  @since 2.7.0
+ @endsignaldef
+
+ @signaldef account-signed-off
+  @signalproto
+void (*signed_off)(PurpleAccount *account);
+  @endsignalproto
+  @signaldesc
+   Emitted when an account has signed off.
+  @param account The account that has signed off.
+  @since 2.7.0
+ @endsignaldef
+
+ @signaldef account-connection-error
+  @signalproto
+void (*connection_error)(PurpleAccount *gc, PurpleConnectionError err, const gchar *desc)
+  @endsignalproto
+  @signaldesc
+   Emitted when a connection error occurs, before @ref signed-off.
+   @param account The account on which the error has occurred
+   @param err     The error that occurred
+   @param desc    A description of the error, giving more information.
+  @since 2.7.0
+ @endsignaldef
  */
 // vim: syntax=c.doxygen tw=75 et
--- a/doc/blist-signals.dox	Thu Jun 16 04:37:03 2011 +0000
+++ b/doc/blist-signals.dox	Sat Aug 06 03:45:56 2011 +0000
@@ -11,6 +11,8 @@
   @signal buddy-removed
   @signal buddy-icon-changed
   @signal blist-node-aliased
+  @signal buddy-caps-changed
+  @signal ui-caps-changed
  @endsignals
 
  @see blist.h
@@ -124,5 +126,29 @@
    Emitted when a blist node (buddy, chat, or contact) is aliased.
   @endsignaldef
 
+ @signaldef buddy-caps-changed
+  @signalproto
+void (*buddy_caps_changed)(PurpleBuddy *buddy, PurpleMediaCaps newcaps,
+    PurpleMediaCaps oldcaps)
+  @endsignalproto
+  @signaldesc
+    Emitted when updating a buddy's media capabilities.
+  @param buddy	  The buddy
+  @param newcaps
+  @param oldcaps
+  @since 2.7.0
+ @endsignaldef
+
+ @signaldef ui-caps-changed
+  @signalproto
+void (*ui_caps_changed)(PurpleMediaCaps newcaps, PurpleMediaCaps oldcaps)
+  @endsignalproto
+  @signaldesc
+    Emitted when updating the media capabilities of the UI.
+  @param newcaps
+  @param oldcaps
+  @since 2.7.0
+ @endsignaldef
+ 
  */
 // vim: syntax=c.doxygen tw=75 et
--- a/doc/connection-signals.dox	Thu Jun 16 04:37:03 2011 +0000
+++ b/doc/connection-signals.dox	Sat Aug 06 03:45:56 2011 +0000
@@ -3,6 +3,7 @@
  @signals
   @signal signing-on
   @signal signed-on
+  @signal autojoin
   @signal signing-off
   @signal signed-off
   @signal connection-error
@@ -30,6 +31,22 @@
   @param gc The connection that has signed on.
  @endsignaldef
 
+ @signaldef autojoin
+  @signalproto
+gboolean (*autojoin)(PurpleConnection *gc);
+  @endsignalproto
+  @signaldesc
+   Emitted when a connection has signed on, after the signed-on signal, to
+   signal UIs to autojoin chats if they wish.  UIs should connect to this
+   with @c PURPLE_SIGNAL_PRIORITY_HIGHEST to allow plugins to block this
+   signal before the UI sees it and then re-emit it later.
+  @param gc The connection that has signed on.
+  @return @c TRUE if the signal was handled or @c FALSE otherwise.  In
+          practice, the return value is irrelevant, as it really only
+          exists so plugins can block the UI's autojoin.
+  @since 2.7.0
+ @endsignaldef
+
  @signaldef signing-off
   @signalproto
 void (*signing_off)(PurpleConnection *gc);
--- a/doc/conversation-signals.dox	Thu Jun 16 04:37:03 2011 +0000
+++ b/doc/conversation-signals.dox	Sat Aug 06 03:45:56 2011 +0000
@@ -32,7 +32,10 @@
   @signal chat-join-failed
   @signal chat-left
   @signal chat-topic-changed
+  @signal cleared-message-history
   @signal conversation-extended-menu
+  @signal sent-attention
+  @signal got-attention
  @endsignals
 
  @see conversation.h
@@ -476,5 +479,43 @@
   @param list   A pointer to the list of actions.
   @since 2.1.0
  @endsignaldef
+
+ @signaldef cleared-message-history
+  @signalproto
+void (*cleared_message_history)(PurpleConversation *conv);
+  @endsignalproto
+  @signaldesc
+    Emitted when the conversation history is cleared.
+  @param conv   The conversation.
+  @since 2.8.0
+ @endsignaldef
+
+ @signaldef sent-attention
+  @signalproto
+void (*got_attention)(PurpleAccount *account, const char *who, 
+	PurpleConversation *conv, guint type)
+  @endsignalproto
+  @signaldesc
+    Emitted when receiving an attention message (buzz, nudge, etc.).
+  @param account  The account
+  @param who      The name of the person receiving the attention
+  @param conv     The conversation
+  @param type     The attention type (an index starting at 0)
+  @since 2.7.0
+ @endsignaldef
+
+ @signaldef got-attention
+  @signalproto
+void (*got_attention)(PurpleAccount *account, const char *who, 
+	PurpleConversation *conv, guint type)
+  @endsignalproto
+  @signaldesc
+    Emitted when receiving an attention message (buzz, nudge, etc.).
+  @param account  The account
+  @param who      The name of the person sending the attention
+  @param conv     The conversation
+  @param type     The attention type (an index starting at 0)
+  @since 2.7.0
+ @endsignaldef
 */
 // vim: syntax=c.doxygen tw=75 et
--- a/doc/finch.1.in	Thu Jun 16 04:37:03 2011 +0000
+++ b/doc/finch.1.in	Sat Aug 06 03:45:56 2011 +0000
@@ -59,7 +59,7 @@
 Display the version information window.
 
 .SH GNT Shortcuts
-You can use the following shortcuts (see the "\*QWidget Actions\*U" section for a more complete list):
+You can use the following shortcuts (see the "Widget Actions" section for a more complete list):
 .TP
 .B Alt \+ a
 Bring up a list of available actions. You can use this list to access the
@@ -305,6 +305,13 @@
 left = focus-prev
 
 .br
+[GntComboBox::binding]
+.br
+down = dropdown
+.br
+up = dropdown
+
+.br
 [GntEntry::binding]
 .br
 c-a = cursor-home
@@ -339,6 +346,10 @@
 .br
 up = suggest-prev
 .br
+page-down = suggest-next-page
+.br
+page-up = suggest-prev-page
+.br
 c-w = delete-prev-word
 .br
 a-b = cursor-prev-word
@@ -348,6 +359,16 @@
 a-d = delete-next-word
 .br
 c-v = clipboard-paste
+.br
+c-p = history-prev
+.br
+c-n = history-next
+.br
+c-r = history-search
+.br
+c-up = history-prev
+.br
+c-down = history-next
 
 .br
 [GntTree::binding]
@@ -366,6 +387,10 @@
 .br
 backspace = move-parent
 .br
+home = move-first
+.br
+end = move-last
+.br
 # Following is the default binding for the context-menu
 .br
 menu = context-menu
@@ -482,6 +507,10 @@
 .br
 a-/ = help-for-widget
 .br
+a-c-j = window-scroll-down
+.br
+a-c-k = window-scroll-up
+.br
 # The following action is still incomplete, and doesn't have a default binding
 .br
 # switch-window-n
--- a/doc/funniest_home_convos.txt	Thu Jun 16 04:37:03 2011 +0000
+++ b/doc/funniest_home_convos.txt	Sat Aug 06 03:45:56 2011 +0000
@@ -530,6 +530,17 @@
 
 --
 
+(14:30:09) linux_user: i have a ?
+(14:31:03) linux_user: when i install this on wine and run it it come up as
+           boxes on the screen
+(14:31:26) nosnilmot: why on earth would you install Pidgin under wine?
+(14:31:41) Err: heh
+(14:31:48) Err: I think my brain just segfaulted on that
+(14:31:58) linux_user: well i am on linux
+(14:32:10) linux_user: linux mint and thay is the only way i can run it
+
+--
+
 14:39 <rrobbertt> Does anyone know a way to get text to speech with pidgin?
 14:41 <elb> do you want to be rooted sooner, or later?
 14:42 <seanegan> good question"; rm -rf ~
--- a/doc/gtkblist-signals.dox	Thu Jun 16 04:37:03 2011 +0000
+++ b/doc/gtkblist-signals.dox	Sat Aug 06 03:45:56 2011 +0000
@@ -5,6 +5,7 @@
   @signal gtkblist-unhiding
   @signal gtkblist-created
   @signal drawing-tooltip
+  @signal drawing-buddy
  @endsignals
 
  @see gtkblist.h
@@ -53,5 +54,17 @@
   @param full Whether we're doing a full tooltip for the priority buddy or
               a compact tooltip for a non-priority buddy.
  @endsignaldef
+
+ @signaldef drawing-buddy
+  @signalproto
+char *(*drawing-buddy)(PurpleBuddy *buddy);
+  @endsignalproto
+  @signaldesc
+   Emitted to allow plugins to handle markup within a buddy's name or to
+   override the default of no formatting for names shown in the buddy list.
+   @param buddy A pointer to the PurpleBuddy that will be displayed.
+   @return The text to display (must be allocated), or @c NULL if no
+           changes to the default behavior are desired.
+ @endsignaldef
 */
 // vim: syntax=c.doxygen tw=75 et
--- a/doc/gtkimhtml-signals.dox	Thu Jun 16 04:37:03 2011 +0000
+++ b/doc/gtkimhtml-signals.dox	Sat Aug 06 03:45:56 2011 +0000
@@ -6,6 +6,7 @@
   @signal format_function_clear
   @signal format_function_toggle
   @signal format_function_update
+  @signal paste
  @endsignals
 
  @see gtkimhtml.h
@@ -57,6 +58,17 @@
   @signaldesc Emitted when the cursor has moved and formatting has changed
   @param imhtml The GtkIMHtml emitting the signal.
   @param data   User defined data.
+
+ @signaldef paste
+ 	@signalproto
+void (*paste) (GtkIMHtml *imhtml, char *format)
+	@endsignalproto
+	@signaldesc Emitted when paste from the clipboard is requested.
+	@param imhtml  The GtkIMHtml emitting the signal.
+	@param format  If 'text', then the formatting of the clipboard content
+	               will be removed before pasting. If empty or 'html', then
+		       the formatting will not be removed. Any other value for
+		       this parameter is ignored and nothing is pasted.
  @endsignaldef
 */
 // vim: syntax=c.doxygen tw=75 et
--- a/doc/gtkrc-2.0	Thu Jun 16 04:37:03 2011 +0000
+++ b/doc/gtkrc-2.0	Sat Aug 06 03:45:56 2011 +0000
@@ -81,6 +81,12 @@
 	bind "<alt>F2" { "format_toggle" (2) }
 # Ctrl-alt-shift-f3 toggles underline
 	bind "<ctrl><alt><shift>F3" { "format_toggle" (4) }
+
+# Ctrl-v to paste as plain text
+	bind "<ctrl>v" { "paste" ("text") }
+
+# Ctrl-Shift-v for normal 'Paste'
+	bind "<ctrl><shift>v" { "paste" ("html") }
 }
   
 widget "*pidgin_conv_entry" binding "my-bindings"
--- a/doc/pidgin.1.in	Thu Jun 16 04:37:03 2011 +0000
+++ b/doc/pidgin.1.in	Sat Aug 06 03:45:56 2011 +0000
@@ -624,6 +624,8 @@
 .br
   Casey Harkins (developer)
 .br
+  Ivan Komarov
+.br
   Gary 'grim' Kramlich (developer)
 .br
   Richard 'rlaager' Laager (developer) <\fIrlaager@pidgin.im\fR>
@@ -662,8 +664,6 @@
 
 Our crazy patch writers include:
 .br
-  Paul Aurich
-.br
   Marcus 'malu' Lundblad
 .br
   Dennis 'EvilDennisR' Ristuccia
--- a/finch/finch.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/finch.c	Sat Aug 06 03:45:56 2011 +0000
@@ -74,11 +74,28 @@
 		 * account "markdoliner."  Please don't use this key for other
 		 * applications.  You can either not specify a client key, in
 		 * which case the default "libpurple" key will be used, or you
-		 * can register for your own client key at
-		 * http://developer.aim.com/manageKeys.jsp
+		 * can try to register your own at the AIM or ICQ web sites
+		 * (although this functionality was removed at some point, it's
+		 * possible it has been re-added).  AOL's old key management
+		 * page is http://developer.aim.com/manageKeys.jsp
 		 */
 		g_hash_table_insert(ui_info, "prpl-aim-clientkey", "ma19sqWV9ymU6UYc");
-		g_hash_table_insert(ui_info, "prpl-icq-clientkey", "ma19sqWV9ymU6UYc");
+
+		/*
+		 * This is the client key for "Pidgin."  It is owned by the AIM
+		 * account "markdoliner."  Please don't use this key for other
+		 * applications.  You can either not specify a client key, in
+		 * which case the default "libpurple" key will be used, or you
+		 * can try to register your own at the AIM or ICQ web sites
+		 * (although this functionality was removed at some point, it's
+		 * possible it has been re-added).  AOL's old key management
+		 * page is http://developer.aim.com/manageKeys.jsp
+		 *
+		 * We used to have a Finch-specific devId/clientkey
+		 * (ma19sqWV9ymU6UYc), but it stopped working, so we switched
+		 * to this one.
+		 */
+		g_hash_table_insert(ui_info, "prpl-icq-clientkey", "ma1cSASNCKFtrdv9");
 
 		/*
 		 * This is the distid for Finch, given to us by AOL.  Please
@@ -252,6 +269,7 @@
 	gboolean opt_version = FALSE;
 	char *opt_config_dir_arg = NULL;
 	gboolean debug_enabled = FALSE;
+	struct stat st;
 
 	struct option long_options[] = {
 		{"config",   required_argument, NULL, 'c'},
@@ -361,6 +379,8 @@
 	purple_idle_set_ui_ops(finch_idle_get_ui_ops());
 
 	path = g_build_filename(purple_user_dir(), "plugins", NULL);
+	if (!g_stat(path, &st))
+		g_mkdir(path, S_IRUSR | S_IWUSR | S_IXUSR);
 	purple_plugins_add_search_path(path);
 	g_free(path);
 
@@ -419,7 +439,7 @@
 	/* Initialize the libpurple stuff */
 	if (!init_libpurple(*argc, *argv))
 		return FALSE;
- 
+
 	purple_blist_show();
 	return TRUE;
 }
@@ -431,9 +451,7 @@
 	g_thread_init(NULL);
 
 	g_set_prgname("Finch");
-#if GLIB_CHECK_VERSION(2,2,0)
 	g_set_application_name(_("Finch"));
-#endif
 
 	if (gnt_start(&argc, &argv)) {
 		gnt_main();
--- a/finch/getopt.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/getopt.c	Sat Aug 06 03:45:56 2011 +0000
@@ -178,7 +178,7 @@
 {
   REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
 } ordering;
-
+
 #ifdef	__GNU_LIBRARY__
 /* We want to avoid inclusion of string.h with non-GNU libraries
    because there are many ways it can cause trouble.
@@ -219,7 +219,7 @@
     to[i] = from[i];
 }
 #endif				/* GNU C library.  */
-
+
 /* Handle permutation of arguments.  */
 
 /* Describe the part of ARGV that contains non-options that have
@@ -259,7 +259,7 @@
   first_nonopt += (optind - last_nonopt);
   last_nonopt = optind;
 }
-
+
 /* Scan elements of ARGV (whose length is ARGC) for option characters
    given in OPTSTRING.
 
@@ -663,7 +663,7 @@
 }
 
 #endif	/* _LIBC or not __GNU_LIBRARY__.  */
-
+
 #ifdef TEST
 
 /* Compile with -DTEST to make an executable for use in testing
--- a/finch/getopt1.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/getopt1.c	Sat Aug 06 03:45:56 2011 +0000
@@ -81,7 +81,7 @@
 
 
 #endif	/* _LIBC or not __GNU_LIBRARY__.  */
-
+
 #ifdef TEST
 
 #include <stdio.h>
--- a/finch/gntaccount.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/gntaccount.c	Sat Aug 06 03:45:56 2011 +0000
@@ -125,7 +125,8 @@
 
 	if (value == NULL || *value == '\0')
 	{
-		purple_notify_error(NULL, _("Error"), _("Account was not added"),
+		purple_notify_error(NULL, _("Error"),
+				dialog->account ? _("Account was not modified") : _("Account was not added"),
 				_("Username of an account must be non-empty."));
 		return;
 	}
@@ -160,8 +161,28 @@
 		account = dialog->account;
 
 		/* Protocol */
-		purple_account_set_protocol_id(account, purple_plugin_get_id(plugin));
-		purple_account_set_username(account, username->str);
+		if (purple_account_is_disconnected(account)) {
+			purple_account_set_protocol_id(account, purple_plugin_get_id(plugin));
+			purple_account_set_username(account, username->str);
+		} else {
+			const char *old = purple_account_get_protocol_id(account);
+			char *oldprpl;
+			if (strcmp(old, purple_plugin_get_id(plugin))) {
+				purple_notify_error(NULL, _("Error"), _("Account was not modified"),
+						_("The account's protocol cannot be changed while it is connected to the server."));
+				return;
+			}
+
+			oldprpl = g_strdup(purple_normalize(account, purple_account_get_username(account)));
+			if (g_utf8_collate(oldprpl, purple_normalize(account, username->str))) {
+				purple_notify_error(NULL, _("Error"), _("Account was not modified"),
+						_("The account's username cannot be changed while it is connected to the server."));
+				g_free(oldprpl);
+				return;
+			}
+			g_free(oldprpl);
+			purple_account_set_username(account, username->str);
+		}
 	}
 	g_string_free(username, TRUE);
 
@@ -215,7 +236,8 @@
 			}
 			else if (type == PURPLE_PREF_STRING_LIST)
 			{
-				/* TODO: */
+				gchar *value = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(entry));
+				purple_account_set_string(account, setting, value);
 			}
 			else
 			{
@@ -245,6 +267,17 @@
 		}
 	}
 
+	/* In case of a new account, the 'Accounts' window is updated from the account-added
+	 * callback. In case of changes in an existing account, we need to explicitly do it
+	 * here.
+	 */
+	if (dialog->account != NULL && accounts.window) {
+		gnt_tree_change_text(GNT_TREE(accounts.tree), dialog->account,
+				0, purple_account_get_username(dialog->account));
+		gnt_tree_change_text(GNT_TREE(accounts.tree), dialog->account,
+				1, purple_account_get_protocol_name(dialog->account));
+	}
+
 	gnt_widget_destroy(dialog->window);
 }
 
@@ -275,7 +308,7 @@
 	if (!plugin)
 		return;
 	prplinfo = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);
-	
+
 	username = dialog->account ? g_strdup(purple_account_get_username(dialog->account)) : NULL;
 
 	for (iter = prplinfo->user_splits; iter; iter = iter->next)
@@ -398,8 +431,26 @@
 
 			if (type == PURPLE_PREF_STRING_LIST)
 			{
-				/* TODO: Use a combobox */
-				/*       Don't forget to append the widget to prpl_entries */
+				GntWidget *combo = gnt_combo_box_new();
+				GList *opt_iter = purple_account_option_get_list(option);
+				const char *dv = purple_account_option_get_default_list_value(option);
+				const char *active = dv;
+
+				if (account)
+					active = purple_account_get_string(account,
+						purple_account_option_get_setting(option), dv);
+
+				gnt_box_add_widget(GNT_BOX(box), combo);
+				dialog->prpl_entries = g_list_append(dialog->prpl_entries, combo);
+
+				for ( ; opt_iter; opt_iter = opt_iter->next)
+				{
+					PurpleKeyValuePair *kvp = opt_iter->data;
+					gnt_combo_box_add_data(GNT_COMBO_BOX(combo), kvp->value, kvp->key);
+
+					if (g_str_equal(kvp->value, active))
+						gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), kvp->value);
+				}
 			}
 			else
 			{
@@ -603,7 +654,7 @@
 	button = gnt_button_new(_("Cancel"));
 	gnt_box_add_widget(GNT_BOX(hbox), button);
 	g_signal_connect_swapped(G_OBJECT(button), "activate", G_CALLBACK(gnt_widget_destroy), window);
-	
+
 	button = gnt_button_new(_("Save"));
 	gnt_box_add_widget(GNT_BOX(hbox), button);
 	g_signal_connect_swapped(G_OBJECT(button), "activate", G_CALLBACK(save_account_cb), dialog);
--- a/finch/gntblist.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/gntblist.c	Sat Aug 06 03:45:56 2011 +0000
@@ -144,7 +144,7 @@
 static void blist_show(PurpleBuddyList *list);
 static void update_node_display(PurpleBlistNode *buddy, FinchBlist *ggblist);
 static void update_buddy_display(PurpleBuddy *buddy, FinchBlist *ggblist);
-static void account_signed_on_cb(PurpleConnection *pc, gpointer null);
+static gboolean account_autojoin_cb(PurpleConnection *pc, gpointer null);
 static void finch_request_add_buddy(PurpleAccount *account, const char *username, const char *grp, const char *alias);
 static void menu_group_set_cb(GntMenuItem *item, gpointer null);
 
@@ -626,6 +626,7 @@
 	const char *username = purple_request_fields_get_string(allfields, "screenname");
 	const char *alias = purple_request_fields_get_string(allfields, "alias");
 	const char *group = purple_request_fields_get_string(allfields, "group");
+	const char *invite = purple_request_fields_get_string(allfields, "invite");
 	PurpleAccount *account = purple_request_fields_get_account(allfields, "account");
 	const char *error = NULL;
 	PurpleGroup *grp;
@@ -662,7 +663,7 @@
 		purple_blist_add_buddy(buddy, NULL, grp, NULL);
 	}
 
-	purple_account_add_buddy(account, buddy);
+	purple_account_add_buddy_with_invite(account, buddy, invite);
 }
 
 static void
@@ -680,6 +681,9 @@
 	field = purple_request_field_string_new("alias", _("Alias (optional)"), alias, FALSE);
 	purple_request_field_group_add_field(group, field);
 
+	field = purple_request_field_string_new("invite", _("Invite message (optional)"), NULL, FALSE);
+	purple_request_field_group_add_field(group, field);
+
 	field = purple_request_field_string_new("group", _("Add in group"), grp, FALSE);
 	purple_request_field_group_add_field(group, field);
 	purple_request_field_set_type_hint(field, "group");
@@ -1117,6 +1121,8 @@
 			list = g_list_delete_link(list, list))
 	{
 		PurpleMenuAction *act = (PurpleMenuAction *) list->data;
+		if (!act)
+			continue;
 		act->data = node;
 		gnt_append_menu_action(menu, act, NULL);
 		g_signal_connect_swapped(G_OBJECT(menu), "destroy",
@@ -1805,7 +1811,7 @@
 			}
 		}
 	}
-	
+
 	tmp = purple_notify_user_info_get_text_with_newline(user_info, "<BR>");
 	purple_notify_user_info_destroy(user_info);
 
@@ -2064,7 +2070,7 @@
 		gnt_tree_set_compare_func(GNT_TREE(ggblist->tree),
 			(GCompareFunc)blist_node_compare_log);
 	}
-	
+
 	list = purple_get_blist();
 	node = purple_blist_get_root();
 	while (node)
@@ -2213,8 +2219,10 @@
 	purple_prefs_connect_callback(finch_blist_get_handle(),
 			PREF_ROOT "/grouping", redraw_blist, NULL);
 
-	purple_signal_connect(purple_connections_get_handle(), "signed-on", purple_blist_get_handle(),
-			G_CALLBACK(account_signed_on_cb), NULL);
+	purple_signal_connect_priority(purple_connections_get_handle(),
+	                               "autojoin", purple_blist_get_handle(),
+			               G_CALLBACK(account_autojoin_cb), NULL,
+	                               PURPLE_SIGNAL_PRIORITY_HIGHEST);
 
 	finch_blist_install_manager(&default_manager);
 
@@ -2684,10 +2692,11 @@
 	return FALSE;
 }
 
-static void
-account_signed_on_cb(PurpleConnection *gc, gpointer null)
+static gboolean
+account_autojoin_cb(PurpleConnection *gc, gpointer null)
 {
 	g_idle_add(auto_join_chats, gc);
+	return TRUE;
 }
 
 static void toggle_pref_cb(GntMenuItem *item, gpointer n)
--- a/finch/gntcertmgr.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/gntcertmgr.c	Sat Aug 06 03:45:56 2011 +0000
@@ -193,7 +193,7 @@
 	subject = purple_certificate_get_subject_name(crt);
 
 	secondary = g_strdup_printf(_("Common name: %s\n\nSHA1 fingerprint:\n%s"), subject, fpr_sha1_asc);
-	
+
 	purple_notify_info(NULL,
 			   _("SSL Host Certificate"), primary, secondary);
 
--- a/finch/gntconn.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/gntconn.c	Sat Aug 06 03:45:56 2011 +0000
@@ -159,7 +159,7 @@
 	return &handle;
 }
 
-static PurpleConnectionUiOps ops = 
+static PurpleConnectionUiOps ops =
 {
 	NULL, /* connect_progress */
 	NULL, /* connected */
--- a/finch/gntconv.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/gntconv.c	Sat Aug 06 03:45:56 2011 +0000
@@ -396,10 +396,18 @@
 }
 
 static void
+cleared_message_history_cb(PurpleConversation *conv, gpointer data)
+{
+	FinchConv *ggc = FINCH_GET_DATA(conv);
+	if (ggc)
+		gnt_text_view_clear(GNT_TEXT_VIEW(ggc->tv));
+}
+
+static void
 clear_scrollback_cb(GntMenuItem *item, gpointer ggconv)
 {
 	FinchConv *ggc = ggconv;
-	gnt_text_view_clear(GNT_TEXT_VIEW(ggc->tv));
+	purple_conversation_clear_message_history(ggc->active_conv);
 }
 
 static void
@@ -1155,7 +1163,7 @@
 	return FALSE;
 }
 
-static PurpleConversationUiOps conv_ui_ops = 
+static PurpleConversationUiOps conv_ui_ops =
 {
 	finch_create_conversation,
 	finch_destroy_conversation,
@@ -1264,8 +1272,6 @@
 clear_command_cb(PurpleConversation *conv,
                  const char *cmd, char **args, char **error, void *data)
 {
-	FinchConv *ggconv = FINCH_GET_DATA(conv);
-	gnt_text_view_clear(GNT_TEXT_VIEW(ggconv->tv));
 	purple_conversation_clear_message_history(conv);
 	return PURPLE_CMD_RET_OK;
 }
@@ -1318,7 +1324,6 @@
 	return PURPLE_CMD_RET_OK;
 }
 
-#if GLIB_CHECK_VERSION(2,6,0)
 static PurpleCmdRet
 cmd_message_color(PurpleConversation *conv, const char *cmd, char **args, char **error, gpointer data)
 {
@@ -1359,7 +1364,6 @@
 
 	return PURPLE_CMD_RET_OK;
 }
-#endif
 
 static PurpleCmdRet
 users_command_cb(PurpleConversation *conv, const char *cmd, char **args, char **error, gpointer data)
@@ -1445,7 +1449,6 @@
 	                  PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL,
 	                  cmd_show_window, _("statuses: Show the savedstatuses window."), finch_savedstatus_show_all);
 
-#if GLIB_CHECK_VERSION(2,6,0)
 	/* Allow customizing the message colors using a command during run-time */
 	purple_cmd_register("msgcolor", "www", PURPLE_CMD_P_DEFAULT,
 			PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL,
@@ -1455,7 +1458,14 @@
 				                 "    &lt;foreground/background&gt;: black, red, green, blue, white, gray, darkgray, magenta, cyan, default<br><br>"
 								 "EXAMPLE:<br>    msgcolor send cyan default"),
 			NULL);
-#endif
+	purple_cmd_register("msgcolour", "www", PURPLE_CMD_P_DEFAULT,
+			PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL,
+			cmd_message_color, _("msgcolor &lt;class&gt; &lt;foreground&gt; &lt;background&gt;: "
+				                 "Set the color for different classes of messages in the conversation window.<br>"
+				                 "    &lt;class&gt;: receive, send, highlight, action, timestamp<br>"
+				                 "    &lt;foreground/background&gt;: black, red, green, blue, white, gray, darkgray, magenta, cyan, default<br><br>"
+								 "EXAMPLE:<br>    msgcolor send cyan default"),
+			NULL);
 
 	purple_signal_connect(purple_conversations_get_handle(), "buddy-typing", finch_conv_get_handle(),
 					PURPLE_CALLBACK(update_buddy_typing), NULL);
@@ -1463,6 +1473,8 @@
 					PURPLE_CALLBACK(update_buddy_typing), NULL);
 	purple_signal_connect(purple_conversations_get_handle(), "chat-left", finch_conv_get_handle(),
 					PURPLE_CALLBACK(chat_left_cb), NULL);
+	purple_signal_connect(purple_conversations_get_handle(), "cleared-message-history", finch_conv_get_handle(),
+					PURPLE_CALLBACK(cleared_message_history_cb), NULL);
 	purple_signal_connect(purple_blist_get_handle(), "buddy-signed-on", finch_conv_get_handle(),
 					PURPLE_CALLBACK(buddy_signed_on_off), NULL);
 	purple_signal_connect(purple_blist_get_handle(), "buddy-signed-off", finch_conv_get_handle(),
--- a/finch/gntdebug.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/gntdebug.c	Sat Aug 06 03:45:56 2011 +0000
@@ -77,7 +77,10 @@
 		}
 		return;
 	}
-	pipe(pipes);
+	if (pipe(pipes)) {
+		readhandle = -1;
+		return;
+	};
 	dup2(pipes[1], STDERR_FILENO);
 
 	stderrch = g_io_channel_unix_new(pipes[0]);
--- a/finch/gntft.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/gntft.c	Sat Aug 06 03:45:56 2011 +0000
@@ -356,7 +356,7 @@
 
 	if (xfer_dialog->num_transfers == 0 && !xfer_dialog->keep_open)
 		finch_xfer_dialog_destroy();
-	else 
+	else
 		update_title_progress();
 	purple_xfer_unref(xfer);
 }
@@ -383,12 +383,10 @@
 		return;
 	}
 
-	data = FINCHXFER(xfer);
-
 	update_title_progress();
 
 	if (purple_xfer_is_canceled(xfer))
-		status = _("Canceled");
+		status = _("Cancelled");
 	else
 		status = _("Failed");
 
@@ -402,7 +400,7 @@
 	char *size_str, *remaining_str;
 	time_t current_time;
 	char prog_str[5];
-	double kb_sent, kb_rem;
+	double kb_sent;
 	double kbps = 0.0;
 	time_t elapsed, now;
 	char *kbsec;
@@ -412,7 +410,6 @@
 		now = time(NULL);
 
 	kb_sent = purple_xfer_get_bytes_sent(xfer) / 1024.0;
-	kb_rem  = purple_xfer_get_bytes_remaining(xfer) / 1024.0;
 	elapsed = (purple_xfer_get_start_time(xfer) > 0 ? now - purple_xfer_get_start_time(xfer) : 0);
 	kbps    = (elapsed > 0 ? (kb_sent / elapsed) : 0);
 
--- a/finch/gntft.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/gntft.h	Sat Aug 06 03:45:56 2011 +0000
@@ -72,9 +72,9 @@
 void finch_xfer_dialog_remove_xfer(PurpleXfer *xfer);
 
 /**
- * Indicate in a file transfer dialog that a transfer was canceled.
+ * Indicate in a file transfer dialog that a transfer was cancelled.
  *
- * @param xfer   The file transfer that was canceled.
+ * @param xfer   The file transfer that was cancelled.
  */
 void finch_xfer_dialog_cancel_xfer(PurpleXfer *xfer);
 
--- a/finch/gntlog.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/gntlog.h	Sat Aug 06 03:45:56 2011 +0000
@@ -8,7 +8,7 @@
  * Finch is the legal property of its developers, whose names are too numerous
  * to list here.  Please refer to the COPYRIGHT file distributed with this
  * source distribution.
- * 
+ *
  * 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
--- a/finch/gntmedia.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/gntmedia.c	Sat Aug 06 03:45:56 2011 +0000
@@ -252,7 +252,7 @@
 	} else if (state == PURPLE_MEDIA_STATE_CONNECTED) {
 		finch_media_connected_cb(media, gntmedia);
 	} else if (state == PURPLE_MEDIA_STATE_NEW &&
-			sid != NULL && name != NULL && 
+			sid != NULL && name != NULL &&
 			purple_media_is_initiator(media, sid, name) == FALSE) {
 		PurpleAccount *account;
 		PurpleBuddy *buddy;
@@ -360,7 +360,7 @@
 			g_value_set_object(value, media->priv->media);
 			break;
 		default:
-			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);	
+			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 			break;
 	}
 }
@@ -480,7 +480,7 @@
 			PURPLE_CMD_FLAG_IM, NULL,
 			call_cmd_cb, _("call: Make an audio call."), NULL);
 
-	purple_media_manager_set_ui_caps(manager, 
+	purple_media_manager_set_ui_caps(manager,
 			PURPLE_MEDIA_CAPS_AUDIO |
 			PURPLE_MEDIA_CAPS_AUDIO_SINGLE_DIRECTION);
 
--- a/finch/gntnotify.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/gntnotify.c	Sat Aug 06 03:45:56 2011 +0000
@@ -84,6 +84,10 @@
 
 	if (secondary) {
 		GntWidget *msg;
+		/* XXX: This is broken.  type is PurpleNotifyMsgType, not
+		 * PurpleNotifyType.  Also, the if() followed by the
+		 * inner switch doesn't make much sense.
+		 */
 		if (type == PURPLE_NOTIFY_FORMATTED) {
 			int width = -1, height = -1;
 			char *plain = (char*)secondary;
@@ -130,7 +134,7 @@
 
 	while (widget->parent)
 		widget = widget->parent;
-	
+
 	if (type == PURPLE_NOTIFY_SEARCHRESULTS)
 		purple_notify_searchresults_free(g_object_get_data(handle, "notify-results"));
 #if 1
@@ -489,7 +493,7 @@
 	return finch_notify_message(PURPLE_NOTIFY_URI, _("URI"), url, NULL);
 }
 
-static PurpleNotifyUiOps ops = 
+static PurpleNotifyUiOps ops =
 {
 	finch_notify_message,
 	finch_notify_email,
--- a/finch/gntplugin.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/gntplugin.c	Sat Aug 06 03:45:56 2011 +0000
@@ -64,7 +64,7 @@
 static void
 decide_conf_button(PurplePlugin *plugin)
 {
-	if (purple_plugin_is_loaded(plugin) && 
+	if (purple_plugin_is_loaded(plugin) &&
 		((PURPLE_IS_GNT_PLUGIN(plugin) &&
 			FINCH_PLUGIN_UI_INFO(plugin) != NULL) ||
 		(plugin->info->prefs_info &&
@@ -262,7 +262,7 @@
 	PurplePlugin *plugin;
 
 	g_return_if_fail(plugins.window);
-	
+
 	plugin = purple_plugin_probe(filename);
 	if (!plugin) {
 		purple_notify_error(handle, _("Error loading plugin"),
@@ -498,7 +498,7 @@
 						break;
 				}
 				stringlist = g_list_prepend(stringlist, value);
-				purple_request_field_list_add(field, label, value);
+				purple_request_field_list_add_icon(field, label, NULL, value);
 				if (strcmp(value, current_value) == 0)
 					purple_request_field_list_add_selected(field, label);
 				list = list->next->next;
--- a/finch/gntprefs.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/gntprefs.c	Sat Aug 06 03:45:56 2011 +0000
@@ -171,7 +171,7 @@
 				default:
 					break;
 			}
-			purple_request_field_list_add(field, data, iter->data);
+			purple_request_field_list_add_icon(field, data, NULL, iter->data);
 			if (select)
 				purple_request_field_list_add_selected(field, data);
 		}
@@ -180,21 +180,21 @@
 	return field;
 }
 
-static Prefs blist[] = 
+static Prefs blist[] =
 {
 	{PURPLE_PREF_BOOLEAN, "/finch/blist/idletime", N_("Show Idle Time"), NULL},
 	{PURPLE_PREF_BOOLEAN, "/finch/blist/showoffline", N_("Show Offline Buddies"), NULL},
 	{PURPLE_PREF_NONE, NULL, NULL, NULL}
 };
 
-static Prefs convs[] = 
+static Prefs convs[] =
 {
 	{PURPLE_PREF_BOOLEAN, "/finch/conversations/timestamps", N_("Show Timestamps"), NULL},
 	{PURPLE_PREF_BOOLEAN, "/finch/conversations/notify_typing", N_("Notify buddies when you are typing"), NULL},
 	{PURPLE_PREF_NONE, NULL, NULL, NULL}
 };
 
-static Prefs logging[] = 
+static Prefs logging[] =
 {
 	{PURPLE_PREF_STRING, "/purple/logging/format", N_("Log format"), get_log_options},
 	{PURPLE_PREF_BOOLEAN, "/purple/logging/log_ims", N_("Log IMs"), NULL},
--- a/finch/gntrequest.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/gntrequest.c	Sat Aug 06 03:45:56 2011 +0000
@@ -243,7 +243,7 @@
 
 	setup_default_callback(window, cancel_cb, user_data);
 	gnt_widget_show(window);
-	
+
 	return window;
 }
 
@@ -349,10 +349,9 @@
 			}
 			else if (type == PURPLE_REQUEST_FIELD_LIST)
 			{
-				GList *list = NULL;
+				GList *list = NULL, *iter;
 				if (purple_request_field_list_get_multi_select(field))
 				{
-					GList *iter;
 					GntWidget *tree = FINCH_GET_DATA(field);
 
 					iter = purple_request_field_list_get_items(field);
@@ -361,14 +360,23 @@
 						const char *text = iter->data;
 						gpointer key = purple_request_field_list_get_data(field, text);
 						if (gnt_tree_get_choice(GNT_TREE(tree), key))
-							list = g_list_prepend(list, key);
+							list = g_list_prepend(list, (gpointer)text);
 					}
 				}
 				else
 				{
 					GntWidget *combo = FINCH_GET_DATA(field);
 					gpointer data = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo));
-					list = g_list_append(list, data);
+
+					iter = purple_request_field_list_get_items(field);
+					for (; iter; iter = iter->next) {
+						const char *text = iter->data;
+						gpointer key = purple_request_field_list_get_data(field, text);
+						if (key == data) {
+							list = g_list_prepend(list, (gpointer)text);
+							break;
+						}
+					}
 				}
 
 				purple_request_field_list_set_selected(field, list);
@@ -815,7 +823,7 @@
 	for (list = purple_request_fields_get_groups(allfields); list; list = list->next) {
 		PurpleRequestFieldGroup *group = list->data;
 		GList *fields = purple_request_field_group_get_fields(group);
-		
+
 		for (; fields ; fields = fields->next) {
 			PurpleRequestField *field = fields->data;
 			PurpleRequestFieldType type = purple_request_field_get_type(field);
@@ -826,6 +834,7 @@
 			switch (type) {
 				case PURPLE_REQUEST_FIELD_LIST:
 					val = purple_request_field_list_get_selected(field)->data;
+					val = purple_request_field_list_get_data(field, val);
 					break;
 				case PURPLE_REQUEST_FIELD_BOOLEAN:
 					val = GINT_TO_POINTER(purple_request_field_bool_get_value(field));
--- a/finch/gntsound.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/gntsound.c	Sat Aug 06 03:45:56 2011 +0000
@@ -104,7 +104,8 @@
 	{PURPLE_SOUND_CHAT_YOU_SAY, N_("You talk in chat"), "send_chat_msg", "send.wav", NULL},
 	{PURPLE_SOUND_CHAT_SAY,     N_("Others talk in chat"), "chat_msg_recv", "receive.wav", NULL},
 	{PURPLE_SOUND_POUNCE_DEFAULT, NULL, "pounce_default", "alert.wav", NULL},
-	{PURPLE_SOUND_CHAT_NICK,    N_("Someone says your username in chat"), "nick_said", "alert.wav", NULL}
+	{PURPLE_SOUND_CHAT_NICK,    N_("Someone says your username in chat"), "nick_said", "alert.wav", NULL},
+	{PURPLE_SOUND_GOT_ATTENTION, N_("Attention received"), "got_attention", "alert.wav", NULL}
 };
 
 const char *
@@ -273,6 +274,14 @@
 		play_conv_event(conv, event);
 }
 
+static void
+got_attention_cb(PurpleAccount *account, const char *who,
+	PurpleConversation *conv, guint type, PurpleSoundEventID event)
+{
+	play_conv_event(conv, event);
+}
+
+
 /*
  * We mute sounds for the 10 seconds after you log in so that
  * you don't get flooded with sounds when the blist shows all
@@ -300,34 +309,22 @@
 static void
 initialize_profile(const char *name, PurplePrefType type, gconstpointer val, gpointer null)
 {
+	FinchSoundEvent *event;
 	if (purple_prefs_exists(make_pref("")))
 		return;
 
 	purple_prefs_add_none(make_pref(""));
 	purple_prefs_add_none(make_pref("/enabled"));
 	purple_prefs_add_none(make_pref("/file"));
-	purple_prefs_add_bool(make_pref("/enabled/login"), FALSE);
-	purple_prefs_add_path(make_pref("/file/login"), "");
-	purple_prefs_add_bool(make_pref("/enabled/logout"), FALSE);
-	purple_prefs_add_path(make_pref("/file/logout"), "");
-	purple_prefs_add_bool(make_pref("/enabled/im_recv"), FALSE);
-	purple_prefs_add_path(make_pref("/file/im_recv"), "");
-	purple_prefs_add_bool(make_pref("/enabled/first_im_recv"), FALSE);
-	purple_prefs_add_path(make_pref("/file/first_im_recv"), "");
-	purple_prefs_add_bool(make_pref("/enabled/send_im"), FALSE);
-	purple_prefs_add_path(make_pref("/file/send_im"), "");
-	purple_prefs_add_bool(make_pref("/enabled/join_chat"), FALSE);
-	purple_prefs_add_path(make_pref("/file/join_chat"), "");
-	purple_prefs_add_bool(make_pref("/enabled/left_chat"), FALSE);
-	purple_prefs_add_path(make_pref("/file/left_chat"), "");
-	purple_prefs_add_bool(make_pref("/enabled/send_chat_msg"), FALSE);
-	purple_prefs_add_path(make_pref("/file/send_chat_msg"), "");
-	purple_prefs_add_bool(make_pref("/enabled/chat_msg_recv"), FALSE);
-	purple_prefs_add_path(make_pref("/file/chat_msg_recv"), "");
-	purple_prefs_add_bool(make_pref("/enabled/nick_said"), FALSE);
-	purple_prefs_add_path(make_pref("/file/nick_said"), "");
-	purple_prefs_add_bool(make_pref("/enabled/pounce_default"), FALSE);
-	purple_prefs_add_path(make_pref("/file/pounce_default"), "");
+
+	for (event = sounds; event - sounds < PURPLE_NUM_SOUNDS; event++) {
+		char pref[512];
+		g_snprintf(pref, sizeof(pref), "/enabled/%s", event->pref);
+		purple_prefs_add_bool(make_pref(pref), FALSE);
+		g_snprintf(pref, sizeof(pref), "/file/%s", event->pref);
+		purple_prefs_add_path(make_pref(pref), "");
+	}
+
 	purple_prefs_add_bool(make_pref("/conv_focus"), FALSE);
 	purple_prefs_add_bool(make_pref("/mute"), FALSE);
 	purple_prefs_add_path(make_pref("/command"), "");
@@ -336,6 +333,25 @@
 }
 
 static void
+update_profiles(void)
+{
+	GList *list = finch_sound_get_profiles();
+	for (; list; list = g_list_delete_link(list, list)) {
+		char pname[512];
+
+		/* got_attention was added in libpurple 2.7.0 */
+		g_snprintf(pname, sizeof(pname), FINCH_PREFS_ROOT "/sound/profiles/%s%s",
+				(char *)list->data, "/enabled/got_attention");
+		purple_prefs_add_bool(pname, FALSE);
+		g_snprintf(pname, sizeof(pname), FINCH_PREFS_ROOT "/sound/profiles/%s%s",
+				(char *)list->data, "/file/got_attention");
+		purple_prefs_add_path(pname, "");
+
+		g_free(list->data);
+	}
+}
+
+static void
 finch_sound_init(void)
 {
 	void *gnt_sound_handle = finch_sound_get_handle();
@@ -356,7 +372,7 @@
 	purple_prefs_connect_callback(gnt_sound_handle, FINCH_PREFS_ROOT "/sound/actprofile", initialize_profile, NULL);
 	purple_prefs_trigger_callback(FINCH_PREFS_ROOT "/sound/actprofile");
 
-	
+
 #ifdef USE_GSTREAMER
 	purple_debug_info("sound", "Initializing sound output drivers.\n");
 #if (GST_VERSION_MAJOR > 0 || \
@@ -399,6 +415,11 @@
 	purple_signal_connect(conv_handle, "received-chat-msg",
 						gnt_sound_handle, PURPLE_CALLBACK(chat_msg_received_cb),
 						GINT_TO_POINTER(PURPLE_SOUND_CHAT_SAY));
+	purple_signal_connect(conv_handle, "got-attention",
+						gnt_sound_handle, PURPLE_CALLBACK(got_attention_cb),
+						GINT_TO_POINTER(PURPLE_SOUND_GOT_ATTENTION));
+
+	update_profiles();
 }
 
 static void
@@ -533,11 +554,11 @@
 	}
 
 	play = gst_element_factory_make("playbin", "play");
-	
+
 	if (play == NULL) {
 		return;
 	}
-	
+
 	uri = g_strdup_printf("file://%s", filename);
 
 	g_object_set(G_OBJECT(play), "uri", uri,
@@ -559,18 +580,12 @@
 #else /* _WIN32 */
 	purple_debug_info("sound", "Playing %s\n", filename);
 
-	if (G_WIN32_HAVE_WIDECHAR_API ()) {
+	{
 		wchar_t *wc_filename = g_utf8_to_utf16(filename,
 				-1, NULL, NULL, NULL);
 		if (!PlaySoundW(wc_filename, NULL, SND_ASYNC | SND_FILENAME))
 			purple_debug(PURPLE_DEBUG_ERROR, "sound", "Error playing sound.\n");
 		g_free(wc_filename);
-	} else {
-		char *l_filename = g_locale_from_utf8(filename,
-				-1, NULL, NULL, NULL);
-		if (!PlaySoundA(l_filename, NULL, SND_ASYNC | SND_FILENAME))
-			purple_debug(PURPLE_DEBUG_ERROR, "sound", "Error playing sound.\n");
-		g_free(l_filename);
 	}
 #endif /* _WIN32 */
 }
@@ -583,7 +598,8 @@
 	if ((event == PURPLE_SOUND_BUDDY_ARRIVE) && mute_login_sounds)
 		return;
 
-	if (event >= PURPLE_NUM_SOUNDS) {
+	if (event >= PURPLE_NUM_SOUNDS ||
+			event >= G_N_ELEMENTS(sounds)) {
 		purple_debug_error("sound", "got request for unknown sound: %d\n", event);
 		return;
 	}
@@ -672,7 +688,7 @@
 
 	gnt_tree_change_text(GNT_TREE(pref_dialog->events), GINT_TO_POINTER(event->id), 1, file);
 	gnt_tree_set_choice(GNT_TREE(pref_dialog->events), GINT_TO_POINTER(event->id), TRUE);
-	
+
 	gnt_widget_destroy(GNT_WIDGET(w));
 }
 
@@ -715,7 +731,7 @@
 reset_cb(GntWidget *button, gpointer null)
 {
 	/* Don't dereference this pointer ! */
-	gpointer key = gnt_tree_get_selection_data(GNT_TREE(pref_dialog->events)); 
+	gpointer key = gnt_tree_get_selection_data(GNT_TREE(pref_dialog->events));
 
 	FinchSoundEvent * event = &sounds[GPOINTER_TO_INT(key)];
 	g_free(event->file);
@@ -865,7 +881,7 @@
 		gnt_entry_set_text(entry, "");
 		gnt_tree_set_selected(GNT_TREE(pref_dialog->profiles), key);
 		finch_sound_set_active_profile(key);
-	} else 
+	} else
 		reload_pref_window(profile);
 }
 
@@ -966,13 +982,13 @@
 	gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox), "nosound", _("No Sound"));
 
 	label = gnt_label_new_with_format(_("Sound Method"), GNT_TEXT_FLAG_BOLD);
-	gnt_box_add_widget(GNT_BOX(box), label); 
+	gnt_box_add_widget(GNT_BOX(box), label);
 	tmpbox = gnt_hbox_new(TRUE);
 	gnt_box_set_fill(GNT_BOX(tmpbox), FALSE);
 	gnt_box_set_pad(GNT_BOX(tmpbox), 0);
 	gnt_box_add_widget(GNT_BOX(tmpbox), gnt_label_new(_("Method: ")));
 	gnt_box_add_widget(GNT_BOX(tmpbox), cmbox);
-	gnt_box_add_widget(GNT_BOX(box), tmpbox); 
+	gnt_box_add_widget(GNT_BOX(box), tmpbox);
 
 	tmpbox = gnt_hbox_new(TRUE);
 	gnt_box_set_pad(GNT_BOX(tmpbox), 0);
@@ -985,7 +1001,7 @@
 	gnt_box_add_widget(GNT_BOX(box), gnt_line_new(FALSE));
 
 	/* Sound options */
-	gnt_box_add_widget(GNT_BOX(box), gnt_label_new_with_format(_("Sound Options"), GNT_TEXT_FLAG_BOLD)); 
+	gnt_box_add_widget(GNT_BOX(box), gnt_label_new_with_format(_("Sound Options"), GNT_TEXT_FLAG_BOLD));
 	pref_dialog->conv_focus = chkbox = gnt_check_box_new(_("Sounds when conversation has focus"));
 	gnt_box_add_widget(GNT_BOX(box), chkbox);
 
@@ -1022,7 +1038,7 @@
 	gnt_box_add_widget(GNT_BOX(win), gnt_hline_new());
 
 	/* Sound events */
-	gnt_box_add_widget(GNT_BOX(win), gnt_label_new_with_format(_("Sound Events"), GNT_TEXT_FLAG_BOLD)); 
+	gnt_box_add_widget(GNT_BOX(win), gnt_label_new_with_format(_("Sound Events"), GNT_TEXT_FLAG_BOLD));
 	pref_dialog->events = tree = gnt_tree_new_with_columns(2);
 	gnt_tree_set_column_titles(GNT_TREE(tree), _("Event"), _("File"));
 	gnt_tree_set_show_title(GNT_TREE(tree), TRUE);
--- a/finch/gntsound.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/gntsound.h	Sat Aug 06 03:45:56 2011 +0000
@@ -44,7 +44,7 @@
 
 /**
  * Set the active profile.  If the profile doesn't exist, nothing is changed.
- * 
+ *
  * @param name  The name of the profile
  *
  * @since 2.1.0
--- a/finch/gntstatus.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/gntstatus.c	Sat Aug 06 03:45:56 2011 +0000
@@ -314,7 +314,7 @@
 		gnt_box_give_focus_to_child(GNT_BOX(edit->window), edit->title);
 		return;
 	}
-	
+
 	if (edit->saved == NULL)
 	{
 		edit->saved = purple_savedstatus_new(title, prim);
@@ -409,7 +409,7 @@
 	gnt_tree_change_text(GNT_TREE(sub->parent->tree), row, 1,
 			purple_status_type_get_name(type));
 	gnt_tree_change_text(GNT_TREE(sub->parent->tree), row, 2, message);
-	
+
 	gnt_widget_destroy(sub->window);
 }
 
--- a/finch/gntui.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/gntui.c	Sat Aug 06 03:45:56 2011 +0000
@@ -51,7 +51,7 @@
 #endif
 
 	purple_prefs_add_none("/purple/gnt");
-	
+
 	/* Accounts */
 	finch_accounts_init();
 	purple_accounts_set_ui_ops(finch_accounts_get_ui_ops());
--- a/finch/libgnt/configure.ac	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/libgnt/configure.ac	Sat Aug 06 03:45:56 2011 +0000
@@ -24,10 +24,10 @@
 # Make sure to update ../../configure.ac with libgnt version changes.
 #
 
-m4_define([gnt_lt_current], [6])
+m4_define([gnt_lt_current], [8])
 m4_define([gnt_major_version], [2])
-m4_define([gnt_minor_version], [6])
-m4_define([gnt_micro_version], [2])
+m4_define([gnt_minor_version], [8])
+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])
@@ -265,6 +265,10 @@
 	for location in $ac_ncurses_includes /usr/include/ncursesw /usr/include
 	do
 		f="$location/ncurses.h"
+		orig_CFLAGS="$CFLAGS"
+		orig_CPPFLAGS="$CPPFLAGS"
+		CFLAGS="$CFLAGS -I$location"
+		CPPFLAGS="$CPPFLAGS -I$location"
 		AC_CHECK_HEADER($f,[
 			AC_MSG_CHECKING([if $f supports wide characters])
 			AC_TRY_COMPILE([
@@ -283,9 +287,13 @@
 				fi
 
 				found_ncurses_h=yes
+				CFLAGS="$orig_CFLAGS"
+				CPPFLAGS="$orig_CPPFLAGS"
 				AC_MSG_RESULT([yes])
 				break
 			], [
+				CFLAGS="$orig_CFLAGS"
+				CPPFLAGS="$orig_CPPFLAGS"
 				AC_MSG_RESULT([no])
 			])
 		])
--- a/finch/libgnt/gnt-skel.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/libgnt/gnt-skel.h	Sat Aug 06 03:45:56 2011 +0000
@@ -61,14 +61,14 @@
 G_BEGIN_DECLS
 
 /**
- * 
+ *
  *
  * @return
  */
 GType gnt_skel_get_gtype(void);
 
 /**
- * 
+ *
  *
  * @return
  */
--- a/finch/libgnt/gntbindable.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/libgnt/gntbindable.c	Sat Aug 06 03:45:56 2011 +0000
@@ -48,7 +48,7 @@
 	GList * params;       /* The list of paramaters */
 } rebind_info;
 
-static void 
+static void
 gnt_bindable_free_rebind_info(void)
 {
 	g_free(rebind_info.name);
@@ -92,7 +92,7 @@
 		if (!strcmp(text, GNT_KEY_CTRL_I) || !strcmp(text, GNT_KEY_ENTER)) {
 			return FALSE;
 		}
-		
+
 		tmp = gnt_key_lookup(text);
 		new_text = g_strdup_printf("KEY: \"%s\"", tmp);
 		gnt_text_view_clear(textview);
@@ -105,7 +105,7 @@
 		return TRUE;
 	}
 	return FALSE;
-} 
+}
 static void
 gnt_bindable_rebinding_activate(GntBindable *data, gpointer bindable)
 {
@@ -154,18 +154,18 @@
 	g_signal_connect(G_OBJECT(win), "key_pressed", G_CALLBACK(gnt_bindable_rebinding_grab_key), key_textview);
 
 	button_box = gnt_box_new(FALSE, FALSE);
-	
+
 	bind_button = gnt_button_new("BIND");
 	gnt_widget_set_name(bind_button, "bind");
 	gnt_box_add_widget(GNT_BOX(button_box), bind_button);
-	
+
 	cancel_button = gnt_button_new("Cancel");
 	gnt_widget_set_name(cancel_button, "cancel");
 	gnt_box_add_widget(GNT_BOX(button_box), cancel_button);
-	
+
 	g_signal_connect(G_OBJECT(bind_button), "activate", G_CALLBACK(gnt_bindable_rebinding_rebind), win);
 	g_signal_connect(G_OBJECT(cancel_button), "activate", G_CALLBACK(gnt_bindable_rebinding_cancel), win);
-	
+
 	gnt_box_add_widget(GNT_BOX(vbox), button_box);
 
 	gnt_box_add_widget(GNT_BOX(win), vbox);
@@ -320,7 +320,7 @@
 	while ((p = va_arg(args, void *)) != NULL)
 		list = g_list_append(list, p);
 	va_end(args);
-	
+
 	action = g_hash_table_lookup(klass->actions, name);
 	if (action && action->u.action) {
 		return action->u.action(bindable, list);
--- a/finch/libgnt/gntbindable.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/libgnt/gntbindable.h	Sat Aug 06 03:45:56 2011 +0000
@@ -67,7 +67,7 @@
 G_BEGIN_DECLS
 
 /**
- * 
+ *
  *
  * @return
  */
--- a/finch/libgnt/gntbox.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/libgnt/gntbox.c	Sat Aug 06 03:45:56 2011 +0000
@@ -27,6 +27,9 @@
 
 #include <string.h>
 
+#define PROP_LAST_RESIZE_S "last-resize"
+#define PROP_SIZE_QUEUED_S "size-queued"
+
 enum
 {
 	PROP_0,
@@ -61,7 +64,7 @@
 	GntWidget *widget = GNT_WIDGET(box);
 	int len;
 	char *end = (char*)gnt_util_onscreen_width_to_pointer(title, widget->priv.width - 4, &len);
-	
+
 	if (p)
 		*p = (widget->priv.width - len) / 2;
 	if (r)
@@ -194,7 +197,7 @@
 	GntBox *box = GNT_BOX(widget);
 	GList *iter;
 	int maxw = 0, maxh = 0;
-	
+
 	g_list_foreach(box->list, (GFunc)gnt_widget_size_request, NULL);
 
 	for (iter = box->list; iter; iter = iter->next)
@@ -398,6 +401,7 @@
 	GList *iter;
 	GntBox *box = GNT_BOX(widget);
 	int wchange, hchange;
+	GntWidget *child, *last;
 
 	if (!box->list)
 		return TRUE;
@@ -406,67 +410,64 @@
 	hchange = widget->priv.height - height;
 
 	if (wchange == 0 && hchange == 0)
-		return TRUE;		/* Quit playing games */
+		return TRUE;		/* Quit playing games with my size */
 
-	/* XXX: Right now, I am trying to just apply all the changes to 
-	 * just one widget. It should be possible to distribute the
-	 * changes to all the widgets in the box. */
-	for (iter = box->list; iter; iter = iter->next)
-	{
+	child = NULL;
+	last = g_object_get_data(G_OBJECT(box), PROP_LAST_RESIZE_S);
+
+	/* First, make sure all the widgets will fit into the box after resizing. */
+	for (iter = box->list; iter; iter = iter->next) {
 		GntWidget *wid = iter->data;
 		int w, h;
 
 		gnt_widget_get_size(wid, &w, &h);
 
-		if (gnt_widget_confirm_size(wid, w - wchange, h - hchange))
-		{
-			GList *i;
-
-			for (i = box->list; i; i = i->next)
-			{
-				int tw, th;
-				if (i == iter) continue;
-				gnt_widget_get_size(GNT_WIDGET(i->data), &tw, &th);
-				if (box->vertical)
-				{
-					if (!gnt_widget_confirm_size(i->data, tw - wchange, th)) {
-						/* If we are decreasing the size and the widget is going
-						 * to be too large to fit into the box, then do not allow
-						 * resizing. */
-						if (wchange > 0 && tw >= widget->priv.width)
-							return FALSE;
-					}
-				}
-				else
-				{
-					if (!gnt_widget_confirm_size(i->data, tw, th - hchange)) {
-						if (hchange > 0 && th >= widget->priv.height)
-							return FALSE;
-						return FALSE;
-					}
-				}
-			}
-#if 0
-			gnt_widget_set_size(wid, w - wchange, h - hchange);
-			if (box->vertical)
-				hchange = 0;
-			else
-				wchange = 0;
-
-			for (i = box->list; i; i = i->next)
-			{
-				int tw, th;
-				if (i == iter) continue;
-				gnt_widget_get_size(GNT_WIDGET(i->data), &tw, &th);
-				gnt_widget_set_size(i->data, tw - wchange, th - hchange);
-			}
-#endif
-			g_object_set_data(G_OBJECT(box), "size-queued", wid);
-			return TRUE;
+		if (wid != last && !child && w > 0 && h > 0 &&
+				!GNT_WIDGET_IS_FLAG_SET(wid, GNT_WIDGET_INVISIBLE) &&
+				gnt_widget_confirm_size(wid, w - wchange, h - hchange)) {
+			child = wid;
+			break;
 		}
 	}
 
-	return FALSE;
+	if (!child && (child = last)) {
+		int w, h;
+		gnt_widget_get_size(child, &w, &h);
+		if (!gnt_widget_confirm_size(child, w - wchange, h - hchange))
+			child = NULL;
+	}
+
+	g_object_set_data(G_OBJECT(box), PROP_SIZE_QUEUED_S, child);
+
+	if (child) {
+		for (iter = box->list; iter; iter = iter->next) {
+			GntWidget *wid = iter->data;
+			int w, h;
+
+			if (wid == child)
+				continue;
+
+			gnt_widget_get_size(wid, &w, &h);
+			if (box->vertical) {
+				/* For a vertical box, if we are changing the width, make sure the widgets
+				 * in the box will fit after resizing the width. */
+				if (wchange > 0 &&
+						w >= child->priv.width &&
+						!gnt_widget_confirm_size(wid, w - wchange, h))
+					return FALSE;
+			} else {
+				/* If we are changing the height, make sure the widgets in the box fit after
+				 * the resize. */
+				if (hchange > 0 &&
+						h >= child->priv.height &&
+						!gnt_widget_confirm_size(wid, w, h - hchange))
+					return FALSE;
+			}
+
+		}
+	}
+
+	return (child != NULL);
 }
 
 static void
@@ -477,16 +478,16 @@
 	GntBox *box = GNT_BOX(widget);
 	GntWidget *wid;
 	int tw, th;
-		
+
 	wchange = widget->priv.width - oldw;
 	hchange = widget->priv.height - oldh;
-	
-	wid = g_object_get_data(G_OBJECT(box), "size-queued");
-	if (wid)
-	{
+
+	wid = g_object_get_data(G_OBJECT(box), PROP_SIZE_QUEUED_S);
+	if (wid) {
 		gnt_widget_get_size(wid, &tw, &th);
 		gnt_widget_set_size(wid, tw + wchange, th + hchange);
-		g_object_set_data(G_OBJECT(box), "size-queued", NULL);
+		g_object_set_data(G_OBJECT(box), PROP_SIZE_QUEUED_S, NULL);
+		g_object_set_data(G_OBJECT(box), PROP_LAST_RESIZE_S, wid);
 	}
 
 	if (box->vertical)
--- a/finch/libgnt/gntcheckbox.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/libgnt/gntcheckbox.c	Sat Aug 06 03:45:56 2011 +0000
@@ -100,7 +100,7 @@
 	wclass->key_pressed = gnt_check_box_key_pressed;
 	wclass->clicked = gnt_check_box_clicked;
 
-	signals[SIG_TOGGLED] = 
+	signals[SIG_TOGGLED] =
 		g_signal_new("toggled",
 					 G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST,
--- a/finch/libgnt/gntclipboard.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/libgnt/gntclipboard.c	Sat Aug 06 03:45:56 2011 +0000
@@ -32,7 +32,7 @@
 static void
 gnt_clipboard_class_init(GntClipboardClass *klass)
 {
-	signals[SIG_CLIPBOARD] = 
+	signals[SIG_CLIPBOARD] =
 		g_signal_new("clipboard_changed",
 					 G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST,
--- a/finch/libgnt/gntcolors.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/libgnt/gntcolors.c	Sat Aug 06 03:45:56 2011 +0000
@@ -161,9 +161,9 @@
 		color = custom ? GNT_COLOR_BLUE : COLOR_BLUE;
 	else if (strcmp(key, "white") == 0)
 		color = custom ? GNT_COLOR_WHITE : COLOR_WHITE;
-	else if (strcmp(key, "gray") == 0)
+	else if (strcmp(key, "gray") == 0 || strcmp(key, "grey") == 0)
 		color = custom ? GNT_COLOR_GRAY : COLOR_YELLOW;  /* eh? */
-	else if (strcmp(key, "darkgray") == 0)
+	else if (strcmp(key, "darkgray") == 0 || strcmp(key, "darkgrey") == 0)
 		color = custom ? GNT_COLOR_DARK_GRAY : COLOR_BLACK;
 	else if (strcmp(key, "magenta") == 0)
 		color = COLOR_MAGENTA;
--- a/finch/libgnt/gntcombobox.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/libgnt/gntcombobox.c	Sat Aug 06 03:45:56 2011 +0000
@@ -25,6 +25,7 @@
 #include "gntcombobox.h"
 #include "gnttree.h"
 #include "gntmarshal.h"
+#include "gntstyle.h"
 #include "gntutils.h"
 
 #include <string.h>
@@ -149,12 +150,11 @@
 gnt_combo_box_key_pressed(GntWidget *widget, const char *text)
 {
 	GntComboBox *box = GNT_COMBO_BOX(widget);
-	if (GNT_WIDGET_IS_FLAG_SET(box->dropdown->parent, GNT_WIDGET_MAPPED))
-	{
-		if (text[1] == 0)
-		{
-			switch (text[0])
-			{
+	gboolean showing = !!GNT_WIDGET_IS_FLAG_SET(box->dropdown->parent, GNT_WIDGET_MAPPED);
+
+	if (showing) {
+		if (text[1] == 0) {
+			switch (text[0]) {
 				case '\r':
 				case '\t':
 				case '\n':
@@ -165,20 +165,42 @@
 					return TRUE;
 			}
 		}
-		if (gnt_widget_key_pressed(box->dropdown, text))
-			return TRUE;
 	}
-	else
+
+	if (gnt_widget_key_pressed(box->dropdown, text)) {
+		if (!showing)
+			popup_dropdown(box);
+		return TRUE;
+	}
+
 	{
-		if (text[0] == 27)
-		{
-			if (strcmp(text, GNT_KEY_UP) == 0 ||
-					strcmp(text, GNT_KEY_DOWN) == 0)
-			{
-				popup_dropdown(box);
-				return TRUE;
-			}
-		}
+#define SEARCH_IN_RANGE(start, end) do { \
+		GntTreeRow *row; \
+		for (row = start; row != end; \
+				row = gnt_tree_row_get_next(tree, row)) { \
+			gpointer key = gnt_tree_row_get_key(tree, row); \
+			GList *list = gnt_tree_get_row_text_list(tree, key); \
+			gboolean found = FALSE; \
+			found = (list->data && g_ascii_strncasecmp(text, list->data, len) == 0); \
+			g_list_foreach(list, (GFunc)g_free, NULL); \
+			g_list_free(list); \
+			if (found) { \
+				if (!showing) \
+					popup_dropdown(box); \
+				gnt_tree_set_selected(tree, key); \
+				return TRUE; \
+			} \
+		} \
+} while (0)
+
+		int len = strlen(text);
+		GntTree *tree = GNT_TREE(box->dropdown);
+		GntTreeRow *current = tree->current;
+
+		SEARCH_IN_RANGE(gnt_tree_row_get_next(tree, current), NULL);
+		SEARCH_IN_RANGE(tree->top, current);
+
+#undef SEARCH_IN_RANGE
 	}
 
 	return FALSE;
@@ -229,9 +251,20 @@
 	gnt_widget_set_size(box->dropdown, widget->priv.width - 1, box->dropdown->priv.height);
 }
 
+static gboolean
+dropdown_menu(GntBindable *b, GList *null)
+{
+	if (GNT_WIDGET_IS_FLAG_SET(GNT_COMBO_BOX(b)->dropdown->parent, GNT_WIDGET_MAPPED))
+		return FALSE;
+	popup_dropdown(GNT_COMBO_BOX(b));
+	return TRUE;
+}
+
 static void
 gnt_combo_box_class_init(GntComboBoxClass *klass)
 {
+	GntBindableClass *bindable = GNT_BINDABLE_CLASS(klass);
+
 	parent_class = GNT_WIDGET_CLASS(klass);
 
 	parent_class->destroy = gnt_combo_box_destroy;
@@ -245,7 +278,7 @@
 	widget_lost_focus = parent_class->lost_focus;
 	parent_class->lost_focus = gnt_combo_box_lost_focus;
 
-	signals[SIG_SELECTION_CHANGED] = 
+	signals[SIG_SELECTION_CHANGED] =
 		g_signal_new("selection-changed",
 					 G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST,
@@ -254,6 +287,12 @@
 					 gnt_closure_marshal_VOID__POINTER_POINTER,
 					 G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER);
 
+	gnt_bindable_class_register_action(bindable, "dropdown", dropdown_menu,
+			GNT_KEY_DOWN, NULL);
+	gnt_bindable_register_binding(bindable, "dropdown", GNT_KEY_UP, NULL);
+
+	gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), bindable);
+
 	GNTDEBUG;
 }
 
@@ -272,7 +311,7 @@
 	GNT_WIDGET_SET_FLAGS(box, GNT_WIDGET_NO_SHADOW | GNT_WIDGET_NO_BORDER | GNT_WIDGET_TRANSIENT);
 	gnt_box_set_pad(GNT_BOX(box), 0);
 	gnt_box_add_widget(GNT_BOX(box), combo->dropdown);
-	
+
 	widget->priv.minw = 4;
 	widget->priv.minh = 3;
 	GNTDEBUG;
--- a/finch/libgnt/gntcombobox.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/libgnt/gntcombobox.h	Sat Aug 06 03:45:56 2011 +0000
@@ -91,7 +91,7 @@
 
 /**
  * Remove an entry
- * 
+ *
  * @param box The GntComboBox
  * @param key The data to be removed
  */
--- a/finch/libgnt/gntentry.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/libgnt/gntentry.c	Sat Aug 06 03:45:56 2011 +0000
@@ -55,6 +55,11 @@
 	GntEntryAction last;
 };
 
+struct _GntEntrySearch
+{
+	char *needle;
+};
+
 static guint signals[SIGS] = { 0 };
 
 static GntWidgetClass *parent_class = NULL;
@@ -471,6 +476,52 @@
 }
 
 static gboolean
+history_search(GntBindable *bind, GList *null)
+{
+	GntEntry *entry = GNT_ENTRY(bind);
+	GList *iter;
+	const char *current;
+
+	if (entry->history->prev && entry->search->needle)
+		current = entry->search->needle;
+	else
+		current = gnt_entry_get_text(entry);
+
+	if (!entry->histlength || !entry->history->next || !*current)
+		return FALSE;
+
+	for (iter = entry->history->next; iter; iter = iter->next) {
+		const char *str = iter->data;
+		/* A more utf8-friendly version of strstr would have been better, but
+		 * for now, this will have to do. */
+		if (strstr(str, current) != NULL)
+			break;
+	}
+
+	if (!iter)
+		return TRUE;
+
+	if (entry->history->prev == NULL) {
+		/* We are doing it for the first time. Save the current contents */
+		char *text = g_strdup(gnt_entry_get_text(entry));
+
+		g_free(entry->search->needle);
+		entry->search->needle = g_strdup(current);
+
+		g_free(entry->history->data);
+		entry->history->data = text;
+	}
+
+	entry->history = iter;
+	gnt_entry_set_text_internal(entry, entry->history->data);
+	destroy_suggest(entry);
+	entry_text_changed(entry);
+
+	update_kill_ring(entry, ENTRY_JAIL, NULL, 0);
+	return TRUE;
+}
+
+static gboolean
 clipboard_paste(GntBindable *bind, GList *n)
 {
 	GntEntry *entry = GNT_ENTRY(bind);
@@ -525,6 +576,28 @@
 }
 
 static gboolean
+suggest_next_page(GntBindable *bind, GList *null)
+{
+	GntEntry *entry = GNT_ENTRY(bind);
+	if (entry->ddown) {
+		gnt_bindable_perform_action_named(GNT_BINDABLE(entry->ddown), "page-down", NULL);
+		return TRUE;
+	}
+	return FALSE;
+}
+
+static gboolean
+suggest_prev_page(GntBindable *bind, GList *null)
+{
+	GntEntry *entry = GNT_ENTRY(bind);
+	if (entry->ddown) {
+		gnt_bindable_perform_action_named(GNT_BINDABLE(entry->ddown), "page-up", NULL);
+		return TRUE;
+	}
+	return FALSE;
+}
+
+static gboolean
 del_to_home(GntBindable *bind, GList *null)
 {
 	GntEntry *entry = GNT_ENTRY(bind);
@@ -833,6 +906,9 @@
 		gnt_widget_destroy(entry->ddown->parent);
 	}
 
+	g_free(entry->search->needle);
+	g_free(entry->search);
+
 	jail_killring(entry->killring);
 }
 
@@ -929,12 +1005,18 @@
 				GNT_KEY_DOWN, NULL);
 	gnt_bindable_class_register_action(bindable, "suggest-prev", suggest_prev,
 				GNT_KEY_UP, NULL);
+	gnt_bindable_class_register_action(bindable, "suggest-next-page", suggest_next_page,
+				GNT_KEY_PGDOWN, NULL);
+	gnt_bindable_class_register_action(bindable, "suggest-prev-page", suggest_prev_page,
+				GNT_KEY_PGUP, NULL);
 	gnt_bindable_class_register_action(bindable, "history-next", history_next,
 				GNT_KEY_CTRL_DOWN, NULL);
 	gnt_bindable_class_register_action(bindable, "history-prev", history_prev,
 				GNT_KEY_CTRL_UP, NULL);
 	gnt_bindable_register_binding(bindable, "history-prev", GNT_KEY_CTRL_P, NULL);
 	gnt_bindable_register_binding(bindable, "history-next", GNT_KEY_CTRL_N, NULL);
+	gnt_bindable_class_register_action(bindable, "history-search", history_search,
+				GNT_KEY_CTRL_R, NULL);
 	gnt_bindable_class_register_action(bindable, "clipboard-paste", clipboard_paste,
 				GNT_KEY_CTRL_V, NULL);
 
@@ -966,6 +1048,7 @@
 	entry->always = FALSE;
 	entry->suggests = NULL;
 	entry->killring = new_killring();
+	entry->search = g_new0(GntEntrySearch, 1);
 
 	GNT_WIDGET_SET_FLAGS(GNT_WIDGET(entry),
 			GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW | GNT_WIDGET_CAN_TAKE_FOCUS);
--- a/finch/libgnt/gntentry.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/libgnt/gntentry.h	Sat Aug 06 03:45:56 2011 +0000
@@ -49,6 +49,7 @@
 typedef struct _GntEntryPriv		GntEntryPriv;
 typedef struct _GntEntryClass	GntEntryClass;
 typedef struct _GntEntryKillRing    GntEntryKillRing;
+typedef struct _GntEntrySearch		GntEntrySearch;
 
 typedef enum
 {
@@ -86,6 +87,7 @@
 	gboolean always;    /* Should the list of suggestions show at all times, or only on tab-press? */
 	GntWidget *ddown;   /* The dropdown with the suggested list */
 	GntEntryKillRing *killring; /**< @since 2.3.0 */
+	GntEntrySearch *search;		/**< @since 2.7.0 */
 };
 
 struct _GntEntryClass
--- a/finch/libgnt/gntfilesel.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/libgnt/gntfilesel.c	Sat Aug 06 03:45:56 2011 +0000
@@ -245,7 +245,7 @@
 	GDir *dir;
 	GntFile *file;
 	const char *str;
-	
+
 	dir = g_dir_open(path, 0, error);
 	if (dir == NULL || (error && *error)) {
 		return FALSE;
@@ -315,7 +315,7 @@
 		success = sel->read_fn(sel->current, &files, err);
 	else
 		success = local_read_fn(sel->current, &files, err);
-	
+
 	if (!success || *err) {
 		gnt_warning("error opening location %s (%s)",
 			sel->current, *err ? (*err)->message : "reason unknown");
@@ -356,7 +356,7 @@
 
 		if (!str)
 			return TRUE;
-		
+
 		path = g_build_filename(sel->current, str, NULL);
 		dir = g_path_get_basename(sel->current);
 		if (!gnt_file_sel_set_current_location(sel, path)) {
@@ -597,7 +597,7 @@
 	orig_size_request = kl->size_request;
 	kl->size_request = gnt_file_sel_size_request;
 
-	signals[SIG_FILE_SELECTED] = 
+	signals[SIG_FILE_SELECTED] =
 		g_signal_new("file_selected",
 					 G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST,
--- a/finch/libgnt/gntkeys.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/libgnt/gntkeys.h	Sat Aug 06 03:45:56 2011 +0000
@@ -158,7 +158,7 @@
  */
 int gnt_keys_find_combination(const char *key);
 
-/* A lot of commonly used variable names are defined in <term.h>. 
+/* A lot of commonly used variable names are defined in <term.h>.
  * #undef them to make life easier for everyone. */
 
 #undef columns
--- a/finch/libgnt/gntmain.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/libgnt/gntmain.c	Sat Aug 06 03:45:56 2011 +0000
@@ -126,7 +126,7 @@
 
 	if (!wm->cws->ordered || buffer[0] != 27)
 		return FALSE;
-	
+
 	buffer++;
 	if (strlen(buffer) < 5)
 		return FALSE;
@@ -177,7 +177,7 @@
 
 	if (widget && gnt_wm_process_click(wm, event, x, y, widget))
 		return TRUE;
-	
+
 	if (event == GNT_LEFT_MOUSE_DOWN && widget && widget != wm->_list.window &&
 			!GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_TRANSIENT)) {
 		if (widget != wm->cws->ordered->data) {
@@ -438,7 +438,7 @@
 {
 	const char *name = gnt_style_get(GNT_STYLE_WM);
 	gpointer handle;
-	
+
 	if (name && *name) {
 		handle = g_module_open(name, G_MODULE_BIND_LAZY);
 		if (handle) {
@@ -459,7 +459,7 @@
 
 	if (channel)
 		return;
-	
+
 	locale = setlocale(LC_ALL, "");
 
 	setup_io();
@@ -554,7 +554,7 @@
 	GntWidget *w;
 	if (!widget)
 		return FALSE;
-	
+
 	if (GNT_IS_MENU(widget))
 		return TRUE;
 
--- a/finch/libgnt/gntmenu.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/libgnt/gntmenu.h	Sat Aug 06 03:45:56 2011 +0000
@@ -63,7 +63,7 @@
 {
 	GntTree parent;
 	GntMenuType type;
-	
+
 	GList *list;
 	int selected;
 
--- a/finch/libgnt/gntprogressbar.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/libgnt/gntprogressbar.c	Sat Aug 06 03:45:56 2011 +0000
@@ -168,7 +168,7 @@
 			0,                            /* n_preallocs */
 			gnt_progress_bar_init,        /* instance_init */
 			NULL                          /* value_table */
-		}; 
+		};
 
 		type = g_type_register_static (GNT_TYPE_WIDGET, "GntProgressBar", &info, 0);
 	}
--- a/finch/libgnt/gntslider.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/libgnt/gntslider.h	Sat Aug 06 03:45:56 2011 +0000
@@ -109,7 +109,7 @@
 
 /**
  * Sets the amount of change at each step.
- * 
+ *
  * @param slider  The slider
  * @param step    The amount for each step
  *
@@ -119,7 +119,7 @@
 
 /**
  * Sets the amount of change a small step.
- * 
+ *
  * @param slider  The slider
  * @param step    The amount for a small step (for the slider)
  *
@@ -129,7 +129,7 @@
 
 /**
  * Sets the amount of change a large step.
- * 
+ *
  * @param slider  The slider
  * @param step    The amount for a large step (for the slider)
  *
--- a/finch/libgnt/gntstyle.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/libgnt/gntstyle.c	Sat Aug 06 03:45:56 2011 +0000
@@ -105,7 +105,7 @@
 
 	if (bool_styles[style] != -1)
 		return bool_styles[style];
-	
+
 	str = gnt_style_get(style);
 
 	bool_styles[style] = str ? gnt_style_parse_bool(str) : def;
@@ -226,7 +226,7 @@
 	{
 		gsize len = 0;
 		char **keys;
-		
+
 		keys = g_key_file_get_keys(gkfile, name, &len, &error);
 		if (error)
 		{
@@ -280,7 +280,7 @@
 	{
 		gsize len = 0;
 		char **keys;
-		
+
 		keys = g_key_file_get_keys(gkfile, kname, &len, &error);
 		if (error)
 		{
@@ -331,14 +331,14 @@
 #if GLIB_CHECK_VERSION(2,6,0)
 	char *name;
 	GError *error = NULL;
-	
+
 	name = g_strdup_printf("%s::remap", g_type_name(type));
 
 	if (g_key_file_has_group(gkfile, name))
 	{
 		gsize len = 0;
 		char **keys;
-		
+
 		keys = g_key_file_get_keys(gkfile, name, &len, &error);
 		if (error)
 		{
--- a/finch/libgnt/gnttextview.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/libgnt/gnttextview.c	Sat Aug 06 03:45:56 2011 +0000
@@ -165,7 +165,7 @@
 
 		if (showing + position > rows)
 			position = rows - showing;
-		
+
 		if (showing + position == rows && view->list && view->list->prev)
 			position = MAX(1, rows - 1 - showing);
 		else if (showing + position < rows && view->list && !view->list->prev)
@@ -456,7 +456,7 @@
 	GntTextView *view = GNT_TEXT_VIEW(widget);
 	GntTextLine *line = g_new0(GntTextLine, 1);
 
-	GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW | 
+	GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW |
             GNT_WIDGET_GROW_Y | GNT_WIDGET_GROW_X);
 	widget->priv.minw = 5;
 	widget->priv.minh = 2;
@@ -636,7 +636,7 @@
 			list = g_list_last(view->list);
 		view->list = list;
 	}
-		
+
 	gnt_widget_draw(GNT_WIDGET(view));
 }
 
@@ -644,7 +644,7 @@
 {
 	GntTextLine *line = g_new0(GntTextLine, 1);
 	GList *list = view->list;
-	
+
 	view->list = g_list_prepend(g_list_first(view->list), line);
 	view->list = list;
 	gnt_widget_draw(GNT_WIDGET(view));
@@ -711,7 +711,7 @@
 int gnt_text_view_get_lines_above(GntTextView *view)
 {
 	int above = 0;
-	GList *list = view->list;
+	GList *list;
 	list = g_list_nth(view->list, GNT_WIDGET(view)->priv.height);
 	if (!list)
 		return 0;
--- a/finch/libgnt/gnttree.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/libgnt/gnttree.c	Sat Aug 06 03:45:56 2011 +0000
@@ -275,7 +275,7 @@
 	return get_root_distance(get_prev(row)) + 1;
 }
 
-/* Returns the distance between a and b. 
+/* Returns the distance between a and b.
  * If a is 'above' b, then the distance is positive */
 static int
 get_distance(GntTreeRow *a, GntTreeRow *b)
@@ -627,7 +627,7 @@
 	GntTree *tree = GNT_TREE(widget);
 
 	redraw_tree(tree);
-	
+
 	GNTDEBUG;
 }
 
@@ -957,6 +957,45 @@
 	return TRUE;
 }
 
+static gboolean
+move_first_action(GntBindable *bind, GList *null)
+{
+	GntTree *tree = GNT_TREE(bind);
+	GntTreeRow *row = tree->root;
+	GntTreeRow *old = tree->current;
+	if (row && !row_matches_search(row))
+		row = get_next(row);
+	if (row) {
+		tree->current = row;
+		redraw_tree(tree);
+		if (old != tree->current)
+			tree_selection_changed(tree, old, tree->current);
+	}
+
+	return TRUE;
+}
+
+static gboolean
+move_last_action(GntBindable *bind, GList *null)
+{
+	GntTree *tree = GNT_TREE(bind);
+	GntTreeRow *old = tree->current;
+	GntTreeRow *row = tree->bottom;
+	GntTreeRow *next;
+
+	while ((next = get_next(row)))
+		row = next;
+
+	if (row) {
+		tree->current = row;
+		redraw_tree(tree);
+		if (old != tree->current)
+			tree_selection_changed(tree, old, tree->current);
+	}
+
+	return TRUE;
+}
+
 static void
 gnt_tree_set_property(GObject *obj, guint prop_id, const GValue *value,
 		GParamSpec *spec)
@@ -1027,7 +1066,7 @@
 			)
 		);
 
-	signals[SIG_SELECTION_CHANGED] = 
+	signals[SIG_SELECTION_CHANGED] =
 		g_signal_new("selection-changed",
 					 G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST,
@@ -1035,7 +1074,7 @@
 					 NULL, NULL,
 					 gnt_closure_marshal_VOID__POINTER_POINTER,
 					 G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER);
-	signals[SIG_SCROLLED] = 
+	signals[SIG_SCROLLED] =
 		g_signal_new("scrolled",
 					 G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST,
@@ -1043,7 +1082,7 @@
 					 NULL, NULL,
 					 g_cclosure_marshal_VOID__INT,
 					 G_TYPE_NONE, 1, G_TYPE_INT);
-	signals[SIG_TOGGLED] = 
+	signals[SIG_TOGGLED] =
 		g_signal_new("toggled",
 					 G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST,
@@ -1051,7 +1090,7 @@
 					 NULL, NULL,
 					 g_cclosure_marshal_VOID__POINTER,
 					 G_TYPE_NONE, 1, G_TYPE_POINTER);
-	signals[SIG_COLLAPSED] = 
+	signals[SIG_COLLAPSED] =
 		g_signal_new("collapse-toggled",
 					 G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST,
@@ -1076,6 +1115,10 @@
 				"/", NULL);
 	gnt_bindable_class_register_action(bindable, "end-search", end_search_action,
 				"\033", NULL);
+	gnt_bindable_class_register_action(bindable, "move-first", move_first_action,
+			GNT_KEY_HOME, NULL);
+	gnt_bindable_class_register_action(bindable, "move-last", move_last_action,
+			GNT_KEY_END, NULL);
 
 	gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), bindable);
 	GNTDEBUG;
@@ -1303,6 +1346,10 @@
 {
 	GntTreeRow *pr = NULL;
 
+	if (g_hash_table_lookup(tree->hash, key)) {
+		gnt_tree_remove(tree, key);
+	}
+
 	row->tree = tree;
 	row->key = key;
 	row->data = NULL;
@@ -1337,7 +1384,7 @@
 			}
 		}
 
-		if (pr == NULL && parent)	
+		if (pr == NULL && parent)
 		{
 			pr = g_hash_table_lookup(tree->hash, parent);
 			if (pr)
@@ -1517,7 +1564,7 @@
 	GntTreeCol *col;
 
 	g_return_if_fail(colno < tree->ncol);
-	
+
 	row = g_hash_table_lookup(tree->hash, key);
 	if (row)
 	{
@@ -1554,7 +1601,7 @@
 				while (r->next)
 					r = r->next;
 				bigbro = r->key;
-			} 
+			}
 		}
 	}
 	row = gnt_tree_add_row_after(tree, key, row, parent, bigbro);
@@ -1838,7 +1885,7 @@
 void gnt_tree_set_column_is_binary(GntTree *tree, int col, gboolean bin)
 {
 	g_return_if_fail(col < tree->ncol);
-	set_column_flag(tree, col, GNT_TREE_COLUMN_FIXED_SIZE, bin);
+	set_column_flag(tree, col, GNT_TREE_COLUMN_BINARY_DATA, bin);
 }
 
 void gnt_tree_set_column_is_right_aligned(GntTree *tree, int col, gboolean right)
@@ -1879,3 +1926,33 @@
 	return (row && row->parent) ? row->parent->key : NULL;
 }
 
+gpointer gnt_tree_row_get_key(GntTree *tree, GntTreeRow *row)
+{
+	g_return_val_if_fail(row && row->tree == tree, NULL);
+	return row->key;
+}
+
+GntTreeRow * gnt_tree_row_get_next(GntTree *tree, GntTreeRow *row)
+{
+	g_return_val_if_fail(row && row->tree == tree, NULL);
+	return row->next;
+}
+
+GntTreeRow * gnt_tree_row_get_prev(GntTree *tree, GntTreeRow *row)
+{
+	g_return_val_if_fail(row && row->tree == tree, NULL);
+	return row->prev;
+}
+
+GntTreeRow * gnt_tree_row_get_child(GntTree *tree, GntTreeRow *row)
+{
+	g_return_val_if_fail(row && row->tree == tree, NULL);
+	return row->child;
+}
+
+GntTreeRow * gnt_tree_row_get_parent(GntTree *tree, GntTreeRow *row)
+{
+	g_return_val_if_fail(row && row->tree == tree, NULL);
+	return row->parent;
+}
+
--- a/finch/libgnt/gnttree.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/libgnt/gnttree.h	Sat Aug 06 03:45:56 2011 +0000
@@ -62,9 +62,9 @@
 
 	GntTreeRow *top;        /* The topmost visible item */
 	GntTreeRow *bottom;     /* The bottommost visible item */
-	
+
 	GntTreeRow *root;       /* The root of all evil */
-	
+
 	GList *list;            /* List of GntTreeRow s */
 	GHashTable *hash;       /* We need this for quickly referencing the rows */
 	guint (*hash_func)(gconstpointer);
@@ -216,12 +216,67 @@
  * @return A list of texts of a row. The list and its data should be
  *         freed by the caller. The caller should make sure that if
  *         any column of the tree contains binary data, it's not freed.
- * @see gnt_tree_get_selection_text_list 
+ * @see gnt_tree_get_selection_text_list
  * @see gnt_tree_get_selection_text
  */
 GList * gnt_tree_get_row_text_list(GntTree *tree, gpointer key);
 
 /**
+ * Get the key of a row.
+ *
+ * @param tree   The tree
+ * @param row    The GntTreeRow object
+ *
+ * @return The key of the row.
+ * @since 2.8.0 (gnt), 2.7.2 (pidgin)
+ */
+gpointer gnt_tree_row_get_key(GntTree *tree, GntTreeRow *row);
+
+/**
+ * Get the next row.
+ *
+ * @param tree The tree
+ * @param row  The GntTreeRow object
+ *
+ * @return The next row.
+ * @since 2.8.0 (gnt), 2.7.2 (pidgin)
+ */
+GntTreeRow * gnt_tree_row_get_next(GntTree *tree, GntTreeRow *row);
+
+/**
+ * Get the previous row.
+ *
+ * @param tree The tree
+ * @param row  The GntTreeRow object
+ *
+ * @return The previous row.
+ * @since 2.8.0 (gnt), 2.7.2 (pidgin)
+ */
+GntTreeRow * gnt_tree_row_get_prev(GntTree *tree, GntTreeRow *row);
+
+/**
+ * Get the child row.
+ *
+ * @param tree The tree
+ * @param row  The GntTreeRow object
+ *
+ * @return The child row.
+ * @since 2.8.0 (gnt), 2.7.2 (pidgin)
+ */
+GntTreeRow * gnt_tree_row_get_child(GntTree *tree, GntTreeRow *row);
+
+/**
+ * Get the parent row.
+ *
+ * @param tree The tree
+ * @param row  The GntTreeRow object
+ *
+ * @return The parent row.
+ * @since 2.8.0 (gnt), 2.7.2 (pidgin)
+ */
+GntTreeRow * gnt_tree_row_get_parent(GntTree *tree, GntTreeRow *row);
+
+/**
  * Get a list of text of the current row.
  *
  * @param tree  The tree
@@ -427,7 +482,7 @@
  * @param func  The comparison function, which is used to compare
  *              the keys
  *
- * @see gnt_tree_sort_row 
+ * @see gnt_tree_sort_row
  */
 void gnt_tree_set_compare_func(GntTree *tree, GCompareFunc func);
 
@@ -480,7 +535,7 @@
  * Set whether a column is visible or not.
  * This can be useful when, for example, we want to store some data
  * which we don't want/need to display.
- * 
+ *
  * @param tree  The tree
  * @param col   The index of the column
  * @param vis   If @c FALSE, the column will not be displayed
@@ -490,7 +545,7 @@
 /**
  * Set whether a column can be resized to keep the same ratio when the
  * tree is resized.
- * 
+ *
  * @param tree  The tree
  * @param col   The index of the column
  * @param res   If @c FALSE, the column will not be resized when the
--- a/finch/libgnt/gntutils.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/libgnt/gntutils.c	Sat Aug 06 03:45:56 2011 +0000
@@ -373,7 +373,6 @@
 
 	xmlFreeDoc(doc);
 	xmlFreeParserCtxt(ctxt);
-	xmlCleanupParser();
 	va_end(list);
 	g_free(data);
 #endif
@@ -386,7 +385,6 @@
 	const char *name;
 	char *content;
 	xmlNode *ch;
-	gboolean processed = FALSE;
 	char *url = NULL;
 	gboolean insert_nl_s = FALSE, insert_nl_e = FALSE;
 
@@ -427,17 +425,14 @@
 
 	for (ch = node->children; ch; ch = ch->next) {
 		if (ch->type == XML_ELEMENT_NODE) {
-			processed = TRUE;
 			util_parse_html_to_tv(ch, tv, flag);
+		} else if (ch->type == XML_TEXT_NODE) {
+			content = (char*)xmlNodeGetContent(ch);
+			gnt_text_view_append_text_with_flags(tv, content, flag);
+			xmlFree(content);
 		}
 	}
 
-	if (!processed) {
-		content = (char*)xmlNodeGetContent(node);
-		gnt_text_view_append_text_with_flags(tv, content, flag);
-		xmlFree(content);
-	}
-
 	if (url) {
 		char *href = g_strdup_printf(" (%s)", url);
 		gnt_text_view_append_text_with_flags(tv, href, flag);
@@ -470,7 +465,6 @@
 		ret = TRUE;
 	}
 	xmlFreeParserCtxt(ctxt);
-	xmlCleanupParser();
 	return ret;
 #endif
 }
--- a/finch/libgnt/gntutils.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/libgnt/gntutils.h	Sat Aug 06 03:45:56 2011 +0000
@@ -66,7 +66,7 @@
 const char *gnt_util_onscreen_width_to_pointer(const char *str, int len, int *w);
 
 /**
- * Inserts newlines in 'string' where necessary so that its onscreen width is 
+ * Inserts newlines in 'string' where necessary so that its onscreen width is
  * no more than 'maxw'.
  *
  * @param string  The string.
@@ -107,7 +107,7 @@
 
 /**
  * Get a helpful display about the bindings of a widget.
- * 
+ *
  * @param widget The widget to get bindings for.
  *
  * @return Returns a GntTree populated with "key" -> "binding" for the widget.
@@ -126,7 +126,7 @@
  *      </vwindow>",
  *   2, &win, &button);
  * @endcode
- * 
+ *
  * @param string  The XML string.
  * @param num     The number of widgets to return, followed by 'num' GntWidget **
  */
--- a/finch/libgnt/gntwidget.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/libgnt/gntwidget.c	Sat Aug 06 03:45:56 2011 +0000
@@ -126,12 +126,12 @@
 	klass->lost_focus = gnt_widget_focus_change;
 	klass->gained_focus = gnt_widget_focus_change;
 	klass->confirm_size = gnt_widget_dummy_confirm_size;
-	
+
 	klass->key_pressed = NULL;
 	klass->activate = NULL;
 	klass->clicked = NULL;
-	
-	signals[SIG_DESTROY] = 
+
+	signals[SIG_DESTROY] =
 		g_signal_new("destroy",
 					 G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST,
@@ -139,7 +139,7 @@
 					 NULL, NULL,
 					 g_cclosure_marshal_VOID__VOID,
 					 G_TYPE_NONE, 0);
-	signals[SIG_GIVE_FOCUS] = 
+	signals[SIG_GIVE_FOCUS] =
 		g_signal_new("gained-focus",
 					 G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST,
@@ -147,7 +147,7 @@
 					 NULL, NULL,
 					 g_cclosure_marshal_VOID__VOID,
 					 G_TYPE_NONE, 0);
-	signals[SIG_LOST_FOCUS] = 
+	signals[SIG_LOST_FOCUS] =
 		g_signal_new("lost-focus",
 					 G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST,
@@ -155,7 +155,7 @@
 					 NULL, NULL,
 					 g_cclosure_marshal_VOID__VOID,
 					 G_TYPE_NONE, 0);
-	signals[SIG_ACTIVATE] = 
+	signals[SIG_ACTIVATE] =
 		g_signal_new("activate",
 					 G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST,
@@ -163,7 +163,7 @@
 					 NULL, NULL,
 					 g_cclosure_marshal_VOID__VOID,
 					 G_TYPE_NONE, 0);
-	signals[SIG_MAP] = 
+	signals[SIG_MAP] =
 		g_signal_new("map",
 					 G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST,
@@ -171,7 +171,7 @@
 					 NULL, NULL,
 					 g_cclosure_marshal_VOID__VOID,
 					 G_TYPE_NONE, 0);
-	signals[SIG_DRAW] = 
+	signals[SIG_DRAW] =
 		g_signal_new("draw",
 					 G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST,
@@ -179,7 +179,7 @@
 					 NULL, NULL,
 					 g_cclosure_marshal_VOID__VOID,
 					 G_TYPE_NONE, 0);
-	signals[SIG_HIDE] = 
+	signals[SIG_HIDE] =
 		g_signal_new("hide",
 					 G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST,
@@ -187,7 +187,7 @@
 					 NULL, NULL,
 					 g_cclosure_marshal_VOID__VOID,
 					 G_TYPE_NONE, 0);
-	signals[SIG_EXPOSE] = 
+	signals[SIG_EXPOSE] =
 		g_signal_new("expose",
 					 G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST,
@@ -195,7 +195,7 @@
 					 NULL, NULL,
 					 gnt_closure_marshal_VOID__INT_INT_INT_INT,
 					 G_TYPE_NONE, 4, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT);
-	signals[SIG_POSITION] = 
+	signals[SIG_POSITION] =
 		g_signal_new("position-set",
 					 G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST,
@@ -203,7 +203,7 @@
 					 NULL, NULL,
 					 gnt_closure_marshal_VOID__INT_INT,
 					 G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
-	signals[SIG_SIZE_REQUEST] = 
+	signals[SIG_SIZE_REQUEST] =
 		g_signal_new("size_request",
 					 G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST,
@@ -211,7 +211,7 @@
 					 NULL, NULL,
 					 g_cclosure_marshal_VOID__VOID,
 					 G_TYPE_NONE, 0);
-	signals[SIG_SIZE_CHANGED] = 
+	signals[SIG_SIZE_CHANGED] =
 		g_signal_new("size_changed",
 					 G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST,
@@ -219,7 +219,7 @@
 					 NULL, NULL,
 					 gnt_closure_marshal_VOID__INT_INT,
 					 G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
-	signals[SIG_CONFIRM_SIZE] = 
+	signals[SIG_CONFIRM_SIZE] =
 		g_signal_new("confirm_size",
 					 G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST,
@@ -227,7 +227,7 @@
 					 NULL, NULL,
 					 gnt_closure_marshal_BOOLEAN__INT_INT,
 					 G_TYPE_BOOLEAN, 2, G_TYPE_INT, G_TYPE_INT);
-	signals[SIG_KEY_PRESSED] = 
+	signals[SIG_KEY_PRESSED] =
 		g_signal_new("key_pressed",
 					 G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST,
@@ -236,7 +236,7 @@
 					 gnt_closure_marshal_BOOLEAN__STRING,
 					 G_TYPE_BOOLEAN, 1, G_TYPE_STRING);
 
-	signals[SIG_CLICKED] = 
+	signals[SIG_CLICKED] =
 		g_signal_new("clicked",
 					 G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST,
@@ -245,7 +245,7 @@
 					 gnt_closure_marshal_BOOLEAN__INT_INT_INT,
 					 G_TYPE_BOOLEAN, 3, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT);
 
-	signals[SIG_CONTEXT_MENU] = 
+	signals[SIG_CONTEXT_MENU] =
 		g_signal_new("context-menu",
 					 G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST,
--- a/finch/libgnt/gntwm.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/libgnt/gntwm.c	Sat Aug 06 03:45:56 2011 +0000
@@ -24,12 +24,17 @@
 
 #ifdef USE_PYTHON
 #include <Python.h>
-#else
+#endif
+
+/* Python.h may define _GNU_SOURCE and _XOPEN_SOURCE_EXTENDED, so protect
+ * these checks with #ifndef/!defined() */
+#ifndef _GNU_SOURCE
 #define _GNU_SOURCE
-#if (defined(__APPLE__) || defined(__unix__)) && !defined(__FreeBSD__) && !defined(__OpenBSD__)
+#endif
+
+#if !defined _XOPEN_SOURCE_EXTENDED && (defined(__APPLE__) || defined(__unix__)) && !defined(__FreeBSD__) && !defined(__OpenBSD__)
 #define _XOPEN_SOURCE_EXTENDED
 #endif
-#endif
 
 #include <glib.h>
 #if GLIB_CHECK_VERSION(2,6,0)
@@ -151,7 +156,7 @@
 /**
  * The following is a workaround for a bug in most versions of ncursesw.
  * Read about it in: http://article.gmane.org/gmane.comp.lib.ncurses.bugs/2751
- * 
+ *
  * In short, if a panel hides one cell of a multi-cell character, then the rest
  * of the characters in that line get screwed. The workaround here is to erase
  * any such character preemptively.
@@ -665,7 +670,7 @@
 	tree = wm->windows->tree;
 
 	gnt_box_set_title(GNT_BOX(win), workspace ? "Workspace List" : "Window List");
-	
+
 	populate_window_list(wm, workspace);
 
 	if (wm->cws->ordered)
@@ -762,7 +767,7 @@
 				{  \
 					fprintf(file, "%s", end);  \
 				}  \
-			} while (0) 
+			} while (0)
 
 			CHECK(A_BOLD, "<b>", "</b>");
 			CHECK(A_UNDERLINE, "<u>", "</u>");
@@ -800,7 +805,7 @@
 				ADJUST(bg.r);
 				ADJUST(bg.b);
 				ADJUST(bg.g);
-				
+
 				if (x) fprintf(file, "</span>");
 				fprintf(file, "<span style=\"background:#%02x%02x%02x;color:#%02x%02x%02x\">",
 						bg.r, bg.g, bg.b, fg.r, fg.g, fg.b);
@@ -889,6 +894,13 @@
 	all = g_list_delete_link(all, list);
 	wm->cws->list = all;
 	gnt_ws_draw_taskbar(wm->cws, FALSE);
+	if (wm->cws->ordered) {
+		GntWidget *w = wm->cws->ordered->data;
+		GntNode *node = g_hash_table_lookup(wm->nodes, w);
+		top_panel(node->panel);
+		update_panels();
+		doupdate();
+	}
 }
 
 static gboolean
@@ -909,7 +921,7 @@
 shift_right(GntBindable *bindable, GList *null)
 {
 	GntWM *wm = GNT_WM(bindable);
-	
+
 	if (wm->_list.window)
 		return TRUE;
 
@@ -1025,7 +1037,7 @@
 
 	if (GNT_WIDGET_IS_FLAG_SET(win, GNT_WIDGET_NO_BORDER))
 		return;
-	
+
 	d = win->window;
 	gnt_widget_get_size(win, &w, &h);
 
@@ -1106,12 +1118,20 @@
 refresh_screen(GntBindable *bindable, GList *null)
 {
 	GntWM *wm = GNT_WM(bindable);
+	GList *iter;
 
 	endwin();
 	refresh();
 
 	g_hash_table_foreach(wm->nodes, (GHFunc)refresh_node, GINT_TO_POINTER(TRUE));
 	g_signal_emit(wm, signals[SIG_TERMINAL_REFRESH], 0);
+
+	for (iter = g_list_last(wm->cws->ordered); iter; iter = iter->prev) {
+		GntWidget *w = iter->data;
+		GntNode *node = g_hash_table_lookup(wm->nodes, w);
+		top_panel(node->panel);
+	}
+
 	gnt_ws_draw_taskbar(wm->cws, TRUE);
 	update_screen(wm);
 	curs_set(0);   /* endwin resets the cursor to normal */
@@ -1390,8 +1410,8 @@
 	klass->key_pressed  = NULL;
 	klass->mouse_clicked = NULL;
 	klass->give_focus = gnt_wm_give_focus;
-	
-	signals[SIG_NEW_WIN] = 
+
+	signals[SIG_NEW_WIN] =
 		g_signal_new("new_win",
 					 G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST,
@@ -1399,7 +1419,7 @@
 					 NULL, NULL,
 					 g_cclosure_marshal_VOID__POINTER,
 					 G_TYPE_NONE, 1, G_TYPE_POINTER);
-	signals[SIG_DECORATE_WIN] = 
+	signals[SIG_DECORATE_WIN] =
 		g_signal_new("decorate_win",
 					 G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST,
@@ -1407,7 +1427,7 @@
 					 NULL, NULL,
 					 g_cclosure_marshal_VOID__POINTER,
 					 G_TYPE_NONE, 1, G_TYPE_POINTER);
-	signals[SIG_CLOSE_WIN] = 
+	signals[SIG_CLOSE_WIN] =
 		g_signal_new("close_win",
 					 G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST,
@@ -1415,7 +1435,7 @@
 					 NULL, NULL,
 					 g_cclosure_marshal_VOID__POINTER,
 					 G_TYPE_NONE, 1, G_TYPE_POINTER);
-	signals[SIG_CONFIRM_RESIZE] = 
+	signals[SIG_CONFIRM_RESIZE] =
 		g_signal_new("confirm_resize",
 					 G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST,
@@ -1424,7 +1444,7 @@
 					 gnt_closure_marshal_BOOLEAN__POINTER_POINTER_POINTER,
 					 G_TYPE_BOOLEAN, 3, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER);
 
-	signals[SIG_CONFIRM_MOVE] = 
+	signals[SIG_CONFIRM_MOVE] =
 		g_signal_new("confirm_move",
 					 G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST,
@@ -1433,7 +1453,7 @@
 					 gnt_closure_marshal_BOOLEAN__POINTER_POINTER_POINTER,
 					 G_TYPE_BOOLEAN, 3, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER);
 
-	signals[SIG_RESIZED] = 
+	signals[SIG_RESIZED] =
 		g_signal_new("window_resized",
 					 G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST,
@@ -1441,7 +1461,7 @@
 					 NULL, NULL,
 					 g_cclosure_marshal_VOID__POINTER,
 					 G_TYPE_NONE, 1, G_TYPE_POINTER);
-	signals[SIG_MOVED] = 
+	signals[SIG_MOVED] =
 		g_signal_new("window_moved",
 					 G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST,
@@ -1449,7 +1469,7 @@
 					 NULL, NULL,
 					 g_cclosure_marshal_VOID__POINTER,
 					 G_TYPE_NONE, 1, G_TYPE_POINTER);
-	signals[SIG_UPDATE_WIN] = 
+	signals[SIG_UPDATE_WIN] =
 		g_signal_new("window_update",
 					 G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST,
@@ -1458,7 +1478,7 @@
 					 g_cclosure_marshal_VOID__POINTER,
 					 G_TYPE_NONE, 1, G_TYPE_POINTER);
 
-	signals[SIG_GIVE_FOCUS] = 
+	signals[SIG_GIVE_FOCUS] =
 		g_signal_new("give_focus",
 					 G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST,
@@ -1467,7 +1487,7 @@
 					 g_cclosure_marshal_VOID__POINTER,
 					 G_TYPE_NONE, 1, G_TYPE_POINTER);
 
-	signals[SIG_MOUSE_CLICK] = 
+	signals[SIG_MOUSE_CLICK] =
 		g_signal_new("mouse_clicked",
 					 G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST,
@@ -1476,7 +1496,7 @@
 					 gnt_closure_marshal_BOOLEAN__INT_INT_INT_POINTER,
 					 G_TYPE_BOOLEAN, 4, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_POINTER);
 
-	signals[SIG_TERMINAL_REFRESH] = 
+	signals[SIG_TERMINAL_REFRESH] =
 		g_signal_new("terminal-refresh",
 					 G_TYPE_FROM_CLASS(klass),
 					 G_SIGNAL_RUN_LAST,
--- a/finch/libgnt/gntws.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/libgnt/gntws.h	Sat Aug 06 03:45:56 2011 +0000
@@ -46,7 +46,7 @@
 	GList *list;
 	GList *ordered;
 	gpointer ui_data;
-	
+
 	void *res1;
 	void *res2;
 	void *res3;
--- a/finch/libgnt/test/combo.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/libgnt/test/combo.c	Sat Aug 06 03:45:56 2011 +0000
@@ -37,7 +37,7 @@
 	freopen(".error", "w", stderr);
 	gnt_init();
 #endif
-	
+
 	box = gnt_box_new(FALSE, TRUE);
 	gnt_widget_set_name(box, "box");
 	gnt_box_set_alignment(GNT_BOX(box), GNT_ALIGN_MID);
--- a/finch/libgnt/test/focus.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/libgnt/test/focus.c	Sat Aug 06 03:45:56 2011 +0000
@@ -24,7 +24,7 @@
 	freopen(".error", "w", stderr);
 	gnt_init();
 #endif
-	
+
 	GntWidget *label = gnt_label_new("So wassup dudes and dudettes!!\u4e0a1\u6d772\u67003\u4f4e4\u67085\nSo this is, like,\nthe third line!! \\o/");
 	GntWidget *vbox, *hbox, *tree, *box, *button;
 	WINDOW *test;
@@ -78,7 +78,7 @@
 	gnt_box_add_widget(GNT_BOX(vbox), button);
 
 	gnt_box_add_widget(GNT_BOX(hbox), vbox);
-	
+
 	gnt_widget_show(hbox);
 
 #ifdef STANDALONE
--- a/finch/libgnt/test/tv.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/libgnt/test/tv.c	Sat Aug 06 03:45:56 2011 +0000
@@ -45,7 +45,7 @@
 			return FALSE;
 		return TRUE;
 	}
-		
+
 	return FALSE;
 }
 
--- a/finch/libgnt/test/wm.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/libgnt/test/wm.c	Sat Aug 06 03:45:56 2011 +0000
@@ -35,7 +35,7 @@
 			gnt_widget_show(widget);
 		}
 	}
-	
+
 	return TRUE;
 }
 
@@ -61,7 +61,7 @@
 	gnt_main();
 
 	gnt_quit();
-	
+
 	return 0;
 }
 
--- a/finch/libgnt/wms/irssi.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/libgnt/wms/irssi.c	Sat Aug 06 03:45:56 2011 +0000
@@ -207,11 +207,15 @@
 update_conv_window_title(GntNode *node)
 {
 	char title[256];
+	int x, y;
 	snprintf(title, sizeof(title), "%d: %s",
 			GPOINTER_TO_INT(g_object_get_data(G_OBJECT(node->me), "irssi-index")) + 1,
 			GNT_BOX(node->me)->title);
+
+	getyx(node->window, y, x);
 	wbkgdset(node->window, '\0' | COLOR_PAIR(gnt_widget_has_focus(node->me) ? GNT_COLOR_TITLE : GNT_COLOR_TITLE_D));
 	mvwaddstr(node->window, 0, 0, title);
+	wmove(node->window, y, x);
 	if (!gnt_is_refugee()) {
 		update_panels();
 		doupdate();
@@ -296,10 +300,15 @@
 
 	name = gnt_widget_get_name(widget);
 	if (name && strstr(name, "conversation-window")) {
+		int cx, cy, cw, ch;
+		gnt_widget_get_position(widget, &cx, &cy);
+		gnt_widget_get_size(widget, &cw, &ch);
 		find_window_position(irssi, widget, &hor, &vert);
 		get_xywh_for_frame(irssi, hor, vert, &x, &y, &w, &h);
-		gnt_wm_move_window(GNT_WM(irssi), widget, x, y);
-		gnt_wm_resize_window(GNT_WM(irssi), widget, w, h);
+		if (x != cx || y != cy)
+			gnt_wm_move_window(GNT_WM(irssi), widget, x, y);
+		if (w != cw || h != ch)
+			gnt_wm_resize_window(GNT_WM(irssi), widget, w, h);
 	}
 }
 
--- a/finch/libgnt/wms/s.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/libgnt/wms/s.c	Sat Aug 06 03:45:56 2011 +0000
@@ -146,11 +146,11 @@
 	if (!widget)
 		return FALSE;
 		/* This might be a place to bring up a context menu */
-	
+
 	if (event != GNT_LEFT_MOUSE_DOWN ||
 			GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_NO_BORDER))
 		return FALSE;
-	
+
 	gnt_widget_get_position(widget, &x, &y);
 	gnt_widget_get_size(widget, &w, &h);
 
--- a/finch/plugins/gntgf.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/plugins/gntgf.c	Sat Aug 06 03:45:56 2011 +0000
@@ -134,7 +134,7 @@
 	ids = getenv("WINDOWID");
 	if (ids == NULL)
 		return;
-	
+
 	id = atoi(ids);
 
 	dpy = XOpenDisplay(NULL);
@@ -255,7 +255,7 @@
 
 	if (flags & PURPLE_MESSAGE_WHISPER)
 		return;
-	
+
 	nick = PURPLE_CONV_CHAT(conv)->nick;
 
 	if (g_utf8_collate(sender, nick) == 0)
@@ -401,7 +401,7 @@
 {
 	purple_prefs_add_none("/plugins");
 	purple_prefs_add_none("/plugins/gnt");
-	
+
 	purple_prefs_add_none("/plugins/gnt/gntgf");
 	purple_prefs_add_none(PREFS_EVENT);
 
--- a/finch/plugins/gnthistory.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/finch/plugins/gnthistory.c	Sat Aug 06 03:45:56 2011 +0000
@@ -158,7 +158,7 @@
 		while (list) {
 			const char *label = _(list->data);
 			list = g_list_delete_link(list, list);
-			purple_request_field_list_add(field, label, list->data);
+			purple_request_field_list_add_icon(field, label, NULL, list->data);
 			if (system && strcmp(system, list->data) == 0)
 				purple_request_field_list_add_selected(field, label);
 			list = g_list_delete_link(list, list);
--- a/libpurple/Makefile.am	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/Makefile.am	Sat Aug 06 03:45:56 2011 +0000
@@ -32,7 +32,7 @@
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = purple.pc
 
-SUBDIRS = $(GCONF_DIR) plugins protocols . tests example
+SUBDIRS = $(GCONF_DIR) plugins protocols ciphers . tests example
 
 purple_coresources = \
 	account.c \
@@ -53,6 +53,11 @@
 	idle.c \
 	imgstore.c \
 	log.c \
+	media/backend-fs2.c \
+	media/backend-iface.c \
+	media/candidate.c \
+	media/codec.c \
+	media/enum-types.c \
 	media.c \
 	mediamanager.c \
 	mime.c \
@@ -151,21 +156,24 @@
 	theme-manager.h \
 	upnp.h \
 	util.h \
-	valgrind.h \
 	value.h \
 	xmlnode.h \
 	whiteboard.h
 
+purple_mediaheaders = \
+	backend-iface.h \
+	candidate.h \
+	codec.h \
+	enum-types.h
+
 purple_builtheaders = purple.h version.h marshallers.h
 
 marshallers.h: marshallers.list
-	@echo "Generating marshallers.h"
-	$(GLIB_GENMARSHAL) --prefix=purple_smarshal $(srcdir)/marshallers.list --header > marshallers.h
+	$(AM_V_GEN)$(GLIB_GENMARSHAL) --prefix=purple_smarshal $(srcdir)/marshallers.list --header > marshallers.h
 
 marshallers.c: marshallers.list marshallers.h
-	@echo "Generating marshallers.c"
-	echo "#include \"marshallers.h\"" > marshallers.c
-	$(GLIB_GENMARSHAL) --prefix=purple_smarshal $(srcdir)/marshallers.list --body >> marshallers.c
+	$(AM_V_GEN)echo "#include \"marshallers.h\"" > marshallers.c
+	$(AM_V_at)$(GLIB_GENMARSHAL) --prefix=purple_smarshal $(srcdir)/marshallers.list --body >> marshallers.c
 
 if ENABLE_DBUS
 
@@ -192,6 +200,7 @@
                 savedstatuses.h smiley.h status.h server.h util.h xmlnode.h prpl.h
 
 purple_build_coreheaders = $(addprefix $(srcdir)/, $(purple_coreheaders)) \
+		$(addprefix $(srcdir)/media/, $(purple_mediaheaders)) \
 		$(purple_builtheaders)
 dbus_build_exported = $(addprefix $(srcdir)/, $(dbus_exported))
 # We should probably make this better
@@ -200,16 +209,16 @@
 	$(srcdir)/protocols/jabber/libxmpp.c
 
 dbus-types.c: dbus-analyze-types.py $(purple_build_coreheaders)
-	cat $(purple_build_coreheaders) | $(PYTHON) $(srcdir)/dbus-analyze-types.py --pattern=PURPLE_DBUS_DEFINE_TYPE\(%s\) > $@
+	$(AM_V_GEN)cat $(purple_build_coreheaders) | $(PYTHON) $(srcdir)/dbus-analyze-types.py --pattern=PURPLE_DBUS_DEFINE_TYPE\(%s\) > $@
 
 dbus-types.h: dbus-analyze-types.py $(purple_build_coreheaders)
-	cat $(purple_build_coreheaders) | $(PYTHON) $(srcdir)/dbus-analyze-types.py --pattern=PURPLE_DBUS_DECLARE_TYPE\(%s\) > $@
+	$(AM_V_GEN)cat $(purple_build_coreheaders) | $(PYTHON) $(srcdir)/dbus-analyze-types.py --pattern=PURPLE_DBUS_DECLARE_TYPE\(%s\) > $@
 
 dbus-bindings.c: dbus-analyze-functions.py $(dbus_exported)
-	cat $(dbus_build_exported) | $(PYTHON) $(srcdir)/dbus-analyze-functions.py > $@
+	$(AM_V_GEN)cat $(dbus_build_exported) | $(PYTHON) $(srcdir)/dbus-analyze-functions.py > $@
 
 dbus-signals.c: dbus-analyze-signals.py $(dbus_signals)
-	cat $(dbus_signals) | $(PYTHON) $(srcdir)/dbus-analyze-signals.py > $@
+	$(AM_V_GEN)cat $(dbus_signals) | $(PYTHON) $(srcdir)/dbus-analyze-signals.py > $@
 
 dbus-server.$(OBJEXT): dbus-bindings.c dbus-signals.c dbus-types.c dbus-types.h
 dbus-server.lo: dbus-bindings.c dbus-signals.c dbus-types.c dbus-types.h
@@ -224,11 +233,11 @@
 libpurple_client_la_LIBADD = $(DBUS_LIBS)
 
 purple-client-bindings.c: dbus-analyze-functions.py $(dbus_exported)
-	cat $(dbus_build_exported) | $(PYTHON) $(srcdir)/dbus-analyze-functions.py --client > $@
+	$(AM_V_GEN)cat $(dbus_build_exported) | $(PYTHON) $(srcdir)/dbus-analyze-functions.py --client > $@
 
-purple-client-bindings.h: dbus-analyze-types.py dbus-analyze-functions.py $(purple_coreheaders) $(purple_builtheaders) $(dbus_exported)
-	cat $(purple_build_coreheaders) | $(PYTHON) $(srcdir)/dbus-analyze-types.py --keyword=enum --verbatim > $@
-	cat $(dbus_build_exported) | $(PYTHON) $(srcdir)/dbus-analyze-functions.py --client --headers >> $@
+purple-client-bindings.h: dbus-analyze-types.py dbus-analyze-functions.py $(purple_coreheaders) $(addprefix media/, $(purple_mediaheaders)) $(purple_builtheaders) $(dbus_exported)
+	$(AM_V_GEN)cat $(purple_build_coreheaders) | $(PYTHON) $(srcdir)/dbus-analyze-types.py --keyword=enum --verbatim > $@
+	$(AM_V_at)cat $(dbus_build_exported) | $(PYTHON) $(srcdir)/dbus-analyze-functions.py --client --headers >> $@
 
 $(libpurple_client_la_OBJECTS): purple-client-bindings.h purple-client-bindings.c
 
@@ -275,6 +284,7 @@
 
 noinst_HEADERS= \
 	internal.h \
+	media/backend-fs2.h \
 	valgrind.h
 
 libpurpleincludedir=$(includedir)/libpurple
@@ -283,6 +293,10 @@
 	$(purple_builtheaders) \
 	$(dbus_headers)
 
+mediaincludedir=$(includedir)/libpurple/media
+mediainclude_HEADERS = \
+	$(addprefix $(srcdir)/media/, $(purple_mediaheaders))
+
 libpurple_la_DEPENDENCIES = $(STATIC_LINK_LIBS)
 libpurple_la_LDFLAGS = -export-dynamic -version-info $(PURPLE_LT_VERSION_INFO) -no-undefined
 libpurple_la_LIBADD = \
@@ -296,6 +310,7 @@
 	$(GSTREAMER_LIBS) \
 	$(GSTINTERFACES_LIBS) \
 	$(IDN_LIBS) \
+	ciphers/libpurple-ciphers.la \
 	-lm
 
 AM_CPPFLAGS = \
--- a/libpurple/Makefile.mingw	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/Makefile.mingw	Sat Aug 06 03:45:56 2011 +0000
@@ -8,7 +8,7 @@
 include $(PIDGIN_TREE_TOP)/libpurple/win32/global.mak
 
 TARGET = libpurple
-NEEDED_DLLS = $(LIBXML2_TOP)/bin/libxml2.dll
+NEEDED_DLLS = $(LIBXML2_TOP)/bin/libxml2-2.dll
 
 ##
 ## INCLUDE PATHS
@@ -20,7 +20,7 @@
 			-I$(GTK_TOP)/include \
 			-I$(GTK_TOP)/include/glib-2.0 \
 			-I$(GTK_TOP)/lib/glib-2.0/include \
-			-I$(LIBXML2_TOP)/include
+			-I$(LIBXML2_TOP)/include/libxml2
 
 LIB_PATHS +=		-L$(GTK_TOP)/lib \
 			-L$(LIBXML2_TOP)/lib
@@ -35,6 +35,14 @@
 			buddyicon.c \
 			certificate.c \
 			cipher.c \
+			ciphers/des.c \
+			ciphers/gchecksum.c \
+			ciphers/hmac.c \
+			ciphers/md4.c \
+			ciphers/md5.c \
+			ciphers/rc4.c \
+			ciphers/sha1.c \
+			ciphers/sha256.c \
 			circbuffer.c \
 			cmds.c \
 			connection.c \
@@ -48,8 +56,8 @@
 			idle.c \
 			imgstore.c \
 			log.c \
+			mediamanager.c \
 			media.c \
-			mediamanager.c \
 			mime.c \
 			nat-pmp.c \
 			network.c \
--- a/libpurple/account.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/account.c	Sat Aug 06 03:45:56 2011 +0000
@@ -294,6 +294,7 @@
 			 proxy_type == PURPLE_PROXY_HTTP       ? "http"   :
 			 proxy_type == PURPLE_PROXY_SOCKS4     ? "socks4" :
 			 proxy_type == PURPLE_PROXY_SOCKS5     ? "socks5" :
+			 proxy_type == PURPLE_PROXY_TOR        ? "tor" :
 			 proxy_type == PURPLE_PROXY_USE_ENVVAR ? "envvar" : "unknown"), -1);
 
 	if ((value = purple_proxy_info_get_host(proxy_info)) != NULL)
@@ -508,8 +509,46 @@
 		purple_account_remove_setting(account, "xferjp_host");
 
 	}
-
-	return;
+}
+
+static void
+migrate_icq_server(PurpleAccount *account)
+{
+	/* Migrate the login server setting for ICQ accounts.  See
+	 * 'mtn log --last 1 --no-graph --from b6d7712e90b68610df3bd2d8cbaf46d94c8b3794'
+	 * for details on the change. */
+
+	if(purple_strequal(purple_account_get_protocol_id(account), "prpl-icq")) {
+		const char *tmp = purple_account_get_string(account, "server", NULL);
+
+		/* Non-secure server */
+		if(purple_strequal(tmp,	"login.messaging.aol.com") ||
+				purple_strequal(tmp, "login.oscar.aol.com"))
+			purple_account_set_string(account, "server", "login.icq.com");
+
+		/* Secure server */
+		if(purple_strequal(tmp, "slogin.oscar.aol.com"))
+			purple_account_set_string(account, "server", "slogin.icq.com");
+	}
+}
+
+static void
+migrate_xmpp_encryption(PurpleAccount *account)
+{
+	/* When this is removed, nuke the "old_ssl" and "require_tls" settings */
+	if (g_str_equal(purple_account_get_protocol_id(account), "prpl-jabber")) {
+		const char *sec = purple_account_get_string(account, "connection_security", "");
+
+		if (g_str_equal("", sec)) {
+			const char *val = "require_tls";
+			if (purple_account_get_bool(account, "old_ssl", FALSE))
+				val = "old_ssl";
+			else if (!purple_account_get_bool(account, "require_tls", TRUE))
+				val = "opportunistic_tls";
+
+			purple_account_set_string(account, "connection_security", val);
+		}
+	}
 }
 
 static void
@@ -579,6 +618,12 @@
 	/* we do this here because we need access to account settings to determine
 	 * if we can/should migrate an old Yahoo! JAPAN account */
 	migrate_yahoo_japan(account);
+	/* we do this here because we need access to account settings to determine
+	 * if we can/should migrate an ICQ account's server setting */
+	migrate_icq_server(account);
+	/* we do this here because we need to do it before the user views the
+	 * Edit Account dialog. */
+	migrate_xmpp_encryption(account);
 }
 
 static GList *
@@ -702,6 +747,8 @@
 			purple_proxy_info_set_type(proxy_info, PURPLE_PROXY_SOCKS4);
 		else if (purple_strequal(data, "socks5"))
 			purple_proxy_info_set_type(proxy_info, PURPLE_PROXY_SOCKS5);
+		else if (purple_strequal(data, "tor"))
+			purple_proxy_info_set_type(proxy_info, PURPLE_PROXY_TOR);
 		else if (purple_strequal(data, "envvar"))
 			purple_proxy_info_set_type(proxy_info, PURPLE_PROXY_USE_ENVVAR);
 		else
@@ -1043,6 +1090,9 @@
 	g_hash_table_destroy(account->settings);
 	g_hash_table_destroy(account->ui_settings);
 
+	if (account->proxy_info)
+		purple_proxy_info_destroy(account->proxy_info);
+
 	purple_account_set_status_types(account, NULL);
 
 	purple_presence_destroy(account->presence);
@@ -1129,7 +1179,7 @@
 static void
 request_password_cancel_cb(PurpleAccount *account, PurpleRequestFields *fields)
 {
-	/* Disable the account as the user has canceled connecting */
+	/* Disable the account as the user has cancelled connecting */
 	purple_account_set_enabled(account, purple_core_get_ui(), FALSE);
 }
 
@@ -1394,6 +1444,27 @@
 		return NULL;
 	}
 
+	plugin_return = GPOINTER_TO_INT(
+			purple_signal_emit_return_1(
+				purple_accounts_get_handle(),
+				"account-authorization-requested-with-message",
+				account, remote_user, message
+			));
+
+	switch (plugin_return)
+	{
+		case PURPLE_ACCOUNT_RESPONSE_IGNORE:
+			return NULL;
+		case PURPLE_ACCOUNT_RESPONSE_ACCEPT:
+			if (auth_cb != NULL)
+				auth_cb(user_data);
+			return NULL;
+		case PURPLE_ACCOUNT_RESPONSE_DENY:
+			if (deny_cb != NULL)
+				deny_cb(user_data);
+			return NULL;
+	}
+
 	if (ui_ops != NULL && ui_ops->request_authorize != NULL) {
 		info            = g_new0(PurpleAccountRequestInfo, 1);
 		info->type      = PURPLE_ACCOUNT_REQUEST_AUTHORIZATION;
@@ -1709,6 +1780,14 @@
 }
 
 void
+purple_account_set_privacy_type(PurpleAccount *account, PurplePrivacyType privacy_type)
+{
+	g_return_if_fail(account != NULL);
+
+	account->perm_deny = privacy_type;
+}
+
+void
 purple_account_set_status_types(PurpleAccount *account, GList *status_types)
 {
 	g_return_if_fail(account != NULL);
@@ -1774,6 +1853,106 @@
 	schedule_accounts_save();
 }
 
+struct public_alias_closure
+{
+	PurpleAccount *account;
+	gpointer failure_cb;
+};
+
+static gboolean
+set_public_alias_unsupported(gpointer data)
+{
+	struct public_alias_closure *closure = data;
+	PurpleSetPublicAliasFailureCallback failure_cb = closure->failure_cb;
+
+	failure_cb(closure->account,
+	           _("This protocol does not support setting a public alias."));
+	g_free(closure);
+
+	return FALSE;
+}
+
+void
+purple_account_set_public_alias(PurpleAccount *account,
+		const char *alias, PurpleSetPublicAliasSuccessCallback success_cb,
+		PurpleSetPublicAliasFailureCallback failure_cb)
+{
+	PurpleConnection *gc;
+	PurplePlugin *prpl = NULL;
+	PurplePluginProtocolInfo *prpl_info = NULL;
+
+	g_return_if_fail(account != NULL);
+	g_return_if_fail(purple_account_is_connected(account));
+
+	gc = purple_account_get_connection(account);
+	prpl = purple_connection_get_prpl(gc);
+	prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+
+	if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, set_public_alias))
+		prpl_info->set_public_alias(gc, alias, success_cb, failure_cb);
+	else if (failure_cb) {
+		struct public_alias_closure *closure =
+				g_new0(struct public_alias_closure, 1);
+		closure->account = account;
+		closure->failure_cb = failure_cb;
+		purple_timeout_add(0, set_public_alias_unsupported, closure);
+	}
+}
+
+static gboolean
+get_public_alias_unsupported(gpointer data)
+{
+	struct public_alias_closure *closure = data;
+	PurpleGetPublicAliasFailureCallback failure_cb = closure->failure_cb;
+
+	failure_cb(closure->account,
+	           _("This protocol does not support fetching the public alias."));
+	g_free(closure);
+
+	return FALSE;
+}
+
+void
+purple_account_get_public_alias(PurpleAccount *account,
+		PurpleGetPublicAliasSuccessCallback success_cb,
+		PurpleGetPublicAliasFailureCallback failure_cb)
+{
+	PurpleConnection *gc;
+	PurplePlugin *prpl = NULL;
+	PurplePluginProtocolInfo *prpl_info = NULL;
+
+	g_return_if_fail(account != NULL);
+	g_return_if_fail(purple_account_is_connected(account));
+
+	gc = purple_account_get_connection(account);
+	prpl = purple_connection_get_prpl(gc);
+	prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+
+	if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, get_public_alias))
+		prpl_info->get_public_alias(gc, success_cb, failure_cb);
+	else if (failure_cb) {
+		struct public_alias_closure *closure =
+				g_new0(struct public_alias_closure, 1);
+		closure->account = account;
+		closure->failure_cb = failure_cb;
+		purple_timeout_add(0, get_public_alias_unsupported, closure);
+	}
+}
+
+gboolean
+purple_account_get_silence_suppression(const PurpleAccount *account)
+{
+	return purple_account_get_bool(account, "silence-suppression", FALSE);
+}
+
+void
+purple_account_set_silence_suppression(PurpleAccount *account, gboolean value)
+{
+	g_return_if_fail(account != NULL);
+
+	purple_account_set_bool(account, "silence-suppression", value);
+}
+
 void
 purple_account_clear_settings(PurpleAccount *account)
 {
@@ -2036,6 +2215,42 @@
 	return account->gc;
 }
 
+const gchar *
+purple_account_get_name_for_display(const PurpleAccount *account)
+{
+	PurpleBuddy *self = NULL;
+	PurpleConnection *gc = NULL;
+	const gchar *name = NULL, *username = NULL, *displayname = NULL;
+
+	name = purple_account_get_alias(account);
+
+	if (name) {
+		return name;
+	}
+
+	username = purple_account_get_username(account);
+	self = purple_find_buddy((PurpleAccount *)account, username);
+
+	if (self) {
+		const gchar *calias= purple_buddy_get_contact_alias(self);
+
+		/* We don't want to return the buddy name if the buddy/contact
+		 * doesn't have an alias set. */
+		if (!purple_strequal(username, calias)) {
+			return calias;
+		}
+	}
+
+	gc = purple_account_get_connection(account);
+	displayname = purple_connection_get_display_name(gc);
+
+	if (displayname) {
+		return displayname;
+	}
+
+	return username;
+}
+
 gboolean
 purple_account_get_remember_password(const PurpleAccount *account)
 {
@@ -2069,6 +2284,14 @@
 	return account->proxy_info;
 }
 
+PurplePrivacyType
+purple_account_get_privacy_type(const PurpleAccount *account)
+{
+	g_return_val_if_fail(account != NULL, PURPLE_PRIVACY_ALLOW_ALL);
+
+	return account->perm_deny;
+}
+
 PurpleStatus *
 purple_account_get_active_status(const PurpleAccount *account)
 {
@@ -2320,8 +2543,37 @@
 	if (prpl != NULL)
 		prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
 
-	if (prpl_info != NULL && prpl_info->add_buddy != NULL)
-		prpl_info->add_buddy(gc, buddy, purple_buddy_get_group(buddy));
+	if (prpl_info != NULL) {
+		if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, add_buddy_with_invite))
+			prpl_info->add_buddy_with_invite(gc, buddy, purple_buddy_get_group(buddy), NULL);
+		else if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, add_buddy))
+			prpl_info->add_buddy(gc, buddy, purple_buddy_get_group(buddy));
+	}
+}
+
+void
+purple_account_add_buddy_with_invite(PurpleAccount *account, PurpleBuddy *buddy, const char *message)
+{
+	PurplePluginProtocolInfo *prpl_info = NULL;
+	PurpleConnection *gc;
+	PurplePlugin *prpl = NULL;
+
+	g_return_if_fail(account != NULL);
+	g_return_if_fail(buddy != NULL);
+
+	gc = purple_account_get_connection(account);
+	if (gc != NULL)
+		prpl = purple_connection_get_prpl(gc);
+
+	if (prpl != NULL)
+		prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+
+	if (prpl_info != NULL) {
+		if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, add_buddy_with_invite))
+			prpl_info->add_buddy_with_invite(gc, buddy, purple_buddy_get_group(buddy), message);
+		else if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, add_buddy))
+			prpl_info->add_buddy(gc, buddy, purple_buddy_get_group(buddy));
+	}
 }
 
 void
@@ -2346,9 +2598,69 @@
 			groups = g_list_append(groups, purple_buddy_get_group(buddy));
 		}
 
-		if (prpl_info->add_buddies != NULL)
+		if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, add_buddies_with_invite))
+			prpl_info->add_buddies_with_invite(gc, buddies, groups, NULL);
+		else if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, add_buddies))
 			prpl_info->add_buddies(gc, buddies, groups);
-		else if (prpl_info->add_buddy != NULL) {
+		else if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, add_buddy_with_invite)) {
+			GList *curb = buddies, *curg = groups;
+
+			while ((curb != NULL) && (curg != NULL)) {
+				prpl_info->add_buddy_with_invite(gc, curb->data, curg->data, NULL);
+				curb = curb->next;
+				curg = curg->next;
+			}
+		}
+		else if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, add_buddy)) {
+			GList *curb = buddies, *curg = groups;
+
+			while ((curb != NULL) && (curg != NULL)) {
+				prpl_info->add_buddy(gc, curb->data, curg->data);
+				curb = curb->next;
+				curg = curg->next;
+			}
+		}
+
+		g_list_free(groups);
+	}
+}
+
+void
+purple_account_add_buddies_with_invite(PurpleAccount *account, GList *buddies, const char *message)
+{
+	PurplePluginProtocolInfo *prpl_info = NULL;
+	PurpleConnection *gc = purple_account_get_connection(account);
+	PurplePlugin *prpl = NULL;
+
+	if (gc != NULL)
+		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) {
+			PurpleBuddy *buddy = cur->data;
+			groups = g_list_append(groups, purple_buddy_get_group(buddy));
+		}
+
+		if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, add_buddies_with_invite))
+			prpl_info->add_buddies_with_invite(gc, buddies, groups, message);
+		else if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, add_buddy_with_invite)) {
+			GList *curb = buddies, *curg = groups;
+
+			while ((curb != NULL) && (curg != NULL)) {
+				prpl_info->add_buddy_with_invite(gc, curb->data, curg->data, message);
+				curb = curb->next;
+				curg = curg->next;
+			}
+		}
+		else if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, add_buddies))
+			prpl_info->add_buddies(gc, buddies, groups);
+		else if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, add_buddy)) {
 			GList *curb = buddies, *curg = groups;
 
 			while ((curb != NULL) && (curg != NULL)) {
@@ -2474,6 +2786,19 @@
 {
 	PurpleAccount *account = purple_connection_get_account(gc);
 	purple_account_clear_current_error(account);
+
+	purple_signal_emit(purple_accounts_get_handle(), "account-signed-on",
+	                   account);
+}
+
+static void
+signed_off_cb(PurpleConnection *gc,
+              gpointer unused)
+{
+	PurpleAccount *account = purple_connection_get_account(gc);
+
+	purple_signal_emit(purple_accounts_get_handle(), "account-signed-off",
+	                   account);
 }
 
 static void
@@ -2524,6 +2849,9 @@
 	err->description = g_strdup(description);
 
 	set_current_error(account, err);
+
+	purple_signal_emit(purple_accounts_get_handle(), "account-connection-error",
+	                   account, type, description);
 }
 
 const PurpleConnectionErrorInfo *
@@ -2708,11 +3036,12 @@
 	char *who;
 
 	g_return_val_if_fail(name != NULL, NULL);
+	g_return_val_if_fail(protocol_id != NULL, NULL);
 
 	for (l = purple_accounts_get_all(); l != NULL; l = l->next) {
 		account = (PurpleAccount *)l->data;
-		if (protocol_id && !purple_strequal(account->protocol_id, protocol_id))
-		  continue;
+		if (!purple_strequal(account->protocol_id, protocol_id))
+			continue;
 
 		who = g_strdup(purple_normalize(account, name));
 		if (purple_strequal(purple_normalize(account, purple_account_get_username(account)), who)) {
@@ -2844,6 +3173,13 @@
 										PURPLE_SUBTYPE_ACCOUNT),
 						purple_value_new(PURPLE_TYPE_STRING));
 
+	purple_signal_register(handle, "account-authorization-requested-with-message",
+						purple_marshal_INT__POINTER_POINTER_POINTER,
+						purple_value_new(PURPLE_TYPE_INT), 3,
+						purple_value_new(PURPLE_TYPE_SUBTYPE,
+										PURPLE_SUBTYPE_ACCOUNT),
+						purple_value_new(PURPLE_TYPE_STRING),
+						purple_value_new(PURPLE_TYPE_STRING));
 	purple_signal_register(handle, "account-authorization-denied",
 						purple_marshal_VOID__POINTER_POINTER, NULL, 2,
 						purple_value_new(PURPLE_TYPE_SUBTYPE,
@@ -2864,8 +3200,27 @@
 	                       purple_value_new(PURPLE_TYPE_POINTER),
 	                       purple_value_new(PURPLE_TYPE_POINTER));
 
+	purple_signal_register(handle, "account-signed-on",
+	                       purple_marshal_VOID__POINTER, NULL, 1,
+	                       purple_value_new(PURPLE_TYPE_SUBTYPE,
+	                                        PURPLE_SUBTYPE_ACCOUNT));
+
+	purple_signal_register(handle, "account-signed-off",
+	                       purple_marshal_VOID__POINTER, NULL, 1,
+	                       purple_value_new(PURPLE_TYPE_SUBTYPE,
+	                                        PURPLE_SUBTYPE_ACCOUNT));
+
+	purple_signal_register(handle, "account-connection-error",
+	                       purple_marshal_VOID__POINTER_INT_POINTER, NULL, 3,
+	                       purple_value_new(PURPLE_TYPE_SUBTYPE,
+	                                        PURPLE_SUBTYPE_ACCOUNT),
+	                       purple_value_new(PURPLE_TYPE_ENUM),
+	                       purple_value_new(PURPLE_TYPE_STRING));
+
 	purple_signal_connect(conn_handle, "signed-on", handle,
 	                      PURPLE_CALLBACK(signed_on_cb), NULL);
+	purple_signal_connect(conn_handle, "signed-off", handle,
+	                      PURPLE_CALLBACK(signed_off_cb), NULL);
 	purple_signal_connect(conn_handle, "connection-error", handle,
 	                      PURPLE_CALLBACK(connection_error_cb), NULL);
 
--- a/libpurple/account.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/account.h	Sat Aug 06 03:45:56 2011 +0000
@@ -39,6 +39,10 @@
 typedef void (*PurpleAccountRequestAuthorizationCb)(void *);
 typedef void (*PurpleAccountRegistrationCb)(PurpleAccount *account, gboolean succeeded, void *user_data);
 typedef void (*PurpleAccountUnregistrationCb)(PurpleAccount *account, gboolean succeeded, void *user_data);
+typedef void (*PurpleSetPublicAliasSuccessCallback)(PurpleAccount *account, const char *new_alias);
+typedef void (*PurpleSetPublicAliasFailureCallback)(PurpleAccount *account, const char *error);
+typedef void (*PurpleGetPublicAliasSuccessCallback)(PurpleAccount *account, const char *alias);
+typedef void (*PurpleGetPublicAliasFailureCallback)(PurpleAccount *account, const char *error);
 
 #include "connection.h"
 #include "log.h"
@@ -55,6 +59,16 @@
 	PURPLE_ACCOUNT_REQUEST_AUTHORIZATION = 0 /* Account authorization request */
 } PurpleAccountRequestType;
 
+/**
+ * Account request response types
+ */
+typedef enum
+{
+	PURPLE_ACCOUNT_RESPONSE_IGNORE = -2,
+	PURPLE_ACCOUNT_RESPONSE_DENY = -1,
+	PURPLE_ACCOUNT_RESPONSE_PASS = 0,
+	PURPLE_ACCOUNT_RESPONSE_ACCEPT = 1
+} PurpleAccountRequestResponse;
 
 /**  Account UI operations, used to notify the user of status changes and when
  *   buddies add this account to their buddy lists.
@@ -139,6 +153,7 @@
 	 * buddies are added to your permit list.  Currently we have to
 	 * iterate through the entire list if we want to check if someone
 	 * is permitted or denied.  We should do this for 3.0.0.
+	 * Or maybe use a GTree.
 	 */
 	GSList *permit;             /**< Permit list.                           */
 	GSList *deny;               /**< Deny list.                             */
@@ -414,6 +429,16 @@
 void purple_account_set_proxy_info(PurpleAccount *account, PurpleProxyInfo *info);
 
 /**
+ * Sets the account's privacy type.
+ *
+ * @param account      The account.
+ * @param privacy_type The privacy type.
+ *
+ * @since 2.7.0
+ */
+void purple_account_set_privacy_type(PurpleAccount *account, PurplePrivacyType privacy_type);
+
+/**
  * Sets the account's status types.
  *
  * @param account      The account.
@@ -452,6 +477,60 @@
 	const char *status_id, gboolean active, GList *attrs);
 
 /**
+ * Set a server-side (public) alias for this account.  The account
+ * must already be connected.
+ *
+ * Currently, the public alias is not stored locally, although this
+ * may change in a later version.
+ *
+ * @param account    The account
+ * @param alias      The new public alias for this account or NULL
+ *                   to unset the alias/nickname (or return it to
+ *                   a protocol-specific "default", like the username)
+ * @param success_cb A callback which will be called if the alias
+ *                   is successfully set on the server (or NULL).
+ * @param failure_cb A callback which will be called if the alias
+ *                   is not successfully set on the server (or NULL).
+ *
+ * @since 2.7.0
+ */
+void purple_account_set_public_alias(PurpleAccount *account,
+	const char *alias, PurpleSetPublicAliasSuccessCallback success_cb,
+	PurpleSetPublicAliasFailureCallback failure_cb);
+
+/**
+ * Fetch the server-side (public) alias for this account.  The account
+ * must already be connected.
+ *
+ * @param account    The account
+ * @param success_cb A callback which will be called with the alias
+ * @param failure_cb A callback which will be called if the prpl is
+ *                   unable to retrieve the server-side alias.
+ * @since 2.7.0
+ */
+void purple_account_get_public_alias(PurpleAccount *account,
+	PurpleGetPublicAliasSuccessCallback success_cb,
+	PurpleGetPublicAliasFailureCallback failure_cb);
+
+/**
+ * Return whether silence suppression is used during voice call.
+ *
+ * @param account The account.
+ *
+ * @return @c TRUE if suppression is used, or @c FALSE if not.
+ */
+gboolean purple_account_get_silence_suppression(const PurpleAccount *account);
+
+/**
+ * Sets whether silence suppression is used during voice call.
+ *
+ * @param account The account.
+ * @param value   @c TRUE if suppression should be used.
+ */
+void purple_account_set_silence_suppression(PurpleAccount *account,
+											gboolean value);
+
+/**
  * Clears all protocol-specific settings on an account.
  *
  * @param account The account.
@@ -630,6 +709,20 @@
 PurpleConnection *purple_account_get_connection(const PurpleAccount *account);
 
 /**
+ * Returns a name for this account appropriate for display to the user. In
+ * order of preference: the account's alias; the contact or buddy alias (if
+ * the account exists on its own buddy list); the connection's display name;
+ * the account's username.
+ *
+ * @param account The account.
+ *
+ * @return The name to display.
+ *
+ * @since 2.7.0
+ */
+const gchar *purple_account_get_name_for_display(const PurpleAccount *account);
+
+/**
  * Returns whether or not this account should save its password.
  *
  * @param account The account.
@@ -669,6 +762,17 @@
 PurpleProxyInfo *purple_account_get_proxy_info(const PurpleAccount *account);
 
 /**
+ * Returns the account's privacy type.
+ *
+ * @param account   The account.
+ *
+ * @return The privacy type.
+ *
+ * @since 2.7.0
+ */
+PurplePrivacyType purple_account_get_privacy_type(const PurpleAccount *account);
+
+/**
  * Returns the active status for this account.  This looks through
  * the PurplePresence associated with this account and returns the
  * PurpleStatus that has its active flag set to "TRUE."  There can be
@@ -854,15 +958,40 @@
  *
  * @param account The account.
  * @param buddy The buddy to add.
+ *
+ * @deprecated Use purple_account_add_buddy_with_invite and \c NULL message.
  */
 void purple_account_add_buddy(PurpleAccount *account, PurpleBuddy *buddy);
 /**
+ * Adds a buddy to the server-side buddy list for the specified account.
+ *
+ * @param account The account.
+ * @param buddy The buddy to add.
+ * @param message The invite message.  This may be ignored by a prpl.
+ *
+ * @since 2.8.0
+ */
+void purple_account_add_buddy_with_invite(PurpleAccount *account, PurpleBuddy *buddy, const char *message);
+
+/**
  * Adds a list of buddies to the server-side buddy list.
  *
  * @param account The account.
  * @param buddies The list of PurpleBlistNodes representing the buddies to add.
+ *
+ * @deprecated Use purple_account_add_buddies_with_invite and \c NULL message.
  */
 void purple_account_add_buddies(PurpleAccount *account, GList *buddies);
+/**
+ * Adds a list of buddies to the server-side buddy list.
+ *
+ * @param account The account.
+ * @param buddies The list of PurpleBlistNodes representing the buddies to add.
+ * @param message The invite message.  This may be ignored by a prpl.
+ *
+ * @since 2.8.0
+ */
+void purple_account_add_buddies_with_invite(PurpleAccount *account, GList *buddies, const char *message);
 
 /**
  * Removes a buddy from the server-side buddy list.
--- a/libpurple/blist.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/blist.c	Sat Aug 06 03:45:56 2011 +0000
@@ -28,6 +28,7 @@
 #include "dbus-maybe.h"
 #include "debug.h"
 #include "notify.h"
+#include "pounce.h"
 #include "prefs.h"
 #include "privacy.h"
 #include "prpl.h"
@@ -1739,6 +1740,14 @@
 	g_free(contact);
 }
 
+PurpleGroup *
+purple_contact_get_group(const PurpleContact *contact)
+{
+	g_return_val_if_fail(contact, NULL);
+
+	return (PurpleGroup *)(((PurpleBlistNode *)contact)->parent);
+}
+
 void purple_contact_set_alias(PurpleContact *contact, const char *alias)
 {
 	purple_blist_alias_contact(contact,alias);
@@ -2176,6 +2185,9 @@
 	if (ops && ops->remove_node)
 		ops->remove_node(node);
 
+	/* Remove this buddy's pounces */
+	purple_pounce_destroy_all_by_buddy(buddy);
+
 	/* Signal that the buddy has been removed before freeing the memory for it */
 	purple_signal_emit(purple_blist_get_handle(), "buddy-removed", buddy);
 
@@ -2605,6 +2617,18 @@
 	return buddy->presence;
 }
 
+PurpleMediaCaps purple_buddy_get_media_caps(const PurpleBuddy *buddy)
+{
+	g_return_val_if_fail(buddy != NULL, 0);
+	return buddy->media_caps;
+}
+
+void purple_buddy_set_media_caps(PurpleBuddy *buddy, PurpleMediaCaps media_caps)
+{
+	g_return_if_fail(buddy != NULL);
+	buddy->media_caps = media_caps;
+}
+
 PurpleGroup *purple_buddy_get_group(PurpleBuddy *buddy)
 {
 	g_return_val_if_fail(buddy != NULL, NULL);
@@ -3187,6 +3211,13 @@
 										PURPLE_SUBTYPE_BLIST_NODE),
 						 purple_value_new(PURPLE_TYPE_STRING));
 
+	purple_signal_register(handle, "buddy-caps-changed",
+			purple_marshal_VOID__POINTER_INT_INT, NULL,
+			3, purple_value_new(PURPLE_TYPE_SUBTYPE,
+				PURPLE_SUBTYPE_BLIST_BUDDY),
+			purple_value_new(PURPLE_TYPE_INT),
+			purple_value_new(PURPLE_TYPE_INT));
+
 	purple_signal_connect(purple_accounts_get_handle(), "account-created",
 			handle,
 			PURPLE_CALLBACK(purple_blist_buddies_cache_add_account),
--- a/libpurple/blist.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/blist.h	Sat Aug 06 03:45:56 2011 +0000
@@ -108,6 +108,7 @@
 
 #include "account.h"
 #include "buddyicon.h"
+#include "media.h"
 #include "status.h"
 
 /**************************************************************************/
@@ -143,6 +144,7 @@
 	PurpleBuddyIcon *icon;                    /**< The buddy icon. */
 	PurpleAccount *account;					/**< the account this buddy belongs to */
 	PurplePresence *presence;
+	PurpleMediaCaps media_caps;		/**< The media capabilities of the buddy. */
 };
 
 /**
@@ -657,6 +659,24 @@
 PurplePresence *purple_buddy_get_presence(const PurpleBuddy *buddy);
 
 /**
+ * Gets the media caps from a buddy.
+ *
+ * @param buddy The buddy.
+ * @return      The media caps.
+ *
+ * @since 2.7.0
+ */
+PurpleMediaCaps purple_buddy_get_media_caps(const PurpleBuddy *buddy);
+
+/**
+ * Sets the media caps for a buddy.
+ *
+ * @param buddy      The PurpleBuddy.
+ * @param media_caps The PurpleMediaCaps.
+ */
+void purple_buddy_set_media_caps(PurpleBuddy *buddy, PurpleMediaCaps media_caps);
+
+/**
  * Adds a new buddy to the buddy list.
  *
  * The buddy will be inserted right after node or prepended to the
@@ -715,6 +735,16 @@
 void purple_contact_destroy(PurpleContact *contact);
 
 /**
+ * Gets the PurpleGroup from a PurpleContact
+ *
+ * @param contact  The contact
+ * @return         The group
+ *
+ * @since 2.7.0
+ */
+PurpleGroup *purple_contact_get_group(const PurpleContact *contact);
+
+/**
  * Adds a new contact to the buddy list.
  *
  * The new contact will be inserted after insert or prepended to the list if
--- a/libpurple/buddyicon.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/buddyicon.c	Sat Aug 06 03:45:56 2011 +0000
@@ -716,9 +716,8 @@
 	if (read_icon_file(path, &data, &len))
 	{
 		g_free(path);
-		img = purple_buddy_icon_data_new(data, len, account_icon_file);
-		g_hash_table_insert(pointer_icon_cache, account, img);
-		return img;
+		img = purple_buddy_icons_set_account_icon(account, data, len);
+		return purple_imgstore_ref(img);
 	}
 	g_free(path);
 
@@ -841,9 +840,8 @@
 	if (read_icon_file(path, &data, &len))
 	{
 		g_free(path);
-		img = purple_buddy_icon_data_new(data, len, custom_icon_file);
-		g_hash_table_insert(pointer_icon_cache, node, img);
-		return img;
+		img = purple_buddy_icons_node_set_custom_icon(node, data, len);
+		return purple_imgstore_ref(img);
 	}
 	g_free(path);
 
@@ -1302,6 +1300,9 @@
 	g_hash_table_destroy(pointer_icon_cache);
 	g_free(old_icons_dir);
 	g_free(cache_dir);
+
+	cache_dir = NULL;
+	old_icons_dir = NULL;
 }
 
 void purple_buddy_icon_get_scale_size(PurpleBuddyIconSpec *spec, int *width, int *height)
--- a/libpurple/certificate.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/certificate.c	Sat Aug 06 03:45:56 2011 +0000
@@ -99,11 +99,13 @@
 			         "that can verify it is currently trusted.");
 			break;
 		case PURPLE_CERTIFICATE_NOT_ACTIVATED:
-			return _("The certificate is not valid yet.");
+			return _("The certificate is not valid yet.  Check that your "
+			         "computer's date and time are accurate.");
 			break;
 		case PURPLE_CERTIFICATE_EXPIRED:
 			return _("The certificate has expired and should not be "
-			         "considered valid.");
+			         "considered valid.  Check that your computer's date "
+			         "and time are accurate.");
 			break;
 		case PURPLE_CERTIFICATE_NAME_MISMATCH:
 			/* Translators: "domain" refers to a DNS domain (e.g. talk.google.com) */
@@ -312,7 +314,7 @@
 		uid = purple_certificate_get_unique_id(issuer);
 
 		ret = purple_certificate_get_times(issuer, &activation, &expiration);
-		if (!ret || now < activation || now > expiration) { 
+		if (!ret || now < activation || now > expiration) {
 			if (!ret)
 				purple_debug_error("certificate",
 						"...Failed to get validity times for certificate %s\n"
@@ -377,6 +379,16 @@
 	return (scheme->import_certificate)(filename);
 }
 
+GSList *
+purple_certificates_import(PurpleCertificateScheme *scheme, const gchar *filename)
+{
+	g_return_val_if_fail(scheme, NULL);
+	g_return_val_if_fail(scheme->import_certificates, NULL);
+	g_return_val_if_fail(filename, NULL);
+
+	return (scheme->import_certificates)(filename);
+}
+
 gboolean
 purple_certificate_export(const gchar *filename, PurpleCertificate *crt)
 {
@@ -401,7 +413,7 @@
 	return (array1->len == array2->len) &&
 		(0 == memcmp(array1->data, array2->data, array1->len));
 }
-	
+
 GByteArray *
 purple_certificate_get_fingerprint_sha1(PurpleCertificate *crt)
 {
@@ -704,6 +716,7 @@
 		x509_singleuse_verify_cb );
 
 	/* Cleanup */
+	g_free(cn);
 	g_free(primary);
 	g_free(secondary);
 	g_free(sha_asc);
@@ -800,8 +813,9 @@
 	PurpleCertificateScheme *x509;
 	GDir *certdir;
 	const gchar *entry;
-	GPatternSpec *pempat;
+	GPatternSpec *pempat, *crtpat;
 	GList *iter = NULL;
+	GSList *crts = NULL;
 
 	if (x509_ca_initialized) return TRUE;
 
@@ -817,6 +831,7 @@
 
 	/* Use a glob to only read .pem files */
 	pempat = g_pattern_spec_new("*.pem");
+	crtpat = g_pattern_spec_new("*.crt");
 
 	/* Populate the certificates pool from the search path(s) */
 	for (iter = x509_ca_paths; iter; iter = iter->next) {
@@ -830,32 +845,40 @@
 			gchar *fullpath;
 			PurpleCertificate *crt;
 
-			if ( !g_pattern_match_string(pempat, entry) ) {
+			if (!g_pattern_match_string(pempat, entry) && !g_pattern_match_string(crtpat, entry)) {
 				continue;
 			}
 
 			fullpath = g_build_filename(iter->data, entry, NULL);
 
 			/* TODO: Respond to a failure in the following? */
-			crt = purple_certificate_import(x509, fullpath);
+			crts = purple_certificates_import(x509, fullpath);
 
-			if (x509_ca_quiet_put_cert(crt)) {
-				purple_debug_info("certificate/x509/ca",
-						  "Loaded %s\n",
-						  fullpath);
-			} else {
-				purple_debug_error("certificate/x509/ca",
-						  "Failed to load %s\n",
-						  fullpath);
+			while (crts && crts->data) {
+				crt = crts->data;
+				if (x509_ca_quiet_put_cert(crt)) {
+					gchar *name;
+					name = purple_certificate_get_subject_name(crt);
+					purple_debug_info("certificate/x509/ca",
+							  "Loaded %s from %s\n",
+							  name ? name : "(unknown)", fullpath);
+					g_free(name);
+				} else {
+					purple_debug_error("certificate/x509/ca",
+							  "Failed to load certificate from %s\n",
+							  fullpath);
+				}
+				purple_certificate_destroy(crt);
+				crts = g_slist_delete_link(crts, crts);
 			}
 
-			purple_certificate_destroy(crt);
 			g_free(fullpath);
 		}
 		g_dir_close(certdir);
 	}
 
 	g_pattern_spec_free(pempat);
+	g_pattern_spec_free(crtpat);
 
 	purple_debug_info("certificate/x509/ca",
 			  "Lazy init completed.\n");
@@ -874,7 +897,6 @@
 #else
 # ifdef SSL_CERTIFICATES_DIR
 		x509_ca_paths = g_list_append(NULL, g_strdup(SSL_CERTIFICATES_DIR));
-# else
 # endif
 		x509_ca_paths = g_list_append(x509_ca_paths,
 			g_build_filename(DATADIR, "purple", "ca-certs", NULL));
@@ -925,6 +947,22 @@
 	return NULL;
 }
 
+static GSList *
+x509_ca_locate_certs(GList *lst, const gchar *dn)
+{
+	GList *cur;
+	GSList *crts = NULL;
+
+	for (cur = lst; cur; cur = cur->next) {
+		x509_ca_element *el = cur->data;
+		if (purple_strequal(dn, el->dn)) {
+			crts = g_slist_prepend(crts, el);
+		}
+	}
+	return crts;
+}
+
+
 static gboolean
 x509_ca_cert_in_pool(const gchar *id)
 {
@@ -963,6 +1001,31 @@
 	return crt;
 }
 
+static GSList *
+x509_ca_get_certs(const gchar *id)
+{
+	GSList *crts = NULL, *els = NULL;
+
+	g_return_val_if_fail(x509_ca_lazy_init(), NULL);
+	g_return_val_if_fail(id, NULL);
+
+	/* Search the memory-cached pool */
+	els = x509_ca_locate_certs(x509_ca_certs, id);
+
+	if (els != NULL) {
+		GSList *cur;
+		/* Make a copy of the memcached ones for the function caller
+		   to play with */
+		for (cur = els; cur; cur = cur->next) {
+			x509_ca_element *el = cur->data;
+			crts = g_slist_prepend(crts, purple_certificate_copy(el->crt));
+		}
+		g_slist_free(els);
+	}
+
+	return crts;
+}
+
 static gboolean
 x509_ca_put_cert(const gchar *id, PurpleCertificate *crt)
 {
@@ -1517,6 +1580,7 @@
 				  "Name mismatch: Certificate given for %s "
 				  "has a name of %s\n",
 				  vrq->subject_name, sn);
+		g_free(sn);
 	}
 
 	x509_tls_cached_complete(vrq, flags);
@@ -1535,8 +1599,10 @@
 	PurpleCertificate *ca_crt, *end_crt;
 	PurpleCertificate *failing_crt;
 	GList *chain = vrq->cert_chain;
+	GSList *ca_crts, *cur;
 	GByteArray *last_fpr, *ca_fpr;
-	gchar *ca_id;
+	gboolean valid = FALSE;
+	gchar *ca_id, *ca2_id;
 
 	peer_crt = (PurpleCertificate *) chain->data;
 
@@ -1553,7 +1619,6 @@
 		return;
 	} /* if (self signed) */
 
-	/* Next, attempt to verify the last certificate against a CA */
 	ca = purple_certificate_find_pool(x509_tls_cached.scheme_name, "ca");
 
 	/* Next, check that the certificate chain is valid */
@@ -1603,6 +1668,9 @@
 		return;
 	} /* if (signature chain not good) */
 
+	/* Next, attempt to verify the last certificate is signed by a trusted
+	 * CA, or is a trusted CA (based on fingerprint).
+	 */
 	/* If, for whatever reason, there is no Certificate Authority pool
 	   loaded, we'll verify the subject name and then warn about thsi. */
 	if ( !ca ) {
@@ -1618,27 +1686,31 @@
 
 	end_crt = g_list_last(chain)->data;
 
-	/* Attempt to look up the last certificate's issuer */
-	ca_id = purple_certificate_get_issuer_unique_id(end_crt);
+	/* Attempt to look up the last certificate, and the last certificate's
+	 * issuer. 
+	 */
+	ca_id  = purple_certificate_get_issuer_unique_id(end_crt);
+	ca2_id = purple_certificate_get_unique_id(end_crt);
 	purple_debug_info("certificate/x509/tls_cached",
 			  "Checking for a CA with DN=%s\n",
 			  ca_id);
-	ca_crt = purple_certificate_pool_retrieve(ca, ca_id);
-	if ( NULL == ca_crt ) {
+	purple_debug_info("certificate/x509/tls_cached",
+			  "Also checking for a CA with DN=%s\n",
+			  ca2_id);
+	ca_crts = g_slist_concat(x509_ca_get_certs(ca_id), x509_ca_get_certs(ca2_id));
+	g_free(ca_id);
+	g_free(ca2_id);
+	if ( NULL == ca_crts ) {
 		flags |= PURPLE_CERTIFICATE_CA_UNKNOWN;
 
 		purple_debug_warning("certificate/x509/tls_cached",
-				  "Certificate Authority with DN='%s' not "
-				  "found. I'll prompt the user, I guess.\n",
-				  ca_id);
-		g_free(ca_id);
+				  "No Certificate Authorities with either DN found "
+				  "found. I'll prompt the user, I guess.\n");
 
 		x509_tls_cached_check_subject_name(vrq, flags);
 		return;
 	}
 
-	g_free(ca_id);
-
 	/*
 	 * Check the fingerprints; if they match, then this certificate *is* one
 	 * of the designated "trusted roots", and we don't need to verify the
@@ -1648,30 +1720,35 @@
 	 *
 	 * If the fingerprints don't match, we'll fall back to checking the
 	 * signature.
-	 *
-	 * GnuTLS doesn't seem to include the final root in the verification
-	 * list, so this check will never succeed.  NSS *does* include it in
-	 * the list, so here we are.
 	 */
 	last_fpr = purple_certificate_get_fingerprint_sha1(end_crt);
-	ca_fpr   = purple_certificate_get_fingerprint_sha1(ca_crt);
+	for (cur = ca_crts; cur; cur = cur->next) {
+		ca_crt = cur->data;
+		ca_fpr = purple_certificate_get_fingerprint_sha1(ca_crt);
 
-	if ( !byte_arrays_equal(last_fpr, ca_fpr) &&
-			!purple_certificate_signed_by(end_crt, ca_crt) )
-	{
-		/* TODO: If signed_by ever returns a reason, maybe mention
-		   that, too. */
-		/* TODO: Also mention the CA involved. While I could do this
-		   now, a full DN is a little much with which to assault the
-		   user's poor, leaky eyes. */
-		flags |= PURPLE_CERTIFICATE_INVALID_CHAIN;
+		if ( byte_arrays_equal(last_fpr, ca_fpr) ||
+				purple_certificate_signed_by(end_crt, ca_crt) )
+		{
+			/* TODO: If signed_by ever returns a reason, maybe mention
+			   that, too. */
+			/* TODO: Also mention the CA involved. While I could do this
+			   now, a full DN is a little much with which to assault the
+			   user's poor, leaky eyes. */
+			valid = TRUE;
+			g_byte_array_free(ca_fpr, TRUE);
+			break;
+		}
+
+		g_byte_array_free(ca_fpr, TRUE);
 	}
 
-	g_byte_array_free(ca_fpr, TRUE);
+	if (valid == FALSE)
+		flags |= PURPLE_CERTIFICATE_INVALID_CHAIN;
+
+	g_slist_foreach(ca_crts, (GFunc)purple_certificate_destroy, NULL);
+	g_slist_free(ca_crts);
 	g_byte_array_free(last_fpr, TRUE);
 
-	purple_certificate_destroy(ca_crt);
-
 	x509_tls_cached_check_subject_name(vrq, flags);
 }
 
--- a/libpurple/certificate.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/certificate.h	Sat Aug 06 03:45:56 2011 +0000
@@ -250,10 +250,17 @@
 	/** Retrieve the certificate activation/expiration times */
 	gboolean (* get_times)(PurpleCertificate *crt, time_t *activation, time_t *expiration);
 
+	/** Imports certificates from a file
+	 *
+	 *  @param filename   File to import the certificates from
+	 *  @return           GSList of pointers to the newly allocated Certificate structs
+	 *                    or NULL on failure.
+	 */
+	GSList * (* import_certificates)(const gchar * filename);
+
 	void (*_purple_reserved1)(void);
 	void (*_purple_reserved2)(void);
 	void (*_purple_reserved3)(void);
-	void (*_purple_reserved4)(void);
 };
 
 /** A set of operations used to provide logic for verifying a Certificate's
@@ -492,6 +499,16 @@
 purple_certificate_import(PurpleCertificateScheme *scheme, const gchar *filename);
 
 /**
+ * Imports a list of PurpleCertificates from a file
+ *
+ * @param scheme      Scheme to import under
+ * @param filename    File path to import from
+ * @return Pointer to a GSList of new PurpleCertificates, or NULL on failure
+ */
+GSList *
+purple_certificates_import(PurpleCertificateScheme *scheme, const gchar *filename);
+
+/**
  * Exports a PurpleCertificate to a file
  *
  * @param filename    File to export the certificate to
--- a/libpurple/cipher.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/cipher.c	Sat Aug 06 03:45:56 2011 +0000
@@ -5,23 +5,6 @@
  * to list here.  Please refer to the COPYRIGHT file distributed with this
  * source distribution.
  *
- * Original md5
- * Copyright (C) 2001-2003  Christophe Devine <c.devine@cr0.net>
- *
- * Original md4 taken from linux kernel
- * MD4 Message Digest Algorithm (RFC1320).
- *
- * Implementation derived from Andrew Tridgell and Steve French's
- * CIFS MD4 implementation, and the cryptoapi implementation
- * originally based on the public domain implementation written
- * by Colin Plumb in 1993.
- *
- * Copyright (c) Andrew Tridgell 1997-1998.
- * Modified by Steve French (sfrench@us.ibm.com) 2002
- * Copyright (c) Cryptoapi developers.
- * Copyright (c) 2002 David S. Miller (davem@redhat.com)
- * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
- *
  * Original des taken from gpg
  *
  * des.c - DES and Triple-DES encryption/decryption Algorithm
@@ -57,2454 +40,6 @@
 #include "signals.h"
 #include "value.h"
 
-#if GLIB_CHECK_VERSION(2,16,0)
-static void
-purple_g_checksum_init(PurpleCipherContext *context, GChecksumType type)
-{
-	GChecksum *checksum;
-
-	checksum = g_checksum_new(type);
-	purple_cipher_context_set_data(context, checksum);
-}
-
-static void
-purple_g_checksum_reset(PurpleCipherContext *context, GChecksumType type)
-{
-	GChecksum *checksum;
-
-	checksum = purple_cipher_context_get_data(context);
-	g_return_if_fail(checksum != NULL);
-
-#if GLIB_CHECK_VERSION(2,18,0)
-	g_checksum_reset(checksum);
-#else
-	g_checksum_free(checksum);
-	checksum = g_checksum_new(type);
-	purple_cipher_context_set_data(context, checksum);
-#endif
-}
-
-static void
-purple_g_checksum_uninit(PurpleCipherContext *context)
-{
-	GChecksum *checksum;
-
-	checksum = purple_cipher_context_get_data(context);
-	g_return_if_fail(checksum != NULL);
-
-	g_checksum_free(checksum);
-}
-
-static void
-purple_g_checksum_append(PurpleCipherContext *context, const guchar *data,
-                         gsize len)
-{
-	GChecksum *checksum;
-
-	checksum = purple_cipher_context_get_data(context);
-	g_return_if_fail(checksum != NULL);
-
-	while (len >= G_MAXSSIZE) {
-		g_checksum_update(checksum, data, G_MAXSSIZE);
-		len -= G_MAXSSIZE;
-		data += G_MAXSSIZE;
-	}
-
-	if (len)
-		g_checksum_update(checksum, data, len);
-}
-
-static gboolean
-purple_g_checksum_digest(PurpleCipherContext *context, GChecksumType type,
-                         gsize len, guchar *digest, gsize *out_len)
-{
-	GChecksum *checksum;
-	const gssize required_length = g_checksum_type_get_length(type);
-
-	checksum = purple_cipher_context_get_data(context);
-
-	g_return_val_if_fail(len >= required_length, FALSE);
-	g_return_val_if_fail(checksum != NULL, FALSE);
-
-	g_checksum_get_digest(checksum, digest, &len);
-
-	purple_cipher_context_reset(context, NULL);
-
-	if (out_len)
-		*out_len = len;
-
-	return TRUE;
-}
-#endif
-
-
-/*******************************************************************************
- * MD5
- ******************************************************************************/
-#define MD5_HMAC_BLOCK_SIZE	64
-
-static size_t
-md5_get_block_size(PurpleCipherContext *context)
-{
-	/* This does not change (in this case) */
-	return MD5_HMAC_BLOCK_SIZE;
-}
-
-#if GLIB_CHECK_VERSION(2,16,0)
-
-static void
-md5_init(PurpleCipherContext *context, void *extra)
-{
-	purple_g_checksum_init(context, G_CHECKSUM_MD5);
-}
-
-static void
-md5_reset(PurpleCipherContext *context, void *extra)
-{
-	purple_g_checksum_reset(context, G_CHECKSUM_MD5);
-}
-
-static gboolean
-md5_digest(PurpleCipherContext *context, gsize in_len, guchar digest[16],
-           size_t *out_len)
-{
-	return purple_g_checksum_digest(context, G_CHECKSUM_MD5, in_len,
-	                                digest, out_len);
-}
-
-static PurpleCipherOps MD5Ops = {
-	NULL,			/* Set Option		*/
-	NULL,			/* Get Option		*/
-	md5_init,		/* init				*/
-	md5_reset,		/* reset			*/
-	purple_g_checksum_uninit,	/* uninit			*/
-	NULL,			/* set iv			*/
-	purple_g_checksum_append,	/* append			*/
-	md5_digest,		/* digest			*/
-	NULL,			/* encrypt			*/
-	NULL,			/* decrypt			*/
-	NULL,			/* set salt			*/
-	NULL,			/* get salt size	*/
-	NULL,			/* set key			*/
-	NULL,			/* get key size		*/
-	NULL,			/* set batch mode */
-	NULL,			/* get batch mode */
-	md5_get_block_size,	/* get block size */
-	NULL			/* set key with len */
-};
-
-#else /* GLIB_CHECK_VERSION(2,16,0) */
-
-struct MD5Context {
-	guint32 total[2];
-	guint32 state[4];
-	guchar buffer[64];
-};
-
-#define MD5_GET_GUINT32(n,b,i) {			\
-	(n) = ((guint32)(b) [(i)    ]      )	\
-		| ((guint32)(b) [(i) + 1] <<  8)	\
-		| ((guint32)(b) [(i) + 2] << 16)	\
-		| ((guint32)(b) [(i) + 3] << 24);	\
-}
-#define MD5_PUT_GUINT32(n,b,i) {			\
-	(b)[(i)    ] = (guchar)((n)      );		\
-	(b)[(i) + 1] = (guchar)((n) >>  8);		\
-	(b)[(i) + 2] = (guchar)((n) >> 16);		\
-	(b)[(i) + 3] = (guchar)((n) >> 24);		\
-}
-
-static void
-md5_init(PurpleCipherContext *context, gpointer extra) {
-	struct MD5Context *md5_context;
-
-	md5_context = g_new0(struct MD5Context, 1);
-
-	purple_cipher_context_set_data(context, md5_context);
-
-	purple_cipher_context_reset(context, extra);
-}
-
-static void
-md5_reset(PurpleCipherContext *context, gpointer extra) {
-	struct MD5Context *md5_context;
-
-	md5_context = purple_cipher_context_get_data(context);
-
-	md5_context->total[0] = 0;
-	md5_context->total[1] = 0;
-
-	md5_context->state[0] = 0x67452301;
-	md5_context->state[1] = 0xEFCDAB89;
-	md5_context->state[2] = 0x98BADCFE;
-	md5_context->state[3] = 0x10325476;
-
-	memset(md5_context->buffer, 0, sizeof(md5_context->buffer));
-}
-
-static void
-md5_uninit(PurpleCipherContext *context) {
-	struct MD5Context *md5_context;
-
-	purple_cipher_context_reset(context, NULL);
-
-	md5_context = purple_cipher_context_get_data(context);
-	memset(md5_context, 0, sizeof(md5_context));
-
-	g_free(md5_context);
-	md5_context = NULL;
-}
-
-static void
-md5_process(struct MD5Context *md5_context, const guchar data[64]) {
-	guint32 X[16], A, B, C, D;
-
-	A = md5_context->state[0];
-	B = md5_context->state[1];
-	C = md5_context->state[2];
-	D = md5_context->state[3];
-
-	MD5_GET_GUINT32(X[ 0], data,  0);
-	MD5_GET_GUINT32(X[ 1], data,  4);
-	MD5_GET_GUINT32(X[ 2], data,  8);
-	MD5_GET_GUINT32(X[ 3], data, 12);
-	MD5_GET_GUINT32(X[ 4], data, 16);
-	MD5_GET_GUINT32(X[ 5], data, 20);
-	MD5_GET_GUINT32(X[ 6], data, 24);
-	MD5_GET_GUINT32(X[ 7], data, 28);
-	MD5_GET_GUINT32(X[ 8], data, 32);
-	MD5_GET_GUINT32(X[ 9], data, 36);
-	MD5_GET_GUINT32(X[10], data, 40);
-	MD5_GET_GUINT32(X[11], data, 44);
-	MD5_GET_GUINT32(X[12], data, 48);
-	MD5_GET_GUINT32(X[13], data, 52);
-	MD5_GET_GUINT32(X[14], data, 56);
-	MD5_GET_GUINT32(X[15], data, 60);
-
-	#define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n)))
-	#define P(a,b,c,d,k,s,t) {		\
-		a += F(b,c,d) + X[k] + t;	\
-		a = S(a,s) + b;				\
-	}
-
-	/* first pass */
-	#define F(x,y,z) (z ^ (x & (y ^ z)))
-	P(A, B, C, D,  0,  7, 0xD76AA478);
-	P(D, A, B, C,  1, 12, 0xE8C7B756);
-	P(C, D, A, B,  2, 17, 0x242070DB);
-	P(B, C, D, A,  3, 22, 0xC1BDCEEE);
-	P(A, B, C, D,  4,  7, 0xF57C0FAF);
-	P(D, A, B, C,  5, 12, 0x4787C62A);
-	P(C, D, A, B,  6, 17, 0xA8304613);
-	P(B, C, D, A,  7, 22, 0xFD469501);
-	P(A, B, C, D,  8,  7, 0x698098D8);
-	P(D, A, B, C,  9, 12, 0x8B44F7AF);
-	P(C, D, A, B, 10, 17, 0xFFFF5BB1);
-	P(B, C, D, A, 11, 22, 0x895CD7BE);
-	P(A, B, C, D, 12,  7, 0x6B901122);
-	P(D, A, B, C, 13, 12, 0xFD987193);
-	P(C, D, A, B, 14, 17, 0xA679438E);
-	P(B, C, D, A, 15, 22, 0x49B40821);
-	#undef F
-
-	/* second pass */
-	#define F(x,y,z) (y ^ (z & (x ^ y)))
-	P(A, B, C, D,  1,  5, 0xF61E2562);
-	P(D, A, B, C,  6,  9, 0xC040B340);
-	P(C, D, A, B, 11, 14, 0x265E5A51);
-	P(B, C, D, A,  0, 20, 0xE9B6C7AA);
-	P(A, B, C, D,  5,  5, 0xD62F105D);
-	P(D, A, B, C, 10,  9, 0x02441453);
-	P(C, D, A, B, 15, 14, 0xD8A1E681);
-	P(B, C, D, A,  4, 20, 0xE7D3FBC8);
-	P(A, B, C, D,  9,  5, 0x21E1CDE6);
-	P(D, A, B, C, 14,  9, 0xC33707D6);
-	P(C, D, A, B,  3, 14, 0xF4D50D87);
-	P(B, C, D, A,  8, 20, 0x455A14ED);
-	P(A, B, C, D, 13,  5, 0xA9E3E905);
-	P(D, A, B, C,  2,  9, 0xFCEFA3F8);
-	P(C, D, A, B,  7, 14, 0x676F02D9);
-	P(B, C, D, A, 12, 20, 0x8D2A4C8A);
-	#undef F
-
-	/* third pass */
-	#define F(x,y,z) (x ^ y ^ z)
-	P(A, B, C, D,  5,  4, 0xFFFA3942);
-	P(D, A, B, C,  8, 11, 0x8771F681);
-	P(C, D, A, B, 11, 16, 0x6D9D6122);
-	P(B, C, D, A, 14, 23, 0xFDE5380C);
-	P(A, B, C, D,  1,  4, 0xA4BEEA44);
-	P(D, A, B, C,  4, 11, 0x4BDECFA9);
-	P(C, D, A, B,  7, 16, 0xF6BB4B60);
-	P(B, C, D, A, 10, 23, 0xBEBFBC70);
-	P(A, B, C, D, 13,  4, 0x289B7EC6);
-	P(D, A, B, C,  0, 11, 0xEAA127FA);
-	P(C, D, A, B,  3, 16, 0xD4EF3085);
-	P(B, C, D, A,  6, 23, 0x04881D05);
-	P(A, B, C, D,  9,  4, 0xD9D4D039);
-	P(D, A, B, C, 12, 11, 0xE6DB99E5);
-	P(C, D, A, B, 15, 16, 0x1FA27CF8);
-	P(B, C, D, A,  2, 23, 0xC4AC5665);
-	#undef F
-
-	/* forth pass */
-	#define F(x,y,z) (y ^ (x | ~z))
-	P(A, B, C, D,  0,  6, 0xF4292244);
-	P(D, A, B, C,  7, 10, 0x432AFF97);
-	P(C, D, A, B, 14, 15, 0xAB9423A7);
-	P(B, C, D, A,  5, 21, 0xFC93A039);
-	P(A, B, C, D, 12,  6, 0x655B59C3);
-	P(D, A, B, C,  3, 10, 0x8F0CCC92);
-	P(C, D, A, B, 10, 15, 0xFFEFF47D);
-	P(B, C, D, A,  1, 21, 0x85845DD1);
-	P(A, B, C, D,  8,  6, 0x6FA87E4F);
-	P(D, A, B, C, 15, 10, 0xFE2CE6E0);
-	P(C, D, A, B,  6, 15, 0xA3014314);
-	P(B, C, D, A, 13, 21, 0x4E0811A1);
-	P(A, B, C, D,  4,  6, 0xF7537E82);
-	P(D, A, B, C, 11, 10, 0xBD3AF235);
-	P(C, D, A, B,  2, 15, 0x2AD7D2BB);
-	P(B, C, D, A,  9, 21, 0xEB86D391);
-	#undef F
-	#undef P
-	#undef S
-
-	md5_context->state[0] += A;
-	md5_context->state[1] += B;
-	md5_context->state[2] += C;
-	md5_context->state[3] += D;
-}
-
-static void
-md5_append(PurpleCipherContext *context, const guchar *data, size_t len) {
-	struct MD5Context *md5_context = NULL;
-	guint32 left = 0, fill = 0;
-
-	g_return_if_fail(context != NULL);
-
-	md5_context = purple_cipher_context_get_data(context);
-	g_return_if_fail(md5_context != NULL);
-
-	left = md5_context->total[0] & 0x3F;
-	fill = 64 - left;
-
-	md5_context->total[0] += len;
-	md5_context->total[0] &= 0xFFFFFFFF;
-
-	if(md5_context->total[0] < len)
-		md5_context->total[1]++;
-
-	if(left && len >= fill) {
-		memcpy((md5_context->buffer + left), data, fill);
-		md5_process(md5_context, md5_context->buffer);
-		len -= fill;
-		data += fill;
-		left = 0;
-	}
-
-	while(len >= 64) {
-		md5_process(md5_context, data);
-		len -= 64;
-		data += 64;
-	}
-
-	if(len) {
-		memcpy((md5_context->buffer + left), data, len);
-	}
-}
-
-static gboolean
-md5_digest(PurpleCipherContext *context, size_t in_len, guchar digest[16],
-		   size_t *out_len)
-{
-	struct MD5Context *md5_context = NULL;
-	guint32 last, pad;
-	guint32 high, low;
-	guchar message[8];
-	guchar padding[64] = {
-		0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-		   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-		   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-		   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-	};
-
-	g_return_val_if_fail(in_len >= 16, FALSE);
-
-	md5_context = purple_cipher_context_get_data(context);
-
-	high = (md5_context->total[0] >> 29)
-		 | (md5_context->total[1] << 3);
-	low = (md5_context->total[0] << 3);
-
-	MD5_PUT_GUINT32(low, message, 0);
-	MD5_PUT_GUINT32(high, message, 4);
-
-	last = md5_context->total[0] & 0x3F;
-	pad = (last < 56) ? (56 - last) : (120 - last);
-
-	md5_append(context, padding, pad);
-	md5_append(context, message, 8);
-
-	MD5_PUT_GUINT32(md5_context->state[0], digest, 0);
-	MD5_PUT_GUINT32(md5_context->state[1], digest, 4);
-	MD5_PUT_GUINT32(md5_context->state[2], digest, 8);
-	MD5_PUT_GUINT32(md5_context->state[3], digest, 12);
-
-	if(out_len)
-		*out_len = 16;
-
-	return TRUE;
-}
-
-static PurpleCipherOps MD5Ops = {
-	NULL,			/* Set option */
-	NULL,			/* Get option */
-	md5_init,		/* init */
-	md5_reset,		/* reset */
-	md5_uninit,		/* uninit */
-	NULL,			/* set iv */
-	md5_append,		/* append */
-	md5_digest,		/* digest */
-	NULL,			/* encrypt */
-	NULL,			/* decrypt */
-	NULL,			/* set salt */
-	NULL,			/* get salt size */
-	NULL,			/* set key */
-	NULL,			/* get key size */
-	NULL,			/* set batch mode */
-	NULL,			/* get batch mode */
-	md5_get_block_size,	/* get block size */
-	NULL			/* set key with len */
-};
-
-#endif /* GLIB_CHECK_VERSION(2,16,0) */
-
-/*******************************************************************************
- * MD4
- ******************************************************************************/
-#define MD4_DIGEST_SIZE		16
-#define MD4_HMAC_BLOCK_SIZE	64
-#define MD4_BLOCK_WORDS		16
-#define MD4_HASH_WORDS		4
-
-
-
-struct MD4_Context {
-	guint32 hash[MD4_HASH_WORDS];
-	guint32 block[MD4_BLOCK_WORDS];
-	guint64 byte_count;
-};
-
-static inline guint32 lshift(guint32 x, unsigned int s)
-{
-	x &= 0xFFFFFFFF;
-	return ((x << s) & 0xFFFFFFFF) | (x >> (32 - s));
-}
-
-static inline guint32 F(guint32 x, guint32 y, guint32 z)
-{
-	return (x & y) | ((~x) & z);
-}
-
-static inline guint32 G(guint32 x, guint32 y, guint32 z)
-{
-	return (x & y) | (x & z) | (y & z);
-}
-
-static inline guint32 H(guint32 x, guint32 y, guint32 z)
-{
-	return x ^ y ^ z;
-}
-
-#define ROUND1(a,b,c,d,k,s) (a = lshift(a + F(b,c,d) + k, s))
-#define ROUND2(a,b,c,d,k,s) (a = lshift(a + G(b,c,d) + k + (guint32)0x5A827999,s))
-#define ROUND3(a,b,c,d,k,s) (a = lshift(a + H(b,c,d) + k + (guint32)0x6ED9EBA1,s))
-
-static inline void le32_to_cpu_array(guint32 *buf, unsigned int words)
-{
-	while (words--) {
-		*buf=GUINT_FROM_LE(*buf);
-		buf++;
-	}
-}
-
-static inline void cpu_to_le32_array(guint32 *buf, unsigned int words)
-{
-	while (words--) {
-		*buf=GUINT_TO_LE(*buf);
-		buf++;
-	}
-}
-
-static void md4_transform(guint32 *hash, guint32 const *in)
-{
-	guint32 a, b, c, d;
-
-	a = hash[0];
-	b = hash[1];
-	c = hash[2];
-	d = hash[3];
-
-	ROUND1(a, b, c, d, in[0], 3);
-	ROUND1(d, a, b, c, in[1], 7);
-	ROUND1(c, d, a, b, in[2], 11);
-	ROUND1(b, c, d, a, in[3], 19);
-	ROUND1(a, b, c, d, in[4], 3);
-	ROUND1(d, a, b, c, in[5], 7);
-	ROUND1(c, d, a, b, in[6], 11);
-	ROUND1(b, c, d, a, in[7], 19);
-	ROUND1(a, b, c, d, in[8], 3);
-	ROUND1(d, a, b, c, in[9], 7);
-	ROUND1(c, d, a, b, in[10], 11);
-	ROUND1(b, c, d, a, in[11], 19);
-	ROUND1(a, b, c, d, in[12], 3);
-	ROUND1(d, a, b, c, in[13], 7);
-	ROUND1(c, d, a, b, in[14], 11);
-	ROUND1(b, c, d, a, in[15], 19);
-
-	ROUND2(a, b, c, d,in[ 0], 3);
-	ROUND2(d, a, b, c, in[4], 5);
-	ROUND2(c, d, a, b, in[8], 9);
-	ROUND2(b, c, d, a, in[12], 13);
-	ROUND2(a, b, c, d, in[1], 3);
-	ROUND2(d, a, b, c, in[5], 5);
-	ROUND2(c, d, a, b, in[9], 9);
-	ROUND2(b, c, d, a, in[13], 13);
-	ROUND2(a, b, c, d, in[2], 3);
-	ROUND2(d, a, b, c, in[6], 5);
-	ROUND2(c, d, a, b, in[10], 9);
-	ROUND2(b, c, d, a, in[14], 13);
-	ROUND2(a, b, c, d, in[3], 3);
-	ROUND2(d, a, b, c, in[7], 5);
-	ROUND2(c, d, a, b, in[11], 9);
-	ROUND2(b, c, d, a, in[15], 13);
-
-	ROUND3(a, b, c, d,in[ 0], 3);
-	ROUND3(d, a, b, c, in[8], 9);
-	ROUND3(c, d, a, b, in[4], 11);
-	ROUND3(b, c, d, a, in[12], 15);
-	ROUND3(a, b, c, d, in[2], 3);
-	ROUND3(d, a, b, c, in[10], 9);
-	ROUND3(c, d, a, b, in[6], 11);
-	ROUND3(b, c, d, a, in[14], 15);
-	ROUND3(a, b, c, d, in[1], 3);
-	ROUND3(d, a, b, c, in[9], 9);
-	ROUND3(c, d, a, b, in[5], 11);
-	ROUND3(b, c, d, a, in[13], 15);
-	ROUND3(a, b, c, d, in[3], 3);
-	ROUND3(d, a, b, c, in[11], 9);
-	ROUND3(c, d, a, b, in[7], 11);
-	ROUND3(b, c, d, a, in[15], 15);
-
-	hash[0] += a;
-	hash[1] += b;
-	hash[2] += c;
-	hash[3] += d;
-}
-
-static inline void md4_transform_helper(struct MD4_Context *ctx)
-{
-	le32_to_cpu_array(ctx->block, sizeof(ctx->block) / sizeof(guint32));
-	md4_transform(ctx->hash, ctx->block);
-}
-
-static void
-md4_init(PurpleCipherContext *context, gpointer extra) {
-	struct MD4_Context *mctx;
-	mctx = g_new0(struct MD4_Context, 1);
-	purple_cipher_context_set_data(context, mctx);
-	purple_cipher_context_reset(context, extra);
-
-	mctx->hash[0] = 0x67452301;
-	mctx->hash[1] = 0xefcdab89;
-	mctx->hash[2] = 0x98badcfe;
-	mctx->hash[3] = 0x10325476;
-	mctx->byte_count = 0;
-}
-
-static void
-md4_reset(PurpleCipherContext *context, gpointer extra) {
-	struct MD4_Context *mctx;
-
-	mctx = purple_cipher_context_get_data(context);
-
-	mctx->hash[0] = 0x67452301;
-	mctx->hash[1] = 0xefcdab89;
-	mctx->hash[2] = 0x98badcfe;
-	mctx->hash[3] = 0x10325476;
-	mctx->byte_count = 0;
-}
-
-static void
-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);
-
-	mctx->byte_count += len;
-
-	if (avail > len) {
-		memcpy((char *)mctx->block + (sizeof(mctx->block) - avail),
-				data, len);
-		return;
-	}
-
-	memcpy((char *)mctx->block + (sizeof(mctx->block) - avail),
-			data, avail);
-
-	md4_transform_helper(mctx);
-	data += avail;
-	len -= avail;
-
-	while (len >= sizeof(mctx->block)) {
-		memcpy(mctx->block, data, sizeof(mctx->block));
-		md4_transform_helper(mctx);
-		data += sizeof(mctx->block);
-		len -= sizeof(mctx->block);
-	}
-
-	memcpy(mctx->block, data, len);
-}
-
-static gboolean
-md4_digest(PurpleCipherContext *context, size_t in_len, guchar *out,
-		                   size_t *out_len)
-{
-	struct MD4_Context *mctx = purple_cipher_context_get_data(context);
-	const unsigned int offset = mctx->byte_count & 0x3f;
-	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;
-	if (padding < 0) {
-		memset(p, 0x00, padding + sizeof (guint64));
-		md4_transform_helper(mctx);
-		p = (char *)mctx->block;
-		padding = 56;
-	}
-
-	memset(p, 0, padding);
-	mctx->block[14] = mctx->byte_count << 3;
-	mctx->block[15] = mctx->byte_count >> 29;
-	le32_to_cpu_array(mctx->block, (sizeof(mctx->block) -
-				sizeof(guint64)) / sizeof(guint32));
-	md4_transform(mctx->hash, mctx->block);
-	cpu_to_le32_array(mctx->hash, sizeof(mctx->hash) / sizeof(guint32));
-	memcpy(out, mctx->hash, sizeof(mctx->hash));
-	memset(mctx, 0, sizeof(*mctx));
-	return TRUE;
-}
-
-static void
-md4_uninit(PurpleCipherContext *context) {
-	struct MD4_Context *md4_context;
-
-	purple_cipher_context_reset(context, NULL);
-
-	md4_context = purple_cipher_context_get_data(context);
-	memset(md4_context, 0, sizeof(md4_context));
-
-	g_free(md4_context);
-	md4_context = NULL;
-}
-
-static size_t
-md4_get_block_size(PurpleCipherContext *context)
-{
-	/* This does not change (in this case) */
-	return MD4_HMAC_BLOCK_SIZE;
-}
-
-static PurpleCipherOps MD4Ops = {
-	NULL,                   /* Set option */
-	NULL,                   /* Get option */
-	md4_init,               /* init */
-	md4_reset,              /* reset */
-	md4_uninit,             /* uninit */
-	NULL,                   /* set iv */
-	md4_append,             /* append */
-	md4_digest,             /* digest */
-	NULL,                   /* encrypt */
-	NULL,                   /* decrypt */
-	NULL,                   /* set salt */
-	NULL,                   /* get salt size */
-	NULL,                   /* set key */
-	NULL,                   /* get key size */
-	NULL,                   /* set batch mode */
-	NULL,                   /* get batch mode */
-	md4_get_block_size,     /* get block size */
-	NULL                    /* set key with len */
-};
-
-/*******************************************************************************
- * HMAC
- ******************************************************************************/
-
-struct HMAC_Context {
-	PurpleCipherContext *hash;
-	char *name;
-	int blocksize;
-	guchar *opad;
-};
-
-static void
-hmac_init(PurpleCipherContext *context, gpointer extra)
-{
-	struct HMAC_Context *hctx;
-	hctx = g_new0(struct HMAC_Context, 1);
-	purple_cipher_context_set_data(context, hctx);
-	purple_cipher_context_reset(context, extra);
-}
-
-static void
-hmac_reset(PurpleCipherContext *context, gpointer extra)
-{
-	struct HMAC_Context *hctx;
-
-	hctx = purple_cipher_context_get_data(context);
-
-	g_free(hctx->name);
-	hctx->name = NULL;
-	if (hctx->hash)
-		purple_cipher_context_destroy(hctx->hash);
-	hctx->hash = NULL;
-	hctx->blocksize = 0;
-	g_free(hctx->opad);
-	hctx->opad = NULL;
-}
-
-static void
-hmac_set_opt(PurpleCipherContext *context, const gchar *name, void *value)
-{
-	struct HMAC_Context *hctx;
-
-	hctx = purple_cipher_context_get_data(context);
-
-	if (purple_strequal(name, "hash")) {
-		g_free(hctx->name);
-		if (hctx->hash)
-			purple_cipher_context_destroy(hctx->hash);
-		hctx->name = g_strdup((char*)value);
-		hctx->hash = purple_cipher_context_new_by_name((char *)value, NULL);
-		hctx->blocksize = purple_cipher_context_get_block_size(hctx->hash);
-	}
-}
-
-static void *
-hmac_get_opt(PurpleCipherContext *context, const gchar *name)
-{
-	struct HMAC_Context *hctx;
-
-	hctx = purple_cipher_context_get_data(context);
-
-	if (purple_strequal(name, "hash")) {
-		return hctx->name;
-	}
-
-	return NULL;
-}
-
-static void
-hmac_append(PurpleCipherContext *context, const guchar *data, size_t len)
-{
-	struct HMAC_Context *hctx = purple_cipher_context_get_data(context);
-
-	g_return_if_fail(hctx->hash != NULL);
-
-	purple_cipher_context_append(hctx->hash, data, len);
-}
-
-static gboolean
-hmac_digest(PurpleCipherContext *context, size_t in_len, guchar *out, size_t *out_len)
-{
-	struct HMAC_Context *hctx = purple_cipher_context_get_data(context);
-	PurpleCipherContext *hash = hctx->hash;
-	guchar *inner_hash;
-	size_t hash_len;
-	gboolean result;
-
-	g_return_val_if_fail(hash != NULL, FALSE);
-
-	inner_hash = g_malloc(100); /* TODO: Should be enough for now... */
-	result = purple_cipher_context_digest(hash, 100, inner_hash, &hash_len);
-
-	purple_cipher_context_reset(hash, NULL);
-
-	purple_cipher_context_append(hash, hctx->opad, hctx->blocksize);
-	purple_cipher_context_append(hash, inner_hash, hash_len);
-
-	g_free(inner_hash);
-
-	result = result && purple_cipher_context_digest(hash, in_len, out, out_len);
-
-	return result;
-}
-
-static void
-hmac_uninit(PurpleCipherContext *context)
-{
-	struct HMAC_Context *hctx;
-
-	purple_cipher_context_reset(context, NULL);
-
-	hctx = purple_cipher_context_get_data(context);
-
-	g_free(hctx);
-}
-
-static void
-hmac_set_key_with_len(PurpleCipherContext *context, const guchar * key, size_t key_len)
-{
-	struct HMAC_Context *hctx = purple_cipher_context_get_data(context);
-	int blocksize, i;
-	guchar *ipad;
-	guchar *full_key;
-
-	g_return_if_fail(hctx->hash != NULL);
-
-	g_free(hctx->opad);
-
-	blocksize = hctx->blocksize;
-	ipad = g_malloc(blocksize);
-	hctx->opad = g_malloc(blocksize);
-
-	if (key_len > blocksize) {
-		purple_cipher_context_reset(hctx->hash, NULL);
-		purple_cipher_context_append(hctx->hash, key, key_len);
-		full_key = g_malloc(100); /* TODO: Should be enough for now... */
-		purple_cipher_context_digest(hctx->hash, 100, full_key, &key_len);
-	} else
-		full_key = g_memdup(key, key_len);
-
-    if (key_len < blocksize) {
-    	full_key = g_realloc(full_key, blocksize);
-    	memset(full_key + key_len, 0, blocksize - key_len);
-    }
-
-	for(i = 0; i < blocksize; i++) {
-		ipad[i] = 0x36 ^ full_key[i];
-		hctx->opad[i] = 0x5c ^ full_key[i];
-	}
-
-	g_free(full_key);
-
-	purple_cipher_context_reset(hctx->hash, NULL);
-	purple_cipher_context_append(hctx->hash, ipad, blocksize);
-	g_free(ipad);
-}
-
-static void
-hmac_set_key(PurpleCipherContext *context, const guchar * key)
-{
-	hmac_set_key_with_len(context, key, strlen((char *)key));
-}
-
-static size_t
-hmac_get_block_size(PurpleCipherContext *context)
-{
-	struct HMAC_Context *hctx = purple_cipher_context_get_data(context);
-
-	return hctx->blocksize;
-}
-
-static PurpleCipherOps HMACOps = {
-	hmac_set_opt,           /* Set option */
-	hmac_get_opt,           /* Get option */
-	hmac_init,               /* init */
-	hmac_reset,              /* reset */
-	hmac_uninit,             /* uninit */
-	NULL,                   /* set iv */
-	hmac_append,             /* append */
-	hmac_digest,             /* digest */
-	NULL,                   /* encrypt */
-	NULL,                   /* decrypt */
-	NULL,                   /* set salt */
-	NULL,                   /* get salt size */
-	hmac_set_key,           /* set key */
-	NULL,                   /* get key size */
-	NULL,                   /* set batch mode */
-	NULL,                   /* get batch mode */
-	hmac_get_block_size,    /* get block size */
-	hmac_set_key_with_len   /* set key with len */
-};
-
-/******************************************************************************
- * DES
- *****************************************************************************/
-
-typedef struct _des_ctx
-{
-	guint32 encrypt_subkeys[32];
-	guint32 decrypt_subkeys[32];
-} des_ctx[1];
-
-/*
- *  The s-box values are permuted according to the 'primitive function P'
- */
-static const guint32 sbox1[64] =
-{
-	0x00808200, 0x00000000, 0x00008000, 0x00808202, 0x00808002, 0x00008202, 0x00000002, 0x00008000,
-	0x00000200, 0x00808200, 0x00808202, 0x00000200, 0x00800202, 0x00808002, 0x00800000, 0x00000002,
-	0x00000202, 0x00800200, 0x00800200, 0x00008200, 0x00008200, 0x00808000, 0x00808000, 0x00800202,
-	0x00008002, 0x00800002, 0x00800002, 0x00008002, 0x00000000, 0x00000202, 0x00008202, 0x00800000,
-	0x00008000, 0x00808202, 0x00000002, 0x00808000, 0x00808200, 0x00800000, 0x00800000, 0x00000200,
-	0x00808002, 0x00008000, 0x00008200, 0x00800002, 0x00000200, 0x00000002, 0x00800202, 0x00008202,
-	0x00808202, 0x00008002, 0x00808000, 0x00800202, 0x00800002, 0x00000202, 0x00008202, 0x00808200,
-	0x00000202, 0x00800200, 0x00800200, 0x00000000, 0x00008002, 0x00008200, 0x00000000, 0x00808002
-};
-
-static const guint32 sbox2[64] =
-{
-	0x40084010, 0x40004000, 0x00004000, 0x00084010, 0x00080000, 0x00000010, 0x40080010, 0x40004010,
-	0x40000010, 0x40084010, 0x40084000, 0x40000000, 0x40004000, 0x00080000, 0x00000010, 0x40080010,
-	0x00084000, 0x00080010, 0x40004010, 0x00000000, 0x40000000, 0x00004000, 0x00084010, 0x40080000,
-	0x00080010, 0x40000010, 0x00000000, 0x00084000, 0x00004010, 0x40084000, 0x40080000, 0x00004010,
-	0x00000000, 0x00084010, 0x40080010, 0x00080000, 0x40004010, 0x40080000, 0x40084000, 0x00004000,
-	0x40080000, 0x40004000, 0x00000010, 0x40084010, 0x00084010, 0x00000010, 0x00004000, 0x40000000,
-	0x00004010, 0x40084000, 0x00080000, 0x40000010, 0x00080010, 0x40004010, 0x40000010, 0x00080010,
-	0x00084000, 0x00000000, 0x40004000, 0x00004010, 0x40000000, 0x40080010, 0x40084010, 0x00084000
-};
-
-static const guint32 sbox3[64] =
-{
-	0x00000104, 0x04010100, 0x00000000, 0x04010004, 0x04000100, 0x00000000, 0x00010104, 0x04000100,
-	0x00010004, 0x04000004, 0x04000004, 0x00010000, 0x04010104, 0x00010004, 0x04010000, 0x00000104,
-	0x04000000, 0x00000004, 0x04010100, 0x00000100, 0x00010100, 0x04010000, 0x04010004, 0x00010104,
-	0x04000104, 0x00010100, 0x00010000, 0x04000104, 0x00000004, 0x04010104, 0x00000100, 0x04000000,
-	0x04010100, 0x04000000, 0x00010004, 0x00000104, 0x00010000, 0x04010100, 0x04000100, 0x00000000,
-	0x00000100, 0x00010004, 0x04010104, 0x04000100, 0x04000004, 0x00000100, 0x00000000, 0x04010004,
-	0x04000104, 0x00010000, 0x04000000, 0x04010104, 0x00000004, 0x00010104, 0x00010100, 0x04000004,
-	0x04010000, 0x04000104, 0x00000104, 0x04010000, 0x00010104, 0x00000004, 0x04010004, 0x00010100
-};
-
-static const guint32 sbox4[64] =
-{
-	0x80401000, 0x80001040, 0x80001040, 0x00000040, 0x00401040, 0x80400040, 0x80400000, 0x80001000,
-	0x00000000, 0x00401000, 0x00401000, 0x80401040, 0x80000040, 0x00000000, 0x00400040, 0x80400000,
-	0x80000000, 0x00001000, 0x00400000, 0x80401000, 0x00000040, 0x00400000, 0x80001000, 0x00001040,
-	0x80400040, 0x80000000, 0x00001040, 0x00400040, 0x00001000, 0x00401040, 0x80401040, 0x80000040,
-	0x00400040, 0x80400000, 0x00401000, 0x80401040, 0x80000040, 0x00000000, 0x00000000, 0x00401000,
-	0x00001040, 0x00400040, 0x80400040, 0x80000000, 0x80401000, 0x80001040, 0x80001040, 0x00000040,
-	0x80401040, 0x80000040, 0x80000000, 0x00001000, 0x80400000, 0x80001000, 0x00401040, 0x80400040,
-	0x80001000, 0x00001040, 0x00400000, 0x80401000, 0x00000040, 0x00400000, 0x00001000, 0x00401040
-};
-
-static const guint32 sbox5[64] =
-{
-	0x00000080, 0x01040080, 0x01040000, 0x21000080, 0x00040000, 0x00000080, 0x20000000, 0x01040000,
-	0x20040080, 0x00040000, 0x01000080, 0x20040080, 0x21000080, 0x21040000, 0x00040080, 0x20000000,
-	0x01000000, 0x20040000, 0x20040000, 0x00000000, 0x20000080, 0x21040080, 0x21040080, 0x01000080,
-	0x21040000, 0x20000080, 0x00000000, 0x21000000, 0x01040080, 0x01000000, 0x21000000, 0x00040080,
-	0x00040000, 0x21000080, 0x00000080, 0x01000000, 0x20000000, 0x01040000, 0x21000080, 0x20040080,
-	0x01000080, 0x20000000, 0x21040000, 0x01040080, 0x20040080, 0x00000080, 0x01000000, 0x21040000,
-	0x21040080, 0x00040080, 0x21000000, 0x21040080, 0x01040000, 0x00000000, 0x20040000, 0x21000000,
-	0x00040080, 0x01000080, 0x20000080, 0x00040000, 0x00000000, 0x20040000, 0x01040080, 0x20000080
-};
-
-static const guint32 sbox6[64] =
-{
-	0x10000008, 0x10200000, 0x00002000, 0x10202008, 0x10200000, 0x00000008, 0x10202008, 0x00200000,
-	0x10002000, 0x00202008, 0x00200000, 0x10000008, 0x00200008, 0x10002000, 0x10000000, 0x00002008,
-	0x00000000, 0x00200008, 0x10002008, 0x00002000, 0x00202000, 0x10002008, 0x00000008, 0x10200008,
-	0x10200008, 0x00000000, 0x00202008, 0x10202000, 0x00002008, 0x00202000, 0x10202000, 0x10000000,
-	0x10002000, 0x00000008, 0x10200008, 0x00202000, 0x10202008, 0x00200000, 0x00002008, 0x10000008,
-	0x00200000, 0x10002000, 0x10000000, 0x00002008, 0x10000008, 0x10202008, 0x00202000, 0x10200000,
-	0x00202008, 0x10202000, 0x00000000, 0x10200008, 0x00000008, 0x00002000, 0x10200000, 0x00202008,
-	0x00002000, 0x00200008, 0x10002008, 0x00000000, 0x10202000, 0x10000000, 0x00200008, 0x10002008
-};
-
-static const guint32 sbox7[64] =
-{
-	0x00100000, 0x02100001, 0x02000401, 0x00000000, 0x00000400, 0x02000401, 0x00100401, 0x02100400,
-	0x02100401, 0x00100000, 0x00000000, 0x02000001, 0x00000001, 0x02000000, 0x02100001, 0x00000401,
-	0x02000400, 0x00100401, 0x00100001, 0x02000400, 0x02000001, 0x02100000, 0x02100400, 0x00100001,
-	0x02100000, 0x00000400, 0x00000401, 0x02100401, 0x00100400, 0x00000001, 0x02000000, 0x00100400,
-	0x02000000, 0x00100400, 0x00100000, 0x02000401, 0x02000401, 0x02100001, 0x02100001, 0x00000001,
-	0x00100001, 0x02000000, 0x02000400, 0x00100000, 0x02100400, 0x00000401, 0x00100401, 0x02100400,
-	0x00000401, 0x02000001, 0x02100401, 0x02100000, 0x00100400, 0x00000000, 0x00000001, 0x02100401,
-	0x00000000, 0x00100401, 0x02100000, 0x00000400, 0x02000001, 0x02000400, 0x00000400, 0x00100001
-};
-
-static const guint32 sbox8[64] =
-{
-	0x08000820, 0x00000800, 0x00020000, 0x08020820, 0x08000000, 0x08000820, 0x00000020, 0x08000000,
-	0x00020020, 0x08020000, 0x08020820, 0x00020800, 0x08020800, 0x00020820, 0x00000800, 0x00000020,
-	0x08020000, 0x08000020, 0x08000800, 0x00000820, 0x00020800, 0x00020020, 0x08020020, 0x08020800,
-	0x00000820, 0x00000000, 0x00000000, 0x08020020, 0x08000020, 0x08000800, 0x00020820, 0x00020000,
-	0x00020820, 0x00020000, 0x08020800, 0x00000800, 0x00000020, 0x08020020, 0x00000800, 0x00020820,
-	0x08000800, 0x00000020, 0x08000020, 0x08020000, 0x08020020, 0x08000000, 0x00020000, 0x08000820,
-	0x00000000, 0x08020820, 0x00020020, 0x08000020, 0x08020000, 0x08000800, 0x08000820, 0x00000000,
-	0x08020820, 0x00020800, 0x00020800, 0x00000820, 0x00000820, 0x00020020, 0x08000000, 0x08020800
-};
-
-
-
-/*
- *  * These two tables are part of the 'permuted choice 1' function.
- *   * In this implementation several speed improvements are done.
- *    */
-static const guint32 leftkey_swap[16] =
-{
-	0x00000000, 0x00000001, 0x00000100, 0x00000101,
-	0x00010000, 0x00010001, 0x00010100, 0x00010101,
-	0x01000000, 0x01000001, 0x01000100, 0x01000101,
-	0x01010000, 0x01010001, 0x01010100, 0x01010101
-};
-
-static const guint32 rightkey_swap[16] =
-{
-	0x00000000, 0x01000000, 0x00010000, 0x01010000,
-	0x00000100, 0x01000100, 0x00010100, 0x01010100,
-	0x00000001, 0x01000001, 0x00010001, 0x01010001,
-	0x00000101, 0x01000101, 0x00010101, 0x01010101,
-};
-
-
-
-/*
- *  Numbers of left shifts per round for encryption subkey schedule
- *  To calculate the decryption key scheduling we just reverse the
- *  ordering of the subkeys so we can omit the table for decryption
- *  subkey schedule.
- */
-static const guint8 encrypt_rotate_tab[16] =
-{
-	1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1
-};
-
-/*
- *  Macro to swap bits across two words
- **/
-#define DO_PERMUTATION(a, temp, b, offset, mask)	\
-	temp = ((a>>offset) ^ b) & mask;			\
-b ^= temp;						\
-a ^= temp<<offset;
-
-
-/*
- *  This performs the 'initial permutation' for the data to be encrypted or decrypted
- **/
-#define INITIAL_PERMUTATION(left, temp, right)		\
-	DO_PERMUTATION(left, temp, right, 4, 0x0f0f0f0f)	\
-DO_PERMUTATION(left, temp, right, 16, 0x0000ffff)	\
-DO_PERMUTATION(right, temp, left, 2, 0x33333333)	\
-DO_PERMUTATION(right, temp, left, 8, 0x00ff00ff)	\
-DO_PERMUTATION(left, temp, right, 1, 0x55555555)
-
-
-/*
- * The 'inverse initial permutation'
- **/
-#define FINAL_PERMUTATION(left, temp, right)		\
-	DO_PERMUTATION(left, temp, right, 1, 0x55555555)	\
-DO_PERMUTATION(right, temp, left, 8, 0x00ff00ff)	\
-DO_PERMUTATION(right, temp, left, 2, 0x33333333)	\
-DO_PERMUTATION(left, temp, right, 16, 0x0000ffff)	\
-DO_PERMUTATION(left, temp, right, 4, 0x0f0f0f0f)
-
-
-/*
- * A full DES round including 'expansion function', 'sbox substitution'
- * and 'primitive function P' but without swapping the left and right word.
- **/
-#define DES_ROUND(from, to, work, subkey)		\
-	work = ((from<<1) | (from>>31)) ^ *subkey++;	\
-to ^= sbox8[  work	    & 0x3f ];			\
-to ^= sbox6[ (work>>8)  & 0x3f ];			\
-to ^= sbox4[ (work>>16) & 0x3f ];			\
-to ^= sbox2[ (work>>24) & 0x3f ];			\
-work = ((from>>3) | (from<<29)) ^ *subkey++;	\
-to ^= sbox7[  work	    & 0x3f ];			\
-to ^= sbox5[ (work>>8)  & 0x3f ];			\
-to ^= sbox3[ (work>>16) & 0x3f ];			\
-to ^= sbox1[ (work>>24) & 0x3f ];
-
-
-/*
- * Macros to convert 8 bytes from/to 32bit words
- **/
-#define READ_64BIT_DATA(data, left, right)					\
-	left  = (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3];	\
-right = (data[4] << 24) | (data[5] << 16) | (data[6] << 8) | data[7];
-
-#define WRITE_64BIT_DATA(data, left, right)					\
-	data[0] = (left >> 24) &0xff; data[1] = (left >> 16) &0xff; 		\
-data[2] = (left >> 8) &0xff; data[3] = left &0xff;				\
-data[4] = (right >> 24) &0xff; data[5] = (right >> 16) &0xff;		\
-data[6] = (right >> 8) &0xff; data[7] = right &0xff;
-
-
-
-
-
-
-/*
- * des_key_schedule():	  Calculate 16 subkeys pairs (even/odd) for
- *			  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)
-{
-	guint32 left, right, work;
-	int round;
-
-	READ_64BIT_DATA (rawkey, left, right)
-
-		DO_PERMUTATION (right, work, left, 4, 0x0f0f0f0f)
-		DO_PERMUTATION (right, work, left, 0, 0x10101010)
-
-		left = (leftkey_swap[(left >> 0) & 0xf] << 3) | (leftkey_swap[(left >> 8) & 0xf] << 2)
-		| (leftkey_swap[(left >> 16) & 0xf] << 1) | (leftkey_swap[(left >> 24) & 0xf])
-		| (leftkey_swap[(left >> 5) & 0xf] << 7) | (leftkey_swap[(left >> 13) & 0xf] << 6)
-		| (leftkey_swap[(left >> 21) & 0xf] << 5) | (leftkey_swap[(left >> 29) & 0xf] << 4);
-
-	left &= 0x0fffffff;
-
-	right = (rightkey_swap[(right >> 1) & 0xf] << 3) | (rightkey_swap[(right >> 9) & 0xf] << 2)
-		| (rightkey_swap[(right >> 17) & 0xf] << 1) | (rightkey_swap[(right >> 25) & 0xf])
-		| (rightkey_swap[(right >> 4) & 0xf] << 7) | (rightkey_swap[(right >> 12) & 0xf] << 6)
-		| (rightkey_swap[(right >> 20) & 0xf] << 5) | (rightkey_swap[(right >> 28) & 0xf] << 4);
-
-	right &= 0x0fffffff;
-
-	for (round = 0; round < 16; ++round)
-	{
-		left = ((left << encrypt_rotate_tab[round]) | (left >> (28 - encrypt_rotate_tab[round]))) & 0x0fffffff;
-		right = ((right << encrypt_rotate_tab[round]) | (right >> (28 - encrypt_rotate_tab[round]))) & 0x0fffffff;
-
-		*subkey++ = ((left << 4) & 0x24000000)
-			| ((left << 28) & 0x10000000)
-			| ((left << 14) & 0x08000000)
-			| ((left << 18) & 0x02080000)
-			| ((left << 6) & 0x01000000)
-			| ((left << 9) & 0x00200000)
-			| ((left >> 1) & 0x00100000)
-			| ((left << 10) & 0x00040000)
-			| ((left << 2) & 0x00020000)
-			| ((left >> 10) & 0x00010000)
-			| ((right >> 13) & 0x00002000)
-			| ((right >> 4) & 0x00001000)
-			| ((right << 6) & 0x00000800)
-			| ((right >> 1) & 0x00000400)
-			| ((right >> 14) & 0x00000200)
-			| (right & 0x00000100)
-			| ((right >> 5) & 0x00000020)
-			| ((right >> 10) & 0x00000010)
-			| ((right >> 3) & 0x00000008)
-			| ((right >> 18) & 0x00000004)
-			| ((right >> 26) & 0x00000002)
-			| ((right >> 24) & 0x00000001);
-
-		*subkey++ = ((left << 15) & 0x20000000)
-			| ((left << 17) & 0x10000000)
-			| ((left << 10) & 0x08000000)
-			| ((left << 22) & 0x04000000)
-			| ((left >> 2) & 0x02000000)
-			| ((left << 1) & 0x01000000)
-			| ((left << 16) & 0x00200000)
-			| ((left << 11) & 0x00100000)
-			| ((left << 3) & 0x00080000)
-			| ((left >> 6) & 0x00040000)
-			| ((left << 15) & 0x00020000)
-			| ((left >> 4) & 0x00010000)
-			| ((right >> 2) & 0x00002000)
-			| ((right << 8) & 0x00001000)
-			| ((right >> 14) & 0x00000808)
-			| ((right >> 9) & 0x00000400)
-			| ((right) & 0x00000200)
-			| ((right << 7) & 0x00000100)
-			| ((right >> 7) & 0x00000020)
-			| ((right >> 3) & 0x00000011)
-			| ((right << 2) & 0x00000004)
-			| ((right >> 21) & 0x00000002);
-	}
-}
-
-
-
-/*
- *  Fill a DES context with subkeys calculated from a 64bit key.
- *  Does not check parity bits, but simply ignore them.
- *  Does not check for weak keys.
- **/
-static void
-des_set_key (PurpleCipherContext *context, const guchar * key)
-{
-	struct _des_ctx *ctx = purple_cipher_context_get_data(context);
-	int i;
-
-	des_key_schedule (key, ctx->encrypt_subkeys);
-
-	for(i=0; i<32; i+=2)
-	{
-		ctx->decrypt_subkeys[i]	= ctx->encrypt_subkeys[30-i];
-		ctx->decrypt_subkeys[i+1] = ctx->encrypt_subkeys[31-i];
-	}
-}
-
-
-
-/*
- *  Electronic Codebook Mode DES encryption/decryption of data according
- *  to 'mode'.
- **/
-static int
-des_ecb_crypt (struct _des_ctx *ctx, const guint8 * from, guint8 * to, int mode)
-{
-	guint32 left, right, work;
-	guint32 *keys;
-
-	keys = mode ? ctx->decrypt_subkeys : ctx->encrypt_subkeys;
-
-	READ_64BIT_DATA (from, left, right)
-		INITIAL_PERMUTATION (left, work, right)
-
-		DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
-		DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
-		DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
-		DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
-		DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
-		DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
-		DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
-		DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
-
-		FINAL_PERMUTATION (right, work, left)
-		WRITE_64BIT_DATA (to, right, left)
-
-		return 0;
-}
-
-static gint
-des_encrypt(PurpleCipherContext *context, const guchar data[],
-	    size_t len, guchar output[], size_t *outlen) {
-	int offset = 0;
-	int i = 0;
-	int tmp;
-	guint8 buf[8] = {0,0,0,0,0,0,0,0};
-	while(offset+8<=len) {
-		des_ecb_crypt(purple_cipher_context_get_data(context),
-				data+offset,
-				output+offset,
-				0);
-		offset+=8;
-	}
-	*outlen = len;
-	if(offset<len) {
-		*outlen += len - offset;
-		tmp = offset;
-		while(tmp<len) {
-			buf[i++] = data[tmp];
-			tmp++;
-		}
-		des_ecb_crypt(purple_cipher_context_get_data(context),
-				buf,
-				output+offset,
-				0);
-	}
-	return 0;
-}
-
-static gint
-des_decrypt(PurpleCipherContext *context, const guchar data[],
-	    size_t len, guchar output[], size_t *outlen) {
-	int offset = 0;
-	int i = 0;
-	int tmp;
-	guint8 buf[8] = {0,0,0,0,0,0,0,0};
-	while(offset+8<=len) {
-		des_ecb_crypt(purple_cipher_context_get_data(context),
-				data+offset,
-				output+offset,
-				1);
-		offset+=8;
-	}
-	*outlen = len;
-	if(offset<len) {
-		*outlen += len - offset;
-		tmp = offset;
-		while(tmp<len) {
-			buf[i++] = data[tmp];
-			tmp++;
-		}
-		des_ecb_crypt(purple_cipher_context_get_data(context),
-				buf,
-				output+offset,
-				1);
-	}
-	return 0;
-}
-
-static void
-des_init(PurpleCipherContext *context, gpointer extra) {
-	struct _des_ctx *mctx;
-	mctx = g_new0(struct _des_ctx, 1);
-	purple_cipher_context_set_data(context, mctx);
-}
-
-static void
-des_uninit(PurpleCipherContext *context) {
-	struct _des_ctx *des_context;
-
-	des_context = purple_cipher_context_get_data(context);
-	memset(des_context, 0, sizeof(des_context));
-
-	g_free(des_context);
-	des_context = NULL;
-}
-
-static PurpleCipherOps DESOps = {
-	NULL,              /* Set option */
-	NULL,              /* Get option */
-	des_init,          /* init */
- 	NULL,              /* reset */
-	des_uninit,        /* uninit */
-	NULL,              /* set iv */
-	NULL,              /* append */
-	NULL,              /* digest */
-	des_encrypt,       /* encrypt */
-	des_decrypt,       /* decrypt */
-	NULL,              /* set salt */
-	NULL,              /* get salt size */
-	des_set_key,       /* set key */
-	NULL,              /* get key size */
-	NULL,              /* set batch mode */
-	NULL,              /* get batch mode */
-	NULL,              /* get block size */
-	NULL               /* set key with len */
-};
-
-/******************************************************************************
- * Triple-DES
- *****************************************************************************/
-
-typedef struct _des3_ctx
-{
-	PurpleCipherBatchMode mode;
-	guchar iv[8];
-	/* First key for encryption */
-	struct _des_ctx key1;
-	/* Second key for decryption */
-	struct _des_ctx key2;
-	/* Third key for encryption */
-	struct _des_ctx key3;
-} des3_ctx[1];
-
-/*
- *  Fill a DES3 context with subkeys calculated from 3 64bit key.
- *  Does not check parity bits, but simply ignore them.
- *  Does not check for weak keys.
- **/
-static void
-des3_set_key(PurpleCipherContext *context, const guchar * key)
-{
-	struct _des3_ctx *ctx = purple_cipher_context_get_data(context);
-	int i;
-
-	des_key_schedule (key +  0, ctx->key1.encrypt_subkeys);
-	des_key_schedule (key +  8, ctx->key2.encrypt_subkeys);
-	des_key_schedule (key + 16, ctx->key3.encrypt_subkeys);
-
-	for (i = 0; i < 32; i += 2)
-	{
-		ctx->key1.decrypt_subkeys[i]	= ctx->key1.encrypt_subkeys[30-i];
-		ctx->key1.decrypt_subkeys[i+1]	= ctx->key1.encrypt_subkeys[31-i];
-		ctx->key2.decrypt_subkeys[i]	= ctx->key2.encrypt_subkeys[30-i];
-		ctx->key2.decrypt_subkeys[i+1]	= ctx->key2.encrypt_subkeys[31-i];
-		ctx->key3.decrypt_subkeys[i]	= ctx->key3.encrypt_subkeys[30-i];
-		ctx->key3.decrypt_subkeys[i+1]	= ctx->key3.encrypt_subkeys[31-i];
-	}
-}
-
-static gint
-des3_ecb_encrypt(struct _des3_ctx *ctx, const guchar data[],
-                 size_t len, guchar output[], size_t *outlen)
-{
-	int offset = 0;
-	int i = 0;
-	int tmp;
-	guint8 buf[8] = {0,0,0,0,0,0,0,0};
-	while (offset + 8 <= len) {
-		des_ecb_crypt(&ctx->key1,
-		              data+offset,
-		              output+offset,
-		              0);
-		des_ecb_crypt(&ctx->key2,
-		              output+offset,
-		              buf,
-		              1);
-		des_ecb_crypt(&ctx->key3,
-		              buf,
-		              output+offset,
-		              0);
-		offset += 8;
-	}
-	*outlen = len;
-	if (offset < len) {
-		*outlen += len - offset;
-		tmp = offset;
-		memset(buf, 0, 8);
-		while (tmp < len) {
-			buf[i++] = data[tmp];
-			tmp++;
-		}
-		des_ecb_crypt(&ctx->key1,
-		              buf,
-		              output+offset,
-		              0);
-		des_ecb_crypt(&ctx->key2,
-		              output+offset,
-		              buf,
-		              1);
-		des_ecb_crypt(&ctx->key3,
-		              buf,
-		              output+offset,
-		              0);
-	}
-	return 0;
-}
-
-static gint
-des3_cbc_encrypt(struct _des3_ctx *ctx, const guchar data[],
-                 size_t len, guchar output[], size_t *outlen)
-{
-	int offset = 0;
-	int i = 0;
-	int tmp;
-	guint8 buf[8];
-	memcpy(buf, ctx->iv, 8);
-	while (offset + 8 <= len) {
-		for (i = 0; i < 8; i++)
-			buf[i] ^= data[offset + i];
-		des_ecb_crypt(&ctx->key1,
-		              buf,
-		              output+offset,
-		              0);
-		des_ecb_crypt(&ctx->key2,
-		              output+offset,
-		              buf,
-		              1);
-		des_ecb_crypt(&ctx->key3,
-		              buf,
-		              output+offset,
-		              0);
-		memcpy(buf, output+offset, 8);
-		offset += 8;
-	}
-	*outlen = len;
-	if (offset < len) {
-		*outlen += len - offset;
-		tmp = offset;
-		i = 0;
-		while (tmp < len) {
-			buf[i++] ^= data[tmp];
-			tmp++;
-		}
-		des_ecb_crypt(&ctx->key1,
-		              buf,
-		              output+offset,
-		              0);
-		des_ecb_crypt(&ctx->key2,
-		              output+offset,
-		              buf,
-		              1);
-		des_ecb_crypt(&ctx->key3,
-		              buf,
-		              output+offset,
-		              0);
-	}
-	return 0;
-}
-
-static gint
-des3_encrypt(PurpleCipherContext *context, const guchar data[],
-             size_t len, guchar output[], size_t *outlen)
-{
-	struct _des3_ctx *ctx = purple_cipher_context_get_data(context);
-
-	if (ctx->mode == PURPLE_CIPHER_BATCH_MODE_ECB) {
-		return des3_ecb_encrypt(ctx, data, len, output, outlen);
-	} else if (ctx->mode == PURPLE_CIPHER_BATCH_MODE_CBC) {
-		return des3_cbc_encrypt(ctx, data, len, output, outlen);
-	} else {
-		g_return_val_if_reached(0);
-	}
-
-	return 0;
-}
-
-static gint
-des3_ecb_decrypt(struct _des3_ctx *ctx, const guchar data[],
-                 size_t len, guchar output[], size_t *outlen)
-{
-	int offset = 0;
-	int i = 0;
-	int tmp;
-	guint8 buf[8] = {0,0,0,0,0,0,0,0};
-	while (offset + 8 <= len) {
-		/* NOTE: Apply key in reverse */
-		des_ecb_crypt(&ctx->key3,
-		              data+offset,
-		              output+offset,
-		              1);
-		des_ecb_crypt(&ctx->key2,
-		              output+offset,
-		              buf,
-		              0);
-		des_ecb_crypt(&ctx->key1,
-		              buf,
-		              output+offset,
-		              1);
-		offset+=8;
-	}
-	*outlen = len;
-	if (offset < len) {
-		*outlen += len - offset;
-		tmp = offset;
-		memset(buf, 0, 8);
-		while (tmp < len) {
-			buf[i++] = data[tmp];
-			tmp++;
-		}
-		des_ecb_crypt(&ctx->key3,
-		              buf,
-		              output+offset,
-		              1);
-		des_ecb_crypt(&ctx->key2,
-		              output+offset,
-		              buf,
-		              0);
-		des_ecb_crypt(&ctx->key1,
-		              buf,
-		              output+offset,
-		              1);
-	}
-	return 0;
-}
-
-static gint
-des3_cbc_decrypt(struct _des3_ctx *ctx, const guchar data[],
-                 size_t len, guchar output[], size_t *outlen)
-{
-	int offset = 0;
-	int i = 0;
-	int tmp;
-	guint8 buf[8] = {0,0,0,0,0,0,0,0};
-	guint8 link[8];
-	memcpy(link, ctx->iv, 8);
-	while (offset + 8 <= len) {
-		des_ecb_crypt(&ctx->key3,
-		              data+offset,
-		              output+offset,
-		              1);
-		des_ecb_crypt(&ctx->key2,
-		              output+offset,
-		              buf,
-		              0);
-		des_ecb_crypt(&ctx->key1,
-		              buf,
-		              output+offset,
-		              1);
-		for (i = 0; i < 8; i++)
-			output[offset + i] ^= link[i];
-		memcpy(link, data + offset, 8);
-		offset+=8;
-	}
-	*outlen = len;
-	if(offset<len) {
-		*outlen += len - offset;
-		tmp = offset;
-		memset(buf, 0, 8);
-		i = 0;
-		while(tmp<len) {
-			buf[i++] = data[tmp];
-			tmp++;
-		}
-		des_ecb_crypt(&ctx->key3,
-		              buf,
-		              output+offset,
-		              1);
-		des_ecb_crypt(&ctx->key2,
-		              output+offset,
-		              buf,
-		              0);
-		des_ecb_crypt(&ctx->key1,
-		              buf,
-		              output+offset,
-		              1);
-		for (i = 0; i < 8; i++)
-			output[offset + i] ^= link[i];
-	}
-	return 0;
-}
-
-static gint
-des3_decrypt(PurpleCipherContext *context, const guchar data[],
-             size_t len, guchar output[], size_t *outlen)
-{
-	struct _des3_ctx *ctx = purple_cipher_context_get_data(context);
-
-	if (ctx->mode == PURPLE_CIPHER_BATCH_MODE_ECB) {
-		return des3_ecb_decrypt(ctx, data, len, output, outlen);
-	} else if (ctx->mode == PURPLE_CIPHER_BATCH_MODE_CBC) {
-		return des3_cbc_decrypt(ctx, data, len, output, outlen);
-	} else {
-		g_return_val_if_reached(0);
-	}
-
-	return 0;
-}
-
-static void
-des3_set_batch(PurpleCipherContext *context, PurpleCipherBatchMode mode)
-{
-	struct _des3_ctx *ctx = purple_cipher_context_get_data(context);
-
-	ctx->mode = mode;
-}
-
-static PurpleCipherBatchMode
-des3_get_batch(PurpleCipherContext *context)
-{
-	struct _des3_ctx *ctx = purple_cipher_context_get_data(context);
-
-	return ctx->mode;
-}
-
-static void
-des3_set_iv(PurpleCipherContext *context, guchar *iv, size_t len)
-{
-	struct _des3_ctx *ctx;
-
-	g_return_if_fail(len == 8);
-
-	ctx = purple_cipher_context_get_data(context);
-
-	memcpy(ctx->iv, iv, len);
-}
-
-static void
-des3_init(PurpleCipherContext *context, gpointer extra)
-{
-	struct _des3_ctx *mctx;
-	mctx = g_new0(struct _des3_ctx, 1);
-	purple_cipher_context_set_data(context, mctx);
-}
-
-static void
-des3_uninit(PurpleCipherContext *context)
-{
-	struct _des3_ctx *des3_context;
-
-	des3_context = purple_cipher_context_get_data(context);
-	memset(des3_context, 0, sizeof(des3_context));
-
-	g_free(des3_context);
-	des3_context = NULL;
-}
-
-static PurpleCipherOps DES3Ops = {
-	NULL,              /* Set option */
-	NULL,              /* Get option */
-	des3_init,         /* init */
-	NULL,              /* reset */
-	des3_uninit,       /* uninit */
-	des3_set_iv,       /* set iv */
-	NULL,              /* append */
-	NULL,              /* digest */
-	des3_encrypt,      /* encrypt */
-	des3_decrypt,      /* decrypt */
-	NULL,              /* set salt */
-	NULL,              /* get salt size */
-	des3_set_key,      /* set key */
-	NULL,              /* get key size */
-	des3_set_batch,    /* set batch mode */
-	des3_get_batch,    /* get batch mode */
-	NULL,              /* get block size */
-	NULL               /* set key with len */
-};
-
-/*******************************************************************************
- * SHA-1
- ******************************************************************************/
-#define SHA1_HMAC_BLOCK_SIZE	64
-
-static size_t
-sha1_get_block_size(PurpleCipherContext *context)
-{
-	/* This does not change (in this case) */
-	return SHA1_HMAC_BLOCK_SIZE;
-}
-
-
-#if GLIB_CHECK_VERSION(2,16,0)
-
-static void
-sha1_init(PurpleCipherContext *context, void *extra)
-{
-	purple_g_checksum_init(context, G_CHECKSUM_SHA1);
-}
-
-static void
-sha1_reset(PurpleCipherContext *context, void *extra)
-{
-	purple_g_checksum_reset(context, G_CHECKSUM_SHA1);
-}
-
-static gboolean
-sha1_digest(PurpleCipherContext *context, gsize in_len, guchar digest[20],
-            gsize *out_len)
-{
-	return purple_g_checksum_digest(context, G_CHECKSUM_SHA1, in_len,
-	                                digest, out_len);
-}
-
-static PurpleCipherOps SHA1Ops = {
-	NULL,			/* Set Option		*/
-	NULL,			/* Get Option		*/
-	sha1_init,		/* init				*/
-	sha1_reset,		/* reset			*/
-	purple_g_checksum_uninit,	/* uninit			*/
-	NULL,			/* set iv			*/
-	purple_g_checksum_append,	/* append			*/
-	sha1_digest,	/* digest			*/
-	NULL,			/* encrypt			*/
-	NULL,			/* decrypt			*/
-	NULL,			/* set salt			*/
-	NULL,			/* get salt size	*/
-	NULL,			/* set key			*/
-	NULL,			/* get key size		*/
-	NULL,			/* set batch mode */
-	NULL,			/* get batch mode */
-	sha1_get_block_size,	/* get block size */
-	NULL			/* set key with len */
-};
-
-#else /* GLIB_CHECK_VERSION(2,16,0) */
-
-#define SHA1_HMAC_BLOCK_SIZE	64
-#define SHA1_ROTL(X,n) ((((X) << (n)) | ((X) >> (32-(n)))) & 0xFFFFFFFF)
-
-struct SHA1Context {
-	guint32 H[5];
-	guint32 W[80];
-
-	gint lenW;
-
-	guint32 sizeHi;
-	guint32 sizeLo;
-};
-
-static void
-sha1_hash_block(struct SHA1Context *sha1_ctx) {
-	gint i;
-	guint32 A, B, C, D, E, T;
-
-	for(i = 16; i < 80; i++) {
-		sha1_ctx->W[i] = SHA1_ROTL(sha1_ctx->W[i -  3] ^
-								   sha1_ctx->W[i -  8] ^
-								   sha1_ctx->W[i - 14] ^
-								   sha1_ctx->W[i - 16], 1);
-	}
-
-	A = sha1_ctx->H[0];
-	B = sha1_ctx->H[1];
-	C = sha1_ctx->H[2];
-	D = sha1_ctx->H[3];
-	E = sha1_ctx->H[4];
-
-	for(i = 0; i < 20; i++) {
-		T = (SHA1_ROTL(A, 5) + (((C ^ D) & B) ^ D) + E + sha1_ctx->W[i] + 0x5A827999) & 0xFFFFFFFF;
-		E = D;
-		D = C;
-		C = SHA1_ROTL(B, 30);
-		B = A;
-		A = T;
-	}
-
-	for(i = 20; i < 40; i++) {
-		T = (SHA1_ROTL(A, 5) + (B ^ C ^ D) + E + sha1_ctx->W[i] + 0x6ED9EBA1) & 0xFFFFFFFF;
-		E = D;
-		D = C;
-		C = SHA1_ROTL(B, 30);
-		B = A;
-		A = T;
-	}
-
-	for(i = 40; i < 60; i++) {
-		T = (SHA1_ROTL(A, 5) + ((B & C) | (D & (B | C))) + E + sha1_ctx->W[i] + 0x8F1BBCDC) & 0xFFFFFFFF;
-		E = D;
-		D = C;
-		C = SHA1_ROTL(B, 30);
-		B = A;
-		A = T;
-	}
-
-	for(i = 60; i < 80; i++) {
-		T = (SHA1_ROTL(A, 5) + (B ^ C ^ D) + E + sha1_ctx->W[i] + 0xCA62C1D6) & 0xFFFFFFFF;
-		E = D;
-		D = C;
-		C = SHA1_ROTL(B, 30);
-		B = A;
-		A = T;
-	}
-
-	sha1_ctx->H[0] += A;
-	sha1_ctx->H[1] += B;
-	sha1_ctx->H[2] += C;
-	sha1_ctx->H[3] += D;
-	sha1_ctx->H[4] += E;
-}
-
-static void
-sha1_set_opt(PurpleCipherContext *context, const gchar *name, void *value) {
-	struct SHA1Context *ctx;
-
-	ctx = purple_cipher_context_get_data(context);
-
-	if(purple_strequal(name, "sizeHi")) {
-		ctx->sizeHi = GPOINTER_TO_INT(value);
-	} else if(purple_strequal(name, "sizeLo")) {
-		ctx->sizeLo = GPOINTER_TO_INT(value);
-	} else if(purple_strequal(name, "lenW")) {
-		ctx->lenW = GPOINTER_TO_INT(value);
-	}
-}
-
-static void *
-sha1_get_opt(PurpleCipherContext *context, const gchar *name) {
-	struct SHA1Context *ctx;
-
-	ctx = purple_cipher_context_get_data(context);
-
-	if(purple_strequal(name, "sizeHi")) {
-		return GINT_TO_POINTER(ctx->sizeHi);
-	} else if(purple_strequal(name, "sizeLo")) {
-		return GINT_TO_POINTER(ctx->sizeLo);
-	} else if(purple_strequal(name, "lenW")) {
-		return GINT_TO_POINTER(ctx->lenW);
-	}
-
-	return NULL;
-}
-
-static void
-sha1_init(PurpleCipherContext *context, void *extra) {
-	struct SHA1Context *sha1_ctx;
-
-	sha1_ctx = g_new0(struct SHA1Context, 1);
-
-	purple_cipher_context_set_data(context, sha1_ctx);
-
-	purple_cipher_context_reset(context, extra);
-}
-
-static void
-sha1_reset(PurpleCipherContext *context, void *extra) {
-	struct SHA1Context *sha1_ctx;
-	gint i;
-
-	sha1_ctx = purple_cipher_context_get_data(context);
-
-	g_return_if_fail(sha1_ctx);
-
-	sha1_ctx->lenW = 0;
-	sha1_ctx->sizeHi = 0;
-	sha1_ctx->sizeLo = 0;
-
-	sha1_ctx->H[0] = 0x67452301;
-	sha1_ctx->H[1] = 0xEFCDAB89;
-	sha1_ctx->H[2] = 0x98BADCFE;
-	sha1_ctx->H[3] = 0x10325476;
-	sha1_ctx->H[4] = 0xC3D2E1F0;
-
-	for(i = 0; i < 80; i++)
-		sha1_ctx->W[i] = 0;
-}
-
-static void
-sha1_uninit(PurpleCipherContext *context) {
-	struct SHA1Context *sha1_ctx;
-
-	purple_cipher_context_reset(context, NULL);
-
-	sha1_ctx = purple_cipher_context_get_data(context);
-
-	memset(sha1_ctx, 0, sizeof(struct SHA1Context));
-
-	g_free(sha1_ctx);
-	sha1_ctx = NULL;
-}
-
-
-static void
-sha1_append(PurpleCipherContext *context, const guchar *data, size_t len) {
-	struct SHA1Context *sha1_ctx;
-	gint i;
-
-	sha1_ctx = purple_cipher_context_get_data(context);
-
-	g_return_if_fail(sha1_ctx);
-
-	for(i = 0; i < len; i++) {
-		sha1_ctx->W[sha1_ctx->lenW / 4] <<= 8;
-		sha1_ctx->W[sha1_ctx->lenW / 4] |= data[i];
-
-		if((++sha1_ctx->lenW) % 64 == 0) {
-			sha1_hash_block(sha1_ctx);
-			sha1_ctx->lenW = 0;
-		}
-
-		sha1_ctx->sizeLo += 8;
-		sha1_ctx->sizeHi += (sha1_ctx->sizeLo < 8);
-	}
-}
-
-static gboolean
-sha1_digest(PurpleCipherContext *context, size_t in_len, guchar digest[20],
-			size_t *out_len)
-{
-	struct SHA1Context *sha1_ctx;
-	guchar pad0x80 = 0x80, pad0x00 = 0x00;
-	guchar padlen[8];
-	gint i;
-
-	g_return_val_if_fail(in_len >= 20, FALSE);
-
-	sha1_ctx = purple_cipher_context_get_data(context);
-
-	g_return_val_if_fail(sha1_ctx, FALSE);
-
-	padlen[0] = (guchar)((sha1_ctx->sizeHi >> 24) & 255);
-	padlen[1] = (guchar)((sha1_ctx->sizeHi >> 16) & 255);
-	padlen[2] = (guchar)((sha1_ctx->sizeHi >> 8) & 255);
-	padlen[3] = (guchar)((sha1_ctx->sizeHi >> 0) & 255);
-	padlen[4] = (guchar)((sha1_ctx->sizeLo >> 24) & 255);
-	padlen[5] = (guchar)((sha1_ctx->sizeLo >> 16) & 255);
-	padlen[6] = (guchar)((sha1_ctx->sizeLo >> 8) & 255);
-	padlen[7] = (guchar)((sha1_ctx->sizeLo >> 0) & 255);
-
-	/* pad with a 1, then zeroes, then length */
-	purple_cipher_context_append(context, &pad0x80, 1);
-	while(sha1_ctx->lenW != 56)
-		purple_cipher_context_append(context, &pad0x00, 1);
-	purple_cipher_context_append(context, padlen, 8);
-
-	for(i = 0; i < 20; i++) {
-		digest[i] = (guchar)(sha1_ctx->H[i / 4] >> 24);
-		sha1_ctx->H[i / 4] <<= 8;
-	}
-
-	purple_cipher_context_reset(context, NULL);
-
-	if(out_len)
-		*out_len = 20;
-
-	return TRUE;
-}
-
-static PurpleCipherOps SHA1Ops = {
-	sha1_set_opt,	/* Set Option		*/
-	sha1_get_opt,	/* Get Option		*/
-	sha1_init,		/* init				*/
-	sha1_reset,		/* reset			*/
-	sha1_uninit,	/* uninit			*/
-	NULL,			/* set iv			*/
-	sha1_append,	/* append			*/
-	sha1_digest,	/* digest			*/
-	NULL,			/* encrypt			*/
-	NULL,			/* decrypt			*/
-	NULL,			/* set salt			*/
-	NULL,			/* get salt size	*/
-	NULL,			/* set key			*/
-	NULL,			/* get key size		*/
-	NULL,			/* set batch mode */
-	NULL,			/* get batch mode */
-	sha1_get_block_size,	/* get block size */
-	NULL			/* set key with len */
-};
-
-#endif /* GLIB_CHECK_VERSION(2,16,0) */
-
-/*******************************************************************************
- * SHA-256
- ******************************************************************************/
-#define SHA256_HMAC_BLOCK_SIZE	64
-
-static size_t
-sha256_get_block_size(PurpleCipherContext *context)
-{
-	/* This does not change (in this case) */
-	return SHA256_HMAC_BLOCK_SIZE;
-}
-
-#if GLIB_CHECK_VERSION(2,16,0)
-
-static void
-sha256_init(PurpleCipherContext *context, void *extra)
-{
-	purple_g_checksum_init(context, G_CHECKSUM_SHA256);
-}
-
-static void
-sha256_reset(PurpleCipherContext *context, void *extra)
-{
-	purple_g_checksum_reset(context, G_CHECKSUM_SHA256);
-}
-
-static gboolean
-sha256_digest(PurpleCipherContext *context, gsize in_len, guchar digest[20],
-            gsize *out_len)
-{
-	return purple_g_checksum_digest(context, G_CHECKSUM_SHA256, in_len,
-	                                digest, out_len);
-}
-
-static PurpleCipherOps SHA256Ops = {
-	NULL,			/* Set Option		*/
-	NULL,			/* Get Option		*/
-	sha256_init,	/* init				*/
-	sha256_reset,	/* reset			*/
-	purple_g_checksum_uninit,	/* uninit			*/
-	NULL,			/* set iv			*/
-	purple_g_checksum_append,	/* append			*/
-	sha256_digest,	/* digest			*/
-	NULL,			/* encrypt			*/
-	NULL,			/* decrypt			*/
-	NULL,			/* set salt			*/
-	NULL,			/* get salt size	*/
-	NULL,			/* set key			*/
-	NULL,			/* get key size		*/
-	NULL,			/* set batch mode */
-	NULL,			/* get batch mode */
-	sha256_get_block_size,	/* get block size */
-	NULL			/* set key with len */
-};
-
-#else /* GLIB_CHECK_VERSION(2,16,0) */
-
-#define SHA256_ROTR(X,n) ((((X) >> (n)) | ((X) << (32-(n)))) & 0xFFFFFFFF)
-
-static const guint32 sha256_K[64] =
-{
-	0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
-	0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
-	0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
-	0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
-	0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
-	0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
-	0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
-	0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
-};
-
-struct SHA256Context {
-	guint32 H[8];
-	guint32 W[64];
-
-	gint lenW;
-
-	guint32 sizeHi;
-	guint32 sizeLo;
-};
-
-static void
-sha256_hash_block(struct SHA256Context *sha256_ctx) {
-	gint i;
-	guint32 A, B, C, D, E, F, G, H, T1, T2;
-
-	for(i = 16; i < 64; i++) {
-		sha256_ctx->W[i] =
-			  (SHA256_ROTR(sha256_ctx->W[i-2], 17) ^ SHA256_ROTR(sha256_ctx->W[i-2],  19) ^ (sha256_ctx->W[i-2] >> 10))
-			+ sha256_ctx->W[i-7]
-			+ (SHA256_ROTR(sha256_ctx->W[i-15], 7) ^ SHA256_ROTR(sha256_ctx->W[i-15], 18) ^ (sha256_ctx->W[i-15] >> 3))
-			+ sha256_ctx->W[i-16];
-	}
-
-	A = sha256_ctx->H[0];
-	B = sha256_ctx->H[1];
-	C = sha256_ctx->H[2];
-	D = sha256_ctx->H[3];
-	E = sha256_ctx->H[4];
-	F = sha256_ctx->H[5];
-	G = sha256_ctx->H[6];
-	H = sha256_ctx->H[7];
-
-	for(i = 0; i < 64; i++) {
-        T1 = H
-			+ (SHA256_ROTR(E, 6) ^ SHA256_ROTR(E, 11) ^ SHA256_ROTR(E, 25))
-			+ ((E & F) ^ ((~E) & G))
-			+ sha256_K[i] + sha256_ctx->W[i];
-        T2 = (SHA256_ROTR(A, 2) ^ SHA256_ROTR(A, 13) ^ SHA256_ROTR(A, 22))
-			+ ((A & B) ^ (A & C) ^ (B & C));
-		H = G;
-		G = F;
-		F = E;
-		E = D + T1;
-		D = C;
-		C = B;
-		B = A;
-		A = T1 + T2;
-	}
-
-	sha256_ctx->H[0] += A;
-	sha256_ctx->H[1] += B;
-	sha256_ctx->H[2] += C;
-	sha256_ctx->H[3] += D;
-	sha256_ctx->H[4] += E;
-	sha256_ctx->H[5] += F;
-	sha256_ctx->H[6] += G;
-	sha256_ctx->H[7] += H;
-}
-
-static void
-sha256_set_opt(PurpleCipherContext *context, const gchar *name, void *value) {
-	struct SHA256Context *ctx;
-
-	ctx = purple_cipher_context_get_data(context);
-
-	if(!strcmp(name, "sizeHi")) {
-		ctx->sizeHi = GPOINTER_TO_INT(value);
-	} else if(!strcmp(name, "sizeLo")) {
-		ctx->sizeLo = GPOINTER_TO_INT(value);
-	} else if(!strcmp(name, "lenW")) {
-		ctx->lenW = GPOINTER_TO_INT(value);
-	}
-}
-
-static void *
-sha256_get_opt(PurpleCipherContext *context, const gchar *name) {
-	struct SHA256Context *ctx;
-
-	ctx = purple_cipher_context_get_data(context);
-
-	if(!strcmp(name, "sizeHi")) {
-		return GINT_TO_POINTER(ctx->sizeHi);
-	} else if(!strcmp(name, "sizeLo")) {
-		return GINT_TO_POINTER(ctx->sizeLo);
-	} else if(!strcmp(name, "lenW")) {
-		return GINT_TO_POINTER(ctx->lenW);
-	}
-
-	return NULL;
-}
-
-static void
-sha256_init(PurpleCipherContext *context, void *extra) {
-	struct SHA256Context *sha256_ctx;
-
-	sha256_ctx = g_new0(struct SHA256Context, 1);
-
-	purple_cipher_context_set_data(context, sha256_ctx);
-
-	purple_cipher_context_reset(context, extra);
-}
-
-static void
-sha256_reset(PurpleCipherContext *context, void *extra) {
-	struct SHA256Context *sha256_ctx;
-	gint i;
-
-	sha256_ctx = purple_cipher_context_get_data(context);
-
-	g_return_if_fail(sha256_ctx);
-
-	sha256_ctx->lenW = 0;
-	sha256_ctx->sizeHi = 0;
-	sha256_ctx->sizeLo = 0;
-
-	sha256_ctx->H[0] = 0x6a09e667;
-	sha256_ctx->H[1] = 0xbb67ae85;
-	sha256_ctx->H[2] = 0x3c6ef372;
-	sha256_ctx->H[3] = 0xa54ff53a;
-	sha256_ctx->H[4] = 0x510e527f;
-	sha256_ctx->H[5] = 0x9b05688c;
-	sha256_ctx->H[6] = 0x1f83d9ab;
-	sha256_ctx->H[7] = 0x5be0cd19;
-
-	for(i = 0; i < 64; i++)
-		sha256_ctx->W[i] = 0;
-}
-
-static void
-sha256_uninit(PurpleCipherContext *context) {
-	struct SHA256Context *sha256_ctx;
-
-	purple_cipher_context_reset(context, NULL);
-
-	sha256_ctx = purple_cipher_context_get_data(context);
-
-	memset(sha256_ctx, 0, sizeof(struct SHA256Context));
-
-	g_free(sha256_ctx);
-	sha256_ctx = NULL;
-}
-
-
-static void
-sha256_append(PurpleCipherContext *context, const guchar *data, size_t len) {
-	struct SHA256Context *sha256_ctx;
-	gint i;
-
-	sha256_ctx = purple_cipher_context_get_data(context);
-
-	g_return_if_fail(sha256_ctx);
-
-	for(i = 0; i < len; i++) {
-		sha256_ctx->W[sha256_ctx->lenW / 4] <<= 8;
-		sha256_ctx->W[sha256_ctx->lenW / 4] |= data[i];
-
-		if((++sha256_ctx->lenW) % 64 == 0) {
-			sha256_hash_block(sha256_ctx);
-			sha256_ctx->lenW = 0;
-		}
-
-		sha256_ctx->sizeLo += 8;
-		sha256_ctx->sizeHi += (sha256_ctx->sizeLo < 8);
-	}
-}
-
-static gboolean
-sha256_digest(PurpleCipherContext *context, size_t in_len, guchar digest[32],
-			size_t *out_len)
-{
-	struct SHA256Context *sha256_ctx;
-	guchar pad0x80 = 0x80, pad0x00 = 0x00;
-	guchar padlen[8];
-	gint i;
-
-	g_return_val_if_fail(in_len >= 32, FALSE);
-
-	sha256_ctx = purple_cipher_context_get_data(context);
-
-	g_return_val_if_fail(sha256_ctx, FALSE);
-
-	padlen[0] = (guchar)((sha256_ctx->sizeHi >> 24) & 255);
-	padlen[1] = (guchar)((sha256_ctx->sizeHi >> 16) & 255);
-	padlen[2] = (guchar)((sha256_ctx->sizeHi >> 8) & 255);
-	padlen[3] = (guchar)((sha256_ctx->sizeHi >> 0) & 255);
-	padlen[4] = (guchar)((sha256_ctx->sizeLo >> 24) & 255);
-	padlen[5] = (guchar)((sha256_ctx->sizeLo >> 16) & 255);
-	padlen[6] = (guchar)((sha256_ctx->sizeLo >> 8) & 255);
-	padlen[7] = (guchar)((sha256_ctx->sizeLo >> 0) & 255);
-
-	/* pad with a 1, then zeroes, then length */
-	purple_cipher_context_append(context, &pad0x80, 1);
-	while(sha256_ctx->lenW != 56)
-		purple_cipher_context_append(context, &pad0x00, 1);
-	purple_cipher_context_append(context, padlen, 8);
-
-	for(i = 0; i < 32; i++) {
-		digest[i] = (guchar)(sha256_ctx->H[i / 4] >> 24);
-		sha256_ctx->H[i / 4] <<= 8;
-	}
-
-	purple_cipher_context_reset(context, NULL);
-
-	if(out_len)
-		*out_len = 32;
-
-	return TRUE;
-}
-
-static PurpleCipherOps SHA256Ops = {
-	sha256_set_opt,	/* Set Option		*/
-	sha256_get_opt,	/* Get Option		*/
-	sha256_init,	/* init				*/
-	sha256_reset,	/* reset			*/
-	sha256_uninit,	/* uninit			*/
-	NULL,			/* set iv			*/
-	sha256_append,	/* append			*/
-	sha256_digest,	/* digest			*/
-	NULL,			/* encrypt			*/
-	NULL,			/* decrypt			*/
-	NULL,			/* set salt			*/
-	NULL,			/* get salt size	*/
-	NULL,			/* set key			*/
-	NULL,			/* get key size		*/
-	NULL,			/* set batch mode */
-	NULL,			/* get batch mode */
-	sha256_get_block_size,	/* get block size */
-	NULL			/* set key with len */
-};
-
-#endif /* GLIB_CHECK_VERSION(2,16,0) */
-
-/*******************************************************************************
- * RC4
- ******************************************************************************/
-
-struct RC4Context {
-  guchar state[256];
-  guchar x;
-  guchar y;
-  gint key_len;
-};
-
-static void
-rc4_init(PurpleCipherContext *context, void *extra) {
-	struct RC4Context *rc4_ctx;
-	rc4_ctx = g_new0(struct RC4Context, 1);
-	purple_cipher_context_set_data(context, rc4_ctx);
-	purple_cipher_context_reset(context, extra);
-}
-
-
-static void
-rc4_reset(PurpleCipherContext *context, void *extra) {
-	struct RC4Context *rc4_ctx;
-	guint i;
-
-	rc4_ctx = purple_cipher_context_get_data(context);
-
-	g_return_if_fail(rc4_ctx);
-
-	for(i = 0; i < 256; i++)
-		rc4_ctx->state[i] = i;
-	rc4_ctx->x = 0;
-	rc4_ctx->y = 0;
-
-	/* default is 5 bytes (40bit key) */
-	rc4_ctx->key_len = 5;
-
-}
-
-static void
-rc4_uninit(PurpleCipherContext *context) {
-	struct RC4Context *rc4_ctx;
-
-	rc4_ctx = purple_cipher_context_get_data(context);
-	memset(rc4_ctx, 0, sizeof(rc4_ctx));
-
-	g_free(rc4_ctx);
-	rc4_ctx = NULL;
-}
-
-
-
-static void
-rc4_set_key (PurpleCipherContext *context, const guchar * key) {
-	struct RC4Context *ctx;
-	guchar *state;
-	guchar temp_swap;
-	guchar x, y;
-	guint i;
-
-	ctx = purple_cipher_context_get_data(context);
-
-	x = 0;
-	y = 0;
-	state = &ctx->state[0];
-	for(i = 0; i < 256; i++)
-	{
-		y = (key[x] + state[i] + y) % 256;
-		temp_swap = state[i];
-		state[i] = state[y];
-		state[y] = temp_swap;
-		x = (x + 1) % ctx->key_len;
-	}
-}
-
-static void
-rc4_set_opt(PurpleCipherContext *context, const gchar *name, void *value) {
-	struct RC4Context *ctx;
-
-	ctx = purple_cipher_context_get_data(context);
-
-	if(purple_strequal(name, "key_len")) {
-		ctx->key_len = GPOINTER_TO_INT(value);
-	}
-}
-
-static size_t
-rc4_get_key_size (PurpleCipherContext *context)
-{
-	struct RC4Context *ctx;
-
-	g_return_val_if_fail(context, -1);
-
-	ctx = purple_cipher_context_get_data(context);
-
-	g_return_val_if_fail(ctx, -1);
-
-	return ctx->key_len;
-}
-
-static void *
-rc4_get_opt(PurpleCipherContext *context, const gchar *name) {
-	struct RC4Context *ctx;
-
-	ctx = purple_cipher_context_get_data(context);
-
-	if(purple_strequal(name, "key_len")) {
-		return GINT_TO_POINTER(ctx->key_len);
-	}
-
-	return NULL;
-}
-
-static gint
-rc4_encrypt(PurpleCipherContext *context, const guchar data[],
-	    size_t len, guchar output[], size_t *outlen) {
-	struct RC4Context *ctx;
-	guchar temp_swap;
-	guchar x, y, z;
-	guchar *state;
-	guint i;
-
-	ctx = purple_cipher_context_get_data(context);
-
-	x = ctx->x;
-	y = ctx->y;
-	state = &ctx->state[0];
-
-	for(i = 0; i < len; i++)
-	{
-		x = (x + 1) % 256;
-		y = (state[x] + y) % 256;
-		temp_swap = state[x];
-		state[x] = state[y];
-		state[y] = temp_swap;
-		z = state[x] + (state[y]) % 256;
-		output[i] = data[i] ^ state[z];
-	}
-	ctx->x = x;
-	ctx->y = y;
-	if(outlen)
-		*outlen = len;
-
-	return 0;
-}
-
-static PurpleCipherOps RC4Ops = {
-	rc4_set_opt,   /* Set Option    */
-	rc4_get_opt,   /* Get Option    */
-	rc4_init,      /* init          */
-	rc4_reset,     /* reset         */
-	rc4_uninit,    /* uninit        */
-	NULL,          /* set iv        */
-	NULL,          /* append        */
-	NULL,          /* digest        */
-	rc4_encrypt,   /* encrypt       */
-	NULL,          /* decrypt       */
-	NULL,          /* set salt      */
-	NULL,          /* get salt size */
-	rc4_set_key,   /* set key       */
-	rc4_get_key_size, /* get key size  */
-	NULL,          /* set batch mode */
-	NULL,          /* get batch mode */
-	NULL,          /* get block size */
-	NULL           /* set key with len */
-};
-
 /*******************************************************************************
  * Structs
  ******************************************************************************/
@@ -2688,6 +223,20 @@
 	return &handle;
 }
 
+/* These are implemented in the purple-ciphers sublibrary built in the ciphers
+ * directory.  We could put a header file in there, but it's less hassle for
+ * the developer to just add it here since they have to register it here as
+ * well.
+ */
+PurpleCipherOps *purple_des_cipher_get_ops();
+PurpleCipherOps *purple_des3_cipher_get_ops();
+PurpleCipherOps *purple_hmac_cipher_get_ops();
+PurpleCipherOps *purple_md4_cipher_get_ops();
+PurpleCipherOps *purple_md5_cipher_get_ops();
+PurpleCipherOps *purple_rc4_cipher_get_ops();
+PurpleCipherOps *purple_sha1_cipher_get_ops();
+PurpleCipherOps *purple_sha256_cipher_get_ops();
+
 void
 purple_ciphers_init() {
 	gpointer handle;
@@ -2703,14 +252,14 @@
 						 purple_value_new(PURPLE_TYPE_SUBTYPE,
 										PURPLE_SUBTYPE_CIPHER));
 
-	purple_ciphers_register_cipher("md5", &MD5Ops);
-	purple_ciphers_register_cipher("sha1", &SHA1Ops);
-	purple_ciphers_register_cipher("sha256", &SHA256Ops);
-	purple_ciphers_register_cipher("md4", &MD4Ops);
-	purple_ciphers_register_cipher("hmac", &HMACOps);
-	purple_ciphers_register_cipher("des", &DESOps);
-	purple_ciphers_register_cipher("des3", &DES3Ops);
-	purple_ciphers_register_cipher("rc4", &RC4Ops);
+	purple_ciphers_register_cipher("md5", purple_md5_cipher_get_ops());
+	purple_ciphers_register_cipher("sha1", purple_sha1_cipher_get_ops());
+	purple_ciphers_register_cipher("sha256", purple_sha256_cipher_get_ops());
+	purple_ciphers_register_cipher("md4", purple_md4_cipher_get_ops());
+	purple_ciphers_register_cipher("hmac", purple_hmac_cipher_get_ops());
+	purple_ciphers_register_cipher("des", purple_des_cipher_get_ops());
+	purple_ciphers_register_cipher("des3", purple_des3_cipher_get_ops());
+	purple_ciphers_register_cipher("rc4", purple_rc4_cipher_get_ops());
 }
 
 void
@@ -2729,6 +278,7 @@
 
 	purple_signals_unregister_by_instance(purple_ciphers_get_handle());
 }
+
 /******************************************************************************
  * PurpleCipherContext API
  *****************************************************************************/
@@ -2828,7 +378,7 @@
 	if(cipher->ops && cipher->ops->uninit)
 		cipher->ops->uninit(context);
 
-	memset(context, 0, sizeof(context));
+	memset(context, 0, sizeof(*context));
 	g_free(context);
 	context = NULL;
 }
--- a/libpurple/cipher.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/cipher.h	Sat Aug 06 03:45:56 2011 +0000
@@ -28,6 +28,7 @@
 #define PURPLE_CIPHER_H
 
 #include <glib.h>
+#include <string.h>
 
 #define PURPLE_CIPHER(obj)			((PurpleCipher *)(obj))			/**< PurpleCipher typecast helper			*/
 #define PURPLE_CIPHER_OPS(obj)		((PurpleCipherOps *)(obj))		/**< PurpleCipherInfo typecase helper		*/
@@ -129,9 +130,7 @@
 	void (*set_key_with_len)(PurpleCipherContext *context, const guchar *key, size_t len);
 };
 
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+G_BEGIN_DECLS
 
 /*****************************************************************************/
 /** @name PurpleCipher API													 */
@@ -498,8 +497,6 @@
 
 /*@}*/
 
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+G_END_DECLS
 
 #endif /* PURPLE_CIPHER_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/ciphers/Makefile.am	Sat Aug 06 03:45:56 2011 +0000
@@ -0,0 +1,17 @@
+noinst_LTLIBRARIES=libpurple-ciphers.la
+
+libpurple_ciphers_la_SOURCES=\
+	des.c \
+	gchecksum.c \
+	hmac.c \
+	md4.c \
+	md5.c \
+	rc4.c \
+	sha1.c \
+	sha256.c
+
+INCLUDES = -I$(top_srcdir)/libpurple
+
+AM_CPPFLAGS = \
+	$(GLIB_CFLAGS)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/ciphers/des.c	Sat Aug 06 03:45:56 2011 +0000
@@ -0,0 +1,846 @@
+/*
+ * purple
+ *
+ * Purple is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * Original des taken from gpg
+ *
+ * des.c - DES and Triple-DES encryption/decryption Algorithm
+ *  Copyright (C) 1998 Free Software Foundation, Inc.
+ *
+ *  Please see below for more legal information!
+ *
+ *   According to the definition of DES in FIPS PUB 46-2 from December 1993.
+ *   For a description of triple encryption, see:
+ *     Bruce Schneier: Applied Cryptography. Second Edition.
+ *     John Wiley & Sons, 1996. ISBN 0-471-12845-7. Pages 358 ff.
+ *
+ *   This file is part of GnuPG.
+ *
+ * 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 <cipher.h>
+
+/******************************************************************************
+ * DES
+ *****************************************************************************/
+typedef struct _des_ctx
+{
+	guint32 encrypt_subkeys[32];
+	guint32 decrypt_subkeys[32];
+} des_ctx[1];
+
+/*
+ *  The s-box values are permuted according to the 'primitive function P'
+ */
+static const guint32 sbox1[64] =
+{
+	0x00808200, 0x00000000, 0x00008000, 0x00808202, 0x00808002, 0x00008202, 0x00000002, 0x00008000,
+	0x00000200, 0x00808200, 0x00808202, 0x00000200, 0x00800202, 0x00808002, 0x00800000, 0x00000002,
+	0x00000202, 0x00800200, 0x00800200, 0x00008200, 0x00008200, 0x00808000, 0x00808000, 0x00800202,
+	0x00008002, 0x00800002, 0x00800002, 0x00008002, 0x00000000, 0x00000202, 0x00008202, 0x00800000,
+	0x00008000, 0x00808202, 0x00000002, 0x00808000, 0x00808200, 0x00800000, 0x00800000, 0x00000200,
+	0x00808002, 0x00008000, 0x00008200, 0x00800002, 0x00000200, 0x00000002, 0x00800202, 0x00008202,
+	0x00808202, 0x00008002, 0x00808000, 0x00800202, 0x00800002, 0x00000202, 0x00008202, 0x00808200,
+	0x00000202, 0x00800200, 0x00800200, 0x00000000, 0x00008002, 0x00008200, 0x00000000, 0x00808002
+};
+
+static const guint32 sbox2[64] =
+{
+	0x40084010, 0x40004000, 0x00004000, 0x00084010, 0x00080000, 0x00000010, 0x40080010, 0x40004010,
+	0x40000010, 0x40084010, 0x40084000, 0x40000000, 0x40004000, 0x00080000, 0x00000010, 0x40080010,
+	0x00084000, 0x00080010, 0x40004010, 0x00000000, 0x40000000, 0x00004000, 0x00084010, 0x40080000,
+	0x00080010, 0x40000010, 0x00000000, 0x00084000, 0x00004010, 0x40084000, 0x40080000, 0x00004010,
+	0x00000000, 0x00084010, 0x40080010, 0x00080000, 0x40004010, 0x40080000, 0x40084000, 0x00004000,
+	0x40080000, 0x40004000, 0x00000010, 0x40084010, 0x00084010, 0x00000010, 0x00004000, 0x40000000,
+	0x00004010, 0x40084000, 0x00080000, 0x40000010, 0x00080010, 0x40004010, 0x40000010, 0x00080010,
+	0x00084000, 0x00000000, 0x40004000, 0x00004010, 0x40000000, 0x40080010, 0x40084010, 0x00084000
+};
+
+static const guint32 sbox3[64] =
+{
+	0x00000104, 0x04010100, 0x00000000, 0x04010004, 0x04000100, 0x00000000, 0x00010104, 0x04000100,
+	0x00010004, 0x04000004, 0x04000004, 0x00010000, 0x04010104, 0x00010004, 0x04010000, 0x00000104,
+	0x04000000, 0x00000004, 0x04010100, 0x00000100, 0x00010100, 0x04010000, 0x04010004, 0x00010104,
+	0x04000104, 0x00010100, 0x00010000, 0x04000104, 0x00000004, 0x04010104, 0x00000100, 0x04000000,
+	0x04010100, 0x04000000, 0x00010004, 0x00000104, 0x00010000, 0x04010100, 0x04000100, 0x00000000,
+	0x00000100, 0x00010004, 0x04010104, 0x04000100, 0x04000004, 0x00000100, 0x00000000, 0x04010004,
+	0x04000104, 0x00010000, 0x04000000, 0x04010104, 0x00000004, 0x00010104, 0x00010100, 0x04000004,
+	0x04010000, 0x04000104, 0x00000104, 0x04010000, 0x00010104, 0x00000004, 0x04010004, 0x00010100
+};
+
+static const guint32 sbox4[64] =
+{
+	0x80401000, 0x80001040, 0x80001040, 0x00000040, 0x00401040, 0x80400040, 0x80400000, 0x80001000,
+	0x00000000, 0x00401000, 0x00401000, 0x80401040, 0x80000040, 0x00000000, 0x00400040, 0x80400000,
+	0x80000000, 0x00001000, 0x00400000, 0x80401000, 0x00000040, 0x00400000, 0x80001000, 0x00001040,
+	0x80400040, 0x80000000, 0x00001040, 0x00400040, 0x00001000, 0x00401040, 0x80401040, 0x80000040,
+	0x00400040, 0x80400000, 0x00401000, 0x80401040, 0x80000040, 0x00000000, 0x00000000, 0x00401000,
+	0x00001040, 0x00400040, 0x80400040, 0x80000000, 0x80401000, 0x80001040, 0x80001040, 0x00000040,
+	0x80401040, 0x80000040, 0x80000000, 0x00001000, 0x80400000, 0x80001000, 0x00401040, 0x80400040,
+	0x80001000, 0x00001040, 0x00400000, 0x80401000, 0x00000040, 0x00400000, 0x00001000, 0x00401040
+};
+
+static const guint32 sbox5[64] =
+{
+	0x00000080, 0x01040080, 0x01040000, 0x21000080, 0x00040000, 0x00000080, 0x20000000, 0x01040000,
+	0x20040080, 0x00040000, 0x01000080, 0x20040080, 0x21000080, 0x21040000, 0x00040080, 0x20000000,
+	0x01000000, 0x20040000, 0x20040000, 0x00000000, 0x20000080, 0x21040080, 0x21040080, 0x01000080,
+	0x21040000, 0x20000080, 0x00000000, 0x21000000, 0x01040080, 0x01000000, 0x21000000, 0x00040080,
+	0x00040000, 0x21000080, 0x00000080, 0x01000000, 0x20000000, 0x01040000, 0x21000080, 0x20040080,
+	0x01000080, 0x20000000, 0x21040000, 0x01040080, 0x20040080, 0x00000080, 0x01000000, 0x21040000,
+	0x21040080, 0x00040080, 0x21000000, 0x21040080, 0x01040000, 0x00000000, 0x20040000, 0x21000000,
+	0x00040080, 0x01000080, 0x20000080, 0x00040000, 0x00000000, 0x20040000, 0x01040080, 0x20000080
+};
+
+static const guint32 sbox6[64] =
+{
+	0x10000008, 0x10200000, 0x00002000, 0x10202008, 0x10200000, 0x00000008, 0x10202008, 0x00200000,
+	0x10002000, 0x00202008, 0x00200000, 0x10000008, 0x00200008, 0x10002000, 0x10000000, 0x00002008,
+	0x00000000, 0x00200008, 0x10002008, 0x00002000, 0x00202000, 0x10002008, 0x00000008, 0x10200008,
+	0x10200008, 0x00000000, 0x00202008, 0x10202000, 0x00002008, 0x00202000, 0x10202000, 0x10000000,
+	0x10002000, 0x00000008, 0x10200008, 0x00202000, 0x10202008, 0x00200000, 0x00002008, 0x10000008,
+	0x00200000, 0x10002000, 0x10000000, 0x00002008, 0x10000008, 0x10202008, 0x00202000, 0x10200000,
+	0x00202008, 0x10202000, 0x00000000, 0x10200008, 0x00000008, 0x00002000, 0x10200000, 0x00202008,
+	0x00002000, 0x00200008, 0x10002008, 0x00000000, 0x10202000, 0x10000000, 0x00200008, 0x10002008
+};
+
+static const guint32 sbox7[64] =
+{
+	0x00100000, 0x02100001, 0x02000401, 0x00000000, 0x00000400, 0x02000401, 0x00100401, 0x02100400,
+	0x02100401, 0x00100000, 0x00000000, 0x02000001, 0x00000001, 0x02000000, 0x02100001, 0x00000401,
+	0x02000400, 0x00100401, 0x00100001, 0x02000400, 0x02000001, 0x02100000, 0x02100400, 0x00100001,
+	0x02100000, 0x00000400, 0x00000401, 0x02100401, 0x00100400, 0x00000001, 0x02000000, 0x00100400,
+	0x02000000, 0x00100400, 0x00100000, 0x02000401, 0x02000401, 0x02100001, 0x02100001, 0x00000001,
+	0x00100001, 0x02000000, 0x02000400, 0x00100000, 0x02100400, 0x00000401, 0x00100401, 0x02100400,
+	0x00000401, 0x02000001, 0x02100401, 0x02100000, 0x00100400, 0x00000000, 0x00000001, 0x02100401,
+	0x00000000, 0x00100401, 0x02100000, 0x00000400, 0x02000001, 0x02000400, 0x00000400, 0x00100001
+};
+
+static const guint32 sbox8[64] =
+{
+	0x08000820, 0x00000800, 0x00020000, 0x08020820, 0x08000000, 0x08000820, 0x00000020, 0x08000000,
+	0x00020020, 0x08020000, 0x08020820, 0x00020800, 0x08020800, 0x00020820, 0x00000800, 0x00000020,
+	0x08020000, 0x08000020, 0x08000800, 0x00000820, 0x00020800, 0x00020020, 0x08020020, 0x08020800,
+	0x00000820, 0x00000000, 0x00000000, 0x08020020, 0x08000020, 0x08000800, 0x00020820, 0x00020000,
+	0x00020820, 0x00020000, 0x08020800, 0x00000800, 0x00000020, 0x08020020, 0x00000800, 0x00020820,
+	0x08000800, 0x00000020, 0x08000020, 0x08020000, 0x08020020, 0x08000000, 0x00020000, 0x08000820,
+	0x00000000, 0x08020820, 0x00020020, 0x08000020, 0x08020000, 0x08000800, 0x08000820, 0x00000000,
+	0x08020820, 0x00020800, 0x00020800, 0x00000820, 0x00000820, 0x00020020, 0x08000000, 0x08020800
+};
+
+
+/*
+ *  * These two tables are part of the 'permuted choice 1' function.
+ *   * In this implementation several speed improvements are done.
+ *    */
+static const guint32 leftkey_swap[16] =
+{
+	0x00000000, 0x00000001, 0x00000100, 0x00000101,
+	0x00010000, 0x00010001, 0x00010100, 0x00010101,
+	0x01000000, 0x01000001, 0x01000100, 0x01000101,
+	0x01010000, 0x01010001, 0x01010100, 0x01010101
+};
+
+static const guint32 rightkey_swap[16] =
+{
+	0x00000000, 0x01000000, 0x00010000, 0x01010000,
+	0x00000100, 0x01000100, 0x00010100, 0x01010100,
+	0x00000001, 0x01000001, 0x00010001, 0x01010001,
+	0x00000101, 0x01000101, 0x00010101, 0x01010101,
+};
+
+
+/*
+ *  Numbers of left shifts per round for encryption subkey schedule
+ *  To calculate the decryption key scheduling we just reverse the
+ *  ordering of the subkeys so we can omit the table for decryption
+ *  subkey schedule.
+ */
+static const guint8 encrypt_rotate_tab[16] =
+{
+	1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1
+};
+
+/*
+ *  Macro to swap bits across two words
+ **/
+#define DO_PERMUTATION(a, temp, b, offset, mask)    \
+	temp = ((a>>offset) ^ b) & mask;            \
+	b ^= temp;                      \
+	a ^= temp<<offset;
+
+
+/*
+ *  This performs the 'initial permutation' for the data to be encrypted or decrypted
+ **/
+#define INITIAL_PERMUTATION(left, temp, right)      \
+	DO_PERMUTATION(left, temp, right, 4, 0x0f0f0f0f)    \
+	DO_PERMUTATION(left, temp, right, 16, 0x0000ffff)   \
+	DO_PERMUTATION(right, temp, left, 2, 0x33333333)    \
+	DO_PERMUTATION(right, temp, left, 8, 0x00ff00ff)    \
+	DO_PERMUTATION(left, temp, right, 1, 0x55555555)
+
+
+/*
+ * The 'inverse initial permutation'
+ **/
+#define FINAL_PERMUTATION(left, temp, right)        \
+	DO_PERMUTATION(left, temp, right, 1, 0x55555555)    \
+	DO_PERMUTATION(right, temp, left, 8, 0x00ff00ff)    \
+	DO_PERMUTATION(right, temp, left, 2, 0x33333333)    \
+	DO_PERMUTATION(left, temp, right, 16, 0x0000ffff)   \
+	DO_PERMUTATION(left, temp, right, 4, 0x0f0f0f0f)
+
+
+/*
+ * A full DES round including 'expansion function', 'sbox substitution'
+ * and 'primitive function P' but without swapping the left and right word.
+ **/
+#define DES_ROUND(from, to, work, subkey)       \
+	work = ((from<<1) | (from>>31)) ^ *subkey++;    \
+	to ^= sbox8[  work      & 0x3f ];           \
+	to ^= sbox6[ (work>>8)  & 0x3f ];           \
+	to ^= sbox4[ (work>>16) & 0x3f ];           \
+	to ^= sbox2[ (work>>24) & 0x3f ];           \
+	work = ((from>>3) | (from<<29)) ^ *subkey++;    \
+	to ^= sbox7[  work      & 0x3f ];           \
+	to ^= sbox5[ (work>>8)  & 0x3f ];           \
+	to ^= sbox3[ (work>>16) & 0x3f ];           \
+	to ^= sbox1[ (work>>24) & 0x3f ];
+
+
+/*
+ * Macros to convert 8 bytes from/to 32bit words
+ **/
+#define READ_64BIT_DATA(data, left, right)                  \
+	left  = (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3];   \
+	right = (data[4] << 24) | (data[5] << 16) | (data[6] << 8) | data[7];
+
+#define WRITE_64BIT_DATA(data, left, right)                 \
+	data[0] = (left >> 24) &0xff; data[1] = (left >> 16) &0xff;         \
+	data[2] = (left >> 8) &0xff; data[3] = left &0xff;              \
+	data[4] = (right >> 24) &0xff; data[5] = (right >> 16) &0xff;       \
+	data[6] = (right >> 8) &0xff; data[7] = right &0xff;
+
+
+/*
+ * des_key_schedule():    Calculate 16 subkeys pairs (even/odd) for
+ *            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)
+{
+	guint32 left, right, work;
+	int round;
+
+	READ_64BIT_DATA (rawkey, left, right)
+
+	DO_PERMUTATION (right, work, left, 4, 0x0f0f0f0f)
+	DO_PERMUTATION (right, work, left, 0, 0x10101010)
+
+	left = (leftkey_swap[(left >> 0) & 0xf] << 3) | (leftkey_swap[(left >> 8) & 0xf] << 2)
+	| (leftkey_swap[(left >> 16) & 0xf] << 1) | (leftkey_swap[(left >> 24) & 0xf])
+	| (leftkey_swap[(left >> 5) & 0xf] << 7) | (leftkey_swap[(left >> 13) & 0xf] << 6)
+	| (leftkey_swap[(left >> 21) & 0xf] << 5) | (leftkey_swap[(left >> 29) & 0xf] << 4);
+
+	left &= 0x0fffffff;
+
+	right = (rightkey_swap[(right >> 1) & 0xf] << 3) | (rightkey_swap[(right >> 9) & 0xf] << 2)
+		| (rightkey_swap[(right >> 17) & 0xf] << 1) | (rightkey_swap[(right >> 25) & 0xf])
+		| (rightkey_swap[(right >> 4) & 0xf] << 7) | (rightkey_swap[(right >> 12) & 0xf] << 6)
+		| (rightkey_swap[(right >> 20) & 0xf] << 5) | (rightkey_swap[(right >> 28) & 0xf] << 4);
+
+	right &= 0x0fffffff;
+
+	for (round = 0; round < 16; ++round)
+	{
+        left = ((left << encrypt_rotate_tab[round]) | (left >> (28 - encrypt_rotate_tab[round]))) & 0x0fffffff;
+        right = ((right << encrypt_rotate_tab[round]) | (right >> (28 - encrypt_rotate_tab[round]))) & 0x0fffffff;
+
+		*subkey++ = ((left << 4) & 0x24000000)
+			| ((left << 28) & 0x10000000)
+			| ((left << 14) & 0x08000000)
+			| ((left << 18) & 0x02080000)
+			| ((left << 6) & 0x01000000)
+			| ((left << 9) & 0x00200000)
+			| ((left >> 1) & 0x00100000)
+			| ((left << 10) & 0x00040000)
+			| ((left << 2) & 0x00020000)
+			| ((left >> 10) & 0x00010000)
+			| ((right >> 13) & 0x00002000)
+			| ((right >> 4) & 0x00001000)
+			| ((right << 6) & 0x00000800)
+			| ((right >> 1) & 0x00000400)
+			| ((right >> 14) & 0x00000200)
+			| (right & 0x00000100)
+			| ((right >> 5) & 0x00000020)
+			| ((right >> 10) & 0x00000010)
+			| ((right >> 3) & 0x00000008)
+			| ((right >> 18) & 0x00000004)
+			| ((right >> 26) & 0x00000002)
+			| ((right >> 24) & 0x00000001);
+
+		*subkey++ = ((left << 15) & 0x20000000)
+			| ((left << 17) & 0x10000000)
+			| ((left << 10) & 0x08000000)
+			| ((left << 22) & 0x04000000)
+			| ((left >> 2) & 0x02000000)
+			| ((left << 1) & 0x01000000)
+			| ((left << 16) & 0x00200000)
+			| ((left << 11) & 0x00100000)
+			| ((left << 3) & 0x00080000)
+			| ((left >> 6) & 0x00040000)
+			| ((left << 15) & 0x00020000)
+			| ((left >> 4) & 0x00010000)
+			| ((right >> 2) & 0x00002000)
+			| ((right << 8) & 0x00001000)
+			| ((right >> 14) & 0x00000808)
+			| ((right >> 9) & 0x00000400)
+			| ((right) & 0x00000200)
+			| ((right << 7) & 0x00000100)
+			| ((right >> 7) & 0x00000020)
+			| ((right >> 3) & 0x00000011)
+			| ((right << 2) & 0x00000004)
+			| ((right >> 21) & 0x00000002);
+	}
+}
+
+
+/*
+ *  Fill a DES context with subkeys calculated from a 64bit key.
+ *  Does not check parity bits, but simply ignore them.
+ *  Does not check for weak keys.
+ **/
+static void
+des_set_key (PurpleCipherContext *context, const guchar * key)
+{
+	struct _des_ctx *ctx = purple_cipher_context_get_data(context);
+	int i;
+
+	des_key_schedule (key, ctx->encrypt_subkeys);
+
+	for(i=0; i<32; i+=2)
+	{
+		ctx->decrypt_subkeys[i] = ctx->encrypt_subkeys[30-i];
+		ctx->decrypt_subkeys[i+1] = ctx->encrypt_subkeys[31-i];
+	}
+}
+
+
+/*
+ *  Electronic Codebook Mode DES encryption/decryption of data according
+ *  to 'mode'.
+ **/
+static int
+des_ecb_crypt (struct _des_ctx *ctx, const guint8 * from, guint8 * to, int mode)
+{
+	guint32 left, right, work;
+	guint32 *keys;
+
+	keys = mode ? ctx->decrypt_subkeys : ctx->encrypt_subkeys;
+
+	READ_64BIT_DATA (from, left, right)
+	INITIAL_PERMUTATION (left, work, right)
+
+	DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+	DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+	DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+	DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+	DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+	DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+	DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+	DES_ROUND (right, left, work, keys) DES_ROUND (left, right, work, keys)
+
+	FINAL_PERMUTATION (right, work, left)
+	WRITE_64BIT_DATA (to, right, left)
+
+	return 0;
+}
+
+static gint
+des_encrypt(PurpleCipherContext *context, const guchar data[],
+            size_t len, guchar output[], size_t *outlen)
+{
+	int offset = 0;
+	int i = 0;
+	int tmp;
+	guint8 buf[8] = {0,0,0,0,0,0,0,0};
+	while(offset+8<=len) {
+		des_ecb_crypt(purple_cipher_context_get_data(context),
+		              data+offset,
+		              output+offset,
+		              0);
+		offset+=8;
+	}
+	*outlen = len;
+	if(offset<len) {
+		*outlen += len - offset;
+		tmp = offset;
+		while(tmp<len) {
+			buf[i++] = data[tmp];
+			tmp++;
+		}
+		des_ecb_crypt(purple_cipher_context_get_data(context),
+		              buf,
+		              output+offset,
+		              0);
+	}
+	return 0;
+}
+
+static gint
+des_decrypt(PurpleCipherContext *context, const guchar data[],
+            size_t len, guchar output[], size_t *outlen)
+{
+	int offset = 0;
+	int i = 0;
+	int tmp;
+	guint8 buf[8] = {0,0,0,0,0,0,0,0};
+	while(offset+8<=len) {
+		des_ecb_crypt(purple_cipher_context_get_data(context),
+		              data+offset,
+		              output+offset,
+		              1);
+		offset+=8;
+	}
+	*outlen = len;
+	if(offset<len) {
+		*outlen += len - offset;
+		tmp = offset;
+		while(tmp<len) {
+			buf[i++] = data[tmp];
+			tmp++;
+		}
+		des_ecb_crypt(purple_cipher_context_get_data(context),
+		              buf,
+		              output+offset,
+		              1);
+	}
+	return 0;
+}
+
+static void
+des_init(PurpleCipherContext *context, gpointer extra) {
+	struct _des_ctx *mctx;
+	mctx = g_new0(struct _des_ctx, 1);
+	purple_cipher_context_set_data(context, mctx);
+}
+
+static void
+des_uninit(PurpleCipherContext *context) {
+	struct _des_ctx *des_context;
+
+	des_context = purple_cipher_context_get_data(context);
+	memset(des_context, 0, sizeof(*des_context));
+
+	g_free(des_context);
+	des_context = NULL;
+}
+
+static PurpleCipherOps DESOps = {
+	NULL,              /* Set option */
+	NULL,              /* Get option */
+	des_init,          /* init */
+ 	NULL,              /* reset */
+	des_uninit,        /* uninit */
+	NULL,              /* set iv */
+	NULL,              /* append */
+	NULL,              /* digest */
+	des_encrypt,       /* encrypt */
+	des_decrypt,       /* decrypt */
+	NULL,              /* set salt */
+	NULL,              /* get salt size */
+	des_set_key,       /* set key */
+	NULL,              /* get key size */
+	NULL,              /* set batch mode */
+	NULL,              /* get batch mode */
+	NULL,              /* get block size */
+	NULL               /* set key with len */
+};
+
+/******************************************************************************
+ * Triple-DES
+ *****************************************************************************/
+
+typedef struct _des3_ctx
+{
+	PurpleCipherBatchMode mode;
+	guchar iv[8];
+	/* First key for encryption */
+	struct _des_ctx key1;
+	/* Second key for decryption */
+	struct _des_ctx key2;
+	/* Third key for encryption */
+	struct _des_ctx key3;
+} des3_ctx[1];
+
+/*
+ *  Fill a DES3 context with subkeys calculated from 3 64bit key.
+ *  Does not check parity bits, but simply ignore them.
+ *  Does not check for weak keys.
+ **/
+static void
+des3_set_key(PurpleCipherContext *context, const guchar * key)
+{
+	struct _des3_ctx *ctx = purple_cipher_context_get_data(context);
+	int i;
+
+	des_key_schedule (key +  0, ctx->key1.encrypt_subkeys);
+	des_key_schedule (key +  8, ctx->key2.encrypt_subkeys);
+	des_key_schedule (key + 16, ctx->key3.encrypt_subkeys);
+
+	for (i = 0; i < 32; i += 2)
+	{
+		ctx->key1.decrypt_subkeys[i]    = ctx->key1.encrypt_subkeys[30-i];
+		ctx->key1.decrypt_subkeys[i+1]  = ctx->key1.encrypt_subkeys[31-i];
+		ctx->key2.decrypt_subkeys[i]    = ctx->key2.encrypt_subkeys[30-i];
+		ctx->key2.decrypt_subkeys[i+1]  = ctx->key2.encrypt_subkeys[31-i];
+		ctx->key3.decrypt_subkeys[i]    = ctx->key3.encrypt_subkeys[30-i];
+		ctx->key3.decrypt_subkeys[i+1]  = ctx->key3.encrypt_subkeys[31-i];
+	}
+}
+
+static gint
+des3_ecb_encrypt(struct _des3_ctx *ctx, const guchar data[],
+                 size_t len, guchar output[], size_t *outlen)
+{
+	int offset = 0;
+	int i = 0;
+	int tmp;
+	guint8 buf[8] = {0,0,0,0,0,0,0,0};
+	while (offset + 8 <= len) {
+		des_ecb_crypt(&ctx->key1,
+		              data+offset,
+		              output+offset,
+		              0);
+		des_ecb_crypt(&ctx->key2,
+		              output+offset,
+		              buf,
+		              1);
+		des_ecb_crypt(&ctx->key3,
+		              buf,
+		              output+offset,
+		              0);
+		offset += 8;
+	}
+	*outlen = len;
+	if (offset < len) {
+		*outlen += len - offset;
+		tmp = offset;
+		memset(buf, 0, 8);
+		while (tmp < len) {
+			buf[i++] = data[tmp];
+			tmp++;
+		}
+		des_ecb_crypt(&ctx->key1,
+		              buf,
+		              output+offset,
+		              0);
+		des_ecb_crypt(&ctx->key2,
+		              output+offset,
+		              buf,
+		              1);
+		des_ecb_crypt(&ctx->key3,
+		              buf,
+		              output+offset,
+		              0);
+	}
+	return 0;
+}
+
+static gint
+des3_cbc_encrypt(struct _des3_ctx *ctx, const guchar data[],
+                 size_t len, guchar output[], size_t *outlen)
+{
+	int offset = 0;
+	int i = 0;
+	int tmp;
+	guint8 buf[8];
+	memcpy(buf, ctx->iv, 8);
+	while (offset + 8 <= len) {
+		for (i = 0; i < 8; i++)
+			buf[i] ^= data[offset + i];
+
+		des_ecb_crypt(&ctx->key1,
+		              buf,
+		              output+offset,
+		              0);
+		des_ecb_crypt(&ctx->key2,
+		              output+offset,
+		              buf,
+		              1);
+		des_ecb_crypt(&ctx->key3,
+		              buf,
+		              output+offset,
+		              0);
+		memcpy(buf, output+offset, 8);
+		offset += 8;
+	}
+	*outlen = len;
+	if (offset < len) {
+		*outlen += len - offset;
+		tmp = offset;
+		i = 0;
+		while (tmp < len) {
+			buf[i++] ^= data[tmp];
+			tmp++;
+		}
+		des_ecb_crypt(&ctx->key1,
+		              buf,
+		              output+offset,
+		              0);
+		des_ecb_crypt(&ctx->key2,
+		              output+offset,
+		              buf,
+		              1);
+		des_ecb_crypt(&ctx->key3,
+		              buf,
+		              output+offset,
+		              0);
+	}
+	return 0;
+}
+
+static gint
+des3_encrypt(PurpleCipherContext *context, const guchar data[],
+             size_t len, guchar output[], size_t *outlen)
+{
+	struct _des3_ctx *ctx = purple_cipher_context_get_data(context);
+
+	if (ctx->mode == PURPLE_CIPHER_BATCH_MODE_ECB) {
+		return des3_ecb_encrypt(ctx, data, len, output, outlen);
+	} else if (ctx->mode == PURPLE_CIPHER_BATCH_MODE_CBC) {
+		return des3_cbc_encrypt(ctx, data, len, output, outlen);
+	} else {
+		g_return_val_if_reached(0);
+	}
+
+	return 0;
+}
+
+static gint
+des3_ecb_decrypt(struct _des3_ctx *ctx, const guchar data[],
+                 size_t len, guchar output[], size_t *outlen)
+{
+	int offset = 0;
+	int i = 0;
+	int tmp;
+	guint8 buf[8] = {0,0,0,0,0,0,0,0};
+	while (offset + 8 <= len) {
+		/* NOTE: Apply key in reverse */
+		des_ecb_crypt(&ctx->key3,
+		              data+offset,
+		              output+offset,
+		              1);
+		des_ecb_crypt(&ctx->key2,
+		              output+offset,
+		              buf,
+		              0);
+		des_ecb_crypt(&ctx->key1,
+		              buf,
+		              output+offset,
+		              1);
+		offset+=8;
+	}
+	*outlen = len;
+	if (offset < len) {
+		*outlen += len - offset;
+		tmp = offset;
+		memset(buf, 0, 8);
+		while (tmp < len) {
+			buf[i++] = data[tmp];
+			tmp++;
+		}
+		des_ecb_crypt(&ctx->key3,
+		              buf,
+		              output+offset,
+		              1);
+		des_ecb_crypt(&ctx->key2,
+		              output+offset,
+		              buf,
+		              0);
+		des_ecb_crypt(&ctx->key1,
+		              buf,
+		              output+offset,
+		              1);
+	}
+	return 0;
+}
+
+static gint
+des3_cbc_decrypt(struct _des3_ctx *ctx, const guchar data[],
+                 size_t len, guchar output[], size_t *outlen)
+{
+	int offset = 0;
+	int i = 0;
+	int tmp;
+	guint8 buf[8] = {0,0,0,0,0,0,0,0};
+	guint8 link[8];
+	memcpy(link, ctx->iv, 8);
+	while (offset + 8 <= len) {
+		des_ecb_crypt(&ctx->key3,
+		              data+offset,
+		              output+offset,
+		              1);
+		des_ecb_crypt(&ctx->key2,
+		              output+offset,
+		              buf,
+		              0);
+		des_ecb_crypt(&ctx->key1,
+		              buf,
+		              output+offset,
+		              1);
+		for (i = 0; i < 8; i++)
+			output[offset + i] ^= link[i];
+		memcpy(link, data + offset, 8);
+		offset+=8;
+	}
+	*outlen = len;
+	if(offset<len) {
+		*outlen += len - offset;
+		tmp = offset;
+		memset(buf, 0, 8);
+		i = 0;
+		while(tmp<len) {
+			buf[i++] = data[tmp];
+			tmp++;
+		}
+		des_ecb_crypt(&ctx->key3,
+		              buf,
+		              output+offset,
+		              1);
+		des_ecb_crypt(&ctx->key2,
+		              output+offset,
+		              buf,
+		              0);
+		des_ecb_crypt(&ctx->key1,
+		              buf,
+		              output+offset,
+		              1);
+		for (i = 0; i < 8; i++)
+			output[offset + i] ^= link[i];
+	}
+	return 0;
+}
+
+static gint
+des3_decrypt(PurpleCipherContext *context, const guchar data[],
+             size_t len, guchar output[], size_t *outlen)
+{
+	struct _des3_ctx *ctx = purple_cipher_context_get_data(context);
+
+	if (ctx->mode == PURPLE_CIPHER_BATCH_MODE_ECB) {
+		return des3_ecb_decrypt(ctx, data, len, output, outlen);
+	} else if (ctx->mode == PURPLE_CIPHER_BATCH_MODE_CBC) {
+		return des3_cbc_decrypt(ctx, data, len, output, outlen);
+	} else {
+		g_return_val_if_reached(0);
+	}
+
+	return 0;
+}
+
+static void
+des3_set_batch(PurpleCipherContext *context, PurpleCipherBatchMode mode)
+{
+	struct _des3_ctx *ctx = purple_cipher_context_get_data(context);
+
+	ctx->mode = mode;
+}
+
+static PurpleCipherBatchMode
+des3_get_batch(PurpleCipherContext *context)
+{
+	struct _des3_ctx *ctx = purple_cipher_context_get_data(context);
+
+	return ctx->mode;
+}
+
+static void
+des3_set_iv(PurpleCipherContext *context, guchar *iv, size_t len)
+{
+	struct _des3_ctx *ctx;
+
+	g_return_if_fail(len == 8);
+
+	ctx = purple_cipher_context_get_data(context);
+
+	memcpy(ctx->iv, iv, len);
+}
+
+static void
+des3_init(PurpleCipherContext *context, gpointer extra)
+{
+	struct _des3_ctx *mctx;
+	mctx = g_new0(struct _des3_ctx, 1);
+	purple_cipher_context_set_data(context, mctx);
+}
+
+static void
+des3_uninit(PurpleCipherContext *context)
+{
+	struct _des3_ctx *des3_context;
+
+	des3_context = purple_cipher_context_get_data(context);
+	memset(des3_context, 0, sizeof(*des3_context));
+
+	g_free(des3_context);
+	des3_context = NULL;
+}
+
+static PurpleCipherOps DES3Ops = {
+	NULL,              /* Set option */
+	NULL,              /* Get option */
+	des3_init,         /* init */
+	NULL,              /* reset */
+	des3_uninit,       /* uninit */
+	des3_set_iv,       /* set iv */
+	NULL,              /* append */
+	NULL,              /* digest */
+	des3_encrypt,      /* encrypt */
+	des3_decrypt,      /* decrypt */
+	NULL,              /* set salt */
+	NULL,              /* get salt size */
+	des3_set_key,      /* set key */
+	NULL,              /* get key size */
+	des3_set_batch,    /* set batch mode */
+	des3_get_batch,    /* get batch mode */
+	NULL,              /* get block size */
+	NULL               /* set key with len */
+};
+
+/******************************************************************************
+ * Registration
+ *****************************************************************************/
+PurpleCipherOps *
+purple_des_cipher_get_ops(void) {
+	return &DESOps;
+}
+
+PurpleCipherOps *
+purple_des3_cipher_get_ops(void) {
+	return &DES3Ops;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/ciphers/gchecksum.c	Sat Aug 06 03:45:56 2011 +0000
@@ -0,0 +1,144 @@
+#include <cipher.h>
+
+#if GLIB_CHECK_VERSION(2,16,0)
+
+static void
+purple_g_checksum_init(PurpleCipherContext *context, GChecksumType type)
+{
+    GChecksum *checksum;
+
+    checksum = g_checksum_new(type);
+    purple_cipher_context_set_data(context, checksum);
+}
+
+static void
+purple_g_checksum_reset(PurpleCipherContext *context, GChecksumType type)
+{
+    GChecksum *checksum;
+
+    checksum = purple_cipher_context_get_data(context);
+    g_return_if_fail(checksum != NULL);
+
+#if GLIB_CHECK_VERSION(2,18,0)
+    g_checksum_reset(checksum);
+#else
+    g_checksum_free(checksum);
+    checksum = g_checksum_new(type);
+    purple_cipher_context_set_data(context, checksum);
+#endif
+}
+
+static void
+purple_g_checksum_uninit(PurpleCipherContext *context)
+{
+    GChecksum *checksum;
+
+    checksum = purple_cipher_context_get_data(context);
+    g_return_if_fail(checksum != NULL);
+
+    g_checksum_free(checksum);
+}
+
+static void
+purple_g_checksum_append(PurpleCipherContext *context, const guchar *data,
+                         gsize len)
+{
+    GChecksum *checksum;
+
+    checksum = purple_cipher_context_get_data(context);
+    g_return_if_fail(checksum != NULL);
+
+    while (len >= G_MAXSSIZE) {
+        g_checksum_update(checksum, data, G_MAXSSIZE);
+        len -= G_MAXSSIZE;
+        data += G_MAXSSIZE;
+    }
+
+    if (len)
+        g_checksum_update(checksum, data, len);
+}
+
+static gboolean
+purple_g_checksum_digest(PurpleCipherContext *context, GChecksumType type,
+                         gsize len, guchar *digest, gsize *out_len)
+{
+    GChecksum *checksum;
+    const gssize required_length = g_checksum_type_get_length(type);
+
+    checksum = purple_cipher_context_get_data(context);
+
+    g_return_val_if_fail(len >= required_length, FALSE);
+    g_return_val_if_fail(checksum != NULL, FALSE);
+
+    g_checksum_get_digest(checksum, digest, &len);
+
+    purple_cipher_context_reset(context, NULL);
+
+    if (out_len)
+        *out_len = len;
+
+    return TRUE;
+}
+
+/******************************************************************************
+ * Macros
+ *****************************************************************************/
+#define PURPLE_G_CHECKSUM_IMPLEMENTATION(lower, camel, type, block_size) \
+	static size_t \
+	lower##_get_block_size(PurpleCipherContext *context) { \
+		return (block_size); \
+	} \
+	\
+	static void \
+	lower##_init(PurpleCipherContext *context, gpointer extra) { \
+		purple_g_checksum_init(context, (type)); \
+	} \
+	\
+	static void \
+	lower##_reset(PurpleCipherContext *context, gpointer extra) { \
+		purple_g_checksum_reset(context, (type)); \
+	} \
+	\
+	static gboolean \
+	lower##_digest(PurpleCipherContext *context, gsize in_len, \
+	                 guchar digest[], size_t *out_len) \
+	{ \
+		return purple_g_checksum_digest(context, (type), in_len, digest, \
+		                                out_len); \
+	} \
+	\
+	static PurpleCipherOps camel##Ops = { \
+		NULL,                     /* Set option */       \
+		NULL,                     /* Get option */       \
+		lower##_init,             /* init */             \
+		lower##_reset,            /* reset */            \
+		purple_g_checksum_uninit, /* uninit */           \
+		NULL,                     /* set iv */           \
+		purple_g_checksum_append, /* append */           \
+		lower##_digest,           /* digest */           \
+		NULL,                     /* encrypt */          \
+		NULL,                     /* decrypt */          \
+		NULL,                     /* set salt */         \
+		NULL,                     /* get salt size */    \
+		NULL,                     /* set key */          \
+		NULL,                     /* get key size */     \
+		NULL,                     /* set batch mode */   \
+		NULL,                     /* get batch mode */   \
+		lower##_get_block_size,   /* get block size */   \
+		NULL                      /* set key with len */ \
+	}; \
+	\
+	PurpleCipherOps * \
+	purple_##lower##_cipher_get_ops(void) { \
+		return &camel##Ops; \
+	}
+
+/******************************************************************************
+ * Macro Expansion
+ *****************************************************************************/
+PURPLE_G_CHECKSUM_IMPLEMENTATION(md5, MD5, G_CHECKSUM_MD5, 64);
+PURPLE_G_CHECKSUM_IMPLEMENTATION(sha1, SHA1, G_CHECKSUM_SHA1, 64);
+PURPLE_G_CHECKSUM_IMPLEMENTATION(sha256, SHA256, G_CHECKSUM_SHA256, 64);
+
+#endif /* GLIB_CHECK_VERSION(2,16,0) */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/ciphers/hmac.c	Sat Aug 06 03:45:56 2011 +0000
@@ -0,0 +1,218 @@
+/*
+ * purple
+ *
+ * Purple is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * 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 <cipher.h>
+
+#include <util.h>
+
+struct HMAC_Context {
+	PurpleCipherContext *hash;
+	char *name;
+	int blocksize;
+	guchar *opad;
+};
+
+	static void
+hmac_init(PurpleCipherContext *context, gpointer extra)
+{
+	struct HMAC_Context *hctx;
+	hctx = g_new0(struct HMAC_Context, 1);
+	purple_cipher_context_set_data(context, hctx);
+	purple_cipher_context_reset(context, extra);
+}
+
+	static void
+hmac_reset(PurpleCipherContext *context, gpointer extra)
+{
+	struct HMAC_Context *hctx;
+
+	hctx = purple_cipher_context_get_data(context);
+
+	g_free(hctx->name);
+	hctx->name = NULL;
+	if (hctx->hash)
+		purple_cipher_context_destroy(hctx->hash);
+	hctx->hash = NULL;
+	hctx->blocksize = 0;
+	g_free(hctx->opad);
+	hctx->opad = NULL;
+}
+
+	static void
+hmac_set_opt(PurpleCipherContext *context, const gchar *name, void *value)
+{
+	struct HMAC_Context *hctx;
+
+	hctx = purple_cipher_context_get_data(context);
+
+	if (purple_strequal(name, "hash")) {
+		g_free(hctx->name);
+		if (hctx->hash)
+			purple_cipher_context_destroy(hctx->hash);
+		hctx->name = g_strdup((char*)value);
+		hctx->hash = purple_cipher_context_new_by_name((char *)value, NULL);
+		hctx->blocksize = purple_cipher_context_get_block_size(hctx->hash);
+	}
+}
+
+	static void *
+hmac_get_opt(PurpleCipherContext *context, const gchar *name)
+{
+	struct HMAC_Context *hctx;
+
+	hctx = purple_cipher_context_get_data(context);
+
+	if (purple_strequal(name, "hash")) {
+		return hctx->name;
+	}
+
+	return NULL;
+}
+
+	static void
+hmac_append(PurpleCipherContext *context, const guchar *data, size_t len)
+{
+	struct HMAC_Context *hctx = purple_cipher_context_get_data(context);
+
+	g_return_if_fail(hctx->hash != NULL);
+
+	purple_cipher_context_append(hctx->hash, data, len);
+}
+
+	static gboolean
+hmac_digest(PurpleCipherContext *context, size_t in_len, guchar *out, size_t *out_len)
+{
+	struct HMAC_Context *hctx = purple_cipher_context_get_data(context);
+	PurpleCipherContext *hash = hctx->hash;
+	guchar *inner_hash;
+	size_t hash_len;
+	gboolean result;
+
+	g_return_val_if_fail(hash != NULL, FALSE);
+
+	inner_hash = g_malloc(100); /* TODO: Should be enough for now... */
+	result = purple_cipher_context_digest(hash, 100, inner_hash, &hash_len);
+
+	purple_cipher_context_reset(hash, NULL);
+
+	purple_cipher_context_append(hash, hctx->opad, hctx->blocksize);
+	purple_cipher_context_append(hash, inner_hash, hash_len);
+
+	g_free(inner_hash);
+
+	result = result && purple_cipher_context_digest(hash, in_len, out, out_len);
+
+	return result;
+}
+
+	static void
+hmac_uninit(PurpleCipherContext *context)
+{
+	struct HMAC_Context *hctx;
+
+	purple_cipher_context_reset(context, NULL);
+
+	hctx = purple_cipher_context_get_data(context);
+
+	g_free(hctx);
+}
+
+	static void
+hmac_set_key_with_len(PurpleCipherContext *context, const guchar * key, size_t key_len)
+{
+	struct HMAC_Context *hctx = purple_cipher_context_get_data(context);
+	int blocksize, i;
+	guchar *ipad;
+	guchar *full_key;
+
+	g_return_if_fail(hctx->hash != NULL);
+
+	g_free(hctx->opad);
+
+	blocksize = hctx->blocksize;
+	ipad = g_malloc(blocksize);
+	hctx->opad = g_malloc(blocksize);
+
+	if (key_len > blocksize) {
+		purple_cipher_context_reset(hctx->hash, NULL);
+		purple_cipher_context_append(hctx->hash, key, key_len);
+		full_key = g_malloc(100); /* TODO: Should be enough for now... */
+		purple_cipher_context_digest(hctx->hash, 100, full_key, &key_len);
+	} else
+		full_key = g_memdup(key, key_len);
+
+	if (key_len < blocksize) {
+		full_key = g_realloc(full_key, blocksize);
+		memset(full_key + key_len, 0, blocksize - key_len);
+	}
+
+	for(i = 0; i < blocksize; i++) {
+		ipad[i] = 0x36 ^ full_key[i];
+		hctx->opad[i] = 0x5c ^ full_key[i];
+	}
+
+	g_free(full_key);
+
+	purple_cipher_context_reset(hctx->hash, NULL);
+	purple_cipher_context_append(hctx->hash, ipad, blocksize);
+	g_free(ipad);
+}
+
+	static void
+hmac_set_key(PurpleCipherContext *context, const guchar * key)
+{
+	hmac_set_key_with_len(context, key, strlen((char *)key));
+}
+
+	static size_t
+hmac_get_block_size(PurpleCipherContext *context)
+{
+	struct HMAC_Context *hctx = purple_cipher_context_get_data(context);
+
+	return hctx->blocksize;
+}
+
+static PurpleCipherOps HMACOps = {
+	hmac_set_opt,           /* Set option */
+	hmac_get_opt,           /* Get option */
+	hmac_init,               /* init */
+	hmac_reset,              /* reset */
+	hmac_uninit,             /* uninit */
+	NULL,                   /* set iv */
+	hmac_append,             /* append */
+	hmac_digest,             /* digest */
+	NULL,                   /* encrypt */
+	NULL,                   /* decrypt */
+	NULL,                   /* set salt */
+	NULL,                   /* get salt size */
+	hmac_set_key,           /* set key */
+	NULL,                   /* get key size */
+	NULL,                   /* set batch mode */
+	NULL,                   /* get batch mode */
+	hmac_get_block_size,    /* get block size */
+	hmac_set_key_with_len   /* set key with len */
+};
+
+PurpleCipherOps *
+purple_hmac_cipher_get_ops(void) {
+	return &HMACOps;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/ciphers/md4.c	Sat Aug 06 03:45:56 2011 +0000
@@ -0,0 +1,297 @@
+/*
+ * purple
+ *
+ * Purple is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * Original md4 taken from linux kernel
+ * MD4 Message Digest Algorithm (RFC1320).
+ *
+ * Implementation derived from Andrew Tridgell and Steve French's
+ * CIFS MD4 implementation, and the cryptoapi implementation
+ * originally based on the public domain implementation written
+ * by Colin Plumb in 1993.
+ *
+ * Copyright (c) Andrew Tridgell 1997-1998.
+ * Modified by Steve French (sfrench@us.ibm.com) 2002
+ * Copyright (c) Cryptoapi developers.
+ * Copyright (c) 2002 David S. Miller (davem@redhat.com)
+ * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
+ *
+ * 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 <cipher.h>
+
+#define MD4_DIGEST_SIZE     16
+#define MD4_HMAC_BLOCK_SIZE 64
+#define MD4_BLOCK_WORDS     16
+#define MD4_HASH_WORDS      4
+
+struct MD4_Context {
+	guint32 hash[MD4_HASH_WORDS];
+	guint32 block[MD4_BLOCK_WORDS];
+	guint64 byte_count;
+};
+
+static inline guint32 lshift(guint32 x, unsigned int s)
+{
+	x &= 0xFFFFFFFF;
+	return ((x << s) & 0xFFFFFFFF) | (x >> (32 - s));
+}
+
+static inline guint32 F(guint32 x, guint32 y, guint32 z)
+{
+	return (x & y) | ((~x) & z);
+}
+
+static inline guint32 G(guint32 x, guint32 y, guint32 z)
+{
+	return (x & y) | (x & z) | (y & z);
+}
+
+static inline guint32 H(guint32 x, guint32 y, guint32 z)
+{
+	return x ^ y ^ z;
+}
+
+#define ROUND1(a,b,c,d,k,s) (a = lshift(a + F(b,c,d) + k, s))
+#define ROUND2(a,b,c,d,k,s) (a = lshift(a + G(b,c,d) + k + (guint32)0x5A827999,s))
+#define ROUND3(a,b,c,d,k,s) (a = lshift(a + H(b,c,d) + k + (guint32)0x6ED9EBA1,s))
+
+static inline void le32_to_cpu_array(guint32 *buf, unsigned int words)
+{
+	while (words--) {
+		*buf=GUINT_FROM_LE(*buf);
+		buf++;
+	}
+}
+
+static inline void cpu_to_le32_array(guint32 *buf, unsigned int words)
+{
+	while (words--) {
+		*buf=GUINT_TO_LE(*buf);
+		buf++;
+	}
+}
+
+static void md4_transform(guint32 *hash, guint32 const *in)
+{
+	guint32 a, b, c, d;
+
+	a = hash[0];
+	b = hash[1];
+	c = hash[2];
+	d = hash[3];
+
+	ROUND1(a, b, c, d, in[0], 3);
+	ROUND1(d, a, b, c, in[1], 7);
+	ROUND1(c, d, a, b, in[2], 11);
+	ROUND1(b, c, d, a, in[3], 19);
+	ROUND1(a, b, c, d, in[4], 3);
+	ROUND1(d, a, b, c, in[5], 7);
+	ROUND1(c, d, a, b, in[6], 11);
+	ROUND1(b, c, d, a, in[7], 19);
+	ROUND1(a, b, c, d, in[8], 3);
+	ROUND1(d, a, b, c, in[9], 7);
+	ROUND1(c, d, a, b, in[10], 11);
+	ROUND1(b, c, d, a, in[11], 19);
+	ROUND1(a, b, c, d, in[12], 3);
+	ROUND1(d, a, b, c, in[13], 7);
+	ROUND1(c, d, a, b, in[14], 11);
+	ROUND1(b, c, d, a, in[15], 19);
+
+	ROUND2(a, b, c, d,in[ 0], 3);
+	ROUND2(d, a, b, c, in[4], 5);
+	ROUND2(c, d, a, b, in[8], 9);
+	ROUND2(b, c, d, a, in[12], 13);
+	ROUND2(a, b, c, d, in[1], 3);
+	ROUND2(d, a, b, c, in[5], 5);
+	ROUND2(c, d, a, b, in[9], 9);
+	ROUND2(b, c, d, a, in[13], 13);
+	ROUND2(a, b, c, d, in[2], 3);
+	ROUND2(d, a, b, c, in[6], 5);
+	ROUND2(c, d, a, b, in[10], 9);
+	ROUND2(b, c, d, a, in[14], 13);
+	ROUND2(a, b, c, d, in[3], 3);
+	ROUND2(d, a, b, c, in[7], 5);
+	ROUND2(c, d, a, b, in[11], 9);
+	ROUND2(b, c, d, a, in[15], 13);
+
+	ROUND3(a, b, c, d,in[ 0], 3);
+	ROUND3(d, a, b, c, in[8], 9);
+	ROUND3(c, d, a, b, in[4], 11);
+	ROUND3(b, c, d, a, in[12], 15);
+	ROUND3(a, b, c, d, in[2], 3);
+	ROUND3(d, a, b, c, in[10], 9);
+	ROUND3(c, d, a, b, in[6], 11);
+	ROUND3(b, c, d, a, in[14], 15);
+	ROUND3(a, b, c, d, in[1], 3);
+	ROUND3(d, a, b, c, in[9], 9);
+	ROUND3(c, d, a, b, in[5], 11);
+	ROUND3(b, c, d, a, in[13], 15);
+	ROUND3(a, b, c, d, in[3], 3);
+	ROUND3(d, a, b, c, in[11], 9);
+	ROUND3(c, d, a, b, in[7], 11);
+	ROUND3(b, c, d, a, in[15], 15);
+
+	hash[0] += a;
+	hash[1] += b;
+	hash[2] += c;
+	hash[3] += d;
+}
+
+static inline void md4_transform_helper(struct MD4_Context *ctx)
+{
+	le32_to_cpu_array(ctx->block, sizeof(ctx->block) / sizeof(guint32));
+	md4_transform(ctx->hash, ctx->block);
+}
+
+static void
+md4_init(PurpleCipherContext *context, gpointer extra) {
+	struct MD4_Context *mctx;
+	mctx = g_new0(struct MD4_Context, 1);
+	purple_cipher_context_set_data(context, mctx);
+	purple_cipher_context_reset(context, extra);
+
+	mctx->hash[0] = 0x67452301;
+	mctx->hash[1] = 0xefcdab89;
+	mctx->hash[2] = 0x98badcfe;
+	mctx->hash[3] = 0x10325476;
+	mctx->byte_count = 0;
+}
+
+static void
+md4_reset(PurpleCipherContext *context, gpointer extra) {
+	struct MD4_Context *mctx;
+
+	mctx = purple_cipher_context_get_data(context);
+
+	mctx->hash[0] = 0x67452301;
+	mctx->hash[1] = 0xefcdab89;
+	mctx->hash[2] = 0x98badcfe;
+	mctx->hash[3] = 0x10325476;
+	mctx->byte_count = 0;
+}
+
+	static void
+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);
+
+	mctx->byte_count += len;
+
+	if (avail > len) {
+		memcpy((char *)mctx->block + (sizeof(mctx->block) - avail),
+				data, len);
+		return;
+	}
+
+	memcpy((char *)mctx->block + (sizeof(mctx->block) - avail),
+			data, avail);
+
+	md4_transform_helper(mctx);
+	data += avail;
+	len -= avail;
+
+	while (len >= sizeof(mctx->block)) {
+		memcpy(mctx->block, data, sizeof(mctx->block));
+		md4_transform_helper(mctx);
+		data += sizeof(mctx->block);
+		len -= sizeof(mctx->block);
+	}
+
+	memcpy(mctx->block, data, len);
+}
+
+	static gboolean
+md4_digest(PurpleCipherContext *context, size_t in_len, guchar *out,
+		size_t *out_len)
+{
+	struct MD4_Context *mctx = purple_cipher_context_get_data(context);
+	const unsigned int offset = mctx->byte_count & 0x3f;
+	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;
+	if (padding < 0) {
+		memset(p, 0x00, padding + sizeof (guint64));
+		md4_transform_helper(mctx);
+		p = (char *)mctx->block;
+		padding = 56;
+	}
+
+	memset(p, 0, padding);
+	mctx->block[14] = mctx->byte_count << 3;
+	mctx->block[15] = mctx->byte_count >> 29;
+	le32_to_cpu_array(mctx->block, (sizeof(mctx->block) -
+				sizeof(guint64)) / sizeof(guint32));
+	md4_transform(mctx->hash, mctx->block);
+	cpu_to_le32_array(mctx->hash, sizeof(mctx->hash) / sizeof(guint32));
+	memcpy(out, mctx->hash, sizeof(mctx->hash));
+	memset(mctx, 0, sizeof(*mctx));
+	return TRUE;
+}
+
+static void
+md4_uninit(PurpleCipherContext *context) {
+	struct MD4_Context *md4_context;
+
+	purple_cipher_context_reset(context, NULL);
+
+	md4_context = purple_cipher_context_get_data(context);
+	memset(md4_context, 0, sizeof(*md4_context));
+
+	g_free(md4_context);
+	md4_context = NULL;
+}
+
+	static size_t
+md4_get_block_size(PurpleCipherContext *context)
+{
+	/* This does not change (in this case) */
+	return MD4_HMAC_BLOCK_SIZE;
+}
+
+static PurpleCipherOps MD4Ops = {
+	NULL,                   /* Set option */
+	NULL,                   /* Get option */
+	md4_init,               /* init */
+	md4_reset,              /* reset */
+	md4_uninit,             /* uninit */
+	NULL,                   /* set iv */
+	md4_append,             /* append */
+	md4_digest,             /* digest */
+	NULL,                   /* encrypt */
+	NULL,                   /* decrypt */
+	NULL,                   /* set salt */
+	NULL,                   /* get salt size */
+	NULL,                   /* set key */
+	NULL,                   /* get key size */
+	NULL,                   /* set batch mode */
+	NULL,                   /* get batch mode */
+	md4_get_block_size,     /* get block size */
+	NULL                    /* set key with len */
+};
+
+PurpleCipherOps *
+purple_md4_cipher_get_ops(void) {
+	return &MD4Ops;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/ciphers/md5.c	Sat Aug 06 03:45:56 2011 +0000
@@ -0,0 +1,326 @@
+/*
+ * purple
+ *
+ * Purple is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * Original md5
+ * Copyright (C) 2001-2003  Christophe Devine <c.devine@cr0.net>
+ *
+ * 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 <cipher.h>
+
+#if !GLIB_CHECK_VERSION(2,16,0)
+
+#define MD5_HMAC_BLOCK_SIZE 64
+
+struct MD5Context {
+	guint32 total[2];
+	guint32 state[4];
+	guchar buffer[64];
+};
+
+#define MD5_GET_GUINT32(n,b,i) {            \
+	(n) = ((guint32)(b) [(i)    ]      )    \
+	| ((guint32)(b) [(i) + 1] <<  8)    \
+	| ((guint32)(b) [(i) + 2] << 16)    \
+	| ((guint32)(b) [(i) + 3] << 24);   \
+}
+#define MD5_PUT_GUINT32(n,b,i) {            \
+	(b)[(i)    ] = (guchar)((n)      );     \
+	(b)[(i) + 1] = (guchar)((n) >>  8);     \
+	(b)[(i) + 2] = (guchar)((n) >> 16);     \
+	(b)[(i) + 3] = (guchar)((n) >> 24);     \
+}
+
+static size_t
+md5_get_block_size(PurpleCipherContext *context)
+{
+	/* This does not change (in this case) */
+	return MD5_HMAC_BLOCK_SIZE;
+}
+
+static void
+md5_init(PurpleCipherContext *context, gpointer extra) {
+	struct MD5Context *md5_context;
+
+	md5_context = g_new0(struct MD5Context, 1);
+
+	purple_cipher_context_set_data(context, md5_context);
+
+	purple_cipher_context_reset(context, extra);
+}
+
+static void
+md5_reset(PurpleCipherContext *context, gpointer extra) {
+	struct MD5Context *md5_context;
+
+	md5_context = purple_cipher_context_get_data(context);
+
+	md5_context->total[0] = 0;
+	md5_context->total[1] = 0;
+
+	md5_context->state[0] = 0x67452301;
+	md5_context->state[1] = 0xEFCDAB89;
+	md5_context->state[2] = 0x98BADCFE;
+	md5_context->state[3] = 0x10325476;
+
+	memset(md5_context->buffer, 0, sizeof(md5_context->buffer));
+}
+
+static void
+md5_uninit(PurpleCipherContext *context) {
+	struct MD5Context *md5_context;
+
+	purple_cipher_context_reset(context, NULL);
+
+	md5_context = purple_cipher_context_get_data(context);
+	memset(md5_context, 0, sizeof(*md5_context));
+
+	g_free(md5_context);
+	md5_context = NULL;
+}
+
+static void
+md5_process(struct MD5Context *md5_context, const guchar data[64]) {
+	guint32 X[16], A, B, C, D;
+
+	A = md5_context->state[0];
+	B = md5_context->state[1];
+	C = md5_context->state[2];
+	D = md5_context->state[3];
+
+	MD5_GET_GUINT32(X[ 0], data,  0);
+	MD5_GET_GUINT32(X[ 1], data,  4);
+	MD5_GET_GUINT32(X[ 2], data,  8);
+	MD5_GET_GUINT32(X[ 3], data, 12);
+	MD5_GET_GUINT32(X[ 4], data, 16);
+	MD5_GET_GUINT32(X[ 5], data, 20);
+	MD5_GET_GUINT32(X[ 6], data, 24);
+	MD5_GET_GUINT32(X[ 7], data, 28);
+	MD5_GET_GUINT32(X[ 8], data, 32);
+	MD5_GET_GUINT32(X[ 9], data, 36);
+	MD5_GET_GUINT32(X[10], data, 40);
+	MD5_GET_GUINT32(X[11], data, 44);
+	MD5_GET_GUINT32(X[12], data, 48);
+	MD5_GET_GUINT32(X[13], data, 52);
+	MD5_GET_GUINT32(X[14], data, 56);
+	MD5_GET_GUINT32(X[15], data, 60);
+
+#define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n)))
+#define P(a,b,c,d,k,s,t) {      \
+	a += F(b,c,d) + X[k] + t;   \
+	a = S(a,s) + b;             \
+}
+
+	/* first pass */
+#define F(x,y,z) (z ^ (x & (y ^ z)))
+	P(A, B, C, D,  0,  7, 0xD76AA478);
+	P(D, A, B, C,  1, 12, 0xE8C7B756);
+	P(C, D, A, B,  2, 17, 0x242070DB);
+	P(B, C, D, A,  3, 22, 0xC1BDCEEE);
+	P(A, B, C, D,  4,  7, 0xF57C0FAF);
+	P(D, A, B, C,  5, 12, 0x4787C62A);
+	P(C, D, A, B,  6, 17, 0xA8304613);
+	P(B, C, D, A,  7, 22, 0xFD469501);
+	P(A, B, C, D,  8,  7, 0x698098D8);
+	P(D, A, B, C,  9, 12, 0x8B44F7AF);
+	P(C, D, A, B, 10, 17, 0xFFFF5BB1);
+	P(B, C, D, A, 11, 22, 0x895CD7BE);
+	P(A, B, C, D, 12,  7, 0x6B901122);
+	P(D, A, B, C, 13, 12, 0xFD987193);
+	P(C, D, A, B, 14, 17, 0xA679438E);
+	P(B, C, D, A, 15, 22, 0x49B40821);
+#undef F
+
+	/* second pass */
+#define F(x,y,z) (y ^ (z & (x ^ y)))
+	P(A, B, C, D,  1,  5, 0xF61E2562);
+	P(D, A, B, C,  6,  9, 0xC040B340);
+	P(C, D, A, B, 11, 14, 0x265E5A51);
+	P(B, C, D, A,  0, 20, 0xE9B6C7AA);
+	P(A, B, C, D,  5,  5, 0xD62F105D);
+	P(D, A, B, C, 10,  9, 0x02441453);
+	P(C, D, A, B, 15, 14, 0xD8A1E681);
+	P(B, C, D, A,  4, 20, 0xE7D3FBC8);
+	P(A, B, C, D,  9,  5, 0x21E1CDE6);
+	P(D, A, B, C, 14,  9, 0xC33707D6);
+	P(C, D, A, B,  3, 14, 0xF4D50D87);
+	P(B, C, D, A,  8, 20, 0x455A14ED);
+	P(A, B, C, D, 13,  5, 0xA9E3E905);
+	P(D, A, B, C,  2,  9, 0xFCEFA3F8);
+	P(C, D, A, B,  7, 14, 0x676F02D9);
+	P(B, C, D, A, 12, 20, 0x8D2A4C8A);
+#undef F
+
+	/* third pass */
+#define F(x,y,z) (x ^ y ^ z)
+	P(A, B, C, D,  5,  4, 0xFFFA3942);
+	P(D, A, B, C,  8, 11, 0x8771F681);
+	P(C, D, A, B, 11, 16, 0x6D9D6122);
+	P(B, C, D, A, 14, 23, 0xFDE5380C);
+	P(A, B, C, D,  1,  4, 0xA4BEEA44);
+	P(D, A, B, C,  4, 11, 0x4BDECFA9);
+	P(C, D, A, B,  7, 16, 0xF6BB4B60);
+	P(B, C, D, A, 10, 23, 0xBEBFBC70);
+	P(A, B, C, D, 13,  4, 0x289B7EC6);
+	P(D, A, B, C,  0, 11, 0xEAA127FA);
+	P(C, D, A, B,  3, 16, 0xD4EF3085);
+	P(B, C, D, A,  6, 23, 0x04881D05);
+	P(A, B, C, D,  9,  4, 0xD9D4D039);
+	P(D, A, B, C, 12, 11, 0xE6DB99E5);
+	P(C, D, A, B, 15, 16, 0x1FA27CF8);
+	P(B, C, D, A,  2, 23, 0xC4AC5665);
+#undef F
+
+	/* forth pass */
+#define F(x,y,z) (y ^ (x | ~z))
+	P(A, B, C, D,  0,  6, 0xF4292244);
+	P(D, A, B, C,  7, 10, 0x432AFF97);
+	P(C, D, A, B, 14, 15, 0xAB9423A7);
+	P(B, C, D, A,  5, 21, 0xFC93A039);
+	P(A, B, C, D, 12,  6, 0x655B59C3);
+	P(D, A, B, C,  3, 10, 0x8F0CCC92);
+	P(C, D, A, B, 10, 15, 0xFFEFF47D);
+	P(B, C, D, A,  1, 21, 0x85845DD1);
+	P(A, B, C, D,  8,  6, 0x6FA87E4F);
+	P(D, A, B, C, 15, 10, 0xFE2CE6E0);
+	P(C, D, A, B,  6, 15, 0xA3014314);
+	P(B, C, D, A, 13, 21, 0x4E0811A1);
+	P(A, B, C, D,  4,  6, 0xF7537E82);
+	P(D, A, B, C, 11, 10, 0xBD3AF235);
+	P(C, D, A, B,  2, 15, 0x2AD7D2BB);
+	P(B, C, D, A,  9, 21, 0xEB86D391);
+#undef F
+#undef P
+#undef S
+
+	md5_context->state[0] += A;
+	md5_context->state[1] += B;
+	md5_context->state[2] += C;
+	md5_context->state[3] += D;
+	}
+
+static void
+md5_append(PurpleCipherContext *context, const guchar *data, size_t len) {
+	struct MD5Context *md5_context = NULL;
+	guint32 left = 0, fill = 0;
+
+	g_return_if_fail(context != NULL);
+
+	md5_context = purple_cipher_context_get_data(context);
+	g_return_if_fail(md5_context != NULL);
+
+	left = md5_context->total[0] & 0x3F;
+	fill = 64 - left;
+
+	md5_context->total[0] += len;
+	md5_context->total[0] &= 0xFFFFFFFF;
+
+	if(md5_context->total[0] < len)
+		md5_context->total[1]++;
+
+	if(left && len >= fill) {
+		memcpy((md5_context->buffer + left), data, fill);
+		md5_process(md5_context, md5_context->buffer);
+		len -= fill;
+		data += fill;
+		left = 0;
+	}
+
+	while(len >= 64) {
+		md5_process(md5_context, data);
+		len -= 64;
+		data += 64;
+	}
+
+	if(len) {
+		memcpy((md5_context->buffer + left), data, len);
+	}
+}
+
+	static gboolean
+md5_digest(PurpleCipherContext *context, size_t in_len, guchar digest[16],
+		size_t *out_len)
+{
+	struct MD5Context *md5_context = NULL;
+	guint32 last, pad;
+	guint32 high, low;
+	guchar message[8];
+	guchar padding[64] = {
+		0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+	};
+
+	g_return_val_if_fail(in_len >= 16, FALSE);
+
+	md5_context = purple_cipher_context_get_data(context);
+
+	high = (md5_context->total[0] >> 29)
+		| (md5_context->total[1] << 3);
+	low = (md5_context->total[0] << 3);
+
+	MD5_PUT_GUINT32(low, message, 0);
+	MD5_PUT_GUINT32(high, message, 4);
+
+	last = md5_context->total[0] & 0x3F;
+	pad = (last < 56) ? (56 - last) : (120 - last);
+
+	md5_append(context, padding, pad);
+	md5_append(context, message, 8);
+
+	MD5_PUT_GUINT32(md5_context->state[0], digest, 0);
+	MD5_PUT_GUINT32(md5_context->state[1], digest, 4);
+	MD5_PUT_GUINT32(md5_context->state[2], digest, 8);
+	MD5_PUT_GUINT32(md5_context->state[3], digest, 12);
+
+	if(out_len)
+		*out_len = 16;
+
+	return TRUE;
+}
+
+static PurpleCipherOps MD5Ops = {
+	NULL,			/* Set Option		*/
+	NULL,			/* Get Option		*/
+	md5_init,		/* init				*/
+	md5_reset,		/* reset			*/
+	md5_uninit,	/* uninit			*/
+	NULL,			/* set iv			*/
+	md5_append,	/* append			*/
+	md5_digest,		/* digest			*/
+	NULL,			/* encrypt			*/
+	NULL,			/* decrypt			*/
+	NULL,			/* set salt			*/
+	NULL,			/* get salt size	*/
+	NULL,			/* set key			*/
+	NULL,			/* get key size		*/
+	NULL,			/* set batch mode */
+	NULL,			/* get batch mode */
+	md5_get_block_size,	/* get block size */
+	NULL			/* set key with len */
+};
+
+PurpleCipherOps *
+purple_md5_cipher_get_ops(void) {
+	return &MD5Ops;
+}
+
+#endif /* !GLIB_CHECK_VERSION(2,16,0) */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/ciphers/rc4.c	Sat Aug 06 03:45:56 2011 +0000
@@ -0,0 +1,192 @@
+/*
+ * purple
+ *
+ * Purple is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * 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 <cipher.h>
+#include <util.h>
+
+struct RC4Context {
+	guchar state[256];
+	guchar x;
+	guchar y;
+	gint key_len;
+};
+
+static void
+rc4_init(PurpleCipherContext *context, void *extra) {
+	struct RC4Context *rc4_ctx;
+	rc4_ctx = g_new0(struct RC4Context, 1);
+	purple_cipher_context_set_data(context, rc4_ctx);
+	purple_cipher_context_reset(context, extra);
+}
+
+
+static void
+rc4_reset(PurpleCipherContext *context, void *extra) {
+	struct RC4Context *rc4_ctx;
+	guint i;
+
+	rc4_ctx = purple_cipher_context_get_data(context);
+
+	g_return_if_fail(rc4_ctx);
+
+	for(i = 0; i < 256; i++)
+		rc4_ctx->state[i] = i;
+	rc4_ctx->x = 0;
+	rc4_ctx->y = 0;
+
+	/* default is 5 bytes (40bit key) */
+	rc4_ctx->key_len = 5;
+
+}
+
+static void
+rc4_uninit(PurpleCipherContext *context) {
+	struct RC4Context *rc4_ctx;
+
+	rc4_ctx = purple_cipher_context_get_data(context);
+	memset(rc4_ctx, 0, sizeof(*rc4_ctx));
+
+	g_free(rc4_ctx);
+	rc4_ctx = NULL;
+}
+
+
+
+static void
+rc4_set_key (PurpleCipherContext *context, const guchar * key) {
+	struct RC4Context *ctx;
+	guchar *state;
+	guchar temp_swap;
+	guchar x, y;
+	guint i;
+
+	ctx = purple_cipher_context_get_data(context);
+
+	x = 0;
+	y = 0;
+	state = &ctx->state[0];
+	for(i = 0; i < 256; i++)
+	{
+		y = (key[x] + state[i] + y) % 256;
+		temp_swap = state[i];
+		state[i] = state[y];
+		state[y] = temp_swap;
+		x = (x + 1) % ctx->key_len;
+	}
+}
+
+static void
+rc4_set_opt(PurpleCipherContext *context, const gchar *name, void *value) {
+	struct RC4Context *ctx;
+
+	ctx = purple_cipher_context_get_data(context);
+
+	if(purple_strequal(name, "key_len")) {
+		ctx->key_len = GPOINTER_TO_INT(value);
+	}
+}
+
+static size_t
+rc4_get_key_size (PurpleCipherContext *context)
+{
+	struct RC4Context *ctx;
+
+	g_return_val_if_fail(context, -1);
+
+	ctx = purple_cipher_context_get_data(context);
+
+	g_return_val_if_fail(ctx, -1);
+
+	return ctx->key_len;
+}
+
+static void *
+rc4_get_opt(PurpleCipherContext *context, const gchar *name) {
+	struct RC4Context *ctx;
+
+	ctx = purple_cipher_context_get_data(context);
+
+	if(purple_strequal(name, "key_len")) {
+		return GINT_TO_POINTER(ctx->key_len);
+	}
+
+	return NULL;
+}
+
+static gint
+rc4_encrypt(PurpleCipherContext *context, const guchar data[],
+            size_t len, guchar output[], size_t *outlen) {
+	struct RC4Context *ctx;
+	guchar temp_swap;
+	guchar x, y, z;
+	guchar *state;
+	guint i;
+
+	ctx = purple_cipher_context_get_data(context);
+
+	x = ctx->x;
+	y = ctx->y;
+	state = &ctx->state[0];
+
+	for(i = 0; i < len; i++)
+	{
+		x = (x + 1) % 256;
+		y = (state[x] + y) % 256;
+		temp_swap = state[x];
+		state[x] = state[y];
+		state[y] = temp_swap;
+		z = state[x] + (state[y]) % 256;
+		output[i] = data[i] ^ state[z];
+	}
+	ctx->x = x;
+	ctx->y = y;
+	if(outlen)
+		*outlen = len;
+
+	return 0;
+}
+
+static PurpleCipherOps RC4Ops = {
+	rc4_set_opt,   /* Set Option    */
+	rc4_get_opt,   /* Get Option    */
+	rc4_init,      /* init          */
+	rc4_reset,     /* reset         */
+	rc4_uninit,    /* uninit        */
+	NULL,          /* set iv        */
+	NULL,          /* append        */
+	NULL,          /* digest        */
+	rc4_encrypt,   /* encrypt       */
+	NULL,          /* decrypt       */
+	NULL,          /* set salt      */
+	NULL,          /* get salt size */
+	rc4_set_key,   /* set key       */
+	rc4_get_key_size, /* get key size  */
+	NULL,          /* set batch mode */
+	NULL,          /* get batch mode */
+	NULL,          /* get block size */
+	NULL           /* set key with len */
+};
+
+PurpleCipherOps *
+purple_rc4_cipher_get_ops(void) {
+	return &RC4Ops;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/ciphers/sha1.c	Sat Aug 06 03:45:56 2011 +0000
@@ -0,0 +1,281 @@
+/*
+ * purple
+ *
+ * Purple is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * 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 <cipher.h>
+#include <util.h>
+
+#if !GLIB_CHECK_VERSION(2,16,0)
+
+#define SHA1_HMAC_BLOCK_SIZE    64
+#define SHA1_ROTL(X,n) ((((X) << (n)) | ((X) >> (32-(n)))) & 0xFFFFFFFF)
+
+struct SHA1Context {
+	guint32 H[5];
+	guint32 W[80];
+
+	gint lenW;
+
+	guint32 sizeHi;
+	guint32 sizeLo;
+};
+
+static size_t
+sha1_get_block_size(PurpleCipherContext *context)
+{
+	/* This does not change (in this case) */
+	return SHA1_HMAC_BLOCK_SIZE;
+}
+
+static void
+sha1_hash_block(struct SHA1Context *sha1_ctx) {
+	gint i;
+	guint32 A, B, C, D, E, T;
+
+	for(i = 16; i < 80; i++) {
+		sha1_ctx->W[i] = SHA1_ROTL(sha1_ctx->W[i -  3] ^
+				sha1_ctx->W[i -  8] ^
+				sha1_ctx->W[i - 14] ^
+				sha1_ctx->W[i - 16], 1);
+	}
+
+	A = sha1_ctx->H[0];
+	B = sha1_ctx->H[1];
+	C = sha1_ctx->H[2];
+	D = sha1_ctx->H[3];
+	E = sha1_ctx->H[4];
+
+	for(i = 0; i < 20; i++) {
+		T = (SHA1_ROTL(A, 5) + (((C ^ D) & B) ^ D) + E + sha1_ctx->W[i] + 0x5A827999) & 0xFFFFFFFF;
+		E = D;
+		D = C;
+		C = SHA1_ROTL(B, 30);
+		B = A;
+		A = T;
+	}
+
+	for(i = 20; i < 40; i++) {
+		T = (SHA1_ROTL(A, 5) + (B ^ C ^ D) + E + sha1_ctx->W[i] + 0x6ED9EBA1) & 0xFFFFFFFF;
+		E = D;
+		D = C;
+		C = SHA1_ROTL(B, 30);
+		B = A;
+		A = T;
+	}
+
+	for(i = 40; i < 60; i++) {
+		T = (SHA1_ROTL(A, 5) + ((B & C) | (D & (B | C))) + E + sha1_ctx->W[i] + 0x8F1BBCDC) & 0xFFFFFFFF;
+		E = D;
+		D = C;
+		C = SHA1_ROTL(B, 30);
+		B = A;
+		A = T;
+	}
+
+	for(i = 60; i < 80; i++) {
+		T = (SHA1_ROTL(A, 5) + (B ^ C ^ D) + E + sha1_ctx->W[i] + 0xCA62C1D6) & 0xFFFFFFFF;
+		E = D;
+		D = C;
+		C = SHA1_ROTL(B, 30);
+		B = A;
+		A = T;
+	}
+
+	sha1_ctx->H[0] += A;
+	sha1_ctx->H[1] += B;
+	sha1_ctx->H[2] += C;
+	sha1_ctx->H[3] += D;
+	sha1_ctx->H[4] += E;
+}
+
+static void
+sha1_set_opt(PurpleCipherContext *context, const gchar *name, void *value) {
+	struct SHA1Context *ctx;
+
+	ctx = purple_cipher_context_get_data(context);
+
+	if(purple_strequal(name, "sizeHi")) {
+		ctx->sizeHi = GPOINTER_TO_INT(value);
+	} else if(purple_strequal(name, "sizeLo")) {
+		ctx->sizeLo = GPOINTER_TO_INT(value);
+	} else if(purple_strequal(name, "lenW")) {
+		ctx->lenW = GPOINTER_TO_INT(value);
+	}
+}
+
+static void *
+sha1_get_opt(PurpleCipherContext *context, const gchar *name) {
+	struct SHA1Context *ctx;
+
+	ctx = purple_cipher_context_get_data(context);
+
+	if(purple_strequal(name, "sizeHi")) {
+		return GINT_TO_POINTER(ctx->sizeHi);
+	} else if(purple_strequal(name, "sizeLo")) {
+		return GINT_TO_POINTER(ctx->sizeLo);
+	} else if(purple_strequal(name, "lenW")) {
+		return GINT_TO_POINTER(ctx->lenW);
+	}
+
+	return NULL;
+}
+
+static void
+sha1_init(PurpleCipherContext *context, void *extra) {
+	struct SHA1Context *sha1_ctx;
+
+	sha1_ctx = g_new0(struct SHA1Context, 1);
+
+	purple_cipher_context_set_data(context, sha1_ctx);
+
+	purple_cipher_context_reset(context, extra);
+}
+
+static void
+sha1_reset(PurpleCipherContext *context, void *extra) {
+	struct SHA1Context *sha1_ctx;
+	gint i;
+
+	sha1_ctx = purple_cipher_context_get_data(context);
+
+	g_return_if_fail(sha1_ctx);
+
+	sha1_ctx->lenW = 0;
+	sha1_ctx->sizeHi = 0;
+	sha1_ctx->sizeLo = 0;
+
+	sha1_ctx->H[0] = 0x67452301;
+	sha1_ctx->H[1] = 0xEFCDAB89;
+	sha1_ctx->H[2] = 0x98BADCFE;
+	sha1_ctx->H[3] = 0x10325476;
+	sha1_ctx->H[4] = 0xC3D2E1F0;
+
+	for(i = 0; i < 80; i++)
+		sha1_ctx->W[i] = 0;
+}
+
+static void
+sha1_uninit(PurpleCipherContext *context) {
+	struct SHA1Context *sha1_ctx;
+
+	purple_cipher_context_reset(context, NULL);
+
+	sha1_ctx = purple_cipher_context_get_data(context);
+
+	memset(sha1_ctx, 0, sizeof(struct SHA1Context));
+
+	g_free(sha1_ctx);
+	sha1_ctx = NULL;
+}
+
+static void
+sha1_append(PurpleCipherContext *context, const guchar *data, size_t len) {
+	struct SHA1Context *sha1_ctx;
+	gint i;
+
+	sha1_ctx = purple_cipher_context_get_data(context);
+
+	g_return_if_fail(sha1_ctx);
+
+	for(i = 0; i < len; i++) {
+		sha1_ctx->W[sha1_ctx->lenW / 4] <<= 8;
+		sha1_ctx->W[sha1_ctx->lenW / 4] |= data[i];
+
+		if((++sha1_ctx->lenW) % 64 == 0) {
+			sha1_hash_block(sha1_ctx);
+			sha1_ctx->lenW = 0;
+		}
+
+		sha1_ctx->sizeLo += 8;
+		sha1_ctx->sizeHi += (sha1_ctx->sizeLo < 8);
+	}
+}
+
+static gboolean
+sha1_digest(PurpleCipherContext *context, size_t in_len, guchar digest[20],
+            size_t *out_len)
+{
+	struct SHA1Context *sha1_ctx;
+	guchar pad0x80 = 0x80, pad0x00 = 0x00;
+	guchar padlen[8];
+	gint i;
+
+	g_return_val_if_fail(in_len >= 20, FALSE);
+
+	sha1_ctx = purple_cipher_context_get_data(context);
+
+	g_return_val_if_fail(sha1_ctx, FALSE);
+
+	padlen[0] = (guchar)((sha1_ctx->sizeHi >> 24) & 255);
+	padlen[1] = (guchar)((sha1_ctx->sizeHi >> 16) & 255);
+	padlen[2] = (guchar)((sha1_ctx->sizeHi >> 8) & 255);
+	padlen[3] = (guchar)((sha1_ctx->sizeHi >> 0) & 255);
+	padlen[4] = (guchar)((sha1_ctx->sizeLo >> 24) & 255);
+	padlen[5] = (guchar)((sha1_ctx->sizeLo >> 16) & 255);
+	padlen[6] = (guchar)((sha1_ctx->sizeLo >> 8) & 255);
+	padlen[7] = (guchar)((sha1_ctx->sizeLo >> 0) & 255);
+
+	/* pad with a 1, then zeroes, then length */
+	purple_cipher_context_append(context, &pad0x80, 1);
+	while(sha1_ctx->lenW != 56)
+		purple_cipher_context_append(context, &pad0x00, 1);
+	purple_cipher_context_append(context, padlen, 8);
+
+	for(i = 0; i < 20; i++) {
+		digest[i] = (guchar)(sha1_ctx->H[i / 4] >> 24);
+		sha1_ctx->H[i / 4] <<= 8;
+	}
+
+	purple_cipher_context_reset(context, NULL);
+
+	if(out_len)
+		*out_len = 20;
+
+	return TRUE;
+}
+
+static PurpleCipherOps SHA1Ops = {
+	sha1_set_opt,		/* Set Option		*/
+	sha1_get_opt,		/* Get Option		*/
+	sha1_init,		/* init				*/
+	sha1_reset,		/* reset			*/
+	sha1_uninit,		/* uninit			*/
+	NULL,			/* set iv			*/
+	sha1_append,		/* append			*/
+	sha1_digest,	/* digest			*/
+	NULL,			/* encrypt			*/
+	NULL,			/* decrypt			*/
+	NULL,			/* set salt			*/
+	NULL,			/* get salt size	*/
+	NULL,			/* set key			*/
+	NULL,			/* get key size		*/
+	NULL,			/* set batch mode */
+	NULL,			/* get batch mode */
+	sha1_get_block_size,	/* get block size */
+	NULL			/* set key with len */
+};
+
+PurpleCipherOps *
+purple_sha1_cipher_get_ops(void) {
+	return &SHA1Ops;
+}
+
+#endif /* !GLIB_CHECK_VERSION(2,16,0) */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/ciphers/sha256.c	Sat Aug 06 03:45:56 2011 +0000
@@ -0,0 +1,283 @@
+/*
+ * purple
+ *
+ * Purple is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * 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 <cipher.h>
+
+#if !GLIB_CHECK_VERSION(2,16,0)
+
+#define SHA256_HMAC_BLOCK_SIZE  64
+#define SHA256_ROTR(X,n) ((((X) >> (n)) | ((X) << (32-(n)))) & 0xFFFFFFFF)
+
+static const guint32 sha256_K[64] =
+{
+	0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
+	0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
+	0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
+	0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
+	0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
+	0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
+	0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
+	0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
+};
+
+struct SHA256Context {
+	guint32 H[8];
+	guint32 W[64];
+
+	gint lenW;
+
+	guint32 sizeHi;
+	guint32 sizeLo;
+};
+
+static size_t
+sha256_get_block_size(PurpleCipherContext *context)
+{
+	/* This does not change (in this case) */
+	return SHA256_HMAC_BLOCK_SIZE;
+}
+
+static void
+sha256_hash_block(struct SHA256Context *sha256_ctx) {
+	gint i;
+	guint32 A, B, C, D, E, F, G, H, T1, T2;
+
+	for(i = 16; i < 64; i++) {
+		sha256_ctx->W[i] =
+			  (SHA256_ROTR(sha256_ctx->W[i-2], 17) ^ SHA256_ROTR(sha256_ctx->W[i-2],  19) ^ (sha256_ctx->W[i-2] >> 10))
+			+ sha256_ctx->W[i-7]
+			+ (SHA256_ROTR(sha256_ctx->W[i-15], 7) ^ SHA256_ROTR(sha256_ctx->W[i-15], 18) ^ (sha256_ctx->W[i-15] >> 3))
+			+ sha256_ctx->W[i-16];
+	}
+
+	A = sha256_ctx->H[0];
+	B = sha256_ctx->H[1];
+	C = sha256_ctx->H[2];
+	D = sha256_ctx->H[3];
+	E = sha256_ctx->H[4];
+	F = sha256_ctx->H[5];
+	G = sha256_ctx->H[6];
+	H = sha256_ctx->H[7];
+
+	for(i = 0; i < 64; i++) {
+		T1 = H
+			+ (SHA256_ROTR(E, 6) ^ SHA256_ROTR(E, 11) ^ SHA256_ROTR(E, 25))
+			+ ((E & F) ^ ((~E) & G))
+			+ sha256_K[i] + sha256_ctx->W[i];
+		T2 = (SHA256_ROTR(A, 2) ^ SHA256_ROTR(A, 13) ^ SHA256_ROTR(A, 22))
+			+ ((A & B) ^ (A & C) ^ (B & C));
+		H = G;
+		G = F;
+		F = E;
+		E = D + T1;
+		D = C;
+		C = B;
+		B = A;
+		A = T1 + T2;
+	}
+
+	sha256_ctx->H[0] += A;
+	sha256_ctx->H[1] += B;
+	sha256_ctx->H[2] += C;
+	sha256_ctx->H[3] += D;
+	sha256_ctx->H[4] += E;
+	sha256_ctx->H[5] += F;
+	sha256_ctx->H[6] += G;
+	sha256_ctx->H[7] += H;
+}
+
+static void
+sha256_set_opt(PurpleCipherContext *context, const gchar *name, void *value) {
+	struct SHA256Context *ctx;
+
+	ctx = purple_cipher_context_get_data(context);
+
+	if(!strcmp(name, "sizeHi")) {
+		ctx->sizeHi = GPOINTER_TO_INT(value);
+	} else if(!strcmp(name, "sizeLo")) {
+		ctx->sizeLo = GPOINTER_TO_INT(value);
+	} else if(!strcmp(name, "lenW")) {
+		ctx->lenW = GPOINTER_TO_INT(value);
+	}
+}
+
+static void *
+sha256_get_opt(PurpleCipherContext *context, const gchar *name) {
+	struct SHA256Context *ctx;
+
+	ctx = purple_cipher_context_get_data(context);
+
+	if(!strcmp(name, "sizeHi")) {
+		return GINT_TO_POINTER(ctx->sizeHi);
+	} else if(!strcmp(name, "sizeLo")) {
+		return GINT_TO_POINTER(ctx->sizeLo);
+	} else if(!strcmp(name, "lenW")) {
+		return GINT_TO_POINTER(ctx->lenW);
+	}
+
+	return NULL;
+}
+
+static void
+sha256_init(PurpleCipherContext *context, void *extra) {
+	struct SHA256Context *sha256_ctx;
+
+	sha256_ctx = g_new0(struct SHA256Context, 1);
+
+	purple_cipher_context_set_data(context, sha256_ctx);
+
+	purple_cipher_context_reset(context, extra);
+}
+
+static void
+sha256_reset(PurpleCipherContext *context, void *extra) {
+	struct SHA256Context *sha256_ctx;
+	gint i;
+
+	sha256_ctx = purple_cipher_context_get_data(context);
+
+	g_return_if_fail(sha256_ctx);
+
+	sha256_ctx->lenW = 0;
+	sha256_ctx->sizeHi = 0;
+	sha256_ctx->sizeLo = 0;
+
+	sha256_ctx->H[0] = 0x6a09e667;
+	sha256_ctx->H[1] = 0xbb67ae85;
+	sha256_ctx->H[2] = 0x3c6ef372;
+	sha256_ctx->H[3] = 0xa54ff53a;
+	sha256_ctx->H[4] = 0x510e527f;
+	sha256_ctx->H[5] = 0x9b05688c;
+	sha256_ctx->H[6] = 0x1f83d9ab;
+	sha256_ctx->H[7] = 0x5be0cd19;
+
+	for(i = 0; i < 64; i++)
+		sha256_ctx->W[i] = 0;
+}
+
+static void
+sha256_uninit(PurpleCipherContext *context) {
+	struct SHA256Context *sha256_ctx;
+
+	purple_cipher_context_reset(context, NULL);
+
+	sha256_ctx = purple_cipher_context_get_data(context);
+
+	memset(sha256_ctx, 0, sizeof(struct SHA256Context));
+
+	g_free(sha256_ctx);
+	sha256_ctx = NULL;
+}
+
+static void
+sha256_append(PurpleCipherContext *context, const guchar *data, size_t len) {
+	struct SHA256Context *sha256_ctx;
+	gint i;
+
+	sha256_ctx = purple_cipher_context_get_data(context);
+
+	g_return_if_fail(sha256_ctx);
+
+	for(i = 0; i < len; i++) {
+		sha256_ctx->W[sha256_ctx->lenW / 4] <<= 8;
+		sha256_ctx->W[sha256_ctx->lenW / 4] |= data[i];
+
+		if((++sha256_ctx->lenW) % 64 == 0) {
+			sha256_hash_block(sha256_ctx);
+			sha256_ctx->lenW = 0;
+		}
+
+		sha256_ctx->sizeLo += 8;
+		sha256_ctx->sizeHi += (sha256_ctx->sizeLo < 8);
+	}
+}
+
+static gboolean
+sha256_digest(PurpleCipherContext *context, size_t in_len, guchar digest[32],
+              size_t *out_len)
+{
+	struct SHA256Context *sha256_ctx;
+	guchar pad0x80 = 0x80, pad0x00 = 0x00;
+	guchar padlen[8];
+	gint i;
+
+	g_return_val_if_fail(in_len >= 32, FALSE);
+
+	sha256_ctx = purple_cipher_context_get_data(context);
+
+	g_return_val_if_fail(sha256_ctx, FALSE);
+
+	padlen[0] = (guchar)((sha256_ctx->sizeHi >> 24) & 255);
+	padlen[1] = (guchar)((sha256_ctx->sizeHi >> 16) & 255);
+	padlen[2] = (guchar)((sha256_ctx->sizeHi >> 8) & 255);
+	padlen[3] = (guchar)((sha256_ctx->sizeHi >> 0) & 255);
+	padlen[4] = (guchar)((sha256_ctx->sizeLo >> 24) & 255);
+	padlen[5] = (guchar)((sha256_ctx->sizeLo >> 16) & 255);
+	padlen[6] = (guchar)((sha256_ctx->sizeLo >> 8) & 255);
+	padlen[7] = (guchar)((sha256_ctx->sizeLo >> 0) & 255);
+
+	/* pad with a 1, then zeroes, then length */
+	purple_cipher_context_append(context, &pad0x80, 1);
+	while(sha256_ctx->lenW != 56)
+		purple_cipher_context_append(context, &pad0x00, 1);
+	purple_cipher_context_append(context, padlen, 8);
+
+	for(i = 0; i < 32; i++) {
+		digest[i] = (guchar)(sha256_ctx->H[i / 4] >> 24);
+		sha256_ctx->H[i / 4] <<= 8;
+	}
+
+	purple_cipher_context_reset(context, NULL);
+
+	if(out_len)
+		*out_len = 32;
+
+	return TRUE;
+}
+
+static PurpleCipherOps SHA256Ops = {
+	sha256_set_opt,			/* Set Option		*/
+	sha256_get_opt,			/* Get Option		*/
+	sha256_init,	/* init				*/
+	sha256_reset,	/* reset			*/
+	sha256_uninit,	/* uninit			*/
+	NULL,			/* set iv			*/
+	sha256_append,	/* append			*/
+	sha256_digest,	/* digest			*/
+	NULL,			/* encrypt			*/
+	NULL,			/* decrypt			*/
+	NULL,			/* set salt			*/
+	NULL,			/* get salt size	*/
+	NULL,			/* set key			*/
+	NULL,			/* get key size		*/
+	NULL,			/* set batch mode */
+	NULL,			/* get batch mode */
+	sha256_get_block_size,	/* get block size */
+	NULL			/* set key with len */
+};
+
+PurpleCipherOps *
+purple_sha256_cipher_get_ops(void) {
+	return &SHA256Ops;
+}
+
+#endif /* !GLIB_CHECK_VERSION(2,16,0) */
+
--- a/libpurple/connection.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/connection.c	Sat Aug 06 03:45:56 2011 +0000
@@ -135,7 +135,7 @@
 			!(prpl_info->options & OPT_PROTO_NO_PASSWORD) &&
 			!(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL))
 		{
-			purple_debug_error("connection", "Can not connect to account %s without "
+			purple_debug_error("connection", "Cannot connect to account %s without "
 							 "a password.\n", purple_account_get_username(account));
 			return;
 		}
@@ -210,7 +210,7 @@
 		!(prpl_info->options & OPT_PROTO_NO_PASSWORD) &&
 		!(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL))
 	{
-		purple_debug_error("connection", "Can not connect to account %s without "
+		purple_debug_error("connection", "Cannot connect to account %s without "
 						   "a password.\n", purple_account_get_username(account));
 		return;
 	}
@@ -372,6 +372,7 @@
 		purple_blist_add_account(account);
 
 		purple_signal_emit(purple_connections_get_handle(), "signed-on", gc);
+		purple_signal_emit_return_1(purple_connections_get_handle(), "autojoin", gc);
 
 		serv_set_permit_deny(gc);
 
@@ -515,7 +516,8 @@
 	account = data;
 	gc = purple_account_get_connection(account);
 
-	gc->disconnect_timeout = 0;
+	if (gc != NULL)
+		gc->disconnect_timeout = 0;
 
 	password = g_strdup(purple_account_get_password(account));
 	purple_account_disconnect(account);
@@ -715,6 +717,11 @@
 	                       purple_value_new(PURPLE_TYPE_ENUM),
 	                       purple_value_new(PURPLE_TYPE_STRING));
 
+	purple_signal_register(handle, "autojoin",
+	                       purple_marshal_BOOLEAN__POINTER, NULL, 1,
+	                       purple_value_new(PURPLE_TYPE_SUBTYPE,
+	                                        PURPLE_SUBTYPE_CONNECTION));
+
 }
 
 void
--- a/libpurple/connection.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/connection.h	Sat Aug 06 03:45:56 2011 +0000
@@ -44,8 +44,9 @@
 	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_IMAGES = 0x0080,  /**< Connection does not support sending of images */
-	PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY = 0x0100 /**< Connection supports sending and receiving custom smileys */
-
+	PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY = 0x0100, /**< Connection supports sending and receiving custom smileys */
+	PURPLE_CONNECTION_SUPPORT_MOODS = 0x0200, /**< Connection supports setting moods */
+	PURPLE_CONNECTION_SUPPORT_MOOD_MESSAGES = 0x0400 /**< Connection supports setting a message on moods */
 } PurpleConnectionFlags;
 
 typedef enum
--- a/libpurple/conversation.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/conversation.c	Sat Aug 06 03:45:56 2011 +0000
@@ -70,6 +70,23 @@
 	g_free(hc);
 }
 
+static guint _purple_conversation_user_hash(gconstpointer data)
+{
+	const gchar *name = data;
+	gchar *collated;
+	guint hash;
+
+	collated = g_utf8_collate_key(name, -1);
+	hash     = g_str_hash(collated);
+	g_free(collated);
+	return hash;
+}
+
+static gboolean _purple_conversation_user_equal(gconstpointer a, gconstpointer b)
+{
+	return !g_utf8_collate(a, b);
+}
+
 void
 purple_conversations_set_ui_ops(PurpleConversationUiOps *ops)
 {
@@ -393,6 +410,8 @@
 
 		conv->u.chat = g_new0(PurpleConvChat, 1);
 		conv->u.chat->conv = conv;
+		conv->u.chat->users = g_hash_table_new_full(_purple_conversation_user_hash,
+				_purple_conversation_user_equal, g_free, NULL);
 		PURPLE_DBUS_REGISTER_POINTER(conv->u.chat, PurpleConvChat);
 
 		chats = g_list_prepend(chats, conv);
@@ -547,6 +566,8 @@
 		conv->u.im = NULL;
 	}
 	else if (conv->type == PURPLE_CONV_TYPE_CHAT) {
+		g_hash_table_destroy(conv->u.chat->users);
+		conv->u.chat->users = NULL;
 
 		g_list_foreach(conv->u.chat->in_room, (GFunc)purple_conv_chat_cb_destroy, NULL);
 		g_list_free(conv->u.chat->in_room);
@@ -575,6 +596,7 @@
 
 	if (ops != NULL && ops->destroy_conversation != NULL)
 		ops->destroy_conversation(conv);
+	conv->ui_data = NULL;
 
 	purple_conversation_close_logs(conv);
 
@@ -999,12 +1021,6 @@
 		}
 	}
 
-	if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) {
-		if ((flags & PURPLE_MESSAGE_RECV) == PURPLE_MESSAGE_RECV) {
-			purple_conv_im_set_typing_state(PURPLE_CONV_IM(conv), PURPLE_NOT_TYPING);
-		}
-	}
-
 	if (ops && ops->write_conv)
 		ops->write_conv(conv, who, alias, displayed, flags, mtime);
 
@@ -1124,7 +1140,6 @@
 purple_conv_im_start_typing_timeout(PurpleConvIm *im, int timeout)
 {
 	PurpleConversation *conv;
-	const char *name;
 
 	g_return_if_fail(im != NULL);
 
@@ -1132,7 +1147,6 @@
 		purple_conv_im_stop_typing_timeout(im);
 
 	conv = purple_conv_im_get_conversation(im);
-	name = purple_conversation_get_name(conv);
 
 	im->typing_timeout = purple_timeout_add_seconds(timeout, reset_typing_cb, conv);
 }
@@ -1226,6 +1240,10 @@
 
 	c = purple_conv_im_get_conversation(im);
 
+	if ((flags & PURPLE_MESSAGE_RECV) == PURPLE_MESSAGE_RECV) {
+		purple_conv_im_set_typing_state(im, PURPLE_NOT_TYPING);
+	}
+
 	/* Pass this on to either the ops structure or the default write func. */
 	if (c->ui_ops != NULL && c->ui_ops->write_im != NULL)
 		c->ui_ops->write_im(c, who, message, flags, mtime);
@@ -1520,7 +1538,6 @@
 	PurpleAccount *account;
 	PurpleConversation *conv;
 	PurpleConnection *gc;
-	PurplePluginProtocolInfo *prpl_info;
 
 	g_return_if_fail(chat != NULL);
 	g_return_if_fail(who != NULL);
@@ -1529,7 +1546,6 @@
 	conv      = purple_conv_chat_get_conversation(chat);
 	gc        = purple_conversation_get_gc(conv);
 	account   = purple_connection_get_account(gc);
-	prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc));
 
 	/* Don't display this if the person who wrote it is ignored. */
 	if (purple_conv_chat_is_user_ignored(chat, who))
@@ -1682,9 +1698,9 @@
 
 		cbuddy = purple_conv_chat_cb_new(user, alias, flag);
 		cbuddy->buddy = purple_find_buddy(conv->account, user) != NULL;
-		/* This seems dumb. Why should we set users thousands of times? */
-		purple_conv_chat_set_users(chat,
-				g_list_prepend(chat->in_room, cbuddy));
+
+		chat->in_room = g_list_prepend(chat->in_room, cbuddy);
+		g_hash_table_replace(chat->users, g_strdup(cbuddy->name), cbuddy);
 
 		cbuddies = g_list_prepend(cbuddies, cbuddy);
 
@@ -1776,8 +1792,9 @@
 	flags = purple_conv_chat_user_get_flags(chat, old_user);
 	cb = purple_conv_chat_cb_new(new_user, new_alias, flags);
 	cb->buddy = purple_find_buddy(conv->account, new_user) != NULL;
-	purple_conv_chat_set_users(chat,
-		g_list_prepend(chat->in_room, cb));
+
+	chat->in_room = g_list_prepend(chat->in_room, cb);
+	g_hash_table_replace(chat->users, g_strdup(cb->name), cb);
 
 	if (ops != NULL && ops->chat_rename_user != NULL)
 		ops->chat_rename_user(conv, old_user, new_user, new_alias);
@@ -1785,8 +1802,8 @@
 	cb = purple_conv_chat_cb_find(chat, old_user);
 
 	if (cb) {
-		purple_conv_chat_set_users(chat,
-				g_list_remove(chat->in_room, cb));
+		chat->in_room = g_list_remove(chat->in_room, cb);
+		g_hash_table_remove(chat->users, cb->name);
 		purple_conv_chat_cb_destroy(cb);
 	}
 
@@ -1879,8 +1896,8 @@
 		cb = purple_conv_chat_cb_find(chat, user);
 
 		if (cb) {
-			purple_conv_chat_set_users(chat,
-					g_list_remove(chat->in_room, cb));
+			chat->in_room = g_list_remove(chat->in_room, cb);
+			g_hash_table_remove(chat->users, cb->name);
 			purple_conv_chat_cb_destroy(cb);
 		}
 
@@ -1960,8 +1977,10 @@
 		purple_conv_chat_cb_destroy(cb);
 	}
 
+	g_hash_table_remove_all(chat->users);
+
 	g_list_free(users);
-	purple_conv_chat_set_users(chat, NULL);
+	chat->in_room = NULL;
 }
 
 
@@ -2141,6 +2160,8 @@
 	cb->name = g_strdup(name);
 	cb->flags = flags;
 	cb->alias = g_strdup(alias);
+	cb->attributes = g_hash_table_new_full(g_str_hash, g_str_equal,
+										   g_free, g_free);
 
 	PURPLE_DBUS_REGISTER_POINTER(cb, PurpleConvChatBuddy);
 	return cb;
@@ -2149,19 +2170,10 @@
 PurpleConvChatBuddy *
 purple_conv_chat_cb_find(PurpleConvChat *chat, const char *name)
 {
-	GList *l;
-	PurpleConvChatBuddy *cb = NULL;
-
 	g_return_val_if_fail(chat != NULL, NULL);
 	g_return_val_if_fail(name != NULL, NULL);
 
-	for (l = purple_conv_chat_get_users(chat); l; l = l->next) {
-		cb = l->data;
-		if (!g_utf8_collate(cb->name, name))
-			return cb;
-	}
-
-	return NULL;
+	return g_hash_table_lookup(chat->users, name);
 }
 
 void
@@ -2170,9 +2182,13 @@
 	if (cb == NULL)
 		return;
 
+	purple_signal_emit(purple_conversations_get_handle(),
+			"deleting-chat-buddy", cb);
+
 	g_free(cb->alias);
 	g_free(cb->alias_key);
 	g_free(cb->name);
+	g_hash_table_destroy(cb->attributes);
 
 	PURPLE_DBUS_UNREGISTER_POINTER(cb);
 	g_free(cb);
@@ -2186,6 +2202,76 @@
 	return cb->name;
 }
 
+const char *
+purple_conv_chat_cb_get_attribute(PurpleConvChatBuddy *cb, const char *key)
+{
+	g_return_val_if_fail(cb != NULL, NULL);
+	g_return_val_if_fail(key != NULL, NULL);
+	
+	return g_hash_table_lookup(cb->attributes, key);
+}
+
+static void
+append_attribute_key(gpointer key, gpointer value, gpointer user_data)
+{
+	GList **list = user_data;
+	*list = g_list_prepend(*list, key);
+}
+
+GList *
+purple_conv_chat_cb_get_attribute_keys(PurpleConvChatBuddy *cb)
+{
+	GList *keys = NULL;
+	
+	g_return_val_if_fail(cb != NULL, NULL);
+	
+	g_hash_table_foreach(cb->attributes, (GHFunc)append_attribute_key, &keys);
+	
+	return keys;
+}
+
+void
+purple_conv_chat_cb_set_attribute(PurpleConvChat *chat, PurpleConvChatBuddy *cb, const char *key, const char *value)
+{
+	PurpleConversation *conv;
+	PurpleConversationUiOps *ops;
+	
+	g_return_if_fail(cb != NULL);
+	g_return_if_fail(key != NULL);
+	g_return_if_fail(value != NULL);
+	
+	g_hash_table_replace(cb->attributes, g_strdup(key), g_strdup(value));
+	
+	conv = purple_conv_chat_get_conversation(chat);
+	ops = purple_conversation_get_ui_ops(conv);
+	
+	if (ops != NULL && ops->chat_update_user != NULL)
+		ops->chat_update_user(conv, cb->name);
+}
+
+void
+purple_conv_chat_cb_set_attributes(PurpleConvChat *chat, PurpleConvChatBuddy *cb, GList *keys, GList *values)
+{
+	PurpleConversation *conv;
+	PurpleConversationUiOps *ops;
+	
+	g_return_if_fail(cb != NULL);
+	g_return_if_fail(keys != NULL);
+	g_return_if_fail(values != NULL);
+	
+	while (keys != NULL && values != NULL) {
+		g_hash_table_replace(cb->attributes, g_strdup(keys->data), g_strdup(values->data));
+		keys = g_list_next(keys);
+		values = g_list_next(values);
+	}
+	
+	conv = purple_conv_chat_get_conversation(chat);
+	ops = purple_conversation_get_ui_ops(conv);
+	
+	if (ops != NULL && ops->chat_update_user != NULL)
+		ops->chat_update_user(conv, cb->name);
+}
+
 GList *
 purple_conversation_get_extended_menu(PurpleConversation *conv)
 {
@@ -2203,6 +2289,9 @@
 	GList *list = conv->message_history;
 	message_history_free(list);
 	conv->message_history = NULL;
+
+	purple_signal_emit(purple_conversations_get_handle(),
+			"cleared-message-history", conv);
 }
 
 GList *purple_conversation_get_message_history(PurpleConversation *conv)
@@ -2303,6 +2392,26 @@
 										PURPLE_SUBTYPE_CONVERSATION),
 						 purple_value_new(PURPLE_TYPE_UINT));
 
+	purple_signal_register(handle, "sent-attention",
+						 purple_marshal_VOID__POINTER_POINTER_POINTER_UINT,
+						 NULL, 4,
+						 purple_value_new(PURPLE_TYPE_SUBTYPE,
+										PURPLE_SUBTYPE_ACCOUNT),
+						 purple_value_new(PURPLE_TYPE_STRING),
+						 purple_value_new(PURPLE_TYPE_SUBTYPE,
+										PURPLE_SUBTYPE_CONVERSATION),
+						 purple_value_new(PURPLE_TYPE_UINT));
+
+	purple_signal_register(handle, "got-attention",
+						 purple_marshal_VOID__POINTER_POINTER_POINTER_UINT,
+						 NULL, 4,
+						 purple_value_new(PURPLE_TYPE_SUBTYPE,
+										PURPLE_SUBTYPE_ACCOUNT),
+						 purple_value_new(PURPLE_TYPE_STRING),
+						 purple_value_new(PURPLE_TYPE_SUBTYPE,
+										PURPLE_SUBTYPE_CONVERSATION),
+						 purple_value_new(PURPLE_TYPE_UINT));
+
 	purple_signal_register(handle, "sending-im-msg",
 						 purple_marshal_VOID__POINTER_POINTER_POINTER,
 						 NULL, 3,
@@ -2482,6 +2591,11 @@
 						 purple_value_new(PURPLE_TYPE_STRING),
 						 purple_value_new(PURPLE_TYPE_STRING));
 
+	purple_signal_register(handle, "deleting-chat-buddy",
+						 purple_marshal_VOID__POINTER, NULL, 1,
+						 purple_value_new(PURPLE_TYPE_SUBTYPE,
+										PURPLE_SUBTYPE_CHATBUDDY));
+
 	purple_signal_register(handle, "chat-inviting-user",
 						 purple_marshal_VOID__POINTER_POINTER_POINTER, NULL, 3,
 						 purple_value_new(PURPLE_TYPE_SUBTYPE,
@@ -2539,6 +2653,11 @@
 						 purple_value_new(PURPLE_TYPE_STRING),
 						 purple_value_new(PURPLE_TYPE_STRING));
 
+	purple_signal_register(handle, "cleared-message-history",
+	                       purple_marshal_VOID__POINTER, NULL, 1,
+	                       purple_value_new(PURPLE_TYPE_SUBTYPE,
+	                                        PURPLE_SUBTYPE_CONVERSATION));
+
 	purple_signal_register(handle, "conversation-extended-menu",
 			     purple_marshal_VOID__POINTER_POINTER, NULL, 2,
 			     purple_value_new(PURPLE_TYPE_SUBTYPE,
--- a/libpurple/conversation.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/conversation.h	Sat Aug 06 03:45:56 2011 +0000
@@ -139,7 +139,8 @@
 	PURPLE_CBFLAGS_HALFOP        = 0x0002, /**< Half-op                      */
 	PURPLE_CBFLAGS_OP            = 0x0004, /**< Channel Op or Moderator      */
 	PURPLE_CBFLAGS_FOUNDER       = 0x0008, /**< Channel Founder              */
-	PURPLE_CBFLAGS_TYPING        = 0x0010  /**< Currently typing             */
+	PURPLE_CBFLAGS_TYPING        = 0x0010, /**< Currently typing             */
+	PURPLE_CBFLAGS_AWAY          = 0x0020  /**< Currently away. @since 2.8.0 */
 
 } PurpleConvChatBuddyFlags;
 
@@ -270,7 +271,9 @@
 {
 	PurpleConversation *conv;          /**< The parent conversation.      */
 
-	GList *in_room;                  /**< The users in the room.        */
+	GList *in_room;                  /**< The users in the room.
+	                                  *   @deprecated Will be removed in 3.0.0
+									  */
 	GList *ignored;                  /**< Ignored users.                */
 	char  *who;                      /**< The person who set the topic. */
 	char  *topic;                    /**< The topic.                    */
@@ -278,6 +281,9 @@
 	char *nick;                      /**< Your nick in this chat.       */
 
 	gboolean left;                   /**< We left the chat and kept the window open */
+	GHashTable *users;               /**< Hash table of the users in the room.
+	                                  *   @since 2.9.0
+	                                  */
 };
 
 /**
@@ -300,6 +306,10 @@
 	PurpleConvChatBuddyFlags flags;  /**< A bitwise OR of flags for this participant,
 	                                  *   such as whether they are a channel operator.
 	                                  */
+	GHashTable *attributes;          /**< A hash table of attributes about the user, such as
+                                    *   real name, user@host, etc.
+                                    */
+	gpointer ui_data;                /** < The UI can put whatever it wants here. */
 };
 
 /**
@@ -513,6 +523,46 @@
 const char *purple_conversation_get_name(const PurpleConversation *conv);
 
 /**
+ * Get an attribute of a chat buddy
+ *
+ * @param cb	The chat buddy.
+ * @param key	The key of the attribute.
+ *
+ * @return The value of the attribute key.
+ */
+const char *purple_conv_chat_cb_get_attribute(PurpleConvChatBuddy *cb, const char *key);
+
+/**
+ * Get the keys of all atributes of a chat buddy
+ *
+ * @param cb	The chat buddy.
+ *
+ * @return A list of the attributes of a chat buddy.
+ */
+GList *purple_conv_chat_cb_get_attribute_keys(PurpleConvChatBuddy *cb);
+	
+/**
+ * Set an attribute of a chat buddy
+ *
+ * @param chat	The chat.
+ * @param cb	The chat buddy.
+ * @param key	The key of the attribute.
+ * @param value	The value of the attribute.
+ */
+void purple_conv_chat_cb_set_attribute(PurpleConvChat *chat, PurpleConvChatBuddy *cb, const char *key, const char *value);
+
+/**
+ * Set attributes of a chat buddy
+ *
+ * @param chat	The chat.
+ * @param cb	The chat buddy.
+ * @param keys	A GList of the keys.
+ * @param values A GList of the values.
+ */
+void
+purple_conv_chat_cb_set_attributes(PurpleConvChat *chat, PurpleConvChatBuddy *cb, GList *keys, GList *values);
+
+/**
  * Enables or disables logging for this conversation.
  *
  * @param conv The conversation.
@@ -646,7 +696,6 @@
 		const char *message, PurpleMessageFlags flags,
 		time_t mtime);
 
-
 /**
 	Set the features as supported for the given conversation.
 	@param conv      The conversation
@@ -1022,6 +1071,8 @@
  * @param users The list of users.
  *
  * @return The list passed.
+ *
+ * @deprecated This function will be removed in 3.0.0.  You shouldn't be using it anyway.
  */
 GList *purple_conv_chat_set_users(PurpleConvChat *chat, GList *users);
 
--- a/libpurple/core.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/core.c	Sat Aug 06 03:45:56 2011 +0000
@@ -496,7 +496,6 @@
 			if (purple_strequal(entry, "logs"))
 			{
 				char *link;
-#if GLIB_CHECK_VERSION(2,4,0)
 				err = NULL;
 
 				if ((link = g_file_read_link(name, &err)) == NULL)
@@ -512,27 +511,6 @@
 					g_free(old_user_dir);
 					return FALSE;
 				}
-#else
-				char buf[MAXPATHLEN];
-				size_t linklen;
-
-				if ((linklen = readlink(name, buf, sizeof(buf) - 1) == -1))
-				{
-					char *name_utf8 = g_filename_to_utf8(name, -1, NULL, NULL, NULL);
-					purple_debug_error("core", "Error reading symlink %s: %s. Please report this at " PURPLE_DEVEL_WEBSITE "\n",
-					                   name_utf8, g_strerror(errno));
-					g_free(name_utf8);
-					g_free(name);
-					g_dir_close(dir);
-					g_free(status_file);
-					g_free(old_user_dir);
-					return FALSE;
-				}
-				buf[linklen] = '\0';
-
-				/* This way we don't have to GLIB_VERSION_CHECK every g_free(link) below. */
-				link = g_strdup(buf);
-#endif
 
 				logs_dir = g_build_filename(user_dir, "logs", NULL);
 
--- a/libpurple/core.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/core.h	Sat Aug 06 03:45:56 2011 +0000
@@ -201,7 +201,7 @@
  *   <dd>the type of UI. Possible values include 'pc', 'console', 'phone',
  *       'handheld', 'web', and 'bot'. These values are compared
  *       programmatically and should not be localized.</dd>
- *   
+ *
  * </dl>
  *
  * @return A GHashTable with strings for keys and values.  This
--- a/libpurple/dbus-analyze-functions.py	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/dbus-analyze-functions.py	Sat Aug 06 03:45:56 2011 +0000
@@ -3,7 +3,7 @@
 import sys
 
 # types translated into "int"
-simpletypes = ["int", "gint", "guint", "gboolean", "gpointer", "size_t", "gssize", "time_t"]
+simpletypes = ["int", "gint", "guint", "gboolean", "size_t", "gssize", "time_t"]
 
 # List "excluded" contains functions that shouldn't be exported via
 # DBus.  If you remove a function from this list, please make sure
@@ -170,7 +170,7 @@
                 return self.inputpurplestructure(type, name)
 
             # special case for *_get_data functions, be careful here...
-            elif (type[0] == "size_t") and (name == "len"):
+            elif (type[0] == "size_t" or type[0] == "gsize") and name == "len":
                 return self.inputgetdata(type, name)
             
             # unknown pointers are always replaced with NULL
--- a/libpurple/dbus-analyze-signals.py	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/dbus-analyze-signals.py	Sat Aug 06 03:45:56 2011 +0000
@@ -32,7 +32,7 @@
         continue
 
     signal = nameregex.sub(lambda x:x.group()[1].upper(), '-'+signal)
-    print "\"<signal name='%s'>\\n\""%signal
+    print "\"    <signal name='%s'>\\n\""%signal
 
     args = marshal.split('_')
     # ['purple', 'marshal', <return type>, '', args...]
@@ -52,9 +52,9 @@
                 type = 't'
             elif arg == "BOOLEAN":
                 type = 'b'
-            print "\"<arg type='%s'/>\\n\""%type
+            print "\"      <arg type='%s'/>\\n\""%type
 
-    print "\"</signal>\\n\""
+    print "\"    </signal>\\n\""
 
 print ";"
 
--- a/libpurple/dbus-server.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/dbus-server.c	Sat Aug 06 03:45:56 2011 +0000
@@ -501,7 +501,9 @@
 
 	g_string_append(str, "<!DOCTYPE node PUBLIC '-//freedesktop//DTD D-BUS Object Introspection 1.0//EN' 'http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd'>\n");
 	g_string_append_printf(str, "<node name='%s'>\n", DBUS_PATH_PURPLE);
-	g_string_append_printf(str, "<interface name='%s'>\n", DBUS_INTERFACE_PURPLE);
+	g_string_append(str, "  <interface name='org.freedesktop.DBus.Introspectable'>\n    <method name='Introspect'>\n      <arg name='data' direction='out' type='s'/>\n    </method>\n  </interface>\n\n");
+
+	g_string_append_printf(str, "  <interface name='%s'>\n", DBUS_INTERFACE_PURPLE);
 
 	bindings_list = NULL;
 	purple_signal_emit(purple_dbus_get_handle(), "dbus-introspect", &bindings_list);
@@ -517,7 +519,7 @@
 		{
 			const char *text;
 
-			g_string_append_printf(str, "<method name='%s'>\n", bindings[i].name);
+			g_string_append_printf(str, "    <method name='%s'>\n", bindings[i].name);
 
 			text = bindings[i].parameters;
 			while (*text)
@@ -529,10 +531,10 @@
 				name = dbus_gettext(&text);
 
 				g_string_append_printf(str,
-						"<arg name='%s' type='%s' direction='%s'/>\n",
+						"      <arg name='%s' type='%s' direction='%s'/>\n",
 						name, type, direction);
 			}
-			g_string_append(str, "</method>\n");
+			g_string_append(str, "    </method>\n");
 		}
 	}
 
@@ -549,7 +551,7 @@
 	}
 	g_string_append(str, signals);
 
-	g_string_append(str, "</interface>\n</node>\n");
+	g_string_append(str, "  </interface>\n</node>\n");
 
 	reply = dbus_message_new_method_return(message);
 	dbus_message_append_args(reply, DBUS_TYPE_STRING, &(str->str),
@@ -568,10 +570,8 @@
 			"dbus-method-called", connection, message))
 		return DBUS_HANDLER_RESULT_HANDLED;
 
-	if (dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_METHOD_CALL &&
-			dbus_message_has_path(message, DBUS_PATH_PURPLE) &&
-			dbus_message_has_interface(message, DBUS_INTERFACE_INTROSPECTABLE) &&
-			dbus_message_has_member(message, "Introspect"))
+	if (dbus_message_is_method_call(message, DBUS_INTERFACE_INTROSPECTABLE, "Introspect") &&
+			dbus_message_has_path(message, DBUS_PATH_PURPLE))
 	{
 		DBusMessage *reply;
 		reply = purple_dbus_introspect(message);
--- a/libpurple/debug.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/debug.h	Sat Aug 06 03:45:56 2011 +0000
@@ -176,20 +176,24 @@
 gboolean purple_debug_is_verbose(void);
 
 /**
- * Enable or disable verbose debugging.  This ordinarily should only be called
+ * Enable or disable unsafe debugging.  This ordinarily should only be called
  * by #purple_debug_init, but there are cases where this can be useful for
  * plugins.
  *
- * @param unsafe  TRUE to enable verbose debugging or FALSE to disable it.
+ * @param unsafe TRUE to enable debug logging of messages that could
+ *        potentially contain passwords and other sensitive information.
+ *        FALSE to disable it.
  *
  * @since 2.6.0
  */
 void purple_debug_set_unsafe(gboolean unsafe);
 
 /**
- * Check if unsafe debugging is enabled.
+ * Check if unsafe debugging is enabled.  Defaults to FALSE.
  *
- * @return TRUE if verbose debugging is enabled, FALSE if it is not.
+ * @return TRUE if the debug logging of all messages is enabled, FALSE
+ *         if messages that could potentially contain passwords and other
+ *         sensitive information are not logged.
  *
  * @since 2.6.0
  */
--- a/libpurple/desktopitem.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/desktopitem.c	Sat Aug 06 03:45:56 2011 +0000
@@ -330,7 +330,7 @@
 	if (c == EOF && pos == 0)
 		return NULL;
 
-	buf[pos++] = '\0';
+	buf[pos] = '\0';
 
 	return buf;
 }
--- a/libpurple/dnsquery.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/dnsquery.c	Sat Aug 06 03:45:56 2011 +0000
@@ -24,6 +24,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
  *
  */
+#define _PURPLE_DNSQUERY_C_
 
 #include "internal.h"
 #include "debug.h"
@@ -54,6 +55,7 @@
 	PurpleDnsQueryConnectFunction callback;
 	gpointer data;
 	guint timeout;
+	PurpleAccount *account;
 
 #if defined(PURPLE_DNSQUERY_USE_FORK)
 	PurpleDnsQueryResolverProcess *resolver;
@@ -153,6 +155,7 @@
 resolve_ip(PurpleDnsQueryData *query_data)
 {
 	struct sockaddr_in sin;
+	/* TODO: Use inet_pton for IPv6 support */
 	if (inet_aton(query_data->hostname, &sin.sin_addr))
 	{
 		/*
@@ -341,20 +344,17 @@
 		}
 		freeaddrinfo(tmp);
 #else
-		if (!inet_aton(hostname, &sin.sin_addr)) {
-			struct hostent *hp;
-			if (!(hp = gethostbyname(hostname))) {
-				write_to_parent(child_out, &h_errno, sizeof(int));
-				close(child_out);
-				if (show_debug)
-					printf("DNS Error: %d\n", h_errno);
-				_exit(0);
-			}
-			memset(&sin, 0, sizeof(struct sockaddr_in));
-			memcpy(&sin.sin_addr.s_addr, hp->h_addr, hp->h_length);
-			sin.sin_family = hp->h_addrtype;
-		} else
-			sin.sin_family = AF_INET;
+		struct hostent *hp;
+		if (!(hp = gethostbyname(hostname))) {
+			write_to_parent(child_out, &h_errno, sizeof(int));
+			close(child_out);
+			if (show_debug)
+				printf("DNS Error: %d\n", h_errno);
+			_exit(0);
+		}
+		memset(&sin, 0, sizeof(struct sockaddr_in));
+		memcpy(&sin.sin_addr.s_addr, hp->h_addr, hp->h_length);
+		sin.sin_family = hp->h_addrtype;
 
 		sin.sin_port = htons(dns_params.port);
 		rc = 0;
@@ -669,62 +669,12 @@
 	handle_next_queued_request();
 }
 
-static gboolean
-resolve_host(gpointer data)
+static void
+resolve_host(PurpleDnsQueryData *query_data)
 {
-	PurpleDnsQueryData *query_data;
-
-	query_data = data;
-	query_data->timeout = 0;
-
-	if (resolve_ip(query_data))
-	{
-		/* resolve_ip calls purple_dnsquery_resolved */
-		return FALSE;
-	}
-
-	if (purple_dnsquery_ui_resolve(query_data))
-	{
-		/* The UI is handling the resolve; we're done */
-		return FALSE;
-	}
-
 	queued_requests = g_slist_append(queued_requests, query_data);
 
 	handle_next_queued_request();
-
-	return FALSE;
-}
-
-PurpleDnsQueryData *
-purple_dnsquery_a(const char *hostname, int port,
-				PurpleDnsQueryConnectFunction callback, gpointer data)
-{
-	PurpleDnsQueryData *query_data;
-
-	g_return_val_if_fail(hostname != NULL, NULL);
-	g_return_val_if_fail(port	  != 0, NULL);
-	g_return_val_if_fail(callback != NULL, NULL);
-
-	query_data = g_new(PurpleDnsQueryData, 1);
-	query_data->hostname = g_strdup(hostname);
-	g_strstrip(query_data->hostname);
-	query_data->port = port;
-	query_data->callback = callback;
-	query_data->data = data;
-	query_data->resolver = NULL;
-
-	if (*query_data->hostname == '\0')
-	{
-		purple_dnsquery_destroy(query_data);
-		g_return_val_if_reached(NULL);
-	}
-
-	purple_debug_info("dns", "DNS query for '%s' queued\n", query_data->hostname);
-
-	query_data->timeout = purple_timeout_add(0, resolve_host, query_data);
-
-	return query_data;
 }
 
 #elif defined _WIN32 /* end PURPLE_DNSQUERY_USE_FORK  */
@@ -837,50 +787,116 @@
 	return 0;
 }
 
+static void
+resolve_host(PurpleDnsQueryData *query_data)
+{
+	GError *err = NULL;
+
+	/*
+	 * Spin off a separate thread to perform the DNS lookup so
+	 * that we don't block the UI.
+	 */
+	query_data->resolver = g_thread_create(dns_thread,
+			query_data, FALSE, &err);
+	if (query_data->resolver == NULL)
+	{
+		char message[1024];
+		g_snprintf(message, sizeof(message), _("Thread creation failure: %s"),
+				(err && err->message) ? err->message : _("Unknown reason"));
+		g_error_free(err);
+		purple_dnsquery_failed(query_data, message);
+	}
+}
+
+#else /* not PURPLE_DNSQUERY_USE_FORK or _WIN32 */
+
+/*
+ * We weren't able to do anything fancier above, so use the
+ * fail-safe name resolution code, which is blocking.
+ */
+
+static void
+resolve_host(PurpleDnsQueryData *query_data)
+{
+	struct sockaddr_in sin;
+	GSList *hosts = NULL;
+	struct hostent *hp;
+	gchar *hostname;
+#ifdef USE_IDN
+	if (!dns_str_is_ascii(query_data->hostname)) {
+		int ret = purple_network_convert_idn_to_ascii(query_data->hostname,
+				&hostname);
+		if (ret != 0) {
+			char message[1024];
+			g_snprintf(message, sizeof(message), _("Error resolving %s: %d"),
+					query_data->hostname, ret);
+			purple_dnsquery_failed(query_data, message);
+			return;
+		}
+	} else /* fallthrough is intentional to the g_strdup */
+#endif
+	hostname = g_strdup(query_data->hostname);
+
+	if(!(hp = gethostbyname(hostname))) {
+		char message[1024];
+		g_snprintf(message, sizeof(message), _("Error resolving %s: %d"),
+				query_data->hostname, h_errno);
+		purple_dnsquery_failed(query_data, message);
+		g_free(hostname);
+		return;
+	}
+	memset(&sin, 0, sizeof(struct sockaddr_in));
+	memcpy(&sin.sin_addr.s_addr, hp->h_addr, hp->h_length);
+	sin.sin_family = hp->h_addrtype;
+	g_free(hostname);
+	sin.sin_port = htons(query_data->port);
+
+	hosts = g_slist_append(hosts, GINT_TO_POINTER(sizeof(sin)));
+	hosts = g_slist_append(hosts, g_memdup(&sin, sizeof(sin)));
+
+	purple_dnsquery_resolved(query_data, hosts);
+}
+
+#endif /* not PURPLE_DNSQUERY_USE_FORK or _WIN32 */
+
 static gboolean
-resolve_host(gpointer data)
+initiate_resolving(gpointer data)
 {
 	PurpleDnsQueryData *query_data;
-	GError *err = NULL;
+	PurpleProxyType proxy_type;
 
 	query_data = data;
 	query_data->timeout = 0;
 
-	if (purple_dnsquery_ui_resolve(query_data))
-	{
-		/* The UI is handling the resolve; we're done */
+	if (resolve_ip(query_data))
+		/* resolve_ip calls purple_dnsquery_resolved */
+		return FALSE;
+
+	proxy_type = purple_proxy_info_get_type(
+		purple_proxy_get_setup(query_data->account));
+	if (proxy_type == PURPLE_PROXY_TOR) {
+		purple_dnsquery_failed(query_data,
+			_("Aborting DNS lookup in Tor Proxy mode."));
 		return FALSE;
 	}
 
-	if (!resolve_ip(query_data))
-	{
-		/*
-		 * Spin off a separate thread to perform the DNS lookup so
-		 * that we don't block the UI.
-		 */
-		query_data->resolver = g_thread_create(dns_thread,
-				query_data, FALSE, &err);
-		if (query_data->resolver == NULL)
-		{
-			char message[1024];
-			g_snprintf(message, sizeof(message), _("Thread creation failure: %s"),
-					(err && err->message) ? err->message : _("Unknown reason"));
-			g_error_free(err);
-			purple_dnsquery_failed(query_data, message);
-		}
-	}
+	if (purple_dnsquery_ui_resolve(query_data))
+		/* The UI is handling the resolve; we're done */
+		return FALSE;
+
+	resolve_host(query_data);
 
 	return FALSE;
 }
 
 PurpleDnsQueryData *
-purple_dnsquery_a(const char *hostname, int port,
+purple_dnsquery_a_account(PurpleAccount *account, const char *hostname, int port,
 				PurpleDnsQueryConnectFunction callback, gpointer data)
 {
 	PurpleDnsQueryData *query_data;
 
 	g_return_val_if_fail(hostname != NULL, NULL);
-	g_return_val_if_fail(port	  != 0, NULL);
+	g_return_val_if_fail(port != 0, NULL);
 	g_return_val_if_fail(callback != NULL, NULL);
 
 	purple_debug_info("dnsquery", "Performing DNS lookup for %s\n", hostname);
@@ -891,115 +907,26 @@
 	query_data->port = port;
 	query_data->callback = callback;
 	query_data->data = data;
+	query_data->account = account;
 
-	if (strlen(query_data->hostname) == 0)
+	if (*query_data->hostname == '\0')
 	{
 		purple_dnsquery_destroy(query_data);
 		g_return_val_if_reached(NULL);
 	}
 
-	/* Don't call the callback before returning */
-	query_data->timeout = purple_timeout_add(0, resolve_host, query_data);
+	query_data->timeout = purple_timeout_add(0, initiate_resolving, query_data);
 
 	return query_data;
 }
 
-#else /* not PURPLE_DNSQUERY_USE_FORK or _WIN32 */
-
-/*
- * We weren't able to do anything fancier above, so use the
- * fail-safe name resolution code, which is blocking.
- */
-
-static gboolean
-resolve_host(gpointer data)
-{
-	PurpleDnsQueryData *query_data;
-	struct sockaddr_in sin;
-	GSList *hosts = NULL;
-
-	query_data = data;
-	query_data->timeout = 0;
-
-	if (purple_dnsquery_ui_resolve(query_data))
-	{
-		/* The UI is handling the resolve; we're done */
-		return FALSE;
-	}
-
-	if (!inet_aton(query_data->hostname, &sin.sin_addr)) {
-		struct hostent *hp;
-		gchar *hostname;
-#ifdef USE_IDN
-		if (!dns_str_is_ascii(query_data->hostname)) {
-			int ret = purple_network_convert_idn_to_ascii(query_data->hostname,
-					&hostname);
-			if (ret != 0) {
-				char message[1024];
-				g_snprintf(message, sizeof(message), _("Error resolving %s: %d"),
-						query_data->hostname, ret);
-				purple_dnsquery_failed(query_data, message);
-				return FALSE;
-			}
-		} else /* fallthrough is intentional to the g_strdup */
-#endif
-		hostname = g_strdup(query_data->hostname);
-
-		if(!(hp = gethostbyname(hostname))) {
-			char message[1024];
-			g_snprintf(message, sizeof(message), _("Error resolving %s: %d"),
-					query_data->hostname, h_errno);
-			purple_dnsquery_failed(query_data, message);
-			g_free(hostname);
-			return FALSE;
-		}
-		memset(&sin, 0, sizeof(struct sockaddr_in));
-		memcpy(&sin.sin_addr.s_addr, hp->h_addr, hp->h_length);
-		sin.sin_family = hp->h_addrtype;
-		g_free(hostname);
-	} else
-		sin.sin_family = AF_INET;
-	sin.sin_port = htons(query_data->port);
-
-	hosts = g_slist_append(hosts, GINT_TO_POINTER(sizeof(sin)));
-	hosts = g_slist_append(hosts, g_memdup(&sin, sizeof(sin)));
-
-	purple_dnsquery_resolved(query_data, hosts);
-
-	return FALSE;
-}
-
 PurpleDnsQueryData *
 purple_dnsquery_a(const char *hostname, int port,
 				PurpleDnsQueryConnectFunction callback, gpointer data)
 {
-	PurpleDnsQueryData *query_data;
-
-	g_return_val_if_fail(hostname != NULL, NULL);
-	g_return_val_if_fail(port	  != 0, NULL);
-	g_return_val_if_fail(callback != NULL, NULL);
-
-	query_data = g_new(PurpleDnsQueryData, 1);
-	query_data->hostname = g_strdup(hostname);
-	g_strstrip(query_data->hostname);
-	query_data->port = port;
-	query_data->callback = callback;
-	query_data->data = data;
-
-	if (strlen(query_data->hostname) == 0)
-	{
-		purple_dnsquery_destroy(query_data);
-		g_return_val_if_reached(NULL);
-	}
-
-	/* Don't call the callback before returning */
-	query_data->timeout = purple_timeout_add(0, resolve_host, query_data);
-
-	return query_data;
+	return purple_dnsquery_a_account(NULL, hostname, port, callback, data);
 }
 
-#endif /* not PURPLE_DNSQUERY_USE_FORK or _WIN32 */
-
 void
 purple_dnsquery_destroy(PurpleDnsQueryData *query_data)
 {
--- a/libpurple/dnsquery.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/dnsquery.h	Sat Aug 06 03:45:56 2011 +0000
@@ -58,7 +58,8 @@
  */
 typedef struct
 {
-	/** If implemented, the UI is responsible for DNS queries */
+	/** If implemented, return TRUE if the UI takes responsibility for DNS
+	  * queries. When returning FALSE, the standard implementation is used. */
 	gboolean (*resolve_host)(PurpleDnsQueryData *query_data,
 	                         PurpleDnsQueryResolvedCallback resolved_cb,
 	                         PurpleDnsQueryFailedCallback failed_cb);
@@ -87,6 +88,7 @@
 /**
  * Perform an asynchronous DNS query.
  *
+ * @param account the account that the query is being done for (or NULL)
  * @param hostname The hostname to resolve.
  * @param port     A port number which is stored in the struct sockaddr.
  * @param callback The callback function to call after resolving.
@@ -95,8 +97,28 @@
  * @return NULL if there was an error, otherwise return a reference to
  *         a data structure that can be used to cancel the pending
  *         DNS query, if needed.
+ *
+ * @since 2.8.0
+ */
+PurpleDnsQueryData *purple_dnsquery_a_account(PurpleAccount *account, const char *hostname, int port, PurpleDnsQueryConnectFunction callback, gpointer data);
+
+#if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_DNSQUERY_C_)
+/**
+ * Perform an asynchronous DNS query.
+ *
+ * @param hostname The hostname to resolve.
+ * @param port     A port number which is stored in the struct sockaddr.
+ * @param callback The callback function to call after resolving.
+ * @param data     Extra data to pass to the callback function.
+ *
+ * @return NULL if there was an error, otherwise return a reference to
+ *         a data structure that can be used to cancel the pending
+ *         DNS query, if needed.
+ *
+ * @deprecated Use purple_dnsquery_a_account instead
  */
 PurpleDnsQueryData *purple_dnsquery_a(const char *hostname, int port, PurpleDnsQueryConnectFunction callback, gpointer data);
+#endif
 
 /**
  * Cancel a DNS query and destroy the associated data structure.
--- a/libpurple/dnssrv.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/dnssrv.c	Sat Aug 06 03:45:56 2011 +0000
@@ -20,6 +20,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
  */
+#define _PURPLE_DNSSRV_C_
 
 #include "internal.h"
 #include "util.h"
@@ -30,21 +31,22 @@
 #ifdef HAVE_ARPA_NAMESER_COMPAT_H
 #include <arpa/nameser_compat.h>
 #endif
-#ifndef T_SRV
-#define T_SRV	33
-#endif
-#ifndef T_TXT
-#define T_TXT	16
-#endif
 #else /* WIN32 */
 #include <windns.h>
 /* Missing from the mingw headers */
 #ifndef DNS_TYPE_SRV
-# define DNS_TYPE_SRV 33
+# define DNS_TYPE_SRV PurpleDnsTypeSrv
 #endif
 #ifndef DNS_TYPE_TXT
-# define DNS_TYPE_TXT 16
+# define DNS_TYPE_TXT PurpleDnsTypeTxt
+#endif
 #endif
+
+#ifndef T_SRV
+#define T_SRV	PurpleDnsTypeSrv
+#endif
+#ifndef T_TXT
+#define T_TXT	PurpleDnsTypeTxt
 #endif
 
 #include "debug.h"
@@ -52,6 +54,8 @@
 #include "eventloop.h"
 #include "network.h"
 
+static PurpleSrvTxtQueryUiOps *srv_txt_query_ui_ops = NULL;
+
 #ifndef _WIN32
 typedef union {
 	HEADER hdr;
@@ -66,11 +70,7 @@
 	DNS_FREE_TYPE FreeType) = NULL;
 #endif
 
-struct _PurpleTxtResponse {
-	char *content;
-};
-
-struct _PurpleSrvQueryData {
+struct _PurpleSrvTxtQueryData {
 	union {
 		PurpleSrvCallback srv;
 		PurpleTxtCallback txt;
@@ -79,9 +79,9 @@
 	gpointer extradata;
 	guint handle;
 	int type;
+	char *query;
 #ifdef _WIN32
 	GThread *resolver;
-	char *query;
 	char *error_message;
 	GList *results;
 #else
@@ -100,6 +100,8 @@
 	int sum;
 } PurpleSrvResponseContainer;
 
+static gboolean purple_srv_txt_query_ui_resolve(PurpleSrvTxtQueryData *query_data);
+
 /**
  * Sort by priority, then by weight.  Strictly numerically--no
  * randomness.  Technically we only need to sort by pref and then
@@ -366,7 +368,7 @@
 		cp += 6;
 
 		GETSHORT(dlen,cp);
-		if (query.type == T_SRV) {
+		if (type == T_SRV) {
 			GETSHORT(pref,cp);
 
 			GETSHORT(weight,cp);
@@ -386,7 +388,7 @@
 			srvres->weight = weight;
 
 			ret = g_list_prepend(ret, srvres);
-		} else if (query.type == T_TXT) {
+		} else if (type == T_TXT) {
 			txtres = g_new0(PurpleTxtResponse, 1);
 			txtres->content = g_strndup((gchar*)(++cp), dlen-1);
 			ret = g_list_append(ret, txtres);
@@ -430,7 +432,7 @@
 {
 	int size;
 	int type;
-	PurpleSrvQueryData *query_data = (PurpleSrvQueryData*)data;
+	PurpleSrvTxtQueryData *query_data = (PurpleSrvTxtQueryData*)data;
 	int i;
 	int status;
 
@@ -532,9 +534,9 @@
 res_main_thread_cb(gpointer data)
 {
 	PurpleSrvResponse *srvres = NULL;
-	PurpleSrvQueryData *query_data = data;
+	PurpleSrvTxtQueryData *query_data = data;
 	if(query_data->error_message != NULL) {
-		purple_debug_error("dnssrv", query_data->error_message);
+		purple_debug_error("dnssrv", "%s", query_data->error_message);
 		if (query_data->type == DNS_TYPE_SRV) {
 			if (query_data->cb.srv)
 				query_data->cb.srv(srvres, 0, query_data->extradata);
@@ -592,7 +594,7 @@
 	PDNS_RECORD dr = NULL;
 	int type;
 	DNS_STATUS ds;
-	PurpleSrvQueryData *query_data = data;
+	PurpleSrvTxtQueryData *query_data = data;
 	type = query_data->type;
 	ds = MyDnsQuery_UTF8(query_data->query, type, DNS_QUERY_STANDARD, NULL, &dr, NULL);
 	if (ds != ERROR_SUCCESS) {
@@ -672,12 +674,23 @@
 
 #endif
 
-PurpleSrvQueryData *
-purple_srv_resolve(const char *protocol, const char *transport, const char *domain, PurpleSrvCallback cb, gpointer extradata)
+PurpleSrvTxtQueryData *
+purple_srv_resolve(const char *protocol, const char *transport,
+	const char *domain, PurpleSrvCallback cb, gpointer extradata)
+{
+	return purple_srv_resolve_account(NULL, protocol, transport, domain,
+			cb, extradata);
+}
+
+PurpleSrvTxtQueryData *
+purple_srv_resolve_account(PurpleAccount *account, const char *protocol,
+	const char *transport, const char *domain, PurpleSrvCallback cb,
+	gpointer extradata)
 {
 	char *query;
 	char *hostname;
-	PurpleSrvQueryData *query_data;
+	PurpleSrvTxtQueryData *query_data;
+	PurpleProxyType proxy_type;
 #ifndef _WIN32
 	PurpleSrvInternalQuery internal_query;
 	int in[2], out[2];
@@ -693,6 +706,14 @@
 		g_return_val_if_reached(NULL);
 	}
 
+	proxy_type = purple_proxy_info_get_type(
+		purple_proxy_get_setup(account));
+	if (proxy_type == PURPLE_PROXY_TOR) {
+		purple_debug_info("dnssrv", "Aborting SRV lookup in Tor Proxy mode.");
+		cb(NULL, 0, extradata);
+		return NULL;
+	}
+
 #ifdef USE_IDN
 	if (!dns_str_is_ascii(domain)) {
 		int ret = purple_network_convert_idn_to_ascii(domain, &hostname);
@@ -709,6 +730,17 @@
 	purple_debug_info("dnssrv","querying SRV record for %s: %s\n", domain,
 			query);
 	g_free(hostname);
+	
+	query_data = g_new0(PurpleSrvTxtQueryData, 1);
+	query_data->type = PurpleDnsTypeSrv;
+	query_data->cb.srv = cb;
+	query_data->extradata = extradata;
+	query_data->query = query;
+	
+	if (purple_srv_txt_query_ui_resolve(query_data))
+	{
+		return query_data;
+	}
 
 #ifndef _WIN32
 	if(pipe(in) || pipe(out)) {
@@ -747,10 +779,6 @@
 	if (write(in[1], &internal_query, sizeof(internal_query)) < 0)
 		purple_debug_error("dnssrv", "Could not write to SRV resolver\n");
 
-	query_data = g_new0(PurpleSrvQueryData, 1);
-	query_data->type = T_SRV;
-	query_data->cb.srv = cb;
-	query_data->extradata = extradata;
 	query_data->pid = pid;
 	query_data->fd_out = out[0];
 	query_data->fd_in = in[1];
@@ -767,12 +795,6 @@
 		initialized = TRUE;
 	}
 
-	query_data = g_new0(PurpleSrvQueryData, 1);
-	query_data->type = DNS_TYPE_SRV;
-	query_data->cb.srv = cb;
-	query_data->query = query;
-	query_data->extradata = extradata;
-
 	if (!MyDnsQuery_UTF8 || !MyDnsRecordListFree)
 		query_data->error_message = g_strdup("System missing DNS API (Requires W2K+)\n");
 	else {
@@ -793,11 +815,20 @@
 #endif
 }
 
-PurpleSrvQueryData *purple_txt_resolve(const char *owner, const char *domain, PurpleTxtCallback cb, gpointer extradata)
+PurpleSrvTxtQueryData *purple_txt_resolve(const char *owner,
+	const char *domain, PurpleTxtCallback cb, gpointer extradata)
+{
+	return purple_txt_resolve_account(NULL, owner, domain, cb, extradata);
+}
+
+PurpleSrvTxtQueryData *purple_txt_resolve_account(PurpleAccount *account,
+	const char *owner, const char *domain, PurpleTxtCallback cb,
+	gpointer extradata)
 {
 	char *query;
 	char *hostname;
-	PurpleSrvQueryData *query_data;
+	PurpleSrvTxtQueryData *query_data;
+	PurpleProxyType proxy_type;
 #ifndef _WIN32
 	PurpleSrvInternalQuery internal_query;
 	int in[2], out[2];
@@ -807,6 +838,14 @@
 	static gboolean initialized = FALSE;
 #endif
 
+	proxy_type = purple_proxy_info_get_type(
+		purple_proxy_get_setup(account));
+	if (proxy_type == PURPLE_PROXY_TOR) {
+		purple_debug_info("dnssrv", "Aborting TXT lookup in Tor Proxy mode.");
+		cb(NULL, extradata);
+		return NULL;
+	}
+
 #ifdef USE_IDN
 	if (!dns_str_is_ascii(domain)) {
 		int ret = purple_network_convert_idn_to_ascii(domain, &hostname);
@@ -823,6 +862,18 @@
 	purple_debug_info("dnssrv","querying TXT record for %s: %s\n", domain,
 			query);
 	g_free(hostname);
+	
+	query_data = g_new0(PurpleSrvTxtQueryData, 1);
+	query_data->type = PurpleDnsTypeTxt;
+	query_data->cb.txt = cb;
+	query_data->extradata = extradata;
+	query_data->query = query;
+	
+	if (purple_srv_txt_query_ui_resolve(query_data)) {
+		/* query intentionally not freed
+		 */
+		return query_data;
+	}
 
 #ifndef _WIN32
 	if(pipe(in) || pipe(out)) {
@@ -860,11 +911,7 @@
 
 	if (write(in[1], &internal_query, sizeof(internal_query)) < 0)
 		purple_debug_error("dnssrv", "Could not write to TXT resolver\n");
-
-	query_data = g_new0(PurpleSrvQueryData, 1);
-	query_data->type = T_TXT;
-	query_data->cb.txt = cb;
-	query_data->extradata = extradata;
+	
 	query_data->pid = pid;
 	query_data->fd_out = out[0];
 	query_data->fd_in = in[1];
@@ -881,12 +928,6 @@
 		initialized = TRUE;
 	}
 
-	query_data = g_new0(PurpleSrvQueryData, 1);
-	query_data->type = DNS_TYPE_TXT;
-	query_data->cb.txt = cb;
-	query_data->query = query;
-	query_data->extradata = extradata;
-
 	if (!MyDnsQuery_UTF8 || !MyDnsRecordListFree)
 		query_data->error_message = g_strdup("System missing DNS API (Requires W2K+)\n");
 	else {
@@ -908,8 +949,13 @@
 }
 
 void
-purple_srv_cancel(PurpleSrvQueryData *query_data)
+purple_srv_cancel(PurpleSrvTxtQueryData *query_data)
 {
+	PurpleSrvTxtQueryUiOps *ops = purple_srv_txt_query_get_ui_ops();
+
+	if (ops && ops->destroy)
+		ops->destroy(query_data);
+	
 	if (query_data->handle > 0)
 		purple_input_remove(query_data->handle);
 #ifdef _WIN32
@@ -933,7 +979,7 @@
 }
 
 void
-purple_txt_cancel(PurpleSrvQueryData *query_data)
+purple_txt_cancel(PurpleSrvTxtQueryData *query_data)
 {
 	purple_srv_cancel(query_data);
 }
@@ -953,3 +999,85 @@
 	g_free(resp->content);
 	g_free(resp);
 }
+
+/*
+ * Only used as the callback for the ui ops.
+ */
+static void
+purple_srv_query_resolved(PurpleSrvTxtQueryData *query_data, GList *records)
+{
+	g_return_if_fail(records != NULL);
+	
+	purple_debug_info("dnssrv", "SRV records resolved for %s, count: %d\n", query_data->query, g_list_length(records));
+	
+	if (query_data->cb.srv != NULL)
+		query_data->cb.srv(purple_srv_sort(records)->data, g_list_length(records), query_data->extradata);
+}
+
+/*
+ * Only used as the callback for the ui ops.
+ */
+static void
+purple_txt_query_resolved(PurpleSrvTxtQueryData *query_data, GList *entries)
+{
+	g_return_if_fail(entries != NULL);
+
+	purple_debug_info("dnssrv", "TXT entries resolved for %s, count: %d\n", query_data->query, g_list_length(entries));
+
+	if (query_data->cb.txt != NULL)
+		query_data->cb.txt(entries, query_data->extradata);
+}
+
+static void
+purple_srv_query_failed(PurpleSrvTxtQueryData *query_data, const gchar *error_message)
+{
+	purple_debug_error("dnssrv", "%s\n", error_message);
+	
+	if (query_data->cb.srv != NULL)
+		query_data->cb.srv(NULL, 0, query_data->extradata);
+		
+	purple_srv_cancel(query_data);
+}
+
+static gboolean
+purple_srv_txt_query_ui_resolve(PurpleSrvTxtQueryData *query_data)
+{
+	PurpleSrvTxtQueryUiOps *ops = purple_srv_txt_query_get_ui_ops();
+
+	if (ops && ops->resolve)
+		return ops->resolve(query_data, (query_data->type == T_SRV ? purple_srv_query_resolved : purple_txt_query_resolved), purple_srv_query_failed);
+
+	return FALSE;
+}
+
+void
+purple_srv_txt_query_set_ui_ops(PurpleSrvTxtQueryUiOps *ops)
+{
+	srv_txt_query_ui_ops = ops;
+}
+
+PurpleSrvTxtQueryUiOps *
+purple_srv_txt_query_get_ui_ops(void)
+{
+	/* It is perfectly acceptable for srv_txt_query_ui_ops to be NULL; this just
+	 * means that the default platform-specific implementation will be used.
+	 */
+	return srv_txt_query_ui_ops;
+}
+
+char *
+purple_srv_txt_query_get_query(PurpleSrvTxtQueryData *query_data)
+{
+	g_return_val_if_fail(query_data != NULL, NULL);
+	
+	return query_data->query;
+}
+
+
+int
+purple_srv_txt_query_get_type(PurpleSrvTxtQueryData *query_data)
+{
+	g_return_val_if_fail(query_data != NULL, 0);
+	
+	return query_data->type;
+}
--- a/libpurple/dnssrv.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/dnssrv.h	Sat Aug 06 03:45:56 2011 +0000
@@ -28,12 +28,21 @@
 extern "C" {
 #endif
 
-typedef struct _PurpleSrvQueryData PurpleSrvQueryData;
+typedef struct _PurpleSrvTxtQueryData PurpleSrvTxtQueryData;
 typedef struct _PurpleSrvResponse PurpleSrvResponse;
 typedef struct _PurpleTxtResponse PurpleTxtResponse;
 
+/* For compatibility, should be removed for 3.0.0
+ */
+typedef struct _PurpleSrvTxtQueryData PurpleSrvQueryData;
+
 #include <glib.h>
 
+enum PurpleDnsType {
+	PurpleDnsTypeTxt = 16,
+	PurpleDnsTypeSrv = 33
+};
+
 struct _PurpleSrvResponse {
 	char hostname[256];
 	int port;
@@ -41,6 +50,40 @@
 	int pref;
 };
 
+struct _PurpleTxtResponse {
+	char *content;
+};
+
+typedef void  (*PurpleSrvTxtQueryResolvedCallback) (PurpleSrvTxtQueryData *query_data, GList *records);
+typedef void  (*PurpleSrvTxtQueryFailedCallback) (PurpleSrvTxtQueryData *query_data, const gchar *error_message);
+
+/**
+ * SRV Request UI operations;  UIs should implement this if they want to do SRV
+ * lookups themselves, rather than relying on the core.
+ *
+ * @see @ref ui-ops
+ */
+typedef struct
+{
+	/** If implemented, return TRUE if the UI takes responsibility for SRV
+	  * queries. When returning FALSE, the standard implementation is used. 
+	  * These callbacks MUST be called asynchronously. */
+	gboolean (*resolve)(PurpleSrvTxtQueryData *query_data,
+	                    PurpleSrvTxtQueryResolvedCallback resolved_cb,
+	                    PurpleSrvTxtQueryFailedCallback failed_cb);
+
+	/** Called just before @a query_data is freed; this should cancel any
+	 *  further use of @a query_data the UI would make. Unneeded if
+	 *  #resolve_host is not implemented.
+	 */
+	void (*destroy)(PurpleSrvTxtQueryData *query_data);
+
+	void (*_purple_reserved1)(void);
+	void (*_purple_reserved2)(void);
+	void (*_purple_reserved3)(void);
+	void (*_purple_reserved4)(void);
+} PurpleSrvTxtQueryUiOps;
+
 /**
  * @param resp An array of PurpleSrvResponse of size results.  The array
  *        is sorted based on the order described in the DNS SRV RFC.
@@ -60,32 +103,67 @@
 /**
  * Queries an SRV record.
  *
+ * @param account the account that the query is being done for (or NULL)
+ * @param protocol Name of the protocol (e.g. "sip")
+ * @param transport Name of the transport ("tcp" or "udp")
+ * @param domain Domain name to query (e.g. "blubb.com")
+ * @param cb A callback which will be called with the results
+ * @param extradata Extra data to be passed to the callback
+ *
+ * @since 2.8.0
+ */
+PurpleSrvTxtQueryData *purple_srv_resolve_account(PurpleAccount *account, const char *protocol, const char *transport, const char *domain, PurpleSrvCallback cb, gpointer extradata);
+
+#if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_DNSSRV_C_)
+/**
+ * Queries an SRV record.
+ *
  * @param protocol Name of the protocol (e.g. "sip")
  * @param transport Name of the transport ("tcp" or "udp")
  * @param domain Domain name to query (e.g. "blubb.com")
  * @param cb A callback which will be called with the results
  * @param extradata Extra data to be passed to the callback
+ *
+ * @deprecated Use purple_srv_resolve_account instead
  */
-PurpleSrvQueryData *purple_srv_resolve(const char *protocol, const char *transport, const char *domain, PurpleSrvCallback cb, gpointer extradata);
+PurpleSrvTxtQueryData *purple_srv_resolve(const char *protocol, const char *transport, const char *domain, PurpleSrvCallback cb, gpointer extradata);
+#endif
 
 /**
- * Cancel an SRV DNS query.
+ * Cancel an SRV or DNS query.
  *
  * @param query_data The request to cancel.
  */
-void purple_srv_cancel(PurpleSrvQueryData *query_data);
+void purple_srv_cancel(PurpleSrvTxtQueryData *query_data);
 
 /**
  * Queries an TXT record.
  *
+ * @param account the account that the query is being done for (or NULL)
+ * @param owner Name of the protocol (e.g. "_xmppconnect")
+ * @param domain Domain name to query (e.g. "blubb.com")
+ * @param cb A callback which will be called with the results
+ * @param extradata Extra data to be passed to the callback
+ *
+ * @since 2.8.0
+ */
+PurpleSrvTxtQueryData *purple_txt_resolve_account(PurpleAccount *account, const char *owner, const char *domain, PurpleTxtCallback cb, gpointer extradata);
+
+#if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_DNSSRV_C_)
+/**
+ * Queries an TXT record.
+ *
  * @param owner Name of the protocol (e.g. "_xmppconnect")
  * @param domain Domain name to query (e.g. "blubb.com")
  * @param cb A callback which will be called with the results
  * @param extradata Extra data to be passed to the callback
  *
+ * @deprecated Use purple_txt_resolve_account instead
+ *
  * @since 2.6.0
  */
-PurpleSrvQueryData *purple_txt_resolve(const char *owner, const char *domain, PurpleTxtCallback cb, gpointer extradata);
+PurpleSrvTxtQueryData *purple_txt_resolve(const char *owner, const char *domain, PurpleTxtCallback cb, gpointer extradata);
+#endif
 
 /**
  * Cancel an TXT DNS query.
@@ -93,7 +171,7 @@
  * @param query_data The request to cancel.
  * @since 2.6.0
  */
-void purple_txt_cancel(PurpleSrvQueryData *query_data);
+void purple_txt_cancel(PurpleSrvTxtQueryData *query_data);
 
 /**
  * Get the value of the current TXT record.
@@ -112,6 +190,47 @@
  */
 void purple_txt_response_destroy(PurpleTxtResponse *response);
 
+/**
+ * Cancel a SRV/TXT query and destroy the associated data structure.
+ *
+ * @param query_data The SRV/TXT query to cancel.  This data structure
+ *        is freed by this function.
+ */
+void purple_srv_txt_query_destroy(PurpleSrvTxtQueryData *query_data);
+
+/**
+ * Sets the UI operations structure to be used when doing a SRV/TXT
+ * resolve.  The UI operations need only be set if the UI wants to
+ * handle the resolve itself; otherwise, leave it as NULL.
+ *
+ * @param ops The UI operations structure.
+ */
+void purple_srv_txt_query_set_ui_ops(PurpleSrvTxtQueryUiOps *ops);
+
+/**
+ * Returns the UI operations structure to be used when doing a SRV/TXT
+ * resolve.
+ *
+ * @return The UI operations structure.
+ */
+PurpleSrvTxtQueryUiOps *purple_srv_txt_query_get_ui_ops(void);
+
+/**
+ * Get the query from a PurpleDnsQueryData
+ *
+ * @param query_data The SRV/TXT query
+ * @return The query.
+ */
+char *purple_srv_txt_query_get_query(PurpleSrvTxtQueryData *query_data);
+
+/**
+ * Get the type from a PurpleDnsQueryData (TXT or SRV)
+ *
+ * @param query_data The query
+ * @return The query.
+ */
+int purple_srv_txt_query_get_type(PurpleSrvTxtQueryData *query_data);
+
 #ifdef __cplusplus
 }
 #endif
--- a/libpurple/example/nullclient.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/example/nullclient.c	Sat Aug 06 03:45:56 2011 +0000
@@ -27,7 +27,11 @@
 
 #include <signal.h>
 #include <string.h>
+#ifndef _WIN32
 #include <unistd.h>
+#else
+#include "win32/win32dep.h"
+#endif
 
 #include "defines.h"
 
@@ -80,7 +84,11 @@
 	if (condition & PURPLE_INPUT_WRITE)
 		cond |= PURPLE_GLIB_WRITE_COND;
 
+#if defined _WIN32 && !defined WINPIDGIN_USE_GLIB_IO_CHANNEL
+	channel = wpurple_g_io_channel_win32_new_socket(fd);
+#else
 	channel = g_io_channel_unix_new(fd);
+#endif
 	closure->result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond,
 					      purple_glib_io_invoke, closure, purple_glib_io_destroy);
 
@@ -88,7 +96,7 @@
 	return closure->result;
 }
 
-static PurpleEventLoopUiOps glib_eventloops = 
+static PurpleEventLoopUiOps glib_eventloops =
 {
 	g_timeout_add,
 	g_source_remove,
@@ -126,7 +134,7 @@
 			name, message);
 }
 
-static PurpleConversationUiOps null_conv_uiops = 
+static PurpleConversationUiOps null_conv_uiops =
 {
 	NULL,                      /* create_conversation  */
 	NULL,                      /* destroy_conversation */
@@ -159,7 +167,7 @@
 	purple_conversations_set_ui_ops(&null_conv_uiops);
 }
 
-static PurpleCoreUiOps null_core_uiops = 
+static PurpleCoreUiOps null_core_uiops =
 {
 	NULL,
 	NULL,
@@ -253,12 +261,14 @@
 	PurpleSavedStatus *status;
 	char *res;
 
+#ifndef _WIN32
 	/* libpurple's built-in DNS resolution forks processes to perform
 	 * blocking lookups without blocking the main process.  It does not
 	 * handle SIGCHLD itself, so if the UI does not you quickly get an army
 	 * of zombie subprocesses marching around.
 	 */
 	signal(SIGCHLD, SIG_IGN);
+#endif
 
 	init_libpurple();
 
--- a/libpurple/ft.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/ft.c	Sat Aug 06 03:45:56 2011 +0000
@@ -57,6 +57,13 @@
 		PURPLE_XFER_READY_UI   = 0x1,
 		PURPLE_XFER_READY_PRPL = 0x2,
 	} ready;
+
+	/* TODO: Should really use a PurpleCircBuffer for this. */
+	GByteArray *buffer;
+
+	gpointer thumbnail_data;		/**< thumbnail image */
+	gsize thumbnail_size;
+	gchar *thumbnail_mimetype;
 } PurpleXferPrivData;
 
 static int purple_xfer_choose_file(PurpleXfer *xfer);
@@ -66,6 +73,13 @@
 {
 	PurpleXferPrivData *priv = data;
 
+	if (priv->buffer)
+		g_byte_array_free(priv->buffer, TRUE);
+
+	g_free(priv->thumbnail_data);
+
+	g_free(priv->thumbnail_mimetype);
+
 	g_free(priv);
 }
 
@@ -117,7 +131,7 @@
 	xfer->type    = type;
 	xfer->account = account;
 	xfer->who     = g_strdup(who);
-	xfer->ui_ops  = purple_xfers_get_ui_ops();
+	xfer->ui_ops  = ui_ops = purple_xfers_get_ui_ops();
 	xfer->message = NULL;
 	xfer->current_buffer_size = FT_INITIAL_BUFFER_SIZE;
 	xfer->fd = -1;
@@ -125,6 +139,13 @@
 	priv = g_new0(PurpleXferPrivData, 1);
 	priv->ready = PURPLE_XFER_READY_NONE;
 
+	if (ui_ops && ui_ops->data_not_sent) {
+		/* If the ui will handle unsent data no need for buffer */
+		priv->buffer = NULL;
+	} else {
+		priv->buffer = g_byte_array_sized_new(FT_INITIAL_BUFFER_SIZE);
+	}
+
 	g_hash_table_insert(xfers_data, xfer, priv);
 
 	ui_ops = purple_xfer_get_ui_ops(xfer);
@@ -253,15 +274,21 @@
 	}
 }
 
-void purple_xfer_conversation_write(PurpleXfer *xfer, char *message, gboolean is_error)
+static void
+purple_xfer_conversation_write_internal(PurpleXfer *xfer,
+	const char *message, gboolean is_error, gboolean print_thumbnail)
 {
 	PurpleConversation *conv = NULL;
 	PurpleMessageFlags flags = PURPLE_MESSAGE_SYSTEM;
 	char *escaped;
+	gconstpointer thumbnail_data;
+	gsize size;
 
 	g_return_if_fail(xfer != NULL);
 	g_return_if_fail(message != NULL);
 
+	thumbnail_data = purple_xfer_get_thumbnail(xfer, &size);
+
 	conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, xfer->who,
 											   purple_xfer_get_account(xfer));
 
@@ -273,10 +300,39 @@
 	if (is_error)
 		flags |= PURPLE_MESSAGE_ERROR;
 
-	purple_conversation_write(conv, NULL, escaped, flags, time(NULL));
+	if (print_thumbnail && thumbnail_data) {
+		gchar *message_with_img;
+		gpointer data = g_memdup(thumbnail_data, size);
+		int id = purple_imgstore_add_with_id(data, size, NULL);
+
+		message_with_img =
+			g_strdup_printf("<img id='%d'> %s", id, escaped);
+		purple_conversation_write(conv, NULL, message_with_img, flags,
+			time(NULL));
+		purple_imgstore_unref_by_id(id);
+		g_free(message_with_img);
+	} else {
+		purple_conversation_write(conv, NULL, escaped, flags, time(NULL));
+	}
 	g_free(escaped);
 }
 
+void
+purple_xfer_conversation_write(PurpleXfer *xfer, gchar *message,
+	gboolean is_error)
+{
+	purple_xfer_conversation_write_internal(xfer, message, is_error, FALSE);
+}
+
+/* maybe this one should be exported publically? */
+static void
+purple_xfer_conversation_write_with_thumbnail(PurpleXfer *xfer,
+	const gchar *message)
+{
+	purple_xfer_conversation_write_internal(xfer, message, FALSE, TRUE);
+}
+
+
 static void purple_xfer_show_file_error(PurpleXfer *xfer, const char *filename)
 {
 	int err = errno;
@@ -435,6 +491,8 @@
 {
 	char *buf, *size_buf;
 	size_t size;
+	gconstpointer thumb;
+	gsize thumb_size;
 
 	/* If we have already accepted the request, ask the destination file
 	   name directly */
@@ -460,12 +518,18 @@
 			serv_got_im(purple_account_get_connection(xfer->account),
 								 xfer->who, xfer->message, 0, time(NULL));
 
-		purple_request_accept_cancel(xfer, NULL, buf, NULL,
-								  PURPLE_DEFAULT_ACTION_NONE,
-								  xfer->account, xfer->who, NULL,
-								  xfer,
-								  G_CALLBACK(purple_xfer_choose_file),
-								  G_CALLBACK(cancel_recv_cb));
+		if ((thumb = purple_xfer_get_thumbnail(xfer, &thumb_size))) {
+			purple_request_accept_cancel_with_icon(xfer, NULL, buf, NULL,
+				PURPLE_DEFAULT_ACTION_NONE, xfer->account, xfer->who, NULL,
+				thumb, thumb_size, xfer,
+				G_CALLBACK(purple_xfer_choose_file),
+				G_CALLBACK(cancel_recv_cb));
+		} else {
+			purple_request_accept_cancel(xfer, NULL, buf, NULL,
+				PURPLE_DEFAULT_ACTION_NONE, xfer->account, xfer->who, NULL,
+				xfer, G_CALLBACK(purple_xfer_choose_file),
+				G_CALLBACK(cancel_recv_cb));
+		}
 
 		g_free(buf);
 	} else
@@ -534,10 +598,12 @@
 		{
 			gchar* message = NULL;
 			PurpleBuddy *buddy = purple_find_buddy(xfer->account, xfer->who);
+
 			message = g_strdup_printf(_("%s is offering to send file %s"),
 				buddy ? purple_buddy_get_alias(buddy) : xfer->who, purple_xfer_get_filename(xfer));
-			purple_xfer_conversation_write(xfer, message, FALSE);
+			purple_xfer_conversation_write_with_thumbnail(xfer, message);
 			g_free(message);
+
 			/* Ask for a filename to save to if it's not already given by a plugin */
 			if (xfer->local_filename == NULL)
 				purple_xfer_ask_recv(xfer);
@@ -568,7 +634,7 @@
 	type = purple_xfer_get_type(xfer);
 	account = purple_xfer_get_account(xfer);
 
-	purple_debug_misc("xfer", "request accepted for %p\n", xfer); 
+	purple_debug_misc("xfer", "request accepted for %p\n", xfer);
 
 	if (!filename && type == PURPLE_XFER_RECEIVE) {
 		xfer->status = PURPLE_XFER_STATUS_ACCEPTED;
@@ -611,7 +677,6 @@
 			purple_xfer_set_local_filename(xfer, filename);
 			purple_xfer_set_size(xfer, st.st_size);
 		} else {
-			utf8 = g_strdup(filename);
 			purple_xfer_set_local_filename(xfer, filename);
 		}
 
@@ -686,6 +751,7 @@
 	return xfer->status;
 }
 
+/* FIXME: Rename with cancelled for 3.0.0. */
 gboolean
 purple_xfer_is_canceled(const PurpleXfer *xfer)
 {
@@ -1033,9 +1099,11 @@
 		r = write(xfer->fd, buffer, s);
 		if (r < 0 && errno == EAGAIN)
 			r = 0;
-		if ((purple_xfer_get_bytes_sent(xfer)+r) >= purple_xfer_get_size(xfer))
-			purple_xfer_set_completed(xfer, TRUE);
 	}
+	if (r >= 0 && (purple_xfer_get_bytes_sent(xfer)+r) >= purple_xfer_get_size(xfer) &&
+		!purple_xfer_is_completed(xfer))
+		purple_xfer_set_completed(xfer, TRUE);
+	
 
 	return r;
 }
@@ -1074,8 +1142,10 @@
 			return;
 		}
 	} else if (xfer->type == PURPLE_XFER_SEND) {
-		size_t result;
+		size_t result = 0;
 		size_t s = MIN(purple_xfer_get_bytes_remaining(xfer), xfer->current_buffer_size);
+		PurpleXferPrivData *priv = g_hash_table_lookup(xfers_data, xfer);
+		gboolean read = TRUE;
 
 		/* this is so the prpl can keep the connection open
 		   if it needs to for some odd reason. */
@@ -1087,60 +1157,88 @@
 			return;
 		}
 
-		if (ui_ops && ui_ops->ui_read) {
-			gssize tmp = ui_ops->ui_read(xfer, &buffer, s);
-			if (tmp == 0) {
-				/*
-				 * UI isn't ready to send data. It will call
-				 * purple_xfer_ui_ready when ready, which sets back up this
-				 * watcher.
-				 */
-				if (xfer->watcher != 0) {
-					purple_input_remove(xfer->watcher);
-					xfer->watcher = 0;
-				}
-
-				return;
-			} else if (tmp < 0) {
-				purple_debug_error("filetransfer", "Unable to read whole buffer.\n");
-				purple_xfer_cancel_local(xfer);
-				return;
-			}
-
-			result = tmp;
-		} else {
-			buffer = g_malloc0(s);
-			result = fread(buffer, 1, s, xfer->dest_fp);
-			if (result != s) {
-				purple_debug_error("filetransfer", "Unable to read whole buffer.\n");
-				purple_xfer_cancel_local(xfer);
-				g_free(buffer);
-				return;
+		if (priv->buffer) {
+			if (priv->buffer->len < s) {
+				s -= priv->buffer->len;
+				read = TRUE;
+			} else {
+				read = FALSE;
 			}
 		}
 
-		/* Write as much as we're allowed to. */
+		if (read) {
+			if (ui_ops && ui_ops->ui_read) {
+				gssize tmp = ui_ops->ui_read(xfer, &buffer, s);
+				if (tmp == 0) {
+					/*
+					 * The UI claimed it was ready, but didn't have any data for
+					 * us...  It will call purple_xfer_ui_ready when ready, which
+					 * sets back up this watcher.
+					 */
+					if (xfer->watcher != 0) {
+						purple_input_remove(xfer->watcher);
+						xfer->watcher = 0;
+					}
+
+					/* Need to indicate the prpl is still ready... */
+					priv->ready |= PURPLE_XFER_READY_PRPL;
+
+					g_return_if_reached();
+				} else if (tmp < 0) {
+					purple_debug_error("filetransfer", "Unable to read whole buffer.\n");
+					purple_xfer_cancel_local(xfer);
+					return;
+				}
+
+				result = tmp;
+			} else {
+				buffer = g_malloc(s);
+				result = fread(buffer, 1, s, xfer->dest_fp);
+				if (result != s) {
+					purple_debug_error("filetransfer", "Unable to read whole buffer.\n");
+					purple_xfer_cancel_local(xfer);
+					g_free(buffer);
+					return;
+				}
+			}
+		}
+
+		if (priv->buffer) {
+			g_byte_array_append(priv->buffer, buffer, result);
+			g_free(buffer);
+			buffer = priv->buffer->data;
+			result = priv->buffer->len;
+		}
+
 		r = purple_xfer_write(xfer, buffer, result);
 
 		if (r == -1) {
 			purple_xfer_cancel_remote(xfer);
-			g_free(buffer);
+			if (!priv->buffer)
+				/* We don't free buffer if priv->buffer is set, because in
+				   that case buffer doesn't belong to us. */
+				g_free(buffer);
 			return;
-		} else if (r < result) {
-			if (ui_ops == NULL || (ui_ops->ui_read == NULL && ui_ops->ui_write == NULL)) {
-				/* We have to seek back in the file now. */
-				fseek(xfer->dest_fp, r - s, SEEK_CUR);
-			}
-			else {
-				ui_ops->data_not_sent(xfer, buffer + r, result - r);
-			}
-		} else {
+		} else if (r == result) {
 			/*
 			 * We managed to write the entire buffer.  This means our
 			 * network is fast and our buffer is too small, so make it
 			 * bigger.
 			 */
 			purple_xfer_increase_buffer_size(xfer);
+		} else {
+			if (ui_ops && ui_ops->data_not_sent)
+				ui_ops->data_not_sent(xfer, buffer + r, result - r);
+		}
+
+		if (priv->buffer) {
+			/*
+			 * Remove what we wrote
+			 * If we wrote the whole buffer the byte array will be empty
+			 * Otherwise we'll keep what wasn't sent for next time.
+			 */
+			buffer = NULL;
+			g_byte_array_remove_range(priv->buffer, 0, r);
 		}
 	}
 
@@ -1181,6 +1279,8 @@
 			purple_debug_misc("xfer", "prpl is ready on ft %p, waiting for UI\n", xfer);
 			return;
 		}
+
+		priv->ready = PURPLE_XFER_READY_NONE;
 	}
 
 	do_transfer(xfer);
@@ -1192,6 +1292,11 @@
 	PurpleXferType type = purple_xfer_get_type(xfer);
 	PurpleXferUiOps *ui_ops = purple_xfer_get_ui_ops(xfer);
 
+	if (xfer->start_time != 0) {
+		purple_debug_error("xfer", "Transfer is being started multiple times\n");
+		g_return_if_reached();
+	}
+
 	if (ui_ops == NULL || (ui_ops->ui_read == NULL && ui_ops->ui_write == NULL)) {
 		xfer->dest_fp = g_fopen(purple_xfer_get_local_filename(xfer),
 		                        type == PURPLE_XFER_RECEIVE ? "wb" : "rb");
@@ -1384,6 +1489,20 @@
 
 	g_return_if_fail(xfer != NULL);
 
+	/* TODO: We definitely want to close any open request dialogs associated
+	   with this transfer.  However, in some cases the request dialog might
+	   own a reference on the xfer.  This happens at least with the "%s wants
+	   to send you %s" dialog from purple_xfer_ask_recv().  In these cases
+	   the ref count will not be decremented when the request dialog is
+	   closed, so the ref count will never reach 0 and the xfer will never
+	   be freed.  This is a memleak and should be fixed.  It's not clear what
+	   the correct fix is.  Probably requests should have a destroy function
+	   that is called when the request is destroyed.  But also, ref counting
+	   xfer objects makes this code REALLY complicated.  An alternate fix is
+	   to not ref count and instead just make sure the object still exists
+	   when we try to use it. */
+	purple_request_close_with_handle(xfer);
+
 	purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_CANCEL_LOCAL);
 	xfer->end_time = time(NULL);
 
@@ -1535,6 +1654,52 @@
 		ui_ops->update_progress(xfer, purple_xfer_get_progress(xfer));
 }
 
+gconstpointer
+purple_xfer_get_thumbnail(const PurpleXfer *xfer, gsize *len)
+{
+	PurpleXferPrivData *priv = g_hash_table_lookup(xfers_data, xfer);
+
+	if (len)
+		*len = priv->thumbnail_size;
+
+	return priv->thumbnail_data;
+}
+
+const gchar *
+purple_xfer_get_thumbnail_mimetype(const PurpleXfer *xfer)
+{
+	PurpleXferPrivData *priv = g_hash_table_lookup(xfers_data, xfer);
+
+	return priv->thumbnail_mimetype;
+}
+
+void
+purple_xfer_set_thumbnail(PurpleXfer *xfer, gconstpointer thumbnail,
+	gsize size, const gchar *mimetype)
+{
+	PurpleXferPrivData *priv = g_hash_table_lookup(xfers_data, xfer);
+
+	g_free(priv->thumbnail_data);
+	g_free(priv->thumbnail_mimetype);
+
+	if (thumbnail && size > 0) {
+		priv->thumbnail_data = g_memdup(thumbnail, size);
+		priv->thumbnail_size = size;
+		priv->thumbnail_mimetype = g_strdup(mimetype);
+	} else {
+		priv->thumbnail_data = NULL;
+		priv->thumbnail_size = 0;
+		priv->thumbnail_mimetype = NULL;
+	}
+}
+
+void
+purple_xfer_prepare_thumbnail(PurpleXfer *xfer, const gchar *formats)
+{
+	if (xfer->ui_ops->add_thumbnail) {
+		xfer->ui_ops->add_thumbnail(xfer, formats);
+	}
+}
 
 /**************************************************************************
  * File Transfer Subsystem API
--- a/libpurple/ft.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/ft.h	Sat Aug 06 03:45:56 2011 +0000
@@ -58,8 +58,8 @@
 	PURPLE_XFER_STATUS_ACCEPTED,      /**< Receive accepted, but destination file not selected yet */
 	PURPLE_XFER_STATUS_STARTED,       /**< purple_xfer_start has been called. */
 	PURPLE_XFER_STATUS_DONE,          /**< The xfer completed successfully. */
-	PURPLE_XFER_STATUS_CANCEL_LOCAL,  /**< The xfer was canceled by us. */
-	PURPLE_XFER_STATUS_CANCEL_REMOTE  /**< The xfer was canceled by the other end, or we couldn't connect. */
+	PURPLE_XFER_STATUS_CANCEL_LOCAL,  /**< The xfer was cancelled by us. */
+	PURPLE_XFER_STATUS_CANCEL_REMOTE  /**< The xfer was cancelled by the other end, or we couldn't connect. */
 } PurpleXferStatusType;
 
 /**
@@ -120,7 +120,12 @@
 	 */
 	void (*data_not_sent)(PurpleXfer *xfer, const guchar *buffer, gsize size);
 
-	void (*_purple_reserved1)(void);
+	/**
+	 * Op to create a thumbnail image for a file transfer
+	 *
+	 * @param xfer   The file transfer structure
+	 */
+	void (*add_thumbnail)(PurpleXfer *xfer, const gchar *formats);
 } PurpleXferUiOps;
 
 /**
@@ -299,11 +304,12 @@
 PurpleXferStatusType purple_xfer_get_status(const PurpleXfer *xfer);
 
 /**
- * Returns true if the file transfer was canceled.
+ * Returns true if the file transfer was cancelled.
  *
  * @param xfer The file transfer.
  *
- * @return Whether or not the transfer was canceled.
+ * @return Whether or not the transfer was cancelled.
+ * FIXME: This should be renamed using cancelled for 3.0.0.
  */
 gboolean purple_xfer_is_canceled(const PurpleXfer *xfer);
 
@@ -687,6 +693,51 @@
  */
 void purple_xfer_prpl_ready(PurpleXfer *xfer);
 
+/**
+ * Gets the thumbnail data for a transfer
+ *
+ * @param xfer The file transfer to get the thumbnail for
+ * @param len  If not @c NULL, the length of the thumbnail data returned
+ *             will be set in the location pointed to by this.
+ * @return The thumbnail data, or NULL if there is no thumbnail
+ * @since 2.7.0
+ */
+gconstpointer purple_xfer_get_thumbnail(const PurpleXfer *xfer, gsize *len);
+
+/**
+ * Gets the mimetype of the thumbnail preview for a transfer
+ *
+ * @param xfer The file transfer to get the mimetype for
+ * @return The mimetype of the thumbnail, or @c NULL if not thumbnail is set
+ * @since 2.7.0
+ */
+const gchar *purple_xfer_get_thumbnail_mimetype(const PurpleXfer *xfer);
+
+
+/**
+ * Sets the thumbnail data for a transfer
+ *
+ * @param xfer The file transfer to set the data for
+ * @param thumbnail A pointer to the thumbnail data, this will be copied
+ * @param size The size in bytes of the passed in thumbnail data
+ * @param mimetype The mimetype of the generated thumbnail
+ * @since 2.7.0
+ */
+void purple_xfer_set_thumbnail(PurpleXfer *xfer, gconstpointer thumbnail,
+	gsize size, const gchar *mimetype);
+
+/**
+ * Prepare a thumbnail for a transfer (if the UI supports it)
+ * will be no-op in case the UI doesn't implement thumbnail creation
+ *
+ * @param xfer The file transfer to create a thumbnail for
+ * @param formats A comma-separated list of mimetypes for image formats
+ *	 	  the protocols can use for thumbnails.
+ * @since 2.7.0
+ */
+void purple_xfer_prepare_thumbnail(PurpleXfer *xfer, const gchar *formats);
+
+
 /*@}*/
 
 /**************************************************************************/
--- a/libpurple/gaim-compat.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/gaim-compat.h	Sat Aug 06 03:45:56 2011 +0000
@@ -841,7 +841,7 @@
 /* from dnssrv.h */
 
 #define GaimSrvResponse   PurpleSrvResponse
-#define GaimSrvQueryData  PurpleSrvQueryData
+#define GaimSrvQueryData  PurpleSrvTxtQueryData
 #define GaimSrvCallback   PurpleSrvCallback
 
 #define gaim_srv_resolve  purple_srv_resolve
--- a/libpurple/gconf/Makefile.am	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/gconf/Makefile.am	Sat Aug 06 03:45:56 2011 +0000
@@ -2,6 +2,7 @@
 
 EXTRA_DIST = purple.schemas.in
 
+if INSTALL_I18N
 schema_in_files = purple.schemas.in
 schema_DATA = $(schema_in_files:.schemas.in=.schemas)
 @INTLTOOL_SCHEMAS_RULE@
@@ -12,4 +13,6 @@
 		grep -v "^WARNING: failed to install schema" | grep -v "^Attached schema" 1>&2
 else
 install-data-local:
-endif
+endif #GCONF_SCHEMAS_INSTALL
+
+endif #INSTALL_I18N
--- a/libpurple/internal.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/internal.h	Sat Aug 06 03:45:56 2011 +0000
@@ -118,36 +118,13 @@
 # include <unistd.h>
 #endif
 
-/* MAXPATHLEN should only be used with readlink() on glib < 2.4.0.  For
- * anything else, use g_file_read_link() or other dynamic functions.  This is
- * important because Hurd has no hard limits on path length. */
-#if !GLIB_CHECK_VERSION(2,4,0)
-# ifndef MAXPATHLEN
-#  ifdef PATH_MAX
-#   define MAXPATHLEN PATH_MAX
-#  else
-#   define MAXPATHLEN 1024
-#  endif
-# endif
-#endif
-
 #ifndef HOST_NAME_MAX
 # define HOST_NAME_MAX 255
 #endif
 
 #include <glib.h>
-#if !GLIB_CHECK_VERSION(2,4,0)
-#	define G_MAXUINT32 ((guint32) 0xffffffff)
-#endif
 
-#ifndef G_MAXSIZE
-#	if GLIB_SIZEOF_LONG == 8
-#		define G_MAXSIZE ((gsize) 0xffffffffffffffff)
-#	else
-#		define G_MAXSIZE ((gsize) 0xffffffff)
-#	endif
-#endif
-
+/* This wasn't introduced until Glib 2.14 :( */
 #ifndef G_MAXSSIZE
 #	if GLIB_SIZEOF_LONG == 8
 #		define G_MAXSSIZE ((gssize) 0x7fffffffffffffff)
@@ -156,80 +133,12 @@
 #	endif
 #endif
 
-#if GLIB_CHECK_VERSION(2,6,0)
-#	include <glib/gstdio.h>
-#endif
-
-#if !GLIB_CHECK_VERSION(2,6,0)
-#	define g_freopen freopen
-#	define g_fopen fopen
-#	define g_rmdir rmdir
-#	define g_remove remove
-#	define g_unlink unlink
-#	define g_lstat lstat
-#	define g_stat stat
-#	define g_mkdir mkdir
-#	define g_rename rename
-#	define g_open open
-#endif
-
-#if !GLIB_CHECK_VERSION(2,8,0) && !defined _WIN32
-#	define g_access access
-#endif
-
-#if !GLIB_CHECK_VERSION(2,10,0)
-#	define g_slice_new(type) g_new(type, 1)
-#	define g_slice_new0(type) g_new0(type, 1)
-#	define g_slice_free(type, mem) g_free(mem)
-#endif
+#include <glib/gstdio.h>
 
 #ifdef _WIN32
 #include "win32dep.h"
 #endif
 
-/* ugly ugly ugly */
-/* This is a workaround for the fact that G_GINT64_MODIFIER and G_GSIZE_FORMAT
- * are only defined in Glib >= 2.4 */
-#ifndef G_GINT64_MODIFIER
-#	if GLIB_SIZEOF_LONG == 8
-#		define G_GINT64_MODIFIER "l"
-#	else
-#		define G_GINT64_MODIFIER "ll"
-#	endif
-#endif
-
-#ifndef G_GSIZE_MODIFIER
-#	if GLIB_SIZEOF_LONG == 8
-#		define G_GSIZE_MODIFIER "l"
-#	else
-#		define G_GSIZE_MODIFIER ""
-#	endif
-#endif
-
-#ifndef G_GSIZE_FORMAT
-#	if GLIB_SIZEOF_LONG == 8
-#		define G_GSIZE_FORMAT "lu"
-#	else
-#		define G_GSIZE_FORMAT "u"
-#	endif
-#endif
-
-#ifndef G_GSSIZE_FORMAT
-#	if GLIB_SIZEOF_LONG == 8
-#		define G_GSSIZE_FORMAT "li"
-#	else
-#		define G_GSSIZE_FORMAT "i"
-#	endif
-#endif
-
-#ifndef G_GNUC_NULL_TERMINATED
-#	if     __GNUC__ >= 4
-#		define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
-#	else
-#		define G_GNUC_NULL_TERMINATED
-#	endif
-#endif
-
 #ifdef HAVE_CONFIG_H
 #if SIZEOF_TIME_T == 4
 #	define PURPLE_TIME_T_MODIFIER "lu"
@@ -242,38 +151,6 @@
 
 #include <glib-object.h>
 
-#ifndef G_DEFINE_TYPE
-#define G_DEFINE_TYPE(TypeName, type_name, TYPE_PARENT) \
-\
-static void     type_name##_init              (TypeName        *self); \
-static void     type_name##_class_init        (TypeName##Class *klass); \
-static gpointer type_name##_parent_class = NULL; \
-static void     type_name##_class_intern_init (gpointer klass) \
-{ \
-  type_name##_parent_class = g_type_class_peek_parent (klass); \
-  type_name##_class_init ((TypeName##Class*) klass); \
-} \
-\
-GType \
-type_name##_get_type (void) \
-{ \
-  static GType g_define_type_id = 0; \
-  if (G_UNLIKELY (g_define_type_id == 0)) \
-    { \
-      g_define_type_id = \
-        g_type_register_static_simple (TYPE_PARENT, \
-                                       g_intern_static_string (#TypeName), \
-                                       sizeof (TypeName##Class), \
-                                       (GClassInitFunc)type_name##_class_intern_init, \
-                                       sizeof (TypeName), \
-                                       (GInstanceInitFunc)type_name##_init, \
-                                       (GTypeFlags) 0); \
-    }					\
-  return g_define_type_id;		\
-} /* closes type_name##_get_type() */
-
-#endif
-
 /* Safer ways to work with static buffers. When using non-static
  * buffers, either use g_strdup_* functions (preferred) or use
  * g_strlcpy/g_strlcpy directly. */
--- a/libpurple/log.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/log.c	Sat Aug 06 03:45:56 2011 +0000
@@ -302,7 +302,7 @@
 			}
 		}
 
-		score = (gint)score_double;
+		score = (gint) ceil(score_double);
 		g_hash_table_replace(logsize_users_decayed, lu, GINT_TO_POINTER(score));
 	}
 	return score;
@@ -1157,6 +1157,7 @@
 			g_dir_close(username_dir);
 		}
 		g_free(protocol_path);
+		g_list_free(accounts);
 		g_dir_close(protocol_dir);
 	}
 	g_free(log_path);
@@ -1681,7 +1682,6 @@
 	struct tm tm;
 	char month[4];
 	struct old_logger_data *data = NULL;
-	char *newlog;
 	int logfound = 0;
 	int lastoff = 0;
 	int newlen;
@@ -1783,7 +1783,7 @@
 	}
 
 	while (fgets(buf, BUF_LONG, file)) {
-		if ((newlog = strstr(buf, "---- New C"))) {
+		if (strstr(buf, "---- New C") != NULL) {
 			int length;
 			int offset;
 			char convostart[32];
--- a/libpurple/marshallers.list	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/marshallers.list	Sat Aug 06 03:45:56 2011 +0000
@@ -4,3 +4,5 @@
 VOID:STRING,STRING,DOUBLE
 VOID:ENUM,STRING,STRING
 VOID:ENUM,STRING,STRING,BOOLEAN
+VOID:FLAGS,FLAGS
+VOID:STRING,STRING,OBJECT,OBJECT
--- a/libpurple/media-gst.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/media-gst.h	Sat Aug 06 03:45:56 2011 +0000
@@ -159,6 +159,31 @@
 PurpleMediaElementInfo *purple_media_manager_get_active_element(
 		PurpleMediaManager *manager, PurpleMediaElementType type);
 
+/**
+ * Reduces media formats supported by the video source to given set.
+ *
+ * Useful to force negotiation of smaller picture resolution more suitable for
+ * use with particular codec and communication protocol without rescaling.
+ *
+ * @param manager The media manager to set the media formats.
+ * @param caps Set of allowed media formats.
+ *
+ * @since 2.8.0
+ */
+void purple_media_manager_set_video_caps(PurpleMediaManager *manager,
+		GstCaps *caps);
+
+/**
+ * Returns current set of media formats limiting the output from video source.
+ *
+ * @param manager The media manager to get the media formats from.
+ *
+ * @return @c GstCaps limiting the video source's formats.
+ *
+ * @since 2.8.0
+ */
+GstCaps *purple_media_manager_get_video_caps(PurpleMediaManager *manager);
+
 gchar *purple_media_element_info_get_id(PurpleMediaElementInfo *info);
 gchar *purple_media_element_info_get_name(PurpleMediaElementInfo *info);
 PurpleMediaElementType purple_media_element_info_get_element_type(
--- a/libpurple/media.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/media.c	Sat Aug 06 03:45:56 2011 +0000
@@ -23,26 +23,23 @@
  * 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 "account.h"
 #include "media.h"
+#include "media/backend-iface.h"
 #include "mediamanager.h"
-#include "network.h"
 
 #include "debug.h"
 
 #ifdef USE_GSTREAMER
+#include "media/backend-fs2.h"
 #include "marshallers.h"
 #include "media-gst.h"
 #endif
 
 #ifdef USE_VV
 
-#include <gst/farsight/fs-conference-iface.h>
-#include <gst/farsight/fs-element-added-notifier.h>
-
 /** @copydoc _PurpleMediaSession */
 typedef struct _PurpleMediaSession PurpleMediaSession;
 /** @copydoc _PurpleMediaStream */
@@ -51,14 +48,6 @@
 typedef struct _PurpleMediaClass PurpleMediaClass;
 /** @copydoc _PurpleMediaPrivate */
 typedef struct _PurpleMediaPrivate PurpleMediaPrivate;
-/** @copydoc _PurpleMediaCandidateClass */
-typedef struct _PurpleMediaCandidateClass PurpleMediaCandidateClass;
-/** @copydoc _PurpleMediaCandidatePrivate */
-typedef struct _PurpleMediaCandidatePrivate PurpleMediaCandidatePrivate;
-/** @copydoc _PurpleMediaCodecClass */
-typedef struct _PurpleMediaCodecClass PurpleMediaCodecClass;
-/** @copydoc _PurpleMediaCodecPrivate */
-typedef struct _PurpleMediaCodecPrivate PurpleMediaCodecPrivate;
 
 /** The media class */
 struct _PurpleMediaClass
@@ -77,10 +66,6 @@
 {
 	gchar *id;
 	PurpleMedia *media;
-	GstElement *src;
-	GstElement *tee;
-	FsSession *session;
-
 	PurpleMediaSessionType type;
 	gboolean initiator;
 };
@@ -89,11 +74,6 @@
 {
 	PurpleMediaSession *session;
 	gchar *participant;
-	FsStream *stream;
-	GstElement *src;
-	GstElement *tee;
-	GstElement *volume;
-	GstElement *level;
 
 	GList *local_candidates;
 	GList *remote_candidates;
@@ -101,13 +81,9 @@
 	gboolean initiator;
 	gboolean accepted;
 	gboolean candidates_prepared;
-	gboolean held;
-	gboolean paused;
 
 	GList *active_local_candidates;
 	GList *active_remote_candidates;
-
-	guint connected_cb_id;
 };
 #endif
 
@@ -116,16 +92,14 @@
 #ifdef USE_VV
 	PurpleMediaManager *manager;
 	PurpleAccount *account;
-	FsConference *conference;
+	PurpleMediaBackend *backend;
+	gchar *conference_type;
 	gboolean initiator;
 	gpointer prpl_data;
 
 	GHashTable *sessions;	/* PurpleMediaSession table */
-	GHashTable *participants; /* FsParticipant table */
-
+	GList *participants;
 	GList *streams;		/* PurpleMediaStream table */
-
-	GstElement *confbin;
 #else
 	gpointer dummy;
 #endif
@@ -133,8 +107,6 @@
 
 #ifdef USE_VV
 #define PURPLE_MEDIA_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_MEDIA, PurpleMediaPrivate))
-#define PURPLE_MEDIA_CANDIDATE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_MEDIA_CANDIDATE, PurpleMediaCandidatePrivate))
-#define PURPLE_MEDIA_CODEC_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_MEDIA_CODEC, PurpleMediaCodecPrivate))
 
 static void purple_media_class_init (PurpleMediaClass *klass);
 static void purple_media_init (PurpleMedia *media);
@@ -143,15 +115,19 @@
 static void purple_media_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
 static void purple_media_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
 
-static void purple_media_new_local_candidate_cb(FsStream *stream,
-		FsCandidate *local_candidate, PurpleMediaSession *session);
-static void purple_media_candidates_prepared_cb(FsStream *stream,
-		PurpleMediaSession *session);
-static void purple_media_candidate_pair_established_cb(FsStream *stream,
-		FsCandidate *native_candidate, FsCandidate *remote_candidate,
-		PurpleMediaSession *session);
-static gboolean media_bus_call(GstBus *bus,
-		GstMessage *msg, PurpleMedia *media);
+static void purple_media_new_local_candidate_cb(PurpleMediaBackend *backend,
+		const gchar *sess_id, const gchar *participant,
+		PurpleMediaCandidate *candidate, PurpleMedia *media);
+static void purple_media_candidates_prepared_cb(PurpleMediaBackend *backend,
+		const gchar *sess_id, const gchar *name, PurpleMedia *media);
+static void purple_media_candidate_pair_established_cb(
+		PurpleMediaBackend *backend,
+		const gchar *sess_id, const gchar *name,
+		PurpleMediaCandidate *local_candidate,
+		PurpleMediaCandidate *remote_candidate,
+		PurpleMedia *media);
+static void purple_media_codecs_changed_cb(PurpleMediaBackend *backend,
+		const gchar *sess_id, PurpleMedia *media);
 
 static GObjectClass *parent_class = NULL;
 
@@ -172,46 +148,15 @@
 enum {
 	PROP_0,
 	PROP_MANAGER,
+	PROP_BACKEND,
 	PROP_ACCOUNT,
-	PROP_CONFERENCE,
+	PROP_CONFERENCE_TYPE,
 	PROP_INITIATOR,
 	PROP_PRPL_DATA,
 };
 #endif
 
 
-/*
- * PurpleMediaElementType
- */
-
-GType
-purple_media_session_type_get_type()
-{
-	static GType type = 0;
-	if (type == 0) {
-		static const GFlagsValue values[] = {
-			{ PURPLE_MEDIA_NONE,
-				"PURPLE_MEDIA_NONE", "none" },
-			{ PURPLE_MEDIA_RECV_AUDIO,
-				"PURPLE_MEDIA_RECV_AUDIO", "recv-audio" },
-			{ PURPLE_MEDIA_SEND_AUDIO,
-				"PURPLE_MEDIA_SEND_AUDIO", "send-audio" },
-			{ PURPLE_MEDIA_RECV_VIDEO,
-				"PURPLE_MEDIA_RECV_VIDEO", "recv-video" },
-			{ PURPLE_MEDIA_SEND_VIDEO,
-				"PURPLE_MEDIA_SEND_VIDEO", "send-audio" },
-			{ PURPLE_MEDIA_AUDIO,
-				"PURPLE_MEDIA_AUDIO", "audio" },
-			{ PURPLE_MEDIA_VIDEO,
-				"PURPLE_MEDIA_VIDEO", "video" },
-			{ 0, NULL, NULL }
-		};
-		type = g_flags_register_static(
-				"PurpleMediaSessionType", values);
-	}
-	return type;
-}
-
 GType
 purple_media_get_type()
 {
@@ -239,63 +184,13 @@
 #endif
 }
 
-GType
-purple_media_state_changed_get_type()
-{
-	static GType type = 0;
-	if (type == 0) {
-		static const GEnumValue values[] = {
-			{ PURPLE_MEDIA_STATE_NEW,
-				"PURPLE_MEDIA_STATE_NEW", "new" },
-			{ PURPLE_MEDIA_STATE_CONNECTED,
-				"PURPLE_MEDIA_STATE_CONNECTED", "connected" },
-			{ PURPLE_MEDIA_STATE_END,
-				"PURPLE_MEDIA_STATE_END", "end" },
-			{ 0, NULL, NULL }
-		};
-		type = g_enum_register_static("PurpleMediaState", values);
-	}
-	return type;
-}
-
-GType
-purple_media_info_type_get_type()
-{
-	static GType type = 0;
-	if (type == 0) {
-		static const GEnumValue values[] = {
-			{ PURPLE_MEDIA_INFO_HANGUP,
-					"PURPLE_MEDIA_INFO_HANGUP", "hangup" },
-			{ PURPLE_MEDIA_INFO_ACCEPT,
-					"PURPLE_MEDIA_INFO_ACCEPT", "accept" },
-			{ PURPLE_MEDIA_INFO_REJECT,
-					"PURPLE_MEDIA_INFO_REJECT", "reject" },
-			{ PURPLE_MEDIA_INFO_MUTE,
-					"PURPLE_MEDIA_INFO_MUTE", "mute" },
-			{ PURPLE_MEDIA_INFO_UNMUTE,
-					"PURPLE_MEDIA_INFO_UNMUTE", "unmute" },
-			{ PURPLE_MEDIA_INFO_PAUSE,
-					"PURPLE_MEDIA_INFO_PAUSE", "pause" },
-			{ PURPLE_MEDIA_INFO_UNPAUSE,
-					"PURPLE_MEDIA_INFO_UNPAUSE", "unpause" },
-			{ PURPLE_MEDIA_INFO_HOLD,
-					"PURPLE_MEDIA_INFO_HOLD", "hold" },
-			{ PURPLE_MEDIA_INFO_UNHOLD,
-					"PURPLE_MEDIA_INFO_UNHOLD", "unhold" },
-			{ 0, NULL, NULL }
-		};
-		type = g_enum_register_static("PurpleMediaInfoType", values);
-	}
-	return type;
-}
-
 #ifdef USE_VV
 static void
 purple_media_class_init (PurpleMediaClass *klass)
 {
 	GObjectClass *gobject_class = (GObjectClass*)klass;
 	parent_class = g_type_class_peek_parent(klass);
-	
+
 	gobject_class->dispose = purple_media_dispose;
 	gobject_class->finalize = purple_media_finalize;
 	gobject_class->set_property = purple_media_set_property;
@@ -308,18 +203,30 @@
 			PURPLE_TYPE_MEDIA_MANAGER,
 			G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
 
+	/*
+	 * This one should be PURPLE_TYPE_MEDIA_BACKEND, but it doesn't
+	 * like interfaces because they "aren't GObjects"
+	 */
+	g_object_class_install_property(gobject_class, PROP_BACKEND,
+			g_param_spec_object("backend",
+			"Purple Media Backend",
+			"The backend object this media object uses.",
+			G_TYPE_OBJECT,
+			G_PARAM_READABLE));
+
 	g_object_class_install_property(gobject_class, PROP_ACCOUNT,
 			g_param_spec_pointer("account",
 			"PurpleAccount",
 			"The account this media session is on.",
 			G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
 
-	g_object_class_install_property(gobject_class, PROP_CONFERENCE,
-			g_param_spec_object("conference",
-			"Farsight conference",
-			"The FsConference associated with this media.",
-			FS_TYPE_CONFERENCE,
-			G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
+	g_object_class_install_property(gobject_class, PROP_CONFERENCE_TYPE,
+			g_param_spec_string("conference-type",
+			"Conference Type",
+			"The type of conference that this media object "
+			"has been created to provide.",
+			NULL,
+			G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
 
 	g_object_class_install_property(gobject_class, PROP_INITIATOR,
 			g_param_spec_boolean("initiator",
@@ -384,21 +291,19 @@
 	if (stream == NULL)
 		return;
 
-	/* Remove the connected_cb timeout */
-	if (stream->connected_cb_id != 0)
-		purple_timeout_remove(stream->connected_cb_id);
-
 	g_free(stream->participant);
 
 	if (stream->local_candidates)
-		fs_candidate_list_destroy(stream->local_candidates);
+		purple_media_candidate_list_free(stream->local_candidates);
 	if (stream->remote_candidates)
-		fs_candidate_list_destroy(stream->remote_candidates);
+		purple_media_candidate_list_free(stream->remote_candidates);
 
 	if (stream->active_local_candidates)
-		fs_candidate_list_destroy(stream->active_local_candidates);
+		purple_media_candidate_list_free(
+				stream->active_local_candidates);
 	if (stream->active_remote_candidates)
-		fs_candidate_list_destroy(stream->active_remote_candidates);
+		purple_media_candidate_list_free(
+				stream->active_remote_candidates);
 
 	g_free(stream);
 }
@@ -417,56 +322,17 @@
 purple_media_dispose(GObject *media)
 {
 	PurpleMediaPrivate *priv = PURPLE_MEDIA_GET_PRIVATE(media);
-	GList *iter = NULL;
 
 	purple_debug_info("media","purple_media_dispose\n");
 
 	purple_media_manager_remove_media(priv->manager, PURPLE_MEDIA(media));
 
-	if (priv->confbin) {
-		gst_element_set_locked_state(priv->confbin, TRUE);
-		gst_element_set_state(GST_ELEMENT(priv->confbin),
-				GST_STATE_NULL);
-		gst_bin_remove(GST_BIN(purple_media_manager_get_pipeline(
-				priv->manager)), priv->confbin);
-		priv->confbin = NULL;
-		priv->conference = NULL;
-	}
-
-	for (iter = priv->streams; iter; iter = g_list_next(iter)) {
-		PurpleMediaStream *stream = iter->data;
-		if (stream->stream) {
-			g_object_unref(stream->stream);
-			stream->stream = NULL;
-		}
-	}
-
-	if (priv->sessions) {
-		GList *sessions = g_hash_table_get_values(priv->sessions);
-		for (; sessions; sessions = g_list_delete_link(sessions, sessions)) {
-			PurpleMediaSession *session = sessions->data;
-			if (session->session) {
-				g_object_unref(session->session);
-				session->session = NULL;
-			}
-		}
-	}
-
-	if (priv->participants) {
-		GList *participants = g_hash_table_get_values(priv->participants);
-		for (; participants; participants = g_list_delete_link(participants, participants))
-			g_object_unref(participants->data);
+	if (priv->backend) {
+		g_object_unref(priv->backend);
+		priv->backend = NULL;
 	}
 
 	if (priv->manager) {
-		GstElement *pipeline = purple_media_manager_get_pipeline(
-				priv->manager);
-		GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
-		g_signal_handlers_disconnect_matched(G_OBJECT(bus),
-				G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA,
-				0, 0, 0, media_bus_call, media);
-		gst_object_unref(bus);
-
 		g_object_unref(priv->manager);
 		priv->manager = NULL;
 	}
@@ -483,6 +349,10 @@
 	for (; priv->streams; priv->streams = g_list_delete_link(priv->streams, priv->streams))
 		purple_media_stream_free(priv->streams->data);
 
+	for (; priv->participants; priv->participants = g_list_delete_link(
+			priv->participants, priv->participants))
+		g_free(priv->participants->data);
+
 	if (priv->sessions) {
 		GList *sessions = g_hash_table_get_values(priv->sessions);
 		for (; sessions; sessions = g_list_delete_link(sessions, sessions)) {
@@ -495,36 +365,6 @@
 }
 
 static void
-purple_media_setup_pipeline(PurpleMedia *media)
-{
-	GstBus *bus;
-	gchar *name;
-	GstElement *pipeline;
-
-	if (media->priv->conference == NULL || media->priv->manager == NULL)
-		return;
-
-	pipeline = purple_media_manager_get_pipeline(media->priv->manager);
-
-	name = g_strdup_printf("conf_%p",
-			media->priv->conference);
-	media->priv->confbin = gst_bin_new(name);
-	g_free(name);
-
-	bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
-	g_signal_connect(G_OBJECT(bus), "message",
-			G_CALLBACK(media_bus_call), media);
-	gst_object_unref(bus);
-
-	gst_bin_add(GST_BIN(pipeline),
-			media->priv->confbin);
-	gst_bin_add(GST_BIN(media->priv->confbin),
-			GST_ELEMENT(media->priv->conference));
-	gst_element_set_state(GST_ELEMENT(media->priv->confbin),
-			GST_STATE_PLAYING);
-}
-
-static void
 purple_media_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
 {
 	PurpleMedia *media;
@@ -534,30 +374,49 @@
 
 	switch (prop_id) {
 		case PROP_MANAGER:
-			media->priv->manager = g_value_get_object(value);
-			g_object_ref(media->priv->manager);
-
-			purple_media_setup_pipeline(media);
+			media->priv->manager = g_value_dup_object(value);
 			break;
 		case PROP_ACCOUNT:
 			media->priv->account = g_value_get_pointer(value);
 			break;
-		case PROP_CONFERENCE: {
-			if (media->priv->conference)
-				gst_object_unref(media->priv->conference);
-			media->priv->conference = g_value_get_object(value);
-			gst_object_ref(media->priv->conference);
-
-			purple_media_setup_pipeline(media);
+		case PROP_CONFERENCE_TYPE:
+			media->priv->conference_type =
+					g_value_dup_string(value);
+			media->priv->backend = g_object_new(
+					purple_media_manager_get_backend_type(
+					purple_media_manager_get()),
+					"conference-type",
+					media->priv->conference_type,
+					"media", media,
+					NULL);
+			g_signal_connect(media->priv->backend,
+					"active-candidate-pair",
+					G_CALLBACK(
+					purple_media_candidate_pair_established_cb),
+					media);
+			g_signal_connect(media->priv->backend,
+					"candidates-prepared",
+					G_CALLBACK(
+					purple_media_candidates_prepared_cb),
+					media);
+			g_signal_connect(media->priv->backend,
+					"codecs-changed",
+					G_CALLBACK(
+					purple_media_codecs_changed_cb),
+					media);
+			g_signal_connect(media->priv->backend,
+					"new-candidate",
+					G_CALLBACK(
+					purple_media_new_local_candidate_cb),
+					media);
 			break;
-		}
 		case PROP_INITIATOR:
 			media->priv->initiator = g_value_get_boolean(value);
 			break;
 		case PROP_PRPL_DATA:
 			media->priv->prpl_data = g_value_get_pointer(value);
 			break;
-		default:	
+		default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 			break;
 	}
@@ -568,18 +427,22 @@
 {
 	PurpleMedia *media;
 	g_return_if_fail(PURPLE_IS_MEDIA(object));
-	
+
 	media = PURPLE_MEDIA(object);
 
 	switch (prop_id) {
 		case PROP_MANAGER:
 			g_value_set_object(value, media->priv->manager);
 			break;
+		case PROP_BACKEND:
+			g_value_set_object(value, media->priv->backend);
+			break;
 		case PROP_ACCOUNT:
 			g_value_set_pointer(value, media->priv->account);
 			break;
-		case PROP_CONFERENCE:
-			g_value_set_object(value, media->priv->conference);
+		case PROP_CONFERENCE_TYPE:
+			g_value_set_string(value,
+					media->priv->conference_type);
 			break;
 		case PROP_INITIATOR:
 			g_value_set_boolean(value, media->priv->initiator);
@@ -587,1133 +450,13 @@
 		case PROP_PRPL_DATA:
 			g_value_set_pointer(value, media->priv->prpl_data);
 			break;
-		default:	
-			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);	
+		default:
+			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 			break;
 	}
 
 }
-#endif
 
-/*
- * PurpleMediaCandidateType
- */
-
-GType
-purple_media_candidate_type_get_type()
-{
-	static GType type = 0;
-	if (type == 0) {
-		static const GEnumValue values[] = {
-			{ PURPLE_MEDIA_CANDIDATE_TYPE_HOST,
-					"PURPLE_MEDIA_CANDIDATE_TYPE_HOST",
-					"host" },
-			{ PURPLE_MEDIA_CANDIDATE_TYPE_SRFLX,
-					"PURPLE_MEDIA_CANDIDATE_TYPE_SRFLX",
-					"srflx" },
-			{ PURPLE_MEDIA_CANDIDATE_TYPE_PRFLX,
-					"PURPLE_MEDIA_CANDIDATE_TYPE_PRFLX",
-					"prflx" },
-			{ PURPLE_MEDIA_CANDIDATE_TYPE_RELAY,
-					"PPURPLE_MEDIA_CANDIDATE_TYPE_RELAY",
-					"relay" },
-			{ PURPLE_MEDIA_CANDIDATE_TYPE_MULTICAST,
-					"PURPLE_MEDIA_CANDIDATE_TYPE_MULTICAST",
-					"multicast" },
-			{ 0, NULL, NULL }
-		};
-		type = g_enum_register_static("PurpleMediaCandidateType",
-				values);
-	}
-	return type;
-}
-
-/*
- * PurpleMediaNetworkProtocol
- */
-
-GType
-purple_media_network_protocol_get_type()
-{
-	static GType type = 0;
-	if (type == 0) {
-		static const GEnumValue values[] = {
-			{ PURPLE_MEDIA_NETWORK_PROTOCOL_UDP,
-					"PURPLE_MEDIA_NETWORK_PROTOCOL_UDP",
-					"udp" },
-			{ PURPLE_MEDIA_NETWORK_PROTOCOL_TCP,
-					"PURPLE_MEDIA_NETWORK_PROTOCOL_TCP",
-					"tcp" },
-			{ 0, NULL, NULL }
-		};
-		type = g_enum_register_static("PurpleMediaNetworkProtocol",
-				values);
-	}
-	return type;
-}
-
-/*
- * PurpleMediaCandidate
- */
-
-struct _PurpleMediaCandidateClass
-{
-	GObjectClass parent_class;
-};
-
-struct _PurpleMediaCandidate
-{
-	GObject parent;
-};
-
-#ifdef USE_VV
-struct _PurpleMediaCandidatePrivate
-{
-	gchar *foundation;
-	guint component_id;
-	gchar *ip;
-	guint16 port;
-	gchar *base_ip;
-	guint16 base_port;
-	PurpleMediaNetworkProtocol proto;
-	guint32 priority;
-	PurpleMediaCandidateType type;
-	gchar *username;
-	gchar *password;
-	guint ttl;
-};
-
-enum {
-	PROP_CANDIDATE_0,
-	PROP_FOUNDATION,
-	PROP_COMPONENT_ID,
-	PROP_IP,
-	PROP_PORT,
-	PROP_BASE_IP,
-	PROP_BASE_PORT,
-	PROP_PROTOCOL,
-	PROP_PRIORITY,
-	PROP_TYPE,
-	PROP_USERNAME,
-	PROP_PASSWORD,
-	PROP_TTL,
-};
-
-static void
-purple_media_candidate_init(PurpleMediaCandidate *info)
-{
-	PurpleMediaCandidatePrivate *priv =
-			PURPLE_MEDIA_CANDIDATE_GET_PRIVATE(info);
-	priv->foundation = NULL;
-	priv->component_id = 0;
-	priv->ip = NULL;
-	priv->port = 0;
-	priv->base_ip = NULL;
-	priv->proto = PURPLE_MEDIA_NETWORK_PROTOCOL_UDP;
-	priv->priority = 0;
-	priv->type = PURPLE_MEDIA_CANDIDATE_TYPE_HOST;
-	priv->username = NULL;
-	priv->password = NULL;
-	priv->ttl = 0;
-}
-
-static void
-purple_media_candidate_finalize(GObject *info)
-{
-	PurpleMediaCandidatePrivate *priv =
-			PURPLE_MEDIA_CANDIDATE_GET_PRIVATE(info);
-
-	g_free(priv->foundation);
-	g_free(priv->ip);
-	g_free(priv->base_ip);
-	g_free(priv->username);
-	g_free(priv->password);
-}
-
-static void
-purple_media_candidate_set_property (GObject *object, guint prop_id,
-		const GValue *value, GParamSpec *pspec)
-{
-	PurpleMediaCandidatePrivate *priv;
-	g_return_if_fail(PURPLE_IS_MEDIA_CANDIDATE(object));
-
-	priv = PURPLE_MEDIA_CANDIDATE_GET_PRIVATE(object);
-
-	switch (prop_id) {
-		case PROP_FOUNDATION:
-			g_free(priv->foundation);
-			priv->foundation = g_value_dup_string(value);
-			break;
-		case PROP_COMPONENT_ID:
-			priv->component_id = g_value_get_uint(value);
-			break;
-		case PROP_IP:
-			g_free(priv->ip);
-			priv->ip = g_value_dup_string(value);
-			break;
-		case PROP_PORT:
-			priv->port = g_value_get_uint(value);
-			break;
-		case PROP_BASE_IP:
-			g_free(priv->base_ip);
-			priv->base_ip = g_value_dup_string(value);
-			break;
-		case PROP_BASE_PORT:
-			priv->base_port = g_value_get_uint(value);
-			break;
-		case PROP_PROTOCOL:
-			priv->proto = g_value_get_enum(value);
-			break;
-		case PROP_PRIORITY:
-			priv->priority = g_value_get_uint(value);
-			break;
-		case PROP_TYPE:
-			priv->type = g_value_get_enum(value);
-			break;
-		case PROP_USERNAME:
-			g_free(priv->username);
-			priv->username = g_value_dup_string(value);
-			break;
-		case PROP_PASSWORD:
-			g_free(priv->password);
-			priv->password = g_value_dup_string(value);
-			break;
-		case PROP_TTL:
-			priv->ttl = g_value_get_uint(value);
-			break;
-		default:	
-			G_OBJECT_WARN_INVALID_PROPERTY_ID(
-					object, prop_id, pspec);
-			break;
-	}
-}
-
-static void
-purple_media_candidate_get_property (GObject *object, guint prop_id,
-		GValue *value, GParamSpec *pspec)
-{
-	PurpleMediaCandidatePrivate *priv;
-	g_return_if_fail(PURPLE_IS_MEDIA_CANDIDATE(object));
-	
-	priv = PURPLE_MEDIA_CANDIDATE_GET_PRIVATE(object);
-
-	switch (prop_id) {
-		case PROP_FOUNDATION:
-			g_value_set_string(value, priv->foundation);
-			break;
-		case PROP_COMPONENT_ID:
-			g_value_set_uint(value, priv->component_id);
-			break;
-		case PROP_IP:
-			g_value_set_string(value, priv->ip);
-			break;
-		case PROP_PORT:
-			g_value_set_uint(value, priv->port);
-			break;
-		case PROP_BASE_IP:
-			g_value_set_string(value, priv->base_ip);
-			break;
-		case PROP_BASE_PORT:
-			g_value_set_uint(value, priv->base_port);
-			break;
-		case PROP_PROTOCOL:
-			g_value_set_enum(value, priv->proto);
-			break;
-		case PROP_PRIORITY:
-			g_value_set_uint(value, priv->priority);
-			break;
-		case PROP_TYPE:
-			g_value_set_enum(value, priv->type);
-			break;
-		case PROP_USERNAME:
-			g_value_set_string(value, priv->username);
-			break;
-		case PROP_PASSWORD:
-			g_value_set_string(value, priv->password);
-			break;
-		case PROP_TTL:
-			g_value_set_uint(value, priv->ttl);
-			break;
-		default:
-			G_OBJECT_WARN_INVALID_PROPERTY_ID(
-					object, prop_id, pspec);
-			break;
-	}
-}
-
-static void
-purple_media_candidate_class_init(PurpleMediaCandidateClass *klass)
-{
-	GObjectClass *gobject_class = (GObjectClass*)klass;
-	
-	gobject_class->finalize = purple_media_candidate_finalize;
-	gobject_class->set_property = purple_media_candidate_set_property;
-	gobject_class->get_property = purple_media_candidate_get_property;
-
-	g_object_class_install_property(gobject_class, PROP_FOUNDATION,
-			g_param_spec_string("foundation",
-			"Foundation",
-			"The foundation of the candidate.",
-			NULL,
-			G_PARAM_READWRITE));
-
-	g_object_class_install_property(gobject_class, PROP_COMPONENT_ID,
-			g_param_spec_uint("component-id",
-			"Component ID",
-			"The component id of the candidate.",
-			0, G_MAXUINT, 0,
-			G_PARAM_READWRITE));
-
-	g_object_class_install_property(gobject_class, PROP_IP,
-			g_param_spec_string("ip",
-			"IP Address",
-			"The IP address of the candidate.",
-			NULL,
-			G_PARAM_READWRITE));
-
-	g_object_class_install_property(gobject_class, PROP_PORT,
-			g_param_spec_uint("port",
-			"Port",
-			"The port of the candidate.",
-			0, G_MAXUINT16, 0,
-			G_PARAM_READWRITE));
-
-	g_object_class_install_property(gobject_class, PROP_BASE_IP,
-			g_param_spec_string("base-ip",
-			"Base IP",
-			"The internal IP address of the candidate.",
-			NULL,
-			G_PARAM_READWRITE));
-
-	g_object_class_install_property(gobject_class, PROP_BASE_PORT,
-			g_param_spec_uint("base-port",
-			"Base Port",
-			"The internal port of the candidate.",
-			0, G_MAXUINT16, 0,
-			G_PARAM_READWRITE));
-
-	g_object_class_install_property(gobject_class, PROP_PROTOCOL,
-			g_param_spec_enum("protocol",
-			"Protocol",
-			"The protocol of the candidate.",
-			PURPLE_TYPE_MEDIA_NETWORK_PROTOCOL,
-			PURPLE_MEDIA_NETWORK_PROTOCOL_UDP,
-			G_PARAM_READWRITE));
-
-	g_object_class_install_property(gobject_class, PROP_PRIORITY,
-			g_param_spec_uint("priority",
-			"Priority",
-			"The priority of the candidate.",
-			0, G_MAXUINT32, 0,
-			G_PARAM_READWRITE));
-
-	g_object_class_install_property(gobject_class, PROP_TYPE,
-			g_param_spec_enum("type",
-			"Type",
-			"The type of the candidate.",
-			PURPLE_TYPE_MEDIA_CANDIDATE_TYPE,
-			PURPLE_MEDIA_CANDIDATE_TYPE_HOST,
-			G_PARAM_READWRITE));
-
-	g_object_class_install_property(gobject_class, PROP_USERNAME,
-			g_param_spec_string("username",
-			"Username",
-			"The username used to connect to the candidate.",
-			NULL,
-			G_PARAM_READWRITE));
-
-	g_object_class_install_property(gobject_class, PROP_PASSWORD,
-			g_param_spec_string("password",
-			"Password",
-			"The password use to connect to the candidate.",
-			NULL,
-			G_PARAM_READWRITE));
-
-	g_object_class_install_property(gobject_class, PROP_TTL,
-			g_param_spec_uint("ttl",
-			"TTL",
-			"The TTL of the candidate.",
-			0, G_MAXUINT, 0,
-			G_PARAM_READWRITE));
-
-	g_type_class_add_private(klass, sizeof(PurpleMediaCandidatePrivate));
-}
-
-G_DEFINE_TYPE(PurpleMediaCandidate,
-		purple_media_candidate, G_TYPE_OBJECT);
-#else
-GType
-purple_media_candidate_get_type()
-{
-	return G_TYPE_NONE;
-}
-#endif
-
-PurpleMediaCandidate *
-purple_media_candidate_new(const gchar *foundation, guint component_id,
-		PurpleMediaCandidateType type,
-		PurpleMediaNetworkProtocol proto,
-		const gchar *ip, guint port)
-{
-	return g_object_new(PURPLE_TYPE_MEDIA_CANDIDATE,
-			"foundation", foundation,
-			"component-id", component_id,
-			"type", type,
-			"protocol", proto,
-			"ip", ip,
-			"port", port, NULL);
-}
-
-static PurpleMediaCandidate *
-purple_media_candidate_copy(PurpleMediaCandidate *candidate)
-{
-#ifdef USE_VV
-	PurpleMediaCandidatePrivate *priv;
-	PurpleMediaCandidate *new_candidate;
-
-	if (candidate == NULL)
-		return NULL;
-
-	priv = PURPLE_MEDIA_CANDIDATE_GET_PRIVATE(candidate);
-
-	new_candidate = purple_media_candidate_new(priv->foundation,
-			priv->component_id, priv->type, priv->proto,
-			priv->ip, priv->port);
-	g_object_set(new_candidate,
-			"base-ip", priv->base_ip,
-			"base-port", priv->base_port,
-			"priority", priv->priority,
-			"username", priv->username,
-			"password", priv->password,
-			"ttl", priv->ttl, NULL);
-	return new_candidate;
-#else
-	return NULL;
-#endif
-}
-
-#ifdef USE_VV
-static FsCandidate *
-purple_media_candidate_to_fs(PurpleMediaCandidate *candidate)
-{
-	PurpleMediaCandidatePrivate *priv;
-	FsCandidate *fscandidate;
-
-	if (candidate == NULL)
-		return NULL;
-
-	priv = PURPLE_MEDIA_CANDIDATE_GET_PRIVATE(candidate);
-
-	fscandidate = fs_candidate_new(priv->foundation,
-			priv->component_id, priv->type,
-			priv->proto, priv->ip, priv->port);
-
-	fscandidate->base_ip = g_strdup(priv->base_ip);
-	fscandidate->base_port = priv->base_port;
-	fscandidate->priority = priv->priority;
-	fscandidate->username = g_strdup(priv->username);
-	fscandidate->password = g_strdup(priv->password);
-	fscandidate->ttl = priv->ttl;
-	return fscandidate;
-}
-
-static PurpleMediaCandidate *
-purple_media_candidate_from_fs(FsCandidate *fscandidate)
-{
-	PurpleMediaCandidate *candidate;
-
-	if (fscandidate == NULL)
-		return NULL;
-
-	candidate = purple_media_candidate_new(fscandidate->foundation,
-		fscandidate->component_id, fscandidate->type,
-		fscandidate->proto, fscandidate->ip, fscandidate->port);
-	g_object_set(candidate,
-			"base-ip", fscandidate->base_ip,
-			"base-port", fscandidate->base_port,
-			"priority", fscandidate->priority,
-			"username", fscandidate->username,
-			"password", fscandidate->password,
-			"ttl", fscandidate->ttl, NULL);
-	return candidate;
-}
-
-static GList *
-purple_media_candidate_list_from_fs(GList *candidates)
-{
-	GList *new_list = NULL;
-
-	for (; candidates; candidates = g_list_next(candidates)) {
-		new_list = g_list_prepend(new_list,
-				purple_media_candidate_from_fs(
-				candidates->data));
-	}
-
-	new_list = g_list_reverse(new_list);
-	return new_list;
-}
-
-static GList *
-purple_media_candidate_list_to_fs(GList *candidates)
-{
-	GList *new_list = NULL;
-
-	for (; candidates; candidates = g_list_next(candidates)) {
-		new_list = g_list_prepend(new_list,
-				purple_media_candidate_to_fs(
-				candidates->data));
-	}
-
-	new_list = g_list_reverse(new_list);
-	return new_list;
-}
-#endif
-
-GList *
-purple_media_candidate_list_copy(GList *candidates)
-{
-	GList *new_list = NULL;
-
-	for (; candidates; candidates = g_list_next(candidates)) {
-		new_list = g_list_prepend(new_list,
-				purple_media_candidate_copy(candidates->data));
-	}
-
-	new_list = g_list_reverse(new_list);
-	return new_list;
-}
-
-void
-purple_media_candidate_list_free(GList *candidates)
-{
-	for (; candidates; candidates =
-			g_list_delete_link(candidates, candidates)) {
-		g_object_unref(candidates->data);
-	}
-}
-
-gchar *
-purple_media_candidate_get_foundation(PurpleMediaCandidate *candidate)
-{
-	gchar *foundation;
-	g_return_val_if_fail(PURPLE_IS_MEDIA_CANDIDATE(candidate), NULL);
-	g_object_get(candidate, "foundation", &foundation, NULL);
-	return foundation;
-}
-
-guint
-purple_media_candidate_get_component_id(PurpleMediaCandidate *candidate)
-{
-	guint component_id;
-	g_return_val_if_fail(PURPLE_IS_MEDIA_CANDIDATE(candidate), 0);
-	g_object_get(candidate, "component-id", &component_id, NULL);
-	return component_id;
-}
-
-gchar *
-purple_media_candidate_get_ip(PurpleMediaCandidate *candidate)
-{
-	gchar *ip;
-	g_return_val_if_fail(PURPLE_IS_MEDIA_CANDIDATE(candidate), NULL);
-	g_object_get(candidate, "ip", &ip, NULL);
-	return ip;
-}
-
-guint16
-purple_media_candidate_get_port(PurpleMediaCandidate *candidate)
-{
-	guint port;
-	g_return_val_if_fail(PURPLE_IS_MEDIA_CANDIDATE(candidate), 0);
-	g_object_get(candidate, "port", &port, NULL);
-	return port;
-}
-
-gchar *
-purple_media_candidate_get_base_ip(PurpleMediaCandidate *candidate)
-{
-	gchar *base_ip;
-	g_return_val_if_fail(PURPLE_IS_MEDIA_CANDIDATE(candidate), NULL);
-	g_object_get(candidate, "base-ip", &base_ip, NULL);
-	return base_ip;
-}
-
-guint16
-purple_media_candidate_get_base_port(PurpleMediaCandidate *candidate)
-{
-	guint base_port;
-	g_return_val_if_fail(PURPLE_IS_MEDIA_CANDIDATE(candidate), 0);
-	g_object_get(candidate, "base_port", &base_port, NULL);
-	return base_port;
-}
-
-PurpleMediaNetworkProtocol
-purple_media_candidate_get_protocol(PurpleMediaCandidate *candidate)
-{
-	PurpleMediaNetworkProtocol protocol;
-	g_return_val_if_fail(PURPLE_IS_MEDIA_CANDIDATE(candidate),
-			PURPLE_MEDIA_NETWORK_PROTOCOL_UDP);
-	g_object_get(candidate, "protocol", &protocol, NULL);
-	return protocol;
-}
-
-guint32
-purple_media_candidate_get_priority(PurpleMediaCandidate *candidate)
-{
-	guint priority;
-	g_return_val_if_fail(PURPLE_IS_MEDIA_CANDIDATE(candidate), 0);
-	g_object_get(candidate, "priority", &priority, NULL);
-	return priority;
-}
-
-PurpleMediaCandidateType
-purple_media_candidate_get_candidate_type(PurpleMediaCandidate *candidate)
-{
-	PurpleMediaCandidateType type;
-	g_return_val_if_fail(PURPLE_IS_MEDIA_CANDIDATE(candidate),
-			PURPLE_MEDIA_CANDIDATE_TYPE_HOST);
-	g_object_get(candidate, "type", &type, NULL);
-	return type;
-}
-
-gchar *
-purple_media_candidate_get_username(PurpleMediaCandidate *candidate)
-{
-	gchar *username;
-	g_return_val_if_fail(PURPLE_IS_MEDIA_CANDIDATE(candidate), NULL);
-	g_object_get(candidate, "username", &username, NULL);
-	return username;
-}
-
-gchar *
-purple_media_candidate_get_password(PurpleMediaCandidate *candidate)
-{
-	gchar *password;
-	g_return_val_if_fail(PURPLE_IS_MEDIA_CANDIDATE(candidate), NULL);
-	g_object_get(candidate, "password", &password, NULL);
-	return password;
-}
-
-guint
-purple_media_candidate_get_ttl(PurpleMediaCandidate *candidate)
-{
-	guint ttl;
-	g_return_val_if_fail(PURPLE_IS_MEDIA_CANDIDATE(candidate), 0);
-	g_object_get(candidate, "ttl", &ttl, NULL);
-	return ttl;
-}
-
-#ifdef USE_VV
-static FsMediaType
-purple_media_to_fs_media_type(PurpleMediaSessionType type)
-{
-	if (type & PURPLE_MEDIA_AUDIO)
-		return FS_MEDIA_TYPE_AUDIO;
-	else if (type & PURPLE_MEDIA_VIDEO)
-		return FS_MEDIA_TYPE_VIDEO;
-	else
-		return 0;
-}
-
-static FsStreamDirection
-purple_media_to_fs_stream_direction(PurpleMediaSessionType type)
-{
-	if ((type & PURPLE_MEDIA_AUDIO) == PURPLE_MEDIA_AUDIO ||
-			(type & PURPLE_MEDIA_VIDEO) == PURPLE_MEDIA_VIDEO)
-		return FS_DIRECTION_BOTH;
-	else if ((type & PURPLE_MEDIA_SEND_AUDIO) ||
-			(type & PURPLE_MEDIA_SEND_VIDEO))
-		return FS_DIRECTION_SEND;
-	else if ((type & PURPLE_MEDIA_RECV_AUDIO) ||
-			(type & PURPLE_MEDIA_RECV_VIDEO))
-		return FS_DIRECTION_RECV;
-	else
-		return FS_DIRECTION_NONE;
-}
-
-static PurpleMediaSessionType
-purple_media_from_fs(FsMediaType type, FsStreamDirection direction)
-{
-	PurpleMediaSessionType result = PURPLE_MEDIA_NONE;
-	if (type == FS_MEDIA_TYPE_AUDIO) {
-		if (direction & FS_DIRECTION_SEND)
-			result |= PURPLE_MEDIA_SEND_AUDIO;
-		if (direction & FS_DIRECTION_RECV)
-			result |= PURPLE_MEDIA_RECV_AUDIO;
-	} else if (type == FS_MEDIA_TYPE_VIDEO) {
-		if (direction & FS_DIRECTION_SEND)
-			result |= PURPLE_MEDIA_SEND_VIDEO;
-		if (direction & FS_DIRECTION_RECV)
-			result |= PURPLE_MEDIA_RECV_VIDEO;
-	}
-	return result;
-}
-#endif
-
-/*
- * PurpleMediaCodec
- */
-
-struct _PurpleMediaCodecClass
-{
-	GObjectClass parent_class;
-};
-
-struct _PurpleMediaCodec
-{
-	GObject parent;
-};
-
-#ifdef USE_VV
-struct _PurpleMediaCodecPrivate
-{
-	gint id;
-	char *encoding_name;
-	PurpleMediaSessionType media_type;
-	guint clock_rate;
-	guint channels;
-	GList *optional_params;
-};
-
-enum {
-	PROP_CODEC_0,
-	PROP_ID,
-	PROP_ENCODING_NAME,
-	PROP_MEDIA_TYPE,
-	PROP_CLOCK_RATE,
-	PROP_CHANNELS,
-	PROP_OPTIONAL_PARAMS,
-};
-
-static void
-purple_media_codec_init(PurpleMediaCodec *info)
-{
-	PurpleMediaCodecPrivate *priv =
-			PURPLE_MEDIA_CODEC_GET_PRIVATE(info);
-	priv->encoding_name = NULL;
-	priv->optional_params = NULL;
-}
-
-static void
-purple_media_codec_finalize(GObject *info)
-{
-	PurpleMediaCodecPrivate *priv =
-			PURPLE_MEDIA_CODEC_GET_PRIVATE(info);
-	g_free(priv->encoding_name);
-	for (; priv->optional_params; priv->optional_params =
-			g_list_delete_link(priv->optional_params,
-			priv->optional_params)) {
-		g_free(priv->optional_params->data);
-	}
-}
-
-static void
-purple_media_codec_set_property (GObject *object, guint prop_id,
-		const GValue *value, GParamSpec *pspec)
-{
-	PurpleMediaCodecPrivate *priv;
-	g_return_if_fail(PURPLE_IS_MEDIA_CODEC(object));
-
-	priv = PURPLE_MEDIA_CODEC_GET_PRIVATE(object);
-
-	switch (prop_id) {
-		case PROP_ID:
-			priv->id = g_value_get_uint(value);
-			break;
-		case PROP_ENCODING_NAME:
-			g_free(priv->encoding_name);
-			priv->encoding_name = g_value_dup_string(value);
-			break;
-		case PROP_MEDIA_TYPE:
-			priv->media_type = g_value_get_flags(value);
-			break;
-		case PROP_CLOCK_RATE:
-			priv->clock_rate = g_value_get_uint(value);
-			break;
-		case PROP_CHANNELS:
-			priv->channels = g_value_get_uint(value);
-			break;
-		case PROP_OPTIONAL_PARAMS:
-			priv->optional_params = g_value_get_pointer(value);
-			break;
-		default:	
-			G_OBJECT_WARN_INVALID_PROPERTY_ID(
-					object, prop_id, pspec);
-			break;
-	}
-}
-
-static void
-purple_media_codec_get_property (GObject *object, guint prop_id,
-		GValue *value, GParamSpec *pspec)
-{
-	PurpleMediaCodecPrivate *priv;
-	g_return_if_fail(PURPLE_IS_MEDIA_CODEC(object));
-	
-	priv = PURPLE_MEDIA_CODEC_GET_PRIVATE(object);
-
-	switch (prop_id) {
-		case PROP_ID:
-			g_value_set_uint(value, priv->id);
-			break;
-		case PROP_ENCODING_NAME:
-			g_value_set_string(value, priv->encoding_name);
-			break;
-		case PROP_MEDIA_TYPE:
-			g_value_set_flags(value, priv->media_type);
-			break;
-		case PROP_CLOCK_RATE:
-			g_value_set_uint(value, priv->clock_rate);
-			break;
-		case PROP_CHANNELS:
-			g_value_set_uint(value, priv->channels);
-			break;
-		case PROP_OPTIONAL_PARAMS:
-			g_value_set_pointer(value, priv->optional_params);
-			break;
-		default:	
-			G_OBJECT_WARN_INVALID_PROPERTY_ID(
-					object, prop_id, pspec);
-			break;
-	}
-}
-
-static void
-purple_media_codec_class_init(PurpleMediaCodecClass *klass)
-{
-	GObjectClass *gobject_class = (GObjectClass*)klass;
-	
-	gobject_class->finalize = purple_media_codec_finalize;
-	gobject_class->set_property = purple_media_codec_set_property;
-	gobject_class->get_property = purple_media_codec_get_property;
-
-	g_object_class_install_property(gobject_class, PROP_ID,
-			g_param_spec_uint("id",
-			"ID",
-			"The numeric identifier of the codec.",
-			0, G_MAXUINT, 0,
-			G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
-
-	g_object_class_install_property(gobject_class, PROP_ENCODING_NAME,
-			g_param_spec_string("encoding-name",
-			"Encoding Name",
-			"The name of the codec.",
-			NULL,
-			G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
-
-	g_object_class_install_property(gobject_class, PROP_MEDIA_TYPE,
-			g_param_spec_flags("media-type",
-			"Media Type",
-			"Whether this is an audio of video codec.",
-			PURPLE_TYPE_MEDIA_SESSION_TYPE,
-			PURPLE_MEDIA_NONE,
-			G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
-
-	g_object_class_install_property(gobject_class, PROP_CLOCK_RATE,
-			g_param_spec_uint("clock-rate",
-			"Create Callback",
-			"The function called to create this element.",
-			0, G_MAXUINT, 0,
-			G_PARAM_READWRITE));
-
-	g_object_class_install_property(gobject_class, PROP_CHANNELS,
-			g_param_spec_uint("channels",
-			"Channels",
-			"The number of channels in this codec.",
-			0, G_MAXUINT, 0,
-			G_PARAM_READWRITE));
-	g_object_class_install_property(gobject_class, PROP_OPTIONAL_PARAMS,
-			g_param_spec_pointer("optional-params",
-			"Optional Params",
-			"A list of optional parameters for the codec.",
-			G_PARAM_READWRITE));
-
-	g_type_class_add_private(klass, sizeof(PurpleMediaCodecPrivate));
-}
-
-G_DEFINE_TYPE(PurpleMediaCodec,
-		purple_media_codec, G_TYPE_OBJECT);
-#else
-GType
-purple_media_codec_get_type()
-{
-	return G_TYPE_NONE;
-}
-#endif
-
-guint
-purple_media_codec_get_id(PurpleMediaCodec *codec)
-{
-	guint id;
-	g_return_val_if_fail(PURPLE_IS_MEDIA_CODEC(codec), 0);
-	g_object_get(codec, "id", &id, NULL);
-	return id;
-}
-
-gchar *
-purple_media_codec_get_encoding_name(PurpleMediaCodec *codec)
-{
-	gchar *name;
-	g_return_val_if_fail(PURPLE_IS_MEDIA_CODEC(codec), NULL);
-	g_object_get(codec, "encoding-name", &name, NULL);
-	return name;
-}
-
-guint
-purple_media_codec_get_clock_rate(PurpleMediaCodec *codec)
-{
-	guint clock_rate;
-	g_return_val_if_fail(PURPLE_IS_MEDIA_CODEC(codec), 0);
-	g_object_get(codec, "clock-rate", &clock_rate, NULL);
-	return clock_rate;
-}
-
-guint
-purple_media_codec_get_channels(PurpleMediaCodec *codec)
-{
-	guint channels;
-	g_return_val_if_fail(PURPLE_IS_MEDIA_CODEC(codec), 0);
-	g_object_get(codec, "channels", &channels, NULL);
-	return channels;
-}
-
-GList *
-purple_media_codec_get_optional_parameters(PurpleMediaCodec *codec)
-{
-	GList *optional_params;
-	g_return_val_if_fail(PURPLE_IS_MEDIA_CODEC(codec), NULL);
-	g_object_get(codec, "optional-params", &optional_params, NULL);
-	return optional_params;
-}
-
-void
-purple_media_codec_add_optional_parameter(PurpleMediaCodec *codec,
-		const gchar *name, const gchar *value)
-{
-#ifdef USE_VV
-	PurpleMediaCodecPrivate *priv;
-	PurpleKeyValuePair *new_param;
-
-	g_return_if_fail(codec != NULL);
-	g_return_if_fail(name != NULL && value != NULL);
-
-	priv = PURPLE_MEDIA_CODEC_GET_PRIVATE(codec);
-
-	new_param = g_new0(PurpleKeyValuePair, 1);
-	new_param->key = g_strdup(name);
-	new_param->value = g_strdup(value);
-	priv->optional_params = g_list_append(
-			priv->optional_params, new_param);
-#endif
-}
-
-void
-purple_media_codec_remove_optional_parameter(PurpleMediaCodec *codec,
-		PurpleKeyValuePair *param)
-{
-#ifdef USE_VV
-	PurpleMediaCodecPrivate *priv;
-
-	g_return_if_fail(codec != NULL && param != NULL);
-
-	priv = PURPLE_MEDIA_CODEC_GET_PRIVATE(codec);
-
-	g_free(param->key);
-	g_free(param->value);
-	g_free(param);
-
-	priv->optional_params =
-			g_list_remove(priv->optional_params, param);
-#endif
-}
-
-PurpleKeyValuePair *
-purple_media_codec_get_optional_parameter(PurpleMediaCodec *codec,
-		const gchar *name, const gchar *value)
-{
-#ifdef USE_VV
-	PurpleMediaCodecPrivate *priv;
-	GList *iter;
-
-	g_return_val_if_fail(codec != NULL, NULL);
-	g_return_val_if_fail(name != NULL, NULL);
-
-	priv = PURPLE_MEDIA_CODEC_GET_PRIVATE(codec);
-
-	for (iter = priv->optional_params; iter; iter = g_list_next(iter)) {
-		PurpleKeyValuePair *param = iter->data;
-		if (!g_ascii_strcasecmp(param->key, name) &&
-				(value == NULL ||
-				!g_ascii_strcasecmp(param->value, value)))
-			return param;
-	}
-#endif
-
-	return NULL;
-}
-
-PurpleMediaCodec *
-purple_media_codec_new(int id, const char *encoding_name,
-		PurpleMediaSessionType media_type, guint clock_rate)
-{
-	PurpleMediaCodec *codec =
-			g_object_new(PURPLE_TYPE_MEDIA_CODEC,
-			"id", id,
-			"encoding_name", encoding_name,
-			"media_type", media_type,
-			"clock-rate", clock_rate, NULL);
-	return codec;
-}
-
-static PurpleMediaCodec *
-purple_media_codec_copy(PurpleMediaCodec *codec)
-{
-#ifdef USE_VV
-	PurpleMediaCodecPrivate *priv;
-	PurpleMediaCodec *new_codec;
-	GList *iter;
-
-	if (codec == NULL)
-		return NULL;
-
-	priv = PURPLE_MEDIA_CODEC_GET_PRIVATE(codec);
-
-	new_codec = purple_media_codec_new(priv->id, priv->encoding_name,
-			priv->media_type, priv->clock_rate);
-	g_object_set(codec, "channels", priv->channels, NULL);
-
-	for (iter = priv->optional_params; iter; iter = g_list_next(iter)) {
-		PurpleKeyValuePair *param =
-				(PurpleKeyValuePair*)iter->data;
-		purple_media_codec_add_optional_parameter(new_codec,
-				param->key, param->value);
-	}
-
-	return new_codec;
-#else
-	return NULL;
-#endif
-}
-
-#ifdef USE_VV
-static FsCodec *
-purple_media_codec_to_fs(const PurpleMediaCodec *codec)
-{
-	PurpleMediaCodecPrivate *priv;
-	FsCodec *new_codec;
-	GList *iter;
-
-	if (codec == NULL)
-		return NULL;
-
-	priv = PURPLE_MEDIA_CODEC_GET_PRIVATE(codec);
-
-	new_codec = fs_codec_new(priv->id, priv->encoding_name,
-			purple_media_to_fs_media_type(priv->media_type),
-			priv->clock_rate);
-	new_codec->channels = priv->channels;
-
-	for (iter = priv->optional_params; iter; iter = g_list_next(iter)) {
-		PurpleKeyValuePair *param = (PurpleKeyValuePair*)iter->data;
-		fs_codec_add_optional_parameter(new_codec,
-				param->key, param->value);
-	}
-
-	return new_codec;
-}
-
-static PurpleMediaCodec *
-purple_media_codec_from_fs(const FsCodec *codec)
-{
-	PurpleMediaCodec *new_codec;
-	GList *iter;
-
-	if (codec == NULL)
-		return NULL;
-
-	new_codec = purple_media_codec_new(codec->id, codec->encoding_name,
-			purple_media_from_fs(codec->media_type,
-			FS_DIRECTION_BOTH), codec->clock_rate);
-	g_object_set(new_codec, "channels", codec->channels, NULL);
-
-	for (iter = codec->optional_params; iter; iter = g_list_next(iter)) {
-		FsCodecParameter *param = (FsCodecParameter*)iter->data;
-		purple_media_codec_add_optional_parameter(new_codec,
-				param->name, param->value);
-	}
-
-	return new_codec;
-}
-#endif
-
-gchar *
-purple_media_codec_to_string(const PurpleMediaCodec *codec)
-{
-#ifdef USE_VV
-	FsCodec *fscodec = purple_media_codec_to_fs(codec);
-	gchar *str = fs_codec_to_string(fscodec);
-	fs_codec_destroy(fscodec);
-	return str;
-#else
-	return g_strdup("");
-#endif
-}
-
-#ifdef USE_VV
-static GList *
-purple_media_codec_list_from_fs(GList *codecs)
-{
-	GList *new_list = NULL;
-
-	for (; codecs; codecs = g_list_next(codecs)) {
-		new_list = g_list_prepend(new_list,
-				purple_media_codec_from_fs(
-				codecs->data));
-	}
-
-	new_list = g_list_reverse(new_list);
-	return new_list;
-}
-
-static GList *
-purple_media_codec_list_to_fs(GList *codecs)
-{
-	GList *new_list = NULL;
-
-	for (; codecs; codecs = g_list_next(codecs)) {
-		new_list = g_list_prepend(new_list,
-				purple_media_codec_to_fs(
-				codecs->data));
-	}
-
-	new_list = g_list_reverse(new_list);
-	return new_list;
-}
-#endif
-
-GList *
-purple_media_codec_list_copy(GList *codecs)
-{
-	GList *new_list = NULL;
-
-	for (; codecs; codecs = g_list_next(codecs)) {
-		new_list = g_list_prepend(new_list,
-				purple_media_codec_copy(codecs->data));
-	}
-
-	new_list = g_list_reverse(new_list);
-	return new_list;
-}
-
-void
-purple_media_codec_list_free(GList *codecs)
-{
-	for (; codecs; codecs =
-			g_list_delete_link(codecs, codecs)) {
-		g_object_unref(codecs->data);
-	}
-}
-
-#ifdef USE_VV
 static PurpleMediaSession*
 purple_media_get_session(PurpleMedia *media, const gchar *sess_id)
 {
@@ -1722,14 +465,6 @@
 			g_hash_table_lookup(media->priv->sessions, sess_id) : NULL;
 }
 
-static FsParticipant*
-purple_media_get_participant(PurpleMedia *media, const gchar *name)
-{
-	g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
-	return (FsParticipant*) (media->priv->participants) ?
-			g_hash_table_lookup(media->priv->participants, name) : NULL;
-}
-
 static PurpleMediaStream*
 purple_media_get_stream(PurpleMedia *media, const gchar *session, const gchar *participant)
 {
@@ -1755,7 +490,7 @@
 {
 	GList *streams;
 	GList *ret = NULL;
-	
+
 	g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
 
 	streams = media->priv->streams;
@@ -1780,63 +515,33 @@
 
 	if (!media->priv->sessions) {
 		purple_debug_info("media", "Creating hash table for sessions\n");
-		media->priv->sessions = g_hash_table_new(g_str_hash, g_str_equal);
+		media->priv->sessions = g_hash_table_new_full(g_str_hash, g_str_equal,
+		                                              g_free, NULL);
 	}
 	g_hash_table_insert(media->priv->sessions, g_strdup(session->id), session);
 }
 
+#if 0
 static gboolean
 purple_media_remove_session(PurpleMedia *media, PurpleMediaSession *session)
 {
 	g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
 	return g_hash_table_remove(media->priv->sessions, session->id);
 }
-
-static FsParticipant *
-purple_media_add_participant(PurpleMedia *media, const gchar *name)
-{
-	FsParticipant *participant;
-	GError *err = NULL;
-
-	g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
-
-	participant = purple_media_get_participant(media, name);
-
-	if (participant)
-		return participant;
-
-	participant = fs_conference_new_participant(media->priv->conference,
-						    (gchar*)name, &err);
-
-	if (err) {
-		purple_debug_error("media", "Error creating participant: %s\n",
-				   err->message);
-		g_error_free(err);
-		return NULL;
-	}
-
-	if (!media->priv->participants) {
-		purple_debug_info("media", "Creating hash table for participants\n");
-		media->priv->participants = g_hash_table_new_full(g_str_hash,
-				g_str_equal, g_free, NULL);
-	}
-
-	g_hash_table_insert(media->priv->participants, g_strdup(name), participant);
-
-	return participant;
-}
+#endif
 
 static PurpleMediaStream *
-purple_media_insert_stream(PurpleMediaSession *session, const gchar *name, FsStream *stream)
+purple_media_insert_stream(PurpleMediaSession *session,
+		const gchar *name, gboolean initiator)
 {
 	PurpleMediaStream *media_stream;
-	
+
 	g_return_val_if_fail(session != NULL, NULL);
 
 	media_stream = g_new0(PurpleMediaStream, 1);
-	media_stream->stream = stream;
 	media_stream->participant = g_strdup(name);
 	media_stream->session = session;
+	media_stream->initiator = initiator;
 
 	session->media->priv->streams =
 			g_list_append(session->media->priv->streams, media_stream);
@@ -1846,7 +551,7 @@
 
 static void
 purple_media_insert_local_candidate(PurpleMediaSession *session, const gchar *name,
-				     FsCandidate *candidate)
+				     PurpleMediaCandidate *candidate)
 {
 	PurpleMediaStream *stream;
 
@@ -1869,322 +574,25 @@
 #endif
 }
 
-#ifdef USE_VV
-static void 
-purple_media_set_src(PurpleMedia *media, const gchar *sess_id, GstElement *src)
-{
-	PurpleMediaSession *session;
-	GstPad *sinkpad;
-	GstPad *srcpad;
-
-	g_return_if_fail(PURPLE_IS_MEDIA(media));
-	g_return_if_fail(GST_IS_ELEMENT(src));
-
-	session = purple_media_get_session(media, sess_id);
-
-	if (session == NULL) {
-		purple_debug_warning("media", "purple_media_set_src: trying"
-				" to set src on non-existent session\n");
-		return;
-	}
-
-	if (session->src)
-		gst_object_unref(session->src);
-	session->src = src;
-	gst_element_set_locked_state(session->src, TRUE);
-
-	session->tee = gst_element_factory_make("tee", NULL);
-	gst_bin_add(GST_BIN(session->media->priv->confbin), session->tee);
-
-	/* This supposedly isn't necessary, but it silences some warnings */
-	if (GST_ELEMENT_PARENT(session->media->priv->confbin)
-			== GST_ELEMENT_PARENT(session->src)) {
-		GstPad *pad = gst_element_get_static_pad(session->tee, "sink");
-		GstPad *ghost = gst_ghost_pad_new(NULL, pad);
-		gst_object_unref(pad);
-		gst_pad_set_active(ghost, TRUE);
-		gst_element_add_pad(session->media->priv->confbin, ghost);
-	}
-
-	gst_element_set_state(session->tee, GST_STATE_PLAYING);
-	gst_element_link(session->src, session->media->priv->confbin);
-
-	g_object_get(session->session, "sink-pad", &sinkpad, NULL);
-	if (session->type & PURPLE_MEDIA_SEND_AUDIO) {
-		gchar *name = g_strdup_printf("volume_%s", session->id);
-		GstElement *level;
-		GstElement *volume = gst_element_factory_make("volume", name);
-		double input_volume = purple_prefs_get_int(
-				"/purple/media/audio/volume/input")/10.0;
-		g_free(name);
-		name = g_strdup_printf("sendlevel_%s", session->id);
-		level = gst_element_factory_make("level", name);
-		g_free(name);
-		gst_bin_add(GST_BIN(session->media->priv->confbin), volume);
-		gst_bin_add(GST_BIN(session->media->priv->confbin), level);
-		gst_element_set_state(level, GST_STATE_PLAYING);
-		gst_element_set_state(volume, GST_STATE_PLAYING);
-		gst_element_link(volume, level);
-		gst_element_link(session->tee, volume);
-		srcpad = gst_element_get_static_pad(level, "src");
-		g_object_set(volume, "volume", input_volume, NULL);
-	} else {
-		srcpad = gst_element_get_request_pad(session->tee, "src%d");
-	}
-	purple_debug_info("media", "connecting pad: %s\n", 
-			  gst_pad_link(srcpad, sinkpad) == GST_PAD_LINK_OK
-			  ? "success" : "failure");
-	gst_element_set_locked_state(session->src, FALSE);
-	gst_object_unref(session->src);
-}
-#endif
-
 #ifdef USE_GSTREAMER
 GstElement *
 purple_media_get_src(PurpleMedia *media, const gchar *sess_id)
 {
 #ifdef USE_VV
-	PurpleMediaSession *session;
 	g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
-	session = purple_media_get_session(media, sess_id);
-	return (session != NULL) ? session->src : NULL;
+
+	if (PURPLE_IS_MEDIA_BACKEND_FS2(media->priv->backend))
+		return purple_media_backend_fs2_get_src(
+				PURPLE_MEDIA_BACKEND_FS2(
+				media->priv->backend), sess_id);
+
+	g_return_val_if_reached(NULL);
 #else
 	return NULL;
 #endif
 }
 #endif /* USE_GSTREAMER */
 
-#ifdef USE_VV
-static PurpleMediaSession *
-purple_media_session_from_fs_stream(PurpleMedia *media, FsStream *stream)
-{
-	FsSession *fssession;
-	GList *values;
-
-	g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
-	g_return_val_if_fail(FS_IS_STREAM(stream), NULL);
-
-	g_object_get(stream, "session", &fssession, NULL);
-
-	values = g_hash_table_get_values(media->priv->sessions);
-
-	for (; values; values = g_list_delete_link(values, values)) {
-		PurpleMediaSession *session = values->data;
-
-		if (session->session == fssession) {
-			g_list_free(values);
-			g_object_unref(fssession);
-			return session;
-		}
-	}
-
-	g_object_unref(fssession);
-	return NULL;
-}
-
-static gboolean
-media_bus_call(GstBus *bus, GstMessage *msg, PurpleMedia *media)
-{
-	switch(GST_MESSAGE_TYPE(msg)) {
-		case GST_MESSAGE_ELEMENT: {
-			if (g_signal_has_handler_pending(media,
-					purple_media_signals[LEVEL], 0, FALSE)
-					&& gst_structure_has_name(
-					gst_message_get_structure(msg), "level")) {
-				GstElement *src = GST_ELEMENT(GST_MESSAGE_SRC(msg));
-				gchar *name;
-				gchar *participant = NULL;
-				PurpleMediaSession *session = NULL;
-				gdouble rms_db;
-				gdouble percent;
-				const GValue *list;
-				const GValue *value;
-
-				if (!PURPLE_IS_MEDIA(media) ||
-						GST_ELEMENT_PARENT(src) !=
-						media->priv->confbin)
-					break;
-
-				name = gst_element_get_name(src);
-				if (!strncmp(name, "sendlevel_", 10)) {
-					session = purple_media_get_session(
-							media, name+10);
-				} else {
-					GList *iter = media->priv->streams;
-					for (; iter; iter = g_list_next(iter)) {
-						PurpleMediaStream *stream = iter->data;
-						if (stream->level == src) {
-							session = stream->session;
-							participant = stream->participant;
-							break;
-						}
-					}
-				}
-				g_free(name);
-				if (!session)
-					break;
-
-				list = gst_structure_get_value(
-						gst_message_get_structure(msg), "rms");
-				value = gst_value_list_get_value(list, 0);
-				rms_db = g_value_get_double(value);
-				percent = pow(10, rms_db / 20) * 5;
-				if(percent > 1.0)
-					percent = 1.0;
-
-				g_signal_emit(media, purple_media_signals[LEVEL],
-						0, session->id, participant, percent);
-				break;
-			}
-			if (!FS_IS_CONFERENCE(GST_MESSAGE_SRC(msg)) ||
-					!PURPLE_IS_MEDIA(media) ||
-					media->priv->conference !=
-					FS_CONFERENCE(GST_MESSAGE_SRC(msg)))
-				break;
-
-			if (gst_structure_has_name(msg->structure, "farsight-error")) {
-				FsError error_no;
-				gst_structure_get_enum(msg->structure, "error-no",
-						FS_TYPE_ERROR, (gint*)&error_no);
-				switch (error_no) {
-					case FS_ERROR_NO_CODECS:
-						purple_media_error(media, _("No codecs found. Install some GStreamer codecs found in GStreamer plugins packages."));
-						purple_media_end(media, NULL, NULL);
-						break;
-					case FS_ERROR_NO_CODECS_LEFT:
-						purple_media_error(media, _("No codecs left. Your codec preferences in fs-codecs.conf are too strict."));
-						purple_media_end(media, NULL, NULL);
-						break;
-					case FS_ERROR_UNKNOWN_CNAME:
-					/*
-					 * Unknown CName is only a problem for the
-					 * multicast transmitter which isn't used.
-					 * It is also deprecated.
-					 */
-						break;
-					default:
-						purple_debug_error("media", "farsight-error: %i: %s\n", error_no,
-							  	gst_structure_get_string(msg->structure, "error-msg"));
-						break;
-				}
-
-				if (FS_ERROR_IS_FATAL(error_no)) {
-					purple_media_error(media, _("A non-recoverable Farsight2 error has occurred."));
-					purple_media_end(media, NULL, NULL);
-				}
-			} else if (gst_structure_has_name(msg->structure,
-					"farsight-new-local-candidate")) {
-				FsStream *stream = g_value_get_object(gst_structure_get_value(msg->structure, "stream"));
-				FsCandidate *local_candidate = g_value_get_boxed(gst_structure_get_value(msg->structure, "candidate"));
-				PurpleMediaSession *session = purple_media_session_from_fs_stream(media, stream);
-				purple_media_new_local_candidate_cb(stream, local_candidate, session);
-			} else if (gst_structure_has_name(msg->structure,
-					"farsight-local-candidates-prepared")) {
-				FsStream *stream = g_value_get_object(gst_structure_get_value(msg->structure, "stream"));
-				PurpleMediaSession *session = purple_media_session_from_fs_stream(media, stream);
-				purple_media_candidates_prepared_cb(stream, session);
-			} else if (gst_structure_has_name(msg->structure,
-					"farsight-new-active-candidate-pair")) {
-				FsStream *stream = g_value_get_object(gst_structure_get_value(msg->structure, "stream"));
-				FsCandidate *local_candidate = g_value_get_boxed(gst_structure_get_value(msg->structure, "local-candidate"));
-				FsCandidate *remote_candidate = g_value_get_boxed(gst_structure_get_value(msg->structure, "remote-candidate"));
-				PurpleMediaSession *session = purple_media_session_from_fs_stream(media, stream);
-				purple_media_candidate_pair_established_cb(stream, local_candidate, remote_candidate, session);
-			} else if (gst_structure_has_name(msg->structure,
-					"farsight-recv-codecs-changed")) {
-				GList *codecs = g_value_get_boxed(gst_structure_get_value(msg->structure, "codecs"));
-				FsCodec *codec = codecs->data;
-				purple_debug_info("media", "farsight-recv-codecs-changed: %s\n", codec->encoding_name);
-				
-			} else if (gst_structure_has_name(msg->structure,
-					"farsight-component-state-changed")) {
-				FsStreamState fsstate = g_value_get_enum(gst_structure_get_value(msg->structure, "state"));
-				guint component = g_value_get_uint(gst_structure_get_value(msg->structure, "component"));
-				const gchar *state;
-				switch (fsstate) {
-					case FS_STREAM_STATE_FAILED:
-						state = "FAILED";
-						break;
-					case FS_STREAM_STATE_DISCONNECTED:
-						state = "DISCONNECTED";
-						break;
-					case FS_STREAM_STATE_GATHERING:
-						state = "GATHERING";
-						break;
-					case FS_STREAM_STATE_CONNECTING:
-						state = "CONNECTING";
-						break;
-					case FS_STREAM_STATE_CONNECTED:
-						state = "CONNECTED";
-						break;
-					case FS_STREAM_STATE_READY:
-						state = "READY";
-						break;
-					default:
-						state = "UNKNOWN";
-						break;
-				}
-				purple_debug_info("media", "farsight-component-state-changed: component: %u state: %s\n", component, state);
-			} else if (gst_structure_has_name(msg->structure,
-					"farsight-send-codec-changed")) {
-				FsCodec *codec = g_value_get_boxed(gst_structure_get_value(msg->structure, "codec"));
-				gchar *codec_str = fs_codec_to_string(codec);
-				purple_debug_info("media", "farsight-send-codec-changed: codec: %s\n", codec_str);
-				g_free(codec_str);
-			} else if (gst_structure_has_name(msg->structure,
-					"farsight-codecs-changed")) {
-				GList *sessions = g_hash_table_get_values(PURPLE_MEDIA(media)->priv->sessions);
-				FsSession *fssession = g_value_get_object(gst_structure_get_value(msg->structure, "session"));
-				for (; sessions; sessions = g_list_delete_link(sessions, sessions)) {
-					PurpleMediaSession *session = sessions->data;
-					if (session->session == fssession) {
-						gchar *session_id = g_strdup(session->id);
-						g_signal_emit(media, purple_media_signals[CODECS_CHANGED], 0, session_id);
-						g_free(session_id);
-						g_list_free(sessions);
-						break;
-					}
-				}
-			}
-			break;
-		}
-		case GST_MESSAGE_ERROR: {
-			GstElement *element = GST_ELEMENT(GST_MESSAGE_SRC(msg));
-			GstElement *lastElement = NULL;
-			while (!GST_IS_PIPELINE(element)) {
-				if (element == media->priv->confbin) {
-					purple_media_error(media, _("Conference error"));
-					purple_media_end(media, NULL, NULL);
-					break;
-				}
-				lastElement = element;
-				element = GST_ELEMENT_PARENT(element);
-			}
-			if (GST_IS_PIPELINE(element)) {
-				GList *sessions = g_hash_table_get_values(media->priv->sessions);
-				for (; sessions; sessions = g_list_delete_link(sessions, sessions)) {
-					PurpleMediaSession *session = sessions->data;
-
-					if (session->src == lastElement) {
-						if (session->type & PURPLE_MEDIA_AUDIO)
-							purple_media_error(media, _("Error with your microphone"));
-						else
-							purple_media_error(media, _("Error with your webcam"));
-						purple_media_end(media, NULL, NULL);
-						break;
-					}
-				}
-				g_list_free(sessions);
-			}
-		}
-		default:
-			break;
-	}
-
-	return TRUE;
-}
-#endif
-
 PurpleAccount *
 purple_media_get_account(PurpleMedia *media)
 {
@@ -2245,12 +653,99 @@
 		const gchar *session_id, const gchar *participant)
 {
 #ifdef USE_VV
+	GList *iter, *sessions = NULL, *participants = NULL;
+
 	g_return_if_fail(PURPLE_IS_MEDIA(media));
-	if (session_id == NULL && participant == NULL) {
+
+	iter = purple_media_get_streams(media, session_id, participant);
+
+	/* Free matching streams */
+	for (; iter; iter = g_list_delete_link(iter, iter)) {
+		PurpleMediaStream *stream = iter->data;
+
+		g_signal_emit(media, purple_media_signals[STATE_CHANGED],
+				0, PURPLE_MEDIA_STATE_END,
+				stream->session->id, stream->participant);
+
+		media->priv->streams =
+				g_list_remove(media->priv->streams, stream);
+
+		if (g_list_find(sessions, stream->session) == NULL)
+			sessions = g_list_prepend(sessions, stream->session);
+
+		if (g_list_find_custom(participants, stream->participant,
+				(GCompareFunc)strcmp) == NULL)
+			participants = g_list_prepend(participants,
+					g_strdup(stream->participant));
+
+		purple_media_stream_free(stream);
+	}
+
+	iter = media->priv->streams;
+
+	/* Reduce to list of sessions to remove */
+	for (; iter; iter = g_list_next(iter)) {
+		PurpleMediaStream *stream = iter->data;
+
+		sessions = g_list_remove(sessions, stream->session);
+	}
+
+	/* Free sessions with no streams left */
+	for (; sessions; sessions = g_list_delete_link(sessions, sessions)) {
+		PurpleMediaSession *session = sessions->data;
+
+		g_signal_emit(media, purple_media_signals[STATE_CHANGED],
+				0, PURPLE_MEDIA_STATE_END,
+				session->id, NULL);
+
+		g_hash_table_remove(media->priv->sessions, session->id);
+		purple_media_session_free(session);
+	}
+
+	iter = media->priv->streams;
+
+	/* Reduce to list of participants to remove */
+	for (; iter; iter = g_list_next(iter)) {
+		PurpleMediaStream *stream = iter->data;
+		GList *tmp;
+
+		tmp = g_list_find_custom(participants,
+				stream->participant, (GCompareFunc)strcmp);
+
+		if (tmp != NULL) {
+			g_free(tmp->data);
+			participants = g_list_delete_link(participants,	tmp);
+		}
+	}
+
+	/* Remove participants with no streams left (just emit the signal) */
+	for (; participants; participants =
+			g_list_delete_link(participants, participants)) {
+		gchar *participant = participants->data;
+		GList *link = g_list_find_custom(media->priv->participants,
+				participant, (GCompareFunc)strcmp);
+
+		g_signal_emit(media, purple_media_signals[STATE_CHANGED],
+				0, PURPLE_MEDIA_STATE_END,
+				NULL, participant);
+
+		if (link != NULL) {
+			g_free(link->data);
+			media->priv->participants = g_list_delete_link(
+					media->priv->participants, link);
+		}
+
+		g_free(participant);
+	}
+
+	/* Free the conference if no sessions left */
+	if (media->priv->sessions != NULL &&
+			g_hash_table_size(media->priv->sessions) == 0) {
 		g_signal_emit(media, purple_media_signals[STATE_CHANGED],
 				0, PURPLE_MEDIA_STATE_END,
 				NULL, NULL);
 		g_object_unref(media);
+		return;
 	}
 #endif
 }
@@ -2264,6 +759,72 @@
 	g_return_if_fail(PURPLE_IS_MEDIA(media));
 
 	if (type == PURPLE_MEDIA_INFO_ACCEPT) {
+		GList *streams, *sessions = NULL, *participants = NULL;
+
+		g_return_if_fail(PURPLE_IS_MEDIA(media));
+
+		streams = purple_media_get_streams(media,
+				session_id, participant);
+
+		/* Emit stream acceptance */
+		for (; streams; streams =
+				g_list_delete_link(streams, streams)) {
+			PurpleMediaStream *stream = streams->data;
+
+			stream->accepted = TRUE;
+
+			g_signal_emit(media,
+					purple_media_signals[STREAM_INFO],
+					0, type, stream->session->id,
+					stream->participant, local);
+
+			if (g_list_find(sessions, stream->session) == NULL)
+				sessions = g_list_prepend(sessions,
+						stream->session);
+
+			if (g_list_find_custom(participants,
+					stream->participant,
+					(GCompareFunc)strcmp) == NULL)
+				participants = g_list_prepend(participants,
+						g_strdup(stream->participant));
+		}
+
+		/* Emit session acceptance */
+		for (; sessions; sessions =
+				g_list_delete_link(sessions, sessions)) {
+			PurpleMediaSession *session = sessions->data;
+
+			if (purple_media_accepted(media, session->id, NULL))
+				g_signal_emit(media, purple_media_signals[
+						STREAM_INFO], 0,
+						PURPLE_MEDIA_INFO_ACCEPT,
+						session->id, NULL, local);
+		}
+
+		/* Emit participant acceptance */
+		for (; participants; participants = g_list_delete_link(
+				participants, participants)) {
+			gchar *participant = participants->data;
+
+			if (purple_media_accepted(media, NULL, participant))
+				g_signal_emit(media, purple_media_signals[
+						STREAM_INFO], 0,
+						PURPLE_MEDIA_INFO_ACCEPT,
+						NULL, participant, local);
+
+			g_free(participant);
+		}
+
+		/* Emit conference acceptance */
+		if (purple_media_accepted(media, NULL, NULL))
+			g_signal_emit(media,
+					purple_media_signals[STREAM_INFO],
+					0, PURPLE_MEDIA_INFO_ACCEPT,
+					NULL, NULL, local);
+
+		return;
+	} else if (type == PURPLE_MEDIA_INFO_HANGUP ||
+			type == PURPLE_MEDIA_INFO_REJECT) {
 		GList *streams;
 
 		g_return_if_fail(PURPLE_IS_MEDIA(media));
@@ -2271,337 +832,230 @@
 		streams = purple_media_get_streams(media,
 				session_id, participant);
 
+		/* Emit for stream */
 		for (; streams; streams =
 				g_list_delete_link(streams, streams)) {
 			PurpleMediaStream *stream = streams->data;
-			g_object_set(G_OBJECT(stream->stream), "direction",
-					purple_media_to_fs_stream_direction(
-					stream->session->type), NULL);
-			stream->accepted = TRUE;
+
+			g_signal_emit(media,
+					purple_media_signals[STREAM_INFO],
+					0, type, stream->session->id,
+					stream->participant, local);
+		}
 
-			if (stream->remote_candidates != NULL &&
-					stream->initiator == FALSE) {
-				GError *err = NULL;
-				fs_stream_set_remote_candidates(stream->stream,
-						stream->remote_candidates, &err);
+		if (session_id != NULL && participant != NULL) {
+			/* Everything that needs to be emitted has been */
+		} else if (session_id == NULL && participant == NULL) {
+			/* Emit for everything in the conference */
+			GList *sessions = NULL;
+			GList *participants = media->priv->participants;
 
-				if (err) {
-					purple_debug_error("media", "Error adding remote"
-							" candidates: %s\n", err->message);
-					g_error_free(err);
-				}
+			if (media->priv->sessions != NULL)
+				sessions = g_hash_table_get_values(
+					media->priv->sessions);
+
+			/* Emit for sessions */
+			for (; sessions; sessions = g_list_delete_link(
+					sessions, sessions)) {
+				PurpleMediaSession *session = sessions->data;
+
+				g_signal_emit(media, purple_media_signals[
+						STREAM_INFO], 0, type,
+						session->id, NULL, local);
 			}
-		}
-	} else if (local == TRUE && (type == PURPLE_MEDIA_INFO_MUTE ||
-			type == PURPLE_MEDIA_INFO_UNMUTE)) {
-		GList *sessions;
-		gboolean active = (type == PURPLE_MEDIA_INFO_MUTE);
+
+			/* Emit for participants */
+			for (; participants; participants =
+					g_list_next(participants)) {
+				gchar *participant = participants->data;
 
-		g_return_if_fail(PURPLE_IS_MEDIA(media));
+				g_signal_emit(media, purple_media_signals[
+						STREAM_INFO], 0, type,
+						NULL, participant, local);
+			}
 
-		if (session_id == NULL)
-			sessions = g_hash_table_get_values(
-					media->priv->sessions);
-		else
-			sessions = g_list_prepend(NULL,
+			/* Emit for conference */
+			g_signal_emit(media,
+					purple_media_signals[STREAM_INFO],
+					0, type, NULL, NULL, local);
+		} else if (session_id != NULL) {
+			/* Emit just the specific session */
+			PurpleMediaSession *session =
 					purple_media_get_session(
-					media, session_id));
+					media, session_id);
 
-		purple_debug_info("media", "Turning mute %s\n",
-				active ? "on" : "off");
-
-		for (; sessions; sessions = g_list_delete_link(
-				sessions, sessions)) {
-			PurpleMediaSession *session = sessions->data;
-			if (session->type & PURPLE_MEDIA_SEND_AUDIO) {
-				gchar *name = g_strdup_printf("volume_%s",
-						session->id);
-				GstElement *volume = gst_bin_get_by_name(
-						GST_BIN(session->media->
-						priv->confbin), name);
-				g_free(name);
-				g_object_set(volume, "mute", active, NULL);
+			if (session == NULL) {
+				purple_debug_warning("media",
+						"Couldn't find session"
+						" to hangup/reject.\n");
+			} else {
+				g_signal_emit(media, purple_media_signals[
+						STREAM_INFO], 0, type,
+						session->id, NULL, local);
+			}
+		} else if (participant != NULL) {
+			/* Emit just the specific participant */
+			if (!g_list_find_custom(media->priv->participants,
+					participant, (GCompareFunc)strcmp)) {
+				purple_debug_warning("media",
+						"Couldn't find participant"
+						" to hangup/reject.\n");
+			} else {
+				g_signal_emit(media, purple_media_signals[
+						STREAM_INFO], 0, type, NULL,
+						participant, local);
 			}
 		}
-	} else if (local == TRUE && (type == PURPLE_MEDIA_INFO_PAUSE ||
-			type == PURPLE_MEDIA_INFO_UNPAUSE)) {
-		gboolean active = (type == PURPLE_MEDIA_INFO_PAUSE);
-		GList *streams = purple_media_get_streams(media,
-				session_id, participant);
-		for (; streams; streams = g_list_delete_link(streams, streams)) {
-			PurpleMediaStream *stream = streams->data;
-			if (stream->session->type & PURPLE_MEDIA_SEND_VIDEO) {
-				stream->paused = active;
 
-				if (!stream->held)
-					g_object_set(stream->stream, "direction",
-							purple_media_to_fs_stream_direction(
-							stream->session->type & ((active) ?
-							~PURPLE_MEDIA_SEND_VIDEO :
-							PURPLE_MEDIA_VIDEO)), NULL);
-			}
-		}
-	} else if (local == TRUE && (type == PURPLE_MEDIA_INFO_HOLD ||
-			type == PURPLE_MEDIA_INFO_UNHOLD)) {
-		GList *streams;
-		gboolean active = (type == PURPLE_MEDIA_INFO_HOLD);
-
-		g_return_if_fail(PURPLE_IS_MEDIA(media));
-
-		streams = purple_media_get_streams(media,
-				session_id, participant);
-		for (; streams; streams = g_list_delete_link(streams, streams)) {
-			PurpleMediaStream *stream = streams->data;
-			stream->held = active;
-			if (stream->session->type & PURPLE_MEDIA_VIDEO) {
-				FsStreamDirection direction;
-
-				direction = ((active) ?
-						~PURPLE_MEDIA_VIDEO :
-						PURPLE_MEDIA_VIDEO);
-				if (!active && stream->paused)
-					direction &= ~PURPLE_MEDIA_SEND_VIDEO;
-
-				g_object_set(stream->stream, "direction",
-						purple_media_to_fs_stream_direction(
-						stream->session->type & direction), NULL);
-			} else if (stream->session->type & PURPLE_MEDIA_AUDIO) {
-				g_object_set(stream->stream, "direction",
-						purple_media_to_fs_stream_direction(
-						stream->session->type & ((active) ?
-						~PURPLE_MEDIA_AUDIO :
-						PURPLE_MEDIA_AUDIO)), NULL);
-			}
-		}
+		purple_media_end(media, session_id, participant);
+		return;
 	}
 
 	g_signal_emit(media, purple_media_signals[STREAM_INFO],
 			0, type, session_id, participant, local);
+#endif
+}
 
-	if (type == PURPLE_MEDIA_INFO_HANGUP ||
-			type == PURPLE_MEDIA_INFO_REJECT) {
-		purple_media_end(media, session_id, participant);
-	}
+void
+purple_media_set_params(PurpleMedia *media,
+		guint num_params, GParameter *params)
+{
+#ifdef USE_VV
+	g_return_if_fail(PURPLE_IS_MEDIA(media));
+
+	purple_media_backend_set_params(media->priv->backend, num_params, params);
 #endif
 }
 
+const gchar **
+purple_media_get_available_params(PurpleMedia *media)
+{
+	static const gchar *NULL_ARRAY[] = { NULL };
+#ifdef USE_VV
+	g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL_ARRAY);
+
+	return purple_media_backend_get_available_params(media->priv->backend);
+#else
+	return NULL_ARRAY;
+#endif
+}
+
+gboolean
+purple_media_param_is_supported(PurpleMedia *media, const gchar *param)
+{
+#ifdef USE_VV
+	const gchar **params;
+
+	g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
+	g_return_val_if_fail(param != NULL, FALSE);
+
+	params = purple_media_backend_get_available_params(media->priv->backend);
+	for (; *params != NULL; ++params)
+		if (!strcmp(*params, param))
+			return TRUE;
+#endif
+	return FALSE;
+}
+
 #ifdef USE_VV
 static void
-purple_media_new_local_candidate_cb(FsStream *stream,
-				    FsCandidate *local_candidate,
-				    PurpleMediaSession *session)
+purple_media_new_local_candidate_cb(PurpleMediaBackend *backend,
+		const gchar *sess_id, const gchar *participant,
+		PurpleMediaCandidate *candidate, PurpleMedia *media)
 {
-	gchar *name;
-	FsParticipant *participant;
-	PurpleMediaCandidate *candidate;
-
-	g_return_if_fail(FS_IS_STREAM(stream));
-	g_return_if_fail(session != NULL);
+	PurpleMediaSession *session =
+			purple_media_get_session(media, sess_id);
 
-	purple_debug_info("media", "got new local candidate: %s\n", local_candidate->foundation);
-	g_object_get(stream, "participant", &participant, NULL);
-	g_object_get(participant, "cname", &name, NULL);
-	g_object_unref(participant);
-
-	purple_media_insert_local_candidate(session, name, fs_candidate_copy(local_candidate));
+	purple_media_insert_local_candidate(session, participant,
+			purple_media_candidate_copy(candidate));
 
-	candidate = purple_media_candidate_from_fs(local_candidate);
 	g_signal_emit(session->media, purple_media_signals[NEW_CANDIDATE],
-		      0, session->id, name, candidate);
-	g_object_unref(candidate);
-
-	g_free(name);
+		      0, session->id, participant, candidate);
 }
 
 static void
-purple_media_candidates_prepared_cb(FsStream *stream, PurpleMediaSession *session)
+purple_media_candidates_prepared_cb(PurpleMediaBackend *backend,
+		const gchar *sess_id, const gchar *name, PurpleMedia *media)
 {
-	gchar *name;
-	FsParticipant *participant;
 	PurpleMediaStream *stream_data;
 
-	g_return_if_fail(FS_IS_STREAM(stream));
-	g_return_if_fail(session != NULL);
+	g_return_if_fail(PURPLE_IS_MEDIA(media));
 
-	g_object_get(stream, "participant", &participant, NULL);
-	g_object_get(participant, "cname", &name, NULL);
-	g_object_unref(participant);
-
-	stream_data = purple_media_get_stream(session->media, session->id, name);
+	stream_data = purple_media_get_stream(media, sess_id, name);
 	stream_data->candidates_prepared = TRUE;
 
-	g_signal_emit(session->media,
-			purple_media_signals[CANDIDATES_PREPARED],
-			0, session->id, name);
-
-	g_free(name);
+	g_signal_emit(media, purple_media_signals[CANDIDATES_PREPARED],
+			0, sess_id, name);
 }
 
 /* callback called when a pair of transport candidates (local and remote)
  * has been established */
 static void
-purple_media_candidate_pair_established_cb(FsStream *fsstream,
-					   FsCandidate *native_candidate,
-					   FsCandidate *remote_candidate,
-					   PurpleMediaSession *session)
+purple_media_candidate_pair_established_cb(PurpleMediaBackend *backend,
+		const gchar *sess_id, const gchar *name,
+		PurpleMediaCandidate *local_candidate,
+		PurpleMediaCandidate *remote_candidate,
+		PurpleMedia *media)
 {
-	gchar *name;
-	FsParticipant *participant;
 	PurpleMediaStream *stream;
 	GList *iter;
-
-	g_return_if_fail(FS_IS_STREAM(fsstream));
-	g_return_if_fail(session != NULL);
+	guint id;
 
-	g_object_get(fsstream, "participant", &participant, NULL);
-	g_object_get(participant, "cname", &name, NULL);
-	g_object_unref(participant);
+	g_return_if_fail(PURPLE_IS_MEDIA(media));
 
-	stream = purple_media_get_stream(session->media, session->id, name);
+	stream = purple_media_get_stream(media, sess_id, name);
+	id = purple_media_candidate_get_component_id(local_candidate);
 
 	iter = stream->active_local_candidates;
 	for(; iter; iter = g_list_next(iter)) {
-		FsCandidate *c = iter->data;
-		if (native_candidate->component_id == c->component_id) {
-			fs_candidate_destroy(c);
+		PurpleMediaCandidate *c = iter->data;
+		if (id == purple_media_candidate_get_component_id(c)) {
+			g_object_unref(c);
 			stream->active_local_candidates =
 					g_list_delete_link(iter, iter);
 			stream->active_local_candidates = g_list_prepend(
 					stream->active_local_candidates,
-					fs_candidate_copy(native_candidate));
+					purple_media_candidate_copy(
+					local_candidate));
 			break;
 		}
 	}
 	if (iter == NULL)
 		stream->active_local_candidates = g_list_prepend(
 				stream->active_local_candidates,
-				fs_candidate_copy(native_candidate));
+				purple_media_candidate_copy(
+				local_candidate));
+
+	id = purple_media_candidate_get_component_id(local_candidate);
 
 	iter = stream->active_remote_candidates;
 	for(; iter; iter = g_list_next(iter)) {
-		FsCandidate *c = iter->data;
-		if (native_candidate->component_id == c->component_id) {
-			fs_candidate_destroy(c);
+		PurpleMediaCandidate *c = iter->data;
+		if (id == purple_media_candidate_get_component_id(c)) {
+			g_object_unref(c);
 			stream->active_remote_candidates =
 					g_list_delete_link(iter, iter);
 			stream->active_remote_candidates = g_list_prepend(
 					stream->active_remote_candidates,
-					fs_candidate_copy(remote_candidate));
+					purple_media_candidate_copy(
+					remote_candidate));
 			break;
 		}
 	}
 	if (iter == NULL)
 		stream->active_remote_candidates = g_list_prepend(
 				stream->active_remote_candidates,
-				fs_candidate_copy(remote_candidate));
+				purple_media_candidate_copy(
+				remote_candidate));
 
 	purple_debug_info("media", "candidate pair established\n");
 }
 
-static gboolean
-purple_media_connected_cb(PurpleMediaStream *stream)
-{
-	g_return_val_if_fail(stream != NULL, FALSE);
-
-	stream->connected_cb_id = 0;
-
-	purple_media_manager_create_output_window(
-			stream->session->media->priv->manager,
-			stream->session->media,
-			stream->session->id, stream->participant);
-
-	g_signal_emit(stream->session->media,
-			purple_media_signals[STATE_CHANGED],
-			0, PURPLE_MEDIA_STATE_CONNECTED,
-			stream->session->id, stream->participant);
-	return FALSE;
-}
-
 static void
-purple_media_src_pad_added_cb(FsStream *fsstream, GstPad *srcpad,
-			      FsCodec *codec, PurpleMediaStream *stream)
+purple_media_codecs_changed_cb(PurpleMediaBackend *backend,
+		const gchar *sess_id, PurpleMedia *media)
 {
-	PurpleMediaPrivate *priv;
-	GstPad *sinkpad;
-
-	g_return_if_fail(FS_IS_STREAM(fsstream));
-	g_return_if_fail(stream != NULL);
-
-	priv = stream->session->media->priv;
-
-	if (stream->src == NULL) {
-		GstElement *sink = NULL;
-
-		if (codec->media_type == FS_MEDIA_TYPE_AUDIO) {
-			GstElement *queue = NULL;
-			double output_volume = purple_prefs_get_int(
-					"/purple/media/audio/volume/output")/10.0;
-			/*
-			 * Should this instead be:
-			 *  audioconvert ! audioresample ! liveadder !
-			 *   audioresample ! audioconvert ! realsink
-			 */
-			queue = gst_element_factory_make("queue", NULL);
-			stream->volume = gst_element_factory_make(
-					"volume", NULL);
-			g_object_set(stream->volume, "volume",
-					output_volume, NULL);
-			stream->level = gst_element_factory_make(
-					"level", NULL);
-			stream->src = gst_element_factory_make(
-					"liveadder", NULL);
-			sink = purple_media_manager_get_element(priv->manager,
-					PURPLE_MEDIA_RECV_AUDIO,
-					stream->session->media,
-					stream->session->id,
-					stream->participant);
-			gst_bin_add(GST_BIN(priv->confbin), queue);
-			gst_bin_add(GST_BIN(priv->confbin), stream->volume);
-			gst_bin_add(GST_BIN(priv->confbin), stream->level);
-			gst_bin_add(GST_BIN(priv->confbin), sink);
-			gst_element_set_state(sink, GST_STATE_PLAYING);
-			gst_element_set_state(stream->level, GST_STATE_PLAYING);
-			gst_element_set_state(stream->volume, GST_STATE_PLAYING);
-			gst_element_set_state(queue, GST_STATE_PLAYING);
-			gst_element_link(stream->level, sink);
-			gst_element_link(stream->volume, stream->level);
-			gst_element_link(queue, stream->volume);
-			sink = queue;
-		} else if (codec->media_type == FS_MEDIA_TYPE_VIDEO) {
-			stream->src = gst_element_factory_make(
-					"fsfunnel", NULL);
-			sink = gst_element_factory_make(
-					"fakesink", NULL);
-			g_object_set(G_OBJECT(sink), "async", FALSE, NULL);
-			gst_bin_add(GST_BIN(priv->confbin), sink);
-			gst_element_set_state(sink, GST_STATE_PLAYING);
-		}
-		stream->tee = gst_element_factory_make("tee", NULL);
-		gst_bin_add_many(GST_BIN(priv->confbin),
-				stream->src, stream->tee, NULL);
-		gst_element_set_state(stream->tee, GST_STATE_PLAYING);
-		gst_element_set_state(stream->src, GST_STATE_PLAYING);
-		gst_element_link_many(stream->src, stream->tee, sink, NULL);
-	}
-
-	sinkpad = gst_element_get_request_pad(stream->src, "sink%d");
-	gst_pad_link(srcpad, sinkpad);
-	gst_object_unref(sinkpad);
-
-	stream->connected_cb_id = purple_timeout_add(0,
-			(GSourceFunc)purple_media_connected_cb, stream);
-}
-
-static void
-purple_media_element_added_cb(FsElementAddedNotifier *self,
-		GstBin *bin, GstElement *element, gpointer user_data)
-{
-	/*
-	 * Hack to make H264 work with Gmail video.
-	 */
-	if (!strncmp(GST_ELEMENT_NAME(element), "x264", 4)) {
-		g_object_set(GST_OBJECT(element), "cabac", FALSE, NULL);
-	}
+	g_signal_emit(media, purple_media_signals[CODECS_CHANGED], 0, sess_id);
 }
 #endif  /* USE_VV */
 
@@ -2613,97 +1067,21 @@
 {
 #ifdef USE_VV
 	PurpleMediaSession *session;
-	FsParticipant *participant = NULL;
 	PurpleMediaStream *stream = NULL;
-	FsMediaType media_type = purple_media_to_fs_media_type(type);
-	FsStreamDirection type_direction =
-			purple_media_to_fs_stream_direction(type);
-	gboolean is_nice = !strcmp(transmitter, "nice");
 
 	g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
 
+	if (!purple_media_backend_add_stream(media->priv->backend,
+			sess_id, who, type, initiator, transmitter,
+			num_params, params)) {
+		purple_debug_error("media", "Error adding stream.\n");
+		return FALSE;
+	}
+
 	session = purple_media_get_session(media, sess_id);
 
 	if (!session) {
-		GError *err = NULL;
-		GList *codec_conf = NULL, *iter = NULL;
-		gchar *filename = NULL;
-		PurpleMediaSessionType session_type;
-		GstElement *src = NULL;
-
 		session = g_new0(PurpleMediaSession, 1);
-
-		session->session = fs_conference_new_session(
-				media->priv->conference, media_type, &err);
-
-		if (err != NULL) {
-			purple_media_error(media, _("Error creating session: %s"), err->message);
-			g_error_free(err);
-			g_free(session);
-			return FALSE;
-		}
-
-		filename = g_build_filename(purple_user_dir(), "fs-codec.conf", NULL);
-		codec_conf = fs_codec_list_from_keyfile(filename, &err);
-		g_free(filename);
-
-		if (err != NULL) {
-			if (err->code == 4)
-				purple_debug_info("media", "Couldn't read "
-						"fs-codec.conf: %s\n",
-						err->message);
-			else
-				purple_debug_error("media", "Error reading "
-						"fs-codec.conf: %s\n",
-						err->message);
-			g_error_free(err);
-		}
-
-		/*
-		 * Add SPEEX if the configuration file doesn't exist or
-		 * there isn't a speex entry.
-		 */
-		for (iter = codec_conf; iter; iter = g_list_next(iter)) {
-			FsCodec *codec = iter->data;
-			if (!g_ascii_strcasecmp(codec->encoding_name, "speex"))
-				break;
-		}
-
-		if (iter == NULL) {
-			codec_conf = g_list_prepend(codec_conf,
-					fs_codec_new(FS_CODEC_ID_ANY,
-					"SPEEX", FS_MEDIA_TYPE_AUDIO, 8000));
-			codec_conf = g_list_prepend(codec_conf,
-					fs_codec_new(FS_CODEC_ID_ANY,
-					"SPEEX", FS_MEDIA_TYPE_AUDIO, 16000));
-		}
-
-		fs_session_set_codec_preferences(session->session, codec_conf, NULL);
-
-		/*
-		 * Removes a 5-7 second delay before
-		 * receiving the src-pad-added signal.
-		 * Only works for non-multicast FsRtpSessions.
-		 */
-		if (is_nice || !strcmp(transmitter, "rawudp"))
-			g_object_set(G_OBJECT(session->session),
-					"no-rtcp-timeout", 0, NULL);
-
-		/*
-		 * Hack to make x264 work with Gmail video.
-		 */
-		if (is_nice && !strcmp(sess_id, "google-video")) {
-			FsElementAddedNotifier *notifier =
-					fs_element_added_notifier_new();
-			g_signal_connect(G_OBJECT(notifier), "element-added",
-					G_CALLBACK(purple_media_element_added_cb),
-					stream);
-			fs_element_added_notifier_add(notifier,
-					GST_BIN(media->priv->conference));
-		}
-
-		fs_codec_list_destroy(codec_conf);
-
 		session->id = g_strdup(sess_id);
 		session->media = media;
 		session->type = type;
@@ -2713,152 +1091,23 @@
 		g_signal_emit(media, purple_media_signals[STATE_CHANGED],
 				0, PURPLE_MEDIA_STATE_NEW,
 				session->id, NULL);
-
-		if (type_direction & FS_DIRECTION_SEND) {
-			session_type = purple_media_from_fs(media_type,
-					FS_DIRECTION_SEND);
-			src = purple_media_manager_get_element(
-					media->priv->manager, session_type,
-					media, session->id, who);
-			if (!GST_IS_ELEMENT(src)) {
-				purple_debug_error("media",
-						"Error creating src for session %s\n",
-						session->id);
-				purple_media_end(media, session->id, NULL);
-				return FALSE;
-			}
-
-			purple_media_set_src(media, session->id, src);
-			gst_element_set_state(session->src, GST_STATE_PLAYING);
-			purple_media_manager_create_output_window(
-					media->priv->manager,
-					session->media,
-					session->id, NULL);
-		}
-	}
-
-	if (!(participant = purple_media_add_participant(media, who))) {
-		purple_media_remove_session(media, session);
-		g_free(session);
-		return FALSE;
-	} else {
-		g_signal_emit(media, purple_media_signals[STATE_CHANGED],
-				0, PURPLE_MEDIA_STATE_NEW,
-				NULL, who);
 	}
 
-	stream = purple_media_get_stream(media, sess_id, who);
-
-	if (!stream) {
-		GError *err = NULL;
-		FsStream *fsstream = NULL;
-		const gchar *stun_ip = purple_network_get_stun_ip();
-		const gchar *turn_ip = purple_network_get_turn_ip();
-
-		if (stun_ip || turn_ip) {
-			guint new_num_params = 
-					(stun_ip && is_nice) && turn_ip ?
-					num_params + 2 : num_params + 1;
-			guint next_param_index = num_params;
-			GParameter *param = g_new0(GParameter, new_num_params);
-			memcpy(param, params, sizeof(GParameter) * num_params);
-
-			if (stun_ip) {
-				purple_debug_info("media", 
-					"setting property stun-ip on new stream: %s\n", stun_ip);
-
-				param[next_param_index].name = "stun-ip";
-				g_value_init(&param[next_param_index].value, G_TYPE_STRING);
-				g_value_set_string(&param[next_param_index].value, stun_ip);
-				next_param_index++;
-			}
-
-			if (turn_ip && is_nice) {
-				GValueArray *relay_info = g_value_array_new(0);
-				GValue value;
-				gint turn_port = 
-					purple_prefs_get_int("/purple/network/turn_port");
-				const gchar *username =
-					purple_prefs_get_string("/purple/network/turn_username");
-				const gchar *password =
-					purple_prefs_get_string("/purple/network/turn_password");
-				GstStructure *turn_setup = gst_structure_new("relay-info",
-					"ip", G_TYPE_STRING, turn_ip, 
-					"port", G_TYPE_UINT, turn_port,
-					"username", G_TYPE_STRING, username,
-					"password", G_TYPE_STRING, password,
-					NULL);
-
-				if (turn_setup) {
-					memset(&value, 0, sizeof(GValue));
-					g_value_init(&value, GST_TYPE_STRUCTURE);
-					gst_value_set_structure(&value, turn_setup);
-					relay_info = g_value_array_append(relay_info, &value);
-					gst_structure_free(turn_setup);
+	if (!g_list_find_custom(media->priv->participants,
+			who, (GCompareFunc)strcmp)) {
+		media->priv->participants = g_list_prepend(
+				media->priv->participants, g_strdup(who));
 
-					purple_debug_info("media",
-						"setting property relay-info on new stream\n");
-					param[next_param_index].name = "relay-info";
-					g_value_init(&param[next_param_index].value, 
-						G_TYPE_VALUE_ARRAY);
-					g_value_set_boxed(&param[next_param_index].value,
-						relay_info);
-					g_value_array_free(relay_info);
-				} else {
-					purple_debug_error("media", "Error relay info");
-					g_object_unref(participant);
-					g_hash_table_remove(media->priv->participants, who);
-					purple_media_remove_session(media, session);
-					g_free(session);
-					return FALSE;
-				}
-			}
+		g_signal_emit_by_name(media, "state-changed",
+				PURPLE_MEDIA_STATE_NEW, NULL, who);
+	}
 
-			fsstream = fs_session_new_stream(session->session,
-					participant, initiator == TRUE ?
-					type_direction : (type_direction &
-					FS_DIRECTION_RECV), transmitter,
-					new_num_params, param, &err);
-			g_free(param);
-		} else {
-			fsstream = fs_session_new_stream(session->session,
-					participant, initiator == TRUE ?
-					type_direction : (type_direction &
-					FS_DIRECTION_RECV), transmitter,
-					num_params, params, &err);
-		}
-
-		if (fsstream == NULL) {
-			purple_debug_error("media",
-					"Error creating stream: %s\n",
-					err && err->message ?
-					err->message : "NULL");
-			if (err)
-				g_error_free(err);
-			g_object_unref(participant);
-			g_hash_table_remove(media->priv->participants, who);
-			purple_media_remove_session(media, session);
-			g_free(session);
-			return FALSE;
-		}
-
-		stream = purple_media_insert_stream(session, who, fsstream);
-		stream->initiator = initiator;
-
-		/* callback for source pad added (new stream source ready) */
-		g_signal_connect(G_OBJECT(fsstream),
-				 "src-pad-added", G_CALLBACK(purple_media_src_pad_added_cb), stream);
+	if (purple_media_get_stream(media, sess_id, who) == NULL) {
+		stream = purple_media_insert_stream(session, who, initiator);
 
 		g_signal_emit(media, purple_media_signals[STATE_CHANGED],
 				0, PURPLE_MEDIA_STATE_NEW,
 				session->id, who);
-	} else {
-		if (purple_media_to_fs_stream_direction(stream->session->type)
-				!= type_direction) {
-			/* change direction */
-			g_object_set(stream->stream, "direction",
-					type_direction, NULL);
-		}
 	}
 
 	return TRUE;
@@ -2893,22 +1142,9 @@
 purple_media_get_codecs(PurpleMedia *media, const gchar *sess_id)
 {
 #ifdef USE_VV
-	GList *fscodecs;
-	GList *codecs;
-	PurpleMediaSession *session;
-
 	g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
 
-	session = purple_media_get_session(media, sess_id);
-
-	if (session == NULL)
-		return NULL;
-
-	g_object_get(G_OBJECT(session->session),
-		     "codecs", &fscodecs, NULL);
-	codecs = purple_media_codec_list_from_fs(fscodecs);
-	fs_codec_list_destroy(fscodecs);
-	return codecs;
+	return purple_media_backend_get_codecs(media->priv->backend, sess_id);
 #else
 	return NULL;
 #endif
@@ -2919,11 +1155,10 @@
                                   const gchar *participant)
 {
 #ifdef USE_VV
-	PurpleMediaStream *stream;
 	g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
-	stream = purple_media_get_stream(media, sess_id, participant);
-	return stream ? purple_media_candidate_list_from_fs(
-			stream->local_candidates) : NULL;
+
+	return purple_media_backend_get_local_candidates(media->priv->backend,
+			sess_id, participant);
 #else
 	return NULL;
 #endif
@@ -2936,7 +1171,6 @@
 {
 #ifdef USE_VV
 	PurpleMediaStream *stream;
-	GError *err = NULL;
 
 	g_return_if_fail(PURPLE_IS_MEDIA(media));
 	stream = purple_media_get_stream(media, sess_id, participant);
@@ -2951,27 +1185,13 @@
 	}
 
 	stream->remote_candidates = g_list_concat(stream->remote_candidates,
-			purple_media_candidate_list_to_fs(remote_candidates));
-
-	if (stream->initiator == TRUE || stream->accepted == TRUE) {
-		fs_stream_set_remote_candidates(stream->stream,
-				stream->remote_candidates, &err);
+			purple_media_candidate_list_copy(remote_candidates));
 
-		if (err) {
-			purple_debug_error("media", "Error adding remote"
-					" candidates: %s\n", err->message);
-			g_error_free(err);
-		}
-	}
+	purple_media_backend_add_remote_candidates(media->priv->backend,
+			sess_id, participant, remote_candidates);
 #endif
 }
 
-#if 0
-/*
- * These two functions aren't being used and I'd rather not lock in the API
- * until they are needed. If they ever are.
- */
-
 GList *
 purple_media_get_active_local_candidates(PurpleMedia *media,
 		const gchar *sess_id, const gchar *participant)
@@ -2980,7 +1200,7 @@
 	PurpleMediaStream *stream;
 	g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
 	stream = purple_media_get_stream(media, sess_id, participant);
-	return purple_media_candidate_list_from_fs(
+	return purple_media_candidate_list_copy(
 			stream->active_local_candidates);
 #else
 	return NULL;
@@ -2995,42 +1215,22 @@
 	PurpleMediaStream *stream;
 	g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
 	stream = purple_media_get_stream(media, sess_id, participant);
-	return purple_media_candidate_list_from_fs(
+	return purple_media_candidate_list_copy(
 			stream->active_remote_candidates);
 #else
 	return NULL;
 #endif
 }
-#endif
 
 gboolean
 purple_media_set_remote_codecs(PurpleMedia *media, const gchar *sess_id,
                                const gchar *participant, GList *codecs)
 {
 #ifdef USE_VV
-	PurpleMediaStream *stream;
-	FsStream *fsstream;
-	GList *fscodecs;
-	GError *err = NULL;
-
 	g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
-	stream = purple_media_get_stream(media, sess_id, participant);
-
-	if (stream == NULL)
-		return FALSE;
 
-	fsstream = stream->stream;
-	fscodecs = purple_media_codec_list_to_fs(codecs);
-	fs_stream_set_remote_codecs(fsstream, fscodecs, &err);
-	fs_codec_list_destroy(fscodecs);
-
-	if (err) {
-		purple_debug_error("media", "Error setting remote codecs: %s\n",
-				   err->message);
-		g_error_free(err);
-		return FALSE;
-	}
-	return TRUE;
+	return purple_media_backend_set_remote_codecs(media->priv->backend,
+			sess_id, participant, codecs);
 #else
 	return FALSE;
 #endif
@@ -3067,27 +1267,10 @@
 purple_media_set_send_codec(PurpleMedia *media, const gchar *sess_id, PurpleMediaCodec *codec)
 {
 #ifdef USE_VV
-	PurpleMediaSession *session;
-	FsCodec *fscodec;
-	GError *err = NULL;
-
 	g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
 
-	session = purple_media_get_session(media, sess_id);
-
-	if (session != NULL)
-		return FALSE;
-
-	fscodec = purple_media_codec_to_fs(codec);
-	fs_session_set_send_codec(session->session, fscodec, &err);
-	fs_codec_destroy(fscodec);
-
-	if (err) {
-		purple_debug_error("media", "Error setting send codec\n");
-		g_error_free(err);
-		return FALSE;
-	}
-	return TRUE;
+	return purple_media_backend_set_send_codec(
+			media->priv->backend, sess_id, codec);
 #else
 	return FALSE;
 #endif
@@ -3097,40 +1280,10 @@
 purple_media_codecs_ready(PurpleMedia *media, const gchar *sess_id)
 {
 #ifdef USE_VV
-	gboolean ret;
-
 	g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
 
-	if (sess_id != NULL) {
-		PurpleMediaSession *session;
-		session = purple_media_get_session(media, sess_id);
-
-		if (session == NULL)
-			return FALSE;
-		if (session->type & (PURPLE_MEDIA_SEND_AUDIO |
-				PURPLE_MEDIA_SEND_VIDEO))
-			g_object_get(session->session,
-					"codecs-ready", &ret, NULL);
-		else
-			ret = TRUE;
-	} else {
-		GList *values = g_hash_table_get_values(media->priv->sessions);
-		for (; values; values = g_list_delete_link(values, values)) {
-			PurpleMediaSession *session = values->data;
-			if (session->type & (PURPLE_MEDIA_SEND_AUDIO |
-					PURPLE_MEDIA_SEND_VIDEO))
-				g_object_get(session->session,
-						"codecs-ready", &ret, NULL);
-			else
-				ret = TRUE;
-
-			if (ret == FALSE)
-				break;
-		}
-		if (values != NULL)
-			g_list_free(values);
-	}
-	return ret;
+	return purple_media_backend_codecs_ready(
+			media->priv->backend, sess_id);
 #else
 	return FALSE;
 #endif
@@ -3206,31 +1359,13 @@
 		const gchar *session_id, double level)
 {
 #ifdef USE_VV
-	GList *sessions;
-
 	g_return_if_fail(PURPLE_IS_MEDIA(media));
-
-	purple_prefs_set_int("/purple/media/audio/volume/input", level);
-
-	if (session_id == NULL)
-		sessions = g_hash_table_get_values(media->priv->sessions);
-	else
-		sessions = g_list_append(NULL,
-				purple_media_get_session(media, session_id));
+	g_return_if_fail(PURPLE_IS_MEDIA_BACKEND_FS2(media->priv->backend));
 
-	for (; sessions; sessions = g_list_delete_link(sessions, sessions)) {
-		PurpleMediaSession *session = sessions->data;
-
-		if (session->type & PURPLE_MEDIA_SEND_AUDIO) {
-			gchar *name = g_strdup_printf("volume_%s",
-					session->id);
-			GstElement *volume = gst_bin_get_by_name(
-					GST_BIN(session->media->priv->confbin),
-					name);
-			g_free(name);
-			g_object_set(volume, "volume", level/10.0, NULL);
-		}
-	}
+	purple_media_backend_fs2_set_input_volume(
+			PURPLE_MEDIA_BACKEND_FS2(
+			media->priv->backend),
+			session_id, level);
 #endif
 }
 
@@ -3239,23 +1374,13 @@
 		double level)
 {
 #ifdef USE_VV
-	GList *streams;
-
 	g_return_if_fail(PURPLE_IS_MEDIA(media));
-
-	purple_prefs_set_int("/purple/media/audio/volume/output", level);
-
-	streams = purple_media_get_streams(media,
-			session_id, participant);
+	g_return_if_fail(PURPLE_IS_MEDIA_BACKEND_FS2(media->priv->backend));
 
-	for (; streams; streams = g_list_delete_link(streams, streams)) {
-		PurpleMediaStream *stream = streams->data;
-
-		if (stream->session->type & PURPLE_MEDIA_RECV_AUDIO
-				&& GST_IS_ELEMENT(stream->volume)) {
-			g_object_set(stream->volume, "volume", level/10.0, NULL);
-		}
-	}
+	purple_media_backend_fs2_set_output_volume(
+			PURPLE_MEDIA_BACKEND_FS2(
+			media->priv->backend),
+			session_id, participant, level);
 #endif
 }
 
@@ -3303,16 +1428,11 @@
 #ifdef USE_VV
 	g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
 
-	if (session_id != NULL && participant == NULL) {
-		PurpleMediaSession *session =
-				purple_media_get_session(media, session_id);
-		return (session != NULL) ? session->tee : NULL;
-	} else if (session_id != NULL && participant != NULL) {
-		PurpleMediaStream *stream =
-				purple_media_get_stream(media,
+	if (PURPLE_IS_MEDIA_BACKEND_FS2(media->priv->backend))
+		return purple_media_backend_fs2_get_tee(
+				PURPLE_MEDIA_BACKEND_FS2(
+				media->priv->backend),
 				session_id, participant);
-		return (stream != NULL) ? stream->tee : NULL;
-	}
 	g_return_val_if_reached(NULL);
 #else
 	return NULL;
--- a/libpurple/media.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/media.h	Sat Aug 06 03:45:56 2011 +0000
@@ -27,26 +27,15 @@
 #ifndef _PURPLE_MEDIA_H_
 #define _PURPLE_MEDIA_H_
 
+#include "media/candidate.h"
+#include "media/codec.h"
+#include "media/enum-types.h"
+
 #include <glib.h>
 #include <glib-object.h>
 
 G_BEGIN_DECLS
 
-#define PURPLE_TYPE_MEDIA_CANDIDATE           (purple_media_candidate_get_type())
-#define PURPLE_MEDIA_CANDIDATE(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_MEDIA_CANDIDATE, PurpleMediaCandidate))
-#define PURPLE_MEDIA_CANDIDATE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_MEDIA_CANDIDATE, PurpleMediaCandidate))
-#define PURPLE_IS_MEDIA_CANDIDATE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_MEDIA_CANDIDATE))
-#define PURPLE_IS_MEDIA_CANDIDATE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PURPLE_TYPE_MEDIA_CANDIDATE))
-#define PURPLE_MEDIA_CANDIDATE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_MEDIA_CANDIDATE, PurpleMediaCandidate))
-
-#define PURPLE_TYPE_MEDIA_CODEC           (purple_media_codec_get_type())
-#define PURPLE_MEDIA_CODEC(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_MEDIA_CODEC, PurpleMediaCodec))
-#define PURPLE_MEDIA_CODEC_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_MEDIA_CODEC, PurpleMediaCodec))
-#define PURPLE_IS_MEDIA_CODEC(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_MEDIA_CODEC))
-#define PURPLE_IS_MEDIA_CODEC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PURPLE_TYPE_MEDIA_CODEC))
-#define PURPLE_MEDIA_CODEC_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_MEDIA_CODEC, PurpleMediaCodec))
-
-#define PURPLE_TYPE_MEDIA_SESSION_TYPE (purple_media_session_type_get_type())
 #define PURPLE_TYPE_MEDIA            (purple_media_get_type())
 #define PURPLE_MEDIA(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_MEDIA, PurpleMedia))
 #define PURPLE_MEDIA_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_MEDIA, PurpleMediaClass))
@@ -54,79 +43,8 @@
 #define PURPLE_IS_MEDIA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PURPLE_TYPE_MEDIA))
 #define PURPLE_MEDIA_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_MEDIA, PurpleMediaClass))
 
-#define PURPLE_TYPE_MEDIA_CANDIDATE_TYPE (purple_media_candidate_type_get_type())
-#define PURPLE_TYPE_MEDIA_NETWORK_PROTOCOL (purple_media_network_protocol_get_type())
-#define PURPLE_MEDIA_TYPE_STATE      (purple_media_state_changed_get_type())
-#define PURPLE_MEDIA_TYPE_INFO_TYPE	(purple_media_info_type_get_type())
-
 /** An opaque structure representing a media call. */
 typedef struct _PurpleMedia PurpleMedia;
-/** An opaque structure representing a network candidate (IP Address and port pair). */
-typedef struct _PurpleMediaCandidate PurpleMediaCandidate;
-/** An opaque structure representing an audio or video codec. */
-typedef struct _PurpleMediaCodec PurpleMediaCodec;
-
-/** Media caps */
-typedef enum {
-	PURPLE_MEDIA_CAPS_NONE = 0,
-	PURPLE_MEDIA_CAPS_AUDIO = 1,
-	PURPLE_MEDIA_CAPS_AUDIO_SINGLE_DIRECTION = 1 << 1,
-	PURPLE_MEDIA_CAPS_VIDEO = 1 << 2,
-	PURPLE_MEDIA_CAPS_VIDEO_SINGLE_DIRECTION = 1 << 3,
-	PURPLE_MEDIA_CAPS_AUDIO_VIDEO = 1 << 4,
-	PURPLE_MEDIA_CAPS_MODIFY_SESSION = 1 << 5,
-	PURPLE_MEDIA_CAPS_CHANGE_DIRECTION = 1 << 6
-} PurpleMediaCaps;
-
-/** Media session types */
-typedef enum {
-	PURPLE_MEDIA_NONE	= 0,
-	PURPLE_MEDIA_RECV_AUDIO = 1 << 0,
-	PURPLE_MEDIA_SEND_AUDIO = 1 << 1,
-	PURPLE_MEDIA_RECV_VIDEO = 1 << 2,
-	PURPLE_MEDIA_SEND_VIDEO = 1 << 3,
-	PURPLE_MEDIA_AUDIO = PURPLE_MEDIA_RECV_AUDIO | PURPLE_MEDIA_SEND_AUDIO,
-	PURPLE_MEDIA_VIDEO = PURPLE_MEDIA_RECV_VIDEO | PURPLE_MEDIA_SEND_VIDEO
-} PurpleMediaSessionType;
-
-/** Media state-changed types */
-typedef enum {
-	PURPLE_MEDIA_STATE_NEW = 0,
-	PURPLE_MEDIA_STATE_CONNECTED,
-	PURPLE_MEDIA_STATE_END
-} PurpleMediaState;
-
-/** Media info types */
-typedef enum {
-	PURPLE_MEDIA_INFO_HANGUP = 0,
-	PURPLE_MEDIA_INFO_ACCEPT,
-	PURPLE_MEDIA_INFO_REJECT,
-	PURPLE_MEDIA_INFO_MUTE,
-	PURPLE_MEDIA_INFO_UNMUTE,
-	PURPLE_MEDIA_INFO_PAUSE,
-	PURPLE_MEDIA_INFO_UNPAUSE,
-	PURPLE_MEDIA_INFO_HOLD,
-	PURPLE_MEDIA_INFO_UNHOLD
-} PurpleMediaInfoType;
-
-typedef enum {
-	PURPLE_MEDIA_CANDIDATE_TYPE_HOST,
-	PURPLE_MEDIA_CANDIDATE_TYPE_SRFLX,
-	PURPLE_MEDIA_CANDIDATE_TYPE_PRFLX,
-	PURPLE_MEDIA_CANDIDATE_TYPE_RELAY,
-	PURPLE_MEDIA_CANDIDATE_TYPE_MULTICAST
-} PurpleMediaCandidateType;
-
-typedef enum {
-	PURPLE_MEDIA_COMPONENT_NONE = 0,
-	PURPLE_MEDIA_COMPONENT_RTP = 1,
-	PURPLE_MEDIA_COMPONENT_RTCP = 2
-} PurpleMediaComponentType;
-
-typedef enum {
-	PURPLE_MEDIA_NETWORK_PROTOCOL_UDP,
-	PURPLE_MEDIA_NETWORK_PROTOCOL_TCP
-} PurpleMediaNetworkProtocol;
 
 #include "signals.h"
 #include "util.h"
@@ -136,33 +54,6 @@
 #endif
 
 /**
- * Gets the media session type's GType
- *
- * @return The media session type's GType.
- *
- * @since 2.6.0
- */
-GType purple_media_session_type_get_type(void);
-
-/**
- * Gets the media candidate type's GType
- *
- * @return The media candidate type's GType.
- *
- * @since 2.6.0
- */
-GType purple_media_candidate_type_get_type(void);
-
-/**
- * Gets the media network protocol's GType
- *
- * @return The media network protocol's GType.
- *
- * @since 2.6.0
- */
-GType purple_media_network_protocol_get_type(void);
-
-/**
  * Gets the media class's GType
  *
  * @return The media class's GType.
@@ -172,187 +63,6 @@
 GType purple_media_get_type(void);
 
 /**
- * Gets the type of the state-changed enum
- *
- * @return The state-changed enum's GType
- *
- * @since 2.6.0
- */
-GType purple_media_state_changed_get_type(void);
-
-/**
- * Gets the type of the info type enum
- *
- * @return The info type enum's GType
- *
- * @since 2.6.0
- */
-GType purple_media_info_type_get_type(void);
-
-/**
- * Gets the type of the media candidate structure.
- *
- * @return The media canditate's GType
- *
- * @since 2.6.0
- */
-GType purple_media_candidate_get_type(void);
-
-/**
- * Creates a PurpleMediaCandidate instance.
- *
- * @param foundation The foundation of the candidate.
- * @param component_id The component this candidate is for.
- * @param type The type of candidate.
- * @param proto The protocol this component is for.
- * @param ip The IP address of this component.
- * @param port The network port.
- *
- * @return The newly created PurpleMediaCandidate instance.
- *
- * @since 2.6.0
- */
-PurpleMediaCandidate *purple_media_candidate_new(
-		const gchar *foundation, guint component_id,
-		PurpleMediaCandidateType type,
-		PurpleMediaNetworkProtocol proto,
-		const gchar *ip, guint port);
-
-/**
- * Copies a GList of PurpleMediaCandidate and its contents.
- *
- * @param candidates The list of candidates to be copied.
- *
- * @return The copy of the GList.
- *
- * @since 2.6.0
- */
-GList *purple_media_candidate_list_copy(GList *candidates);
-
-/**
- * Frees a GList of PurpleMediaCandidate and its contents.
- *
- * @param candidates The list of candidates to be freed.
- *
- * @since 2.6.0
- */
-void purple_media_candidate_list_free(GList *candidates);
-
-gchar *purple_media_candidate_get_foundation(PurpleMediaCandidate *candidate);
-guint purple_media_candidate_get_component_id(PurpleMediaCandidate *candidate);
-gchar *purple_media_candidate_get_ip(PurpleMediaCandidate *candidate);
-guint16 purple_media_candidate_get_port(PurpleMediaCandidate *candidate);
-gchar *purple_media_candidate_get_base_ip(PurpleMediaCandidate *candidate);
-guint16 purple_media_candidate_get_base_port(PurpleMediaCandidate *candidate);
-PurpleMediaNetworkProtocol purple_media_candidate_get_protocol(
-		PurpleMediaCandidate *candidate);
-guint32 purple_media_candidate_get_priority(PurpleMediaCandidate *candidate);
-PurpleMediaCandidateType purple_media_candidate_get_candidate_type(
-		PurpleMediaCandidate *candidate);
-gchar *purple_media_candidate_get_username(PurpleMediaCandidate *candidate);
-gchar *purple_media_candidate_get_password(PurpleMediaCandidate *candidate);
-guint purple_media_candidate_get_ttl(PurpleMediaCandidate *candidate);
-
-/**
- * Gets the type of the media codec structure.
- *
- * @return The media codec's GType
- *
- * @since 2.6.0
- */
-GType purple_media_codec_get_type(void);
-
-/**
- * Creates a new PurpleMediaCodec instance.
- *
- * @param id Codec identifier.
- * @param encoding_name Name of the media type this encodes.
- * @param media_type PurpleMediaSessionType of this codec.
- * @param clock_rate The clock rate this codec encodes at, if applicable.
- *
- * @return The newly created PurpleMediaCodec.
- *
- * @since 2.6.0
- */
-PurpleMediaCodec *purple_media_codec_new(int id, const char *encoding_name,
-		PurpleMediaSessionType media_type, guint clock_rate);
-
-guint purple_media_codec_get_id(PurpleMediaCodec *codec);
-gchar *purple_media_codec_get_encoding_name(PurpleMediaCodec *codec);
-guint purple_media_codec_get_clock_rate(PurpleMediaCodec *codec);
-guint purple_media_codec_get_channels(PurpleMediaCodec *codec);
-GList *purple_media_codec_get_optional_parameters(PurpleMediaCodec *codec);
-
-/**
- * Creates a string representation of the codec.
- *
- * @param codec The codec to create the string of.
- *
- * @return The new string representation.
- *
- * @since 2.6.0
- */
-gchar *purple_media_codec_to_string(const PurpleMediaCodec *codec);
-
-/**
- * Adds an optional parameter to the codec.
- *
- * @param codec The codec to add the parameter to.
- * @param name The name of the parameter to add.
- * @param value The value of the parameter to add.
- *
- * @since 2.6.0
- */
-void purple_media_codec_add_optional_parameter(PurpleMediaCodec *codec,
-		const gchar *name, const gchar *value);
-
-/**
- * Removes an optional parameter from the codec.
- *
- * @param codec The codec to remove the parameter from.
- * @param param A pointer to the parameter to remove.
- *
- * @since 2.6.0
- */
-void purple_media_codec_remove_optional_parameter(PurpleMediaCodec *codec,
-		PurpleKeyValuePair *param);
-
-/**
- * Gets an optional parameter based on the values given.
- *
- * @param codec The codec to find the parameter in.
- * @param name The name of the parameter to search for.
- * @param value The value to search for or NULL.
- *
- * @return The value found or NULL.
- *
- * @since 2.6.0
- */
-PurpleKeyValuePair *purple_media_codec_get_optional_parameter(
-		PurpleMediaCodec *codec, const gchar *name,
-		const gchar *value);
-
-/**
- * Copies a GList of PurpleMediaCodec and its contents.
- *
- * @param codecs The list of codecs to be copied.
- *
- * @return The copy of the GList.
- *
- * @since 2.6.0
- */
-GList *purple_media_codec_list_copy(GList *codecs);
-
-/**
- * Frees a GList of PurpleMediaCodec and its contents.
- *
- * @param codecs The list of codecs to be freed.
- *
- * @since 2.6.0
- */
-void purple_media_codec_list_free(GList *codecs);
-
-/**
  * Gets a list of session IDs.
  *
  * @param media The media session from which to retrieve session IDs.
@@ -434,6 +144,52 @@
 		gboolean local);
 
 /**
+ * Sets various optional parameters of the media call.
+ *
+ * Currently supported are:
+ *   - "sdes-cname"    : The CNAME for the RTP sessions
+ *   - "sdes-name"     : Real name used to describe the source in SDES messages
+ *   - "sdes-tool"     : The TOOL to put in SDES messages
+ *   - "sdes-email"    : Email address to put in SDES messages
+ *   - "sdes-location" : The LOCATION to put in SDES messages
+ *   - "sdes-note"     : The NOTE to put in SDES messages
+ *   - "sdes-phone"    : The PHONE to put in SDES messages
+ *
+ * @param media The media object to set the parameters on.
+ * @param num_params The number of parameters to pass
+ * @param params Array of @c GParameter to pass
+ *
+ * @since 2.8.0
+ */
+void purple_media_set_params(PurpleMedia *media,
+		guint num_params, GParameter *params);
+
+/**
+ * Gets the list of optional parameters supported by the media backend.
+ *
+ * The list is owned by the @c PurpleMedia internals and should NOT be freed.
+ *
+ * @param media The media object
+ *
+ * @return NULL-terminated array of names of supported parameters.
+ *
+ * @since 2.8.0
+ */
+const gchar **purple_media_get_available_params(PurpleMedia *media);
+
+/**
+ * Checks if given optional parameter is supported by the media backend.
+ *
+ * @param media The media object
+ * @param param name of parameter
+ *
+ * @return @c TRUE if backend recognizes the parameter, @c FALSE otherwise.
+ *
+ * @since 2.8.0
+ */
+gboolean purple_media_param_is_supported(PurpleMedia *media, const gchar *param);
+
+/**
  * Adds a stream to a session.
  *
  * It only adds a stream to one audio session or video session as
@@ -520,12 +276,6 @@
 					 const gchar *sess_id,
 					 const gchar *participant);
 
-#if 0
-/*
- * These two functions aren't being used and I'd rather not lock in the API
- * until they are needed. If they ever are.
- */
-
 /**
  * Gets the active local candidates for the stream.
  *
@@ -535,6 +285,8 @@
  *                    from.
  *
  * @return The active candidates retrieved.
+ *
+ * @since 2.8.0
  */
 GList *purple_media_get_active_local_candidates(PurpleMedia *media,
 		const gchar *sess_id, const gchar *participant);
@@ -548,10 +300,11 @@
  *                    from.
  *
  * @return The remote candidates retrieved.
+ *
+ * @since 2.8.0
  */
 GList *purple_media_get_active_remote_candidates(PurpleMedia *media,
 		const gchar *sess_id, const gchar *participant);
-#endif
 
 /**
  * Sets remote candidates from the stream.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/media/backend-fs2.c	Sat Aug 06 03:45:56 2011 +0000
@@ -0,0 +1,2292 @@
+/**
+ * @file backend-fs2.c Farsight 2 backend for media API
+ * @ingroup core
+ */
+
+/* purple
+ *
+ * Purple is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * 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 "backend-fs2.h"
+
+#ifdef USE_VV
+#include "backend-iface.h"
+#include "debug.h"
+#include "network.h"
+#include "media-gst.h"
+
+#include <gst/farsight/fs-conference-iface.h>
+#include <gst/farsight/fs-element-added-notifier.h>
+
+/** @copydoc _PurpleMediaBackendFs2Class */
+typedef struct _PurpleMediaBackendFs2Class PurpleMediaBackendFs2Class;
+/** @copydoc _PurpleMediaBackendFs2Private */
+typedef struct _PurpleMediaBackendFs2Private PurpleMediaBackendFs2Private;
+/** @copydoc _PurpleMediaBackendFs2Session */
+typedef struct _PurpleMediaBackendFs2Session PurpleMediaBackendFs2Session;
+/** @copydoc _PurpleMediaBackendFs2Stream */
+typedef struct _PurpleMediaBackendFs2Stream PurpleMediaBackendFs2Stream;
+
+#define PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(obj) \
+		(G_TYPE_INSTANCE_GET_PRIVATE((obj), \
+		PURPLE_TYPE_MEDIA_BACKEND_FS2, PurpleMediaBackendFs2Private))
+
+static void purple_media_backend_iface_init(PurpleMediaBackendIface *iface);
+
+static gboolean
+gst_bus_cb(GstBus *bus, GstMessage *msg, PurpleMediaBackendFs2 *self);
+static void
+state_changed_cb(PurpleMedia *media, PurpleMediaState state,
+		gchar *sid, gchar *name, PurpleMediaBackendFs2 *self);
+static void
+stream_info_cb(PurpleMedia *media, PurpleMediaInfoType type,
+		gchar *sid, gchar *name, gboolean local,
+		PurpleMediaBackendFs2 *self);
+
+static gboolean purple_media_backend_fs2_add_stream(PurpleMediaBackend *self,
+		const gchar *sess_id, const gchar *who,
+		PurpleMediaSessionType type, gboolean initiator,
+		const gchar *transmitter,
+		guint num_params, GParameter *params);
+static void purple_media_backend_fs2_add_remote_candidates(
+		PurpleMediaBackend *self,
+		const gchar *sess_id, const gchar *participant,
+		GList *remote_candidates);
+static gboolean purple_media_backend_fs2_codecs_ready(PurpleMediaBackend *self,
+		const gchar *sess_id);
+static GList *purple_media_backend_fs2_get_codecs(PurpleMediaBackend *self,
+		const gchar *sess_id);
+static GList *purple_media_backend_fs2_get_local_candidates(
+		PurpleMediaBackend *self,
+		const gchar *sess_id, const gchar *participant);
+static gboolean purple_media_backend_fs2_set_remote_codecs(
+		PurpleMediaBackend *self,
+		const gchar *sess_id, const gchar *participant,
+		GList *codecs);
+static gboolean purple_media_backend_fs2_set_send_codec(
+		PurpleMediaBackend *self, const gchar *sess_id,
+		PurpleMediaCodec *codec);
+static void purple_media_backend_fs2_set_params(PurpleMediaBackend *self,
+		guint num_params, GParameter *params);
+static const gchar **purple_media_backend_fs2_get_available_params(void);
+
+static void free_stream(PurpleMediaBackendFs2Stream *stream);
+static void free_session(PurpleMediaBackendFs2Session *session);
+
+struct _PurpleMediaBackendFs2Class
+{
+	GObjectClass parent_class;
+};
+
+struct _PurpleMediaBackendFs2
+{
+	GObject parent;
+};
+
+G_DEFINE_TYPE_WITH_CODE(PurpleMediaBackendFs2, purple_media_backend_fs2,
+		G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE(
+		PURPLE_TYPE_MEDIA_BACKEND, purple_media_backend_iface_init));
+
+struct _PurpleMediaBackendFs2Stream
+{
+	PurpleMediaBackendFs2Session *session;
+	gchar *participant;
+	FsStream *stream;
+
+	GstElement *src;
+	GstElement *tee;
+	GstElement *volume;
+	GstElement *level;
+	GstElement *fakesink;
+	GstElement *queue;
+
+	GList *local_candidates;
+	GList *remote_candidates;
+
+	guint connected_cb_id;
+};
+
+struct _PurpleMediaBackendFs2Session
+{
+	PurpleMediaBackendFs2 *backend;
+	gchar *id;
+	FsSession *session;
+
+	GstElement *src;
+	GstElement *tee;
+	GstElement *srcvalve;
+
+	GstPad *srcpad;
+
+	PurpleMediaSessionType type;
+};
+
+struct _PurpleMediaBackendFs2Private
+{
+	PurpleMedia *media;
+	GstElement *confbin;
+	FsConference *conference;
+	gchar *conference_type;
+
+	GHashTable *sessions;
+	GHashTable *participants;
+
+	GList *streams;
+
+	gdouble silence_threshold;
+};
+
+enum {
+	PROP_0,
+	PROP_CONFERENCE_TYPE,
+	PROP_MEDIA,
+};
+
+static void
+purple_media_backend_fs2_init(PurpleMediaBackendFs2 *self)
+{}
+
+static gboolean
+event_probe_cb(GstPad *srcpad, GstEvent *event, gboolean release_pad)
+{
+	if (GST_EVENT_TYPE(event) == GST_EVENT_CUSTOM_DOWNSTREAM
+		&& gst_event_has_name(event, "purple-unlink-tee")) {
+
+		const GstStructure *s = gst_event_get_structure(event);
+
+		gst_pad_unlink(srcpad, gst_pad_get_peer(srcpad));
+
+		gst_pad_remove_event_probe(srcpad,
+			g_value_get_uint(gst_structure_get_value(s, "handler-id")));
+
+		if (g_value_get_boolean(gst_structure_get_value(s, "release-pad")))
+			gst_element_release_request_pad(GST_ELEMENT_PARENT(srcpad), srcpad);
+
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+static void
+unlink_teepad_dynamic(GstPad *srcpad, gboolean release_pad)
+{
+	guint id = gst_pad_add_event_probe(srcpad, G_CALLBACK(event_probe_cb), NULL);
+
+	if (GST_IS_GHOST_PAD(srcpad))
+		srcpad = gst_ghost_pad_get_target(GST_GHOST_PAD(srcpad));
+
+	gst_element_send_event(gst_pad_get_parent_element(srcpad),
+		gst_event_new_custom(GST_EVENT_CUSTOM_DOWNSTREAM,
+			gst_structure_new("purple-unlink-tee",
+				"release-pad", G_TYPE_BOOLEAN, release_pad,
+				"handler-id", G_TYPE_UINT, id,
+				NULL)));
+}
+
+static void
+purple_media_backend_fs2_dispose(GObject *obj)
+{
+	PurpleMediaBackendFs2Private *priv =
+			PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(obj);
+	GList *iter = NULL;
+
+	purple_debug_info("backend-fs2", "purple_media_backend_fs2_dispose\n");
+
+	if (priv->confbin) {
+		GstElement *pipeline;
+
+		pipeline = purple_media_manager_get_pipeline(
+				purple_media_get_manager(priv->media));
+
+		/* All connections to media sources should be blocked before confbin is
+		 * removed, to prevent freezing of any other simultaneously running
+		 * media calls. */
+		if (priv->sessions) {
+			GList *sessions = g_hash_table_get_values(priv->sessions);
+			for (; sessions; sessions =
+					g_list_delete_link(sessions, sessions)) {
+				PurpleMediaBackendFs2Session *session = sessions->data;
+				if (session->srcpad) {
+					unlink_teepad_dynamic(session->srcpad, FALSE);
+					gst_object_unref(session->srcpad);
+					session->srcpad = NULL;
+				}
+			}
+		}
+
+		gst_element_set_locked_state(priv->confbin, TRUE);
+		gst_element_set_state(GST_ELEMENT(priv->confbin),
+				GST_STATE_NULL);
+
+		if (pipeline) {
+			GstBus *bus;
+			gst_bin_remove(GST_BIN(pipeline), priv->confbin);
+			bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
+			g_signal_handlers_disconnect_matched(G_OBJECT(bus),
+					G_SIGNAL_MATCH_FUNC |
+					G_SIGNAL_MATCH_DATA,
+					0, 0, 0, gst_bus_cb, obj);
+			gst_object_unref(bus);
+		} else {
+			purple_debug_warning("backend-fs2", "Unable to "
+					"properly dispose the conference. "
+					"Couldn't get the pipeline.\n");
+		}
+
+		priv->confbin = NULL;
+		priv->conference = NULL;
+
+	}
+
+	if (priv->sessions) {
+		GList *sessions = g_hash_table_get_values(priv->sessions);
+
+		for (; sessions; sessions =
+				g_list_delete_link(sessions, sessions)) {
+			PurpleMediaBackendFs2Session *session =
+					sessions->data;
+
+			if (session->session) {
+				g_object_unref(session->session);
+				session->session = NULL;
+			}
+		}
+	}
+
+	if (priv->participants) {
+		g_hash_table_destroy(priv->participants);
+		priv->participants = NULL;
+	}
+
+	for (iter = priv->streams; iter; iter = g_list_next(iter)) {
+		PurpleMediaBackendFs2Stream *stream = iter->data;
+		if (stream->stream) {
+			g_object_unref(stream->stream);
+			stream->stream = NULL;
+		}
+	}
+
+	if (priv->media) {
+		g_object_remove_weak_pointer(G_OBJECT(priv->media),
+				(gpointer*)&priv->media);
+		priv->media = NULL;
+	}
+
+	G_OBJECT_CLASS(purple_media_backend_fs2_parent_class)->dispose(obj);
+}
+
+static void
+purple_media_backend_fs2_finalize(GObject *obj)
+{
+	PurpleMediaBackendFs2Private *priv =
+			PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(obj);
+
+	purple_debug_info("backend-fs2", "purple_media_backend_fs2_finalize\n");
+
+	g_free(priv->conference_type);
+
+	for (; priv->streams; priv->streams =
+			g_list_delete_link(priv->streams, priv->streams)) {
+		PurpleMediaBackendFs2Stream *stream = priv->streams->data;
+		free_stream(stream);
+	}
+
+	if (priv->sessions) {
+		GList *sessions = g_hash_table_get_values(priv->sessions);
+
+		for (; sessions; sessions =
+				g_list_delete_link(sessions, sessions)) {
+			PurpleMediaBackendFs2Session *session =
+					sessions->data;
+			free_session(session);
+		}
+
+		g_hash_table_destroy(priv->sessions);
+	}
+
+	G_OBJECT_CLASS(purple_media_backend_fs2_parent_class)->finalize(obj);
+}
+
+static void
+purple_media_backend_fs2_set_property(GObject *object, guint prop_id,
+		const GValue *value, GParamSpec *pspec)
+{
+	PurpleMediaBackendFs2Private *priv;
+	g_return_if_fail(PURPLE_IS_MEDIA_BACKEND_FS2(object));
+
+	priv = PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(object);
+
+	switch (prop_id) {
+		case PROP_CONFERENCE_TYPE:
+			priv->conference_type = g_value_dup_string(value);
+			break;
+		case PROP_MEDIA:
+			priv->media = g_value_get_object(value);
+
+			if (priv->media == NULL)
+				break;
+
+			g_object_add_weak_pointer(G_OBJECT(priv->media),
+					(gpointer*)&priv->media);
+
+			g_signal_connect(G_OBJECT(priv->media),
+					"state-changed",
+					G_CALLBACK(state_changed_cb),
+					PURPLE_MEDIA_BACKEND_FS2(object));
+			g_signal_connect(G_OBJECT(priv->media), "stream-info",
+					G_CALLBACK(stream_info_cb),
+					PURPLE_MEDIA_BACKEND_FS2(object));
+			break;
+		default:
+			G_OBJECT_WARN_INVALID_PROPERTY_ID(
+					object, prop_id, pspec);
+			break;
+	}
+}
+
+static void
+purple_media_backend_fs2_get_property(GObject *object, guint prop_id,
+		GValue *value, GParamSpec *pspec)
+{
+	PurpleMediaBackendFs2Private *priv;
+	g_return_if_fail(PURPLE_IS_MEDIA_BACKEND_FS2(object));
+
+	priv = PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(object);
+
+	switch (prop_id) {
+		case PROP_CONFERENCE_TYPE:
+			g_value_set_string(value, priv->conference_type);
+			break;
+		case PROP_MEDIA:
+			g_value_set_object(value, priv->media);
+			break;
+		default:
+			G_OBJECT_WARN_INVALID_PROPERTY_ID(
+					object, prop_id, pspec);
+			break;
+	}
+}
+
+static void
+purple_media_backend_fs2_class_init(PurpleMediaBackendFs2Class *klass)
+{
+	GObjectClass *gobject_class = (GObjectClass*)klass;
+
+	gobject_class->dispose = purple_media_backend_fs2_dispose;
+	gobject_class->finalize = purple_media_backend_fs2_finalize;
+	gobject_class->set_property = purple_media_backend_fs2_set_property;
+	gobject_class->get_property = purple_media_backend_fs2_get_property;
+
+	g_object_class_override_property(gobject_class, PROP_CONFERENCE_TYPE,
+			"conference-type");
+	g_object_class_override_property(gobject_class, PROP_MEDIA, "media");
+
+	g_type_class_add_private(klass, sizeof(PurpleMediaBackendFs2Private));
+}
+
+static void
+purple_media_backend_iface_init(PurpleMediaBackendIface *iface)
+{
+	iface->add_stream = purple_media_backend_fs2_add_stream;
+	iface->add_remote_candidates =
+			purple_media_backend_fs2_add_remote_candidates;
+	iface->codecs_ready = purple_media_backend_fs2_codecs_ready;
+	iface->get_codecs = purple_media_backend_fs2_get_codecs;
+	iface->get_local_candidates =
+			purple_media_backend_fs2_get_local_candidates;
+	iface->set_remote_codecs = purple_media_backend_fs2_set_remote_codecs;
+	iface->set_send_codec = purple_media_backend_fs2_set_send_codec;
+	iface->set_params = purple_media_backend_fs2_set_params;
+	iface->get_available_params = purple_media_backend_fs2_get_available_params;
+}
+
+static FsMediaType
+session_type_to_fs_media_type(PurpleMediaSessionType type)
+{
+	if (type & PURPLE_MEDIA_AUDIO)
+		return FS_MEDIA_TYPE_AUDIO;
+	else if (type & PURPLE_MEDIA_VIDEO)
+		return FS_MEDIA_TYPE_VIDEO;
+	else
+		return 0;
+}
+
+static FsStreamDirection
+session_type_to_fs_stream_direction(PurpleMediaSessionType type)
+{
+	if ((type & PURPLE_MEDIA_AUDIO) == PURPLE_MEDIA_AUDIO ||
+			(type & PURPLE_MEDIA_VIDEO) == PURPLE_MEDIA_VIDEO)
+		return FS_DIRECTION_BOTH;
+	else if ((type & PURPLE_MEDIA_SEND_AUDIO) ||
+			(type & PURPLE_MEDIA_SEND_VIDEO))
+		return FS_DIRECTION_SEND;
+	else if ((type & PURPLE_MEDIA_RECV_AUDIO) ||
+			(type & PURPLE_MEDIA_RECV_VIDEO))
+		return FS_DIRECTION_RECV;
+	else
+		return FS_DIRECTION_NONE;
+}
+
+static PurpleMediaSessionType
+session_type_from_fs(FsMediaType type, FsStreamDirection direction)
+{
+	PurpleMediaSessionType result = PURPLE_MEDIA_NONE;
+	if (type == FS_MEDIA_TYPE_AUDIO) {
+		if (direction & FS_DIRECTION_SEND)
+			result |= PURPLE_MEDIA_SEND_AUDIO;
+		if (direction & FS_DIRECTION_RECV)
+			result |= PURPLE_MEDIA_RECV_AUDIO;
+	} else if (type == FS_MEDIA_TYPE_VIDEO) {
+		if (direction & FS_DIRECTION_SEND)
+			result |= PURPLE_MEDIA_SEND_VIDEO;
+		if (direction & FS_DIRECTION_RECV)
+			result |= PURPLE_MEDIA_RECV_VIDEO;
+	}
+	return result;
+}
+
+static FsCandidate *
+candidate_to_fs(PurpleMediaCandidate *candidate)
+{
+	FsCandidate *fscandidate;
+	gchar *foundation;
+	guint component_id;
+	gchar *ip;
+	guint port;
+	gchar *base_ip;
+	guint base_port;
+	PurpleMediaNetworkProtocol proto;
+	guint32 priority;
+	PurpleMediaCandidateType type;
+	gchar *username;
+	gchar *password;
+	guint ttl;
+
+	if (candidate == NULL)
+		return NULL;
+
+	g_object_get(G_OBJECT(candidate),
+			"foundation", &foundation,
+			"component-id", &component_id,
+			"ip", &ip,
+			"port", &port,
+			"base-ip", &base_ip,
+			"base-port", &base_port,
+			"protocol", &proto,
+			"priority", &priority,
+			"type", &type,
+			"username", &username,
+			"password", &password,
+			"ttl", &ttl,
+			NULL);
+
+	fscandidate = fs_candidate_new(foundation,
+			component_id, type,
+			proto, ip, port);
+
+	fscandidate->base_ip = base_ip;
+	fscandidate->base_port = base_port;
+	fscandidate->priority = priority;
+	fscandidate->username = username;
+	fscandidate->password = password;
+	fscandidate->ttl = ttl;
+
+	g_free(foundation);
+	g_free(ip);
+	return fscandidate;
+}
+
+static GList *
+candidate_list_to_fs(GList *candidates)
+{
+	GList *new_list = NULL;
+
+	for (; candidates; candidates = g_list_next(candidates)) {
+		new_list = g_list_prepend(new_list,
+				candidate_to_fs(candidates->data));
+	}
+
+	new_list = g_list_reverse(new_list);
+	return new_list;
+}
+
+static PurpleMediaCandidate *
+candidate_from_fs(FsCandidate *fscandidate)
+{
+	PurpleMediaCandidate *candidate;
+
+	if (fscandidate == NULL)
+		return NULL;
+
+	candidate = purple_media_candidate_new(fscandidate->foundation,
+		fscandidate->component_id, fscandidate->type,
+		fscandidate->proto, fscandidate->ip, fscandidate->port);
+	g_object_set(candidate,
+			"base-ip", fscandidate->base_ip,
+			"base-port", fscandidate->base_port,
+			"priority", fscandidate->priority,
+			"username", fscandidate->username,
+			"password", fscandidate->password,
+			"ttl", fscandidate->ttl, NULL);
+	return candidate;
+}
+
+static GList *
+candidate_list_from_fs(GList *candidates)
+{
+	GList *new_list = NULL;
+
+	for (; candidates; candidates = g_list_next(candidates)) {
+		new_list = g_list_prepend(new_list,
+			candidate_from_fs(candidates->data));
+	}
+
+	new_list = g_list_reverse(new_list);
+	return new_list;
+}
+
+static FsCodec *
+codec_to_fs(const PurpleMediaCodec *codec)
+{
+	FsCodec *new_codec;
+	gint id;
+	char *encoding_name;
+	PurpleMediaSessionType media_type;
+	guint clock_rate;
+	guint channels;
+	GList *iter;
+
+	if (codec == NULL)
+		return NULL;
+
+	g_object_get(G_OBJECT(codec),
+			"id", &id,
+			"encoding-name", &encoding_name,
+			"media-type", &media_type,
+			"clock-rate", &clock_rate,
+			"channels", &channels,
+			"optional-params", &iter,
+			NULL);
+
+	new_codec = fs_codec_new(id, encoding_name,
+			session_type_to_fs_media_type(media_type),
+			clock_rate);
+	new_codec->channels = channels;
+
+	for (; iter; iter = g_list_next(iter)) {
+		PurpleKeyValuePair *param = (PurpleKeyValuePair*)iter->data;
+		fs_codec_add_optional_parameter(new_codec,
+				param->key, param->value);
+	}
+
+	g_free(encoding_name);
+	return new_codec;
+}
+
+static PurpleMediaCodec *
+codec_from_fs(const FsCodec *codec)
+{
+	PurpleMediaCodec *new_codec;
+	GList *iter;
+
+	if (codec == NULL)
+		return NULL;
+
+	new_codec = purple_media_codec_new(codec->id, codec->encoding_name,
+			session_type_from_fs(codec->media_type,
+			FS_DIRECTION_BOTH), codec->clock_rate);
+	g_object_set(new_codec, "channels", codec->channels, NULL);
+
+	for (iter = codec->optional_params; iter; iter = g_list_next(iter)) {
+		FsCodecParameter *param = (FsCodecParameter*)iter->data;
+		purple_media_codec_add_optional_parameter(new_codec,
+				param->name, param->value);
+	}
+
+	return new_codec;
+}
+
+static GList *
+codec_list_from_fs(GList *codecs)
+{
+	GList *new_list = NULL;
+
+	for (; codecs; codecs = g_list_next(codecs)) {
+		new_list = g_list_prepend(new_list,
+				codec_from_fs(codecs->data));
+	}
+
+	new_list = g_list_reverse(new_list);
+	return new_list;
+}
+
+static GList *
+codec_list_to_fs(GList *codecs)
+{
+	GList *new_list = NULL;
+
+	for (; codecs; codecs = g_list_next(codecs)) {
+		new_list = g_list_prepend(new_list,
+				codec_to_fs(codecs->data));
+	}
+
+	new_list = g_list_reverse(new_list);
+	return new_list;
+}
+
+static PurpleMediaBackendFs2Session *
+get_session(PurpleMediaBackendFs2 *self, const gchar *sess_id)
+{
+	PurpleMediaBackendFs2Private *priv;
+	PurpleMediaBackendFs2Session *session = NULL;
+
+	g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND_FS2(self), NULL);
+
+	priv = PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(self);
+
+	if (priv->sessions != NULL)
+		session = g_hash_table_lookup(priv->sessions, sess_id);
+
+	return session;
+}
+
+static FsParticipant *
+get_participant(PurpleMediaBackendFs2 *self, const gchar *name)
+{
+	PurpleMediaBackendFs2Private *priv;
+	FsParticipant *participant = NULL;
+
+	g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND_FS2(self), NULL);
+
+	priv = PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(self);
+
+	if (priv->participants != NULL)
+		participant = g_hash_table_lookup(priv->participants, name);
+
+	return participant;
+}
+
+static PurpleMediaBackendFs2Stream *
+get_stream(PurpleMediaBackendFs2 *self,
+		const gchar *sess_id, const gchar *name)
+{
+	PurpleMediaBackendFs2Private *priv;
+	GList *streams;
+
+	g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND_FS2(self), NULL);
+
+	priv = PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(self);
+	streams = priv->streams;
+
+	for (; streams; streams = g_list_next(streams)) {
+		PurpleMediaBackendFs2Stream *stream = streams->data;
+		if (!strcmp(stream->session->id, sess_id) &&
+				!strcmp(stream->participant, name))
+			return stream;
+	}
+
+	return NULL;
+}
+
+static GList *
+get_streams(PurpleMediaBackendFs2 *self,
+		const gchar *sess_id, const gchar *name)
+{
+	PurpleMediaBackendFs2Private *priv;
+	GList *streams, *ret = NULL;
+
+	g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND_FS2(self), NULL);
+
+	priv = PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(self);
+	streams = priv->streams;
+
+	for (; streams; streams = g_list_next(streams)) {
+		PurpleMediaBackendFs2Stream *stream = streams->data;
+
+		if (sess_id != NULL && strcmp(stream->session->id, sess_id))
+			continue;
+		else if (name != NULL && strcmp(stream->participant, name))
+			continue;
+		else
+			ret = g_list_prepend(ret, stream);
+	}
+
+	ret = g_list_reverse(ret);
+	return ret;
+}
+
+static PurpleMediaBackendFs2Session *
+get_session_from_fs_stream(PurpleMediaBackendFs2 *self, FsStream *stream)
+{
+	PurpleMediaBackendFs2Private *priv =
+			PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(self);
+	FsSession *fssession;
+	GList *values;
+
+	g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND_FS2(self), NULL);
+	g_return_val_if_fail(FS_IS_STREAM(stream), NULL);
+
+	g_object_get(stream, "session", &fssession, NULL);
+
+	values = g_hash_table_get_values(priv->sessions);
+
+	for (; values; values = g_list_delete_link(values, values)) {
+		PurpleMediaBackendFs2Session *session = values->data;
+
+		if (session->session == fssession) {
+			g_list_free(values);
+			g_object_unref(fssession);
+			return session;
+		}
+	}
+
+	g_object_unref(fssession);
+	return NULL;
+}
+
+static gdouble
+gst_msg_db_to_percent(GstMessage *msg, gchar *value_name)
+{
+	const GValue *list;
+	const GValue *value;
+	gdouble value_db;
+	gdouble percent;
+
+	list = gst_structure_get_value(
+				gst_message_get_structure(msg), value_name);
+	value = gst_value_list_get_value(list, 0);
+	value_db = g_value_get_double(value);
+	percent = pow(10, value_db / 20);
+	return (percent > 1.0) ? 1.0 : percent;
+}
+
+static void
+gst_handle_message_element(GstBus *bus, GstMessage *msg,
+		PurpleMediaBackendFs2 *self)
+{
+	PurpleMediaBackendFs2Private *priv =
+			PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(self);
+	GstElement *src = GST_ELEMENT(GST_MESSAGE_SRC(msg));
+	static guint level_id = 0;
+
+	if (level_id == 0)
+		level_id = g_signal_lookup("level", PURPLE_TYPE_MEDIA);
+
+	if (gst_structure_has_name(msg->structure, "level")) {
+		GstElement *src = GST_ELEMENT(GST_MESSAGE_SRC(msg));
+		gchar *name;
+		gchar *participant = NULL;
+		PurpleMediaBackendFs2Session *session = NULL;
+		gdouble percent;
+
+		if (!PURPLE_IS_MEDIA(priv->media) ||
+				GST_ELEMENT_PARENT(src) != priv->confbin)
+			return;
+
+		name = gst_element_get_name(src);
+
+		if (!strncmp(name, "sendlevel_", 10)) {
+			session = get_session(self, name+10);
+			if (priv->silence_threshold > 0) {
+				percent = gst_msg_db_to_percent(msg, "decay");
+				g_object_set(session->srcvalve,
+						"drop", (percent < priv->silence_threshold), NULL);
+			}
+		}
+
+		g_free(name);
+
+		if (!g_signal_has_handler_pending(priv->media, level_id, 0, FALSE))
+			return;
+
+		if (!session) {
+			GList *iter = priv->streams;
+			PurpleMediaBackendFs2Stream *stream;
+			for (; iter; iter = g_list_next(iter)) {
+				stream = iter->data;
+				if (stream->level == src) {
+					session = stream->session;
+					participant = stream->participant;
+					break;
+				}
+			}
+		}
+
+		if (!session)
+			return;
+
+		percent = gst_msg_db_to_percent(msg, "rms");
+
+		g_signal_emit(priv->media, level_id, 0,
+				session->id, participant, percent);
+		return;
+	}
+
+	if (!FS_IS_CONFERENCE(src) || !PURPLE_IS_MEDIA_BACKEND(self) ||
+			priv->conference != FS_CONFERENCE(src))
+		return;
+
+	if (gst_structure_has_name(msg->structure, "farsight-error")) {
+		FsError error_no;
+		gst_structure_get_enum(msg->structure, "error-no",
+				FS_TYPE_ERROR, (gint*)&error_no);
+		switch (error_no) {
+			case FS_ERROR_NO_CODECS:
+				purple_media_error(priv->media, _("No codecs"
+						" found. Install some"
+						" GStreamer codecs found"
+						" in GStreamer plugins"
+						" packages."));
+				purple_media_end(priv->media, NULL, NULL);
+				break;
+			case FS_ERROR_NO_CODECS_LEFT:
+				purple_media_error(priv->media, _("No codecs"
+						" left. Your codec"
+						" preferences in"
+						" fs-codecs.conf are too"
+						" strict."));
+				purple_media_end(priv->media, NULL, NULL);
+				break;
+			case FS_ERROR_UNKNOWN_CNAME:
+			/*
+			 * Unknown CName is only a problem for the
+			 * multicast transmitter which isn't used.
+			 * It is also deprecated.
+			 */
+				break;
+			default:
+				purple_debug_error("backend-fs2",
+						"farsight-error: %i: %s\n",
+						error_no,
+					  	gst_structure_get_string(
+						msg->structure, "error-msg"));
+				break;
+		}
+
+		if (FS_ERROR_IS_FATAL(error_no)) {
+			purple_media_error(priv->media, _("A non-recoverable "
+					"Farsight2 error has occurred."));
+			purple_media_end(priv->media, NULL, NULL);
+		}
+	} else if (gst_structure_has_name(msg->structure,
+			"farsight-new-local-candidate")) {
+		const GValue *value;
+		FsStream *stream;
+		FsCandidate *local_candidate;
+		PurpleMediaCandidate *candidate;
+		FsParticipant *participant;
+		PurpleMediaBackendFs2Session *session;
+		PurpleMediaBackendFs2Stream *media_stream;
+		gchar *name;
+
+		value = gst_structure_get_value(msg->structure, "stream");
+		stream = g_value_get_object(value);
+		value = gst_structure_get_value(msg->structure, "candidate");
+		local_candidate = g_value_get_boxed(value);
+
+		session = get_session_from_fs_stream(self, stream);
+
+		purple_debug_info("backend-fs2",
+				"got new local candidate: %s\n",
+				local_candidate->foundation);
+
+		g_object_get(stream, "participant", &participant, NULL);
+		g_object_get(participant, "cname", &name, NULL);
+		g_object_unref(participant);
+
+		media_stream = get_stream(self, session->id, name);
+		media_stream->local_candidates = g_list_append(
+				media_stream->local_candidates,
+				fs_candidate_copy(local_candidate));
+
+		candidate = candidate_from_fs(local_candidate);
+		g_signal_emit_by_name(self, "new-candidate",
+				session->id, name, candidate);
+		g_object_unref(candidate);
+	} else if (gst_structure_has_name(msg->structure,
+			"farsight-local-candidates-prepared")) {
+		const GValue *value;
+		FsStream *stream;
+		FsParticipant *participant;
+		PurpleMediaBackendFs2Session *session;
+		gchar *name;
+
+		value = gst_structure_get_value(msg->structure, "stream");
+		stream = g_value_get_object(value);
+		session = get_session_from_fs_stream(self, stream);
+
+		g_object_get(stream, "participant", &participant, NULL);
+		g_object_get(participant, "cname", &name, NULL);
+		g_object_unref(participant);
+
+		g_signal_emit_by_name(self, "candidates-prepared",
+				session->id, name);
+	} else if (gst_structure_has_name(msg->structure,
+			"farsight-new-active-candidate-pair")) {
+		const GValue *value;
+		FsStream *stream;
+		FsCandidate *local_candidate;
+		FsCandidate *remote_candidate;
+		FsParticipant *participant;
+		PurpleMediaBackendFs2Session *session;
+		PurpleMediaCandidate *lcandidate, *rcandidate;
+		gchar *name;
+
+		value = gst_structure_get_value(msg->structure, "stream");
+		stream = g_value_get_object(value);
+		value = gst_structure_get_value(msg->structure,
+				"local-candidate");
+		local_candidate = g_value_get_boxed(value);
+		value = gst_structure_get_value(msg->structure,
+				"remote-candidate");
+		remote_candidate = g_value_get_boxed(value);
+
+		g_object_get(stream, "participant", &participant, NULL);
+		g_object_get(participant, "cname", &name, NULL);
+		g_object_unref(participant);
+
+		session = get_session_from_fs_stream(self, stream);
+
+		lcandidate = candidate_from_fs(local_candidate);
+		rcandidate = candidate_from_fs(remote_candidate);
+
+		g_signal_emit_by_name(self, "active-candidate-pair",
+				session->id, name, lcandidate, rcandidate);
+
+		g_object_unref(lcandidate);
+		g_object_unref(rcandidate);
+	} else if (gst_structure_has_name(msg->structure,
+			"farsight-recv-codecs-changed")) {
+		const GValue *value;
+		GList *codecs;
+		FsCodec *codec;
+
+		value = gst_structure_get_value(msg->structure, "codecs");
+		codecs = g_value_get_boxed(value);
+		codec = codecs->data;
+
+		purple_debug_info("backend-fs2",
+				"farsight-recv-codecs-changed: %s\n",
+				codec->encoding_name);
+	} else if (gst_structure_has_name(msg->structure,
+			"farsight-component-state-changed")) {
+		const GValue *value;
+		FsStreamState fsstate;
+		guint component;
+		const gchar *state;
+
+		value = gst_structure_get_value(msg->structure, "state");
+		fsstate = g_value_get_enum(value);
+		value = gst_structure_get_value(msg->structure, "component");
+		component = g_value_get_uint(value);
+
+		switch (fsstate) {
+			case FS_STREAM_STATE_FAILED:
+				state = "FAILED";
+				break;
+			case FS_STREAM_STATE_DISCONNECTED:
+				state = "DISCONNECTED";
+				break;
+			case FS_STREAM_STATE_GATHERING:
+				state = "GATHERING";
+				break;
+			case FS_STREAM_STATE_CONNECTING:
+				state = "CONNECTING";
+				break;
+			case FS_STREAM_STATE_CONNECTED:
+				state = "CONNECTED";
+				break;
+			case FS_STREAM_STATE_READY:
+				state = "READY";
+				break;
+			default:
+				state = "UNKNOWN";
+				break;
+		}
+
+		purple_debug_info("backend-fs2",
+				"farsight-component-state-changed: "
+				"component: %u state: %s\n",
+				component, state);
+	} else if (gst_structure_has_name(msg->structure,
+			"farsight-send-codec-changed")) {
+		const GValue *value;
+		FsCodec *codec;
+		gchar *codec_str;
+
+		value = gst_structure_get_value(msg->structure, "codec");
+		codec = g_value_get_boxed(value);
+		codec_str = fs_codec_to_string(codec);
+
+		purple_debug_info("backend-fs2",
+				"farsight-send-codec-changed: codec: %s\n",
+				codec_str);
+
+		g_free(codec_str);
+	} else if (gst_structure_has_name(msg->structure,
+			"farsight-codecs-changed")) {
+		const GValue *value;
+		FsSession *fssession;
+		GList *sessions;
+
+		value = gst_structure_get_value(msg->structure, "session");
+		fssession = g_value_get_object(value);
+		sessions = g_hash_table_get_values(priv->sessions);
+
+		for (; sessions; sessions =
+				g_list_delete_link(sessions, sessions)) {
+			PurpleMediaBackendFs2Session *session = sessions->data;
+			gchar *session_id;
+
+			if (session->session != fssession)
+				continue;
+
+			session_id = g_strdup(session->id);
+			g_signal_emit_by_name(self, "codecs-changed",
+					session_id);
+			g_free(session_id);
+			g_list_free(sessions);
+			break;
+		}
+	}
+}
+
+static void
+gst_handle_message_error(GstBus *bus, GstMessage *msg,
+		PurpleMediaBackendFs2 *self)
+{
+	PurpleMediaBackendFs2Private *priv =
+			PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(self);
+	GstElement *element = GST_ELEMENT(GST_MESSAGE_SRC(msg));
+	GstElement *lastElement = NULL;
+	GList *sessions;
+
+	GError *error = NULL;
+	gchar *debug_msg = NULL;
+
+	gst_message_parse_error(msg, &error, &debug_msg);
+	purple_debug_error("backend-fs2", "gst error %s\ndebugging: %s\n",
+			error->message, debug_msg);
+
+	g_error_free(error);
+	g_free(debug_msg);
+
+	while (element && !GST_IS_PIPELINE(element)) {
+		if (element == priv->confbin)
+			break;
+
+		lastElement = element;
+		element = GST_ELEMENT_PARENT(element);
+	}
+
+	if (!element || !GST_IS_PIPELINE(element))
+		return;
+
+	sessions = purple_media_get_session_ids(priv->media);
+
+	for (; sessions; sessions = g_list_delete_link(sessions, sessions)) {
+		if (purple_media_get_src(priv->media, sessions->data)
+				!= lastElement)
+			continue;
+
+		if (purple_media_get_session_type(priv->media, sessions->data)
+				& PURPLE_MEDIA_AUDIO)
+			purple_media_error(priv->media,
+					_("Error with your microphone"));
+		else
+			purple_media_error(priv->media,
+					_("Error with your webcam"));
+
+		break;
+	}
+
+	g_list_free(sessions);
+
+	purple_media_error(priv->media, _("Conference error"));
+	purple_media_end(priv->media, NULL, NULL);
+}
+
+static gboolean
+gst_bus_cb(GstBus *bus, GstMessage *msg, PurpleMediaBackendFs2 *self)
+{
+	switch(GST_MESSAGE_TYPE(msg)) {
+		case GST_MESSAGE_ELEMENT:
+			gst_handle_message_element(bus, msg, self);
+			break;
+		case GST_MESSAGE_ERROR:
+			gst_handle_message_error(bus, msg, self);
+			break;
+		default:
+			break;
+	}
+
+	return TRUE;
+}
+
+static void
+remove_element(GstElement *element)
+{
+	if (element) {
+		gst_element_set_locked_state(element, TRUE);
+		gst_element_set_state(element, GST_STATE_NULL);
+		gst_bin_remove(GST_BIN(GST_ELEMENT_PARENT(element)), element);
+	}
+}
+
+static void
+state_changed_cb(PurpleMedia *media, PurpleMediaState state,
+		gchar *sid, gchar *name, PurpleMediaBackendFs2 *self)
+{
+	if (state == PURPLE_MEDIA_STATE_END) {
+		PurpleMediaBackendFs2Private *priv =
+				PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(self);
+
+		if (sid && name) {
+			PurpleMediaBackendFs2Stream *stream = get_stream(self, sid, name);
+			gst_object_unref(stream->stream);
+
+			priv->streams = g_list_remove(priv->streams, stream);
+
+			remove_element(stream->src);
+			remove_element(stream->tee);
+			remove_element(stream->volume);
+			remove_element(stream->level);
+			remove_element(stream->fakesink);
+			remove_element(stream->queue);
+
+			free_stream(stream);
+		} else if (sid && !name) {
+			PurpleMediaBackendFs2Session *session = get_session(self, sid);
+			GstPad *pad;
+
+			g_object_get(session->session, "sink-pad", &pad, NULL);
+			gst_pad_unlink(GST_PAD_PEER(pad), pad);
+			gst_object_unref(pad);
+
+			gst_object_unref(session->session);
+			g_hash_table_remove(priv->sessions, session->id);
+
+			pad = gst_pad_get_peer(session->srcpad);
+			gst_element_remove_pad(GST_ELEMENT_PARENT(pad), pad);
+			gst_object_unref(pad);
+			gst_object_unref(session->srcpad);
+
+			remove_element(session->srcvalve);
+			remove_element(session->tee);
+
+			free_session(session);
+		}
+
+		purple_media_manager_remove_output_windows(
+				purple_media_get_manager(media), media, sid, name);
+	}
+}
+
+static void
+stream_info_cb(PurpleMedia *media, PurpleMediaInfoType type,
+		gchar *sid, gchar *name, gboolean local,
+		PurpleMediaBackendFs2 *self)
+{
+	if (type == PURPLE_MEDIA_INFO_ACCEPT && sid != NULL && name != NULL) {
+		PurpleMediaBackendFs2Stream *stream =
+				get_stream(self, sid, name);
+		GError *err = NULL;
+
+		g_object_set(G_OBJECT(stream->stream), "direction",
+				session_type_to_fs_stream_direction(
+				stream->session->type), NULL);
+
+		if (stream->remote_candidates == NULL ||
+				purple_media_is_initiator(media, sid, name))
+			return;
+
+		fs_stream_set_remote_candidates(stream->stream,
+				stream->remote_candidates, &err);
+
+		if (err == NULL)
+			return;
+
+		purple_debug_error("backend-fs2", "Error adding "
+				"remote candidates: %s\n",
+				err->message);
+		g_error_free(err);
+	} else if (local == TRUE && (type == PURPLE_MEDIA_INFO_MUTE ||
+			type == PURPLE_MEDIA_INFO_UNMUTE)) {
+		PurpleMediaBackendFs2Private *priv =
+				PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(self);
+		gboolean active = (type == PURPLE_MEDIA_INFO_MUTE);
+		GList *sessions;
+
+		if (sid == NULL)
+			sessions = g_hash_table_get_values(priv->sessions);
+		else
+			sessions = g_list_prepend(NULL,
+					get_session(self, sid));
+
+		purple_debug_info("media", "Turning mute %s\n",
+				active ? "on" : "off");
+
+		for (; sessions; sessions = g_list_delete_link(
+				sessions, sessions)) {
+			PurpleMediaBackendFs2Session *session =
+					sessions->data;
+
+			if (session->type & PURPLE_MEDIA_SEND_AUDIO) {
+				gchar *name = g_strdup_printf("volume_%s",
+						session->id);
+				GstElement *volume = gst_bin_get_by_name(
+						GST_BIN(priv->confbin), name);
+				g_free(name);
+				g_object_set(volume, "mute", active, NULL);
+			}
+		}
+	} else if (local == TRUE && (type == PURPLE_MEDIA_INFO_HOLD ||
+			type == PURPLE_MEDIA_INFO_UNHOLD)) {
+		gboolean active = (type == PURPLE_MEDIA_INFO_HOLD);
+		GList *streams = get_streams(self, sid, name);
+		for (; streams; streams =
+				g_list_delete_link(streams, streams)) {
+			PurpleMediaBackendFs2Stream *stream = streams->data;
+			if (stream->session->type & PURPLE_MEDIA_SEND_AUDIO) {
+				g_object_set(stream->stream, "direction",
+						session_type_to_fs_stream_direction(
+						stream->session->type & ((active) ?
+						~PURPLE_MEDIA_SEND_AUDIO :
+						PURPLE_MEDIA_AUDIO)), NULL);
+			}
+		}
+	} else if (local == TRUE && (type == PURPLE_MEDIA_INFO_PAUSE ||
+			type == PURPLE_MEDIA_INFO_UNPAUSE)) {
+		gboolean active = (type == PURPLE_MEDIA_INFO_PAUSE);
+		GList *streams = get_streams(self, sid, name);
+		for (; streams; streams =
+				g_list_delete_link(streams, streams)) {
+			PurpleMediaBackendFs2Stream *stream = streams->data;
+			if (stream->session->type & PURPLE_MEDIA_SEND_VIDEO) {
+				g_object_set(stream->stream, "direction",
+						session_type_to_fs_stream_direction(
+						stream->session->type & ((active) ?
+						~PURPLE_MEDIA_SEND_VIDEO :
+						PURPLE_MEDIA_VIDEO)), NULL);
+			}
+		}
+	}
+}
+
+static gboolean
+init_conference(PurpleMediaBackendFs2 *self)
+{
+	PurpleMediaBackendFs2Private *priv =
+			PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(self);
+	GstElement *pipeline;
+	GstBus *bus;
+	gchar *name;
+
+	priv->conference = FS_CONFERENCE(
+			gst_element_factory_make(priv->conference_type, NULL));
+
+	if (priv->conference == NULL) {
+		purple_debug_error("backend-fs2", "Conference == NULL\n");
+		return FALSE;
+	}
+
+	if (purple_account_get_silence_suppression(
+				purple_media_get_account(priv->media)))
+		priv->silence_threshold = purple_prefs_get_int(
+				"/purple/media/audio/silence_threshold") / 100.0;
+	else
+		priv->silence_threshold = 0;
+
+	pipeline = purple_media_manager_get_pipeline(
+			purple_media_get_manager(priv->media));
+
+	if (pipeline == NULL) {
+		purple_debug_error("backend-fs2",
+				"Couldn't retrieve pipeline.\n");
+		return FALSE;
+	}
+
+	name = g_strdup_printf("conf_%p", priv->conference);
+	priv->confbin = gst_bin_new(name);
+	if (priv->confbin == NULL) {
+		purple_debug_error("backend-fs2",
+				"Couldn't create confbin.\n");
+		return FALSE;
+	}
+
+	g_free(name);
+
+	bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
+	if (bus == NULL) {
+		purple_debug_error("backend-fs2",
+				"Couldn't get the pipeline's bus.\n");
+		return FALSE;
+	}
+
+	g_signal_connect(G_OBJECT(bus), "message",
+			G_CALLBACK(gst_bus_cb), self);
+	gst_object_unref(bus);
+
+	if (!gst_bin_add(GST_BIN(pipeline),
+			GST_ELEMENT(priv->confbin))) {
+		purple_debug_error("backend-fs2", "Couldn't add confbin "
+				"element to the pipeline\n");
+		return FALSE;
+	}
+
+	if (!gst_bin_add(GST_BIN(priv->confbin),
+			GST_ELEMENT(priv->conference))) {
+		purple_debug_error("backend-fs2", "Couldn't add conference "
+				"element to the confbin\n");
+		return FALSE;
+	}
+
+	if (gst_element_set_state(GST_ELEMENT(priv->confbin),
+			GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) {
+		purple_debug_error("backend-fs2",
+				"Failed to start conference.\n");
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+static void
+gst_element_added_cb(FsElementAddedNotifier *self,
+		GstBin *bin, GstElement *element, gpointer user_data)
+{
+	/*
+	 * Hack to make H264 work with Gmail video.
+	 */
+	if (!strncmp(GST_ELEMENT_NAME(element), "x264", 4)) {
+		g_object_set(GST_OBJECT(element), "cabac", FALSE, NULL);
+	}
+}
+
+static gboolean
+create_src(PurpleMediaBackendFs2 *self, const gchar *sess_id,
+		PurpleMediaSessionType type)
+{
+	PurpleMediaBackendFs2Private *priv =
+			PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(self);
+	PurpleMediaBackendFs2Session *session;
+	PurpleMediaSessionType session_type;
+	FsMediaType media_type = session_type_to_fs_media_type(type);
+	FsStreamDirection type_direction =
+			session_type_to_fs_stream_direction(type);
+	GstElement *src;
+	GstPad *sinkpad, *srcpad;
+	GstPad *ghost = NULL;
+
+	if ((type_direction & FS_DIRECTION_SEND) == 0)
+		return TRUE;
+
+	session_type = session_type_from_fs(
+			media_type, FS_DIRECTION_SEND);
+	src = purple_media_manager_get_element(
+			purple_media_get_manager(priv->media),
+			session_type, priv->media, sess_id, NULL);
+
+	if (!GST_IS_ELEMENT(src)) {
+		purple_debug_error("backend-fs2",
+				"Error creating src for session %s\n",
+				sess_id);
+		return FALSE;
+	}
+
+	session = get_session(self, sess_id);
+
+	if (session == NULL) {
+		purple_debug_warning("backend-fs2",
+				"purple_media_set_src: trying to set"
+				" src on non-existent session\n");
+		return FALSE;
+	}
+
+	if (session->src)
+		gst_object_unref(session->src);
+
+	session->src = src;
+	gst_element_set_locked_state(session->src, TRUE);
+
+	session->tee = gst_element_factory_make("tee", NULL);
+	gst_bin_add(GST_BIN(priv->confbin), session->tee);
+
+	/* This supposedly isn't necessary, but it silences some warnings */
+	if (GST_ELEMENT_PARENT(priv->confbin)
+			== GST_ELEMENT_PARENT(session->src)) {
+		GstPad *pad = gst_element_get_static_pad(session->tee, "sink");
+		ghost = gst_ghost_pad_new(NULL, pad);
+		gst_object_unref(pad);
+		gst_pad_set_active(ghost, TRUE);
+		gst_element_add_pad(priv->confbin, ghost);
+	}
+
+	gst_element_set_state(session->tee, GST_STATE_PLAYING);
+	gst_element_link(session->src, priv->confbin);
+	if (ghost)
+		session->srcpad = gst_pad_get_peer(ghost);
+
+	g_object_get(session->session, "sink-pad", &sinkpad, NULL);
+	if (session->type & PURPLE_MEDIA_SEND_AUDIO) {
+		gchar *name = g_strdup_printf("volume_%s", session->id);
+		GstElement *level;
+		GstElement *volume = gst_element_factory_make("volume", name);
+		double input_volume = purple_prefs_get_int(
+				"/purple/media/audio/volume/input")/10.0;
+		g_free(name);
+		name = g_strdup_printf("sendlevel_%s", session->id);
+		level = gst_element_factory_make("level", name);
+		g_free(name);
+		session->srcvalve = gst_element_factory_make("valve", NULL);
+		gst_bin_add(GST_BIN(priv->confbin), volume);
+		gst_bin_add(GST_BIN(priv->confbin), level);
+		gst_bin_add(GST_BIN(priv->confbin), session->srcvalve);
+		gst_element_set_state(level, GST_STATE_PLAYING);
+		gst_element_set_state(volume, GST_STATE_PLAYING);
+		gst_element_set_state(session->srcvalve, GST_STATE_PLAYING);
+		gst_element_link(level, session->srcvalve);
+		gst_element_link(volume, level);
+		gst_element_link(session->tee, volume);
+		srcpad = gst_element_get_static_pad(session->srcvalve, "src");
+		g_object_set(volume, "volume", input_volume, NULL);
+	} else {
+		srcpad = gst_element_get_request_pad(session->tee, "src%d");
+	}
+
+	purple_debug_info("backend-fs2", "connecting pad: %s\n",
+			  gst_pad_link(srcpad, sinkpad) == GST_PAD_LINK_OK
+			  ? "success" : "failure");
+	gst_element_set_locked_state(session->src, FALSE);
+	gst_object_unref(session->src);
+	gst_object_unref(sinkpad);
+
+	gst_element_set_state(session->src, GST_STATE_PLAYING);
+
+	purple_media_manager_create_output_window(purple_media_get_manager(
+			priv->media), priv->media, sess_id, NULL);
+
+	return TRUE;
+}
+
+static gboolean
+create_session(PurpleMediaBackendFs2 *self, const gchar *sess_id,
+		PurpleMediaSessionType type, gboolean initiator,
+		const gchar *transmitter)
+{
+	PurpleMediaBackendFs2Private *priv =
+			PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(self);
+	PurpleMediaBackendFs2Session *session;
+	GError *err = NULL;
+	GList *codec_conf = NULL, *iter = NULL;
+	gchar *filename = NULL;
+	gboolean is_nice = !strcmp(transmitter, "nice");
+
+	session = g_new0(PurpleMediaBackendFs2Session, 1);
+
+	session->session = fs_conference_new_session(priv->conference,
+			session_type_to_fs_media_type(type), &err);
+
+	if (err != NULL) {
+		purple_media_error(priv->media,
+				_("Error creating session: %s"),
+				err->message);
+		g_error_free(err);
+		g_free(session);
+		return FALSE;
+	}
+
+	filename = g_build_filename(purple_user_dir(), "fs-codec.conf", NULL);
+	codec_conf = fs_codec_list_from_keyfile(filename, &err);
+	g_free(filename);
+
+	if (err != NULL) {
+		if (err->code == 4)
+			purple_debug_info("backend-fs2", "Couldn't read "
+					"fs-codec.conf: %s\n",
+					err->message);
+		else
+			purple_debug_error("backend-fs2", "Error reading "
+					"fs-codec.conf: %s\n",
+					err->message);
+		g_error_free(err);
+	}
+
+	/*
+	 * Add SPEEX if the configuration file doesn't exist or
+	 * there isn't a speex entry.
+	 */
+	for (iter = codec_conf; iter; iter = g_list_next(iter)) {
+		FsCodec *codec = iter->data;
+		if (!g_ascii_strcasecmp(codec->encoding_name, "speex"))
+			break;
+	}
+
+	if (iter == NULL) {
+		codec_conf = g_list_prepend(codec_conf,
+				fs_codec_new(FS_CODEC_ID_ANY,
+				"SPEEX", FS_MEDIA_TYPE_AUDIO, 8000));
+		codec_conf = g_list_prepend(codec_conf,
+				fs_codec_new(FS_CODEC_ID_ANY,
+				"SPEEX", FS_MEDIA_TYPE_AUDIO, 16000));
+	}
+
+	fs_session_set_codec_preferences(session->session, codec_conf, NULL);
+	fs_codec_list_destroy(codec_conf);
+
+	/*
+	 * Removes a 5-7 second delay before
+	 * receiving the src-pad-added signal.
+	 * Only works for non-multicast FsRtpSessions.
+	 */
+	if (is_nice || !strcmp(transmitter, "rawudp"))
+		g_object_set(G_OBJECT(session->session),
+				"no-rtcp-timeout", 0, NULL);
+
+	/*
+	 * Hack to make x264 work with Gmail video.
+	 */
+	if (is_nice && !strcmp(sess_id, "google-video")) {
+		FsElementAddedNotifier *notifier =
+				fs_element_added_notifier_new();
+		g_signal_connect(G_OBJECT(notifier), "element-added",
+				G_CALLBACK(gst_element_added_cb), NULL);
+		fs_element_added_notifier_add(notifier,
+				GST_BIN(priv->conference));
+	}
+
+	session->id = g_strdup(sess_id);
+	session->backend = self;
+	session->type = type;
+
+	if (!priv->sessions) {
+		purple_debug_info("backend-fs2",
+				"Creating hash table for sessions\n");
+		priv->sessions = g_hash_table_new_full(g_str_hash, g_str_equal,
+		                                       g_free, NULL);
+	}
+
+	g_hash_table_insert(priv->sessions, g_strdup(session->id), session);
+
+	if (!create_src(self, sess_id, type)) {
+		purple_debug_info("backend-fs2", "Error creating the src\n");
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+static void
+free_session(PurpleMediaBackendFs2Session *session)
+{
+	g_free(session->id);
+	g_free(session);
+}
+
+static gboolean
+create_participant(PurpleMediaBackendFs2 *self, const gchar *name)
+{
+	PurpleMediaBackendFs2Private *priv =
+			PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(self);
+	FsParticipant *participant;
+	GError *err = NULL;
+
+	participant = fs_conference_new_participant(
+			priv->conference, name, &err);
+
+	if (err) {
+		purple_debug_error("backend-fs2",
+				"Error creating participant: %s\n",
+				err->message);
+		g_error_free(err);
+		return FALSE;
+	}
+
+	if (!priv->participants) {
+		purple_debug_info("backend-fs2",
+				"Creating hash table for participants\n");
+		priv->participants = g_hash_table_new_full(g_str_hash,
+				g_str_equal, g_free, g_object_unref);
+	}
+
+	g_hash_table_insert(priv->participants, g_strdup(name), participant);
+
+	return TRUE;
+}
+
+static gboolean
+src_pad_added_cb_cb(PurpleMediaBackendFs2Stream *stream)
+{
+	PurpleMediaBackendFs2Private *priv;
+
+	g_return_val_if_fail(stream != NULL, FALSE);
+
+	priv = PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(stream->session->backend);
+	stream->connected_cb_id = 0;
+
+	purple_media_manager_create_output_window(
+			purple_media_get_manager(priv->media), priv->media,
+			stream->session->id, stream->participant);
+
+	g_signal_emit_by_name(priv->media, "state-changed",
+			PURPLE_MEDIA_STATE_CONNECTED,
+			stream->session->id, stream->participant);
+	return FALSE;
+}
+
+static void
+src_pad_added_cb(FsStream *fsstream, GstPad *srcpad,
+		FsCodec *codec, PurpleMediaBackendFs2Stream *stream)
+{
+	PurpleMediaBackendFs2Private *priv;
+	GstPad *sinkpad;
+
+	g_return_if_fail(FS_IS_STREAM(fsstream));
+	g_return_if_fail(stream != NULL);
+
+	priv = PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(stream->session->backend);
+
+	if (stream->src == NULL) {
+		GstElement *sink = NULL;
+
+		if (codec->media_type == FS_MEDIA_TYPE_AUDIO) {
+			double output_volume = purple_prefs_get_int(
+					"/purple/media/audio/volume/output")/10.0;
+			/*
+			 * Should this instead be:
+			 *  audioconvert ! audioresample ! liveadder !
+			 *   audioresample ! audioconvert ! realsink
+			 */
+			stream->queue = gst_element_factory_make("queue", NULL);
+			stream->volume = gst_element_factory_make(
+					"volume", NULL);
+			g_object_set(stream->volume, "volume",
+					output_volume, NULL);
+			stream->level = gst_element_factory_make(
+					"level", NULL);
+			stream->src = gst_element_factory_make(
+					"liveadder", NULL);
+			sink = purple_media_manager_get_element(
+					purple_media_get_manager(priv->media),
+					PURPLE_MEDIA_RECV_AUDIO, priv->media,
+					stream->session->id,
+					stream->participant);
+			gst_bin_add(GST_BIN(priv->confbin), stream->queue);
+			gst_bin_add(GST_BIN(priv->confbin), stream->volume);
+			gst_bin_add(GST_BIN(priv->confbin), stream->level);
+			gst_bin_add(GST_BIN(priv->confbin), sink);
+			gst_element_set_state(sink, GST_STATE_PLAYING);
+			gst_element_set_state(stream->level, GST_STATE_PLAYING);
+			gst_element_set_state(stream->volume, GST_STATE_PLAYING);
+			gst_element_set_state(stream->queue, GST_STATE_PLAYING);
+			gst_element_link(stream->level, sink);
+			gst_element_link(stream->volume, stream->level);
+			gst_element_link(stream->queue, stream->volume);
+			sink = stream->queue;
+		} else if (codec->media_type == FS_MEDIA_TYPE_VIDEO) {
+			stream->src = gst_element_factory_make(
+					"fsfunnel", NULL);
+			sink = gst_element_factory_make(
+					"fakesink", NULL);
+			g_object_set(G_OBJECT(sink), "async", FALSE, NULL);
+			gst_bin_add(GST_BIN(priv->confbin), sink);
+			gst_element_set_state(sink, GST_STATE_PLAYING);
+			stream->fakesink = sink;
+		}
+		stream->tee = gst_element_factory_make("tee", NULL);
+		gst_bin_add_many(GST_BIN(priv->confbin),
+				stream->src, stream->tee, NULL);
+		gst_element_set_state(stream->tee, GST_STATE_PLAYING);
+		gst_element_set_state(stream->src, GST_STATE_PLAYING);
+		gst_element_link_many(stream->src, stream->tee, sink, NULL);
+	}
+
+	sinkpad = gst_element_get_request_pad(stream->src, "sink%d");
+	gst_pad_link(srcpad, sinkpad);
+	gst_object_unref(sinkpad);
+
+	stream->connected_cb_id = purple_timeout_add(0,
+			(GSourceFunc)src_pad_added_cb_cb, stream);
+}
+
+static GValueArray *
+append_relay_info(GValueArray *relay_info, const gchar *ip, gint port,
+	const gchar *username, const gchar *password, const gchar *type)
+{
+	GValue value;
+	GstStructure *turn_setup = gst_structure_new("relay-info",
+				"ip", G_TYPE_STRING, ip,
+				"port", G_TYPE_UINT, port,
+				"username", G_TYPE_STRING, username,
+				"password", G_TYPE_STRING, password,
+	            "relay-type", G_TYPE_STRING, type,
+				NULL);
+
+	if (turn_setup) {
+		memset(&value, 0, sizeof(GValue));
+		g_value_init(&value, GST_TYPE_STRUCTURE);
+		gst_value_set_structure(&value, turn_setup);
+		relay_info = g_value_array_append(relay_info, &value);
+		gst_structure_free(turn_setup);
+	}
+
+	return relay_info;
+}
+
+static gboolean
+create_stream(PurpleMediaBackendFs2 *self,
+		const gchar *sess_id, const gchar *who,
+		PurpleMediaSessionType type, gboolean initiator,
+		const gchar *transmitter,
+		guint num_params, GParameter *params)
+{
+	PurpleMediaBackendFs2Private *priv =
+			PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(self);
+	GError *err = NULL;
+	FsStream *fsstream = NULL;
+	const gchar *stun_ip = purple_network_get_stun_ip();
+	const gchar *turn_ip = purple_network_get_turn_ip();
+	guint _num_params = num_params;
+	GParameter *_params = g_new0(GParameter, num_params + 3);
+	FsStreamDirection type_direction =
+			session_type_to_fs_stream_direction(type);
+	PurpleMediaBackendFs2Session *session;
+	PurpleMediaBackendFs2Stream *stream;
+	FsParticipant *participant;
+	/* check if the prpl has already specified a relay-info
+	  we need to do this to allow them to override when using non-standard
+	  TURN modes, like Google f.ex. */
+	gboolean got_turn_from_prpl = FALSE;
+	int i;
+
+	for (i = 0 ; i < num_params ; i++) {
+		if (purple_strequal(params[i].name, "relay-info")) {
+			got_turn_from_prpl = TRUE;
+			break;
+		}
+	}
+
+	memcpy(_params, params, sizeof(GParameter) * num_params);
+
+	/* set the controlling mode parameter */
+	_params[_num_params].name = "controlling-mode";
+	g_value_init(&_params[_num_params].value, G_TYPE_BOOLEAN);
+	g_value_set_boolean(&_params[_num_params].value, initiator);
+	++_num_params;
+
+	if (stun_ip) {
+		purple_debug_info("backend-fs2",
+			"Setting stun-ip on new stream: %s\n", stun_ip);
+
+		_params[_num_params].name = "stun-ip";
+		g_value_init(&_params[_num_params].value, G_TYPE_STRING);
+		g_value_set_string(&_params[_num_params].value, stun_ip);
+		++_num_params;
+	}
+
+	if (turn_ip && !strcmp("nice", transmitter) && !got_turn_from_prpl) {
+		GValueArray *relay_info = g_value_array_new(0);
+		gint port;
+		const gchar *username =	purple_prefs_get_string(
+				"/purple/network/turn_username");
+		const gchar *password = purple_prefs_get_string(
+				"/purple/network/turn_password");
+
+		/* UDP */
+		port = purple_prefs_get_int("/purple/network/turn_port");
+		if (port > 0) {
+			relay_info = append_relay_info(relay_info, turn_ip, port, username,
+				password, "udp");
+		}
+		
+		/* TCP */
+		port = purple_prefs_get_int("/purple/network/turn_port_tcp");
+		if (port > 0) {
+			relay_info = append_relay_info(relay_info, turn_ip, port, username,
+				password, "tcp");
+		}
+
+		/* TURN over SSL is only supported by libnice for Google's "psuedo" SSL mode
+			at this time */
+
+		purple_debug_info("backend-fs2",
+			"Setting relay-info on new stream\n");
+		_params[_num_params].name = "relay-info";
+		g_value_init(&_params[_num_params].value,
+			G_TYPE_VALUE_ARRAY);
+		g_value_set_boxed(&_params[_num_params].value,
+			relay_info);
+		g_value_array_free(relay_info);
+		_num_params++;
+	}
+
+	session = get_session(self, sess_id);
+
+	if (session == NULL) {
+		purple_debug_error("backend-fs2",
+				"Couldn't find session to create stream.\n");
+		return FALSE;
+	}
+
+	participant = get_participant(self, who);
+
+	if (participant == NULL) {
+		purple_debug_error("backend-fs2", "Couldn't find "
+				"participant to create stream.\n");
+		return FALSE;
+	}
+
+	fsstream = fs_session_new_stream(session->session, participant,
+			initiator == TRUE ? type_direction :
+			(type_direction & FS_DIRECTION_RECV), transmitter,
+			_num_params, _params, &err);
+	g_free(_params);
+
+	if (fsstream == NULL) {
+		if (err) {
+			purple_debug_error("backend-fs2",
+					"Error creating stream: %s\n",
+					err && err->message ?
+					err->message : "NULL");
+			g_error_free(err);
+		} else
+			purple_debug_error("backend-fs2",
+					"Error creating stream\n");
+		return FALSE;
+	}
+
+	stream = g_new0(PurpleMediaBackendFs2Stream, 1);
+	stream->participant = g_strdup(who);
+	stream->session = session;
+	stream->stream = fsstream;
+
+	priv->streams =	g_list_append(priv->streams, stream);
+
+	g_signal_connect(G_OBJECT(fsstream), "src-pad-added",
+			G_CALLBACK(src_pad_added_cb), stream);
+
+	return TRUE;
+}
+
+static void
+free_stream(PurpleMediaBackendFs2Stream *stream)
+{
+	/* Remove the connected_cb timeout */
+	if (stream->connected_cb_id != 0)
+		purple_timeout_remove(stream->connected_cb_id);
+
+	g_free(stream->participant);
+
+	if (stream->local_candidates)
+		fs_candidate_list_destroy(stream->local_candidates);
+
+	if (stream->remote_candidates)
+		fs_candidate_list_destroy(stream->remote_candidates);
+
+	g_free(stream);
+}
+
+static gboolean
+purple_media_backend_fs2_add_stream(PurpleMediaBackend *self,
+		const gchar *sess_id, const gchar *who,
+		PurpleMediaSessionType type, gboolean initiator,
+		const gchar *transmitter,
+		guint num_params, GParameter *params)
+{
+	PurpleMediaBackendFs2 *backend = PURPLE_MEDIA_BACKEND_FS2(self);
+	PurpleMediaBackendFs2Private *priv =
+			PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(backend);
+	PurpleMediaBackendFs2Stream *stream;
+
+	if (priv->conference == NULL && !init_conference(backend)) {
+		purple_debug_error("backend-fs2",
+				"Error initializing the conference.\n");
+		return FALSE;
+	}
+
+	if (get_session(backend, sess_id) == NULL &&
+			!create_session(backend, sess_id, type,
+			initiator, transmitter)) {
+		purple_debug_error("backend-fs2",
+				"Error creating the session.\n");
+		return FALSE;
+	}
+
+	if (get_participant(backend, who) == NULL &&
+			!create_participant(backend, who)) {
+		purple_debug_error("backend-fs2",
+				"Error creating the participant.\n");
+		return FALSE;
+	}
+
+	stream = get_stream(backend, sess_id, who);
+
+	if (stream != NULL) {
+		FsStreamDirection type_direction =
+				session_type_to_fs_stream_direction(type);
+
+		if (session_type_to_fs_stream_direction(
+				stream->session->type) != type_direction) {
+			/* change direction */
+			g_object_set(stream->stream, "direction",
+					type_direction, NULL);
+		}
+	} else if (!create_stream(backend, sess_id, who, type,
+			initiator, transmitter, num_params, params)) {
+		purple_debug_error("backend-fs2",
+				"Error creating the stream.\n");
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+static void
+purple_media_backend_fs2_add_remote_candidates(PurpleMediaBackend *self,
+		const gchar *sess_id, const gchar *participant,
+		GList *remote_candidates)
+{
+	PurpleMediaBackendFs2Private *priv;
+	PurpleMediaBackendFs2Stream *stream;
+	GError *err = NULL;
+
+	g_return_if_fail(PURPLE_IS_MEDIA_BACKEND_FS2(self));
+
+	priv = PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(self);
+	stream = get_stream(PURPLE_MEDIA_BACKEND_FS2(self),
+			sess_id, participant);
+
+	if (stream == NULL) {
+		purple_debug_error("backend-fs2",
+				"purple_media_add_remote_candidates: "
+				"couldn't find stream %s %s.\n",
+				sess_id ? sess_id : "(null)",
+				participant ? participant : "(null)");
+		return;
+	}
+
+	stream->remote_candidates = g_list_concat(stream->remote_candidates,
+			candidate_list_to_fs(remote_candidates));
+
+	if (purple_media_is_initiator(priv->media, sess_id, participant) ||
+			purple_media_accepted(
+			priv->media, sess_id, participant)) {
+		fs_stream_set_remote_candidates(stream->stream,
+				stream->remote_candidates, &err);
+
+		if (err) {
+			purple_debug_error("backend-fs2", "Error adding remote"
+					" candidates: %s\n", err->message);
+			g_error_free(err);
+		}
+	}
+}
+
+static gboolean
+purple_media_backend_fs2_codecs_ready(PurpleMediaBackend *self,
+		const gchar *sess_id)
+{
+	PurpleMediaBackendFs2Private *priv;
+	gboolean ret = FALSE;
+
+	g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND_FS2(self), FALSE);
+
+	priv = PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(self);
+
+	if (sess_id != NULL) {
+		PurpleMediaBackendFs2Session *session = get_session(
+				PURPLE_MEDIA_BACKEND_FS2(self), sess_id);
+
+		if (session == NULL)
+			return FALSE;
+
+		if (session->type & (PURPLE_MEDIA_SEND_AUDIO |
+				PURPLE_MEDIA_SEND_VIDEO))
+			g_object_get(session->session,
+					"codecs-ready", &ret, NULL);
+		else
+			ret = TRUE;
+	} else {
+		GList *values = g_hash_table_get_values(priv->sessions);
+
+		for (; values; values = g_list_delete_link(values, values)) {
+			PurpleMediaBackendFs2Session *session = values->data;
+			if (session->type & (PURPLE_MEDIA_SEND_AUDIO |
+					PURPLE_MEDIA_SEND_VIDEO))
+				g_object_get(session->session,
+						"codecs-ready", &ret, NULL);
+			else
+				ret = TRUE;
+
+			if (ret == FALSE)
+				break;
+		}
+
+		if (values != NULL)
+			g_list_free(values);
+	}
+
+	return ret;
+}
+
+static GList *
+purple_media_backend_fs2_get_codecs(PurpleMediaBackend *self,
+		const gchar *sess_id)
+{
+	PurpleMediaBackendFs2Session *session;
+	GList *fscodecs;
+	GList *codecs;
+
+	g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND_FS2(self), NULL);
+
+	session = get_session(PURPLE_MEDIA_BACKEND_FS2(self), sess_id);
+
+	if (session == NULL)
+		return NULL;
+
+	g_object_get(G_OBJECT(session->session),
+		     "codecs", &fscodecs, NULL);
+	codecs = codec_list_from_fs(fscodecs);
+	fs_codec_list_destroy(fscodecs);
+
+	return codecs;
+}
+
+static GList *
+purple_media_backend_fs2_get_local_candidates(PurpleMediaBackend *self,
+		const gchar *sess_id, const gchar *participant)
+{
+	PurpleMediaBackendFs2Stream *stream;
+	GList *candidates = NULL;
+
+	g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND_FS2(self), NULL);
+
+	stream = get_stream(PURPLE_MEDIA_BACKEND_FS2(self),
+			sess_id, participant);
+
+	if (stream != NULL)
+		candidates = candidate_list_from_fs(
+				stream->local_candidates);
+	return candidates;
+}
+
+static gboolean
+purple_media_backend_fs2_set_remote_codecs(PurpleMediaBackend *self,
+		const gchar *sess_id, const gchar *participant,
+		GList *codecs)
+{
+	PurpleMediaBackendFs2Stream *stream;
+	GList *fscodecs;
+	GError *err = NULL;
+
+	g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND_FS2(self), FALSE);
+	stream = get_stream(PURPLE_MEDIA_BACKEND_FS2(self),
+			sess_id, participant);
+
+	if (stream == NULL)
+		return FALSE;
+
+	fscodecs = codec_list_to_fs(codecs);
+	fs_stream_set_remote_codecs(stream->stream, fscodecs, &err);
+	fs_codec_list_destroy(fscodecs);
+
+	if (err) {
+		purple_debug_error("backend-fs2",
+				"Error setting remote codecs: %s\n",
+				err->message);
+		g_error_free(err);
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+static gboolean
+purple_media_backend_fs2_set_send_codec(PurpleMediaBackend *self,
+		const gchar *sess_id, PurpleMediaCodec *codec)
+{
+	PurpleMediaBackendFs2Session *session;
+	FsCodec *fscodec;
+	GError *err = NULL;
+
+	g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND_FS2(self), FALSE);
+
+	session = get_session(PURPLE_MEDIA_BACKEND_FS2(self), sess_id);
+
+	if (session == NULL)
+		return FALSE;
+
+	fscodec = codec_to_fs(codec);
+	fs_session_set_send_codec(session->session, fscodec, &err);
+	fs_codec_destroy(fscodec);
+
+	if (err) {
+		purple_debug_error("media", "Error setting send codec\n");
+		g_error_free(err);
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+static void
+purple_media_backend_fs2_set_params(PurpleMediaBackend *self,
+		guint num_params, GParameter *params)
+{
+	PurpleMediaBackendFs2Private *priv;
+	const gchar **supported = purple_media_backend_fs2_get_available_params();
+	const gchar **p;
+	guint i;
+
+	g_return_if_fail(PURPLE_IS_MEDIA_BACKEND_FS2(self));
+
+	priv = PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(self);
+
+	if (priv->conference == NULL &&
+		!init_conference(PURPLE_MEDIA_BACKEND_FS2(self))) {
+		purple_debug_error("backend-fs2",
+				"Error initializing the conference.\n");
+		return;
+	}
+
+	for (i = 0; i != num_params; ++i) {
+		for (p = supported; *p != NULL; ++p) {
+			if (!strcmp(params[i].name, *p)) {
+				g_object_set(priv->conference,
+						params[i].name, g_value_get_string(&params[i].value),
+						NULL);
+				break;
+			}
+		}
+	}
+}
+
+static const gchar **
+purple_media_backend_fs2_get_available_params(void)
+{
+	static const gchar *supported_params[] = {
+		"sdes-cname", "sdes-email", "sdes-location", "sdes-name", "sdes-note",
+		"sdes-phone", "sdes-tool", NULL
+	};
+
+	return supported_params;
+}
+#else
+GType
+purple_media_backend_fs2_get_type(void)
+{
+	return G_TYPE_NONE;
+}
+#endif /* USE_VV */
+
+#ifdef USE_GSTREAMER
+GstElement *
+purple_media_backend_fs2_get_src(PurpleMediaBackendFs2 *self,
+		const gchar *sess_id)
+{
+#ifdef USE_VV
+	PurpleMediaBackendFs2Session *session = get_session(self, sess_id);
+	return session != NULL ? session->src : NULL;
+#else
+	return NULL;
+#endif
+}
+
+GstElement *
+purple_media_backend_fs2_get_tee(PurpleMediaBackendFs2 *self,
+		const gchar *sess_id, const gchar *who)
+{
+#ifdef USE_VV
+	if (sess_id != NULL && who == NULL) {
+		PurpleMediaBackendFs2Session *session =
+				get_session(self, sess_id);
+		return (session != NULL) ? session->tee : NULL;
+	} else if (sess_id != NULL && who != NULL) {
+		PurpleMediaBackendFs2Stream *stream =
+				get_stream(self, sess_id, who);
+		return (stream != NULL) ? stream->tee : NULL;
+	}
+
+#endif /* USE_VV */
+	g_return_val_if_reached(NULL);
+}
+
+void
+purple_media_backend_fs2_set_input_volume(PurpleMediaBackendFs2 *self,
+		const gchar *sess_id, double level)
+{
+#ifdef USE_VV
+	PurpleMediaBackendFs2Private *priv;
+	GList *sessions;
+
+	g_return_if_fail(PURPLE_IS_MEDIA_BACKEND_FS2(self));
+
+	priv = PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(self);
+
+	purple_prefs_set_int("/purple/media/audio/volume/input", level);
+
+	if (sess_id == NULL)
+		sessions = g_hash_table_get_values(priv->sessions);
+	else
+		sessions = g_list_append(NULL, get_session(self, sess_id));
+
+	for (; sessions; sessions = g_list_delete_link(sessions, sessions)) {
+		PurpleMediaBackendFs2Session *session = sessions->data;
+
+		if (session->type & PURPLE_MEDIA_SEND_AUDIO) {
+			gchar *name = g_strdup_printf("volume_%s",
+					session->id);
+			GstElement *volume = gst_bin_get_by_name(
+					GST_BIN(priv->confbin), name);
+			g_free(name);
+			g_object_set(volume, "volume", level/10.0, NULL);
+		}
+	}
+#endif /* USE_VV */
+}
+
+void
+purple_media_backend_fs2_set_output_volume(PurpleMediaBackendFs2 *self,
+		const gchar *sess_id, const gchar *who, double level)
+{
+#ifdef USE_VV
+	GList *streams;
+
+	g_return_if_fail(PURPLE_IS_MEDIA_BACKEND_FS2(self));
+
+	purple_prefs_set_int("/purple/media/audio/volume/output", level);
+
+	streams = get_streams(self, sess_id, who);
+
+	for (; streams; streams = g_list_delete_link(streams, streams)) {
+		PurpleMediaBackendFs2Stream *stream = streams->data;
+
+		if (stream->session->type & PURPLE_MEDIA_RECV_AUDIO
+				&& GST_IS_ELEMENT(stream->volume)) {
+			g_object_set(stream->volume, "volume",
+					level/10.0, NULL);
+		}
+	}
+#endif /* USE_VV */
+}
+#endif /* USE_GSTREAMER */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/media/backend-fs2.h	Sat Aug 06 03:45:56 2011 +0000
@@ -0,0 +1,79 @@
+/**
+ * @file backend-fs2.h Farsight 2 backend for media API
+ * @ingroup core
+ */
+
+/* purple
+ *
+ * Purple is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * 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
+ */
+
+/*
+ * This file should not yet be part of libpurple's API.
+ * It should remain internal only for now.
+ */
+
+#ifndef _MEDIA_BACKEND_FS2_H_
+#define _MEDIA_BACKEND_FS2_H_
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define PURPLE_TYPE_MEDIA_BACKEND_FS2            (purple_media_backend_fs2_get_type())
+#define PURPLE_IS_MEDIA_BACKEND_FS2(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_MEDIA_BACKEND_FS2))
+#define PURPLE_IS_MEDIA_BACKEND_FS2_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PURPLE_TYPE_MEDIA_BACKEND_FS2))
+#define PURPLE_MEDIA_BACKEND_FS2(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_MEDIA_BACKEND_FS2, PurpleMediaBackendFs2))
+#define PURPLE_MEDIA_BACKEND_FS2_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_MEDIA_BACKEND_FS2, PurpleMediaBackendFs2))
+#define PURPLE_MEDIA_BACKEND_FS2_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_MEDIA_BACKEND_FS2, PurpleMediaBackendFs2))
+
+/** An opaque structure representing the Farsight 2 media backend. */
+typedef struct _PurpleMediaBackendFs2 PurpleMediaBackendFs2;
+
+/**
+ * Gets the type of the Farsight 2 media backend object.
+ *
+ * @return The Farsight 2 media backend's GType
+ *
+ * @since 2.7.0
+ */
+GType purple_media_backend_fs2_get_type(void);
+
+#ifdef USE_GSTREAMER
+/*
+ * Temporary function in order to be able to test while
+ * integrating with PurpleMedia
+ */
+#include <gst/gst.h>
+GstElement *purple_media_backend_fs2_get_src(
+		PurpleMediaBackendFs2 *self,
+		const gchar *sess_id);
+GstElement *purple_media_backend_fs2_get_tee(
+		PurpleMediaBackendFs2 *self,
+		const gchar *sess_id, const gchar *who);
+void purple_media_backend_fs2_set_input_volume(PurpleMediaBackendFs2 *self,
+		const gchar *sess_id, double level);
+void purple_media_backend_fs2_set_output_volume(PurpleMediaBackendFs2 *self,
+		const gchar *sess_id, const gchar *who, double level);
+/* end tmp */
+#endif /* USE_GSTREAMER */
+
+G_END_DECLS
+
+#endif /* _MEDIA_BACKEND_FS2_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/media/backend-iface.c	Sat Aug 06 03:45:56 2011 +0000
@@ -0,0 +1,211 @@
+/**
+ * @file backend-iface.c Interface for media backend
+ * @ingroup core
+ */
+
+/* purple
+ *
+ * Purple is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * 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 "backend-iface.h"
+
+#include "marshallers.h"
+
+enum {
+	S_ERROR,
+	CANDIDATES_PREPARED,
+	CODECS_CHANGED,
+	NEW_CANDIDATE,
+	ACTIVE_CANDIDATE_PAIR,
+	LAST_SIGNAL
+};
+
+static guint purple_media_backend_signals[LAST_SIGNAL] = {0};
+
+static void
+purple_media_backend_base_init(gpointer iface)
+{
+	static gboolean is_initialized = FALSE;
+
+	if (is_initialized)
+		return;
+
+	g_object_interface_install_property(iface,
+			g_param_spec_string("conference-type",
+			"Conference Type",
+			"The type of conference that this backend "
+			"has been created to provide.",
+			NULL,
+			G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
+	g_object_interface_install_property(iface,
+			g_param_spec_object("media",
+			"Purple Media",
+			"The media object that this backend is bound to.",
+			PURPLE_TYPE_MEDIA,
+			G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
+
+	purple_media_backend_signals[S_ERROR] =
+			g_signal_new("error", G_TYPE_FROM_CLASS(iface),
+			G_SIGNAL_RUN_LAST, 0, NULL, NULL,
+			g_cclosure_marshal_VOID__STRING,
+			G_TYPE_NONE, 1, G_TYPE_STRING);
+	purple_media_backend_signals[CANDIDATES_PREPARED] =
+			g_signal_new("candidates-prepared",
+			G_TYPE_FROM_CLASS(iface),
+			G_SIGNAL_RUN_LAST, 0, NULL, NULL,
+			purple_smarshal_VOID__STRING_STRING,
+			G_TYPE_NONE, 2, G_TYPE_STRING,
+			G_TYPE_STRING);
+	purple_media_backend_signals[CODECS_CHANGED] =
+			g_signal_new("codecs-changed",
+			G_TYPE_FROM_CLASS(iface),
+			G_SIGNAL_RUN_LAST, 0, NULL, NULL,
+			g_cclosure_marshal_VOID__STRING,
+			G_TYPE_NONE, 1, G_TYPE_STRING);
+	purple_media_backend_signals[NEW_CANDIDATE] =
+			g_signal_new("new-candidate",
+			G_TYPE_FROM_CLASS(iface),
+			G_SIGNAL_RUN_LAST, 0, NULL, NULL,
+			purple_smarshal_VOID__POINTER_POINTER_OBJECT,
+			G_TYPE_NONE, 3, G_TYPE_POINTER,
+			G_TYPE_POINTER, PURPLE_TYPE_MEDIA_CANDIDATE);
+	purple_media_backend_signals[ACTIVE_CANDIDATE_PAIR] =
+			g_signal_new("active-candidate-pair",
+			G_TYPE_FROM_CLASS(iface),
+			G_SIGNAL_RUN_LAST, 0, NULL, NULL,
+			purple_smarshal_VOID__STRING_STRING_OBJECT_OBJECT,
+			G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_STRING,
+			PURPLE_TYPE_MEDIA_CANDIDATE,
+			PURPLE_TYPE_MEDIA_CANDIDATE);
+
+	is_initialized = TRUE;
+}
+
+GType
+purple_media_backend_get_type(void)
+{
+	static GType iface_type = 0;
+	if (iface_type == 0) {
+		static const GTypeInfo info = {
+			sizeof(PurpleMediaBackendIface),
+			purple_media_backend_base_init,
+			NULL,
+			NULL,
+			NULL,
+			NULL,
+			0,
+			0,
+			NULL,
+			NULL
+		};
+
+		iface_type = g_type_register_static (G_TYPE_INTERFACE,
+				"PurpleMediaBackend", &info, 0);
+	}
+
+	return iface_type;
+}
+
+gboolean
+purple_media_backend_add_stream(PurpleMediaBackend *self,
+		const gchar *sess_id, const gchar *who,
+		PurpleMediaSessionType type, gboolean initiator,
+		const gchar *transmitter,
+		guint num_params, GParameter *params)
+{
+	g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND(self), FALSE);
+	return PURPLE_MEDIA_BACKEND_GET_INTERFACE(self)->add_stream(self,
+			sess_id, who, type, initiator, transmitter,
+			num_params, params);
+}
+
+void
+purple_media_backend_add_remote_candidates(PurpleMediaBackend *self,
+		const gchar *sess_id, const gchar *participant,
+		GList *remote_candidates)
+{
+	g_return_if_fail(PURPLE_IS_MEDIA_BACKEND(self));
+	PURPLE_MEDIA_BACKEND_GET_INTERFACE(self)->add_remote_candidates(self,
+			sess_id, participant, remote_candidates);
+}
+
+gboolean
+purple_media_backend_codecs_ready(PurpleMediaBackend *self,
+		const gchar *sess_id)
+{
+	g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND(self), FALSE);
+	return PURPLE_MEDIA_BACKEND_GET_INTERFACE(self)->codecs_ready(self,
+			sess_id);
+}
+
+GList *
+purple_media_backend_get_codecs(PurpleMediaBackend *self,
+		const gchar *sess_id)
+{
+	g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND(self), NULL);
+	return PURPLE_MEDIA_BACKEND_GET_INTERFACE(self)->get_codecs(self,
+			sess_id);
+}
+
+GList *
+purple_media_backend_get_local_candidates(PurpleMediaBackend *self,
+		const gchar *sess_id, const gchar *participant)
+{
+	g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND(self), NULL);
+	return PURPLE_MEDIA_BACKEND_GET_INTERFACE(self)->
+			get_local_candidates(self,
+			sess_id, participant);
+}
+
+gboolean
+purple_media_backend_set_remote_codecs(PurpleMediaBackend *self,
+		const gchar *sess_id, const gchar *participant,
+		GList *codecs)
+{
+	g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND(self), FALSE);
+	return PURPLE_MEDIA_BACKEND_GET_INTERFACE(self)->set_remote_codecs(
+			self, sess_id, participant, codecs);
+}
+
+gboolean
+purple_media_backend_set_send_codec(PurpleMediaBackend *self,
+		const gchar *sess_id, PurpleMediaCodec *codec)
+{
+	g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND(self), FALSE);
+	return PURPLE_MEDIA_BACKEND_GET_INTERFACE(self)->set_send_codec(self,
+			sess_id, codec);
+}
+
+void
+purple_media_backend_set_params(PurpleMediaBackend *self,
+		guint num_params, GParameter *params)
+{
+	g_return_if_fail(PURPLE_IS_MEDIA_BACKEND(self));
+	PURPLE_MEDIA_BACKEND_GET_INTERFACE(self)->set_params(self, num_params, params);
+}
+
+const gchar **
+purple_media_backend_get_available_params(PurpleMediaBackend *self)
+{
+	static const gchar *NULL_ARRAY[] = { NULL };
+
+	g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND(self), NULL_ARRAY);
+	return PURPLE_MEDIA_BACKEND_GET_INTERFACE(self)->get_available_params();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/media/backend-iface.h	Sat Aug 06 03:45:56 2011 +0000
@@ -0,0 +1,224 @@
+/**
+ * @file backend-iface.h Interface for media backends
+ * @ingroup core
+ */
+
+/* purple
+ *
+ * Purple is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * 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
+ */
+
+#ifndef _MEDIA_BACKEND_IFACE_H_
+#define _MEDIA_BACKEND_IFACE_H_
+
+#include "codec.h"
+#include "enum-types.h"
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define PURPLE_TYPE_MEDIA_BACKEND		(purple_media_backend_get_type())
+#define PURPLE_IS_MEDIA_BACKEND(obj)		(G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_MEDIA_BACKEND))
+#define PURPLE_MEDIA_BACKEND(obj)		(G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_MEDIA_BACKEND, PurpleMediaBackend))
+#define PURPLE_MEDIA_BACKEND_GET_INTERFACE(inst)(G_TYPE_INSTANCE_GET_INTERFACE((inst), PURPLE_TYPE_MEDIA_BACKEND, PurpleMediaBackendIface))
+
+/** A placeholder to represent any media backend */
+typedef struct _PurpleMediaBackend PurpleMediaBackend;
+/** A structure to derive media backends from. */
+typedef struct _PurpleMediaBackendIface PurpleMediaBackendIface;
+
+struct _PurpleMediaBackendIface
+{
+	GTypeInterface parent_iface; /**< The parent iface class */
+
+	/** Implementable functions called with purple_media_backend_* */
+	gboolean (*add_stream) (PurpleMediaBackend *self,
+		const gchar *sess_id, const gchar *who,
+		PurpleMediaSessionType type, gboolean initiator,
+		const gchar *transmitter,
+		guint num_params, GParameter *params);
+	void (*add_remote_candidates) (PurpleMediaBackend *self,
+		const gchar *sess_id, const gchar *participant,
+		GList *remote_candidates);
+	gboolean (*codecs_ready) (PurpleMediaBackend *self,
+		const gchar *sess_id);
+	GList *(*get_codecs) (PurpleMediaBackend *self,
+		const gchar *sess_id);
+	GList *(*get_local_candidates) (PurpleMediaBackend *self,
+		const gchar *sess_id, const gchar *participant);
+	gboolean (*set_remote_codecs) (PurpleMediaBackend *self,
+		const gchar *sess_id, const gchar *participant,
+		GList *codecs);
+	gboolean (*set_send_codec) (PurpleMediaBackend *self,
+		const gchar *sess_id, PurpleMediaCodec *codec);
+	void (*set_params) (PurpleMediaBackend *self,
+		guint num_params, GParameter *params);
+	const gchar **(*get_available_params) (void);
+};
+
+/**
+ * Gets the media backend's GType.
+ *
+ * @return The media backend's GType.
+ *
+ * @since 2.7.0
+ */
+GType purple_media_backend_get_type(void);
+
+/**
+ * Creates and adds a stream to the media backend.
+ *
+ * @param self The backend to add the stream to.
+ * @param sess_id The session id of the stream to add.
+ * @param who The remote participant of the stream to add.
+ * @param type The media type and direction of the stream to add.
+ * @param initiator True if the local user initiated the stream.
+ * @param transmitter The string id of the tranmsitter to use.
+ * @param num_params The number of parameters in the param parameter.
+ * @param params The additional parameters to pass when creating the stream.
+ *
+ * @return True if the stream was successfully created, othewise False.
+ *
+ * @since 2.7.0
+ */
+gboolean purple_media_backend_add_stream(PurpleMediaBackend *self,
+		const gchar *sess_id, const gchar *who,
+		PurpleMediaSessionType type, gboolean initiator,
+		const gchar *transmitter,
+		guint num_params, GParameter *params);
+
+/**
+ * Add remote candidates to a stream.
+ *
+ * @param self The backend the stream is in.
+ * @param sess_id The session id associated with the stream.
+ * @param participant The participant associated with the stream.
+ * @param remote_candidates The list of remote candidates to add.
+ *
+ * @since 2.7.0
+ */
+void purple_media_backend_add_remote_candidates(PurpleMediaBackend *self,
+		const gchar *sess_id, const gchar *participant,
+		GList *remote_candidates);
+
+/**
+ * Get whether or not a session's codecs are ready.
+ *
+ * A codec is ready if all of the attributes and additional
+ * parameters have been collected.
+ *
+ * @param self The media backend the session is in.
+ * @param sess_id The session id of the session to check.
+ *
+ * @return True if the codecs are ready, otherwise False.
+ *
+ * @since 2.7.0
+ */
+gboolean purple_media_backend_codecs_ready(PurpleMediaBackend *self,
+		const gchar *sess_id);
+
+/**
+ * Gets the codec intersection list for a session.
+ *
+ * The intersection list consists of all codecs that are compatible
+ * between the local and remote software.
+ *
+ * @param self The media backend the session is in.
+ * @param sess_id The session id of the session to use.
+ *
+ * @return The codec intersection list.
+ *
+ * @since 2.7.0
+ */
+GList *purple_media_backend_get_codecs(PurpleMediaBackend *self,
+		const gchar *sess_id);
+
+/**
+ * Gets the list of local candidates for a stream.
+ *
+ * @param self The media backend the stream is in.
+ * @param sess_id The session id associated with the stream.
+ * @param particilant The participant associated with the stream.
+ *
+ * @return The list of local candidates.
+ *
+ * @since 2.7.0
+ */
+GList *purple_media_backend_get_local_candidates(PurpleMediaBackend *self,
+		const gchar *sess_id, const gchar *participant);
+
+/**
+ * Sets the remote codecs on a stream.
+ *
+ * @param self The media backend the stream is in.
+ * @param sess_id The session id the stream is associated with.
+ * @param participant The participant the stream is associated with.
+ * @param codecs The list of remote codecs to set.
+ *
+ * @return True if the remote codecs were set successfully, otherwise False.
+ *
+ * @since 2.7.0
+ */
+gboolean purple_media_backend_set_remote_codecs(PurpleMediaBackend *self,
+		const gchar *sess_id, const gchar *participant,
+		GList *codecs);
+
+/**
+ * Sets which codec format to send media content in for a session.
+ *
+ * @param self The media backend the session is in.
+ * @param sess_id The session id of the session to set the codec for.
+ * @param codec The codec to set.
+ *
+ * @return True if set successfully, otherwise False.
+ *
+ * @since 2.7.0
+ */
+gboolean purple_media_backend_set_send_codec(PurpleMediaBackend *self,
+		const gchar *sess_id, PurpleMediaCodec *codec);
+
+/**
+ * Sets various optional parameters of the media backend.
+ *
+ * @param self The media backend to set the parameters on.
+ * @param num_params The number of parameters to pass to backend
+ * @param params Array of @c GParameter to pass to backend
+ *
+ * @since 2.8.0
+ */
+void purple_media_backend_set_params(PurpleMediaBackend *self,
+		guint num_params, GParameter *params);
+
+/**
+ * Gets the list of optional parameters supported by the media backend.
+ *
+ * The list should NOT be freed.
+ *
+ * @param self The media backend
+ *
+ * @return NULL-terminated array of names of supported parameters.
+ *
+ * @since 2.8.0
+ */
+const gchar **purple_media_backend_get_available_params(PurpleMediaBackend *self);
+
+G_END_DECLS
+
+#endif /* _MEDIA_BACKEND_IFACE_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/media/candidate.c	Sat Aug 06 03:45:56 2011 +0000
@@ -0,0 +1,495 @@
+/**
+ * @file candidate.c Candidate for Media API
+ * @ingroup core
+ */
+
+/* purple
+ *
+ * Purple is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * 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 "candidate.h"
+
+/** @copydoc _PurpleMediaCandidateClass */
+typedef struct _PurpleMediaCandidateClass PurpleMediaCandidateClass;
+/** @copydoc _PurpleMediaCandidatePrivate */
+typedef struct _PurpleMediaCandidatePrivate PurpleMediaCandidatePrivate;
+
+#define PURPLE_MEDIA_CANDIDATE_GET_PRIVATE(obj) \
+		(G_TYPE_INSTANCE_GET_PRIVATE((obj), \
+		PURPLE_TYPE_MEDIA_CANDIDATE, \
+		PurpleMediaCandidatePrivate))
+
+
+struct _PurpleMediaCandidateClass
+{
+	GObjectClass parent_class;
+};
+
+struct _PurpleMediaCandidate
+{
+	GObject parent;
+};
+
+G_DEFINE_TYPE(PurpleMediaCandidate, purple_media_candidate, G_TYPE_OBJECT);
+
+struct _PurpleMediaCandidatePrivate
+{
+	gchar *foundation;
+	guint component_id;
+	gchar *ip;
+	guint16 port;
+	gchar *base_ip;
+	guint16 base_port;
+	PurpleMediaNetworkProtocol proto;
+	guint32 priority;
+	PurpleMediaCandidateType type;
+	gchar *username;
+	gchar *password;
+	guint ttl;
+};
+
+enum {
+	PROP_CANDIDATE_0,
+	PROP_FOUNDATION,
+	PROP_COMPONENT_ID,
+	PROP_IP,
+	PROP_PORT,
+	PROP_BASE_IP,
+	PROP_BASE_PORT,
+	PROP_PROTOCOL,
+	PROP_PRIORITY,
+	PROP_TYPE,
+	PROP_USERNAME,
+	PROP_PASSWORD,
+	PROP_TTL,
+};
+
+static void
+purple_media_candidate_init(PurpleMediaCandidate *info)
+{
+	PurpleMediaCandidatePrivate *priv =
+			PURPLE_MEDIA_CANDIDATE_GET_PRIVATE(info);
+	priv->foundation = NULL;
+	priv->component_id = 0;
+	priv->ip = NULL;
+	priv->port = 0;
+	priv->base_ip = NULL;
+	priv->proto = PURPLE_MEDIA_NETWORK_PROTOCOL_UDP;
+	priv->priority = 0;
+	priv->type = PURPLE_MEDIA_CANDIDATE_TYPE_HOST;
+	priv->username = NULL;
+	priv->password = NULL;
+	priv->ttl = 0;
+}
+
+static void
+purple_media_candidate_finalize(GObject *info)
+{
+	PurpleMediaCandidatePrivate *priv =
+			PURPLE_MEDIA_CANDIDATE_GET_PRIVATE(info);
+
+	g_free(priv->foundation);
+	g_free(priv->ip);
+	g_free(priv->base_ip);
+	g_free(priv->username);
+	g_free(priv->password);
+}
+
+static void
+purple_media_candidate_set_property (GObject *object, guint prop_id,
+		const GValue *value, GParamSpec *pspec)
+{
+	PurpleMediaCandidatePrivate *priv;
+	g_return_if_fail(PURPLE_IS_MEDIA_CANDIDATE(object));
+
+	priv = PURPLE_MEDIA_CANDIDATE_GET_PRIVATE(object);
+
+	switch (prop_id) {
+		case PROP_FOUNDATION:
+			g_free(priv->foundation);
+			priv->foundation = g_value_dup_string(value);
+			break;
+		case PROP_COMPONENT_ID:
+			priv->component_id = g_value_get_uint(value);
+			break;
+		case PROP_IP:
+			g_free(priv->ip);
+			priv->ip = g_value_dup_string(value);
+			break;
+		case PROP_PORT:
+			priv->port = g_value_get_uint(value);
+			break;
+		case PROP_BASE_IP:
+			g_free(priv->base_ip);
+			priv->base_ip = g_value_dup_string(value);
+			break;
+		case PROP_BASE_PORT:
+			priv->base_port = g_value_get_uint(value);
+			break;
+		case PROP_PROTOCOL:
+			priv->proto = g_value_get_enum(value);
+			break;
+		case PROP_PRIORITY:
+			priv->priority = g_value_get_uint(value);
+			break;
+		case PROP_TYPE:
+			priv->type = g_value_get_enum(value);
+			break;
+		case PROP_USERNAME:
+			g_free(priv->username);
+			priv->username = g_value_dup_string(value);
+			break;
+		case PROP_PASSWORD:
+			g_free(priv->password);
+			priv->password = g_value_dup_string(value);
+			break;
+		case PROP_TTL:
+			priv->ttl = g_value_get_uint(value);
+			break;
+		default:
+			G_OBJECT_WARN_INVALID_PROPERTY_ID(
+					object, prop_id, pspec);
+			break;
+	}
+}
+
+static void
+purple_media_candidate_get_property (GObject *object, guint prop_id,
+		GValue *value, GParamSpec *pspec)
+{
+	PurpleMediaCandidatePrivate *priv;
+	g_return_if_fail(PURPLE_IS_MEDIA_CANDIDATE(object));
+
+	priv = PURPLE_MEDIA_CANDIDATE_GET_PRIVATE(object);
+
+	switch (prop_id) {
+		case PROP_FOUNDATION:
+			g_value_set_string(value, priv->foundation);
+			break;
+		case PROP_COMPONENT_ID:
+			g_value_set_uint(value, priv->component_id);
+			break;
+		case PROP_IP:
+			g_value_set_string(value, priv->ip);
+			break;
+		case PROP_PORT:
+			g_value_set_uint(value, priv->port);
+			break;
+		case PROP_BASE_IP:
+			g_value_set_string(value, priv->base_ip);
+			break;
+		case PROP_BASE_PORT:
+			g_value_set_uint(value, priv->base_port);
+			break;
+		case PROP_PROTOCOL:
+			g_value_set_enum(value, priv->proto);
+			break;
+		case PROP_PRIORITY:
+			g_value_set_uint(value, priv->priority);
+			break;
+		case PROP_TYPE:
+			g_value_set_enum(value, priv->type);
+			break;
+		case PROP_USERNAME:
+			g_value_set_string(value, priv->username);
+			break;
+		case PROP_PASSWORD:
+			g_value_set_string(value, priv->password);
+			break;
+		case PROP_TTL:
+			g_value_set_uint(value, priv->ttl);
+			break;
+		default:
+			G_OBJECT_WARN_INVALID_PROPERTY_ID(
+					object, prop_id, pspec);
+			break;
+	}
+}
+
+static void
+purple_media_candidate_class_init(PurpleMediaCandidateClass *klass)
+{
+	GObjectClass *gobject_class = (GObjectClass*)klass;
+
+	gobject_class->finalize = purple_media_candidate_finalize;
+	gobject_class->set_property = purple_media_candidate_set_property;
+	gobject_class->get_property = purple_media_candidate_get_property;
+
+	g_object_class_install_property(gobject_class, PROP_FOUNDATION,
+			g_param_spec_string("foundation",
+			"Foundation",
+			"The foundation of the candidate.",
+			NULL,
+			G_PARAM_READWRITE));
+
+	g_object_class_install_property(gobject_class, PROP_COMPONENT_ID,
+			g_param_spec_uint("component-id",
+			"Component ID",
+			"The component id of the candidate.",
+			0, G_MAXUINT, 0,
+			G_PARAM_READWRITE));
+
+	g_object_class_install_property(gobject_class, PROP_IP,
+			g_param_spec_string("ip",
+			"IP Address",
+			"The IP address of the candidate.",
+			NULL,
+			G_PARAM_READWRITE));
+
+	g_object_class_install_property(gobject_class, PROP_PORT,
+			g_param_spec_uint("port",
+			"Port",
+			"The port of the candidate.",
+			0, G_MAXUINT16, 0,
+			G_PARAM_READWRITE));
+
+	g_object_class_install_property(gobject_class, PROP_BASE_IP,
+			g_param_spec_string("base-ip",
+			"Base IP",
+			"The internal IP address of the candidate.",
+			NULL,
+			G_PARAM_READWRITE));
+
+	g_object_class_install_property(gobject_class, PROP_BASE_PORT,
+			g_param_spec_uint("base-port",
+			"Base Port",
+			"The internal port of the candidate.",
+			0, G_MAXUINT16, 0,
+			G_PARAM_READWRITE));
+
+	g_object_class_install_property(gobject_class, PROP_PROTOCOL,
+			g_param_spec_enum("protocol",
+			"Protocol",
+			"The protocol of the candidate.",
+			PURPLE_TYPE_MEDIA_NETWORK_PROTOCOL,
+			PURPLE_MEDIA_NETWORK_PROTOCOL_UDP,
+			G_PARAM_READWRITE));
+
+	g_object_class_install_property(gobject_class, PROP_PRIORITY,
+			g_param_spec_uint("priority",
+			"Priority",
+			"The priority of the candidate.",
+			0, G_MAXUINT32, 0,
+			G_PARAM_READWRITE));
+
+	g_object_class_install_property(gobject_class, PROP_TYPE,
+			g_param_spec_enum("type",
+			"Type",
+			"The type of the candidate.",
+			PURPLE_TYPE_MEDIA_CANDIDATE_TYPE,
+			PURPLE_MEDIA_CANDIDATE_TYPE_HOST,
+			G_PARAM_READWRITE));
+
+	g_object_class_install_property(gobject_class, PROP_USERNAME,
+			g_param_spec_string("username",
+			"Username",
+			"The username used to connect to the candidate.",
+			NULL,
+			G_PARAM_READWRITE));
+
+	g_object_class_install_property(gobject_class, PROP_PASSWORD,
+			g_param_spec_string("password",
+			"Password",
+			"The password use to connect to the candidate.",
+			NULL,
+			G_PARAM_READWRITE));
+
+	g_object_class_install_property(gobject_class, PROP_TTL,
+			g_param_spec_uint("ttl",
+			"TTL",
+			"The TTL of the candidate.",
+			0, G_MAXUINT, 0,
+			G_PARAM_READWRITE));
+
+	g_type_class_add_private(klass, sizeof(PurpleMediaCandidatePrivate));
+}
+
+PurpleMediaCandidate *
+purple_media_candidate_new(const gchar *foundation, guint component_id,
+		PurpleMediaCandidateType type,
+		PurpleMediaNetworkProtocol proto,
+		const gchar *ip, guint port)
+{
+	return g_object_new(PURPLE_TYPE_MEDIA_CANDIDATE,
+			"foundation", foundation,
+			"component-id", component_id,
+			"type", type,
+			"protocol", proto,
+			"ip", ip,
+			"port", port, NULL);
+}
+
+PurpleMediaCandidate *
+purple_media_candidate_copy(PurpleMediaCandidate *candidate)
+{
+	PurpleMediaCandidatePrivate *priv;
+	PurpleMediaCandidate *new_candidate;
+
+	if (candidate == NULL)
+		return NULL;
+
+	priv = PURPLE_MEDIA_CANDIDATE_GET_PRIVATE(candidate);
+
+	new_candidate = purple_media_candidate_new(priv->foundation,
+			priv->component_id, priv->type, priv->proto,
+			priv->ip, priv->port);
+	g_object_set(new_candidate,
+			"base-ip", priv->base_ip,
+			"base-port", priv->base_port,
+			"priority", priv->priority,
+			"username", priv->username,
+			"password", priv->password,
+			"ttl", priv->ttl, NULL);
+	return new_candidate;
+}
+
+GList *
+purple_media_candidate_list_copy(GList *candidates)
+{
+	GList *new_list = NULL;
+
+	for (; candidates; candidates = g_list_next(candidates)) {
+		new_list = g_list_prepend(new_list,
+				purple_media_candidate_copy(candidates->data));
+	}
+
+	new_list = g_list_reverse(new_list);
+	return new_list;
+}
+
+void
+purple_media_candidate_list_free(GList *candidates)
+{
+	for (; candidates; candidates =
+			g_list_delete_link(candidates, candidates)) {
+		g_object_unref(candidates->data);
+	}
+}
+
+gchar *
+purple_media_candidate_get_foundation(PurpleMediaCandidate *candidate)
+{
+	gchar *foundation;
+	g_return_val_if_fail(PURPLE_IS_MEDIA_CANDIDATE(candidate), NULL);
+	g_object_get(candidate, "foundation", &foundation, NULL);
+	return foundation;
+}
+
+guint
+purple_media_candidate_get_component_id(PurpleMediaCandidate *candidate)
+{
+	guint component_id;
+	g_return_val_if_fail(PURPLE_IS_MEDIA_CANDIDATE(candidate), 0);
+	g_object_get(candidate, "component-id", &component_id, NULL);
+	return component_id;
+}
+
+gchar *
+purple_media_candidate_get_ip(PurpleMediaCandidate *candidate)
+{
+	gchar *ip;
+	g_return_val_if_fail(PURPLE_IS_MEDIA_CANDIDATE(candidate), NULL);
+	g_object_get(candidate, "ip", &ip, NULL);
+	return ip;
+}
+
+guint16
+purple_media_candidate_get_port(PurpleMediaCandidate *candidate)
+{
+	guint port;
+	g_return_val_if_fail(PURPLE_IS_MEDIA_CANDIDATE(candidate), 0);
+	g_object_get(candidate, "port", &port, NULL);
+	return port;
+}
+
+gchar *
+purple_media_candidate_get_base_ip(PurpleMediaCandidate *candidate)
+{
+	gchar *base_ip;
+	g_return_val_if_fail(PURPLE_IS_MEDIA_CANDIDATE(candidate), NULL);
+	g_object_get(candidate, "base-ip", &base_ip, NULL);
+	return base_ip;
+}
+
+guint16
+purple_media_candidate_get_base_port(PurpleMediaCandidate *candidate)
+{
+	guint base_port;
+	g_return_val_if_fail(PURPLE_IS_MEDIA_CANDIDATE(candidate), 0);
+	g_object_get(candidate, "base_port", &base_port, NULL);
+	return base_port;
+}
+
+PurpleMediaNetworkProtocol
+purple_media_candidate_get_protocol(PurpleMediaCandidate *candidate)
+{
+	PurpleMediaNetworkProtocol protocol;
+	g_return_val_if_fail(PURPLE_IS_MEDIA_CANDIDATE(candidate),
+			PURPLE_MEDIA_NETWORK_PROTOCOL_UDP);
+	g_object_get(candidate, "protocol", &protocol, NULL);
+	return protocol;
+}
+
+guint32
+purple_media_candidate_get_priority(PurpleMediaCandidate *candidate)
+{
+	guint priority;
+	g_return_val_if_fail(PURPLE_IS_MEDIA_CANDIDATE(candidate), 0);
+	g_object_get(candidate, "priority", &priority, NULL);
+	return priority;
+}
+
+PurpleMediaCandidateType
+purple_media_candidate_get_candidate_type(PurpleMediaCandidate *candidate)
+{
+	PurpleMediaCandidateType type;
+	g_return_val_if_fail(PURPLE_IS_MEDIA_CANDIDATE(candidate),
+			PURPLE_MEDIA_CANDIDATE_TYPE_HOST);
+	g_object_get(candidate, "type", &type, NULL);
+	return type;
+}
+
+gchar *
+purple_media_candidate_get_username(PurpleMediaCandidate *candidate)
+{
+	gchar *username;
+	g_return_val_if_fail(PURPLE_IS_MEDIA_CANDIDATE(candidate), NULL);
+	g_object_get(candidate, "username", &username, NULL);
+	return username;
+}
+
+gchar *
+purple_media_candidate_get_password(PurpleMediaCandidate *candidate)
+{
+	gchar *password;
+	g_return_val_if_fail(PURPLE_IS_MEDIA_CANDIDATE(candidate), NULL);
+	g_object_get(candidate, "password", &password, NULL);
+	return password;
+}
+
+guint
+purple_media_candidate_get_ttl(PurpleMediaCandidate *candidate)
+{
+	guint ttl;
+	g_return_val_if_fail(PURPLE_IS_MEDIA_CANDIDATE(candidate), 0);
+	g_object_get(candidate, "ttl", &ttl, NULL);
+	return ttl;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/media/candidate.h	Sat Aug 06 03:45:56 2011 +0000
@@ -0,0 +1,252 @@
+/**
+ * @file candidate.h Candidate for Media API
+ * @ingroup core
+ */
+
+/* purple
+ *
+ * Purple is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * 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
+ */
+
+#ifndef _PURPLE_MEDIA_CANDIDATE_H_
+#define _PURPLE_MEDIA_CANDIDATE_H_
+
+#include "enum-types.h"
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define PURPLE_TYPE_MEDIA_CANDIDATE            (purple_media_candidate_get_type())
+#define PURPLE_IS_MEDIA_CANDIDATE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_MEDIA_CANDIDATE))
+#define PURPLE_IS_MEDIA_CANDIDATE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PURPLE_TYPE_MEDIA_CANDIDATE))
+#define PURPLE_MEDIA_CANDIDATE(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_MEDIA_CANDIDATE, PurpleMediaCandidate))
+#define PURPLE_MEDIA_CANDIDATE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_MEDIA_CANDIDATE, PurpleMediaCandidate))
+#define PURPLE_MEDIA_CANDIDATE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_MEDIA_CANDIDATE, PurpleMediaCandidate))
+
+/** An opaque structure representing a network candidate (IP Address and port pair). */
+typedef struct _PurpleMediaCandidate PurpleMediaCandidate;
+
+/**
+ * Gets the type of the media candidate structure.
+ *
+ * @return The media canditate's GType
+ *
+ * @since 2.6.0
+ */
+GType purple_media_candidate_get_type(void);
+
+/**
+ * Creates a PurpleMediaCandidate instance.
+ *
+ * @param foundation The foundation of the candidate.
+ * @param component_id The component this candidate is for.
+ * @param type The type of candidate.
+ * @param proto The protocol this component is for.
+ * @param ip The IP address of this component.
+ * @param port The network port.
+ *
+ * @return The newly created PurpleMediaCandidate instance.
+ *
+ * @since 2.6.0
+ */
+PurpleMediaCandidate *purple_media_candidate_new(
+		const gchar *foundation, guint component_id,
+		PurpleMediaCandidateType type,
+		PurpleMediaNetworkProtocol proto,
+		const gchar *ip, guint port);
+
+/**
+ * Copies a PurpleMediaCandidate.
+ *
+ * @param candidate The candidate to copy.
+ *
+ * @return The copy of the PurpleMediaCandidate.
+ *
+ * @since 2.7.0
+ */
+PurpleMediaCandidate *purple_media_candidate_copy(
+		PurpleMediaCandidate *candidate);
+
+/**
+ * Copies a GList of PurpleMediaCandidate and its contents.
+ *
+ * @param candidates The list of candidates to be copied.
+ *
+ * @return The copy of the GList.
+ *
+ * @since 2.6.0
+ */
+GList *purple_media_candidate_list_copy(GList *candidates);
+
+/**
+ * Frees a GList of PurpleMediaCandidate and its contents.
+ *
+ * @param candidates The list of candidates to be freed.
+ *
+ * @since 2.6.0
+ */
+void purple_media_candidate_list_free(GList *candidates);
+
+/**
+ * Gets the foundation (identifier) from the candidate.
+ *
+ * @param candidate The candidate to get the foundation from.
+ *
+ * @return The foundation.
+ *
+ * @since 2.6.0
+ */
+gchar *purple_media_candidate_get_foundation(PurpleMediaCandidate *candidate);
+
+/**
+ * Gets the component id (rtp or rtcp)
+ *
+ * @param candidate The candidate to get the compnent id from.
+ *
+ * @return The component id.
+ *
+ * @since 2.6.0
+ */
+guint purple_media_candidate_get_component_id(PurpleMediaCandidate *candidate);
+
+/**
+ * Gets the IP address.
+ *
+ * @param candidate The candidate to get the IP address from.
+ *
+ * @return The IP address.
+ *
+ * @since 2.6.0
+ */
+gchar *purple_media_candidate_get_ip(PurpleMediaCandidate *candidate);
+
+/**
+ * Gets the port.
+ *
+ * @param candidate The candidate to get the port from.
+ *
+ * @return The port.
+ *
+ * @since 2.6.0
+ */
+guint16 purple_media_candidate_get_port(PurpleMediaCandidate *candidate);
+
+/**
+ * Gets the base (internal) IP address.
+ *
+ * This can be NULL.
+ *
+ * @param candidate The candidate to get the base IP address from.
+ *
+ * @return The base IP address.
+ *
+ * @since 2.6.0
+ */
+gchar *purple_media_candidate_get_base_ip(PurpleMediaCandidate *candidate);
+
+/**
+ * Gets the base (internal) port.
+ *
+ * Invalid if the base IP is NULL.
+ *
+ * @param candidate The candidate to get the base port.
+ *
+ * @return The base port.
+ *
+ * @since 2.6.0
+ */
+guint16 purple_media_candidate_get_base_port(PurpleMediaCandidate *candidate);
+
+/**
+ * Gets the protocol (TCP or UDP).
+ *
+ * @param candidate The candidate to get the protocol from.
+ *
+ * @return The protocol.
+ *
+ * @since 2.6.0
+ */
+PurpleMediaNetworkProtocol purple_media_candidate_get_protocol(
+		PurpleMediaCandidate *candidate);
+
+/**
+ * Gets the priority.
+ *
+ * @param candidate The candidate to get the priority from.
+ *
+ * @return The priority.
+ *
+ * @since 2.6.0
+ */
+guint32 purple_media_candidate_get_priority(PurpleMediaCandidate *candidate);
+
+/**
+ * Gets the candidate type.
+ *
+ * @param candidate The candidate to get the candidate type from.
+ *
+ * @return The candidate type.
+ *
+ * @since 2.6.0
+ */
+PurpleMediaCandidateType purple_media_candidate_get_candidate_type(
+		PurpleMediaCandidate *candidate);
+
+/**
+ * Gets the username.
+ *
+ * This can be NULL. It depends on the transmission type.
+ *
+ * @param The candidate to get the username from.
+ *
+ * @return The username.
+ *
+ * @since 2.6.0
+ */
+gchar *purple_media_candidate_get_username(PurpleMediaCandidate *candidate);
+
+/**
+ * Gets the password.
+ *
+ * This can be NULL. It depends on the transmission type.
+ *
+ * @param The candidate to get the password from.
+ *
+ * @return The password.
+ *
+ * @since 2.6.0
+ */
+gchar *purple_media_candidate_get_password(PurpleMediaCandidate *candidate);
+
+/**
+ * Gets the TTL.
+ *
+ * @param The candidate to get the TTL from.
+ *
+ * @return The TTL.
+ *
+ * @since 2.6.0
+ */
+guint purple_media_candidate_get_ttl(PurpleMediaCandidate *candidate);
+
+G_END_DECLS
+
+#endif  /* _PURPLE_MEDIA_CANDIDATE_H_ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/media/codec.c	Sat Aug 06 03:45:56 2011 +0000
@@ -0,0 +1,421 @@
+/**
+ * @file codec.c Codec for Media API
+ * @ingroup core
+ */
+
+/* purple
+ *
+ * Purple is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * 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 "codec.h"
+
+/** @copydoc _PurpleMediaCodecClass */
+typedef struct _PurpleMediaCodecClass PurpleMediaCodecClass;
+/** @copydoc _PurpleMediaCodecPrivate */
+typedef struct _PurpleMediaCodecPrivate PurpleMediaCodecPrivate;
+
+#define PURPLE_MEDIA_CODEC_GET_PRIVATE(obj) \
+		(G_TYPE_INSTANCE_GET_PRIVATE((obj), \
+		PURPLE_TYPE_MEDIA_CODEC, PurpleMediaCodecPrivate))
+
+struct _PurpleMediaCodecClass
+{
+	GObjectClass parent_class;
+};
+
+struct _PurpleMediaCodec
+{
+	GObject parent;
+};
+
+G_DEFINE_TYPE(PurpleMediaCodec, purple_media_codec, G_TYPE_OBJECT);
+
+struct _PurpleMediaCodecPrivate
+{
+	gint id;
+	char *encoding_name;
+	PurpleMediaSessionType media_type;
+	guint clock_rate;
+	guint channels;
+	GList *optional_params;
+};
+
+enum {
+	PROP_CODEC_0,
+	PROP_ID,
+	PROP_ENCODING_NAME,
+	PROP_MEDIA_TYPE,
+	PROP_CLOCK_RATE,
+	PROP_CHANNELS,
+	PROP_OPTIONAL_PARAMS,
+};
+
+static void
+purple_media_codec_init(PurpleMediaCodec *info)
+{
+	PurpleMediaCodecPrivate *priv =
+			PURPLE_MEDIA_CODEC_GET_PRIVATE(info);
+	priv->encoding_name = NULL;
+	priv->optional_params = NULL;
+}
+
+static void
+purple_media_codec_finalize(GObject *info)
+{
+	PurpleMediaCodecPrivate *priv =
+			PURPLE_MEDIA_CODEC_GET_PRIVATE(info);
+	g_free(priv->encoding_name);
+	for (; priv->optional_params; priv->optional_params =
+			g_list_delete_link(priv->optional_params, priv->optional_params)) {
+		PurpleKeyValuePair *param = priv->optional_params->data;
+		g_free(param->key);
+		g_free(param->value);
+		g_free(param);
+	}
+}
+
+static void
+purple_media_codec_set_property (GObject *object, guint prop_id,
+		const GValue *value, GParamSpec *pspec)
+{
+	PurpleMediaCodecPrivate *priv;
+	g_return_if_fail(PURPLE_IS_MEDIA_CODEC(object));
+
+	priv = PURPLE_MEDIA_CODEC_GET_PRIVATE(object);
+
+	switch (prop_id) {
+		case PROP_ID:
+			priv->id = g_value_get_uint(value);
+			break;
+		case PROP_ENCODING_NAME:
+			g_free(priv->encoding_name);
+			priv->encoding_name = g_value_dup_string(value);
+			break;
+		case PROP_MEDIA_TYPE:
+			priv->media_type = g_value_get_flags(value);
+			break;
+		case PROP_CLOCK_RATE:
+			priv->clock_rate = g_value_get_uint(value);
+			break;
+		case PROP_CHANNELS:
+			priv->channels = g_value_get_uint(value);
+			break;
+		case PROP_OPTIONAL_PARAMS:
+			priv->optional_params = g_value_get_pointer(value);
+			break;
+		default:
+			G_OBJECT_WARN_INVALID_PROPERTY_ID(
+					object, prop_id, pspec);
+			break;
+	}
+}
+
+static void
+purple_media_codec_get_property (GObject *object, guint prop_id,
+		GValue *value, GParamSpec *pspec)
+{
+	PurpleMediaCodecPrivate *priv;
+	g_return_if_fail(PURPLE_IS_MEDIA_CODEC(object));
+
+	priv = PURPLE_MEDIA_CODEC_GET_PRIVATE(object);
+
+	switch (prop_id) {
+		case PROP_ID:
+			g_value_set_uint(value, priv->id);
+			break;
+		case PROP_ENCODING_NAME:
+			g_value_set_string(value, priv->encoding_name);
+			break;
+		case PROP_MEDIA_TYPE:
+			g_value_set_flags(value, priv->media_type);
+			break;
+		case PROP_CLOCK_RATE:
+			g_value_set_uint(value, priv->clock_rate);
+			break;
+		case PROP_CHANNELS:
+			g_value_set_uint(value, priv->channels);
+			break;
+		case PROP_OPTIONAL_PARAMS:
+			g_value_set_pointer(value, priv->optional_params);
+			break;
+		default:
+			G_OBJECT_WARN_INVALID_PROPERTY_ID(
+					object, prop_id, pspec);
+			break;
+	}
+}
+
+static void
+purple_media_codec_class_init(PurpleMediaCodecClass *klass)
+{
+	GObjectClass *gobject_class = (GObjectClass*)klass;
+
+	gobject_class->finalize = purple_media_codec_finalize;
+	gobject_class->set_property = purple_media_codec_set_property;
+	gobject_class->get_property = purple_media_codec_get_property;
+
+	g_object_class_install_property(gobject_class, PROP_ID,
+			g_param_spec_uint("id",
+			"ID",
+			"The numeric identifier of the codec.",
+			0, G_MAXUINT, 0,
+			G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
+
+	g_object_class_install_property(gobject_class, PROP_ENCODING_NAME,
+			g_param_spec_string("encoding-name",
+			"Encoding Name",
+			"The name of the codec.",
+			NULL,
+			G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
+
+	g_object_class_install_property(gobject_class, PROP_MEDIA_TYPE,
+			g_param_spec_flags("media-type",
+			"Media Type",
+			"Whether this is an audio of video codec.",
+			PURPLE_TYPE_MEDIA_SESSION_TYPE,
+			PURPLE_MEDIA_NONE,
+			G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
+
+	g_object_class_install_property(gobject_class, PROP_CLOCK_RATE,
+			g_param_spec_uint("clock-rate",
+			"Create Callback",
+			"The function called to create this element.",
+			0, G_MAXUINT, 0,
+			G_PARAM_READWRITE));
+
+	g_object_class_install_property(gobject_class, PROP_CHANNELS,
+			g_param_spec_uint("channels",
+			"Channels",
+			"The number of channels in this codec.",
+			0, G_MAXUINT, 0,
+			G_PARAM_READWRITE));
+	g_object_class_install_property(gobject_class, PROP_OPTIONAL_PARAMS,
+			g_param_spec_pointer("optional-params",
+			"Optional Params",
+			"A list of optional parameters for the codec.",
+			G_PARAM_READWRITE));
+
+	g_type_class_add_private(klass, sizeof(PurpleMediaCodecPrivate));
+}
+
+PurpleMediaCodec *
+purple_media_codec_new(int id, const char *encoding_name,
+		PurpleMediaSessionType media_type, guint clock_rate)
+{
+	PurpleMediaCodec *codec =
+			g_object_new(PURPLE_TYPE_MEDIA_CODEC,
+			"id", id,
+			"encoding_name", encoding_name,
+			"media_type", media_type,
+			"clock-rate", clock_rate, NULL);
+	return codec;
+}
+
+guint
+purple_media_codec_get_id(PurpleMediaCodec *codec)
+{
+	guint id;
+	g_return_val_if_fail(PURPLE_IS_MEDIA_CODEC(codec), 0);
+	g_object_get(codec, "id", &id, NULL);
+	return id;
+}
+
+gchar *
+purple_media_codec_get_encoding_name(PurpleMediaCodec *codec)
+{
+	gchar *name;
+	g_return_val_if_fail(PURPLE_IS_MEDIA_CODEC(codec), NULL);
+	g_object_get(codec, "encoding-name", &name, NULL);
+	return name;
+}
+
+guint
+purple_media_codec_get_clock_rate(PurpleMediaCodec *codec)
+{
+	guint clock_rate;
+	g_return_val_if_fail(PURPLE_IS_MEDIA_CODEC(codec), 0);
+	g_object_get(codec, "clock-rate", &clock_rate, NULL);
+	return clock_rate;
+}
+
+guint
+purple_media_codec_get_channels(PurpleMediaCodec *codec)
+{
+	guint channels;
+	g_return_val_if_fail(PURPLE_IS_MEDIA_CODEC(codec), 0);
+	g_object_get(codec, "channels", &channels, NULL);
+	return channels;
+}
+
+GList *
+purple_media_codec_get_optional_parameters(PurpleMediaCodec *codec)
+{
+	GList *optional_params;
+	g_return_val_if_fail(PURPLE_IS_MEDIA_CODEC(codec), NULL);
+	g_object_get(codec, "optional-params", &optional_params, NULL);
+	return optional_params;
+}
+
+void
+purple_media_codec_add_optional_parameter(PurpleMediaCodec *codec,
+		const gchar *name, const gchar *value)
+{
+	PurpleMediaCodecPrivate *priv;
+	PurpleKeyValuePair *new_param;
+
+	g_return_if_fail(codec != NULL);
+	g_return_if_fail(name != NULL && value != NULL);
+
+	priv = PURPLE_MEDIA_CODEC_GET_PRIVATE(codec);
+
+	new_param = g_new0(PurpleKeyValuePair, 1);
+	new_param->key = g_strdup(name);
+	new_param->value = g_strdup(value);
+	priv->optional_params = g_list_append(
+			priv->optional_params, new_param);
+}
+
+void
+purple_media_codec_remove_optional_parameter(PurpleMediaCodec *codec,
+		PurpleKeyValuePair *param)
+{
+	PurpleMediaCodecPrivate *priv;
+
+	g_return_if_fail(codec != NULL && param != NULL);
+
+	priv = PURPLE_MEDIA_CODEC_GET_PRIVATE(codec);
+
+	g_free(param->key);
+	g_free(param->value);
+
+	priv->optional_params =
+			g_list_remove(priv->optional_params, param);
+	g_free(param);
+}
+
+PurpleKeyValuePair *
+purple_media_codec_get_optional_parameter(PurpleMediaCodec *codec,
+		const gchar *name, const gchar *value)
+{
+	PurpleMediaCodecPrivate *priv;
+	GList *iter;
+
+	g_return_val_if_fail(codec != NULL, NULL);
+	g_return_val_if_fail(name != NULL, NULL);
+
+	priv = PURPLE_MEDIA_CODEC_GET_PRIVATE(codec);
+
+	for (iter = priv->optional_params; iter; iter = g_list_next(iter)) {
+		PurpleKeyValuePair *param = iter->data;
+		if (!g_ascii_strcasecmp(param->key, name) &&
+				(value == NULL ||
+				!g_ascii_strcasecmp(param->value, value)))
+			return param;
+	}
+
+	return NULL;
+}
+
+PurpleMediaCodec *
+purple_media_codec_copy(PurpleMediaCodec *codec)
+{
+	PurpleMediaCodecPrivate *priv;
+	PurpleMediaCodec *new_codec;
+	GList *iter;
+
+	if (codec == NULL)
+		return NULL;
+
+	priv = PURPLE_MEDIA_CODEC_GET_PRIVATE(codec);
+
+	new_codec = purple_media_codec_new(priv->id, priv->encoding_name,
+			priv->media_type, priv->clock_rate);
+	g_object_set(codec, "channels", priv->channels, NULL);
+
+	for (iter = priv->optional_params; iter; iter = g_list_next(iter)) {
+		PurpleKeyValuePair *param =
+				(PurpleKeyValuePair*)iter->data;
+		purple_media_codec_add_optional_parameter(new_codec,
+				param->key, param->value);
+	}
+
+	return new_codec;
+}
+
+GList *
+purple_media_codec_list_copy(GList *codecs)
+{
+	GList *new_list = NULL;
+
+	for (; codecs; codecs = g_list_next(codecs)) {
+		new_list = g_list_prepend(new_list,
+				purple_media_codec_copy(codecs->data));
+	}
+
+	new_list = g_list_reverse(new_list);
+	return new_list;
+}
+
+void
+purple_media_codec_list_free(GList *codecs)
+{
+	for (; codecs; codecs =
+			g_list_delete_link(codecs, codecs)) {
+		g_object_unref(codecs->data);
+	}
+}
+
+gchar *
+purple_media_codec_to_string(const PurpleMediaCodec *codec)
+{
+	PurpleMediaCodecPrivate *priv;
+	GString *string = NULL;
+	GList *item;
+	gchar *charstring;
+	const gchar *media_type_str = NULL;
+
+	if (codec == NULL)
+		return g_strdup("(NULL)");
+
+	priv = PURPLE_MEDIA_CODEC_GET_PRIVATE(codec);
+
+	string = g_string_new("");
+
+	if (priv->media_type & PURPLE_MEDIA_AUDIO)
+		media_type_str = "audio";
+	else if (priv->media_type & PURPLE_MEDIA_VIDEO)
+		media_type_str = "video";
+
+	g_string_printf(string, "%d: %s %s clock:%d channels:%d", priv->id,
+			media_type_str, priv->encoding_name,
+			priv->clock_rate, priv->channels);
+
+	for (item = priv->optional_params; item; item = g_list_next (item)) {
+		PurpleKeyValuePair *param = item->data;
+		g_string_append_printf (string, " %s=%s",
+				param->key, (gchar *)param->value);
+	}
+
+	charstring = string->str;
+	g_string_free (string, FALSE);
+
+	return charstring;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/media/codec.h	Sat Aug 06 03:45:56 2011 +0000
@@ -0,0 +1,214 @@
+/**
+ * @file codec.h Codec for Media API
+ * @ingroup core
+ */
+
+/* purple
+ *
+ * Purple is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * 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
+ */
+
+#ifndef _PURPLE_MEDIA_CODEC_H_
+#define _PURPLE_MEDIA_CODEC_H_
+
+#include "enum-types.h"
+
+/** An opaque structure representing an audio or video codec. */
+typedef struct _PurpleMediaCodec PurpleMediaCodec;
+
+#include "../util.h"
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define PURPLE_TYPE_MEDIA_CODEC            (purple_media_codec_get_type())
+#define PURPLE_IS_MEDIA_CODEC(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_MEDIA_CODEC))
+#define PURPLE_IS_MEDIA_CODEC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PURPLE_TYPE_MEDIA_CODEC))
+#define PURPLE_MEDIA_CODEC(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_MEDIA_CODEC, PurpleMediaCodec))
+#define PURPLE_MEDIA_CODEC_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_MEDIA_CODEC, PurpleMediaCodec))
+#define PURPLE_MEDIA_CODEC_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_MEDIA_CODEC, PurpleMediaCodec))
+
+
+/**
+ * Gets the type of the media codec structure.
+ *
+ * @return The media codec's GType
+ *
+ * @since 2.6.0
+ */
+GType purple_media_codec_get_type(void);
+
+/**
+ * Creates a new PurpleMediaCodec instance.
+ *
+ * @param id Codec identifier.
+ * @param encoding_name Name of the media type this encodes.
+ * @param media_type PurpleMediaSessionType of this codec.
+ * @param clock_rate The clock rate this codec encodes at, if applicable.
+ *
+ * @return The newly created PurpleMediaCodec.
+ *
+ * @since 2.6.0
+ */
+PurpleMediaCodec *purple_media_codec_new(int id, const char *encoding_name,
+		PurpleMediaSessionType media_type, guint clock_rate);
+
+/**
+ * Gets the codec id.
+ *
+ * @param The codec to get the id from.
+ *
+ * @return The codec id.
+ *
+ * @since 2.6.0
+ */
+guint purple_media_codec_get_id(PurpleMediaCodec *codec);
+
+/**
+ * Gets the encoding name.
+ *
+ * @param The codec to get the encoding name from.
+ *
+ * @return The encoding name.
+ *
+ * @since 2.6.0
+ */
+gchar *purple_media_codec_get_encoding_name(PurpleMediaCodec *codec);
+
+/**
+ * Gets the clock rate.
+ *
+ * @param The codec to get the clock rate from.
+ *
+ * @return The clock rate.
+ *
+ * @since 2.6.0
+ */
+guint purple_media_codec_get_clock_rate(PurpleMediaCodec *codec);
+
+/**
+ * Gets the number of channels.
+ *
+ * @param The codec to get the number of channels from.
+ *
+ * @return The number of channels.
+ *
+ * @since 2.6.0
+ */
+guint purple_media_codec_get_channels(PurpleMediaCodec *codec);
+
+/**
+ * Gets a list of the optional parameters.
+ *
+ * The list consists of PurpleKeyValuePair's.
+ *
+ * @param The codec to get the optional parameters from.
+ *
+ * @return The list of optional parameters. The list is owned by the codec and
+ *         should not be freed.
+ *
+ * @since 2.6.0
+ */
+GList *purple_media_codec_get_optional_parameters(PurpleMediaCodec *codec);
+
+/**
+ * Adds an optional parameter to the codec.
+ *
+ * @param codec The codec to add the parameter to.
+ * @param name The name of the parameter to add.
+ * @param value The value of the parameter to add.
+ *
+ * @since 2.6.0
+ */
+void purple_media_codec_add_optional_parameter(PurpleMediaCodec *codec,
+		const gchar *name, const gchar *value);
+
+/**
+ * Removes an optional parameter from the codec.
+ *
+ * @param codec The codec to remove the parameter from.
+ * @param param A pointer to the parameter to remove.
+ *
+ * @since 2.6.0
+ */
+void purple_media_codec_remove_optional_parameter(PurpleMediaCodec *codec,
+		PurpleKeyValuePair *param);
+
+/**
+ * Gets an optional parameter based on the values given.
+ *
+ * @param codec The codec to find the parameter in.
+ * @param name The name of the parameter to search for.
+ * @param value The value to search for or NULL.
+ *
+ * @return The value found or NULL.
+ *
+ * @since 2.6.0
+ */
+PurpleKeyValuePair *purple_media_codec_get_optional_parameter(
+		PurpleMediaCodec *codec, const gchar *name,
+		const gchar *value);
+
+/**
+ * Copies a PurpleMediaCodec object.
+ *
+ * @param codec The codec to copy.
+ *
+ * @return The copy of the codec.
+ *
+ * @since 2.7.0
+ */
+PurpleMediaCodec *purple_media_codec_copy(PurpleMediaCodec *codec);
+
+/**
+ * Copies a GList of PurpleMediaCodec and its contents.
+ *
+ * @param codecs The list of codecs to be copied.
+ *
+ * @return The copy of the GList.
+ *
+ * @since 2.6.0
+ */
+GList *purple_media_codec_list_copy(GList *codecs);
+
+/**
+ * Frees a GList of PurpleMediaCodec and its contents.
+ *
+ * @param codecs The list of codecs to be freed.
+ *
+ * @since 2.6.0
+ */
+void purple_media_codec_list_free(GList *codecs);
+
+/**
+ * Creates a string representation of the codec.
+ *
+ * @param codec The codec to create the string of.
+ *
+ * @return The new string representation.
+ *
+ * @since 2.6.0
+ */
+gchar *purple_media_codec_to_string(const PurpleMediaCodec *codec);
+
+G_END_DECLS
+
+#endif  /* _PURPLE_MEDIA_CODEC_H_ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/media/enum-types.c	Sat Aug 06 03:45:56 2011 +0000
@@ -0,0 +1,213 @@
+/**
+ * @file enum-types.c Enum types for Media API
+ * @ingroup core
+ */
+
+/* purple
+ *
+ * Purple is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * 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 "enum-types.h"
+
+/*
+ * PurpleMediaCandidateType
+ */
+
+GType
+purple_media_candidate_type_get_type()
+{
+	static GType type = 0;
+	if (type == 0) {
+		static const GEnumValue values[] = {
+			{ PURPLE_MEDIA_CANDIDATE_TYPE_HOST,
+					"PURPLE_MEDIA_CANDIDATE_TYPE_HOST",
+					"host" },
+			{ PURPLE_MEDIA_CANDIDATE_TYPE_SRFLX,
+					"PURPLE_MEDIA_CANDIDATE_TYPE_SRFLX",
+					"srflx" },
+			{ PURPLE_MEDIA_CANDIDATE_TYPE_PRFLX,
+					"PURPLE_MEDIA_CANDIDATE_TYPE_PRFLX",
+					"prflx" },
+			{ PURPLE_MEDIA_CANDIDATE_TYPE_RELAY,
+					"PURPLE_MEDIA_CANDIDATE_TYPE_RELAY",
+					"relay" },
+			{ PURPLE_MEDIA_CANDIDATE_TYPE_MULTICAST,
+					"PURPLE_MEDIA_CANDIDATE_TYPE_MULTICAST",
+					"multicast" },
+			{ 0, NULL, NULL }
+		};
+		type = g_enum_register_static("PurpleMediaCandidateType",
+				values);
+	}
+	return type;
+}
+
+/*
+ * PurpleMediaCaps
+ */
+
+GType
+purple_media_caps_get_type()
+{
+	static GType type = 0;
+	if (type == 0) {
+		static const GEnumValue values[] = {
+			{ PURPLE_MEDIA_CAPS_NONE,
+					"PURPLE_MEDIA_CAPS_NONE", "none" },
+			{ PURPLE_MEDIA_CAPS_AUDIO,
+					"PURPLE_MEDIA_CAPS_AUDIO", "audio" },
+			{ PURPLE_MEDIA_CAPS_AUDIO_SINGLE_DIRECTION,
+					"PURPLE_MEDIA_CAPS_AUDIO_SINGLE_DIRECTION",
+					"audio-single-direction" },
+			{ PURPLE_MEDIA_CAPS_VIDEO,
+					"PURPLE_MEDIA_CAPS_VIDEO", "video" },
+			{ PURPLE_MEDIA_CAPS_VIDEO_SINGLE_DIRECTION,
+					"PURPLE_MEDIA_CAPS_VIDEO_SINGLE_DIRECTION",
+					"video-single-direction" },
+			{ PURPLE_MEDIA_CAPS_AUDIO_VIDEO,
+					"PURPLE_MEDIA_CAPS_AUDIO_VIDEO",
+					"audio-video" },
+			{ PURPLE_MEDIA_CAPS_MODIFY_SESSION,
+					"PURPLE_MEDIA_CAPS_MODIFY_SESSION",
+					"modify-session" },
+			{ PURPLE_MEDIA_CAPS_CHANGE_DIRECTION,
+					"PURPLE_MEDIA_CAPS_CHANGE_DIRECTION",
+					"change-direction" },
+			{ 0, NULL, NULL }
+		};
+		type = g_enum_register_static("PurpleMediaCaps", values);
+	}
+	return type;
+}
+
+/*
+ * PurpleMediaInfoType
+ */
+
+GType
+purple_media_info_type_get_type()
+{
+	static GType type = 0;
+	if (type == 0) {
+		static const GEnumValue values[] = {
+			{ PURPLE_MEDIA_INFO_HANGUP,
+					"PURPLE_MEDIA_INFO_HANGUP", "hangup" },
+			{ PURPLE_MEDIA_INFO_ACCEPT,
+					"PURPLE_MEDIA_INFO_ACCEPT", "accept" },
+			{ PURPLE_MEDIA_INFO_REJECT,
+					"PURPLE_MEDIA_INFO_REJECT", "reject" },
+			{ PURPLE_MEDIA_INFO_MUTE,
+					"PURPLE_MEDIA_INFO_MUTE", "mute" },
+			{ PURPLE_MEDIA_INFO_UNMUTE,
+					"PURPLE_MEDIA_INFO_UNMUTE", "unmute" },
+			{ PURPLE_MEDIA_INFO_PAUSE,
+					"PURPLE_MEDIA_INFO_PAUSE", "pause" },
+			{ PURPLE_MEDIA_INFO_UNPAUSE,
+					"PURPLE_MEDIA_INFO_UNPAUSE", "unpause" },
+			{ PURPLE_MEDIA_INFO_HOLD,
+					"PURPLE_MEDIA_INFO_HOLD", "hold" },
+			{ PURPLE_MEDIA_INFO_UNHOLD,
+					"PURPLE_MEDIA_INFO_HOLD", "unhold" },
+			{ 0, NULL, NULL }
+		};
+		type = g_enum_register_static("PurpleMediaInfoType", values);
+	}
+	return type;
+}
+
+/*
+ * PurpleMediaNetworkProtocol
+ */
+
+GType
+purple_media_network_protocol_get_type()
+{
+	static GType type = 0;
+	if (type == 0) {
+		static const GEnumValue values[] = {
+			{ PURPLE_MEDIA_NETWORK_PROTOCOL_UDP,
+					"PURPLE_MEDIA_NETWORK_PROTOCOL_UDP",
+					"udp" },
+			{ PURPLE_MEDIA_NETWORK_PROTOCOL_TCP,
+					"PURPLE_MEDIA_NETWORK_PROTOCOL_TCP",
+					"tcp" },
+			{ 0, NULL, NULL }
+		};
+		type = g_enum_register_static("PurpleMediaNetworkProtocol",
+				values);
+	}
+	return type;
+}
+
+/*
+ * PurpleMediaSessionType
+ */
+
+GType
+purple_media_session_type_get_type()
+{
+	static GType type = 0;
+	if (type == 0) {
+		static const GFlagsValue values[] = {
+			{ PURPLE_MEDIA_NONE,
+				"PURPLE_MEDIA_NONE", "none" },
+			{ PURPLE_MEDIA_RECV_AUDIO,
+				"PURPLE_MEDIA_RECV_AUDIO", "recv-audio" },
+			{ PURPLE_MEDIA_SEND_AUDIO,
+				"PURPLE_MEDIA_SEND_AUDIO", "send-audio" },
+			{ PURPLE_MEDIA_RECV_VIDEO,
+				"PURPLE_MEDIA_RECV_VIDEO", "recv-video" },
+			{ PURPLE_MEDIA_SEND_VIDEO,
+				"PURPLE_MEDIA_SEND_VIDEO", "send-audio" },
+			{ PURPLE_MEDIA_AUDIO,
+				"PURPLE_MEDIA_AUDIO", "audio" },
+			{ PURPLE_MEDIA_VIDEO,
+				"PURPLE_MEDIA_VIDEO", "video" },
+			{ 0, NULL, NULL }
+		};
+		type = g_flags_register_static(
+				"PurpleMediaSessionType", values);
+	}
+	return type;
+}
+
+/*
+ * PurpleMediaState
+ */
+
+GType
+purple_media_state_changed_get_type()
+{
+	static GType type = 0;
+	if (type == 0) {
+		static const GEnumValue values[] = {
+			{ PURPLE_MEDIA_STATE_NEW,
+				"PURPLE_MEDIA_STATE_NEW", "new" },
+			{ PURPLE_MEDIA_STATE_CONNECTED,
+				"PURPLE_MEDIA_STATE_CONNECTED", "connected" },
+			{ PURPLE_MEDIA_STATE_END,
+				"PURPLE_MEDIA_STATE_END", "end" },
+			{ 0, NULL, NULL }
+		};
+		type = g_enum_register_static("PurpleMediaState", values);
+	}
+	return type;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/media/enum-types.h	Sat Aug 06 03:45:56 2011 +0000
@@ -0,0 +1,162 @@
+/**
+ * @file enum-types.h Enum types for Media API
+ * @ingroup core
+ */
+
+/* purple
+ *
+ * Purple is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * 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
+ */
+
+#ifndef _PURPLE_MEDIA_ENUM_TYPES_H_
+#define _PURPLE_MEDIA_ENUM_TYPES_H_
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define PURPLE_TYPE_MEDIA_CANDIDATE_TYPE   (purple_media_candidate_type_get_type())
+#define PURPLE_MEDIA_TYPE_CAPS	           (purple_media_caps_get_type())
+#define PURPLE_MEDIA_TYPE_INFO_TYPE	   (purple_media_info_type_get_type())
+#define PURPLE_TYPE_MEDIA_NETWORK_PROTOCOL (purple_media_network_protocol_get_type())
+#define PURPLE_TYPE_MEDIA_SESSION_TYPE     (purple_media_session_type_get_type())
+#define PURPLE_MEDIA_TYPE_STATE            (purple_media_state_changed_get_type())
+
+/** Media candidate types */
+typedef enum {
+	PURPLE_MEDIA_CANDIDATE_TYPE_HOST,
+	PURPLE_MEDIA_CANDIDATE_TYPE_SRFLX,
+	PURPLE_MEDIA_CANDIDATE_TYPE_PRFLX,
+	PURPLE_MEDIA_CANDIDATE_TYPE_RELAY,
+	PURPLE_MEDIA_CANDIDATE_TYPE_MULTICAST,
+} PurpleMediaCandidateType;
+
+/** Media caps */
+typedef enum {
+	PURPLE_MEDIA_CAPS_NONE = 0,
+	PURPLE_MEDIA_CAPS_AUDIO = 1,
+	PURPLE_MEDIA_CAPS_AUDIO_SINGLE_DIRECTION = 1 << 1,
+	PURPLE_MEDIA_CAPS_VIDEO = 1 << 2,
+	PURPLE_MEDIA_CAPS_VIDEO_SINGLE_DIRECTION = 1 << 3,
+	PURPLE_MEDIA_CAPS_AUDIO_VIDEO = 1 << 4,
+	PURPLE_MEDIA_CAPS_MODIFY_SESSION = 1 << 5,
+	PURPLE_MEDIA_CAPS_CHANGE_DIRECTION = 1 << 6,
+} PurpleMediaCaps;
+
+/** Media component types */
+typedef enum {
+	PURPLE_MEDIA_COMPONENT_NONE = 0,
+	PURPLE_MEDIA_COMPONENT_RTP = 1,
+	PURPLE_MEDIA_COMPONENT_RTCP = 2,
+} PurpleMediaComponentType;
+
+/** Media info types */
+typedef enum {
+	PURPLE_MEDIA_INFO_HANGUP = 0,
+	PURPLE_MEDIA_INFO_ACCEPT,
+	PURPLE_MEDIA_INFO_REJECT,
+	PURPLE_MEDIA_INFO_MUTE,
+	PURPLE_MEDIA_INFO_UNMUTE,
+	PURPLE_MEDIA_INFO_PAUSE,
+	PURPLE_MEDIA_INFO_UNPAUSE,
+	PURPLE_MEDIA_INFO_HOLD,
+	PURPLE_MEDIA_INFO_UNHOLD,
+} PurpleMediaInfoType;
+
+/** Media network protocols */
+typedef enum {
+	PURPLE_MEDIA_NETWORK_PROTOCOL_UDP,
+	PURPLE_MEDIA_NETWORK_PROTOCOL_TCP,
+} PurpleMediaNetworkProtocol;
+
+/** Media session types */
+typedef enum {
+	PURPLE_MEDIA_NONE	= 0,
+	PURPLE_MEDIA_RECV_AUDIO = 1 << 0,
+	PURPLE_MEDIA_SEND_AUDIO = 1 << 1,
+	PURPLE_MEDIA_RECV_VIDEO = 1 << 2,
+	PURPLE_MEDIA_SEND_VIDEO = 1 << 3,
+	PURPLE_MEDIA_AUDIO = PURPLE_MEDIA_RECV_AUDIO | PURPLE_MEDIA_SEND_AUDIO,
+	PURPLE_MEDIA_VIDEO = PURPLE_MEDIA_RECV_VIDEO | PURPLE_MEDIA_SEND_VIDEO
+} PurpleMediaSessionType;
+
+/** Media state-changed types */
+typedef enum {
+	PURPLE_MEDIA_STATE_NEW = 0,
+	PURPLE_MEDIA_STATE_CONNECTED,
+	PURPLE_MEDIA_STATE_END,
+} PurpleMediaState;
+
+/**
+ * Gets the media candidate type's GType
+ *
+ * @return The media candidate type's GType.
+ *
+ * @since 2.6.0
+ */
+GType purple_media_candidate_type_get_type(void);
+
+/**
+ * Gets the type of the media caps flags
+ *
+ * @return The media caps flags' GType
+ *
+ * @since 2.7.0
+ */
+GType purple_media_caps_get_type(void);
+
+/**
+ * Gets the type of the info type enum
+ *
+ * @return The info type enum's GType
+ *
+ * @since 2.6.0
+ */
+GType purple_media_info_type_get_type(void);
+
+/**
+ * Gets the media network protocol's GType
+ *
+ * @return The media network protocol's GType.
+ *
+ * @since 2.6.0
+ */
+GType purple_media_network_protocol_get_type(void);
+
+/**
+ * Gets the media session type's GType
+ *
+ * @return The media session type's GType.
+ *
+ * @since 2.6.0
+ */
+GType purple_media_session_type_get_type(void);
+
+/**
+ * Gets the type of the state-changed enum
+ *
+ * @return The state-changed enum's GType
+ *
+ * @since 2.6.0
+ */
+GType purple_media_state_changed_get_type(void);
+
+G_END_DECLS
+
+#endif  /* _PURPLE_MEDIA_ENUM_TYPES_ */
--- a/libpurple/mediamanager.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/mediamanager.c	Sat Aug 06 03:45:56 2011 +0000
@@ -37,8 +37,8 @@
 #endif
 
 #ifdef USE_VV
+#include <media/backend-fs2.h>
 
-#include <gst/farsight/fs-conference-iface.h>
 #include <gst/farsight/fs-element-added-notifier.h>
 #include <gst/interfaces/xoverlay.h>
 
@@ -80,6 +80,8 @@
 	GList *elements;
 	GList *output_windows;
 	gulong next_output_window_id;
+	GType backend_type;
+	GstCaps *video_caps;
 
 	PurpleMediaElementInfo *video_src;
 	PurpleMediaElementInfo *video_sink;
@@ -100,6 +102,7 @@
 
 enum {
 	INIT_MEDIA,
+	UI_CAPS_CHANGED,
 	LAST_SIGNAL
 };
 static guint purple_media_manager_signals[LAST_SIGNAL] = {0};
@@ -138,7 +141,7 @@
 {
 	GObjectClass *gobject_class = (GObjectClass*)klass;
 	parent_class = g_type_class_peek_parent(klass);
-	
+
 	gobject_class->finalize = purple_media_manager_finalize;
 
 	purple_media_manager_signals[INIT_MEDIA] = g_signal_new ("init-media",
@@ -148,6 +151,15 @@
 		purple_smarshal_BOOLEAN__OBJECT_POINTER_STRING,
 		G_TYPE_BOOLEAN, 3, PURPLE_TYPE_MEDIA,
 		G_TYPE_POINTER, G_TYPE_STRING);
+
+	purple_media_manager_signals[UI_CAPS_CHANGED] = g_signal_new ("ui-caps-changed",
+		G_TYPE_FROM_CLASS (klass),
+		G_SIGNAL_RUN_LAST,
+		0, NULL, NULL,
+		purple_smarshal_VOID__FLAGS_FLAGS,
+		G_TYPE_NONE, 2, PURPLE_MEDIA_TYPE_CAPS,
+		PURPLE_MEDIA_TYPE_CAPS);
+
 	g_type_class_add_private(klass, sizeof(PurpleMediaManagerPrivate));
 }
 
@@ -157,9 +169,13 @@
 	media->priv = PURPLE_MEDIA_MANAGER_GET_PRIVATE(media);
 	media->priv->medias = NULL;
 	media->priv->next_output_window_id = 1;
+#ifdef USE_VV
+	media->priv->backend_type = PURPLE_TYPE_MEDIA_BACKEND_FS2;
+#endif
 
 	purple_prefs_add_none("/purple/media");
 	purple_prefs_add_none("/purple/media/audio");
+	purple_prefs_add_int("/purple/media/audio/silence_threshold", 5);
 	purple_prefs_add_none("/purple/media/audio/volume");
 	purple_prefs_add_int("/purple/media/audio/volume/input", 10);
 	purple_prefs_add_int("/purple/media/audio/volume/output", 10);
@@ -177,6 +193,8 @@
 			g_list_delete_link(priv->elements, priv->elements)) {
 		g_object_unref(priv->elements->data);
 	}
+	if (priv->video_caps)
+		gst_caps_unref(priv->video_caps);
 	parent_class->finalize(media);
 }
 #endif
@@ -304,34 +322,15 @@
 {
 #ifdef USE_VV
 	PurpleMedia *media;
-	FsConference *conference = FS_CONFERENCE(gst_element_factory_make(conference_type, NULL));
-	GstStateChangeReturn ret;
 	gboolean signal_ret;
 
-	if (conference == NULL) {
-		purple_conv_present_error(remote_user, account,
-					  _("Error creating conference."));
-		purple_debug_error("media", "Conference == NULL\n");
-		return NULL;
-	}
-
 	media = PURPLE_MEDIA(g_object_new(purple_media_get_type(),
 			     "manager", manager,
 			     "account", account,
-			     "conference", conference,
+			     "conference-type", conference_type,
 			     "initiator", initiator,
 			     NULL));
 
-	ret = gst_element_set_state(GST_ELEMENT(conference), GST_STATE_PLAYING);
-
-	if (ret == GST_STATE_CHANGE_FAILURE) {
-		purple_conv_present_error(remote_user, account,
-					  _("Error creating conference."));
-		purple_debug_error("media", "Failed to start conference.\n");
-		g_object_unref(media);
-		return NULL;
-	}
-
 	g_signal_emit(manager, purple_media_manager_signals[INIT_MEDIA], 0,
 			media, account, remote_user, &signal_ret);
 
@@ -402,6 +401,7 @@
 	GstIteratorResult result;
 
 	gst_element_release_request_pad(GST_ELEMENT_PARENT(pad), pad);
+
 	iter = gst_element_iterate_src_pads(parent);
 
 	result = gst_iterator_next(iter, (gpointer)&remaining_pad);
@@ -419,6 +419,43 @@
 #endif
 
 #ifdef USE_GSTREAMER
+
+void
+purple_media_manager_set_video_caps(PurpleMediaManager *manager, GstCaps *caps)
+{
+#ifdef USE_VV
+	if (manager->priv->video_caps)
+		gst_caps_unref(manager->priv->video_caps);
+
+	manager->priv->video_caps = caps;
+
+	if (manager->priv->pipeline && manager->priv->video_src) {
+		gchar *id = purple_media_element_info_get_id(manager->priv->video_src);
+		GstElement *src = gst_bin_get_by_name(GST_BIN(manager->priv->pipeline), id);
+
+		if (src) {
+			GstElement *capsfilter = gst_bin_get_by_name(GST_BIN(src), "prpl_video_caps");
+			g_object_set(G_OBJECT(capsfilter), "caps", caps, NULL);
+		}
+
+		g_free(id);
+	}
+#endif
+}
+
+GstCaps *
+purple_media_manager_get_video_caps(PurpleMediaManager *manager)
+{
+#ifdef USE_VV
+	if (manager->priv->video_caps == NULL)
+		manager->priv->video_caps = gst_caps_from_string("video/x-raw-yuv,"
+			"width=[250,352], height=[200,288], framerate=[1/1,20/1]");
+	return manager->priv->video_caps;
+#else
+	return NULL;
+#endif
+}
+
 GstElement *
 purple_media_manager_get_element(PurpleMediaManager *manager,
 		PurpleMediaSessionType type, PurpleMedia *media,
@@ -461,7 +498,21 @@
 			bin = gst_bin_new(id);
 			tee = gst_element_factory_make("tee", "tee");
 			gst_bin_add_many(GST_BIN(bin), ret, tee, NULL);
-			gst_element_link(ret, tee);
+
+			if (type & PURPLE_MEDIA_SEND_VIDEO) {
+				GstElement *videoscale;
+				GstElement *capsfilter;
+
+				videoscale = gst_element_factory_make("videoscale", NULL);
+				capsfilter = gst_element_factory_make("capsfilter", "prpl_video_caps");
+
+				g_object_set(G_OBJECT(capsfilter),
+					"caps", purple_media_manager_get_video_caps(manager), NULL);
+
+				gst_bin_add_many(GST_BIN(bin), videoscale, capsfilter, NULL);
+				gst_element_link_many(ret, videoscale, capsfilter, tee, NULL);
+			} else
+				gst_element_link(ret, tee);
 
 			/*
 			 * This shouldn't be necessary, but it stops it from
@@ -894,8 +945,17 @@
 		PurpleMediaCaps caps)
 {
 #ifdef USE_VV
+	PurpleMediaCaps oldcaps;
+
 	g_return_if_fail(PURPLE_IS_MEDIA_MANAGER(manager));
+
+	oldcaps = manager->priv->ui_caps;
 	manager->priv->ui_caps = caps;
+
+	if (caps != oldcaps)
+		g_signal_emit(manager,
+				purple_media_manager_signals[UI_CAPS_CHANGED],
+				0, caps, oldcaps);
 #endif
 }
 
@@ -911,6 +971,30 @@
 #endif
 }
 
+void
+purple_media_manager_set_backend_type(PurpleMediaManager *manager,
+		GType backend_type)
+{
+#ifdef USE_VV
+	g_return_if_fail(PURPLE_IS_MEDIA_MANAGER(manager));
+
+	manager->priv->backend_type = backend_type;
+#endif
+}
+
+GType
+purple_media_manager_get_backend_type(PurpleMediaManager *manager)
+{
+#ifdef USE_VV
+	g_return_val_if_fail(PURPLE_IS_MEDIA_MANAGER(manager),
+			PURPLE_MEDIA_CAPS_NONE);
+
+	return manager->priv->backend_type;
+#else
+	return G_TYPE_NONE;
+#endif
+}
+
 #ifdef USE_GSTREAMER
 
 /*
@@ -1042,7 +1126,7 @@
 		case PROP_CREATE_CB:
 			priv->create = g_value_get_pointer(value);
 			break;
-		default:	
+		default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID(
 					object, prop_id, pspec);
 			break;
@@ -1055,7 +1139,7 @@
 {
 	PurpleMediaElementInfoPrivate *priv;
 	g_return_if_fail(PURPLE_IS_MEDIA_ELEMENT_INFO(object));
-	
+
 	priv = PURPLE_MEDIA_ELEMENT_INFO_GET_PRIVATE(object);
 
 	switch (prop_id) {
@@ -1071,7 +1155,7 @@
 		case PROP_CREATE_CB:
 			g_value_set_pointer(value, priv->create);
 			break;
-		default:	
+		default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID(
 					object, prop_id, pspec);
 			break;
@@ -1082,7 +1166,7 @@
 purple_media_element_info_class_init(PurpleMediaElementInfoClass *klass)
 {
 	GObjectClass *gobject_class = (GObjectClass*)klass;
-	
+
 	gobject_class->finalize = purple_media_element_info_finalize;
 	gobject_class->set_property = purple_media_element_info_set_property;
 	gobject_class->get_property = purple_media_element_info_get_property;
--- a/libpurple/mediamanager.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/mediamanager.h	Sat Aug 06 03:45:56 2011 +0000
@@ -213,6 +213,28 @@
  */
 PurpleMediaCaps purple_media_manager_get_ui_caps(PurpleMediaManager *manager);
 
+/**
+ * Sets which media backend type media objects will use.
+ *
+ * @param manager The manager to set the caps on.
+ * @param backend_type The media backend type to use.
+ *
+ * @since 2.7.0
+ */
+void purple_media_manager_set_backend_type(PurpleMediaManager *manager,
+		GType backend_type);
+
+/**
+ * Gets which media backend type media objects will use.
+ *
+ * @param manager The manager to get the media backend type from.
+ *
+ * @return The type of media backend type media objects will use.
+ *
+ * @since 2.7.0
+ */
+GType purple_media_manager_get_backend_type(PurpleMediaManager *manager);
+
 /*}@*/
 
 #ifdef __cplusplus
--- a/libpurple/mime.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/mime.c	Sat Aug 06 03:45:56 2011 +0000
@@ -436,6 +436,34 @@
 	g_free(bnd);
 }
 
+#define BOUNDARY "boundary="
+static char *
+parse_boundary(const char *ct)
+{
+	char *boundary_begin = g_strstr_len(ct, -1, BOUNDARY);
+	char *boundary_end;
+
+	if (!boundary_begin)
+		return NULL;
+
+	boundary_begin += sizeof(BOUNDARY) - 1;
+
+	if (*boundary_begin == '"') {
+		boundary_end = strchr(++boundary_begin, '"');
+		if (!boundary_end)
+			return NULL;
+	} else {
+		boundary_end = strchr(boundary_begin, ' ');
+		if (!boundary_end) {
+			boundary_end = strchr(boundary_begin, ';');
+			if (!boundary_end)
+				boundary_end = boundary_begin + strlen(boundary_begin);
+		}
+	}
+
+	return g_strndup(boundary_begin, boundary_end - boundary_begin);
+}
+#undef BOUNDARY
 
 PurpleMimeDocument *
 purple_mime_document_parsen(const char *buf, gsize len)
@@ -456,10 +484,11 @@
 
 	{
 		const char *ct = fields_get(&doc->fields, "content-type");
-		if(ct && purple_str_has_prefix(ct, "multipart")) {
-			char *bd = strrchr(ct, '=');
-			if(bd++) {
+		if (ct && purple_str_has_prefix(ct, "multipart")) {
+			char *bd = parse_boundary(ct);
+			if (bd) {
 				doc_parts_load(doc, bd, b, n);
+				g_free(bd);
 			}
 		}
 	}
--- a/libpurple/network.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/network.c	Sat Aug 06 03:45:56 2011 +0000
@@ -32,6 +32,9 @@
 #include <netinet/in.h>
 #include <net/if.h>
 #include <sys/ioctl.h>
+#ifdef HAVE_GETIFADDRS
+#include <ifaddrs.h>
+#endif
 #else
 #include <nspapi.h>
 #endif
@@ -68,6 +71,10 @@
 #include <dbus/dbus-glib.h>
 #include <NetworkManager.h>
 
+#if !defined(NM_CHECK_VERSION)
+#define NM_CHECK_VERSION(x,y,z) 0
+#endif
+
 static DBusGConnection *nm_conn = NULL;
 static DBusGProxy *nm_proxy = NULL;
 static DBusGProxy *dbus_proxy = NULL;
@@ -95,6 +102,7 @@
 	PurpleNetworkListenCallback cb;
 	gpointer cb_data;
 	UPnPMappingAddRemove *mapping_data;
+	int timer;
 };
 
 #ifdef HAVE_NETWORKMANAGER
@@ -160,7 +168,7 @@
 	struct ifconf ifc;
 	struct ifreq *ifr;
 	struct sockaddr_in *sinptr;
-	guint32 lhost = htonl(127 * 256 * 256 * 256 + 1);
+	guint32 lhost = htonl((127 << 24) + 1); /* 127.0.0.1 */
 	long unsigned int add;
 	int source = fd;
 
@@ -200,6 +208,85 @@
 	return "0.0.0.0";
 }
 
+GList *
+purple_network_get_all_local_system_ips(void)
+{
+#if defined(HAVE_GETIFADDRS) && defined(HAVE_INET_NTOP)
+	GList *result = NULL;
+	struct ifaddrs *start, *ifa;
+	int ret;
+
+	ret = getifaddrs(&start);
+	if (ret < 0) {
+		purple_debug_warning("network",
+				"getifaddrs() failed: %s\n", g_strerror(errno));
+		return NULL;
+	}
+
+	for (ifa = start; ifa; ifa = ifa->ifa_next) {
+		int family = ifa->ifa_addr ? ifa->ifa_addr->sa_family : AF_UNSPEC;
+		char host[INET6_ADDRSTRLEN];
+		const char *tmp = NULL;
+
+		if ((family != AF_INET && family != AF_INET6) || ifa->ifa_flags & IFF_LOOPBACK)
+			continue;
+
+		if (family == AF_INET)
+			tmp = inet_ntop(family, &((struct sockaddr_in *)ifa->ifa_addr)->sin_addr, host, sizeof(host));
+		else {
+			struct sockaddr_in6 *sockaddr = (struct sockaddr_in6 *)ifa->ifa_addr;
+			/* Peer-peer link-local communication is a big TODO.  I am not sure
+			 * how communicating link-local addresses is supposed to work, and
+			 * it seems like it would require attempting the cartesian product
+			 * of the local and remote interfaces to see if any match (eww).
+			 */
+			if (!IN6_IS_ADDR_LINKLOCAL(&sockaddr->sin6_addr))
+				tmp = inet_ntop(family, &sockaddr->sin6_addr, host, sizeof(host));
+		}
+		if (tmp != NULL)
+			result = g_list_prepend(result, g_strdup(tmp));
+	}
+
+	freeifaddrs(start);
+
+	return g_list_reverse(result);
+#else /* HAVE_GETIFADDRS && HAVE_INET_NTOP */
+	GList *result = NULL;
+	int source = socket(PF_INET,SOCK_STREAM, 0);
+	char buffer[1024];
+	char *tmp;
+	struct ifconf ifc;
+	struct ifreq *ifr;
+
+	ifc.ifc_len = sizeof(buffer);
+	ifc.ifc_req = (struct ifreq *)buffer;
+	ioctl(source, SIOCGIFCONF, &ifc);
+	close(source);
+
+	tmp = buffer;
+	while (tmp < buffer + ifc.ifc_len) {
+		char dst[INET_ADDRSTRLEN];
+
+		ifr = (struct ifreq *)tmp;
+		tmp += HX_SIZE_OF_IFREQ(*ifr);
+
+		if (ifr->ifr_addr.sa_family == AF_INET) {
+			struct sockaddr_in *sinptr = (struct sockaddr_in *)&ifr->ifr_addr;
+
+			inet_ntop(AF_INET, &sinptr->sin_addr, dst,
+				sizeof(dst));
+			purple_debug_info("network",
+				"found local i/f with address %s on IPv4\n", dst);
+			if (!purple_strequal(dst, "127.0.0.1")) {
+				result = g_list_append(result, g_strdup(dst));
+			}
+		}
+	}
+
+	return result;
+#endif /* HAVE_GETIFADDRS && HAVE_INET_NTOP */
+}
+
 const char *
 purple_network_get_my_ip(int fd)
 {
@@ -267,17 +354,15 @@
 
 	if (success) {
 		/* add port mapping to hash table */
-		gint *key = g_new(gint, 1);
-		gint *value = g_new(gint, 1);
-		*key = purple_network_get_port_from_fd(listen_data->listenfd);
-		*value = listen_data->socket_type;
-		g_hash_table_insert(upnp_port_mappings, key, value);
+		gint key = purple_network_get_port_from_fd(listen_data->listenfd);
+		gint value = listen_data->socket_type;
+		g_hash_table_insert(upnp_port_mappings, GINT_TO_POINTER(key), GINT_TO_POINTER(value));
 	}
 
 	if (listen_data->cb)
 		listen_data->cb(listen_data->listenfd, listen_data->cb_data);
 
-	/* Clear the UPnP mapping data, since it's complete and purple_netweork_listen_cancel() will try to cancel
+	/* Clear the UPnP mapping data, since it's complete and purple_network_listen_cancel() will try to cancel
 	 * it otherwise. */
 	listen_data->mapping_data = NULL;
 	purple_network_listen_cancel(listen_data);
@@ -287,15 +372,16 @@
 purple_network_finish_pmp_map_cb(gpointer data)
 {
 	PurpleNetworkListenData *listen_data;
-	gint *key = g_new(gint, 1);
-	gint *value = g_new(gint, 1);
+	gint key;
+	gint value;
 
 	listen_data = data;
+	listen_data->timer = 0;
 
 	/* add port mapping to hash table */
-	*key = purple_network_get_port_from_fd(listen_data->listenfd);
-	*value = listen_data->socket_type;
-	g_hash_table_insert(nat_pmp_port_mappings, key, value);
+	key = purple_network_get_port_from_fd(listen_data->listenfd);
+	value = listen_data->socket_type;
+	g_hash_table_insert(nat_pmp_port_mappings, GINT_TO_POINTER(key), GINT_TO_POINTER(value));
 
 	if (listen_data->cb)
 		listen_data->cb(listen_data->listenfd, listen_data->cb_data);
@@ -312,7 +398,7 @@
 }
 
 static PurpleNetworkListenData *
-purple_network_do_listen(unsigned short port, int socket_type, PurpleNetworkListenCallback cb, gpointer cb_data)
+purple_network_do_listen(unsigned short port, int socket_family, int socket_type, PurpleNetworkListenCallback cb, gpointer cb_data)
 {
 	int listenfd = -1;
 	int flags;
@@ -330,7 +416,7 @@
 	g_snprintf(serv, sizeof(serv), "%hu", port);
 	memset(&hints, 0, sizeof(struct addrinfo));
 	hints.ai_flags = AI_PASSIVE;
-	hints.ai_family = AF_UNSPEC;
+	hints.ai_family = socket_family;
 	hints.ai_socktype = socket_type;
 	errnum = getaddrinfo(NULL /* any IP */, serv, &hints, &res);
 	if (errnum != 0) {
@@ -354,7 +440,7 @@
 		if (listenfd < 0)
 			continue;
 		if (setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) != 0)
-			purple_debug_warning("network", "setsockopt: %s\n", g_strerror(errno));
+			purple_debug_warning("network", "setsockopt(SO_REUSEADDR): %s\n", g_strerror(errno));
 		if (bind(listenfd, next->ai_addr, next->ai_addrlen) == 0)
 			break; /* success */
 		/* XXX - It is unclear to me (datallah) whether we need to be
@@ -369,6 +455,13 @@
 #else
 	struct sockaddr_in sockin;
 
+	if (socket_family != AF_INET && socket_family != AF_UNSPEC) {
+		purple_debug_warning("network", "Address family %d only "
+		                     "supported when built with getaddrinfo() "
+		                     "support\n", socket_family);
+		return NULL;
+	}
+
 	if ((listenfd = socket(AF_INET, socket_type, 0)) < 0) {
 		purple_debug_warning("network", "socket: %s\n", g_strerror(errno));
 		return NULL;
@@ -410,11 +503,12 @@
 	listen_data->cb_data = cb_data;
 	listen_data->socket_type = socket_type;
 
-	if (!listen_map_external || !purple_prefs_get_bool("/purple/network/map_ports"))
+	if (!purple_socket_speaks_ipv4(listenfd) || !listen_map_external ||
+			!purple_prefs_get_bool("/purple/network/map_ports"))
 	{
 		purple_debug_info("network", "Skipping external port mapping.\n");
 		/* The pmp_map_cb does what we want to do */
-		purple_timeout_add(0, purple_network_finish_pmp_map_cb, listen_data);
+		listen_data->timer = purple_timeout_add(0, purple_network_finish_pmp_map_cb, listen_data);
 	}
 	/* Attempt a NAT-PMP Mapping, which will return immediately */
 	else if (purple_pmp_create_map(((socket_type == SOCK_STREAM) ? PURPLE_PMP_TYPE_TCP : PURPLE_PMP_TYPE_UDP),
@@ -422,7 +516,7 @@
 	{
 		purple_debug_info("network", "Created NAT-PMP mapping on port %i\n", actual_port);
 		/* We want to return listen_data now, and on the next run loop trigger the cb and destroy listen_data */
-		purple_timeout_add(0, purple_network_finish_pmp_map_cb, listen_data);
+		listen_data->timer = purple_timeout_add(0, purple_network_finish_pmp_map_cb, listen_data);
 	}
 	else
 	{
@@ -437,17 +531,29 @@
 }
 
 PurpleNetworkListenData *
-purple_network_listen(unsigned short port, int socket_type,
-		PurpleNetworkListenCallback cb, gpointer cb_data)
+purple_network_listen_family(unsigned short port, int socket_family,
+                             int socket_type, PurpleNetworkListenCallback cb,
+                             gpointer cb_data)
 {
 	g_return_val_if_fail(port != 0, NULL);
 
-	return purple_network_do_listen(port, socket_type, cb, cb_data);
+	return purple_network_do_listen(port, socket_family, socket_type,
+	                                cb, cb_data);
 }
 
 PurpleNetworkListenData *
-purple_network_listen_range(unsigned short start, unsigned short end,
-		int socket_type, PurpleNetworkListenCallback cb, gpointer cb_data)
+purple_network_listen(unsigned short port, int socket_type,
+		PurpleNetworkListenCallback cb, gpointer cb_data)
+{
+	return purple_network_listen_family(port, AF_UNSPEC, socket_type,
+	                                    cb, cb_data);
+}
+
+PurpleNetworkListenData *
+purple_network_listen_range_family(unsigned short start, unsigned short end,
+                                   int socket_family, int socket_type,
+                                   PurpleNetworkListenCallback cb,
+                                   gpointer cb_data)
 {
 	PurpleNetworkListenData *ret = NULL;
 
@@ -460,7 +566,7 @@
 	}
 
 	for (; start <= end; start++) {
-		ret = purple_network_do_listen(start, socket_type, cb, cb_data);
+		ret = purple_network_do_listen(start, AF_UNSPEC, socket_type, cb, cb_data);
 		if (ret != NULL)
 			break;
 	}
@@ -468,11 +574,23 @@
 	return ret;
 }
 
+PurpleNetworkListenData *
+purple_network_listen_range(unsigned short start, unsigned short end,
+                            int socket_type, PurpleNetworkListenCallback cb,
+                            gpointer cb_data)
+{
+	return purple_network_listen_range_family(start, end, AF_UNSPEC,
+	                                          socket_type, cb, cb_data);
+}
+
 void purple_network_listen_cancel(PurpleNetworkListenData *listen_data)
 {
 	if (listen_data->mapping_data != NULL)
 		purple_upnp_cancel_port_mapping(listen_data->mapping_data);
 
+	if (listen_data->timer > 0)
+		purple_timeout_remove(listen_data->timer);
+
 	g_free(listen_data);
 }
 
@@ -577,7 +695,7 @@
 
 static gboolean _print_debug_msg(gpointer data) {
 	gchar *msg = data;
-	purple_debug_warning("network", msg);
+	purple_debug_warning("network", "%s", msg);
 	g_free(msg);
 	return FALSE;
 }
@@ -749,7 +867,13 @@
 
 	switch(state)
 	{
+#if NM_CHECK_VERSION(0,8,992)
+		case NM_STATE_CONNECTED_LOCAL:
+		case NM_STATE_CONNECTED_SITE:
+		case NM_STATE_CONNECTED_GLOBAL:
+#else
 		case NM_STATE_CONNECTED:
+#endif
 			/* Call res_init in case DNS servers have changed */
 			res_init();
 			/* update STUN IP in case we it changed (theoretically we could
@@ -759,13 +883,16 @@
 				purple_prefs_get_string("/purple/network/stun_server"));
 			purple_network_set_turn_server(
 				purple_prefs_get_string("/purple/network/turn_server"));
-			
+
 			if (ui_ops != NULL && ui_ops->network_connected != NULL)
 				ui_ops->network_connected();
 			break;
 		case NM_STATE_ASLEEP:
 		case NM_STATE_CONNECTING:
 		case NM_STATE_DISCONNECTED:
+#if NM_CHECK_VERSION(0,8,992)
+		case NM_STATE_DISCONNECTING:
+#endif
 			if (prev != NM_STATE_CONNECTED && prev != NM_STATE_UNKNOWN)
 				break;
 			if (ui_ops != NULL && ui_ops->network_disconnected != NULL)
@@ -822,10 +949,10 @@
 #endif
 
 static void
-purple_network_ip_lookup_cb(GSList *hosts, gpointer data, 
+purple_network_ip_lookup_cb(GSList *hosts, gpointer data,
 	const char *error_message)
 {
-	const gchar **ip = (const gchar **) data; 
+	const gchar **ip = (const gchar **) data;
 
 	if (error_message) {
 		purple_debug_error("network", "lookup of IP address failed: %s\n",
@@ -835,14 +962,14 @@
 	}
 
 	if (hosts && g_slist_next(hosts)) {
-		struct sockaddr *addr = g_slist_next(hosts)->data; 
+		struct sockaddr *addr = g_slist_next(hosts)->data;
 		char dst[INET6_ADDRSTRLEN];
-		
+
 		if (addr->sa_family == AF_INET6) {
-			inet_ntop(addr->sa_family, &((struct sockaddr_in6 *) addr)->sin6_addr, 
+			inet_ntop(addr->sa_family, &((struct sockaddr_in6 *) addr)->sin6_addr,
 				dst, sizeof(dst));
 		} else {
-			inet_ntop(addr->sa_family, &((struct sockaddr_in *) addr)->sin_addr, 
+			inet_ntop(addr->sa_family, &((struct sockaddr_in *) addr)->sin_addr,
 				dst, sizeof(dst));
 		}
 
@@ -864,10 +991,10 @@
 	if (stun_server && stun_server[0] != '\0') {
 		if (purple_network_is_available()) {
 			purple_debug_info("network", "running DNS query for STUN server\n");
-			purple_dnsquery_a(stun_server, 3478, purple_network_ip_lookup_cb,
+			purple_dnsquery_a_account(NULL, stun_server, 3478, purple_network_ip_lookup_cb,
 				&stun_ip);
 		} else {
-			purple_debug_info("network", 
+			purple_debug_info("network",
 				"network is unavailable, don't try to update STUN IP");
 		}
 	} else if (stun_ip) {
@@ -882,11 +1009,11 @@
 	if (turn_server && turn_server[0] != '\0') {
 		if (purple_network_is_available()) {
 			purple_debug_info("network", "running DNS query for TURN server\n");
-			purple_dnsquery_a(turn_server, 
-				purple_prefs_get_int("/purple/network/turn_port"), 
+			purple_dnsquery_a_account(NULL, turn_server,
+				purple_prefs_get_int("/purple/network/turn_port"),
 				purple_network_ip_lookup_cb, &turn_ip);
 		} else {
-			purple_debug_info("network", 
+			purple_debug_info("network",
 				"network is unavailable, don't try to update TURN IP");
 		}
 	} else if (turn_ip) {
@@ -929,44 +1056,42 @@
 purple_network_upnp_mapping_remove(gpointer key, gpointer value,
 	gpointer user_data)
 {
-	gint port = (gint) *((gint *) key);
-	gint protocol = (gint) *((gint *) value);
+	gint port = GPOINTER_TO_INT(key);
+	gint protocol = GPOINTER_TO_INT(value);
 	purple_debug_info("network", "removing UPnP port mapping for port %d\n",
 		port);
-	purple_upnp_remove_port_mapping(port, 
-		protocol == SOCK_STREAM ? "TCP" : "UDP", 
+	purple_upnp_remove_port_mapping(port,
+		protocol == SOCK_STREAM ? "TCP" : "UDP",
 		purple_network_upnp_mapping_remove_cb, NULL);
-	g_hash_table_remove(upnp_port_mappings, key);
+	g_hash_table_remove(upnp_port_mappings, GINT_TO_POINTER(port));
 }
 
 static void
 purple_network_nat_pmp_mapping_remove(gpointer key, gpointer value,
 	gpointer user_data)
 {
-	gint port = (gint) *((gint *) key);
-	gint protocol = (gint) *((gint *) value);
+	gint port = GPOINTER_TO_INT(key);
+	gint protocol = GPOINTER_TO_INT(value);
 	purple_debug_info("network", "removing NAT-PMP port mapping for port %d\n",
 		port);
 	purple_pmp_destroy_map(
-		protocol == SOCK_STREAM ? PURPLE_PMP_TYPE_TCP : PURPLE_PMP_TYPE_UDP, 
+		protocol == SOCK_STREAM ? PURPLE_PMP_TYPE_TCP : PURPLE_PMP_TYPE_UDP,
 		port);
-	g_hash_table_remove(nat_pmp_port_mappings, key);
+	g_hash_table_remove(nat_pmp_port_mappings, GINT_TO_POINTER(port));
 }
 
 void
 purple_network_remove_port_mapping(gint fd)
 {
 	int port = purple_network_get_port_from_fd(fd);
-	gint *protocol = g_hash_table_lookup(upnp_port_mappings, &port);
+	gint protocol = GPOINTER_TO_INT(g_hash_table_lookup(upnp_port_mappings, GINT_TO_POINTER(port)));
 
 	if (protocol) {
-		purple_network_upnp_mapping_remove(&port, protocol, NULL);
-		g_hash_table_remove(upnp_port_mappings, protocol);
+		purple_network_upnp_mapping_remove(GINT_TO_POINTER(port), GINT_TO_POINTER(protocol), NULL);
 	} else {
-		protocol = g_hash_table_lookup(nat_pmp_port_mappings, &port);
+		protocol = GPOINTER_TO_INT(g_hash_table_lookup(nat_pmp_port_mappings, GINT_TO_POINTER(port)));
 		if (protocol) {
-			purple_network_nat_pmp_mapping_remove(&port, protocol, NULL);
-			g_hash_table_remove(nat_pmp_port_mappings, protocol);
+			purple_network_nat_pmp_mapping_remove(GINT_TO_POINTER(port), GINT_TO_POINTER(protocol), NULL);
 		}
 	}
 }
@@ -1024,6 +1149,7 @@
 	purple_prefs_add_string("/purple/network/stun_server", "");
 	purple_prefs_add_string("/purple/network/turn_server", "");
 	purple_prefs_add_int   ("/purple/network/turn_port", 3478);
+	purple_prefs_add_int	 ("/purple/network/turn_port_tcp", 3478);
 	purple_prefs_add_string("/purple/network/turn_username", "");
 	purple_prefs_add_string("/purple/network/turn_password", "");
 	purple_prefs_add_bool  ("/purple/network/auto_ip", TRUE);
@@ -1064,16 +1190,14 @@
 
 	purple_pmp_init();
 	purple_upnp_init();
-	
+
 	purple_network_set_stun_server(
 		purple_prefs_get_string("/purple/network/stun_server"));
 	purple_network_set_turn_server(
 		purple_prefs_get_string("/purple/network/turn_server"));
 
-	upnp_port_mappings = 
-		g_hash_table_new_full(g_int_hash, g_int_equal, g_free, g_free);
-	nat_pmp_port_mappings =
-		g_hash_table_new_full(g_int_hash, g_int_equal, g_free, g_free);
+	upnp_port_mappings = g_hash_table_new(g_direct_hash, g_direct_equal);
+	nat_pmp_port_mappings = g_hash_table_new(g_direct_hash, g_direct_equal);
 }
 
 
@@ -1117,13 +1241,13 @@
 #endif
 	purple_signal_unregister(purple_network_get_handle(),
 							 "network-configuration-changed");
-	
+
 	if (stun_ip)
 		g_free(stun_ip);
 
 	g_hash_table_destroy(upnp_port_mappings);
 	g_hash_table_destroy(nat_pmp_port_mappings);
 
-	/* TODO: clean up remaining port mappings, note calling 
+	/* TODO: clean up remaining port mappings, note calling
 	 purple_upnp_remove_port_mapping from here doesn't quite work... */
 }
--- a/libpurple/network.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/network.h	Sat Aug 06 03:45:56 2011 +0000
@@ -88,6 +88,17 @@
 const char *purple_network_get_local_system_ip(int fd);
 
 /**
+ * Returns all IP addresses of the local system.
+ *
+ * @note The caller must free this list.  If libpurple was built with
+ *       support for it, this function also enumerates IPv6 addresses.
+ * @since 2.7.0
+ *
+ * @return A list of local IP addresses.
+ */
+GList *purple_network_get_all_local_system_ips(void);
+
+/**
  * Returns the IP address that should be used anywhere a
  * public IP addresses is needed (listening for an incoming
  * file transfer, etc).
@@ -112,8 +123,8 @@
  * The default value is TRUE
  *
  * @param map_external Should the open port be mapped externally?
- * @deprecated In 3.0.0 a boolean will be added to the above functions to
- *             perform the same function.
+ * @deprecated In 3.0.0 a boolean will be added to the functions mentioned
+ *             above to perform the same function.
  * @since 2.3.0
  */
 void purple_network_listen_map_external(gboolean map_external);
@@ -127,8 +138,8 @@
  *
  * This opens a listening port. The caller will want to set up a watcher
  * of type PURPLE_INPUT_READ on the fd returned in cb. It will probably call
- * accept in the watcher callback, and then possibly remove the watcher and close
- * the listening socket, and add a new watcher on the new socket accept
+ * accept in the watcher callback, and then possibly remove the watcher and
+ * close the listening socket, and add a new watcher on the new socket accept
  * returned.
  *
  * @param port The port number to bind to.  Must be greater than 0.
@@ -147,6 +158,27 @@
 		int socket_type, PurpleNetworkListenCallback cb, gpointer cb_data);
 
 /**
+ * \copydoc purple_network_listen
+ *
+ * Libpurple does not currently do any port mapping (stateful firewall hole
+ * poking) for IPv6-only listeners (if an IPv6 socket supports v4-mapped
+ * addresses, a mapping is done).
+ *
+ * @param socket_family The protocol family of the socket.  This should be
+ *                      AF_INET for IPv4 or AF_INET6 for IPv6.  IPv6 sockets
+ *                      may or may not be able to accept IPv4 connections
+ *                      based on the system configuration (use
+ *                      purple_socket_speaks_ipv4 to check).  If an IPv6
+ *                      socket doesn't accept V4-mapped addresses, you will
+ *                      need a second listener to support both v4 and v6.
+ * @since 2.7.0
+ * @deprecated This function will be renamed to purple_network_listen in 3.0.0.
+ */
+PurpleNetworkListenData *purple_network_listen_family(unsigned short port,
+	int socket_family, int socket_type, PurpleNetworkListenCallback cb,
+	gpointer cb_data);
+
+/**
  * Opens a listening port selected from a range of ports.  The range of
  * ports used is chosen in the following manner:
  * If a range is specified in preferences, these values are used.
@@ -181,11 +213,33 @@
 		PurpleNetworkListenCallback cb, gpointer cb_data);
 
 /**
+ * \copydoc purple_network_listen_range
+ *
+ * Libpurple does not currently do any port mapping (stateful firewall hole
+ * poking) for IPv6-only listeners (if an IPv6 socket supports v4-mapped
+ * addresses, a mapping is done).
+ *
+ * @param socket_family The protocol family of the socket.  This should be
+ *                      AF_INET for IPv4 or AF_INET6 for IPv6.  IPv6 sockets
+ *                      may or may not be able to accept IPv4 connections
+ *                      based on the system configuration (use
+ *                      purple_socket_speaks_ipv4 to check).  If an IPv6
+ *                      socket doesn't accept V4-mapped addresses, you will
+ *                      need a second listener to support both v4 and v6.
+ * @since 2.7.0
+ * @deprecated This function will be renamed to purple_network_listen_range
+ *             in 3.0.0.
+ */
+PurpleNetworkListenData *purple_network_listen_range_family(
+	unsigned short start, unsigned short end, int socket_family,
+	int socket_type, PurpleNetworkListenCallback cb, gpointer cb_data);
+
+/**
  * This can be used to cancel any in-progress listener connection
  * by passing in the return value from either purple_network_listen()
  * or purple_network_listen_range().
  *
- * @param listen_data This listener attempt will be canceled and
+ * @param listen_data This listener attempt will be cancelled and
  *        the struct will be freed.
  */
 void purple_network_listen_cancel(PurpleNetworkListenData *listen_data);
@@ -225,15 +279,15 @@
  */
 void *purple_network_get_handle(void);
 
-/**	
+/**
  * Update the STUN server IP given the host name
  * Will result in a DNS query being executed asynchronous
- * 
+ *
  * @param stun_server The host name of the STUN server to set
  * @since 2.6.0
  */
 void purple_network_set_stun_server(const gchar *stun_server);
-	
+
 /**
  * Get the IP address of the STUN server as a string representation
  *
@@ -241,31 +295,31 @@
  * @since 2.6.0
  */
 const gchar *purple_network_get_stun_ip(void);
-	
-/**	
+
+/**
  * Update the TURN server IP given the host name
  * Will result in a DNS query being executed asynchronous
- * 
+ *
  * @param turn_server The host name of the TURN server to set
  * @since 2.6.0
  */
 void purple_network_set_turn_server(const gchar *turn_server);
-	
+
 /**
- * Get the IP address of the STUN server as a string representation
+ * Get the IP address of the TURN server as a string representation
  *
  * @return the IP address
  * @since 2.6.0
  */
 const gchar *purple_network_get_turn_ip(void);
-		
+
 /**
  * Remove a port mapping (UPnP or NAT-PMP) associated with listening socket
  *
  * @param fd Socket to remove the port mapping for
  * @since 2.6.0
  */
-void purple_network_remove_port_mapping(gint fd);	
+void purple_network_remove_port_mapping(gint fd);
 
 /**
  * Convert a UTF-8 domain name to ASCII in accordance with the IDNA
--- a/libpurple/notify.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/notify.c	Sat Aug 06 03:45:56 2011 +0000
@@ -602,6 +602,18 @@
 }
 
 void
+purple_notify_user_info_add_pair_plaintext(PurpleNotifyUserInfo *user_info, const char *label, const char *value)
+{
+	gchar *escaped;
+	PurpleNotifyUserInfoEntry *entry;
+
+	escaped = g_markup_escape_text(value, -1);
+	entry = purple_notify_user_info_entry_new(label, escaped);
+	g_free(escaped);
+	user_info->user_info_entries = g_list_append(user_info->user_info_entries, entry);
+}
+
+void
 purple_notify_user_info_prepend_pair(PurpleNotifyUserInfo *user_info, const char *label, const char *value)
 {
 	PurpleNotifyUserInfoEntry *entry;
--- a/libpurple/notify.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/notify.h	Sat Aug 06 03:45:56 2011 +0000
@@ -540,13 +540,28 @@
  *                   a colon.  If NULL, value will be displayed without a
  *                   label.
  * @param value      The value, which might be displayed by a UI after
- *                   the label.  If NULL, label will still be displayed;
- *                   the UI should then treat label as independent and not
+ *                   the label.  This should be valid HTML.  If you want
+ *                   to insert plaintext then use
+ *                   purple_notify_user_info_add_pair_plaintext(), instead.
+ *                   If this is NULL the label will still be displayed;
+ *                   the UI should treat label as independent and not
  *                   include a colon if it would otherwise.
  */
+/*
+ * TODO: In 3.0.0 this function should be renamed to
+ *       purple_notify_user_info_add_pair_html().  And optionally
+ *       purple_notify_user_info_add_pair_plaintext() could be renamed to
+ *       purple_notify_user_info_add_pair().
+ */
 void purple_notify_user_info_add_pair(PurpleNotifyUserInfo *user_info, const char *label, const char *value);
 
 /**
+ * Like purple_notify_user_info_add_pair, but value should be plaintext
+ * and will be escaped using g_markup_escape_text().
+ */
+void purple_notify_user_info_add_pair_plaintext(PurpleNotifyUserInfo *user_info, const char *label, const char *value);
+
+/**
  * Prepend a label/value pair to a PurpleNotifyUserInfo object
  *
  * @param user_info  The PurpleNotifyUserInfo
--- a/libpurple/ntlm.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/ntlm.c	Sat Aug 06 03:45:56 2011 +0000
@@ -152,9 +152,14 @@
 	static guint8 nonce[8];
 
 	tmsg = (struct type2_message*)purple_base64_decode(type2, &retlen);
-	memcpy(nonce, tmsg->nonce, 8);
-	if (flags != NULL)
-		*flags = GUINT16_FROM_LE(tmsg->flags);
+	if (tmsg != NULL && retlen >= (sizeof(struct type2_message) - 1)) {
+		memcpy(nonce, tmsg->nonce, 8);
+		if (flags != NULL)
+			*flags = GUINT16_FROM_LE(tmsg->flags);
+	} else {
+		purple_debug_error("ntlm", "Unable to parse type2 message - returning empty nonce.\n");
+		memset(nonce, 0, 8);
+	}
 	g_free(tmsg);
 
 	return nonce;
--- a/libpurple/plugin.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugin.c	Sat Aug 06 03:45:56 2011 +0000
@@ -254,11 +254,7 @@
 		 *
 		 * G_MODULE_BIND_LOCAL was added in glib 2.3.3.
 		 */
-#if GLIB_CHECK_VERSION(2,3,3)
 		plugin->handle = g_module_open(filename, G_MODULE_BIND_LOCAL);
-#else
-		plugin->handle = g_module_open(filename, 0);
-#endif
 
 		if (plugin->handle == NULL)
 		{
@@ -287,11 +283,7 @@
 				purple_debug_error("plugins", "%s is not loadable: %s\n",
 						 plugin->path, plugin->error);
 			}
-#if GLIB_CHECK_VERSION(2,3,3)
 			plugin->handle = g_module_open(filename, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
-#else
-			plugin->handle = g_module_open(filename, G_MODULE_BIND_LAZY);
-#endif
 
 			if (plugin->handle == NULL)
 			{
--- a/libpurple/plugins/Makefile.mingw	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/Makefile.mingw	Sat Aug 06 03:45:56 2011 +0000
@@ -55,7 +55,7 @@
 	$(MAKE) -C $(SSL_PLUGIN) -f $(MINGW_MAKEFILE) install
 	cp *.dll $(PURPLE_INSTALL_PLUGINS_DIR)
 
-.c.dll:
+%.dll: %.c $(PURPLE_CONFIG_H) $(PURPLE_VERSION_H)
 	$(CC) $(CFLAGS) $(DEFINES) $(INCLUDE_PATHS) -o $@.o -c $<
 	$(CC) -shared $@.o $(LIB_PATHS) $(LIBS) $(DLL_LD_FLAGS) -o $@
 
--- a/libpurple/plugins/autoaccept.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/autoaccept.c	Sat Aug 06 03:45:56 2011 +0000
@@ -28,13 +28,7 @@
 
 /* System headers */
 #include <glib.h>
-#if GLIB_CHECK_VERSION(2,6,0)
-#	include <glib/gstdio.h>
-#else
-#	include <sys/types.h>
-#	include <sys/stat.h>
-#	define	g_mkdir mkdir
-#endif
+#include <glib/gstdio.h>
 
 /* Purple headers */
 #include <plugin.h>
@@ -49,9 +43,12 @@
 
 #define PREF_PREFIX		"/plugins/core/" PLUGIN_ID
 #define PREF_PATH		PREF_PREFIX "/path"
-#define PREF_STRANGER	PREF_PREFIX "/reject_stranger"
+#define PREF_STRANGER	PREF_PREFIX "/stranger"
 #define PREF_NOTIFY		PREF_PREFIX "/notify"
 #define PREF_NEWDIR     PREF_PREFIX "/newdir"
+#define PREF_ESCAPE     PREF_PREFIX "/escape"
+
+#define PREF_STRANGER_OLD PREF_PREFIX "/reject_stranger"
 
 typedef enum
 {
@@ -94,25 +91,27 @@
 	char *filename;
 	char *dirname;
 
+    int accept_setting;
+
 	account = xfer->account;
 	node = PURPLE_BLIST_NODE(purple_find_buddy(account, xfer->who));
 
-	if (!node)
-	{
-		if (purple_prefs_get_bool(PREF_STRANGER))
-			xfer->status = PURPLE_XFER_STATUS_CANCEL_LOCAL;
-		return;
+	/* If person is on buddy list, use the buddy setting; otherwise, use the
+	   stranger setting. */
+	if (node) {
+		node = purple_blist_node_get_parent(node);
+		g_return_if_fail(PURPLE_BLIST_NODE_IS_CONTACT(node));
+		accept_setting = purple_blist_node_get_int(node, "autoaccept");
+	} else {
+		accept_setting = purple_prefs_get_int(PREF_STRANGER);
 	}
 
-	node = purple_blist_node_get_parent(node);
-	g_return_if_fail(PURPLE_BLIST_NODE_IS_CONTACT(node));
-
-	pref = purple_prefs_get_string(PREF_PATH);
-	switch (purple_blist_node_get_int(node, "autoaccept"))
+	switch (accept_setting)
 	{
 		case FT_ASK:
 			break;
 		case FT_ACCEPT:
+            pref = purple_prefs_get_string(PREF_PATH);
 			if (ensure_path_exists(pref))
 			{
 				int count = 1;
@@ -132,7 +131,12 @@
 					break;
 				}
 
-				escape = purple_escape_filename(xfer->filename);
+				/* Escape filename (if escaping is turned on) */
+				if (purple_prefs_get_bool(PREF_ESCAPE)) {
+					escape = purple_escape_filename(xfer->filename);
+				} else {
+					escape = xfer->filename;
+				}
 				filename = g_build_filename(dirname, escape, NULL);
 
 				/* Split at the first dot, to avoid uniquifying "foo.tar.gz" to "foo.tar-2.gz" */
@@ -193,7 +197,7 @@
 		node = purple_blist_node_get_parent(node);
 	g_return_if_fail(PURPLE_BLIST_NODE_IS_CONTACT(node));
 
-	message = g_strdup_printf(_("When a file-transfer request arrives from %s"), 
+	message = g_strdup_printf(_("When a file-transfer request arrives from %s"),
 					purple_contact_get_alias((PurpleContact *)node));
 	purple_request_choice(plugin, _("Set Autoaccept Setting"), message,
 						NULL, purple_blist_node_get_int(node, "autoaccept"),
@@ -226,6 +230,17 @@
 static gboolean
 plugin_load(PurplePlugin *plugin)
 {
+	/* migrate the old pref (we should only care if the plugin is actually *used*) */
+	/*
+	 * TODO: We should eventually call purple_prefs_remove(PREFS_STRANGER_OLD)
+	 *       to clean up after ourselves, but we don't want to do it yet
+	 *       so that we don't break users who share a .purple directory
+	 *       between old libpurple clients and new libpurple clients.
+	 *                                             --Mark Doliner, 2011-01-03
+	 */
+	if(purple_prefs_get_bool(PREF_STRANGER_OLD))
+		purple_prefs_set_int(PREF_STRANGER, FT_REJECT);
+
 	purple_signal_connect(purple_xfers_get_handle(), "file-recv-request", plugin,
 						PURPLE_CALLBACK(file_recv_request_cb), plugin);
 	purple_signal_connect(purple_blist_get_handle(), "blist-node-extended-menu", plugin,
@@ -253,7 +268,12 @@
 	purple_plugin_pref_frame_add(frame, pref);
 
 	pref = purple_plugin_pref_new_with_name_and_label(PREF_STRANGER,
-					_("Automatically reject from users not in buddy list"));
+					_("When a file-transfer request arrives from a user who is\n"
+                      "*not* on your buddy list:"));
+	purple_plugin_pref_set_type(pref, PURPLE_PLUGIN_PREF_CHOICE);
+	purple_plugin_pref_add_choice(pref, _("Ask"), GINT_TO_POINTER(FT_ASK));
+	purple_plugin_pref_add_choice(pref, _("Auto Accept"), GINT_TO_POINTER(FT_ACCEPT));
+	purple_plugin_pref_add_choice(pref, _("Auto Reject"), GINT_TO_POINTER(FT_REJECT));
 	purple_plugin_pref_frame_add(frame, pref);
 
 	pref = purple_plugin_pref_new_with_name_and_label(PREF_NOTIFY,
@@ -265,6 +285,10 @@
 			_("Create a new directory for each user"));
 	purple_plugin_pref_frame_add(frame, pref);
 
+	pref = purple_plugin_pref_new_with_name_and_label(PREF_ESCAPE,
+			_("Escape the filenames"));
+	purple_plugin_pref_frame_add(frame, pref);
+
 	return frame;
 }
 
@@ -321,9 +345,10 @@
 	dirname = g_build_filename(purple_user_dir(), "autoaccept", NULL);
 	purple_prefs_add_none(PREF_PREFIX);
 	purple_prefs_add_string(PREF_PATH, dirname);
-	purple_prefs_add_bool(PREF_STRANGER, TRUE);
+	purple_prefs_add_int(PREF_STRANGER, FT_ASK);
 	purple_prefs_add_bool(PREF_NOTIFY, TRUE);
 	purple_prefs_add_bool(PREF_NEWDIR, TRUE);
+	purple_prefs_add_bool(PREF_ESCAPE, TRUE);
 	g_free(dirname);
 }
 
--- a/libpurple/plugins/codeinline.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/codeinline.c	Sat Aug 06 03:45:56 2011 +0000
@@ -62,7 +62,7 @@
 {
      PURPLE_PLUGIN_MAGIC,
      PURPLE_MAJOR_VERSION,
-     PURPLE_MINOR_VERSION,     
+     PURPLE_MINOR_VERSION,
      PURPLE_PLUGIN_STANDARD,
      NULL,
      0,
--- a/libpurple/plugins/fortuneprofile.pl	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/fortuneprofile.pl	Sat Aug 06 03:45:56 2011 +0000
@@ -51,7 +51,7 @@
 	summary          => "Sets your AIM profile to a fortune (with a header and footer of your choice).",
 	description      => "Sets your AIM profile to a fortune (with a header and footer of your choice).",
 	author           => "Sean Egan <seanegan\@gmail.com>",
-	url              => "http://gaim.sf.net/",
+	url              => "http://pidgin.im/",
 
 	load             => "plugin_load"
 );
--- a/libpurple/plugins/idle.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/idle.c	Sat Aug 06 03:45:56 2011 +0000
@@ -104,15 +104,11 @@
 	PurpleAccount *acct = NULL;
 	GList *list, *iter;
 	int tm = purple_request_fields_get_integer(fields, "mins");
-	const char *prpl_id = NULL;
 
 	list = purple_accounts_get_all_active();
 	for(iter = list; iter; iter = iter->next) {
 		acct = (PurpleAccount *)(iter->data);
 
-		if(acct)
-			prpl_id = purple_account_get_protocol_id(acct);
-
 		if(acct && idleable_filter(acct)) {
 			purple_debug_misc("idle", "Idling %s.\n",
 					purple_account_get_username(acct));
--- a/libpurple/plugins/log_reader.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/log_reader.c	Sat Aug 06 03:45:56 2011 +0000
@@ -1587,7 +1587,7 @@
 
 					if (buddy != NULL)
 						alias = purple_buddy_get_alias(buddy);
-					
+
 					if (alias != NULL)
 						g_string_append(formatted, alias);
 					else
@@ -1824,7 +1824,7 @@
 				purple_str_has_prefix(c, QIP_LOG_OUT_MESSAGE)) {
 
 				char *tmp;
-				
+
 				new_line = c;
 
 				/* find EOL */
@@ -1886,7 +1886,7 @@
 			data->offset = offset;
 			offset += data->length;
 			purple_debug_info("QIP logger list",
-				"Creating log: path = (%s); length = (%d); offset = (%d)\n", 
+				"Creating log: path = (%s); length = (%d); offset = (%d)\n",
 				data->path, data->length, data->offset);
 
 			/* XXX: Look into this later... Should we pass in a struct tm? */
@@ -2323,7 +2323,7 @@
 
 	file = g_fopen(data->path, "rb");
 	g_return_val_if_fail(file != NULL, g_strdup(""));
-	
+
 	fseek(file, data->offset, SEEK_SET);
 	data->length = fread(contents, 1, data->length, file);
 	fclose(file);
@@ -2417,7 +2417,7 @@
 	g_return_val_if_fail(log != NULL, 0);
 
 	data = log->logger_data;
-	
+
 	if (purple_prefs_get_bool("/plugins/core/log_reader/fast_sizes")) {
 		return data ? data->length : 0;
 	}
@@ -2644,7 +2644,7 @@
 			g_free(contents);
 		}
 		g_free(path);
-#endif /* !GTK_CHECK_VERSION(2,6,0) */
+#endif /* !GLIB_CHECK_VERSION(2,6,0) */
 	} /* path */
 
 	if (!found) {
--- a/libpurple/plugins/mono/loader/blist-glue.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/mono/loader/blist-glue.c	Sat Aug 06 03:45:56 2011 +0000
@@ -6,21 +6,21 @@
 MonoObject* purple_blist_get_handle_glue(void)
 {
 	void *handle = purple_blist_get_handle();
-	
+
 	return mono_value_box(ml_get_domain(), mono_get_intptr_class(), &handle);
 }
 
 MonoObject* purple_blist_build_buddy_object(void* data)
 {
 	MonoObject *obj = NULL;
-			
+
 	PurpleBuddy *buddy = (PurpleBuddy*)data;
-	
+
 	obj = ml_create_api_object("Buddy");
 	g_return_val_if_fail(obj != NULL, NULL);
-		
+
 	ml_set_prop_string(obj, "Name", (char*)purple_buddy_get_name(buddy));
 	ml_set_prop_string(obj, "Alias", (char*)purple_buddy_get_alias(buddy));
-	
+
 	return obj;
 }
--- a/libpurple/plugins/mono/loader/debug-glue.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/mono/loader/debug-glue.c	Sat Aug 06 03:45:56 2011 +0000
@@ -5,12 +5,12 @@
 {
 	char *ccat;
 	char *cstr;
-	
+
 	ccat = mono_string_to_utf8(cat);
 	cstr = mono_string_to_utf8(str);
-	
+
 	purple_debug(type, ccat, "%s", cstr);
-	
+
 	g_free(ccat);
 	g_free(cstr);
 }
--- a/libpurple/plugins/mono/loader/mono-helper.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/mono/loader/mono-helper.c	Sat Aug 06 03:45:56 2011 +0000
@@ -22,57 +22,57 @@
 gboolean ml_init()
 {
 	MonoDomain *d;
-	
+
 	g_return_val_if_fail(_runtime_active == FALSE, TRUE);
-	
+
 	d = mono_jit_init("purple");
-	
+
 	if (!d) {
 		ml_set_domain(NULL);
 		return FALSE;
 	}
-	
+
 	ml_set_domain(d);
-	
+
 	ml_init_internal_calls();
-	
+
 	_runtime_active = TRUE;
-	
+
 	return TRUE;
 }
 
 void ml_uninit()
 {
 	g_return_if_fail(_runtime_active == TRUE);
-	
+
 	mono_jit_cleanup(ml_get_domain());
-	
+
 	ml_set_domain(NULL);
-	
+
 	_runtime_active = FALSE;
 }
 
 MonoObject* ml_delegate_invoke(MonoObject *method, void **params)
 {
 	MonoObject *ret, *exception;
-	
+
 	ret = mono_runtime_delegate_invoke(method, params, &exception);
 	if (exception) {
 		purple_debug(PURPLE_DEBUG_ERROR, "mono", "caught exception: %s\n", mono_class_get_name(mono_object_get_class(exception)));
 	}
-	
+
 	return ret;
 }
 
 MonoObject* ml_invoke(MonoMethod *method, void *obj, void **params)
 {
 	MonoObject *ret, *exception;
-	
+
 	ret = mono_runtime_invoke(method, obj, params, &exception);
 	if (exception) {
 		purple_debug(PURPLE_DEBUG_ERROR, "mono", "caught exception: %s\n", mono_class_get_name(mono_object_get_class(exception)));
 	}
-	
+
 	return ret;
 }
 
@@ -84,15 +84,15 @@
 	total = mono_image_get_table_rows (image, MONO_TABLE_TYPEDEF);
 	for (i = 1; i <= total; ++i) {
 		klass = mono_class_get (image, MONO_TOKEN_TYPE_DEF | i);
-		
+
 		pklass = mono_class_get_parent(klass);
 		if (pklass) {
-		
+
 			if (strcmp("Plugin", mono_class_get_name(pklass)) == 0)
 				return klass;
 		}
 	}
-	
+
 	return NULL;
 }
 
@@ -102,15 +102,15 @@
 	MonoProperty *prop;
 	MonoString *str;
 	gpointer args[1];
-	
+
 	klass = mono_object_get_class(obj);
-	
+
 	prop = mono_class_get_property_from_name(klass, field);
-	
+
 	str = mono_string_new(ml_get_domain(), data);
-	
+
 	args[0] = str;
-	
+
 	mono_property_set_value(prop, obj, args, NULL);
 }
 
@@ -119,13 +119,13 @@
 	MonoClass *klass;
 	MonoProperty *prop;
 	MonoString *str;
-	
+
 	klass = mono_object_get_class(obj);
-	
+
 	prop = mono_class_get_property_from_name(klass, field);
-	
+
 	str = (MonoString*)mono_property_get_value(prop, obj, NULL, NULL);
-	
+
 	return mono_string_to_utf8(str);
 }
 
@@ -133,16 +133,16 @@
 {
 	MonoClass *klass;
 	MonoProperty *prop;
-	
+
 	klass = mono_class_get_parent(mono_object_get_class(obj));
-	
+
 	prop = mono_class_get_property_from_name(klass, "Info");
-	
+
 	return mono_property_get_value(prop, obj, NULL, NULL);
 }
 
 gboolean ml_is_api_dll(MonoImage *image)
-{	
+{
 	MonoClass *klass;
 	int i, total;
 
@@ -155,7 +155,7 @@
 				return TRUE;
 			}
 	}
-	
+
 	return FALSE;
 }
 
@@ -167,7 +167,7 @@
 MonoObject* ml_object_from_purple_subtype(PurpleSubType type, gpointer data)
 {
 	MonoObject *obj = NULL;
-	
+
 	switch (type) {
 		case PURPLE_SUBTYPE_BLIST_BUDDY:
 			obj = purple_blist_build_buddy_object(data);
@@ -178,7 +178,7 @@
 		default:
 		break;
 	}
-	
+
 	return obj;
 }
 
@@ -186,21 +186,21 @@
 {
 	MonoObject *obj = NULL;
 	MonoClass *klass = NULL;
-		
+
 	klass = mono_class_from_name(ml_get_api_image(), "Purple", class_name);
 	if (!klass) {
 		purple_debug(PURPLE_DEBUG_FATAL, "mono", "couldn't find the '%s' class\n", class_name);
 		return NULL;
 	}
-	
+
 	obj = mono_object_new(ml_get_domain(), klass);
 	if (!obj) {
 		purple_debug(PURPLE_DEBUG_FATAL, "mono", "couldn't create the object from class '%s'\n", class_name);
 		return NULL;
 	}
-	
+
 	mono_runtime_object_init(obj);
-	
+
 	return obj;
 }
 
@@ -241,7 +241,7 @@
 {
 	if (!plugins_hash)
 		plugins_hash = g_hash_table_new(NULL, NULL);
-		
+
 	g_hash_table_insert(plugins_hash, plugin->klass, plugin);
 }
 
--- a/libpurple/plugins/mono/loader/mono-helper.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/mono/loader/mono-helper.h	Sat Aug 06 03:45:56 2011 +0000
@@ -13,16 +13,16 @@
 
 typedef struct {
 	PurplePlugin *plugin;
-	
+
 	MonoAssembly *assm;
 	MonoClass *klass;
-	MonoObject *obj;	
-	
+	MonoObject *obj;
+
 	MonoMethod *init;
 	MonoMethod *load;
 	MonoMethod *unload;
 	MonoMethod *destroy;
-	
+
 	GList *signal_data;
 } PurpleMonoPlugin;
 
--- a/libpurple/plugins/mono/loader/signal-glue.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/mono/loader/signal-glue.c	Sat Aug 06 03:45:56 2011 +0000
@@ -22,13 +22,13 @@
 	int i;
 	gpointer meth_args[1];
 	gpointer purple_obj;
-	
+
 	va_list args;
-	
+
 	va_start(args, num_vals);
-	
+
 	array = mono_array_new(ml_get_domain(), mono_get_object_class(), num_vals);
-	
+
 	for (i = 0; i < num_vals; i++) {
 		if (purple_value_get_type(sig_data->values[i]) == PURPLE_TYPE_SUBTYPE) {
 			purple_obj = va_arg(args, gpointer);
@@ -40,22 +40,22 @@
 			mono_array_set(array, MonoObject*, i, obj);
 		}
 	}
-	
+
 	va_end(args);
-	
+
 	meth_args[0] = array;
-	
-	return ml_delegate_invoke(sig_data->func, meth_args);	
+
+	return ml_delegate_invoke(sig_data->func, meth_args);
 }
 
 static void cb_void__pointer(void *arg1, void *data)
 {
-	dispatch_callback((SignalData*)data, ((SignalData*)data)->num_vals, arg1);	
+	dispatch_callback((SignalData*)data, ((SignalData*)data)->num_vals, arg1);
 }
 
 static void cb_void__pointer_pointer_pointer(void *arg1, void *arg2, void *arg3, void *data)
 {
-	dispatch_callback((SignalData*)data, ((SignalData*)data)->num_vals, arg1, arg2, arg3);	
+	dispatch_callback((SignalData*)data, ((SignalData*)data)->num_vals, arg1, arg2, arg3);
 }
 
 
@@ -66,23 +66,23 @@
 	SignalData *sig_data;
 	PurpleMonoPlugin *mplug;
 	MonoClass *klass;
-		
+
 	sig = mono_string_to_utf8(signal);
 	purple_debug(PURPLE_DEBUG_INFO, "mono", "connecting signal: %s\n", sig);
-	
+
 	instance = (void*)mono_object_unbox(h);
-	
+
 	sig_data = g_new0(SignalData, 1);
-	
+
 	sig_data->func = func;
 	sig_data->signal = sig;
-	
+
 	purple_signal_get_values(*instance, sig, &sig_data->ret_value, &sig_data->num_vals, &sig_data->values);
-	
+
 	klass = mono_object_get_class(plugin);
-	
+
 	mplug = ml_find_plugin_by_class(klass);
-	
+
 	mplug->signal_data = g_list_append(mplug->signal_data, (gpointer)sig_data);
 
 	return purple_signal_connect(*instance, sig, (gpointer)klass, get_callback(sig_data), (gpointer)sig_data);
@@ -104,7 +104,7 @@
 	}
 }
 
-static gpointer callbacks[]= { 
+static gpointer callbacks[]= {
 										NULL,
 										cb_void__pointer,
 										NULL,
@@ -112,7 +112,7 @@
 									};
 
 static int callbacks_array_size = sizeof(callbacks) / sizeof(PurpleCallback);
-	
+
 
 static PurpleCallback get_callback(SignalData *sig_data)
 {
@@ -122,18 +122,18 @@
 		index = 0;
 	else
 		index = determine_index(purple_value_get_type(sig_data->ret_value));
-	
+
 	for (i = 0; i < sig_data->num_vals; i++) {
 		index += determine_index(purple_value_get_type(sig_data->values[i]));
 	}
-	
+
 	purple_debug(PURPLE_DEBUG_INFO, "mono", "get_callback index = %d\n", index);
-	
+
 	if (index >= callbacks_array_size || callbacks[index] == NULL) {
 		purple_debug(PURPLE_DEBUG_ERROR, "mono", "couldn't find a callback function for signal: %s\n", sig_data->signal);
 		return NULL;
 	}
-	
+
 	purple_debug(PURPLE_DEBUG_MISC, "mono", "using callback at index: %d\n", index);
 	return PURPLE_CALLBACK(callbacks[index]);
 }
--- a/libpurple/plugins/mono/loader/status-glue.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/mono/loader/status-glue.c	Sat Aug 06 03:45:56 2011 +0000
@@ -6,11 +6,11 @@
 {
 	MonoObject *obj = NULL;
 	PurpleStatus *status = (PurpleStatus*)data;
-	
+
 	obj = ml_create_api_object("Status");
 	g_return_val_if_fail(obj != NULL, NULL);
-		
+
 	ml_set_prop_string(obj, "Id", (char*)purple_status_get_id(status));
-	
+
 	return obj;
 }
--- a/libpurple/plugins/offlinemsg.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/offlinemsg.c	Sat Aug 06 03:45:56 2011 +0000
@@ -89,7 +89,7 @@
 
 	purple_pounce_action_set_enabled(pounce, "send-message", TRUE);
 	purple_pounce_action_set_attribute(pounce, "send-message", "message", offline->message);
- 
+
 	conv = offline->conv;
 	if (!purple_conversation_get_data(conv, "plugin_pack:offlinemsg"))
 		purple_conversation_write(conv, NULL, _("The rest of the messages will be saved "
@@ -156,7 +156,7 @@
 		ask = g_strdup_printf(_("\"%s\" is currently offline. Do you want to save the "
 						"rest of the messages in a pounce and automatically send them "
 						"when \"%s\" logs back in?"), who, who);
-	
+
 		purple_request_action(handle, _("Offline Message"), ask,
 					_("You can edit/delete the pounce from the `Buddy Pounces' dialog"),
 					0,
--- a/libpurple/plugins/perl/common/BuddyList.xs	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/perl/common/BuddyList.xs	Sat Aug 06 03:45:56 2011 +0000
@@ -2,6 +2,13 @@
 #include "module.h"
 #include "../perl-handlers.h"
 
+static void
+chat_components_foreach(gpointer key, gpointer value, gpointer user_data)
+{
+	HV *hv = user_data;
+	hv_store(hv, key, strlen(key), newSVpv(value, 0), 0);
+}
+
 MODULE = Purple::BuddyList  PACKAGE = Purple  PREFIX = purple_
 PROTOTYPES: ENABLE
 
@@ -331,6 +338,19 @@
 purple_chat_get_name(chat)
 	Purple::BuddyList::Chat chat
 
+HV *
+purple_chat_get_components(chat)
+	Purple::BuddyList::Chat chat
+INIT:
+	HV * t_HV;
+	GHashTable * t_GHash;
+CODE:
+	t_GHash = purple_chat_get_components(chat);
+	RETVAL = t_HV = newHV();
+	g_hash_table_foreach(t_GHash, chat_components_foreach, t_HV);
+OUTPUT:
+	RETVAL
+
 Purple::BuddyList::Chat
 purple_chat_new(account, alias, components)
 	Purple::Account account
@@ -345,14 +365,14 @@
 	char *t_key, *t_value;
 CODE:
 	t_HV =  (HV *)SvRV(components);
-	t_GHash = g_hash_table_new(g_str_hash, g_str_equal);
+	t_GHash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
 
 	for (t_HE = hv_iternext(t_HV); t_HE != NULL; t_HE = hv_iternext(t_HV) ) {
 		t_key = hv_iterkey(t_HE, &len);
 		t_SV = *hv_fetch(t_HV, t_key, len, 0);
 		t_value = SvPVutf8_nolen(t_SV);
 
-		g_hash_table_insert(t_GHash, t_key, t_value);
+		g_hash_table_insert(t_GHash, g_strdup(t_key), g_strdup(t_value));
 	}
 
 	RETVAL = purple_chat_new(account, alias, t_GHash);
--- a/libpurple/plugins/perl/common/Conversation.xs	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/perl/common/Conversation.xs	Sat Aug 06 03:45:56 2011 +0000
@@ -118,6 +118,12 @@
 		XPUSHs(sv_2mortal(purple_perl_bless_object(l->data, "Purple::Conversation")));
 	}
 
+Purple::Conversation
+purple_find_conversation_with_account(type, name, account)
+	Purple::ConversationType type
+	const char *name
+	Purple::Account account
+
 MODULE = Purple::Conversation  PACKAGE = Purple::Conversations  PREFIX = purple_conversations_
 PROTOTYPES: ENABLE
 
@@ -297,6 +303,12 @@
 	const char *message
 
 void
+purple_conv_im_send_with_flags(im, message, flags)
+	Purple::Conversation::IM im
+	const char *message
+	Purple::MessageFlags flags
+
+void
 purple_conv_im_write(im, who, message, flags, mtime)
 	Purple::Conversation::IM im
 	const char *who
@@ -410,6 +422,12 @@
 	const char * message
 
 void
+purple_conv_chat_send_with_flags(chat, message, flags)
+	Purple::Conversation::Chat chat
+	const char * message
+	Purple::MessageFlags flags
+
+void
 purple_conv_chat_write(chat, who, message, flags, mtime)
 	Purple::Conversation::Chat chat
 	const char *who
--- a/libpurple/plugins/perl/common/Log.xs	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/perl/common/Log.xs	Sat Aug 06 03:45:56 2011 +0000
@@ -27,6 +27,9 @@
 		newCONSTSUB(flags_stash, (char *)civ->name, newSViv(civ->iv));
 }
 
+Purple::Handle
+purple_log_get_handle()
+
 int
 purple_log_common_sizer(log)
 	Purple::Log log
--- a/libpurple/plugins/perl/common/Makefile.PL.in	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/perl/common/Makefile.PL.in	Sat Aug 06 03:45:56 2011 +0000
@@ -10,6 +10,7 @@
       (ABSTRACT_FROM    => '@srcdir@/Purple.pm', # finds $ABSTRACT
        AUTHOR           => 'Purple <http://pidgin.im/>') : ()),
     'DEFINE'            => '@DEBUG_CFLAGS@',
+    'dynamic_lib'       => { 'OTHERLDFLAGS' => '@LDFLAGS@' },
     'INC'               => '-I. -I@srcdir@ -I@top_srcdir@ -I@top_srcdir@/libpurple @GLIB_CFLAGS@',
     'OBJECT'            => '$(O_FILES)', # link all the C files too
 #    'OPTIMIZE'          => '-g', # For debugging
--- a/libpurple/plugins/perl/common/Makefile.mingw	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/perl/common/Makefile.mingw	Sat Aug 06 03:45:56 2011 +0000
@@ -13,7 +13,6 @@
 
 TARGET = Purple
 AUTOSPLIT = lib/auto/Purple/autosplit.ix
-EXTUTILS ?= C:/perl/lib/ExtUtils
 PERL_PLUGIN_TOP := ..
 
 ##
--- a/libpurple/plugins/perl/common/Request.xs	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/perl/common/Request.xs	Sat Aug 06 03:45:56 2011 +0000
@@ -380,6 +380,13 @@
 	void * data
 
 void
+purple_request_field_list_add_icon(field, item, icon_path, data)
+	Purple::Request::Field field
+	const char *item
+	const char *icon_path
+	void * data
+
+void
 purple_request_field_list_add_selected(field, item)
 	Purple::Request::Field field
 	const char *item
--- a/libpurple/plugins/perl/common/Server.xs	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/perl/common/Server.xs	Sat Aug 06 03:45:56 2011 +0000
@@ -144,6 +144,7 @@
 		g_hash_table_insert(t_GHash, t_key, t_value);
 	}
 	serv_join_chat(conn, t_GHash);
+	g_hash_table_destroy(t_GHash);
 
 void 
 serv_move_buddy(buddy, group1, group2)
--- a/libpurple/plugins/perl/common/Util.xs	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/perl/common/Util.xs	Sat Aug 06 03:45:56 2011 +0000
@@ -238,7 +238,7 @@
 	guchar *ret;
 	CODE:
 		ret = purple_base16_decode(str, &len);
-		if(len) {
+		if(ret && len > 0) {
 			RETVAL = newSVpv((gchar *)ret, len);
 		} else {
 			g_free(ret);
@@ -256,7 +256,7 @@
 	guchar *ret;
 	CODE:
 		ret = purple_base64_decode(str, &len);
-		if(len) {
+		if(ret && len > 0) {
 			RETVAL = newSVpv((gchar *)ret, len);
 		} else {
 			g_free(ret);
--- a/libpurple/plugins/perl/common/module.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/perl/common/module.h	Sat Aug 06 03:45:56 2011 +0000
@@ -9,6 +9,7 @@
 #include <glib.h>
 #ifdef _WIN32
 #undef pipe
+#undef STRINGIFY
 #endif
 #include <EXTERN.h>
 #include <perl.h>
--- a/libpurple/plugins/perl/perl-common.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/perl/perl-common.h	Sat Aug 06 03:45:56 2011 +0000
@@ -3,6 +3,7 @@
 
 #include <glib.h>
 #ifdef _WIN32
+#undef STRINGIFY
 #undef pipe
 #endif
 #include <EXTERN.h>
--- a/libpurple/plugins/perl/perl-handlers.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/perl/perl-handlers.c	Sat Aug 06 03:45:56 2011 +0000
@@ -299,7 +299,7 @@
 	for (i = 0; i < value_count; i++) {
 		sv_args[i] = purple_perl_sv_from_vargs(values[i],
 #ifdef VA_COPY_AS_ARRAY
-		                                       args,
+		                                       (va_list*)args,
 #else
 		                                       (va_list*)&args,
 #endif
--- a/libpurple/plugins/perl/scripts/account.pl	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/perl/scripts/account.pl	Sat Aug 06 03:45:56 2011 +0000
@@ -27,7 +27,7 @@
 
 	# We will create these on load then destroy them on unload
 	my $TEST_NAME	 	= "perlTestName";
-	my $PROTOCOL_ID 	= "prpl-oscar";
+	my $PROTOCOL_ID 	= "prpl-aim";
 
 
 sub plugin_init {
--- a/libpurple/plugins/perl/scripts/buddy_list.pl	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/perl/scripts/buddy_list.pl	Sat Aug 06 03:45:56 2011 +0000
@@ -24,7 +24,7 @@
 	my $TEST_GROUP		= "UConn Buddies";
 	my $TEST_NAME	 	= "johnhkelm";
 	my $TEST_ALIAS	 	= "John Kelm";
-	my $PROTOCOL_ID 	= "prpl-oscar";
+	my $PROTOCOL_ID 	= "prpl-aim";
 
 
 sub plugin_init {
--- a/libpurple/plugins/perl/scripts/conversation.pl	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/perl/scripts/conversation.pl	Sat Aug 06 03:45:56 2011 +0000
@@ -30,7 +30,7 @@
 	my $TEST_GROUP		= "UConn Buddies";
 	my $TEST_NAME	 	= "johnhkelm";
 	my $TEST_ALIAS	 	= "John Kelm";
-	my $PROTOCOL_ID 	= "prpl-oscar";
+	my $PROTOCOL_ID 	= "prpl-aim";
 
 
 sub plugin_init { 
--- a/libpurple/plugins/perl/scripts/plugin_pref.pl	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/perl/scripts/plugin_pref.pl	Sat Aug 06 03:45:56 2011 +0000
@@ -28,7 +28,7 @@
 	my $TEST_GROUP		= "perlTestGroup";
 	my $TEST_NAME	 	= "perlTestName";
 	my $TEST_ALIAS	 	= "perlTestAlias";
-	my $PROTOCOL_ID 	= "prpl-oscar";
+	my $PROTOCOL_ID 	= "prpl-aim";
 
 sub foo {
 	$frame = Purple::PluginPref::Frame->new();
--- a/libpurple/plugins/perl/scripts/signals-test.pl	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/perl/scripts/signals-test.pl	Sat Aug 06 03:45:56 2011 +0000
@@ -44,6 +44,11 @@
 	Purple::Debug::misc("signals test in perl", "$data (" . $account->get_username() . ", $sender, $message, $flags)\n");
 }
 
+sub timeout_cb
+{
+	Purple::Debug::misc("signals test in perl", "timeout elapsed\n");
+}
+
 sub plugin_load
 {
 	my $plugin = shift;
@@ -71,6 +76,9 @@
 					\&conv_received_msg, "received im message");
 	Purple::Signal::connect($conv, "received-chat-msg", $plugin,
 					\&conv_received_msg, "received chat message");
+
+
+	Purple::timeout_add($plugin, 10, \&timeout_cb);
 }
 
 sub plugin_unload
--- a/libpurple/plugins/psychic.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/psychic.c	Sat Aug 06 03:45:56 2011 +0000
@@ -85,9 +85,9 @@
 
   PurplePluginPrefFrame *frame;
   PurplePluginPref *pref;
-  
+
   frame = purple_plugin_pref_frame_new();
-  
+
   pref = purple_plugin_pref_new_with_name(PREF_BUDDIES);
   purple_plugin_pref_set_label(pref, _("Only enable for users on"
 				     " the buddy list"));
@@ -118,7 +118,7 @@
 
   purple_signal_connect(convs_handle, "buddy-typing", plugin,
 		      PURPLE_CALLBACK(buddy_typing_cb), NULL);
-  
+
   return TRUE;
 }
 
@@ -127,7 +127,7 @@
   get_plugin_pref_frame,
   0,    /* page_num (Reserved) */
   NULL, /* frame (Reserved) */
-  
+
   /* padding */
   NULL,
   NULL,
@@ -145,7 +145,7 @@
   0,                      /**< flags */
   NULL,                   /**< dependencies */
   PURPLE_PRIORITY_DEFAULT,  /**< priority */
-  
+
   PLUGIN_ID,              /**< id */
   PLUGIN_NAME,            /**< name */
   DISPLAY_VERSION,        /**< version */
@@ -153,11 +153,11 @@
   PLUGIN_DESC,            /**< description */
   PLUGIN_AUTHOR,          /**< author */
   PURPLE_WEBSITE,           /**< homepage */
-  
+
   plugin_load,            /**< load */
   NULL,                   /**< unload */
   NULL,                   /**< destroy */
-  
+
   NULL,                   /**< ui_info */
   NULL,                   /**< extra_info */
   &prefs_info,            /**< prefs_info */
--- a/libpurple/plugins/signals-test.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/signals-test.c	Sat Aug 06 03:45:56 2011 +0000
@@ -592,12 +592,12 @@
 
 static void
 ft_recv_cancel_cb(PurpleXfer *xfer, gpointer data) {
-	purple_debug_misc("signals test", "file receive canceled\n");
+	purple_debug_misc("signals test", "file receive cancelled\n");
 }
 
 static void
 ft_send_cancel_cb(PurpleXfer *xfer, gpointer data) {
-	purple_debug_misc("signals test", "file send canceled\n");
+	purple_debug_misc("signals test", "file send cancelled\n");
 }
 
 static void
--- a/libpurple/plugins/ssl/Makefile.mingw	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/ssl/Makefile.mingw	Sat Aug 06 03:45:56 2011 +0000
@@ -15,14 +15,16 @@
 
 NEEDED_DLLS = \
 			$(NSS_TOP)/lib/freebl3.dll \
+			$(NSS_TOP)/lib/libnspr4.dll \
+			$(NSS_TOP)/lib/libplc4.dll \
+			$(NSS_TOP)/lib/libplds4.dll \
 			$(NSS_TOP)/lib/nss3.dll \
 			$(NSS_TOP)/lib/nssckbi.dll \
-			$(NSS_TOP)/lib/softokn3.dll \
+			$(NSS_TOP)/lib/nssutil3.dll \
 			$(NSS_TOP)/lib/smime3.dll \
-			$(NSS_TOP)/lib/ssl3.dll \
-			$(NSPR_TOP)/lib/nspr4.dll \
-			$(NSPR_TOP)/lib/plc4.dll \
-			$(NSPR_TOP)/lib/plds4.dll
+			$(NSS_TOP)/lib/softokn3.dll \
+                        $(NSS_TOP)/lib/sqlite3.dll \
+			$(NSS_TOP)/lib/ssl3.dll 
 
 ##
 ## INCLUDE PATHS
@@ -34,13 +36,11 @@
 			-I$(PURPLE_TOP) \
 			-I$(PURPLE_TOP)/win32 \
 			-I$(PIDGIN_TREE_TOP) \
-			-I$(NSS_TOP)/include \
-			-I$(NSPR_TOP)/include
+			-I$(NSS_TOP)/include
 
 LIB_PATHS +=		-L$(GTK_TOP)/lib \
 			-L$(PURPLE_TOP) \
-			-L$(NSS_TOP)/lib \
-			-L$(NSPR_TOP)/lib
+			-L$(NSS_TOP)/lib
 
 ##
 ##  SOURCES, OBJECTS
--- a/libpurple/plugins/ssl/ssl-gnutls.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/ssl/ssl-gnutls.c	Sat Aug 06 03:45:56 2011 +0000
@@ -36,11 +36,25 @@
 {
 	gnutls_session session;
 	guint handshake_handler;
+	guint handshake_timer;
 } PurpleSslGnutlsData;
 
 #define PURPLE_SSL_GNUTLS_DATA(gsc) ((PurpleSslGnutlsData *)gsc->private_data)
 
-static gnutls_certificate_client_credentials xcred;
+static gnutls_certificate_client_credentials xcred = NULL;
+
+#ifdef HAVE_GNUTLS_PRIORITY_FUNCS
+/* Priority strings.  The default one is, well, the default (and is always
+ * set).  The hash table is of the form hostname => priority (both
+ * char *).
+ *
+ * We only use a gnutls_priority_t for the default on the assumption that
+ * that's the more common case.  Improvement patches (like matching on
+ * subdomains) welcome.
+ */
+static gnutls_priority_t default_priority = NULL;
+static GHashTable *host_priorities = NULL;
+#endif
 
 static void
 ssl_gnutls_log(int level, const char *str)
@@ -53,6 +67,7 @@
 ssl_gnutls_init_gnutls(void)
 {
 	const char *debug_level;
+	const char *host_priorities_str;
 
 	/* Configure GnuTLS to use glib memory management */
 	/* I expect that this isn't really necessary, but it may prevent
@@ -82,6 +97,80 @@
 		gnutls_global_set_log_function(ssl_gnutls_log);
 	}
 
+	/* Expected format: host=priority;host2=priority;*=priority
+	 * where "*" is used to override the default priority string for
+	 * libpurple.
+	 */
+	host_priorities_str = g_getenv("PURPLE_GNUTLS_PRIORITIES");
+	if (host_priorities_str) {
+#ifndef HAVE_GNUTLS_PRIORITY_FUNCS
+		purple_debug_warning("gnutls", "Warning, PURPLE_GNUTLS_PRIORITIES "
+		                     "environment variable set, but we were built "
+		                     "against an older GnuTLS that doesn't support "
+		                     "this. :-(");
+#else /* HAVE_GNUTLS_PRIORITY_FUNCS */
+		char **entries = g_strsplit(host_priorities_str, ";", -1);
+		char *default_priority_str = NULL;
+		guint i;
+
+		host_priorities = g_hash_table_new_full(g_str_hash, g_str_equal,
+		                                        g_free, g_free);
+
+		for (i = 0; entries[i]; ++i) {
+			char *host = entries[i];
+			char *equals = strchr(host, '=');
+			char *prio_str;
+
+			if (equals) {
+				*equals = '\0';
+				prio_str = equals + 1;
+
+				/* Empty? */
+				if (*prio_str == '\0') {
+					purple_debug_warning("gnutls", "Ignoring empty priority "
+					                               "string for %s\n", host);
+				} else {
+					/* TODO: Validate each of these and complain */
+					if (g_str_equal(host, "*")) {
+						/* Override the default priority */
+						g_free(default_priority_str);
+						default_priority_str = g_strdup(prio_str);
+					} else
+						g_hash_table_insert(host_priorities, g_strdup(host),
+						                    g_strdup(prio_str));
+				}
+			}
+		}
+
+		if (default_priority_str) {
+			if (gnutls_priority_init(&default_priority, default_priority_str, NULL)) {
+				purple_debug_warning("gnutls", "Unable to set default priority to %s\n",
+				                     default_priority_str);
+				/* Versions of GnuTLS as of 2.8.6 (2010-03-31) don't free/NULL
+				 * this on error.
+				 */
+				gnutls_free(default_priority);
+				default_priority = NULL;
+			}
+
+			g_free(default_priority_str);
+		}
+
+		g_strfreev(entries);
+#endif /* HAVE_GNUTLS_PRIORITY_FUNCS */
+	}
+
+#ifdef HAVE_GNUTLS_PRIORITY_FUNCS
+	/* Make sure we set have a default priority! */
+	if (!default_priority) {
+		if (gnutls_priority_init(&default_priority, "NORMAL:%SSL3_RECORD_VERSION", NULL)) {
+			/* See comment above about memory leak */
+			gnutls_free(default_priority);
+			gnutls_priority_init(&default_priority, "NORMAL", NULL);
+		}
+	}
+#endif /* HAVE_GNUTLS_PRIORITY_FUNCS */
+
 	gnutls_global_init();
 
 	gnutls_certificate_allocate_credentials(&xcred);
@@ -103,6 +192,17 @@
 	gnutls_global_deinit();
 
 	gnutls_certificate_free_credentials(xcred);
+	xcred = NULL;
+
+#ifdef HAVE_GNUTLS_PRIORITY_FUNCS
+	if (host_priorities) {
+		g_hash_table_destroy(host_priorities);
+		host_priorities = NULL;
+	}
+
+	gnutls_priority_deinit(default_priority);
+	default_priority = NULL;
+#endif
 }
 
 static void
@@ -268,6 +368,19 @@
 
 }
 
+static gboolean
+start_handshake_cb(gpointer data)
+{
+	PurpleSslConnection *gsc = data;
+	PurpleSslGnutlsData *gnutls_data = PURPLE_SSL_GNUTLS_DATA(gsc);
+
+	purple_debug_info("gnutls", "Starting handshake with %s\n", gsc->host);
+
+	gnutls_data->handshake_timer = 0;
+
+	ssl_gnutls_handshake_cb(gsc, gsc->fd, PURPLE_INPUT_READ);
+	return FALSE;
+}
 
 static void
 ssl_gnutls_connect(PurpleSslConnection *gsc)
@@ -280,9 +393,22 @@
 
 	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);
+	{
+		const char *prio_str = NULL;
+		gboolean set = FALSE;
+
+		/* Let's see if someone has specified a specific priority */
+		if (gsc->host && host_priorities)
+			prio_str = g_hash_table_lookup(host_priorities, gsc->host);
+
+		if (prio_str)
+			set = (GNUTLS_E_SUCCESS ==
+					gnutls_priority_set_direct(gnutls_data->session, prio_str,
+				                               NULL));
+
+		if (!set)
+			gnutls_priority_set(gnutls_data->session, default_priority);
+	}
 #else
 	gnutls_set_default_priority(gnutls_data->session);
 #endif
@@ -298,10 +424,8 @@
 	gnutls_data->handshake_handler = purple_input_add(gsc->fd,
 		PURPLE_INPUT_READ, ssl_gnutls_handshake_cb, gsc);
 
-	purple_debug_info("gnutls", "Starting handshake with %s\n", gsc->host);
-
 	/* Orborde asks: Why are we configuring a callback, then
-	   immediately calling it?
+	   (almost) immediately calling it?
 
 	   Answer: gnutls_handshake (up in handshake_cb) needs to be called
 	   once in order to get the ball rolling on the SSL connection.
@@ -312,7 +436,8 @@
 	   and subsequent calls, we'll just fire the callback immediately to
 	   accomplish this.
 	*/
-	ssl_gnutls_handshake_cb(gsc, gsc->fd, PURPLE_INPUT_READ);
+	gnutls_data->handshake_timer = purple_timeout_add(0, start_handshake_cb,
+	                                                  gsc);
 }
 
 static void
@@ -325,6 +450,8 @@
 
 	if(gnutls_data->handshake_handler)
 		purple_input_remove(gnutls_data->handshake_handler);
+	if (gnutls_data->handshake_timer)
+		purple_timeout_remove(gnutls_data->handshake_timer);
 
 	gnutls_bye(gnutls_data->session, GNUTLS_SHUT_RDWR);
 
@@ -393,11 +520,18 @@
 /* Forward declarations are fun! */
 static PurpleCertificate *
 x509_import_from_datum(const gnutls_datum dt, gnutls_x509_crt_fmt mode);
+/* indeed! */
+static gboolean
+x509_certificate_signed_by(PurpleCertificate * crt,
+			   PurpleCertificate * issuer);
+static void
+x509_destroy_certificate(PurpleCertificate * crt);
 
 static GList *
 ssl_gnutls_get_peer_certificates(PurpleSslConnection * gsc)
 {
 	PurpleSslGnutlsData *gnutls_data = PURPLE_SSL_GNUTLS_DATA(gsc);
+	PurpleCertificate *prvcrt = NULL;
 
 	/* List of Certificate instances to return */
 	GList * peer_certs = NULL;
@@ -423,7 +557,17 @@
 		/* Append is somewhat inefficient on linked lists, but is easy
 		   to read. If someone complains, I'll change it.
 		   TODO: Is anyone complaining? (Maybe elb?) */
-		peer_certs = g_list_append(peer_certs, newcrt);
+		/* only append if previous cert was actually signed by this one.
+		 * Thanks Microsoft. */
+		if ((prvcrt == NULL) || x509_certificate_signed_by(prvcrt, newcrt)) {
+			peer_certs = g_list_append(peer_certs, newcrt);
+			prvcrt = newcrt;
+		} else {
+			x509_destroy_certificate(newcrt);
+			purple_debug_error("gnutls", "Dropping further peer certificates "
+			                             "because the chain is broken!\n");
+			break;
+		}
 	}
 
 	/* cert_list doesn't need free()-ing */
@@ -548,6 +692,55 @@
 	return crt;
 }
 
+/** Imports a number of PEM-formatted X.509 certificates from the specified file.
+ * @param filename Filename to import from. Format is PEM
+ *
+ * @return A newly allocated GSList of Certificate structures of the x509_gnutls scheme
+ */
+static GSList *
+x509_importcerts_from_file(const gchar * filename)
+{
+	PurpleCertificate *crt;  /* Certificate being constructed */
+	gchar *buf;        /* Used to load the raw file data */
+	gchar *begin, *end;
+	GSList *crts = NULL;
+	gsize buf_sz;      /* Size of the above */
+	gnutls_datum dt; /* Struct to pass down to GnuTLS */
+
+	purple_debug_info("gnutls",
+			  "Attempting to load X.509 certificates from %s\n",
+			  filename);
+
+	/* Next, we'll simply yank the entire contents of the file
+	   into memory */
+	/* TODO: Should I worry about very large files here? */
+	g_return_val_if_fail(
+		g_file_get_contents(filename,
+			    &buf,
+			    &buf_sz,
+			    NULL      /* No error checking for now */
+		),
+		NULL);
+
+	begin = buf;
+	while((end = strstr(begin, "-----END CERTIFICATE-----")) != NULL) {
+		end += sizeof("-----END CERTIFICATE-----")-1;
+		/* Load the datum struct */
+		dt.data = (unsigned char *) begin;
+		dt.size = (end-begin);
+
+		/* Perform the conversion; files should be in PEM format */
+		crt = x509_import_from_datum(dt, GNUTLS_X509_FMT_PEM);
+		crts = g_slist_prepend(crts, crt);
+		begin = end;
+	}
+
+	/* Cleanup */
+	g_free(buf);
+
+	return crts;
+}
+
 /**
  * Exports a PEM-formatted X.509 certificate to the specified file.
  * @param filename Filename to export to. Format will be PEM
@@ -964,10 +1157,10 @@
 	x509_common_name,                /* Subject name */
 	x509_check_name,                 /* Check subject name */
 	x509_times,                      /* Activation/Expiration time */
+	x509_importcerts_from_file,      /* Multiple certificates import function */
 
 	NULL,
 	NULL,
-	NULL,
 	NULL
 
 };
--- a/libpurple/plugins/ssl/ssl-nss.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/ssl/ssl-nss.c	Sat Aug 06 03:45:56 2011 +0000
@@ -51,7 +51,7 @@
 	PRFileDesc *fd;
 	PRFileDesc *in;
 	guint handshake_handler;
-
+	guint handshake_timer;
 } PurpleSslNssData;
 
 #define PURPLE_SSL_NSS_DATA(gsc) ((PurpleSslNssData *)gsc->private_data)
@@ -235,6 +235,7 @@
 static void
 ssl_nss_uninit(void)
 {
+	NSS_Shutdown();
 	PR_Cleanup();
 
 	_nss_methods = NULL;
@@ -288,13 +289,13 @@
 	GList * peer_certs = NULL;
 	int count;
 	int64 now = PR_Now();
-	
+
 	curcert = SSL_PeerCertificate(socket);
 	if (curcert == NULL) {
 		purple_debug_error("nss", "could not DupCertificate\n");
 		return NULL;
 	}
-	
+
 	for (count = 0 ; count < CERT_MAX_CERT_CHAIN ; count++) {
 		purple_debug_info("nss", "subject=%s issuer=%s\n", curcert->subjectName,
 						  curcert->issuerName  ? curcert->issuerName : "(null)");
@@ -368,6 +369,18 @@
 	}
 }
 
+static gboolean
+start_handshake_cb(gpointer data)
+{
+	PurpleSslConnection *gsc = data;
+	PurpleSslNssData *nss_data = PURPLE_SSL_NSS_DATA(gsc);
+
+	nss_data->handshake_timer = 0;
+
+	ssl_nss_handshake_cb(gsc, gsc->fd, PURPLE_INPUT_READ);
+	return FALSE;
+}
+
 static void
 ssl_nss_connect(PurpleSslConnection *gsc)
 {
@@ -438,7 +451,7 @@
 	nss_data->handshake_handler = purple_input_add(gsc->fd,
 		PURPLE_INPUT_READ, ssl_nss_handshake_cb, gsc);
 
-	ssl_nss_handshake_cb(gsc, gsc->fd, PURPLE_INPUT_READ);
+	nss_data->handshake_timer = purple_timeout_add(0, start_handshake_cb, gsc);
 }
 
 static void
@@ -460,6 +473,9 @@
 	if (nss_data->handshake_handler)
 		purple_input_remove(nss_data->handshake_handler);
 
+	if (nss_data->handshake_timer)
+		purple_timeout_remove(nss_data->handshake_timer);
+
 	g_free(nss_data);
 	gsc->private_data = NULL;
 }
@@ -514,7 +530,7 @@
 		CERT_DestroyCertificate(cert);
 #endif
 
-	
+
 
 	return NULL;
 }
@@ -530,7 +546,7 @@
 /** Imports a PEM-formatted X.509 certificate from the specified file.
  * @param filename Filename to import from. Format is PEM
  *
- * @return A newly allocated Certificate structure of the x509_gnutls scheme
+ * @return A newly allocated Certificate structure of the x509_nss scheme
  */
 static PurpleCertificate *
 x509_import_from_file(const gchar *filename)
@@ -571,10 +587,64 @@
 	crt = g_new0(PurpleCertificate, 1);
 	crt->scheme = &x509_nss;
 	crt->data = crt_dat;
-	
+
 	return crt;
 }
 
+/** Imports a number of PEM-formatted X.509 certificates from the specified file.
+ * @param filename Filename to import from. Format is PEM
+ *
+ * @return A GSList of newly allocated Certificate structures of the x509_nss scheme
+ */
+static GSList *
+x509_importcerts_from_file(const gchar *filename)
+{
+	gchar *rawcert, *begin, *end;
+	gsize len = 0;
+	GSList *crts = NULL;
+	CERTCertificate *crt_dat;
+	PurpleCertificate *crt;
+
+	g_return_val_if_fail(filename != NULL, NULL);
+
+	purple_debug_info("nss/x509",
+			  "Loading certificate from %s\n",
+			  filename);
+
+	/* Load the raw data up */
+	if (!g_file_get_contents(filename,
+				 &rawcert, &len,
+				 NULL)) {
+		purple_debug_error("nss/x509", "Unable to read certificate file.\n");
+		return NULL;
+	}
+
+	if (len == 0) {
+		purple_debug_error("nss/x509",
+				"Certificate file has no contents!\n");
+		if (rawcert)
+			g_free(rawcert);
+		return NULL;
+	}
+
+	begin = rawcert;
+	while((end = strstr(begin, "-----END CERTIFICATE-----")) != NULL) {
+		end += sizeof("-----END CERTIFICATE-----")-1;
+		/* Decode the certificate */
+		crt_dat = CERT_DecodeCertFromPackage(begin, (end-begin));
+
+		g_return_val_if_fail(crt_dat != NULL, NULL);
+
+		crt = g_new0(PurpleCertificate, 1);
+		crt->scheme = &x509_nss;
+		crt->data = crt_dat;
+		crts = g_slist_prepend(crts, crt);
+		begin = end;
+	}
+	g_free(rawcert);
+
+	return crts;
+}
 /**
  * Exports a PEM-formatted X.509 certificate to the specified file.
  * @param filename Filename to export to. Format will be PEM
@@ -602,7 +672,7 @@
 
 	purple_debug_info("nss/x509",
 			  "Exporting certificate to %s\n", filename);
-	
+
 	/* First, use NSS voodoo to create a DER-formatted certificate */
 	dercrt = SEC_ASN1EncodeItem(NULL, NULL, crt_dat,
 				    SEC_ASN1_GET(SEC_SignedCertificateTemplate));
@@ -622,7 +692,7 @@
 	ret =  purple_util_write_data_to_file_absolute(filename, pemcrt, -1);
 
 	g_free(pemcrt);
-	
+
 	return ret;
 }
 
@@ -643,7 +713,7 @@
 	newcrt->scheme = &x509_nss;
 	/* NSS does refcounting automatically */
 	newcrt->data = CERT_DupCertificate(crt_dat);
-	
+
 	return newcrt;
 }
 
@@ -689,7 +759,7 @@
 	CERTCertificate *subjectCert;
 	CERTCertificate *issuerCert;
 	SECStatus st;
-	
+
 	issuerCert = X509_NSS_DATA(issuer);
 	g_return_val_if_fail(issuerCert, FALSE);
 
@@ -725,7 +795,7 @@
 	sha1sum = g_byte_array_sized_new(hashlen);
 	/* glib leaves the size as 0 by default */
 	sha1sum->len = hashlen;
-	
+
 	st = PK11_HashBuf(SEC_OID_SHA1, sha1sum->data,
 			  derCert->data, derCert->len);
 
@@ -744,7 +814,7 @@
 x509_dn (PurpleCertificate *crt)
 {
 	CERTCertificate *crt_dat;
-	
+
 	g_return_val_if_fail(crt, NULL);
 	g_return_val_if_fail(crt->scheme == &x509_nss, NULL);
 
@@ -758,7 +828,7 @@
 x509_issuer_dn (PurpleCertificate *crt)
 {
 	CERTCertificate *crt_dat;
-	
+
 	g_return_val_if_fail(crt, NULL);
 	g_return_val_if_fail(crt->scheme == &x509_nss, NULL);
 
@@ -774,7 +844,7 @@
 	CERTCertificate *crt_dat;
 	char *nss_cn;
 	gchar *ret_cn;
-	
+
 	g_return_val_if_fail(crt, NULL);
 	g_return_val_if_fail(crt->scheme == &x509_nss, NULL);
 
@@ -805,7 +875,7 @@
 {
 	CERTCertificate *crt_dat;
 	SECStatus st;
-	
+
 	g_return_val_if_fail(crt, FALSE);
 	g_return_val_if_fail(crt->scheme == &x509_nss, FALSE);
 
@@ -820,7 +890,7 @@
 	else if (st == SECFailure) {
 		return FALSE;
 	}
-	
+
 	/* If we get here...bad things! */
 	purple_debug_error("nss/x509",
 			   "x509_check_name fell through where it shouldn't "
@@ -833,7 +903,7 @@
 {
 	CERTCertificate *crt_dat;
 	PRTime nss_activ, nss_expir;
-	
+
 	g_return_val_if_fail(crt, FALSE);
 	g_return_val_if_fail(crt->scheme == &x509_nss, FALSE);
 
@@ -856,7 +926,7 @@
 	if (expiration) {
 		*expiration = nss_expir / 1000000;
 	}
-	
+
 	return TRUE;
 }
 
@@ -874,10 +944,10 @@
 	x509_common_name,                /* Subject name */
 	x509_check_name,                 /* Check subject name */
 	x509_times,                      /* Activation/Expiration time */
+	x509_importcerts_from_file,      /* Multiple certificate import function */
 
 	NULL,
 	NULL,
-	NULL,
 	NULL
 };
 
--- a/libpurple/plugins/tcl/tcl_cmd.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/tcl/tcl_cmd.c	Sat Aug 06 03:45:56 2011 +0000
@@ -125,7 +125,7 @@
                                    gchar **args, gchar **errors,
                                    struct tcl_cmd_handler *handler)
 {
-	int retval, error, i;
+	int retval, i;
 	Tcl_Obj *command, *arg, *tclargs, *result;
 
 	command = Tcl_NewListObj(0, NULL);
@@ -153,8 +153,7 @@
 	}
 	Tcl_ListObjAppendElement(handler->interp, command, tclargs);
 
-	if ((error = Tcl_EvalObjEx(handler->interp, command,
-	                           TCL_EVAL_GLOBAL)) != TCL_OK) {
+	if (Tcl_EvalObjEx(handler->interp, command, TCL_EVAL_GLOBAL) != TCL_OK) {
 		gchar *errorstr;
 
 		errorstr = g_strdup_printf("error evaluating callback: %s\n",
@@ -164,8 +163,8 @@
 		retval = PURPLE_CMD_RET_FAILED;
 	} else {
 		result = Tcl_GetObjResult(handler->interp);
-		if ((error = Tcl_GetIntFromObj(handler->interp, result,
-		                               &retval)) != TCL_OK) {
+		if (Tcl_GetIntFromObj(handler->interp, result,
+		                      &retval) != TCL_OK) {
 			gchar *errorstr;
 
 			errorstr = g_strdup_printf("Error retreiving procedure result: %s\n",
--- a/libpurple/plugins/tcl/tcl_cmds.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/tcl/tcl_cmds.c	Sat Aug 06 03:45:56 2011 +0000
@@ -4,7 +4,7 @@
  * purple
  *
  * Copyright (C) 2003 Ethan Blanton <eblanton@cs.purdue.edu>
- * 
+ *
  * 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
@@ -184,7 +184,7 @@
 		if ((account = tcl_validate_account(objv[2], interp)) == NULL)
 			return TCL_ERROR;
 		if (objc == 3) {
-			Tcl_SetObjResult(interp, 
+			Tcl_SetObjResult(interp,
 					 Tcl_NewBooleanObj(
 						 purple_account_get_enabled(account,
 									    purple_core_get_ui())));
@@ -209,7 +209,7 @@
 			Tcl_WrongNumArgs(interp, 2, objv, "");
 			return TCL_ERROR;
 		}
-		Tcl_SetObjResult(interp, 
+		Tcl_SetObjResult(interp,
 				 purple_tcl_ref_new(PurpleTclRefHandle,
 						    purple_accounts_get_handle()));
 		break;
@@ -374,7 +374,7 @@
 		}
 		if ((account = tcl_validate_account(objv[2], interp)) == NULL)
 			return TCL_ERROR;
-		Tcl_SetObjResult(interp, 
+		Tcl_SetObjResult(interp,
 				 Tcl_NewStringObj((char *)purple_account_get_username(account), -1));
 		break;
 	}
@@ -865,7 +865,7 @@
 			return error;
 		from = Tcl_GetString(objv[4]);
 		what = Tcl_GetString(objv[5]);
-		
+
 		switch (style) {
 		case CMD_CONV_WRITE_SEND:
 			flags = PURPLE_MESSAGE_SEND;
@@ -1426,7 +1426,7 @@
 			Tcl_WrongNumArgs(interp, 2, objv, "");
 			return TCL_ERROR;
 		}
-		Tcl_SetObjResult(interp, 
+		Tcl_SetObjResult(interp,
 				 purple_tcl_ref_new(PurpleTclRefHandle,
 						    purple_savedstatuses_get_handle()));
 		break;
@@ -1809,7 +1809,7 @@
 		/* This isn't exactly OK, but heh.  What do you do? */
 		return TCL_OK;
 	}
-	/* We can't unload immediately, but we can unload at the first 
+	/* We can't unload immediately, but we can unload at the first
 	 * known safe opportunity. */
 	purple_timeout_add(0, unload_self, (gpointer)plugin);
 
--- a/libpurple/plugins/tcl/tcl_glib.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/tcl/tcl_glib.c	Sat Aug 06 03:45:56 2011 +0000
@@ -43,7 +43,7 @@
 
 /*
  * NOTES
- * 
+ *
  * This file was developed for the Purple project.  It inserts the Tcl
  * event loop into the glib2 event loop for the purposes of providing
  * Tcl bindings in a glib2 (e.g. Gtk2) program.  To use it, simply
@@ -51,9 +51,9 @@
  * function tcl_glib_init() before creating or using any Tcl
  * interpreters.  Then go ahead and use Tcl, Tk, whatever to your
  * heart's content.
- * 
+ *
  * BUGS
- * 
+ *
  * tcl_wait_for_event seems to have a bug that makes vwait not work so
  * well...  I'm not sure why, yet, but I haven't put much time into
  * it.  Hopefully I will figure it out soon.  In the meantime, this
@@ -159,7 +159,7 @@
 
 	if (g_hash_table_lookup(tcl_file_handlers, GINT_TO_POINTER(fd)))
             tcl_delete_file_handler(fd);
-	
+
 	if (mask & TCL_READABLE)
 		cond |= G_IO_IN;
 	if (mask & TCL_WRITABLE)
--- a/libpurple/plugins/tcl/tcl_glib.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/tcl/tcl_glib.h	Sat Aug 06 03:45:56 2011 +0000
@@ -2,7 +2,7 @@
  * Tcl/Glib glue
  *
  * Copyright (C) 2003 Ethan Blanton <eblanton@cs.purdue.edu>
- * 
+ *
  * 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
--- a/libpurple/plugins/tcl/tcl_purple.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/tcl/tcl_purple.h	Sat Aug 06 03:45:56 2011 +0000
@@ -4,7 +4,7 @@
  * purple
  *
  * Copyright (C) 2003 Ethan Blanton <eblanton@cs.purdue.edu>
- * 
+ *
  * 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
--- a/libpurple/plugins/tcl/tcl_ref.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/tcl/tcl_ref.c	Sat Aug 06 03:45:56 2011 +0000
@@ -4,7 +4,7 @@
  * purple
  *
  * Copyright (C) 2006 Ethan Blanton <eblanton@cs.purdue.edu>
- * 
+ *
  * 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
--- a/libpurple/plugins/tcl/tcl_signals.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/plugins/tcl/tcl_signals.c	Sat Aug 06 03:45:56 2011 +0000
@@ -4,7 +4,7 @@
  * purple
  *
  * Copyright (C) 2003 Ethan Blanton <eblanton@cs.purdue.edu>
- * 
+ *
  * 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
@@ -117,7 +117,7 @@
 
 	for (cur = tcl_callbacks; cur != NULL; cur = g_list_next(cur)) {
 		handler = cur->data;
-		if (handler->interp == interp && handler->instance == instance 
+		if (handler->interp == interp && handler->instance == instance
 		    && !strcmp(signal, Tcl_GetString(handler->signal))) {
 			purple_signal_disconnect(instance, signal, handler->interp,
 					       PURPLE_CALLBACK(tcl_signal_callback));
@@ -160,7 +160,7 @@
 {
 	GString *name, *val;
 	PurpleBlistNode *node;
-	int error, i;
+	int i;
 	void *retval = NULL;
 	Tcl_Obj *cmd, *arg, *result;
 	void **vals; /* Used for inout parameters */
@@ -335,7 +335,7 @@
 	}
 
 	/* Call the friggin' procedure already */
-	if ((error = Tcl_EvalObjEx(handler->interp, cmd, TCL_EVAL_GLOBAL)) != TCL_OK) {
+	if (Tcl_EvalObjEx(handler->interp, cmd, TCL_EVAL_GLOBAL) != TCL_OK) {
 		purple_debug(PURPLE_DEBUG_ERROR, "tcl", "error evaluating callback: %s\n",
 			   Tcl_GetString(Tcl_GetObjResult(handler->interp)));
 	} else {
@@ -345,7 +345,7 @@
 			if (purple_value_get_type(handler->returntype) == PURPLE_TYPE_STRING) {
 				retval = (void *)g_strdup(Tcl_GetString(result));
 			} else {
-				if ((error = Tcl_GetIntFromObj(handler->interp, result, (int *)&retval)) != TCL_OK) {
+				if (Tcl_GetIntFromObj(handler->interp, result, (int *)&retval) != TCL_OK) {
 					purple_debug(PURPLE_DEBUG_ERROR, "tcl", "Error retrieving procedure result: %s\n",
 						   Tcl_GetString(Tcl_GetObjResult(handler->interp)));
 					retval = NULL;
--- a/libpurple/pounce.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/pounce.c	Sat Aug 06 03:45:56 2011 +0000
@@ -695,6 +695,31 @@
 }
 
 void
+purple_pounce_destroy_all_by_buddy(PurpleBuddy *buddy)
+{
+	const char *pouncee, *bname;
+	PurpleAccount *pouncer, *bacct;
+	PurplePounce *pounce;
+	GList *l, *l_next;
+
+	g_return_if_fail(buddy != NULL);
+
+	bacct = purple_buddy_get_account(buddy);
+	bname = purple_buddy_get_name(buddy);
+
+	for (l = purple_pounces_get_all(); l != NULL; l = l_next) {
+		pounce = (PurplePounce *)l->data;
+		l_next = l->next;
+
+		pouncer = purple_pounce_get_pouncer(pounce);
+		pouncee = purple_pounce_get_pouncee(pounce);
+
+		if ( (pouncer == bacct) && (strcmp(pouncee, bname) == 0) )
+			purple_pounce_destroy(pounce);
+	}
+}
+
+void
 purple_pounce_set_events(PurplePounce *pounce, PurplePounceEvent events)
 {
 	g_return_if_fail(pounce != NULL);
--- a/libpurple/pounce.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/pounce.h	Sat Aug 06 03:45:56 2011 +0000
@@ -123,6 +123,15 @@
 void purple_pounce_destroy_all_by_account(PurpleAccount *account);
 
 /**
+ * Destroys all buddy pounces for a buddy
+ *
+ * @param buddy The buddy whose pounces are to be removed
+ *
+ * @since 2.8.0
+ */
+void purple_pounce_destroy_all_by_buddy(PurpleBuddy *buddy);
+
+/**
  * Sets the events a pounce should watch for.
  *
  * @param pounce The buddy pounce.
--- a/libpurple/prefs.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/prefs.c	Sat Aug 06 03:45:56 2011 +0000
@@ -506,7 +506,6 @@
 		return g_strdup("/");
 
 	name = g_string_new(pref->name);
-	parent = pref->parent;
 
 	for(parent = pref->parent; parent && parent->name; parent = parent->parent) {
 		name = g_string_prepend_c(name, '/');
--- a/libpurple/prefs.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/prefs.h	Sat Aug 06 03:45:56 2011 +0000
@@ -185,7 +185,16 @@
  *
  * @param name  The name of the pref
  * @param value The value to set
+ *
+ * @deprecated We're not really sure what purpose this function serves, so it
+ *             will be removed in 3.0.0.  Preferences values set using this
+ *             function aren't serialized to prefs.xml, which could be
+ *             misleading.  There is also no purple_prefs_get_generic, which
+ *             means that if you can't really get the value (other in a
+ *             connected callback).  If you think you have a use for this then
+ *             please let us know.
  */
+/* TODO: When this is removed, also remove struct purple_pref->value.generic */
 void purple_prefs_set_generic(const char *name, gpointer value);
 
 /**
--- a/libpurple/protocols/Makefile.am	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/protocols/Makefile.am	Sat Aug 06 03:45:56 2011 +0000
@@ -1,5 +1,5 @@
 EXTRA_DIST = Makefile.mingw
 
-DIST_SUBDIRS = bonjour gg irc jabber msn msnp9 myspace mxit novell null oscar qq sametime silc silc10 simple yahoo zephyr
+DIST_SUBDIRS = bonjour gg irc jabber msn myspace mxit novell null oscar sametime silc silc10 simple yahoo zephyr
 
 SUBDIRS = $(DYNAMIC_PRPLS) $(STATIC_PRPLS)
--- a/libpurple/protocols/Makefile.mingw	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/protocols/Makefile.mingw	Sat Aug 06 03:45:56 2011 +0000
@@ -8,7 +8,7 @@
 PIDGIN_TREE_TOP := ../..
 include $(PIDGIN_TREE_TOP)/libpurple/win32/global.mak
 
-SUBDIRS = gg irc jabber msn mxit novell null oscar qq sametime silc simple yahoo bonjour myspace
+SUBDIRS = gg irc jabber msn mxit novell null oscar sametime silc simple yahoo bonjour myspace
 
 .PHONY: all install clean
 
--- a/libpurple/protocols/bonjour/Makefile.mingw	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/protocols/bonjour/Makefile.mingw	Sat Aug 06 03:45:56 2011 +0000
@@ -30,7 +30,7 @@
 			-I$(GTK_TOP)/include/glib-2.0 \
 			-I$(GTK_TOP)/lib/glib-2.0/include \
 			-I$(BONJOUR_TOP)/Include \
-			-I$(LIBXML2_TOP)/include \
+			-I$(LIBXML2_TOP)/include/libxml2 \
 			-I$(PURPLE_TOP) \
 			-I$(PURPLE_TOP)/win32 \
 			-I$(PIDGIN_TREE_TOP)
--- a/libpurple/protocols/bonjour/bonjour.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/protocols/bonjour/bonjour.c	Sat Aug 06 03:45:56 2011 +0000
@@ -46,7 +46,14 @@
 
 static char *default_firstname;
 static char *default_lastname;
-static char *default_hostname;
+
+const char *
+bonjour_get_jid(PurpleAccount *account)
+{
+	PurpleConnection *conn = purple_account_get_connection(account);
+	BonjourData *bd = conn->proto_data;
+	return bd->jid;
+}
 
 static void
 bonjour_removeallfromlocal(PurpleConnection *conn, PurpleGroup *bonjour_group)
@@ -70,7 +77,6 @@
 			buddy = (PurpleBuddy *) bnode;
 			if (purple_buddy_get_account(buddy) != account)
 				continue;
-			purple_prpl_got_user_status(account, purple_buddy_get_name(buddy), "offline", NULL);
 			purple_account_remove_buddy(account, buddy, NULL);
 			purple_blist_remove_buddy(buddy);
 		}
@@ -101,6 +107,8 @@
 
 	/* Start waiting for jabber connections (iChat style) */
 	bd->jabber_data = g_new0(BonjourJabber, 1);
+	bd->jabber_data->socket = -1;
+	bd->jabber_data->socket6 = -1;
 	bd->jabber_data->port = purple_account_get_int(account, "port", BONJOUR_DEFAULT_PORT);
 	bd->jabber_data->account = account;
 
@@ -170,7 +178,9 @@
 		g_free(bd->jabber_data);
 	}
 
-	/* Delete the bonjour group */
+	/* Delete the bonjour group
+	 * (purple_blist_remove_group will bail out if the group isn't empty)
+	 */
 	if (bonjour_group != NULL)
 		purple_blist_remove_group(bonjour_group);
 
@@ -179,6 +189,8 @@
 		purple_xfer_cancel_local(bd->xfer_lists->data);
 	}
 
+	if (bd != NULL)
+		g_free(bd->jid);
 	g_free(bd);
 	connection->proto_data = NULL;
 }
@@ -203,18 +215,12 @@
 {
 	PurpleConnection *gc;
 	BonjourData *bd;
-	gboolean disconnected;
-	PurpleStatusType *type;
-	int primitive;
 	PurplePresence *presence;
 	const char *message, *bonjour_status;
 	gchar *stripped;
 
 	gc = purple_account_get_connection(account);
 	bd = gc->proto_data;
-	disconnected = purple_account_is_disconnected(account);
-	type = purple_status_get_type(status);
-	primitive = purple_status_type_get_primitive(type);
 	presence = purple_account_get_presence(account);
 
 	message = purple_status_get_attr_string(status, "message");
@@ -392,7 +398,8 @@
 		purple_notify_user_info_add_pair(user_info, _("XMPP Account"), bb->jid);
 }
 
-static void bonjour_do_group_change(PurpleBuddy *buddy, const char *new_group) {
+static void
+bonjour_do_group_change(PurpleBuddy *buddy, const char *new_group) {
 	PurpleBlistNodeFlags oldflags;
 
 	if (buddy == NULL)
@@ -448,7 +455,6 @@
 
 	g_free(default_firstname);
 	g_free(default_lastname);
-	g_free(default_hostname);
 
 	return TRUE;
 }
@@ -525,7 +531,12 @@
 	sizeof(PurplePluginProtocolInfo),                        /* struct_size */
 	NULL,                                                    /* get_account_text_table */
 	NULL,                                                    /* initiate_media */
-	NULL                                                     /* can_do_media */
+	NULL,                                                    /* get_media_caps */
+	NULL,                                                    /* get_moods */
+	NULL,                                                    /* set_public_alias */
+	NULL,                                                    /* get_public_alias */
+	NULL,                                                    /* add_buddy_with_invite */
+	NULL                                                     /* add_buddies_with_invite */
 };
 
 static PurplePluginInfo info =
@@ -566,7 +577,8 @@
 };
 
 #ifdef WIN32
-static gboolean _set_default_name_cb(gpointer data) {
+static gboolean
+_set_default_name_cb(gpointer data) {
 	gchar *fullname = data;
 	const char *splitpoint;
 	GList *tmp = prpl_info.protocol_options;
@@ -603,7 +615,8 @@
 	return FALSE;
 }
 
-static gpointer _win32_name_lookup_thread(gpointer data) {
+static gpointer
+_win32_name_lookup_thread(gpointer data) {
 	gchar *fullname = NULL;
 	wchar_t username[UNLEN + 1];
 	DWORD dwLenUsername = UNLEN + 1;
@@ -707,24 +720,15 @@
 	}
 
 	g_free(conv);
-
-	/* Try to figure out a good host name to use */
-	/* TODO: Avoid 'localhost,' if possible */
-	default_hostname = g_strdup(purple_get_host_name());
 }
 
 static void
 init_plugin(PurplePlugin *plugin)
 {
-	PurpleAccountUserSplit *split;
 	PurpleAccountOption *option;
 
 	initialize_default_account_values();
 
-	/* Creating the user splits */
-	split = purple_account_user_split_new(_("Hostname"), default_hostname, '@');
-	prpl_info.user_splits = g_list_append(prpl_info.user_splits, split);
-
 	/* Creating the options for the protocol */
 	option = purple_account_option_int_new(_("Local Port"), "port", BONJOUR_DEFAULT_PORT);
 	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
--- a/libpurple/protocols/bonjour/bonjour.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/protocols/bonjour/bonjour.h	Sat Aug 06 03:45:56 2011 +0000
@@ -45,6 +45,12 @@
 	BonjourDnsSd *dns_sd_data;
 	BonjourJabber *jabber_data;
 	GSList *xfer_lists;
+	gchar *jid;
 } BonjourData;
 
+/**
+ *  This will always be username@machinename
+ */
+const char *bonjour_get_jid(PurpleAccount *account);
+
 #endif /* _BONJOUR_H_ */
--- a/libpurple/protocols/bonjour/bonjour_ft.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/protocols/bonjour/bonjour_ft.c	Sat Aug 06 03:45:56 2011 +0000
@@ -53,11 +53,12 @@
 	g_return_if_fail(error_code != NULL);
 	g_return_if_fail(error_type != NULL);
 
-	if(!to || !id)
+	if(!to || !id) {
+		purple_debug_info("bonjour", "xep file transfer stream initialization error.\n");
 		return;
+	}
 
-	purple_debug_info("bonjour", "xep file transfer stream initialization error.\n");
-	iq = xep_iq_new(bd, XEP_IQ_ERROR, to, purple_account_get_username(bd->jabber_data->account), id);
+	iq = xep_iq_new(bd, XEP_IQ_ERROR, to, bonjour_get_jid(bd->jabber_data->account), id);
 	if(iq == NULL)
 		return;
 
@@ -195,7 +196,7 @@
 	/* Assign stream id. */
 	g_free(xf->iq_id);
 	xf->iq_id = g_strdup_printf("%u", next_id++);
-	iq = xep_iq_new(xf->data, XEP_IQ_SET, to, purple_account_get_username(bd->jabber_data->account), xf->iq_id);
+	iq = xep_iq_new(xf->data, XEP_IQ_SET, to, bonjour_get_jid(bd->jabber_data->account), xf->iq_id);
 	if(iq == NULL)
 		return;
 
@@ -255,7 +256,7 @@
 	bd = xf->data;
 
 	purple_debug_info("bonjour", "xep file transfer stream initialization result.\n");
-	iq = xep_iq_new(bd, XEP_IQ_RESULT, to, purple_account_get_username(bd->jabber_data->account), xf->iq_id);
+	iq = xep_iq_new(bd, XEP_IQ_RESULT, to, bonjour_get_jid(bd->jabber_data->account), xf->iq_id);
 	if(iq == NULL)
 		return;
 
@@ -747,8 +748,7 @@
 	XepIq *iq;
 	xmlnode *query, *streamhost;
 	gchar *port;
-	const char *next_ip, *local_ip;
-	const char token [] = ";";
+	GSList *local_ips;
 	BonjourData *bd;
 
 	purple_debug_info("bonjour", "Bonjour-bytestreams-listen. sock=%d.\n", sock);
@@ -764,7 +764,7 @@
 
 	bd = xf->data;
 
-	iq = xep_iq_new(bd, XEP_IQ_SET, xfer->who, purple_account_get_username(bd->jabber_data->account), xf->sid);
+	iq = xep_iq_new(bd, XEP_IQ_SET, xfer->who, bonjour_get_jid(bd->jabber_data->account), xf->sid);
 
 	query = xmlnode_new_child(iq->node, "query");
 	xmlnode_set_namespace(query, "http://jabber.org/protocol/bytestreams");
@@ -773,17 +773,16 @@
 
 	xfer->local_port = purple_network_get_port_from_fd(sock);
 
-	local_ip = purple_network_get_my_ip_ext2(sock);
-	/* cheat a little here - the intent of the "const" attribute is to make it clear that the string doesn't need to be freed */
-	next_ip = strtok((char *)local_ip, token);
+	local_ips = bonjour_jabber_get_local_ips(sock);
 
 	port = g_strdup_printf("%hu", xfer->local_port);
-	while(next_ip != NULL) {
+	while(local_ips) {
 		streamhost = xmlnode_new_child(query, "streamhost");
 		xmlnode_set_attrib(streamhost, "jid", xf->sid);
-		xmlnode_set_attrib(streamhost, "host", next_ip);
+		xmlnode_set_attrib(streamhost, "host", local_ips->data);
 		xmlnode_set_attrib(streamhost, "port", port);
-		next_ip = strtok(NULL, token);
+		g_free(local_ips->data);
+		local_ips = g_slist_delete_link(local_ips, local_ips);
 	}
 	g_free(port);
 
@@ -796,15 +795,17 @@
 	XepXfer *xf;
 	if(xfer == NULL)
 		return;
+
 	purple_debug_info("bonjour", "Bonjour-bytestreams-init.\n");
 	xf = xfer->data;
+
 	purple_network_listen_map_external(FALSE);
 	xf->listen_data = purple_network_listen_range(0, 0, SOCK_STREAM,
 						      bonjour_bytestreams_listen, xfer);
 	purple_network_listen_map_external(TRUE);
-	if (xf->listen_data == NULL) {
+	if (xf->listen_data == NULL)
 		purple_xfer_cancel_local(xfer);
-	}
+
 	return;
 }
 
@@ -835,7 +836,7 @@
 	/* Here, start the file transfer.*/
 
 	/* Notify Initiator of Connection */
-	iq = xep_iq_new(bd, XEP_IQ_RESULT, xfer->who, purple_account_get_username(bd->jabber_data->account), xf->iq_id);
+	iq = xep_iq_new(bd, XEP_IQ_RESULT, xfer->who, bonjour_get_jid(bd->jabber_data->account), xf->iq_id);
 	q_node = xmlnode_new_child(iq->node, "query");
 	xmlnode_set_namespace(q_node, "http://jabber.org/protocol/bytestreams");
 	tmp_node = xmlnode_new_child(q_node, "streamhost-used");
@@ -868,7 +869,7 @@
 	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));
+	p = g_strdup_printf("%s%s%s", xf->sid, name, bonjour_get_jid(account));
 	purple_cipher_digest_region("sha1", (guchar *)p, strlen(p),
 				    sizeof(hashval), hashval, NULL);
 	g_free(p);
@@ -882,8 +883,9 @@
 	purple_proxy_info_set_type(xf->proxy_info, PURPLE_PROXY_SOCKS5);
 	purple_proxy_info_set_host(xf->proxy_info, xf->proxy_host);
 	purple_proxy_info_set_port(xf->proxy_info, xf->proxy_port);
-	xf->proxy_connection = purple_proxy_connect_socks5(
+	xf->proxy_connection = purple_proxy_connect_socks5_account(
 							   purple_account_get_connection(account),
+							   account,
 							   xf->proxy_info,
 							   dstaddr, 0,
 							   bonjour_bytestreams_connect_cb, xfer);
--- a/libpurple/protocols/bonjour/dns_sd_proxy.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/protocols/bonjour/dns_sd_proxy.c	Sat Aug 06 03:45:56 2011 +0000
@@ -1,181 +1,191 @@
-/*
- *
- * Purple is the legal property of its developers, whose names are too numerous
- * to list here.  Please refer to the COPYRIGHT file distributed with this
- * source distribution.
- *
- * 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 02111-1301, USA.
- */
-
-#include "win32dep.h"
-#include "dns_sd_proxy.h"
-
-#ifndef LINK_DNS_SD_DIRECTLY
-static DNSServiceErrorType (DNSSD_API* _DNSServiceAddRecord)(DNSServiceRef sdRef, DNSRecordRef *RecordRef, DNSServiceFlags flags,
-		uint16_t rrtype, uint16_t rdlen, const void *rdata, uint32_t ttl);
-static DNSServiceErrorType (DNSSD_API* _DNSServiceBrowse)(DNSServiceRef *sdRef, DNSServiceFlags flags, uint32_t interfaceIndex,
-	const char *regtype, const char *domain, DNSServiceBrowseReply callBack, void *context);
-static int (DNSSD_API* _DNSServiceConstructFullName)(char *fullName, const char *service, const char *regtype, const char *domain);
-static DNSServiceErrorType (DNSSD_API* _DNSServiceProcessResult)(DNSServiceRef sdRef);
-static DNSServiceErrorType (DNSSD_API* _DNSServiceQueryRecord)(DNSServiceRef *sdRef, DNSServiceFlags flags, uint32_t interfaceIndex,
-	const char *fullname, uint16_t rrtype, uint16_t rrclass, DNSServiceQueryRecordReply callBack, void *context);
-static void (DNSSD_API* _DNSServiceRefDeallocate)(DNSServiceRef sdRef);
-static int (DNSSD_API* _DNSServiceRefSockFD)(DNSServiceRef sdRef);
-static DNSServiceErrorType (DNSSD_API* _DNSServiceRegister)(DNSServiceRef *sdRef, DNSServiceFlags flags, uint32_t interfaceIndex,
-	const char *name, const char *regtype, const char *domain, const char *host, uint16_t port, uint16_t txtLen,
-	const void *txtRecord, DNSServiceRegisterReply callBack, void *context);
-static DNSServiceErrorType (DNSSD_API* _DNSServiceResolve)(DNSServiceRef *sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, const char *name,
-	const char *regtype, const char *domain, DNSServiceResolveReply callBack, void *context);
-static DNSServiceErrorType (DNSSD_API* _DNSServiceRemoveRecord)(DNSServiceRef sdRef, DNSRecordRef RecordRef, DNSServiceFlags flags);
-static DNSServiceErrorType (DNSSD_API* _DNSServiceUpdateRecord)(DNSServiceRef sdRef, DNSRecordRef RecordRef, DNSServiceFlags flags,
-	uint16_t rdlen, const void *rdata, uint32_t ttl);
-static void (DNSSD_API* _TXTRecordCreate)(TXTRecordRef *txtRecord, uint16_t bufferLen, void *buffer);
-static void (DNSSD_API* _TXTRecordDeallocate)(TXTRecordRef *txtRecord);
-static const void * (DNSSD_API* _TXTRecordGetBytesPtr)(const TXTRecordRef *txtRecord);
-static int16_t (DNSSD_API* _TXTRecordGetLength)(const TXTRecordRef *txtRecord);
-static const void * (DNSSD_API* _TXTRecordGetValuePtr)(uint16_t txtLen, const void *txtRecord, const char *key, uint8_t *valueLen);
-static DNSServiceErrorType (DNSSD_API* _TXTRecordSetValue)(TXTRecordRef *txtRecord, const char *key, uint8_t valueSize, const void *value);
-#endif
-
-gboolean dns_sd_available(void) {
-#ifndef LINK_DNS_SD_DIRECTLY
-	static gboolean initialized = FALSE;
-	static gboolean loaded = FALSE;
-
-	if (!initialized) {
-		initialized = TRUE;
-		if ((_DNSServiceAddRecord = (void *) wpurple_find_and_loadproc("dnssd.dll", "DNSServiceAddRecord"))
-				&& (_DNSServiceBrowse = (void *) wpurple_find_and_loadproc("dnssd.dll", "DNSServiceBrowse"))
-				&& (_DNSServiceConstructFullName = (void *) wpurple_find_and_loadproc("dnssd.dll", "DNSServiceConstructFullName"))
-				&& (_DNSServiceProcessResult = (void *) wpurple_find_and_loadproc("dnssd.dll", "DNSServiceProcessResult"))
-				&& (_DNSServiceQueryRecord = (void *) wpurple_find_and_loadproc("dnssd.dll", "DNSServiceQueryRecord"))
-				&& (_DNSServiceRefDeallocate = (void *) wpurple_find_and_loadproc("dnssd.dll", "DNSServiceRefDeallocate"))
-				&& (_DNSServiceRefSockFD = (void *) wpurple_find_and_loadproc("dnssd.dll", "DNSServiceRefSockFD"))
-				&& (_DNSServiceRegister = (void *) wpurple_find_and_loadproc("dnssd.dll", "DNSServiceRegister"))
-				&& (_DNSServiceResolve = (void *) wpurple_find_and_loadproc("dnssd.dll", "DNSServiceResolve"))
-				&& (_DNSServiceRemoveRecord = (void *) wpurple_find_and_loadproc("dnssd.dll", "DNSServiceRemoveRecord"))
-				&& (_DNSServiceUpdateRecord = (void *) wpurple_find_and_loadproc("dnssd.dll", "DNSServiceUpdateRecord"))
-				&& (_TXTRecordCreate = (void *) wpurple_find_and_loadproc("dnssd.dll", "TXTRecordCreate"))
-				&& (_TXTRecordDeallocate = (void *) wpurple_find_and_loadproc("dnssd.dll", "TXTRecordDeallocate"))
-				&& (_TXTRecordGetBytesPtr = (void *) wpurple_find_and_loadproc("dnssd.dll", "TXTRecordGetBytesPtr"))
-				&& (_TXTRecordGetLength = (void *) wpurple_find_and_loadproc("dnssd.dll", "TXTRecordGetLength"))
-				&& (_TXTRecordGetValuePtr = (void *) wpurple_find_and_loadproc("dnssd.dll", "TXTRecordGetValuePtr"))
-				&& (_TXTRecordSetValue = (void *) wpurple_find_and_loadproc("dnssd.dll", "TXTRecordSetValue"))) {
-			loaded = TRUE;
-		}
-	}
-	return loaded;
-#else
-	return TRUE;
-#endif
-}
-
-#ifndef LINK_DNS_SD_DIRECTLY
-
-DNSServiceErrorType _wpurple_DNSServiceAddRecord(DNSServiceRef sdRef, DNSRecordRef *RecordRef, DNSServiceFlags flags,
-		uint16_t rrtype, uint16_t rdlen, const void *rdata, uint32_t ttl) {
-	g_return_val_if_fail(_DNSServiceAddRecord != NULL, kDNSServiceErr_Unknown);
-	return (_DNSServiceAddRecord)(sdRef, RecordRef, flags, rrtype, rdlen, rdata, ttl);
-}
-
-DNSServiceErrorType _wpurple_DNSServiceBrowse(DNSServiceRef *sdRef, DNSServiceFlags flags, uint32_t interfaceIndex,
-		const char *regtype, const char *domain, DNSServiceBrowseReply callBack, void *context) {
-	g_return_val_if_fail(_DNSServiceBrowse != NULL, kDNSServiceErr_Unknown);
-	return (_DNSServiceBrowse)(sdRef, flags, interfaceIndex, regtype, domain, callBack, context);
-}
-
-int _wpurple_DNSServiceConstructFullName(char *fullName, const char *service, const char *regtype, const char *domain) {
-	g_return_val_if_fail(_DNSServiceConstructFullName != NULL, 0);
-	return (_DNSServiceConstructFullName)(fullName, service, regtype, domain);
-}
-
-DNSServiceErrorType _wpurple_DNSServiceProcessResult(DNSServiceRef sdRef) {
-	g_return_val_if_fail(_DNSServiceProcessResult != NULL, kDNSServiceErr_Unknown);
-	return (_DNSServiceProcessResult)(sdRef);
-}
-
-
-DNSServiceErrorType _wpurple_DNSServiceQueryRecord(DNSServiceRef *sdRef, DNSServiceFlags flags, uint32_t interfaceIndex,
-		const char *fullname, uint16_t rrtype, uint16_t rrclass, DNSServiceQueryRecordReply callBack, void *context) {
-	g_return_val_if_fail(_DNSServiceQueryRecord != NULL, kDNSServiceErr_Unknown);
-	return (_DNSServiceQueryRecord)(sdRef, flags, interfaceIndex, fullname, rrtype, rrclass, callBack, context);
-}
-
-void _wpurple_DNSServiceRefDeallocate(DNSServiceRef sdRef) {
-	g_return_if_fail(_DNSServiceRefDeallocate != NULL);
-	(_DNSServiceRefDeallocate)(sdRef);
-}
-
-int _wpurple_DNSServiceRefSockFD(DNSServiceRef sdRef) {
-	g_return_val_if_fail(_DNSServiceRefSockFD != NULL, -1);
-	return (_DNSServiceRefSockFD)(sdRef);
-}
-
-DNSServiceErrorType _wpurple_DNSServiceRegister(DNSServiceRef *sdRef, DNSServiceFlags flags, uint32_t interfaceIndex,
-		const char *name, const char *regtype, const char *domain, const char *host, uint16_t port, uint16_t txtLen,
-		const void *txtRecord, DNSServiceRegisterReply callBack, void *context) {
-	g_return_val_if_fail(_DNSServiceRegister != NULL, kDNSServiceErr_Unknown);
-	return (_DNSServiceRegister)(sdRef, flags, interfaceIndex, name, regtype, domain, host, port, txtLen, txtRecord, callBack, context);
-}
-
-DNSServiceErrorType _wpurple_DNSServiceResolve(DNSServiceRef *sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, const char *name,
-		const char *regtype, const char *domain, DNSServiceResolveReply callBack, void *context) {
-	g_return_val_if_fail(_DNSServiceResolve != NULL, kDNSServiceErr_Unknown);
-	return (_DNSServiceResolve)(sdRef, flags, interfaceIndex, name, regtype, domain, callBack, context);
-}
-
-DNSServiceErrorType _wpurple_DNSServiceRemoveRecord(DNSServiceRef sdRef, DNSRecordRef RecordRef, DNSServiceFlags flags) {
-	g_return_val_if_fail(_DNSServiceRemoveRecord != NULL, kDNSServiceErr_Unknown);
-	return (_DNSServiceRemoveRecord)(sdRef, RecordRef, flags);
-}
-
-DNSServiceErrorType _wpurple_DNSServiceUpdateRecord(DNSServiceRef sdRef, DNSRecordRef RecordRef, DNSServiceFlags flags,
-		uint16_t rdlen, const void *rdata, uint32_t ttl) {
-	g_return_val_if_fail(_DNSServiceUpdateRecord != NULL, kDNSServiceErr_Unknown);
-	return (_DNSServiceUpdateRecord)(sdRef, RecordRef, flags, rdlen, rdata, ttl);
-}
-
-void _wpurple_TXTRecordCreate(TXTRecordRef *txtRecord, uint16_t bufferLen, void *buffer) {
-	g_return_if_fail(_TXTRecordCreate != NULL);
-	(_TXTRecordCreate)(txtRecord, bufferLen, buffer);
-}
-
-void _wpurple_TXTRecordDeallocate(TXTRecordRef *txtRecord) {
-	g_return_if_fail(_TXTRecordDeallocate != NULL);
-	(_TXTRecordDeallocate)(txtRecord);
-}
-
-const void * _wpurple_TXTRecordGetBytesPtr(const TXTRecordRef *txtRecord) {
-	g_return_val_if_fail(_TXTRecordGetBytesPtr != NULL, NULL);
-	return (_TXTRecordGetBytesPtr)(txtRecord);
-}
-
-uint16_t _wpurple_TXTRecordGetLength(const TXTRecordRef *txtRecord) {
-	g_return_val_if_fail(_TXTRecordGetLength != NULL, 0);
-	return (_TXTRecordGetLength)(txtRecord);
-}
-
-const void * _wpurple_TXTRecordGetValuePtr(uint16_t txtLen, const void *txtRecord, const char *key, uint8_t *valueLen) {
-	g_return_val_if_fail(_TXTRecordGetValuePtr != NULL, NULL);
-	return (_TXTRecordGetValuePtr)(txtLen, txtRecord, key, valueLen);
-}
-
-DNSServiceErrorType _wpurple_TXTRecordSetValue(TXTRecordRef *txtRecord, const char *key, uint8_t valueSize, const void *value) {
-	g_return_val_if_fail(_TXTRecordSetValue != NULL, kDNSServiceErr_Unknown);
-	return (_TXTRecordSetValue)(txtRecord, key, valueSize, value);
-}
-
-#endif /*LINK_DNS_SD_DIRECTLY*/
-
+/*
+ *
+ * Purple is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * 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 02111-1301, USA.
+ */
+
+#include "win32dep.h"
+#include "dns_sd_proxy.h"
+
+#ifndef LINK_DNS_SD_DIRECTLY
+static DNSServiceErrorType (DNSSD_API* _DNSServiceAddRecord)(DNSServiceRef sdRef, DNSRecordRef *RecordRef, DNSServiceFlags flags,
+		uint16_t rrtype, uint16_t rdlen, const void *rdata, uint32_t ttl);
+static DNSServiceErrorType (DNSSD_API* _DNSServiceBrowse)(DNSServiceRef *sdRef, DNSServiceFlags flags, uint32_t interfaceIndex,
+	const char *regtype, const char *domain, DNSServiceBrowseReply callBack, void *context);
+static int (DNSSD_API* _DNSServiceConstructFullName)(char *fullName, const char *service, const char *regtype, const char *domain);
+static DNSServiceErrorType (DNSSD_API* _DNSServiceGetAddrInfo)(DNSServiceRef *sdRef, DNSServiceFlags flags, uint32_t interfaceIndex,
+	DNSServiceProtocol protocol, const char *hostname, DNSServiceGetAddrInfoReply callBack, void *context);
+static DNSServiceErrorType (DNSSD_API* _DNSServiceProcessResult)(DNSServiceRef sdRef);
+static DNSServiceErrorType (DNSSD_API* _DNSServiceQueryRecord)(DNSServiceRef *sdRef, DNSServiceFlags flags, uint32_t interfaceIndex,
+	const char *fullname, uint16_t rrtype, uint16_t rrclass, DNSServiceQueryRecordReply callBack, void *context);
+static void (DNSSD_API* _DNSServiceRefDeallocate)(DNSServiceRef sdRef);
+static int (DNSSD_API* _DNSServiceRefSockFD)(DNSServiceRef sdRef);
+static DNSServiceErrorType (DNSSD_API* _DNSServiceRegister)(DNSServiceRef *sdRef, DNSServiceFlags flags, uint32_t interfaceIndex,
+	const char *name, const char *regtype, const char *domain, const char *host, uint16_t port, uint16_t txtLen,
+	const void *txtRecord, DNSServiceRegisterReply callBack, void *context);
+static DNSServiceErrorType (DNSSD_API* _DNSServiceResolve)(DNSServiceRef *sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, const char *name,
+	const char *regtype, const char *domain, DNSServiceResolveReply callBack, void *context);
+static DNSServiceErrorType (DNSSD_API* _DNSServiceRemoveRecord)(DNSServiceRef sdRef, DNSRecordRef RecordRef, DNSServiceFlags flags);
+static DNSServiceErrorType (DNSSD_API* _DNSServiceUpdateRecord)(DNSServiceRef sdRef, DNSRecordRef RecordRef, DNSServiceFlags flags,
+	uint16_t rdlen, const void *rdata, uint32_t ttl);
+static void (DNSSD_API* _TXTRecordCreate)(TXTRecordRef *txtRecord, uint16_t bufferLen, void *buffer);
+static void (DNSSD_API* _TXTRecordDeallocate)(TXTRecordRef *txtRecord);
+static const void * (DNSSD_API* _TXTRecordGetBytesPtr)(const TXTRecordRef *txtRecord);
+static int16_t (DNSSD_API* _TXTRecordGetLength)(const TXTRecordRef *txtRecord);
+static const void * (DNSSD_API* _TXTRecordGetValuePtr)(uint16_t txtLen, const void *txtRecord, const char *key, uint8_t *valueLen);
+static DNSServiceErrorType (DNSSD_API* _TXTRecordSetValue)(TXTRecordRef *txtRecord, const char *key, uint8_t valueSize, const void *value);
+
+#endif
+
+gboolean dns_sd_available(void) {
+#ifndef LINK_DNS_SD_DIRECTLY
+	static gboolean initialized = FALSE;
+	static gboolean loaded = FALSE;
+
+	if (!initialized) {
+		initialized = TRUE;
+		if ((_DNSServiceAddRecord = (void *) wpurple_find_and_loadproc("dnssd.dll", "DNSServiceAddRecord"))
+				&& (_DNSServiceBrowse = (void *) wpurple_find_and_loadproc("dnssd.dll", "DNSServiceBrowse"))
+				&& (_DNSServiceConstructFullName = (void *) wpurple_find_and_loadproc("dnssd.dll", "DNSServiceConstructFullName"))
+				&& (_DNSServiceGetAddrInfo = (void *) wpurple_find_and_loadproc("dnssd.dll", "DNSServiceGetAddrInfo"))
+				&& (_DNSServiceProcessResult = (void *) wpurple_find_and_loadproc("dnssd.dll", "DNSServiceProcessResult"))
+				&& (_DNSServiceQueryRecord = (void *) wpurple_find_and_loadproc("dnssd.dll", "DNSServiceQueryRecord"))
+				&& (_DNSServiceRefDeallocate = (void *) wpurple_find_and_loadproc("dnssd.dll", "DNSServiceRefDeallocate"))
+				&& (_DNSServiceRefSockFD = (void *) wpurple_find_and_loadproc("dnssd.dll", "DNSServiceRefSockFD"))
+				&& (_DNSServiceRegister = (void *) wpurple_find_and_loadproc("dnssd.dll", "DNSServiceRegister"))
+				&& (_DNSServiceResolve = (void *) wpurple_find_and_loadproc("dnssd.dll", "DNSServiceResolve"))
+				&& (_DNSServiceRemoveRecord = (void *) wpurple_find_and_loadproc("dnssd.dll", "DNSServiceRemoveRecord"))
+				&& (_DNSServiceUpdateRecord = (void *) wpurple_find_and_loadproc("dnssd.dll", "DNSServiceUpdateRecord"))
+				&& (_TXTRecordCreate = (void *) wpurple_find_and_loadproc("dnssd.dll", "TXTRecordCreate"))
+				&& (_TXTRecordDeallocate = (void *) wpurple_find_and_loadproc("dnssd.dll", "TXTRecordDeallocate"))
+				&& (_TXTRecordGetBytesPtr = (void *) wpurple_find_and_loadproc("dnssd.dll", "TXTRecordGetBytesPtr"))
+				&& (_TXTRecordGetLength = (void *) wpurple_find_and_loadproc("dnssd.dll", "TXTRecordGetLength"))
+				&& (_TXTRecordGetValuePtr = (void *) wpurple_find_and_loadproc("dnssd.dll", "TXTRecordGetValuePtr"))
+				&& (_TXTRecordSetValue = (void *) wpurple_find_and_loadproc("dnssd.dll", "TXTRecordSetValue"))) {
+			loaded = TRUE;
+		}
+	}
+	return loaded;
+#else
+	return TRUE;
+#endif
+}
+
+#ifndef LINK_DNS_SD_DIRECTLY
+
+DNSServiceErrorType _wpurple_DNSServiceAddRecord(DNSServiceRef sdRef, DNSRecordRef *RecordRef, DNSServiceFlags flags,
+		uint16_t rrtype, uint16_t rdlen, const void *rdata, uint32_t ttl) {
+	g_return_val_if_fail(_DNSServiceAddRecord != NULL, kDNSServiceErr_Unknown);
+	return (_DNSServiceAddRecord)(sdRef, RecordRef, flags, rrtype, rdlen, rdata, ttl);
+}
+
+DNSServiceErrorType _wpurple_DNSServiceBrowse(DNSServiceRef *sdRef, DNSServiceFlags flags, uint32_t interfaceIndex,
+		const char *regtype, const char *domain, DNSServiceBrowseReply callBack, void *context) {
+	g_return_val_if_fail(_DNSServiceBrowse != NULL, kDNSServiceErr_Unknown);
+	return (_DNSServiceBrowse)(sdRef, flags, interfaceIndex, regtype, domain, callBack, context);
+}
+
+int _wpurple_DNSServiceConstructFullName(char *fullName, const char *service, const char *regtype, const char *domain) {
+	g_return_val_if_fail(_DNSServiceConstructFullName != NULL, 0);
+	return (_DNSServiceConstructFullName)(fullName, service, regtype, domain);
+}
+
+DNSServiceErrorType _wpurple_DNSServiceGetAddrInfo(DNSServiceRef *sdRef, DNSServiceFlags flags, uint32_t interfaceIndex,
+		DNSServiceProtocol protocol, const char *hostname, DNSServiceGetAddrInfoReply callBack, void *context) {
+	g_return_val_if_fail(_DNSServiceGetAddrInfo != NULL, 0);
+	return (_DNSServiceGetAddrInfo)(sdRef, flags, interfaceIndex, protocol, hostname, callBack, context);
+}
+
+DNSServiceErrorType _wpurple_DNSServiceProcessResult(DNSServiceRef sdRef) {
+	g_return_val_if_fail(_DNSServiceProcessResult != NULL, kDNSServiceErr_Unknown);
+	return (_DNSServiceProcessResult)(sdRef);
+}
+
+
+DNSServiceErrorType _wpurple_DNSServiceQueryRecord(DNSServiceRef *sdRef, DNSServiceFlags flags, uint32_t interfaceIndex,
+		const char *fullname, uint16_t rrtype, uint16_t rrclass, DNSServiceQueryRecordReply callBack, void *context) {
+	g_return_val_if_fail(_DNSServiceQueryRecord != NULL, kDNSServiceErr_Unknown);
+	return (_DNSServiceQueryRecord)(sdRef, flags, interfaceIndex, fullname, rrtype, rrclass, callBack, context);
+}
+
+void _wpurple_DNSServiceRefDeallocate(DNSServiceRef sdRef) {
+	g_return_if_fail(_DNSServiceRefDeallocate != NULL);
+	(_DNSServiceRefDeallocate)(sdRef);
+}
+
+int _wpurple_DNSServiceRefSockFD(DNSServiceRef sdRef) {
+	g_return_val_if_fail(_DNSServiceRefSockFD != NULL, -1);
+	return (_DNSServiceRefSockFD)(sdRef);
+}
+
+DNSServiceErrorType _wpurple_DNSServiceRegister(DNSServiceRef *sdRef, DNSServiceFlags flags, uint32_t interfaceIndex,
+		const char *name, const char *regtype, const char *domain, const char *host, uint16_t port, uint16_t txtLen,
+		const void *txtRecord, DNSServiceRegisterReply callBack, void *context) {
+	g_return_val_if_fail(_DNSServiceRegister != NULL, kDNSServiceErr_Unknown);
+	return (_DNSServiceRegister)(sdRef, flags, interfaceIndex, name, regtype, domain, host, port, txtLen, txtRecord, callBack, context);
+}
+
+DNSServiceErrorType _wpurple_DNSServiceResolve(DNSServiceRef *sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, const char *name,
+		const char *regtype, const char *domain, DNSServiceResolveReply callBack, void *context) {
+	g_return_val_if_fail(_DNSServiceResolve != NULL, kDNSServiceErr_Unknown);
+	return (_DNSServiceResolve)(sdRef, flags, interfaceIndex, name, regtype, domain, callBack, context);
+}
+
+DNSServiceErrorType _wpurple_DNSServiceRemoveRecord(DNSServiceRef sdRef, DNSRecordRef RecordRef, DNSServiceFlags flags) {
+	g_return_val_if_fail(_DNSServiceRemoveRecord != NULL, kDNSServiceErr_Unknown);
+	return (_DNSServiceRemoveRecord)(sdRef, RecordRef, flags);
+}
+
+DNSServiceErrorType _wpurple_DNSServiceUpdateRecord(DNSServiceRef sdRef, DNSRecordRef RecordRef, DNSServiceFlags flags,
+		uint16_t rdlen, const void *rdata, uint32_t ttl) {
+	g_return_val_if_fail(_DNSServiceUpdateRecord != NULL, kDNSServiceErr_Unknown);
+	return (_DNSServiceUpdateRecord)(sdRef, RecordRef, flags, rdlen, rdata, ttl);
+}
+
+void _wpurple_TXTRecordCreate(TXTRecordRef *txtRecord, uint16_t bufferLen, void *buffer) {
+	g_return_if_fail(_TXTRecordCreate != NULL);
+	(_TXTRecordCreate)(txtRecord, bufferLen, buffer);
+}
+
+void _wpurple_TXTRecordDeallocate(TXTRecordRef *txtRecord) {
+	g_return_if_fail(_TXTRecordDeallocate != NULL);
+	(_TXTRecordDeallocate)(txtRecord);
+}
+
+const void * _wpurple_TXTRecordGetBytesPtr(const TXTRecordRef *txtRecord) {
+	g_return_val_if_fail(_TXTRecordGetBytesPtr != NULL, NULL);
+	return (_TXTRecordGetBytesPtr)(txtRecord);
+}
+
+uint16_t _wpurple_TXTRecordGetLength(const TXTRecordRef *txtRecord) {
+	g_return_val_if_fail(_TXTRecordGetLength != NULL, 0);
+	return (_TXTRecordGetLength)(txtRecord);
+}
+
+const void * _wpurple_TXTRecordGetValuePtr(uint16_t txtLen, const void *txtRecord, const char *key, uint8_t *valueLen) {
+	g_return_val_if_fail(_TXTRecordGetValuePtr != NULL, NULL);
+	return (_TXTRecordGetValuePtr)(txtLen, txtRecord, key, valueLen);
+}
+
+DNSServiceErrorType _wpurple_TXTRecordSetValue(TXTRecordRef *txtRecord, const char *key, uint8_t valueSize, const void *value) {
+	g_return_val_if_fail(_TXTRecordSetValue != NULL, kDNSServiceErr_Unknown);
+	return (_TXTRecordSetValue)(txtRecord, key, valueSize, value);
+}
+
+#endif /*LINK_DNS_SD_DIRECTLY*/
+
--- a/libpurple/protocols/bonjour/dns_sd_proxy.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/protocols/bonjour/dns_sd_proxy.h	Sat Aug 06 03:45:56 2011 +0000
@@ -51,6 +51,11 @@
 #define DNSServiceConstructFullName(fullName, service, regtype, domain) \
 	_wpurple_DNSServiceConstructFullName(fullName, service, regtype, domain)
 
+DNSServiceErrorType _wpurple_DNSServiceGetAddrInfo(DNSServiceRef *sdRef, DNSServiceFlags flags, uint32_t interfaceIndex,
+	DNSServiceProtocol protocol, const char *hostname, DNSServiceGetAddrInfoReply callBack, void *context);
+#define DNSServiceGetAddrInfo(sdRef, flags, interfaceIndex, protocol, hostname, callBack, context) \
+	_wpurple_DNSServiceGetAddrInfo(sdRef, flags, interfaceIndex, protocol, hostname, callBack, context)
+
 DNSServiceErrorType _wpurple_DNSServiceProcessResult(DNSServiceRef sdRef);
 #define DNSServiceProcessResult(sdRef) \
 	_wpurple_DNSServiceProcessResult(sdRef);
--- a/libpurple/protocols/bonjour/jabber.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/protocols/bonjour/jabber.c	Sat Aug 06 03:45:56 2011 +0000
@@ -44,6 +44,11 @@
 #endif
 #include <fcntl.h>
 
+#ifdef HAVE_GETIFADDRS
+#include <ifaddrs.h>
+#endif
+
+
 #include "network.h"
 #include "eventloop.h"
 #include "connection.h"
@@ -381,7 +386,7 @@
 	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", name);
+	purple_debug_info("bonjour", "Received conversation close notification from %s.\n", name);
 
 	if(bconv->pb != NULL)
 		bb = purple_buddy_get_protocol_data(bconv->pb);
@@ -420,7 +425,7 @@
 			bonjour_jabber_close_conversation(bconv);
 			if (bconv->pb != NULL) {
 				BonjourBuddy *bb = purple_buddy_get_protocol_data(bconv->pb);
-				
+
 				if(bb != NULL)
 					bb->conversation = NULL;
 			}
@@ -529,7 +534,7 @@
 	if (bname == NULL)
 		bname = "";
 
-	stream_start = g_strdup_printf(DOCTYPE, purple_account_get_username(bconv->account), bname);
+	stream_start = g_strdup_printf(DOCTYPE, bonjour_get_jid(bconv->account), bname);
 	len = strlen(stream_start);
 
 	bconv->sent_stream_start = PARTIALLY_SENT;
@@ -577,7 +582,7 @@
 }
 
 /* This gets called when we've successfully sent our <stream:stream />
- * AND when we've recieved a <stream:stream /> */
+ * AND when we've received a <stream:stream /> */
 void bonjour_jabber_stream_started(BonjourJabberConversation *bconv) {
 
 	if (bconv->sent_stream_start == NOT_SENT && !bonjour_jabber_send_stream_init(bconv, bconv->socket)) {
@@ -623,15 +628,22 @@
 
 }
 
+#ifndef INET6_ADDRSTRLEN
+#define INET6_ADDRSTRLEN 46
+#endif
+
 static void
 _server_socket_handler(gpointer data, int server_socket, PurpleInputCondition condition)
 {
 	BonjourJabber *jdata = data;
-	struct sockaddr_in their_addr; /* connector's address information */
-	socklen_t sin_size = sizeof(struct sockaddr);
+	struct sockaddr_storage their_addr; /* connector's address information */
+	socklen_t sin_size = sizeof(struct sockaddr_storage);
 	int client_socket;
 	int flags;
-	char *address_text = NULL;
+#ifdef HAVE_INET_NTOP
+	char addrstr[INET6_ADDRSTRLEN];
+#endif
+	const char *address_text;
 	struct _match_buddies_by_address_t *mbba;
 	BonjourJabberConversation *bconv;
 	GSList *buddies;
@@ -640,7 +652,9 @@
 	if (condition != PURPLE_INPUT_READ)
 		return;
 
-	if ((client_socket = accept(server_socket, (struct sockaddr *)&their_addr, &sin_size)) == -1)
+	memset(&their_addr, 0, sin_size);
+
+	if ((client_socket = accept(server_socket, (struct sockaddr*)&their_addr, &sin_size)) == -1)
 		return;
 
 	flags = fcntl(client_socket, F_GETFL);
@@ -650,7 +664,16 @@
 #endif
 
 	/* Look for the buddy that has opened the conversation and fill information */
-	address_text = inet_ntoa(their_addr.sin_addr);
+#ifdef HAVE_INET_NTOP
+	if (their_addr.ss_family == AF_INET6)
+		address_text = inet_ntop(their_addr.ss_family, &((struct sockaddr_in6 *)&their_addr)->sin6_addr,
+			addrstr, sizeof(addrstr));
+	else
+		address_text = inet_ntop(their_addr.ss_family, &((struct sockaddr_in *)&their_addr)->sin_addr,
+			addrstr, sizeof(addrstr));
+#else
+	address_text = inet_ntoa(((struct sockaddr_in *)&their_addr)->sin_addr);
+#endif
 	purple_debug_info("bonjour", "Received incoming connection from %s.\n", address_text);
 	mbba = g_new0(struct _match_buddies_by_address_t, 1);
 	mbba->address = address_text;
@@ -660,7 +683,7 @@
 	g_slist_free(buddies);
 
 	if (mbba->matched_buddies == NULL) {
-		purple_debug_info("bonjour", "We don't like invisible buddies, this is not a superheros comic\n");
+		purple_debug_info("bonjour", "We don't like invisible buddies, this is not a superheroes comic\n");
 		g_free(mbba);
 		close(client_socket);
 		return;
@@ -680,52 +703,42 @@
 
 }
 
-gint
-bonjour_jabber_start(BonjourJabber *jdata)
+static int
+start_serversocket_listening(int port, int socket, struct sockaddr *addr, size_t addr_size, gboolean ip6, gboolean allow_port_fallback)
 {
-	struct sockaddr_in my_addr;
+	int ret_port = port;
 
-	/* Open a listening socket for incoming conversations */
-	jdata->socket = socket(PF_INET, SOCK_STREAM, 0);
-	if (jdata->socket < 0) {
-		gchar *buf = g_strdup_printf(_("Unable to create socket: %s"),
-				g_strerror(errno));
-		purple_connection_error_reason(jdata->account->gc,
-			PURPLE_CONNECTION_ERROR_NETWORK_ERROR, buf);
-		g_free(buf);
-		return -1;
-	}
-
-	memset(&my_addr, 0, sizeof(struct sockaddr_in));
-	my_addr.sin_family = AF_INET;
+	purple_debug_info("bonjour", "Attempting to bind IPv%d socket to port %d.\n", ip6 ? 6 : 4, port);
 
 	/* Try to use the specified port - if it isn't available, use a random port */
-	my_addr.sin_port = htons(jdata->port);
-	if (bind(jdata->socket, (struct sockaddr*)&my_addr, sizeof(struct sockaddr)) != 0)
-	{
+	if (bind(socket, addr, addr_size) != 0) {
+
 		purple_debug_info("bonjour", "Unable to bind to specified "
-				"port %i: %s\n", jdata->port, g_strerror(errno));
-		my_addr.sin_port = 0;
-		if (bind(jdata->socket, (struct sockaddr*)&my_addr, sizeof(struct sockaddr)) != 0)
-		{
-			gchar *buf = g_strdup_printf(_("Unable to bind socket "
-					"to port: %s"), g_strerror(errno));
-			purple_connection_error_reason(jdata->account->gc,
-				PURPLE_CONNECTION_ERROR_NETWORK_ERROR, buf);
-			g_free(buf);
+				"port %i: %s\n", port, g_strerror(errno));
+
+		if (!allow_port_fallback) {
+			purple_debug_warning("bonjour", "Not attempting random port assignment.\n");
 			return -1;
 		}
-		jdata->port = purple_network_get_port_from_fd(jdata->socket);
+#ifdef PF_INET6
+		if (ip6)
+			((struct sockaddr_in6 *) addr)->sin6_port = 0;
+		else
+#endif
+		((struct sockaddr_in *) addr)->sin_port = 0;
+
+		if (bind(socket, addr, addr_size) != 0) {
+			purple_debug_error("bonjour", "Unable to bind IPv%d socket to port: %s\n", ip6 ? 6 : 4, g_strerror(errno));
+			return -1;
+		}
+		ret_port = purple_network_get_port_from_fd(socket);
 	}
 
+	purple_debug_info("bonjour", "Bound IPv%d socket to port %d.\n", ip6 ? 6 : 4, ret_port);
+
 	/* Attempt to listen on the bound socket */
-	if (listen(jdata->socket, 10) != 0)
-	{
-		gchar *buf = g_strdup_printf(_("Unable to listen on socket: %s"),
-				g_strerror(errno));
-		purple_connection_error_reason(jdata->account->gc,
-			PURPLE_CONNECTION_ERROR_NETWORK_ERROR, buf);
-		g_free(buf);
+	if (listen(socket, 10) != 0) {
+		purple_debug_error("bonjour", "Unable to listen on IPv%d socket: %s\n", ip6 ? 6 : 4, g_strerror(errno));
 		return -1;
 	}
 
@@ -739,8 +752,70 @@
 	}
 #endif
 
-	/* Open a watcher in the socket we have just opened */
-	jdata->watcher_id = purple_input_add(jdata->socket, PURPLE_INPUT_READ, _server_socket_handler, jdata);
+	return ret_port;
+}
+
+gint
+bonjour_jabber_start(BonjourJabber *jdata)
+{
+	int ipv6_port = -1, ipv4_port = -1;
+
+	/* Open a listening socket for incoming conversations */
+#ifdef PF_INET6
+	jdata->socket6 = socket(PF_INET6, SOCK_STREAM, 0);
+#endif
+	jdata->socket = socket(PF_INET, SOCK_STREAM, 0);
+	if (jdata->socket == -1 && jdata->socket6 == -1) {
+		purple_debug_error("bonjour", "Unable to create socket: %s",
+				g_strerror(errno));
+		return -1;
+	}
+
+#ifdef PF_INET6
+	if (jdata->socket6 != -1) {
+		struct sockaddr_in6 addr6;
+#ifdef IPV6_V6ONLY
+		int on = 1;
+		setsockopt(jdata->socket6, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on));
+#endif
+	        memset(&addr6, 0, sizeof(addr6));
+		addr6.sin6_family = AF_INET6;
+		addr6.sin6_port = htons(jdata->port);
+      		addr6.sin6_addr = in6addr_any;
+		ipv6_port = start_serversocket_listening(jdata->port, jdata->socket6, (struct sockaddr *) &addr6, sizeof(addr6), TRUE, TRUE);
+		/* Open a watcher in the socket we have just opened */
+		if (ipv6_port > 0) {
+			jdata->watcher_id6 = purple_input_add(jdata->socket6, PURPLE_INPUT_READ, _server_socket_handler, jdata);
+			jdata->port = ipv6_port;
+		} else {
+			purple_debug_error("bonjour", "Failed to start listening on IPv6 socket.\n");
+			close(jdata->socket6);
+			jdata->socket6 = -1;
+		}
+	}
+#endif
+	if (jdata->socket != -1) {
+		struct sockaddr_in addr4;
+		memset(&addr4, 0, sizeof(addr4));
+		addr4.sin_family = AF_INET;
+		addr4.sin_port = htons(jdata->port);
+		ipv4_port = start_serversocket_listening(jdata->port, jdata->socket, (struct sockaddr *) &addr4, sizeof(addr4), FALSE, ipv6_port != -1);
+		/* Open a watcher in the socket we have just opened */
+		if (ipv4_port > 0) {
+			jdata->watcher_id = purple_input_add(jdata->socket, PURPLE_INPUT_READ, _server_socket_handler, jdata);
+			jdata->port = ipv4_port;
+		} else {
+			purple_debug_error("bonjour", "Failed to start listening on IPv4 socket.\n");
+			close(jdata->socket);
+			jdata->socket = -1;
+		}
+	}
+
+	if (!(ipv6_port > 0 || ipv4_port > 0)) {
+		purple_debug_error("bonjour", "Unable to listen on socket: %s",
+				g_strerror(errno));
+		return -1;
+	}
 
 	return jdata->port;
 }
@@ -756,12 +831,45 @@
 	if (source < 0) {
 		PurpleConversation *conv = NULL;
 		PurpleAccount *account = NULL;
+		GSList *tmp = bb->ips;
 
-		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)");
+		purple_debug_error("bonjour", "Error connecting to buddy %s at %s:%d (%s); Trying next IP address\n",
+				   purple_buddy_get_name(pb), bb->conversation->ip, bb->port_p2pj, error);
+
+		/* There may be multiple entries for the same IP - one per
+		 * presence recieved (e.g. multiple interfaces).
+		 * We need to make sure that we find the previously used entry.
+		 */
+		while (tmp && bb->conversation->ip_link != tmp->data)
+			tmp = g_slist_next(tmp);
+		if (tmp)
+			tmp = g_slist_next(tmp);
 
 		account = purple_buddy_get_account(pb);
 
+		if (tmp != NULL) {
+			const gchar *ip;
+			PurpleProxyConnectData *connect_data;
+
+			bb->conversation->ip_link = ip = tmp->data;
+
+			purple_debug_info("bonjour", "Starting conversation with %s at %s:%d\n",
+					  purple_buddy_get_name(pb), ip, bb->port_p2pj);
+
+			connect_data = purple_proxy_connect(purple_account_get_connection(account),
+							    account, ip, bb->port_p2pj, _connected_to_buddy, pb);
+
+			if (connect_data != NULL) {
+				g_free(bb->conversation->ip);
+				bb->conversation->ip = g_strdup(ip);
+				bb->conversation->connect_data = connect_data;
+
+				return;
+			}
+		}
+
+		purple_debug_error("bonjour", "No more addresses for buddy %s. Aborting", purple_buddy_get_name(pb));
+
 		conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bb->name, account);
 		if (conv != NULL)
 			purple_conversation_write(conv, NULL,
@@ -920,10 +1028,9 @@
 	{
 		PurpleProxyConnectData *connect_data;
 		PurpleProxyInfo *proxy_info;
-		/* For better or worse, use the first IP*/
-		const char *ip = bb->ips->data;
+		const char *ip = bb->ips->data; /* Start with the first IP address. */
 
-		purple_debug_info("bonjour", "Starting conversation with %s\n", to);
+		purple_debug_info("bonjour", "Starting conversation with %s at %s:%d\n", to, ip, bb->port_p2pj);
 
 		/* Make sure that the account always has a proxy of "none".
 		 * This is kind of dirty, but proxy_connect_none() isn't exposed. */
@@ -946,6 +1053,7 @@
 
 		bb->conversation = bonjour_jabber_conv_new(pb, jdata->account, ip);
 		bb->conversation->connect_data = connect_data;
+		bb->conversation->ip_link = ip;
 		/* We don't want _send_data() to register the tx_handler;
 		 * that neeeds to wait until we're actually connected. */
 		bb->conversation->tx_handler = 0;
@@ -973,7 +1081,7 @@
 
 	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));
+	xmlnode_set_attrib(message_node, "from", bonjour_get_jid(jdata->account));
 	xmlnode_set_attrib(message_node, "type", "chat");
 
 	/* Enclose the message from the UI within a "font" node */
@@ -1101,6 +1209,10 @@
 		close(jdata->socket);
 	if (jdata->watcher_id > 0)
 		purple_input_remove(jdata->watcher_id);
+	if (jdata->socket6 >= 0)
+		close(jdata->socket6);
+	if (jdata->watcher_id6 > 0)
+		purple_input_remove(jdata->watcher_id6);
 
 	/* Close all the conversation sockets and remove all the watchers after sending end streams */
 	if (jdata->account->gc != NULL) {
@@ -1109,7 +1221,10 @@
 		buddies = purple_find_buddies(jdata->account, NULL);
 		for (l = buddies; l; l = l->next) {
 			BonjourBuddy *bb = purple_buddy_get_protocol_data((PurpleBuddy*) l->data);
-			if (bb != NULL) {
+			if (bb && bb->conversation) {
+				/* Any ongoing connection attempt is cancelled
+				 * by _purple_connection_destroy */
+				bb->conversation->connect_data = NULL;
 				bonjour_jabber_close_conversation(bb->conversation);
 				bb->conversation = NULL;
 			}
@@ -1181,7 +1296,7 @@
 
 	for(l = acc->deny; l != NULL; l = l->next) {
 		const gchar *name = purple_buddy_get_name(pb);
-		const gchar *username = purple_account_get_username(acc);
+		const gchar *username = bonjour_get_jid(acc);
 
 		if(!purple_utf8_strcasecmp(name, (char *)l->data)) {
 			purple_debug_info("bonjour", "%s has been blocked by %s.\n", name, username);
@@ -1195,7 +1310,6 @@
 static void
 xep_iq_parse(xmlnode *packet, PurpleBuddy *pb)
 {
-	xmlnode *child;
 	PurpleAccount *account;
 	PurpleConnection *gc;
 
@@ -1205,7 +1319,7 @@
 		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")))
+	if (xmlnode_get_child(packet, "si") != NULL || xmlnode_get_child(packet, "error") != NULL)
 		xep_si_parse(gc, packet, pb);
 	else
 		xep_bytestreams_parse(gc, packet, pb);
@@ -1234,58 +1348,97 @@
 	return (ret >= 0) ? 0 : -1;
 }
 
-/* This returns a ';' delimited string containing all non-localhost IPs */
-const char *
-purple_network_get_my_ip_ext2(int fd)
+/* This returns a list containing all non-localhost IPs */
+GSList *
+bonjour_jabber_get_local_ips(int fd)
 {
-	char buffer[1024];
-	static char ip_ext[17 * 10];
+	GSList *ips = NULL;
+	const char *address_text;
+	int ret;
+
+#ifdef HAVE_GETIFADDRS /* This is required for IPv6 */
+	{
+	struct ifaddrs *ifap, *ifa;
+	struct sockaddr *addr;
+	char addrstr[INET6_ADDRSTRLEN];
+
+	ret = getifaddrs(&ifap);
+	if (ret != 0) {
+		const char *error = g_strerror(errno);
+		purple_debug_error("bonjour", "getifaddrs() error: %s\n", error ? error : "(null)");
+		return NULL;
+	}
+
+	for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) {
+		if (!(ifa->ifa_flags & IFF_RUNNING) || (ifa->ifa_flags & IFF_LOOPBACK) || ifa->ifa_addr == NULL)
+			continue;
+
+		addr = ifa->ifa_addr;
+		address_text = NULL;
+		switch (addr->sa_family) {
+			case AF_INET:
+				address_text = inet_ntop(addr->sa_family, &((struct sockaddr_in *)addr)->sin_addr,
+					addrstr, sizeof(addrstr));
+				break;
+#ifdef PF_INET6
+			case AF_INET6:
+				address_text = inet_ntop(addr->sa_family, &((struct sockaddr_in6 *)addr)->sin6_addr,
+					addrstr, sizeof(addrstr));
+				break;
+#endif
+		}
+
+		if (address_text != NULL) {
+			if (addr->sa_family == AF_INET)
+				ips = g_slist_append(ips, g_strdup(address_text));
+			else
+				ips = g_slist_prepend(ips, g_strdup(address_text));
+		}
+	}
+
+	freeifaddrs(ifap);
+
+	}
+#else
+	{
 	char *tmp;
-	char *tip;
 	struct ifconf ifc;
 	struct ifreq *ifr;
+	char buffer[1024];
 	struct sockaddr_in *sinptr;
-	guint32 lhost = htonl(127 * 256 * 256 * 256 + 1);
-	long unsigned int add;
 	int source = fd;
-	int len, count = 0;
 
 	if (fd < 0)
 		source = socket(PF_INET, SOCK_STREAM, 0);
 
 	ifc.ifc_len = sizeof(buffer);
 	ifc.ifc_req = (struct ifreq *)buffer;
-	ioctl(source, SIOCGIFCONF, &ifc);
+	ret = ioctl(source, SIOCGIFCONF, &ifc);
 
 	if (fd < 0)
 		close(source);
 
-	memset(ip_ext, 0, sizeof(ip_ext));
-	memcpy(ip_ext, "0.0.0.0", 7);
+	if (ret < 0) {
+		const char *error = g_strerror(errno);
+		purple_debug_error("bonjour", "ioctl(SIOCGIFCONF) error: %s\n", error ? error : "(null)");
+		return NULL;
+	}
+
 	tmp = buffer;
-	tip = ip_ext;
-	while (tmp < buffer + ifc.ifc_len && count < 10)
-	{
+	while (tmp < buffer + ifc.ifc_len) {
 		ifr = (struct ifreq *)tmp;
 		tmp += HX_SIZE_OF_IFREQ(*ifr);
 
-		if (ifr->ifr_addr.sa_family == AF_INET)
-		{
+		if (ifr->ifr_addr.sa_family == AF_INET) {
 			sinptr = (struct sockaddr_in *)&ifr->ifr_addr;
-			if (sinptr->sin_addr.s_addr != lhost)
-			{
-				add = ntohl(sinptr->sin_addr.s_addr);
-				len = g_snprintf(tip, 17, "%lu.%lu.%lu.%lu;",
-					((add >> 24) & 255),
-					((add >> 16) & 255),
-					((add >> 8) & 255),
-					add & 255);
-				tip = &tip[len];
-				count++;
-				continue;
+			if ((ntohl(sinptr->sin_addr.s_addr) >> 24) != 127) {
+				address_text = inet_ntoa(sinptr->sin_addr);
+				ips = g_slist_prepend(ips, g_strdup(address_text));
 			}
-		}
+ 		}
 	}
+	}
+#endif
 
-	return ip_ext;
+	return ips;
 }
--- a/libpurple/protocols/bonjour/jabber.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/protocols/bonjour/jabber.h	Sat Aug 06 03:45:56 2011 +0000
@@ -37,7 +37,9 @@
 {
 	gint port;
 	gint socket;
+	gint socket6;
 	gint watcher_id;
+	gint watcher_id6;
 	PurpleAccount *account;
 	GSList *pending_conversations;
 } BonjourJabber;
@@ -61,6 +63,8 @@
 	/* The following are only needed before attaching to a PurpleBuddy */
 	gchar *buddy_name;
 	gchar *ip;
+	/* This points to a data entry in BonjourBuddy->ips */
+	const gchar *ip_link;
 } BonjourJabberConversation;
 
 /**
@@ -105,6 +109,6 @@
 
 XepIq *xep_iq_new(void *data, XepIqType type, const char *to, const char *from, const char *id);
 int xep_iq_send_and_free(XepIq *iq);
-const char *purple_network_get_my_ip_ext2(int fd);
+GSList * bonjour_jabber_get_local_ips(int fd);
 
 #endif /* _BONJOUR_JABBER_H_ */
--- a/libpurple/protocols/bonjour/mdns_avahi.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/protocols/bonjour/mdns_avahi.c	Sat Aug 06 03:45:56 2011 +0000
@@ -115,7 +115,6 @@
 	AvahiStringList *l;
 	size_t size;
 	char *key, *value;
-	int ret;
 	char ip[AVAHI_ADDRESS_STR_MAX];
 	AvahiBuddyImplData *b_impl;
 	AvahiSvcResolverData *rd;
@@ -189,8 +188,14 @@
 					bb->ips = g_slist_remove(bb->ips, rd->ip);
 					g_free((gchar *) rd->ip);
 				}
-				bb->ips = g_slist_prepend(bb->ips, g_strdup(ip));
-				rd->ip = bb->ips->data;
+				/* IPv6 goes at the front of the list and IPv4 at the end so that we "prefer" IPv6, if present */
+				if (protocol == AVAHI_PROTO_INET6) {
+					rd->ip = g_strdup_printf("%s%%%d", ip, interface);
+					bb->ips = g_slist_prepend(bb->ips, (gchar *) rd->ip);
+				} else {
+					rd->ip = g_strdup(ip);
+					bb->ips = g_slist_append(bb->ips, (gchar *) rd->ip);
+				}
 			}
 
 			bb->port_p2pj = port;
@@ -198,7 +203,7 @@
 			/* Obtain the parameters from the text_record */
 			clear_bonjour_buddy_values(bb);
 			for(l = txt; l != NULL; l = l->next) {
-				if ((ret = avahi_string_list_get_pair(l, &key, &value, &size)) < 0)
+				if (avahi_string_list_get_pair(l, &key, &value, &size) < 0)
 					continue;
 				set_bonjour_buddy_value(bb, key, value, size);
 				/* TODO: Since we're using the glib allocator, I think we
@@ -247,9 +252,9 @@
 			/* A new peer has joined the network and uses iChat bonjour */
 			purple_debug_info("bonjour", "_browser_callback - new service\n");
 			/* Make sure it isn't us */
-			if (purple_utf8_strcasecmp(name, account->username) != 0) {
+			if (purple_utf8_strcasecmp(name, bonjour_get_jid(account)) != 0) {
 				if (!avahi_service_resolver_new(avahi_service_browser_get_client(b),
-						interface, protocol, name, type, domain, AVAHI_PROTO_INET,
+						interface, protocol, name, type, domain, protocol,
 						0, _resolver_callback, account)) {
 					purple_debug_warning("bonjour", "_browser_callback -- Error initiating resolver: %s\n",
 						avahi_strerror(avahi_client_errno(avahi_service_browser_get_client(b))));
@@ -416,6 +421,8 @@
 
 	data->mdns_impl_data = idata;
 
+	bonjour_dns_sd_set_jid(data->account, avahi_client_get_host_name(idata->client));
+
 	return TRUE;
 }
 
@@ -448,15 +455,15 @@
 		case PUBLISH_START:
 			publish_result = avahi_entry_group_add_service_strlst(
 				idata->group, AVAHI_IF_UNSPEC,
-				AVAHI_PROTO_INET, 0,
-				purple_account_get_username(data->account),
+				AVAHI_PROTO_UNSPEC, 0,
+				bonjour_get_jid(data->account),
 				LINK_LOCAL_RECORD_NAME, NULL, NULL, data->port_p2pj, lst);
 			break;
 		case PUBLISH_UPDATE:
 			publish_result = avahi_entry_group_update_service_txt_strlst(
 				idata->group, AVAHI_IF_UNSPEC,
-				AVAHI_PROTO_INET, 0,
-				purple_account_get_username(data->account),
+				AVAHI_PROTO_UNSPEC, 0,
+				bonjour_get_jid(data->account),
 				LINK_LOCAL_RECORD_NAME, NULL, lst);
 			break;
 	}
@@ -487,7 +494,7 @@
 
 	g_return_val_if_fail(idata != NULL, FALSE);
 
-	idata->sb = avahi_service_browser_new(idata->client, AVAHI_IF_UNSPEC, AVAHI_PROTO_INET, LINK_LOCAL_RECORD_NAME, NULL, 0, _browser_callback, data->account);
+	idata->sb = avahi_service_browser_new(idata->client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, LINK_LOCAL_RECORD_NAME, NULL, 0, _browser_callback, data->account);
 	if (!idata->sb) {
 
 		purple_debug_error("bonjour",
@@ -530,10 +537,10 @@
 		}
 
 		svc_name = g_strdup_printf("%s." LINK_LOCAL_RECORD_NAME "local",
-				purple_account_get_username(data->account));
+				bonjour_get_jid(data->account));
 
 		ret = avahi_entry_group_add_record(idata->buddy_icon_group, AVAHI_IF_UNSPEC,
-			AVAHI_PROTO_INET, flags, svc_name,
+			AVAHI_PROTO_UNSPEC, flags, svc_name,
 			AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_NULL, 120, avatar_data, avatar_len);
 
 		g_free(svc_name);
@@ -622,7 +629,7 @@
 
 	name = g_strdup_printf("%s." LINK_LOCAL_RECORD_NAME "local", buddy->name);
 	idata->buddy_icon_rec_browser = avahi_record_browser_new(session_idata->client, AVAHI_IF_UNSPEC,
-		AVAHI_PROTO_INET, name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_NULL, 0,
+		AVAHI_PROTO_UNSPEC, name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_NULL, 0,
 		_buddy_icon_record_cb, buddy);
 	g_free(name);
 
--- a/libpurple/protocols/bonjour/mdns_common.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/protocols/bonjour/mdns_common.c	Sat Aug 06 03:45:56 2011 +0000
@@ -252,3 +252,36 @@
 void bonjour_dns_sd_stop(BonjourDnsSd *data) {
 	_mdns_stop(data);
 }
+
+void
+bonjour_dns_sd_set_jid(PurpleAccount *account, const char *hostname)
+{
+	PurpleConnection *conn = purple_account_get_connection(account);
+	BonjourData *bd = conn->proto_data;
+	const char *tmp, *account_name = purple_account_get_username(account);
+
+	/* Previously we allowed the hostname part of the jid to be set
+	 * explicitly when it should always be the current hostname.
+	 * That is what this is intended to deal with.
+	 */
+	if ((tmp = strchr(account_name, '@'))
+	    && strstr(tmp, hostname) == (tmp + 1)
+	    && *((tmp + 1) + strlen(hostname)) == '\0')
+		bd->jid = g_strdup(account_name);
+	else {
+		const char *tmp2;
+		GString *str = g_string_new("");
+		/* Escape an '@' in the account name */
+		tmp = account_name;
+		while ((tmp2 = strchr(tmp, '@')) != NULL) {
+			g_string_append_len(str, tmp, tmp2 - tmp);
+			g_string_append(str, "\\40");
+			tmp = tmp2 + 1;
+		}
+		g_string_append(str, tmp);
+		g_string_append_c(str, '@');
+		g_string_append(str, hostname);
+
+		bd->jid = g_string_free(str, FALSE);
+	}
+}
--- a/libpurple/protocols/bonjour/mdns_common.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/protocols/bonjour/mdns_common.h	Sat Aug 06 03:45:56 2011 +0000
@@ -57,4 +57,6 @@
  */
 void bonjour_dns_sd_stop(BonjourDnsSd *data);
 
+void bonjour_dns_sd_set_jid(PurpleAccount *account, const char *hostname);
+
 #endif
--- a/libpurple/protocols/bonjour/mdns_win32.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/protocols/bonjour/mdns_win32.c	Sat Aug 06 03:45:56 2011 +0000
@@ -25,8 +25,8 @@
 #include "buddy.h"
 #include "mdns_interface.h"
 #include "dns_sd_proxy.h"
-#include "dnsquery.h"
 #include "mdns_common.h"
+#include "bonjour.h"
 
 static GSList *pending_buddies = NULL;
 
@@ -65,7 +65,6 @@
 	BonjourBuddy *bb;
 	Win32SvcResolverData *res_data;
 	gchar *full_service_name;
-	PurpleDnsQueryData *dns_query;
 } ResolveCallbackArgs;
 
 
@@ -135,7 +134,7 @@
 {
 
 	if (errorCode != kDNSServiceErr_NoError) {
-		purple_debug_error("bonjour", "record query - callback error.\n");
+		purple_debug_error("bonjour", "record query - callback error (%d).\n", errorCode);
 		/* TODO: Probably should remove the buddy when this happens */
 	} else if (flags & kDNSServiceFlagsAdd) {
 		if (rrtype == kDNSServiceType_TXT) {
@@ -161,14 +160,22 @@
 	}
 }
 
-static void
-_mdns_resolve_host_callback(GSList *hosts, gpointer data, const char *error_message)
+static void DNSSD_API
+_mdns_resolve_host_callback(DNSServiceRef sdRef, DNSServiceFlags flags,
+	uint32_t interfaceIndex, DNSServiceErrorType errorCode,
+	const char *hostname, const struct sockaddr *address,
+	uint32_t ttl, void *context)
 {
-	ResolveCallbackArgs *args = (ResolveCallbackArgs*) data;
+	ResolveCallbackArgs *args = (ResolveCallbackArgs*) context;
 	Win32BuddyImplData *idata = args->bb->mdns_impl_data;
 	gboolean delete_buddy = FALSE;
 	PurpleBuddy *pb = NULL;
 
+	purple_input_remove(args->resolver_query->input_handler);
+	DNSServiceRefDeallocate(args->resolver_query->sdRef);
+	g_free(args->resolver_query);
+	args->resolver_query = NULL;
+
 	if ((pb = purple_find_buddy(args->account, args->res_data->name))) {
 		if (pb->proto_data != args->bb) {
 			purple_debug_error("bonjour", "Found purple buddy for %s not matching bonjour buddy record.",
@@ -181,12 +188,10 @@
 		goto cleanup;
 	}
 
-	if (!hosts || !hosts->data) {
-		purple_debug_error("bonjour", "host resolution - callback error.\n");
+	if (errorCode != kDNSServiceErr_NoError) {
+		purple_debug_error("bonjour", "host resolution - callback error (%d).\n", errorCode);
 		delete_buddy = TRUE;
 	} else {
-		struct sockaddr_in *addr = g_slist_nth_data(hosts, 1);
-		DNSServiceErrorType errorCode;
 		DNSServiceRef txt_query_sr;
 
 		/* finally, set up the continuous txt record watcher, and add the buddy to purple */
@@ -194,7 +199,7 @@
 				kDNSServiceInterfaceIndexAny, args->full_service_name, kDNSServiceType_TXT,
 				kDNSServiceClass_IN, _mdns_record_query_callback, args->bb);
 		if (errorCode == kDNSServiceErr_NoError) {
-			const char *ip = inet_ntoa(addr->sin_addr);
+			const char *ip = inet_ntoa(((struct sockaddr_in *) address)->sin_addr);
 
 			purple_debug_info("bonjour", "Found buddy %s at %s:%d\n", args->bb->name, ip, args->bb->port_p2pj);
 
@@ -218,13 +223,6 @@
 
 	cleanup:
 
-	/* free the hosts list*/
-	while (hosts != NULL) {
-		hosts = g_slist_remove(hosts, hosts->data);
-		g_free(hosts->data);
-		hosts = g_slist_remove(hosts, hosts->data);
-	}
-
 	if (delete_buddy) {
 		idata->resolvers = g_slist_remove(idata->resolvers, args->res_data);
 		_cleanup_resolver_data(args->res_data);
@@ -251,7 +249,7 @@
 
 static void DNSSD_API
 _mdns_service_resolve_callback(DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, DNSServiceErrorType errorCode,
-    const char *fullname, const char *hosttarget, uint16_t port, uint16_t txtLen, const char *txtRecord, void *context)
+    const char *fullname, const char *hosttarget, uint16_t port, uint16_t txtLen, const unsigned char *txtRecord, void *context)
 {
 	ResolveCallbackArgs *args = (ResolveCallbackArgs*) context;
 	Win32BuddyImplData *idata = args->bb->mdns_impl_data;
@@ -259,17 +257,20 @@
 	/* remove the input fd and destroy the service ref */
 	purple_input_remove(args->resolver_query->input_handler);
 	DNSServiceRefDeallocate(args->resolver_query->sdRef);
-	g_free(args->resolver_query);
-	args->resolver_query = NULL;
 
 	if (errorCode != kDNSServiceErr_NoError)
-		purple_debug_error("bonjour", "service resolver - callback error.\n");
+		purple_debug_error("bonjour", "service resolver - callback error. (%d)\n", errorCode);
 	else {
+		DNSServiceRef getaddrinfo_sr;
 		/* set more arguments, and start the host resolver */
-
-		if ((args->dns_query =
-				purple_dnsquery_a(hosttarget, port, _mdns_resolve_host_callback, args)) != NULL) {
-
+		errorCode = DNSServiceGetAddrInfo(&getaddrinfo_sr, 0, interfaceIndex,
+			kDNSServiceProtocol_IPv4, hosttarget, _mdns_resolve_host_callback, args);
+		if (errorCode != kDNSServiceErr_NoError)
+			purple_debug_error("bonjour", "service resolver - host resolution failed.\n");
+		else {
+			args->resolver_query->sdRef = getaddrinfo_sr;
+			args->resolver_query->input_handler = purple_input_add(DNSServiceRefSockFD(getaddrinfo_sr),
+				PURPLE_INPUT_READ, _mdns_handle_event, args->resolver_query);
 			args->full_service_name = g_strdup(fullname);
 
 			/* TODO: Should this be per resolver? */
@@ -277,12 +278,14 @@
 
 			/* We don't want to hit the cleanup code */
 			return;
-		} else
-			purple_debug_error("bonjour", "service resolver - host resolution failed.\n");
+		}
 	}
 
 	/* If we get this far, clean up */
 
+	g_free(args->resolver_query);
+	args->resolver_query = NULL;
+
 	idata->resolvers = g_slist_remove(idata->resolvers, args->res_data);
 	_cleanup_resolver_data(args->res_data);
 
@@ -324,7 +327,7 @@
 		purple_debug_error("bonjour", "service browser - callback error (%d)\n", errorCode);
 	else if (flags & kDNSServiceFlagsAdd) {
 		/* A presence service instance has been discovered... check it isn't us! */
-		if (purple_utf8_strcasecmp(serviceName, account->username) != 0) {
+		if (purple_utf8_strcasecmp(serviceName, bonjour_get_jid(account)) != 0) {
 			DNSServiceErrorType resErrorCode;
 			/* OK, lets go ahead and resolve it to add to the buddy list */
 			ResolveCallbackArgs *args = g_new0(ResolveCallbackArgs, 1);
@@ -334,7 +337,7 @@
 							  serviceName, interfaceIndex, regtype ? regtype : "",
 							  replyDomain ? replyDomain : "");
 
-			resErrorCode = DNSServiceResolve(&resolver_sr, 0, 0, serviceName, regtype,
+			resErrorCode = DNSServiceResolve(&resolver_sr, 0, interfaceIndex, serviceName, regtype,
 					replyDomain, _mdns_service_resolve_callback, args);
 			if (resErrorCode == kDNSServiceErr_NoError) {
 				GSList *tmp = pending_buddies;
@@ -452,6 +455,9 @@
 
 gboolean _mdns_init_session(BonjourDnsSd *data) {
 	data->mdns_impl_data = g_new0(Win32SessionImplData, 1);
+
+	bonjour_dns_sd_set_jid(data->account, purple_get_host_name());
+
 	return TRUE;
 }
 
@@ -483,7 +489,8 @@
 		switch (type) {
 			case PUBLISH_START:
 				purple_debug_info("bonjour", "Registering presence on port %d\n", data->port_p2pj);
-				errorCode = DNSServiceRegister(&presence_sr, 0, 0, purple_account_get_username(data->account), LINK_LOCAL_RECORD_NAME,
+				errorCode = DNSServiceRegister(&presence_sr, kDNSServiceInterfaceIndexAny,
+					0, bonjour_get_jid(data->account), LINK_LOCAL_RECORD_NAME,
 					NULL, NULL, htons(data->port_p2pj), TXTRecordGetLength(&dns_data), TXTRecordGetBytesPtr(&dns_data),
 					_mdns_service_register_callback, NULL);
 				break;
@@ -522,8 +529,9 @@
 
 	g_return_val_if_fail(idata != NULL, FALSE);
 
-	errorCode = DNSServiceBrowse(&browser_sr, 0, 0, LINK_LOCAL_RECORD_NAME, NULL,
-		_mdns_service_browse_callback, data->account);
+	errorCode = DNSServiceBrowse(&browser_sr, 0, kDNSServiceInterfaceIndexAny,
+			LINK_LOCAL_RECORD_NAME, NULL,_mdns_service_browse_callback,
+			data->account);
 	if (errorCode == kDNSServiceErr_NoError) {
 		idata->browser_query = g_new(DnsSDServiceRefHandlerData, 1);
 		idata->browser_query->sdRef = browser_sr;
--- a/libpurple/protocols/bonjour/parser.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/protocols/bonjour/parser.c	Sat Aug 06 03:45:56 2011 +0000
@@ -102,7 +102,7 @@
 			attrib[attrib_len] = '\0';
 
 			txt = attrib;
-			attrib = purple_unescape_html(txt);
+			attrib = purple_unescape_text(txt);
 			g_free(txt);
 			xmlnode_set_attrib_full(node, name, attrib_ns, prefix, attrib);
 			g_free(attrib);
--- a/libpurple/protocols/gg/Makefile.am	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/protocols/gg/Makefile.am	Sat Aug 06 03:45:56 2011 +0000
@@ -4,14 +4,30 @@
 	lib/compat.h \
 	lib/COPYING \
 	lib/dcc.c \
+	lib/dcc7.c \
+	lib/debug.c \
+	lib/deflate.c \
+	lib/deflate.h \
+	lib/encoding.c \
+	lib/encoding.h \
 	lib/events.c \
+	lib/handlers.c \
 	lib/http.c \
+	lib/libgadu.h \
 	lib/libgadu.c \
 	lib/libgadu-config.h \
-	lib/libgadu.h \
+	lib/libgadu-debug.h \
+	lib/libgadu-internal.h \
+	lib/message.c \
+	lib/message.h \
 	lib/obsolete.c \
+	lib/protocol.h \
+	lib/pubdir.c \
 	lib/pubdir50.c \
-	lib/pubdir.c
+	lib/resolver.c \
+	lib/resolver.h \
+	lib/session.h \
+	lib/sha1.c
 
 pkgdir = $(libdir)/purple-$(PURPLE_MAJOR_VERSION)
 
@@ -20,16 +36,36 @@
 	lib/common.c \
 	lib/compat.h \
 	lib/dcc.c \
+	lib/dcc7.c \
+	lib/debug.c \
+	lib/deflate.c \
+	lib/deflate.h \
+	lib/encoding.c \
+	lib/encoding.h \
 	lib/events.c \
+	lib/handlers.c \
 	lib/http.c \
+	lib/libgadu.h \
 	lib/libgadu.c \
 	lib/libgadu-config.h \
-	lib/libgadu.h \
+	lib/libgadu-internal.h \
+	lib/message.c \
+	lib/message.h \
 	lib/obsolete.c \
+	lib/protocol.h \
+	lib/pubdir.c \
 	lib/pubdir50.c \
-	lib/pubdir.c
+	lib/resolver.c \
+	lib/resolver.h \
+	lib/session.h \
+	lib/sha1.c
 
-INTGG_CFLAGS = -I$(top_srcdir)/libpurple/protocols/gg/lib
+INTGG_CFLAGS = -I$(top_srcdir)/libpurple/protocols/gg/lib -DGG_IGNORE_DEPRECATED -DUSE_INTERNAL_LIBGADU
+
+if USE_GNUTLS
+GADU_LIBS += $(GNUTLS_LIBS)
+endif
+
 endif
 
 GGSOURCES = \
--- a/libpurple/protocols/gg/Makefile.mingw	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/protocols/gg/Makefile.mingw	Sat Aug 06 03:45:56 2011 +0000
@@ -8,7 +8,7 @@
 include $(PIDGIN_TREE_TOP)/libpurple/win32/global.mak
 
 TARGET = libgg
-CFLAGS += -include win32dep.h
+CFLAGS += -include win32dep.h -DGG_IGNORE_DEPRECATED
 TYPE = PLUGIN
 
 # Static or Plugin...
@@ -41,12 +41,21 @@
 ##
 C_SRC =	\
 	lib/common.c \
+	lib/dcc.c \
+	lib/dcc7.c \
+	lib/debug.c \
+	lib/deflate.c \
+	lib/encoding.c \
 	lib/events.c \
+	lib/handlers.c \
 	lib/http.c \
 	lib/libgadu.c \
+	lib/message.c \
 	lib/obsolete.c \
 	lib/pubdir.c \
 	lib/pubdir50.c \
+	lib/resolver.c \
+	lib/sha1.c \
 	buddylist.c \
 	confer.c \
 	gg.c \
--- a/libpurple/protocols/gg/buddylist.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/protocols/gg/buddylist.c	Sat Aug 06 03:45:56 2011 +0000
@@ -95,7 +95,7 @@
 
 		data_tbl = g_strsplit(users_tbl[i], ";", 8);
 		if (ggp_array_size(data_tbl) < 8) {
-			purple_debug_warning("gg", 
+			purple_debug_warning("gg",
 				"Something is wrong on line %d of the buddylist. Skipping.\n",
 				i + 1);
 			continue;
--- a/libpurple/protocols/gg/buddylist.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/protocols/gg/buddylist.h	Sat Aug 06 03:45:56 2011 +0000
@@ -44,7 +44,7 @@
  * Get all the buddies in the current account.
  *
  * @param account Current account.
- * 
+ *
  * @return List of buddies.
  */
 char *
--- a/libpurple/protocols/gg/confer.h	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/protocols/gg/confer.h	Sat Aug 06 03:45:56 2011 +0000
@@ -39,7 +39,7 @@
 
 /**
  * Adds the specified UIN to the specified conversation.
- * 
+ *
  * @param gc        PurpleConnection.
  * @param chat_name Name of the conversation.
  */
@@ -61,7 +61,7 @@
 
 /**
  * Finds a conversation in which all the specified recipients participate.
- * 
+ *
  * TODO: This function should be rewritten to better handle situations when
  * somebody adds more people to the converation.
  *
@@ -81,7 +81,7 @@
  *
  * @param gc   PurpleConnection.
  * @param name Name of the conversation.
- * 
+ *
  * @return Name of the conversation.
  */
 const char*
--- a/libpurple/protocols/gg/gg.c	Thu Jun 16 04:37:03 2011 +0000
+++ b/libpurple/protocols/gg/gg.c	Sat Aug 06 03:45:56 2011 +0000
@@ -49,6 +49,10 @@
 
 static PurplePlugin *my_protocol = NULL;
 
+/* Prototypes */
+static void ggp_set_status(PurpleAccount *account, PurpleStatus *status);
+static int ggp_to_gg_status(PurpleStatus *status, char **msg);
+
 /* ---------------------------------------------------------------------- */
 /* ----- EXTERNAL CALLBACKS --------------------------------------------- */
 /* ---------------------------------------------------------------------- */
@@ -215,7 +219,7 @@
 	char *buddylist = ggp_buddylist_dump(purple_connection_get_account(gc));
 
 	purple_debug_info("gg", "Uploading...\n");
-	
+
 	if (buddylist == NULL)
 		return;
 
@@ -483,15 +487,16 @@
 	GGPSearchForm *form = user_data;
 	guint32 seq;
 
-	g_free(form->offset);
-	form->offset = g_strdup(form->last_uin);
+	form->page_number++;
 
 	ggp_search_remove(info->searches, form->seq);
-	purple_debug_info("gg", "ggp_callback_show_next(): Removed seq %u", form->seq);
+	purple_debug_info("gg", "ggp_callback_show_next(): Removed seq %u\n",
+		form->seq);
 
 	seq = ggp_search_start(gc, form);
 	ggp_search_add(info->searches, seq, form);
-	purple_debug_info("gg", "ggp_callback_show_next(): Added seq %u", seq);
+	purple_debug_info("gg", "ggp_callback_show_next(): Added seq %u\n",
+		seq);
 }
 
 static void ggp_callback_add_buddy(PurpleConnection *gc, GList *row, gpointer user_data)
@@ -522,21 +527,16 @@
 	form = ggp_search_form_new(GGP_SEARCH_TYPE_FULL);
 
 	form->user_data = info;
-	form->lastname  = charset_convert(
-				purple_request_fields_get_string(fields, "lastname"),
-				"UTF-8", "CP1250");
-	form->firstname = charset_convert(
-				purple_request_fields_get_string(fields, "firstname"),
-				"UTF-8", "CP1250");
-	form->nickname  = charset_convert(
-				purple_request_fields_get_string(fields, "nickname"),
-				"UTF-8", "CP1250");
-	form->city      = charset_convert(
-				purple_request_fields_get_string(fields, "city"),
-				"UTF-8", "CP1250");
-	form->birthyear = charset_convert(
-				purple_request_fields_get_string(fields, "year"),
-				"UTF-8", "CP1250");
+	form->lastname = g_strdup(
+		purple_request_fields_get_string(fields, "lastname"));
+	form->firstname = g_strdup(
+		purple_request_fields_get_string(fields, "firstname"));
+	form->nickname = g_strdup(
+		purple_request_fields_get_string(fields, "nickname"));
+	form->city = g_strdup(
+		purple_request_fields_get_string(fields, "city"));
+	form->birthyear = g_strdup(
+		purple_request_fields_get_string(fields, "year"));
 
 	switch (purple_request_fields_get_choice(fields, "gender")) {
 		case 1:
@@ -553,11 +553,10 @@
 	form->active = purple_request_fields_get_bool(fields, "active")
 				   ? g_strdup(GG_PUBDIR50_ACTIVE_TRUE) : NULL;
 
-	form->offset = g_strdup("0");
-
 	seq = ggp_search_start(gc, form);
 	ggp_search_add(info->searches, seq, form);
-	purple_debug_info("gg", "ggp_callback_find_buddies(): Added seq %u", seq);
+	purple_debug_info("gg", "ggp_callback_find_buddies(): Added seq %u\n",
+		seq);
 }
 
 static void ggp_find_buddies(PurplePluginAction *action)
@@ -755,11 +754,65 @@
 	ggp_token_request(gc, ggp_change_passwd_dialog);
 }
 
+/* ----- CHANGE STATUS BROADCASTING ------------------------------------------------ */
+
+static void ggp_action_change_status_broadcasting_ok(PurpleConnection *gc, PurpleRequestFields *fields)
+{
+	GGPInfo *info = gc->proto_data;
+	int selected_field;
+	PurpleAccount *account = purple_connection_get_account(gc);
+	PurpleStatus *status;
+
+	selected_field = purple_request_fields_get_choice(fields, "status_broadcasting");
+	
+	if (selected_field == 0)
+		info->status_broadcasting = TRUE;
+	else
+		info->status_broadcasting = FALSE;
+	
+	status = purple_account_get_active_status(account);
+	
+	ggp_set_status(account, status);
+}
+
+static void ggp_action_change_status_broadcasting(PurplePluginAction *action)
+{
+	PurpleConnection *gc = (PurpleConnection *)action->context;
+	GGPInfo *info = gc->proto_data;
+	
+	PurpleRequestFields *fields;
+	PurpleRequestFieldGroup *group;
+	PurpleRequestField *field;
+
+	fields = purple_request_fields_new();
+	group = purple_request_field_group_new(NULL);
+	purple_request_fields_add_group(fields, group);
+	
+	field = purple_request_field_choice_new("status_broadcasting", _("Show status to:"), 0);
+	purple_request_field_choice_add(field, _("All people"));
+	purple_request_field_choice_add(field, _("Only buddies"));
+	purple_request_field_group_add_field(group, field);
+
+	if (info->status_broadcasting)
+		purple_request_field_choice_set_default_value(field, 0);
+	else
+		purple_request_field_choice_set_default_value(field, 1);
+
+	purple_request_fields(gc,
+		_("Change status broadcasting"),
+		_("Change status broadcasting"),
+		_("Please, select who can see your status"),
+		fields,
+		_("OK"), G_CALLBACK(ggp_action_change_status_broadcasting_ok),
+		_("Cancel"), NULL,
+		purple_connection_get_account(gc), NULL, NULL,
+		gc);
+}
+
 /* ----- CONFERENCES ---------------------------------------------------- */
 
 static void ggp_callback_add_to_chat_ok(PurpleBuddy *buddy, PurpleRequestFields *fields)
 {
-	GGPInfo *info;
 	PurpleConnection *conn;
 	PurpleRequestField *field;
 	GList *sel;
@@ -768,8 +821,6 @@
 
 	g_return_if_fail(conn != NULL);
 
-	info = conn->proto_data;
-
 	field = purple_request_fields_get_field(fields, "name");
 	sel = purple_request_field_list_get_selected(field);
 
@@ -826,40 +877,32 @@
 
 /* ----- BLOCK BUDDIES -------------------------------------------------- */
 
-static void ggp_bmenu_block(PurpleBlistNode *node, gpointer ignored)
+static void ggp_add_deny(PurpleConnection *gc, const char *who)
 {
-	PurpleConnection *gc;
-	PurpleBuddy *buddy;
-	GGPInfo *info;
-	uin_t uin;
-
-	buddy = (PurpleBuddy *)node;
-	gc = purple_account_get_connection(purple_buddy_get_account(buddy));
-	info = gc->proto_data;
-
-	uin = ggp_str_to_uin(purple_buddy_get_name(buddy));
-
-	if (purple_blist_node_get_bool(node, "blocked")) {
-		purple_blist_node_set_bool(node, "blocked", FALSE);
-		gg_remove_notify_ex(info->session, uin, GG_USER_BLOCKED);
-		gg_add_notify_ex(info->session, uin, GG_USER_NORMAL);
-		purple_debug_info("gg", "send: uin=%d; mode=NORMAL\n", uin);
-	} else {
-		purple_blist_node_set_bool(node, "blocked", TRUE);
-		gg_remove_notify_ex(info->session, uin, GG_USER_NORMAL);
-		gg_add_notify_ex(info->session, uin, GG_USER_BLOCKED);
-		purple_debug_info("gg", "send: uin=%d; mode=BLOCKED\n", uin);
-	}
+	GGPInfo *info = gc->proto_data;
+	uin_t uin = ggp_str_to_uin(who);
+	
+	purple_debug_info("gg", "ggp_add_deny: %u\n", uin);
+	
+	gg_remove_notify_ex(info->session, uin, GG_USER_NORMAL);
+	gg_add_notify_ex(info->session, uin, GG_USER_BLOCKED);
+}
+
+static void ggp_rem_deny(PurpleConnection *gc, const char *who)
+{
+	GGPInfo *info = gc->proto_data;
+	uin_t uin = ggp_str_to_uin(who);
+	
+	purple_debug_info("gg", "ggp_rem_deny: %u\n", uin);
+	
+	gg_remove_notify_ex(info->session, uin, GG_USER_BLOCKED);
+	gg_add_notify_ex(info->session, uin, GG_USER_NORMAL);
 }
 
 /* ---------------------------------------------------------------------- */
 /* ----- INTERNAL CALLBACKS --------------------------------------------- */
 /* ---------------------------------------------------------------------- */
 
-/* Prototypes */
-static void ggp_set_status(PurpleAccount *account, PurpleStatus *status);
-static int ggp_to_gg_status(PurpleStatus *status, char **msg);
-
 struct gg_fetch_avatar_data
 {
 	PurpleConnection *gc;
@@ -989,6 +1032,29 @@
 }
 
 /**
+ * Try to update avatar of the buddy.
+ *
+ * @param gc     PurpleConnection
+ * @param uin    UIN of the buddy.
+ */
+static void ggp_update_buddy_avatar(PurpleConnection *gc, uin_t uin)
+{
+	gchar *avatarurl;
+	PurpleUtilFetchUrlData *url_data;
+
+	purple_debug_info("gg", "ggp_update_buddy_avatar(gc, %u)\n", uin);
+
+	avatarurl = g_strdup_printf("http://api.gadu-gadu.pl/avatars/%u/0.xml", uin);
+
+	url_data = purple_util_fetch_url_request_len_with_account(
+			purple_connection_get_account(gc), avatarurl, TRUE,
+			"Mozilla/4.0 (compatible; MSIE 5.5)", FALSE, NULL, FALSE, -1,
+			gg_get_avatar_url_cb, gc);
+
+	g_free(avatarurl);
+}
+
+/**
  * Handle change of the status of the buddy.
  *
  * @param gc     PurpleConnection
@@ -1001,50 +1067,64 @@
 {
 	gchar *from;
 	const char *st;
-	gchar *msg;
-	gchar *avatarurl;
-	PurpleUtilFetchUrlData *url_data;
+	char *status_msg = NULL;
+
+	ggp_update_buddy_avatar(gc, uin);
 
 	from = g_strdup_printf("%u", uin);
-	avatarurl = g_strdup_printf("http://api.gadu-gadu.pl/avatars/%s/0.xml", from);
-
-	url_data = purple_util_fetch_url_request_len_with_account(
-			purple_connection_get_account(gc), avatarurl, TRUE,
-			"Mozilla/4.0 (compatible; MSIE 5.5)", FALSE, NULL, FALSE, -1,
-			gg_get_avatar_url_cb, gc);
-
-	g_free(avatarurl);
 
 	switch (status) {
 		case GG_STATUS_NOT_AVAIL:
 		case GG_STATUS_NOT_AVAIL_DESCR:
-			st = "offline";
+			st = purple_primitive_get_id_from_type(PURPLE_STATUS_OFFLINE);
+			break;
+		case GG_STATUS_FFC:
+		case GG_STATUS_FFC_DESCR:
+			st = purple_primitive_get_id_from_type(PURPLE_STATUS_AVAILABLE);
 			break;
 		case GG_STATUS_AVAIL:
 		case GG_STATUS_AVAIL_DESCR:
-			st = "available";
+			st = purple_primitive_get_id_from_type(PURPLE_STATUS_AVAILABLE);
 			break;
 		case GG_STATUS_BUSY:
 		case GG_STATUS_BUSY_DESCR:
-			st = "away";
+			st = purple_primitive_get_id_from_type(PURPLE_STATUS_AWAY);
+			break;
+		case GG_STATUS_DND:
+		case GG_STATUS_DND_DESCR:
+			st = purple_primitive_get_id_from_type(PURPLE_STATUS_UNAVAILABLE);
 			break;
 		case GG_STATUS_BLOCKED:
 			/* user is blocking us.... */
 			st = "blocked";
 			break;
 		default:
-			st = "available";
+			st = purple_primitive_get_id_from_type(PURPLE_STATUS_AVAILABLE);
 			purple_debug_info("gg",
 				"GG_EVENT_NOTIFY: Unknown status: %d\n", status);
 			break;
 	}
 
-	purple_debug_info("gg", "st = %s\n", st);
-	msg = charset_convert(descr, "CP1250", "UTF-8");
-	purple_prpl_got_user_status(purple_connection_get_account(gc),
-				  from, st, "message", msg, NULL);
+	if (descr != NULL) {
+		status_msg = g_strdup(descr);
+		g_strstrip(status_msg);
+		if (status_msg[0] == '\0') {
+			g_free(status_msg);
+			status_msg = NULL;
+		}
+	}
+
+	purple_debug_info("gg", "status of %u is %s [%s]\n", uin, st,
+		status_msg ? status_msg : "");
+	if (status_msg == NULL) {
+		purple_prpl_got_user_status(purple_connection_get_account(gc),
+			from, st, NULL);
+	} else {
+		purple_prpl_got_user_status(purple_connection_get_account(gc),
+			from, st, "message", status_msg, NULL);
+		g_free(status_msg);
+	}
 	g_free(from);
-	g_free(msg);
 }
 
 static void ggp_sr_close_cb(gpointer user_data)
@@ -1053,7 +1133,8 @@
 	GGPInfo *info = form->user_data;
 
 	ggp_search_remove(info->searches, form->seq);
-	purple_debug_info("gg", "ggp_sr_close_cb(): Removed seq %u", form->seq);
+	purple_debug_info("gg", "ggp_sr_close_cb(): Removed seq %u\n",
+		form->seq);
 	ggp_search_form_destroy(form);
 }
 
@@ -1078,6 +1159,12 @@
 		case GG_STATUS_AVAIL_DESCR:
 			st = _("Available");
 			break;
+		case GG_STATUS_FFC:
+		case GG_STATUS_FFC_DESCR:
+			return _("Chatty");
+		case GG_STATUS_DND:
+		case GG_STATUS_DND_DESCR:
+			return _("Do Not Disturb");
 		case GG_STATUS_BUSY:
 		case GG_STATUS_BUSY_DESCR:
 			st = _("Away");
@@ -1162,6 +1249,8 @@
 
 	res_count = gg_pubdir50_count(req);
 	res_count = (res_count > PUBDIR_RESULTS_MAX) ? PUBDIR_RESULTS_MAX : res_count;
+	if (form->page_size == 0)
+		form->page_size = res_count;
 
 	results = purple_notify_searchresults_new();
 
@@ -1171,7 +1260,8 @@
 		purple_notify_error(gc, NULL,
 				  _("Unable to display the search results."),
 				  NULL);
-		ggp_sr_close_cb(form);
+		if (form->window == NULL)
+			ggp_sr_close_cb(form);
 		return;
 	}
 
@@ -1213,11 +1303,6 @@
 			(birth && strncmp(birth, "0", 1)) ? birth : g_strdup("-"));
 
 		purple_notify_searchresults_row_add(results, row);
-
-		if (i == res_count - 1) {
-			g_free(form->last_uin);
-			form->last_uin = ggp_search_get_result(req, i, GG_PUBDIR50_UIN);
-		}
 	}
 
 	purple_notify_searchresults_button_add(results, PURPLE_NOTIFY_BUTTON_CONTINUE,
@@ -1258,7 +1343,8 @@
 
 	seq = gg_pubdir50_seq(req);
 	form = ggp_search_get(info->searches, seq);
-	purple_debug_info("gg", "ggp_pubdir_reply_handler(): seq %u --> form %p", seq, form);
+	purple_debug_info("gg",
+		"ggp_pubdir_reply_handler(): seq %u --> form %p\n", seq, form);
 	/*
 	 * this can happen when user will request more results
 	 * and close the results window before they arrive.
@@ -1271,7 +1357,8 @@
 		purple_notify_error(gc, NULL,
 			_("No matching users found"),
 			_("There are no users matching your search criteria."));
-		ggp_sr_close_cb(form);
+		if (form->window == NULL)
+			ggp_sr_close_cb(form);
 		return;
 	}
 
@@ -1311,8 +1398,8 @@
 			info->pending_richtext_messages = g_list_remove(info->pending_richtext_messages, entry->data);
 			/* We don't have any more images to download */
 			if (strstr(text, "<IMG ID=\"IMGID_HANDLER") == NULL) {
-				gchar *buf = g_strdup_printf("%lu", (unsigned long int)ev->event.msg.sender);
-				serv_got_im(gc, buf, text, PURPLE_MESSAGE_IMAGES, ev->event.msg.time);
+				gchar *buf = g_strdup_printf("%lu", (unsigned long int)ev->event.image_reply.sender);
+				serv_got_im(gc, buf, text, PURPLE_MESSAGE_IMAGES, time(NULL));
 				g_free(buf);
 				purple_debug_info("gg", "ggp_recv_image_handler: richtext message: %s\n", text);
 				g_free(text);
@@ -1345,10 +1432,19 @@
 	gchar *msg;
 	gchar *tmp;
 
+	if (ev->event.msg.message == NULL)
+	{
+		purple_debug_warning("gg", "ggp_recv_message_handler: NULL as message pointer\n");
+		return;
+	}
+
 	from = g_strdup_printf("%lu", (unsigned long int)ev->event.msg.sender);
 
+	/*
 	tmp = charset_convert((const char *)ev->event.msg.message,
 			      "CP1250", "UTF-8");
+	*/
+	tmp = g_strdup_printf("%s", ev->event.msg.message);
 	purple_str_strip_char(tmp, '\r');
 	msg = g_markup_escape_text(tmp, -1);
 	g_free(tmp);
@@ -1444,6 +1540,10 @@
 				increased_len += 4;
 				under = FALSE;
 			}
+
+			if (actformat->font & GG_FONT_COLOR) {
+				cformats += sizeof(struct gg_msg_richtext_color);
+			}
 		}
 
 		msg = message->str;
@@ -1497,9 +1597,9 @@
 {
 	GGPInfo *info = gc->proto_data;
 	PurpleStoredImage *image;
-	gint imgid = GPOINTER_TO_INT(g_hash_table_lookup(info->pending_images, &ev->event.image_request.crc32));
-
-	purple_debug_info("gg", "ggp_send_image_handler: image request received, crc32: %u\n", ev->event.image_request.crc32);
+	gint imgid = GPOINTER_TO_INT(g_hash_table_lookup(info->pending_images, GINT_TO_POINTER(ev->event.image_request.crc32)));
+
+	purple_debug_info("gg", "ggp_send_image_handler: image request received, crc32: %u, imgid: %d\n", ev->event.image_request.crc32, imgid);
 
 	if(imgid)
 	{
@@ -1514,10 +1614,90 @@
 		} else {
 			purple_debug_error("gg", "ggp_send_image_handler: image imgid: %i, crc: %u in hash but not found in imgstore!\n", imgid, ev->event.image_request.crc32);
 		}
-		g_hash_table_remove(info->pending_images, &ev->event.image_request.crc32);
+		g_hash_table_remove(info->pending_images, GINT_TO_POINTER(ev->event.image_request.crc32));
 	}
 }
 
+static void ggp_typing_notification_handler(PurpleConnection *gc, uin_t uin, int length) {
+	gchar *from;
+
+	from = g_strdup_printf("%u", uin);
+	if (length)
+		serv_got_typing(gc, from, 0, PURPLE_TYPING);
+	else
+		serv_got_typing_stopped(gc, from);
+	g_free(from);
+}
+
+/**
+ * Handling of XML events.
+ *
+ * @param gc PurpleConnection.
+ * @param data Raw XML contents.
+ *
+ * @see http://toxygen.net/libgadu/protocol/#ch1.13
+ */
+static void ggp_xml_event_handler(PurpleConnection *gc, char *data)
+{
+	xmlnode *xml = NULL;
+	xmlnode *xmlnode_next_event;
+
+	xml = xmlnode_from_str(data, -1);
+	if (xml == NULL)
+		goto out;
+
+	xmlnode_next_event = xmlnode_get_child(xml, "event");
+	while (xmlnode_next_event != NULL)
+	{
+		xmlnode *xmlnode_current_event = xmlnode_next_event;
+		
+		xmlnode *xmlnode_type;
+		char *event_type_raw;
+		int event_type = 0;
+		
+		xmlnode *xmlnode_sender;
+		char *event_sender_raw;
+		uin_t event_sender = 0;
+
+		xmlnode_next_event = xmlnode_get_next_twin(xmlnode_next_event);
+		
+		xmlnode_type = xmlnode_get_child(xmlnode_current_event, "type");
+		if (xmlnode_type == NULL)
+			continue;
+		event_type_raw = xmlnode_get_data(xmlnode_type);
+		if (event_type_raw != NULL)
+			event_type = atoi(event_type_raw);
+		g_free(event_type_raw);
+		
+		xmlnode_sender = xmlnode_get_child(xmlnode_current_event, "sender");
+		if (xmlnode_sender != NULL)
+		{
+			event_sender_raw = xmlnode_get_data(xmlnode_sender);
+			if (event_sender_raw != NULL)
+				event_sender = ggp_str_to_uin(event_sender_raw);
+			g_free(event_sender_raw);
+		}
+		
+		switch (event_type)
+		{
+			case 28: /* avatar update */
+				purple_debug_info("gg",
+					"ggp_xml_event_handler: avatar updated (uid: %u)\n",
+					event_sender);
+				ggp_update_buddy_avatar(gc, event_sender);
+				break;
+			default:
+				purple_debug_error("gg",
+					"ggp_xml_event_handler: unsupported event type=%d from=%u\n",
+					event_type, event_sender);
+		}
+	}
+	
+	out:
+		if (xml)
+			xmlnode_free(xml);
+}
+
 static void ggp_callback_recv(gpointer _gc, gint fd, PurpleInputCondition cond)
 {
 	PurpleConnection *gc = _gc;
@@ -1533,7 +1713,7 @@
 			_("Unable to read from socket"));
 		return;
 	}
-	gc->last_received = time(NULL);
+
 	switch (ev->type) {
 		case GG_EVENT_NONE:
 			/* Nothing happened. */
@@ -1562,7 +1742,7 @@
 
 				purple_debug_info("gg", "notify_pre: (%d) status: %d\n",
 						ev->event.notify->uin,
-						ev->event.notify->status);
+						GG_S(ev->event.notify->status));
 
 				n = (ev->type == GG_EVENT_NOTIFY) ? ev->event.notify
 								  : ev->event.notify_descr.notify;
@@ -1573,53 +1753,47 @@
 
 					purple_debug_info("gg",
 						"notify: (%d) status: %d; descr: %s\n",
-						n->uin, n->status, descr ? descr : "(null)");
+						n->uin, GG_S(n->status), descr ? descr : "(null)");
 
 					ggp_generic_status_handler(gc,
-						n->uin, n->status, descr);
+						n->uin, GG_S(n->status), descr);
 				}
 			}
 			break;
 		case GG_EVENT_NOTIFY60:
-			purple_debug_info("gg",
-				"notify60_pre: (%d) status=%d; version=%d; descr=%s\n",
-				ev->event.notify60->uin, ev->event.notify60->status,
-				ev->event.notify60->version,
-				ev->event.notify60->descr ? ev->event.notify60->descr : "(null)");
-
 			for (i = 0; ev->event.notify60[i].uin; i++) {
 				purple_debug_info("gg",
 					"notify60: (%d) status=%d; version=%d; descr=%s\n",
 					ev->event.notify60[i].uin,
-					ev->event.notify60[i].status,
+					GG_S(ev->event.notify60[i].status),
 					ev->event.notify60[i].version,
 					ev->event.notify60[i].descr ? ev->event.notify60[i].descr : "(null)");
 
 				ggp_generic_status_handler(gc, ev->event.notify60[i].uin,
-					ev->event.notify60[i].status,
+					GG_S(ev->event.notify60[i].status),
 					ev->event.notify60[i].descr);
 			}
 			break;
 		case GG_EVENT_STATUS:
 			purple_debug_info("gg", "status: (%d) status=%d; descr=%s\n",
-					ev->event.status.uin, ev->event.status.status,
+					ev->event.status.uin, GG_S(ev->event.status.status),
 					ev->event.status.descr ? ev->event.status.descr : "(null)");
 
 			ggp_generic_status_handler(gc, ev->event.status.uin,
-				ev->event.status.status, ev->event.status.descr);
+				GG_S(ev->event.status.status), ev->event.status.descr);
 			break;
 		case GG_EVENT_STATUS60:
 			purple_debug_info("gg",
 				"status60: (%d) status=%d; version=%d; descr=%s\n",
-				ev->event.status60.uin, ev->event.status60.status,
+				ev->event.status60.uin, GG_S(ev->event.status60.status),
 				ev->event.status60.version,
 				ev->event.status60.descr ? ev->event.status60.descr : "(null)");
 
 			ggp_generic_status_handler(gc, ev->event.status60.uin,
-				ev->event.status60.status, ev->event.status60.descr);
+				GG_S(ev->event.status60.status), ev->event.status60.descr);
 			break;
 		case GG_EVENT_USERLIST:
-	    		if (ev->event.userlist.type == GG_USERLIST_GET_REPLY) {
+			if (ev->event.userlist.type == GG_USERLIST_GET_REPLY) {
 				purple_debug_info("gg", "GG_USERLIST_GET_REPLY\n");
 				purple_notify_info(gc, NULL,
 					_("Buddy list downloaded"),
@@ -1637,6 +1811,14 @@
 		case GG_EVENT_PUBDIR50_SEARCH_REPLY:
 			ggp_pubdir_reply_handler(gc, ev->event.pubdir50);
 			break;
+		case GG_EVENT_TYPING_NOTIFICATION:
+			ggp_typing_notification_handler(gc, ev->event.typing_notification.uin,
+				ev->event.typing_notification.length);
+			break;
+		case GG_EVENT_XML_EVENT:
+			purple_debug_info("gg", "GG_EVENT_XML_EVENT\n");
+			ggp_xml_event_handler(gc, ev->event.xml_event.data);
+			break;
 		default:
 			purple_debug_error("gg",
 				"unsupported event type=%d\n", ev->type);
@@ -1663,6 +1845,9 @@
 		case GG_STATE_RESOLVING:
 			purple_debug_info("gg", "GG_STATE_RESOLVING\n");
 			break;
+		case GG_STATE_RESOLVING_GG:
+			purple_debug_info("gg", "GG_STATE_RESOLVING_GG\n");
+			break;
 		case GG_STATE_CONNECTING_HUB:
 			purple_debug_info("gg", "GG_STATE_CONNECTING_HUB\n");
 			break;
@@ -1678,6 +1863,9 @@
 		case GG_STATE_READING_REPLY:
 			purple_debug_info("gg", "GG_STATE_READING_REPLY\n");
 			break;
+		case GG_STATE_TLS_NEGOTIATION:
+			purple_debug_info("gg", "GG_STATE_TLS_NEGOTIATION\n");
+			break;
 		default:
 			purple_debug_error("gg", "unknown state = %d\n",
 					 info->session->state);
@@ -1698,10 +1886,11 @@
 	purple_input_remove(gc->inpa);
 
 	/** XXX I think that this shouldn't be done if ev->type is GG_EVENT_CONN_FAILED or GG_EVENT_CONN_SUCCESS -datallah */
-	gc->inpa = purple_input_add(info->session->fd,
-				  (info->session->check == 1) ? PURPLE_INPUT_WRITE
-							      : PURPLE_INPUT_READ,
-				  ggp_async_login_handler, gc);
+	if (info->session->fd >= 0)
+		gc->inpa = purple_input_add(info->session->fd,
+			(info->session->check == 1) ? PURPLE_INPUT_WRITE :
+				PURPLE_INPUT_READ,
+			ggp_async_login_handler, gc);
 
 	switch (ev->type) {
 		case GG_EVENT_NONE:
@@ -1715,9 +1904,9 @@
 				gc->inpa = purple_input_add(info->session->fd,
 							  PURPLE_INPUT_READ,
 							  ggp_callback_recv, gc);
-				
+
 				ggp_buddylist_send(gc);
-				purple_connection_update_progress(gc, _("Connected"), 2, 2);
+				purple_connection_update_progress(gc, _("Connected"), 1, 2);
 				purple_connection_set_state(gc, PURPLE_CONNECTED);
 			}
 			break;
@@ -1728,6 +1917,17 @@
 				PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
 				_("Connection failed"));
 			break;
+		case GG_EVENT_MSG:
+			if (ev->event.msg.sender == 0)
+				/* system messages are mostly ads */
+				purple_debug_info("gg", "System message:\n%s\n",
+					ev->event.msg.message);
+			else
+				purple_debug_warning("gg", "GG_EVENT_MSG: message from user %u "
+					"unexpected while connecting:\n%s\n",
+					ev->event.msg.sender,
+					ev->event.msg.message);
+			break;
 		default:
 			purple_debug_error("gg", "strange event: %d\n", ev->type);
 			break;
@@ -1752,23 +1952,18 @@
 	char *text;
 	char *tmp;
 
-	status = purple_presence_get_active_status(purple_buddy_get_presence(b));
-
+	status = purple_presence_get_active_status(
+		purple_buddy_get_presence(b));
 	msg = purple_status_get_attr_string(status, "message");
 
-	if (msg != NULL) {
-		tmp = purple_markup_strip_html(msg);
-		text = g_markup_escape_text(tmp, -1);
-		g_free(tmp);
-
-		return text;
-	} else {
-		tmp = purple_utf8_salvage(purple_status_get_name(status));
-		text = g_markup_escape_text(tmp, -1);
-		g_free(tmp);
-
-		return text;
-	}
+	if (msg == NULL)
+		return NULL;
+
+	tmp = purple_markup_strip_html(msg);
+	text = g_markup_escape_text(tmp, -1);
+	g_free(tmp);
+
+	return text;
 }
 
 static void ggp_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full)
@@ -1829,6 +2024,16 @@
 			NULL);
 	types = g_list_append(types, type);
 
+ 	/*
+	 * New statuses for GG 8.0 like PoGGadaj ze mna (not yet because
+	 * libpurple can't support Chatty status) and Nie przeszkadzac
+	 */
+	type = purple_status_type_new_with_attrs(
+			PURPLE_STATUS_UNAVAILABLE, NULL, NULL, TRUE, TRUE, FALSE,
+			"message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
+			NULL);
+	types = g_list_append(types, type);
+
 	/*
 	 * This status is necessary to display guys who are blocking *us*.
 	 */
@@ -1865,20 +2070,6 @@
 		m = g_list_append(m, act);
 	}
 
-	/* Using a blist node boolean here is also wrong.
-	 * Once the Block and Unblock actions are added to the core,
-	 * this will have to go. -- rlaager */
-	if (purple_blist_node_get_bool(node, "blocked")) {
-		act = purple_menu_action_new(_("Unblock"),
-		                           PURPLE_CALLBACK(ggp_bmenu_block),
-		                           NULL, NULL);
-	} else {
-		act = purple_menu_action_new(_("Block"),
-		                           PURPLE_CALLBACK(ggp_bmenu_block),
-		                           NULL, NULL);
-	}
-	m = g_list_append(m, act);
-
 	return m;
 }
 
@@ -1904,6 +2095,7 @@
 	struct gg_login_params *glp;
 	GGPInfo *info;
 	const char *address;
+	const gchar *encryption_type;
 
 	if (ggp_setup_proxy(account) == -1)
 		return;
@@ -1919,8 +2111,9 @@
 	info->token = NULL;
 	info->searches = ggp_search_new();
 	info->pending_richtext_messages = NULL;
-	info->pending_images = g_hash_table_new(g_int_hash, g_int_equal);
-
+	info->pending_images = g_hash_table_new(g_direct_hash, g_direct_equal);