Merged pidgin/main into default
--- a/.hgignore Thu Jun 15 10:48:26 2017 +0300
+++ b/.hgignore Fri Jun 30 15:03:16 2017 +0300
@@ -64,7 +64,6 @@
doc/reference/.*/version.xml
-finch/libgnt/gntmarshal.[ch]
@@ -75,9 +74,7 @@
libpurple/example/nullclient
libpurple/data/purple-url-handler.desktop$
libpurple/data/purple-url-handler.desktop.in$
-libpurple/marshallers.[ch]
libpurple/plugins/dbus-example-bindings.c
-libpurple/protocols/facebook/marshal.[ch]
libpurple/purple-client-bindings.[ch]
libpurple/purple-client-example
@@ -108,7 +105,7 @@
+pidgin/.*\.gresource\.[ch]$ pidgin/data/pidgin.appdata.xml$
pidgin/data/pidgin.desktop$
--- a/ChangeLog.API Thu Jun 15 10:48:26 2017 +0300
+++ b/ChangeLog.API Fri Jun 30 15:03:16 2017 +0300
@@ -23,14 +23,6 @@
* purple_account_presence_new
* purple_buddy_presence_new
* purple_account_register_completed
- * PurpleAESCipher, PurpleDESCipher, PurpleDES3Cipher, PurpleHMACCipher,
- PurplePBKDF2Cipher and PurpleRC4Cipher inherit PurpleCipher
- * purple_aes_cipher_new
- * purple_des3_cipher_new
- * purple_des_cipher_new
- * purple_hmac_cipher_new
- * purple_pbkdf2_cipher_new
- * purple_rc4_cipher_new
* purple_blist_node_is_transient
* purple_blist_node_set_transient
* purple_certificate_get_der_data
@@ -55,13 +47,6 @@
* purple_counting_node_get_*
* purple_counting_node_change_*
* purple_counting_node_set_*
- * PurpleHash and purple_hash_* API
- * PurpleMD4Hash, PurpleMD5Hash, PurpleSHA1Hash and PurpleSHA265Hash
- * purple_sha256_hash_new
* PurpleIMConversation and PurpleChatConversation inherit
* purple_notify_emails_pending
@@ -197,8 +182,6 @@
* conversation.h has been split into conversation.h
(PurpleConversation), conversationtypes.h (PurpleIMConversation and
PurpleChatConversation) and conversations.h (Conversations subsystem)
- * Files in libpurple/ciphers have been renamed. To use a particular
- cipher, include its header.
* Renamed ft.h file to xfer.h
* Renamed plugin.h file to plugins.h
* prpl.h has been split into protocol.h (PurpleProtocol GObject and
@@ -259,9 +242,6 @@
* Replaced 'chat-buddy' with 'chat-user' in conversation signals
* Replaced chatname, buddyname arguments of 'chat-user-flags' (formerly
'chat-buddy-flags') signal with PurpleChatUser *
- * PurpleCipher split into PurpleCipher and PurpleHash, both are
- GObjects. Please see the documentation for details.
- * purple_cipher_context_* functions are now purple_cipher_*
* PurpleCircBuffer changed to PurpleCircularBuffer, is now a GObject.
Please see the documentation for details.
* purple_circ_buffer_* functions are now purple_circular_buffer_*
@@ -403,7 +383,6 @@
* buddy-added and buddy-removed blist signals
- * _PurpleCipherBatchMode
@@ -430,19 +409,8 @@
purple_certificate_check_signature_chain, instead
* purple_certificate_display_x509. Use purple_request_certificate,
- * purple_cipher_context_destroy
- * purple_cipher_context_get_data
- * purple_cipher_context_get_option
- * purple_cipher_context_new
- * purple_cipher_context_new_by_name
- * purple_cipher_context_set_data
- * purple_cipher_context_set_option
- * purple_cipher_get_capabilities
- * purple_cipher_get_name
- * PurpleCipher's init and uninit operations
+ * Purple Cipher API (PurpleCipherContext and friends). + Use GLib's GHmac or GChecksum instead. * purple_connection_error_reason
* purple_connection_new_unregister
@@ -453,6 +421,10 @@
* purple_dnsquery_a_account
+ * purple_event_loop_{get|set}_ui_ops. Manually drive the GLib + event loop yourself. See GLib Main Event Loop docs. + * PurpleEventLoopUiOps. Manually drive the GLib event loop + yourself. See GLib Main Event Loop docs. * purple_network_listen_family. Use purple_network_listen, instead.
* purple_network_listen_map_external
* purple_network_listen_range_family. Use purple_network_listen,
--- a/config.h.mingw Thu Jun 15 10:48:26 2017 +0300
+++ b/config.h.mingw Fri Jun 30 15:03:16 2017 +0300
@@ -287,9 +287,6 @@
/* Define to 1 if you have X11 */
-/* Define to 1 if you have the <X11/SM/SMlib.h> header file. */
-/* #define HAVE_X11_SM_SMLIB_H 1 */
/* whether or not we have xsltproc for devhelp index */
/* #define HAVE_XSLTPROC 1 */
@@ -360,9 +357,6 @@
/* Define if we're using XScreenSaver. */
#define USE_SCREENSAVER 1
-/* Define if we're using X Session Management. */
/* Use voice and video */
--- a/configure.ac Thu Jun 15 10:48:26 2017 +0300
+++ b/configure.ac Fri Jun 30 15:03:16 2017 +0300
@@ -109,7 +109,6 @@
AC_SUBST(GNT_LT_VERSION_INFO)
AC_PATH_PROG(sedpath, sed)
-AC_PATH_PROG(xxdpath, xxd)
dnl Storing configure arguments
AC_DEFINE_UNQUOTED(CONFIG_ARGS, "$ac_configure_args", [configure arguments])
@@ -488,6 +487,8 @@
GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0`
+AC_PATH_PROG(GLIB_COMPILE_RESOURCES, [glib-compile-resources]) AC_PATH_PROG(GTESTER, gtester)
@@ -522,10 +523,6 @@
[AS_HELP_STRING([--disable-screensaver],
[compile without X screensaver extension (used to detect idleness)])],
enable_screensaver="$enableval", enable_screensaver="yes")
- [AS_HELP_STRING([--disable-sm],
- [compile without X session management support])],
- enable_sm="$enableval", enable_sm="yes")
AC_ARG_ENABLE(startup-notification,
[AS_HELP_STRING([--disable-startup-notification],
[compile without startup notification support])],
@@ -644,7 +641,6 @@
@@ -690,36 +686,6 @@
dnl #######################################################################
- dnl # Check for X session management libs
- dnl #######################################################################
- if test "x$enable_sm" = "xyes"; then
- if test "x$with_x" = "xyes" ; then
- AC_CHECK_LIB(SM, SmcSaveYourselfDone, found_sm_lib=true, , [$x_libpath_add -lICE])
- if test "x$found_sm_lib" = "xtrue"; then
- oldCPPFLAGS="$CPPFLAGS"
- CPPFLAGS="$CPPFLAGS $x_incpath_add"
- AC_CHECK_HEADERS(X11/SM/SMlib.h, SM_LIBS="$x_libpath_add -lSM -lICE" enable_sm=yes)
- CPPFLAGS="$oldCPPFLAGS"
- if test "x$enable_sm" = "xyes"; then
- AC_DEFINE(USE_SM, 1, [Define if we're using X Session Management.])
- if test "x$force_deps" = "xyes" ; then
-X session management development headers not found.
-Use --disable-sm if you do not need session management support.
- AC_MSG_ERROR([X support is required to build with X session management support])
- dnl #######################################################################
dnl # Check for X11 to allow the gestures plugin
dnl #######################################################################
if test "x$enable_gestures" = "xyes"; then
@@ -787,7 +753,6 @@
enable_startup_notification=no
@@ -1865,105 +1830,6 @@
AM_CONDITIONAL(INSTALL_SSL_CERTIFICATES, test "x$SSL_CERTIFICATES_DIR" = "x")
-dnl These two are inverses of each other <-- stolen from evolution!
- [ --enable-gnutls=[yes,no] attempt to use GnuTLS for SSL support [default=yes]],
- [enable_gnutls="$enableval"],
- [ --enable-nss=[yes,no,static] attempt to use Mozilla libnss for SSL support [default=yes]],
- [enable_nss="$enableval"],
-msg_ssl="None. Novell Groupwise and Google Talk will not work without GnuTLS or NSS. OpenSSL is NOT usable!"
-dnl # Check for GnuTLS if it isn't disabled
-if test "x$enable_gnutls" != "xno"; then
- looked_for_gnutls="yes"
- if `$PKG_CONFIG --exists gnutls`; then
- dnl # minimum required version should almost certainly be higher
- PKG_CHECK_MODULES(GNUTLS, [gnutls >= 2.10], [
- if test "x$have_gnutls" = "xyes"; then
- AC_DEFINE(HAVE_GNUTLS, 1, [Define if you have GnuTLS])
-AM_CONDITIONAL(USE_GNUTLS, test "x$have_gnutls" = "xyes")
-dnl # Check for NSS if it isn't disabled
-if test "x$enable_nss" != "xno"; then
- if `$PKG_CONFIG --exists mozilla-nss`; then
- dnl # TODO: set required minimum version
- PKG_CHECK_MODULES(NSS, mozilla-nss, [
- elif `$PKG_CONFIG --exists nss`; then
- dnl # TODO: set required minimum version
- PKG_CHECK_MODULES(NSS, nss, [
- if test "x$have_nss" = "xyes"; then
- AC_DEFINE(HAVE_NSS, 1, [Define if you have Mozilla NSS])
-AM_CONDITIONAL(USE_NSS, test "x$have_nss" = "xyes")
-if test "x$msg_nss" != "x" -a "x$msg_gnutls" != "x"; then
- msg_ssl="$msg_nss and $msg_gnutls"
-elif test "x$msg_nss" != "x"; then
-elif test "x$msg_gnutls" != "x"; then
-elif test "x$looked_for_gnutls" = "xyes" -a "x$looked_for_nss" = "xyes" -a "x$force_deps" = "xyes" ; then
-Neither GnuTLS or NSS SSL development headers found.
-Use --disable-nss --disable-gnutls if you do not need SSL support.
-Novell Groupwise and Google Talk will not work without GnuTLS or NSS. OpenSSL is NOT usable!
-elif test "x$looked_for_gnutls" = "xyes" -a "x$force_deps" = "xyes" ; then
-GnuTLS SSL development headers not found.
-Use --disable-gnutls if you do not need SSL support.
-Novell Groupwise and Google Talk will not work without SSL support.
-elif test "x$looked_for_nss" = "xyes" -a "x$force_deps" = "xyes" ; then
-NSS SSL development headers not found.
-Use --disable-nss if you do not need SSL support.
-Novell Groupwise and Google Talk will not work without SSL support.
if test "$ac_cv_cygwin" = yes ; then
AC_DEFINE(DEBUG, 1, [Define if debugging is enabled.])
@@ -1985,6 +1851,33 @@
dnl #######################################################################
+dnl # Check for Nettle (Crypto Library) +dnl ####################################################################### + [AC_HELP_STRING([--disable-nettle], [disable Nettle support])], + enable_nettle="$enableval", enable_nettle="yes") +if test "x$enable_nettle" = "xyes" ; then + PKG_CHECK_MODULES(NETTLE, [nettle >= 3.0], [ + AC_SUBST(NETTLE_CFLAGS) + AC_DEFINE(HAVE_NETTLE, 1, [Define if we have Nettle.]) + if test "x$enable_nettle" != "xyes" -a "x$force_deps" = "xyes" ; then +Nettle development headers not found +Use --disable-nettle if you do not need it. +AM_CONDITIONAL(ENABLE_NETTLE, test "x$enable_nettle" = "xyes") +dnl ####################################################################### dnl # Check for Cyrus-SASL (for xmpp/irc)
dnl #######################################################################
dnl AC_CHECK_SIZEOF(short)
@@ -2230,10 +2123,10 @@
eval eval echo D-Bus services directory...... : $DBUS_SERVICES_DIR
echo Build with GNU Libidn......... : $enable_idn
-echo SSL Library/Libraries......... : $msg_ssl
if test "x$SSL_CERTIFICATES_DIR" != "x" ; then
eval eval echo SSL CA certificates directory. : $SSL_CERTIFICATES_DIR
+echo Build with Nettle support..... : $enable_nettle echo Build with Cyrus SASL support. : $enable_cyrus_sasl
echo Use kerberos 4 with zephyr.... : $kerberos
echo Use external libzephyr........ : $zephyr
@@ -2243,7 +2136,6 @@
echo Has you....................... : yes
echo Use XScreenSaver Extension.... : $enable_screensaver
-echo Use X Session Management...... : $enable_sm
echo Use startup notification...... : $enable_startup_notification
echo Build with Enchant support.... : $use_enchant
echo Build with GCR widgets........ : $enable_gcr
--- a/doc/reference/libpurple/Makefile.am Thu Jun 15 10:48:26 2017 +0300
+++ b/doc/reference/libpurple/Makefile.am Fri Jun 30 15:03:16 2017 +0300
@@ -135,8 +135,6 @@
$(NETWORKMANAGER_CFLAGS) \
@@ -155,8 +153,6 @@
--- a/doc/reference/libpurple/libpurple-docs.xml Thu Jun 15 10:48:26 2017 +0300
+++ b/doc/reference/libpurple/libpurple-docs.xml Fri Jun 30 15:03:16 2017 +0300
@@ -38,7 +38,6 @@
<xi:include href="xml/pounce.xml" />
<xi:include href="xml/chat.xml" />
<xi:include href="xml/circularbuffer.xml" />
- <xi:include href="xml/cipher.xml" />
<xi:include href="xml/contact.xml" />
<xi:include href="xml/connection.xml" />
<xi:include href="xml/conversation.xml" />
@@ -104,17 +103,6 @@
<xi:include href="xml/cmds.xml" />
- <title>Ciphers and Hashes</title>
- <xi:include href="xml/aescipher.xml" />
- <xi:include href="xml/descipher.xml" />
- <xi:include href="xml/des3cipher.xml" />
- <xi:include href="xml/pbkdf2cipher.xml" />
- <xi:include href="xml/rc4cipher.xml" />
- <xi:include href="xml/md4hash.xml" />
<title>Smiley APIs</title>
--- a/doc/reference/libpurple/ui_ops.xml Thu Jun 15 10:48:26 2017 +0300
+++ b/doc/reference/libpurple/ui_ops.xml Fri Jun 30 15:03:16 2017 +0300
@@ -17,7 +17,6 @@
<listitem><link linkend="PurpleCoreUiOps"><literal>PurpleCoreUiOps</literal></link></listitem>
<listitem><link linkend="PurpleDebugUiOps"><literal>PurpleDebugUiOps</literal></link></listitem>
<listitem><link linkend="PurpleDnsQueryUiOps"><literal>PurpleDnsQueryUiOps</literal></link></listitem>
-<listitem><link linkend="PurpleEventLoopUiOps"><literal>PurpleEventLoopUiOps</literal></link> (without this, nothing will work and you will cry)</listitem>
<listitem><link linkend="PurpleIdleUiOps"><literal>PurpleIdleUiOps</literal></link></listitem>
<listitem><link linkend="PurpleNotifyUiOps"><literal>PurpleNotifyUiOps</literal></link></listitem>
<listitem><link linkend="PurpleRequestUiOps"><literal>PurpleRequestUiOps</literal></link></listitem>
--- a/doc/reference/pidgin/Makefile.am Thu Jun 15 10:48:26 2017 +0300
+++ b/doc/reference/pidgin/Makefile.am Fri Jun 30 15:03:16 2017 +0300
@@ -120,7 +120,6 @@
--- a/doc/reference/pidgin/pidgin-docs.xml Thu Jun 15 10:48:26 2017 +0300
+++ b/doc/reference/pidgin/pidgin-docs.xml Fri Jun 30 15:03:16 2017 +0300
@@ -35,7 +35,6 @@
<xi:include href="xml/gtkdebug.xml" />
<xi:include href="xml/gtkdocklet.xml" />
<xi:include href="xml/gtkdnd-hints.xml" />
- <xi:include href="xml/gtkeventloop.xml" />
<xi:include href="xml/gtkxfer.xml" />
<xi:include href="xml/gtkicon-theme.xml" />
<xi:include href="xml/gtkidle.xml" />
@@ -65,7 +64,6 @@
<xi:include href="xml/gtkwebview.xml" />
<xi:include href="xml/gtkwebviewtoolbar.xml" />
<xi:include href="xml/gtkwhiteboard.xml" />
- <xi:include href="xml/gtksession.xml" />
<xi:include href="xml/pidgin.xml" />
--- a/finch/libfinch.c Thu Jun 15 10:48:26 2017 +0300
+++ b/finch/libfinch.c Fri Jun 30 15:03:16 2017 +0300
@@ -26,7 +26,6 @@
#include "conversation.h"
@@ -134,103 +133,6 @@
-/* Anything IO-related is directly copied from gtkpurple's source tree */
-#define FINCH_READ_COND (G_IO_IN | G_IO_HUP | G_IO_ERR)
-#define FINCH_WRITE_COND (G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL)
-typedef struct _PurpleGntIOClosure {
- PurpleInputFunction function;
-static void purple_gnt_io_destroy(gpointer data)
-static gboolean purple_gnt_io_invoke(GIOChannel *source, GIOCondition condition, gpointer data)
- PurpleGntIOClosure *closure = data;
- PurpleInputCondition purple_cond = 0;
- if (condition & FINCH_READ_COND)
- purple_cond |= PURPLE_INPUT_READ;
- if (condition & FINCH_WRITE_COND)
- purple_cond |= PURPLE_INPUT_WRITE;
- purple_debug(PURPLE_DEBUG_MISC, "gtk_eventloop",
- "CLOSURE: callback for %d, fd is %d\n",
- closure->result, g_io_channel_unix_get_fd(source));
- purple_debug_misc("gnt_eventloop",
- "CLOSURE received GIOCondition of 0x%x, which does not"
- " match 0x%x (READ) or 0x%x (WRITE)\n",
- condition, FINCH_READ_COND, FINCH_WRITE_COND);
- closure->function(closure->data, g_io_channel_unix_get_fd(source),
-static guint gnt_input_add(gint fd, PurpleInputCondition condition, PurpleInputFunction function,
- PurpleGntIOClosure *closure = g_new0(PurpleGntIOClosure, 1);
- closure->function = function;
- if (condition & PURPLE_INPUT_READ)
- cond |= FINCH_READ_COND;
- if (condition & PURPLE_INPUT_WRITE)
- cond |= FINCH_WRITE_COND;
- channel = g_io_channel_unix_new(fd);
- closure->result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond,
- purple_gnt_io_invoke, closure, purple_gnt_io_destroy);
- g_io_channel_unref(channel);
- return closure->result;
-static PurpleEventLoopUiOps eventloop_ops =
- NULL, /* input_get_error */
-static PurpleEventLoopUiOps *
-gnt_eventloop_get_ui_ops(void)
/* This is mostly copied from gtkpurple's source tree */
show_usage(const char *name, gboolean terse)
@@ -348,7 +250,6 @@
purple_debug_set_enabled(debug_enabled);
purple_core_set_ui_ops(gnt_core_get_ui_ops());
- purple_eventloop_set_ui_ops(gnt_eventloop_get_ui_ops());
purple_idle_set_ui_ops(finch_idle_get_ui_ops());
if (!purple_core_init(FINCH_UI))
--- a/finch/libgnt/Makefile.am Thu Jun 15 10:48:26 2017 +0300
+++ b/finch/libgnt/Makefile.am Fri Jun 30 15:03:16 2017 +0300
@@ -1,5 +1,3 @@
pkgconfigdir = $(libdir)/pkgconfig
@@ -8,10 +6,7 @@
noinst_HEADERS = gntinternal.h
-BUILT_SOURCES = gntmarshal.h
@@ -53,7 +48,6 @@
@@ -68,17 +62,6 @@
-gntmarshal.c: $(srcdir)/genmarshal gntmarshal.h
- $(AM_V_GEN)echo "#include \"gntmarshal.h\"" > $@
- $(AM_V_at)glib-genmarshal --prefix=gnt_closure_marshal --body $(srcdir)/genmarshal >> $@
-gntmarshal.h: $(srcdir)/genmarshal
- $(AM_V_GEN)glib-genmarshal --prefix=gnt_closure_marshal --header $(srcdir)/genmarshal > $@
libgnt_laincludedir=$(includedir)/gnt
libgnt_lainclude_HEADERS = \
@@ -147,5 +130,5 @@
$(INTROSPECTION_TYPELIBDIR)
typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
-CLEANFILES += $(gir_DATA) $(typelib_DATA)
+CLEANFILES = $(gir_DATA) $(typelib_DATA) --- a/finch/libgnt/genmarshal Thu Jun 15 10:48:26 2017 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-BOOLEAN:POINTER,POINTER,POINTER
-BOOLEAN:INT,INT,INT,POINTER
--- a/finch/libgnt/gntcheckbox.c Thu Jun 15 10:48:26 2017 +0300
+++ b/finch/libgnt/gntcheckbox.c Fri Jun 30 15:03:16 2017 +0300
@@ -105,8 +105,7 @@
G_TYPE_FROM_CLASS(klass),
G_STRUCT_OFFSET(GntCheckBoxClass, toggled),
- g_cclosure_marshal_VOID__VOID,
--- a/finch/libgnt/gntclipboard.c Thu Jun 15 10:48:26 2017 +0300
+++ b/finch/libgnt/gntclipboard.c Fri Jun 30 15:03:16 2017 +0300
@@ -37,8 +37,7 @@
G_TYPE_FROM_CLASS(klass),
- g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1, G_TYPE_POINTER);
--- a/finch/libgnt/gntcombobox.c Thu Jun 15 10:48:26 2017 +0300
+++ b/finch/libgnt/gntcombobox.c Fri Jun 30 15:03:16 2017 +0300
@@ -24,7 +24,6 @@
@@ -283,8 +282,7 @@
G_TYPE_FROM_CLASS(klass),
- 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,
--- a/finch/libgnt/gntentry.c Thu Jun 15 10:48:26 2017 +0300
+++ b/finch/libgnt/gntentry.c Fri Jun 30 15:03:16 2017 +0300
@@ -26,7 +26,6 @@
@@ -951,16 +950,14 @@
G_TYPE_FROM_CLASS(klass),
G_STRUCT_OFFSET(GntEntryClass, text_changed),
- g_cclosure_marshal_VOID__VOID,
signals[SIG_COMPLETION] =
g_signal_new("completion",
G_TYPE_FROM_CLASS(klass),
- gnt_closure_marshal_VOID__POINTER_POINTER,
G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER);
gnt_bindable_class_register_action(bindable, "cursor-home", move_start,
--- a/finch/libgnt/gntfilesel.c Thu Jun 15 10:48:26 2017 +0300
+++ b/finch/libgnt/gntfilesel.c Fri Jun 30 15:03:16 2017 +0300
@@ -28,7 +28,6 @@
@@ -506,8 +505,7 @@
G_TYPE_FROM_CLASS(klass),
G_STRUCT_OFFSET(GntFileSelClass, file_selected),
- gnt_closure_marshal_VOID__STRING_STRING,
G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING);
gnt_bindable_class_register_action(bindable, "toggle-tag", toggle_tag_selection, "t", NULL);
--- a/finch/libgnt/gntmenuitem.c Thu Jun 15 10:48:26 2017 +0300
+++ b/finch/libgnt/gntmenuitem.c Fri Jun 30 15:03:16 2017 +0300
@@ -57,8 +57,7 @@
G_TYPE_FROM_CLASS(klass),
- g_cclosure_marshal_VOID__VOID,
--- a/finch/libgnt/gntslider.c Thu Jun 15 10:48:26 2017 +0300
+++ b/finch/libgnt/gntslider.c Fri Jun 30 15:03:16 2017 +0300
@@ -202,8 +202,7 @@
G_TYPE_FROM_CLASS(klass),
G_STRUCT_OFFSET(GntSliderClass, changed),
- g_cclosure_marshal_VOID__INT,
G_TYPE_NONE, 1, G_TYPE_INT);
gnt_bindable_class_register_action(bindable, "step-backward", step_back, GNT_KEY_LEFT, NULL);
--- a/finch/libgnt/gnttree.c Thu Jun 15 10:48:26 2017 +0300
+++ b/finch/libgnt/gnttree.c Fri Jun 30 15:03:16 2017 +0300
@@ -21,7 +21,6 @@
@@ -1072,32 +1071,28 @@
G_TYPE_FROM_CLASS(klass),
G_STRUCT_OFFSET(GntTreeClass, selection_changed),
- gnt_closure_marshal_VOID__POINTER_POINTER,
G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER);
G_TYPE_FROM_CLASS(klass),
- g_cclosure_marshal_VOID__INT,
G_TYPE_NONE, 1, G_TYPE_INT);
G_TYPE_FROM_CLASS(klass),
G_STRUCT_OFFSET(GntTreeClass, toggled),
- g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1, G_TYPE_POINTER);
g_signal_new("collapse-toggled",
G_TYPE_FROM_CLASS(klass),
- gnt_closure_marshal_VOID__POINTER_BOOLEAN,
G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_BOOLEAN);
gnt_bindable_class_register_action(bindable, "move-up", action_up,
--- a/finch/libgnt/gntwidget.c Thu Jun 15 10:48:26 2017 +0300
+++ b/finch/libgnt/gntwidget.c Fri Jun 30 15:03:16 2017 +0300
@@ -25,7 +25,6 @@
@@ -135,104 +134,91 @@
G_TYPE_FROM_CLASS(klass),
G_STRUCT_OFFSET(GntWidgetClass, destroy),
- g_cclosure_marshal_VOID__VOID,
signals[SIG_GIVE_FOCUS] =
g_signal_new("gained-focus",
G_TYPE_FROM_CLASS(klass),
G_STRUCT_OFFSET(GntWidgetClass, gained_focus),
- g_cclosure_marshal_VOID__VOID,
signals[SIG_LOST_FOCUS] =
g_signal_new("lost-focus",
G_TYPE_FROM_CLASS(klass),
G_STRUCT_OFFSET(GntWidgetClass, lost_focus),
- g_cclosure_marshal_VOID__VOID,
G_TYPE_FROM_CLASS(klass),
G_STRUCT_OFFSET(GntWidgetClass, activate),
- g_cclosure_marshal_VOID__VOID,
G_TYPE_FROM_CLASS(klass),
G_STRUCT_OFFSET(GntWidgetClass, map),
- g_cclosure_marshal_VOID__VOID,
G_TYPE_FROM_CLASS(klass),
G_STRUCT_OFFSET(GntWidgetClass, draw),
- g_cclosure_marshal_VOID__VOID,
G_TYPE_FROM_CLASS(klass),
G_STRUCT_OFFSET(GntWidgetClass, hide),
- g_cclosure_marshal_VOID__VOID,
G_TYPE_FROM_CLASS(klass),
G_STRUCT_OFFSET(GntWidgetClass, expose),
- gnt_closure_marshal_VOID__INT_INT_INT_INT,
G_TYPE_NONE, 4, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT);
g_signal_new("position-set",
G_TYPE_FROM_CLASS(klass),
G_STRUCT_OFFSET(GntWidgetClass, set_position),
- gnt_closure_marshal_VOID__INT_INT,
G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
signals[SIG_SIZE_REQUEST] =
g_signal_new("size_request",
G_TYPE_FROM_CLASS(klass),
G_STRUCT_OFFSET(GntWidgetClass, size_request),
- g_cclosure_marshal_VOID__VOID,
signals[SIG_SIZE_CHANGED] =
g_signal_new("size_changed",
G_TYPE_FROM_CLASS(klass),
G_STRUCT_OFFSET(GntWidgetClass, size_changed),
- gnt_closure_marshal_VOID__INT_INT,
G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
signals[SIG_CONFIRM_SIZE] =
g_signal_new("confirm_size",
G_TYPE_FROM_CLASS(klass),
G_STRUCT_OFFSET(GntWidgetClass, confirm_size),
- gnt_closure_marshal_BOOLEAN__INT_INT,
G_TYPE_BOOLEAN, 2, G_TYPE_INT, G_TYPE_INT);
signals[SIG_KEY_PRESSED] =
g_signal_new("key_pressed",
G_TYPE_FROM_CLASS(klass),
G_STRUCT_OFFSET(GntWidgetClass, key_pressed),
- gnt_boolean_handled_accumulator, NULL,
- gnt_closure_marshal_BOOLEAN__STRING,
+ gnt_boolean_handled_accumulator, NULL, NULL, G_TYPE_BOOLEAN, 1, G_TYPE_STRING);
@@ -240,8 +226,7 @@
G_TYPE_FROM_CLASS(klass),
G_STRUCT_OFFSET(GntWidgetClass, clicked),
- gnt_boolean_handled_accumulator, NULL,
- gnt_closure_marshal_BOOLEAN__INT_INT_INT,
+ gnt_boolean_handled_accumulator, NULL, NULL, G_TYPE_BOOLEAN, 3, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT);
signals[SIG_CONTEXT_MENU] =
@@ -249,8 +234,7 @@
G_TYPE_FROM_CLASS(klass),
- gnt_boolean_handled_accumulator, NULL,
- gnt_closure_marshal_BOOLEAN__VOID,
+ gnt_boolean_handled_accumulator, NULL, NULL, /* This is relevant for all widgets */
--- a/finch/libgnt/gntwindow.c Thu Jun 15 10:48:26 2017 +0300
+++ b/finch/libgnt/gntwindow.c Fri Jun 30 15:03:16 2017 +0300
@@ -94,8 +94,7 @@
G_TYPE_FROM_CLASS(klass),
- g_cclosure_marshal_VOID__VOID,
signals[SIG_WORKSPACE_SHOW] =
@@ -103,8 +102,7 @@
G_TYPE_FROM_CLASS(klass),
- g_cclosure_marshal_VOID__VOID,
gnt_bindable_class_register_action(bindable, "show-menu", show_menu,
--- a/finch/libgnt/gntwm.c Thu Jun 15 10:48:26 2017 +0300
+++ b/finch/libgnt/gntwm.c Fri Jun 30 15:03:16 2017 +0300
@@ -50,7 +50,6 @@
@@ -1421,32 +1420,28 @@
G_TYPE_FROM_CLASS(klass),
G_STRUCT_OFFSET(GntWMClass, new_window),
- g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1, G_TYPE_POINTER);
signals[SIG_DECORATE_WIN] =
g_signal_new("decorate_win",
G_TYPE_FROM_CLASS(klass),
G_STRUCT_OFFSET(GntWMClass, decorate_window),
- g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1, G_TYPE_POINTER);
g_signal_new("close_win",
G_TYPE_FROM_CLASS(klass),
G_STRUCT_OFFSET(GntWMClass, close_window),
- g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1, G_TYPE_POINTER);
signals[SIG_CONFIRM_RESIZE] =
g_signal_new("confirm_resize",
G_TYPE_FROM_CLASS(klass),
G_STRUCT_OFFSET(GntWMClass, window_resize_confirm),
- gnt_boolean_handled_accumulator, NULL,
- gnt_closure_marshal_BOOLEAN__POINTER_POINTER_POINTER,
+ gnt_boolean_handled_accumulator, NULL, NULL, G_TYPE_BOOLEAN, 3, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER);
signals[SIG_CONFIRM_MOVE] =
@@ -1454,8 +1449,7 @@
G_TYPE_FROM_CLASS(klass),
G_STRUCT_OFFSET(GntWMClass, window_move_confirm),
- gnt_boolean_handled_accumulator, NULL,
- gnt_closure_marshal_BOOLEAN__POINTER_POINTER_POINTER,
+ gnt_boolean_handled_accumulator, NULL, NULL, G_TYPE_BOOLEAN, 3, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER);
@@ -1463,24 +1457,21 @@
G_TYPE_FROM_CLASS(klass),
G_STRUCT_OFFSET(GntWMClass, window_resized),
- g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1, G_TYPE_POINTER);
g_signal_new("window_moved",
G_TYPE_FROM_CLASS(klass),
G_STRUCT_OFFSET(GntWMClass, window_moved),
- g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1, G_TYPE_POINTER);
signals[SIG_UPDATE_WIN] =
g_signal_new("window_update",
G_TYPE_FROM_CLASS(klass),
G_STRUCT_OFFSET(GntWMClass, window_update),
- g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1, G_TYPE_POINTER);
signals[SIG_GIVE_FOCUS] =
@@ -1488,8 +1479,7 @@
G_TYPE_FROM_CLASS(klass),
G_STRUCT_OFFSET(GntWMClass, give_focus),
- g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1, G_TYPE_POINTER);
signals[SIG_MOUSE_CLICK] =
@@ -1497,8 +1487,7 @@
G_TYPE_FROM_CLASS(klass),
G_STRUCT_OFFSET(GntWMClass, mouse_clicked),
- gnt_boolean_handled_accumulator, NULL,
- gnt_closure_marshal_BOOLEAN__INT_INT_INT_POINTER,
+ gnt_boolean_handled_accumulator, NULL, NULL, G_TYPE_BOOLEAN, 4, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_POINTER);
signals[SIG_TERMINAL_REFRESH] =
@@ -1506,8 +1495,7 @@
G_TYPE_FROM_CLASS(klass),
G_STRUCT_OFFSET(GntWMClass, terminal_refresh),
- g_cclosure_marshal_VOID__VOID,
gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-next", window_next,
--- a/libpurple/Makefile.am Thu Jun 15 10:48:26 2017 +0300
+++ b/libpurple/Makefile.am Fri Jun 30 15:03:16 2017 +0300
@@ -5,7 +5,6 @@
purple-notifications-example \
@@ -40,13 +39,6 @@
- ciphers/pbkdf2cipher.c \
@@ -121,8 +113,7 @@
@@ -133,7 +124,6 @@
@@ -233,20 +223,11 @@
-purple_cipherheaders = \
-purple_builtheaders = purple.h version.h enums.h marshallers.h
+purple_builtheaders = purple.h version.h enums.h
$(srcdir)/conversation.h \
$(srcdir)/conversationtypes.h \
@@ -263,13 +244,6 @@
-marshallers.h: marshallers.list
- $(AM_V_GEN)$(GLIB_GENMARSHAL) --prefix=purple_smarshal $(srcdir)/marshallers.list --header > marshallers.h
-marshallers.c: marshallers.list marshallers.h
- $(AM_V_GEN)echo "#include \"marshallers.h\"" > marshallers.c
- $(AM_V_at)$(GLIB_GENMARSHAL) --prefix=purple_smarshal $(srcdir)/marshallers.list --body >> marshallers.c
# glib-mkenums doesn't handle VPATHs well, sed is used here to fix the
# include paths and documentation.
# Escaping possible . in $(srcdir) to \. for sed pattern.
@@ -283,9 +257,7 @@
data/purple-url-handler.desktop
@@ -314,14 +286,13 @@
prefs.h presence.h roomlist.h savedstatuses.h smiley.h smiley-list.h \
status.h server.h util.h xmlnode.h protocol.h protocols.h
-# Filter out enums.h and marshallers.h as they don't actually generate
-# anything. This way making from a VPATH and distcheck doesn't fail due
-# to not being able to find the enums.h or marshallers.h files if
-# they've already been generated in the $(srcdir).
+# Filter out enums.h as it doesn't actually generate anything. +# This way making from a VPATH and distcheck doesn't fail due +# to not being able to find the enums.h file if it's already +# been generated in the $(srcdir). purple_build_coreheaders = $(addprefix $(srcdir)/, $(purple_coreheaders)) \
- $(addprefix $(srcdir)/ciphers/, $(purple_cipherheaders)) \
$(addprefix $(srcdir)/media/, $(purple_mediaheaders)) \
- $(filter-out: enums.h marshallers.h, $(purple_builtheaders))
+ $(filter-out: enums.h, $(purple_builtheaders)) dbus_build_exported = $(addprefix $(srcdir)/, $(dbus_exported))
# We should probably make this better
dbus_signals = $(addprefix $(srcdir)/, $(purple_coresources)) \
@@ -345,7 +316,7 @@
# Declare these as dependencies so they're built even if `make distcheck`
# is run immediately after configuring.
-$(libpurple_la_OBJECTS): dbus-types.h enums.h marshallers.h
+$(libpurple_la_OBJECTS): dbus-types.h enums.h @@ -358,7 +329,7 @@
purple-client-bindings.c: dbus-analyze-functions.py $(dbus_exported)
$(AM_V_GEN) $(PYTHON) $(srcdir)/dbus-analyze-functions.py --client -o $@ $(dbus_build_exported)
-purple-client-bindings.h: dbus-analyze-types.py dbus-analyze-functions.py $(purple_coreheaders) $(addprefix ciphers/, $(purple_cipherheaders)) $(addprefix media/, $(purple_mediaheaders)) $(purple_builtheaders) $(dbus_exported)
+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) $(PYTHON) $(srcdir)/dbus-analyze-types.py --keyword=enum --verbatim -o $@ $(purple_build_coreheaders)
$(AM_V_at) $(PYTHON) $(srcdir)/dbus-analyze-functions.py --client --headers --append -o $@ $(dbus_build_exported)
@@ -398,7 +369,7 @@
# Declare these as dependencies so they're built even if `make distcheck`
# is run immediately after configuring.
-$(libpurple_la_OBJECTS): enums.h marshallers.h
+$(libpurple_la_OBJECTS): enums.h @@ -420,10 +391,6 @@
-cipherincludedir=$(includedir)/libpurple/ciphers
-cipherinclude_HEADERS = \
- $(addprefix $(srcdir)/ciphers/, $(purple_cipherheaders))
mediaincludedir=$(includedir)/libpurple/media
$(addprefix $(srcdir)/media/, $(purple_mediaheaders))
@@ -467,8 +434,6 @@
@@ -487,8 +452,6 @@
$(NETWORKMANAGER_CFLAGS) \
@@ -500,7 +463,6 @@
introspection_sources = \
$(libpurpleinclude_HEADERS) \
- $(addprefix ciphers/, $(purple_cipherheaders)) \
$(addprefix media/, $(purple_mediaheaders))
Purple-$(PURPLE_MAJOR_VERSION).$(PURPLE_MINOR_VERSION).gir: $(builddir)/libpurple.la
@@ -530,8 +492,6 @@
$(NETWORKMANAGER_CFLAGS) \
--- a/libpurple/Makefile.mingw Thu Jun 15 10:48:26 2017 +0300
+++ b/libpurple/Makefile.mingw Fri Jun 30 15:03:16 2017 +0300
@@ -56,7 +56,7 @@
-BUILT_SRC = marshallers.c enums.c
@@ -68,13 +68,6 @@
- ciphers/pbkdf2cipher.c \
@@ -146,7 +139,6 @@
@@ -209,15 +201,6 @@
$(OBJECTS): $(PURPLE_CONFIG_H) $(PURPLE_VERSION_H) $(PURPLE_PURPLE_H)
-marshallers.h: marshallers.list
- @$(GLIB_GENMARSHAL) --prefix=purple_smarshal $< --header > marshallers.h
-marshallers.c: marshallers.list marshallers.h
- @echo "#include \"marshallers.h\"" > marshallers.c
- @$(GLIB_GENMARSHAL) --prefix=purple_smarshal $< --body >> marshallers.c
enums.h: enums.h.in $(ENUM_HEADERS)
@$(GLIB_MKENUMS) --template enums.h.in $(ENUM_HEADERS) > enums.h
@@ -233,7 +216,7 @@
- rm -f $(OBJECTS) $(RC_SRC) $(PURPLE_VERSION_H) $(PURPLE_PURPLE_H) marshallers.h marshallers.c enums.h enums.c
+ rm -f $(OBJECTS) $(RC_SRC) $(PURPLE_VERSION_H) $(PURPLE_PURPLE_H) enums.h enums.c rm -f $(TARGET).dll $(TARGET).dll.a $(TARGET).def
$(MAKE_at) $(MAKE) -C $(PURPLE_PROTOS_TOP) -f $(MINGW_MAKEFILE) clean
$(MAKE_at) $(MAKE) -C $(PURPLE_PLUGINS_TOP) -f $(MINGW_MAKEFILE) clean
--- a/libpurple/cipher.c Thu Jun 15 10:48:26 2017 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,555 +0,0 @@
- * 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
- * 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
-/******************************************************************************
- *****************************************************************************/
-purple_cipher_get_type(void) {
- static const GTypeInfo info = {
- sizeof(PurpleCipherClass),
- type = g_type_register_static(G_TYPE_OBJECT,
- &info, G_TYPE_FLAG_ABSTRACT);
-purple_cipher_get_name(PurpleCipher *cipher)
- PurpleCipherClass *klass;
- if (!PURPLE_IS_CIPHER(cipher))
- return "(error: not a cipher)";
- klass = PURPLE_CIPHER_GET_CLASS(cipher);
- return "(error: unknown cipher class)";
- name = g_type_name(G_TYPE_FROM_CLASS(klass));
- return "(error: unknown cipher name)";
-purple_hash_get_name(PurpleHash *hash)
- PurpleHashClass *klass;
- if (!PURPLE_IS_HASH(hash))
- return "(error: not a hash)";
- klass = PURPLE_HASH_GET_CLASS(hash);
- return "(error: unknown hash class)";
- name = g_type_name(G_TYPE_FROM_CLASS(klass));
- return "(error: unknown hash name)";
-purple_cipher_reset(PurpleCipher *cipher) {
- PurpleCipherClass *klass = NULL;
- g_return_if_fail(PURPLE_IS_CIPHER(cipher));
- klass = PURPLE_CIPHER_GET_CLASS(cipher);
- if (klass && klass->reset)
- purple_debug_warning("cipher", "the %s cipher does not "
- "implement the reset method",
- purple_cipher_get_name(cipher));
-purple_cipher_reset_state(PurpleCipher *cipher) {
- PurpleCipherClass *klass = NULL;
- g_return_if_fail(PURPLE_IS_CIPHER(cipher));
- klass = PURPLE_CIPHER_GET_CLASS(cipher);
- if (klass && klass->reset_state)
- klass->reset_state(cipher);
- purple_debug_warning("cipher", "the %s cipher does not "
- "implement the reset_state method",
- purple_cipher_get_name(cipher));
-purple_cipher_set_iv(PurpleCipher *cipher, guchar *iv, size_t len)
- PurpleCipherClass *klass = NULL;
- g_return_if_fail(PURPLE_IS_CIPHER(cipher));
- klass = PURPLE_CIPHER_GET_CLASS(cipher);
- if (klass && klass->set_iv)
- klass->set_iv(cipher, iv, len);
- purple_debug_warning("cipher", "the %s cipher does not "
- "implement the set_iv method",
- purple_cipher_get_name(cipher));
-purple_cipher_append(PurpleCipher *cipher, const guchar *data,
- PurpleCipherClass *klass = NULL;
- g_return_if_fail(PURPLE_IS_CIPHER(cipher));
- klass = PURPLE_CIPHER_GET_CLASS(cipher);
- if (klass && klass->append)
- klass->append(cipher, data, len);
- purple_debug_warning("cipher", "the %s cipher does not "
- "implement the append method",
- purple_cipher_get_name(cipher));
-purple_cipher_digest(PurpleCipher *cipher, guchar digest[], size_t len)
- PurpleCipherClass *klass = NULL;
- g_return_val_if_fail(PURPLE_IS_CIPHER(cipher), FALSE);
- klass = PURPLE_CIPHER_GET_CLASS(cipher);
- if (klass && klass->digest)
- return klass->digest(cipher, digest, len);
- purple_debug_warning("cipher", "the %s cipher does not "
- "implement the digest method",
- purple_cipher_get_name(cipher));
-purple_cipher_digest_to_str(PurpleCipher *cipher, gchar digest_s[], size_t len)
- /* 8k is a bit excessive, will tweak later. */
- guchar digest[BUF_LEN * 4];
- g_return_val_if_fail(PURPLE_IS_CIPHER(cipher), FALSE);
- g_return_val_if_fail(digest_s, FALSE);
- digest_size = purple_cipher_get_digest_size(cipher);
- g_return_val_if_fail(digest_size <= BUF_LEN * 4, FALSE);
- if(!purple_cipher_digest(cipher, digest, sizeof(digest)))
- /* Every digest byte occupies 2 chars + the NUL at the end. */
- g_return_val_if_fail(digest_size * 2 + 1 <= len, FALSE);
- for(n = 0; n < digest_size; n++)
- sprintf(digest_s + (n * 2), "%02x", digest[n]);
- digest_s[n * 2] = '\0';
-purple_cipher_get_digest_size(PurpleCipher *cipher)
- PurpleCipherClass *klass = NULL;
- g_return_val_if_fail(PURPLE_IS_CIPHER(cipher), FALSE);
- klass = PURPLE_CIPHER_GET_CLASS(cipher);
- if (klass && klass->get_digest_size)
- return klass->get_digest_size(cipher);
- purple_debug_warning("cipher", "the %s cipher does not "
- "implement the get_digest_size method",
- purple_cipher_get_name(cipher));
-purple_cipher_encrypt(PurpleCipher *cipher, const guchar input[],
- size_t in_len, guchar output[], size_t out_size)
- PurpleCipherClass *klass = NULL;
- g_return_val_if_fail(PURPLE_IS_CIPHER(cipher), -1);
- g_return_val_if_fail(input != NULL, -1);
- g_return_val_if_fail(output != NULL, -1);
- g_return_val_if_fail(out_size >= in_len, -1);
- klass = PURPLE_CIPHER_GET_CLASS(cipher);
- if (klass && klass->encrypt)
- return klass->encrypt(cipher, input, in_len, output, out_size);
- purple_debug_warning("cipher", "the %s cipher does not "
- "implement the encrypt method",
- purple_cipher_get_name(cipher));
-purple_cipher_decrypt(PurpleCipher *cipher, const guchar input[],
- size_t in_len, guchar output[], size_t out_size)
- PurpleCipherClass *klass = NULL;
- g_return_val_if_fail(PURPLE_IS_CIPHER(cipher), -1);
- g_return_val_if_fail(input != NULL, -1);
- g_return_val_if_fail(output != NULL, -1);
- klass = PURPLE_CIPHER_GET_CLASS(cipher);
- if (klass && klass->decrypt)
- return klass->decrypt(cipher, input, in_len, output, out_size);
- purple_debug_warning("cipher", "the %s cipher does not "
- "implement the decrypt method",
- purple_cipher_get_name(cipher));
-purple_cipher_set_salt(PurpleCipher *cipher, const guchar *salt, size_t len) {
- PurpleCipherClass *klass = NULL;
- g_return_if_fail(PURPLE_IS_CIPHER(cipher));
- klass = PURPLE_CIPHER_GET_CLASS(cipher);
- if (klass && klass->set_salt)
- klass->set_salt(cipher, salt, len);
- purple_debug_warning("cipher", "the %s cipher does not "
- "implement the set_salt method",
- purple_cipher_get_name(cipher));
-purple_cipher_set_key(PurpleCipher *cipher, const guchar *key, size_t len) {
- PurpleCipherClass *klass = NULL;
- g_return_if_fail(PURPLE_IS_CIPHER(cipher));
- klass = PURPLE_CIPHER_GET_CLASS(cipher);
- if (klass && klass->set_key)
- klass->set_key(cipher, key, len);
- purple_debug_warning("cipher", "the %s cipher does not "
- "implement the set_key method",
- purple_cipher_get_name(cipher));
-purple_cipher_get_key_size(PurpleCipher *cipher) {
- PurpleCipherClass *klass = NULL;
- g_return_val_if_fail(PURPLE_IS_CIPHER(cipher), -1);
- klass = PURPLE_CIPHER_GET_CLASS(cipher);
- if (klass && klass->get_key_size)
- return klass->get_key_size(cipher);
- purple_debug_warning("cipher", "the %s cipher does not "
- "implement the get_key_size method",
- purple_cipher_get_name(cipher));
-purple_cipher_set_batch_mode(PurpleCipher *cipher,
- PurpleCipherBatchMode mode)
- PurpleCipherClass *klass = NULL;
- g_return_if_fail(PURPLE_IS_CIPHER(cipher));
- klass = PURPLE_CIPHER_GET_CLASS(cipher);
- if (klass && klass->set_batch_mode)
- klass->set_batch_mode(cipher, mode);
- purple_debug_warning("cipher", "the %s cipher does not "
- "implement the set_batch_mode method",
- purple_cipher_get_name(cipher));
-purple_cipher_get_batch_mode(PurpleCipher *cipher)
- PurpleCipherClass *klass = NULL;
- g_return_val_if_fail(PURPLE_IS_CIPHER(cipher), -1);
- klass = PURPLE_CIPHER_GET_CLASS(cipher);
- if (klass && klass->get_batch_mode)
- return klass->get_batch_mode(cipher);
- purple_debug_warning("cipher", "the %s cipher does not "
- "implement the get_batch_mode method",
- purple_cipher_get_name(cipher));
-purple_cipher_get_block_size(PurpleCipher *cipher)
- PurpleCipherClass *klass = NULL;
- g_return_val_if_fail(PURPLE_IS_CIPHER(cipher), -1);
- klass = PURPLE_CIPHER_GET_CLASS(cipher);
- if (klass && klass->get_block_size)
- return klass->get_block_size(cipher);
- purple_debug_warning("cipher", "the %s cipher does not "
- "implement the get_block_size method",
- purple_cipher_get_name(cipher));
-/******************************************************************************
- *****************************************************************************/
-purple_hash_get_type(void) {
- static const GTypeInfo info = {
- sizeof(PurpleHashClass),
- type = g_type_register_static(G_TYPE_OBJECT,
- &info, G_TYPE_FLAG_ABSTRACT);
-purple_hash_reset(PurpleHash *hash) {
- PurpleHashClass *klass = NULL;
- g_return_if_fail(PURPLE_IS_HASH(hash));
- klass = PURPLE_HASH_GET_CLASS(hash);
- if (klass && klass->reset)
- purple_debug_warning("hash", "the %s hash does not implement "
- "the reset method", purple_hash_get_name(hash));
-purple_hash_reset_state(PurpleHash *hash) {
- PurpleHashClass *klass = NULL;
- g_return_if_fail(PURPLE_IS_HASH(hash));
- klass = PURPLE_HASH_GET_CLASS(hash);
- if (klass && klass->reset_state)
- klass->reset_state(hash);
- purple_debug_warning("hash", "the %s hash does not implement "
- "the reset_state method", purple_hash_get_name(hash));
-purple_hash_append(PurpleHash *hash, const guchar *data,
- PurpleHashClass *klass = NULL;
- g_return_if_fail(PURPLE_IS_HASH(hash));
- klass = PURPLE_HASH_GET_CLASS(hash);
- if (klass && klass->append)
- klass->append(hash, data, len);
- purple_debug_warning("hash", "the %s hash does not implement "
- "the append method", purple_hash_get_name(hash));
-purple_hash_digest(PurpleHash *hash, guchar digest[], size_t len)
- PurpleHashClass *klass = NULL;
- g_return_val_if_fail(PURPLE_IS_HASH(hash), FALSE);
- klass = PURPLE_HASH_GET_CLASS(hash);
- if (klass && klass->digest)
- return klass->digest(hash, digest, len);
- purple_debug_warning("hash", "the %s hash does not implement "
- "the digest method", purple_hash_get_name(hash));
-purple_hash_digest_to_str(PurpleHash *hash, gchar digest_s[], size_t len)
- /* 8k is a bit excessive, will tweak later. */
- guchar digest[BUF_LEN * 4];
- g_return_val_if_fail(PURPLE_IS_HASH(hash), FALSE);
- g_return_val_if_fail(digest_s, FALSE);
- digest_size = purple_hash_get_digest_size(hash);
- g_return_val_if_fail(digest_size <= BUF_LEN * 4, FALSE);
- if(!purple_hash_digest(hash, digest, sizeof(digest)))
- /* Every digest byte occupies 2 chars + the NUL at the end. */
- g_return_val_if_fail(digest_size * 2 + 1 <= len, FALSE);
- for(n = 0; n < digest_size; n++)
- sprintf(digest_s + (n * 2), "%02x", digest[n]);
- digest_s[n * 2] = '\0';
-purple_hash_get_digest_size(PurpleHash *hash)
- PurpleHashClass *klass = NULL;
- g_return_val_if_fail(PURPLE_IS_HASH(hash), FALSE);
- klass = PURPLE_HASH_GET_CLASS(hash);
- if (klass && klass->get_digest_size)
- return klass->get_digest_size(hash);
- purple_debug_warning("hash", "the %s hash does not implement "
- "the get_digest_size method", purple_hash_get_name(hash));
-purple_hash_get_block_size(PurpleHash *hash)
- PurpleHashClass *klass = NULL;
- g_return_val_if_fail(PURPLE_IS_HASH(hash), -1);
- klass = PURPLE_HASH_GET_CLASS(hash);
- if (klass && klass->get_block_size)
- return klass->get_block_size(hash);
- purple_debug_warning("hash", "the %s hash does not implement "
- "the get_block_size method", purple_hash_get_name(hash));
--- a/libpurple/cipher.h Thu Jun 15 10:48:26 2017 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,421 +0,0 @@
- * 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
- * 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
- * @section_id: libpurple-cipher
- * @short_description: <filename>cipher.h</filename>
- * @title: Cipher and Hash API
-#include <glib-object.h>
-#define PURPLE_TYPE_CIPHER (purple_cipher_get_type())
-#define PURPLE_CIPHER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_CIPHER, PurpleCipher))
-#define PURPLE_CIPHER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_CIPHER, PurpleCipherClass))
-#define PURPLE_IS_CIPHER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_CIPHER))
-#define PURPLE_IS_CIPHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PURPLE_TYPE_CIPHER))
-#define PURPLE_CIPHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_CIPHER, PurpleCipherClass))
-typedef struct _PurpleCipher PurpleCipher;
-typedef struct _PurpleCipherClass PurpleCipherClass;
-#define PURPLE_TYPE_HASH (purple_hash_get_type())
-#define PURPLE_HASH(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_HASH, PurpleHash))
-#define PURPLE_HASH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_HASH, PurpleHashClass))
-#define PURPLE_IS_HASH(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_HASH))
-#define PURPLE_IS_HASH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PURPLE_TYPE_HASH))
-#define PURPLE_HASH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_HASH, PurpleHashClass))
-typedef struct _PurpleHash PurpleHash;
-typedef struct _PurpleHashClass PurpleHashClass;
- * PurpleCipherBatchMode:
- * @PURPLE_CIPHER_BATCH_MODE_ECB: Electronic Codebook Mode
- * @PURPLE_CIPHER_BATCH_MODE_CBC: Cipher Block Chaining Mode
- * Modes for batch encrypters
- PURPLE_CIPHER_BATCH_MODE_ECB,
- PURPLE_CIPHER_BATCH_MODE_CBC
-} PurpleCipherBatchMode;
- * Purple Cipher is an opaque data structure and should not be used directly.
-struct _PurpleCipherClass {
- GObjectClass parent_class;
- /** The reset function */
- void (*reset)(PurpleCipher *cipher);
- /** The reset state function */
- void (*reset_state)(PurpleCipher *cipher);
- /** The set initialization vector function */
- void (*set_iv)(PurpleCipher *cipher, guchar *iv, size_t len);
- /** The append data function */
- void (*append)(PurpleCipher *cipher, const guchar *data, size_t len);
- /** The digest function */
- gboolean (*digest)(PurpleCipher *cipher, guchar digest[], size_t len);
- /** The get digest size function */
- size_t (*get_digest_size)(PurpleCipher *cipher);
- /** The encrypt function */
- ssize_t (*encrypt)(PurpleCipher *cipher, const guchar input[], size_t in_len, guchar output[], size_t out_size);
- /** The decrypt function */
- ssize_t (*decrypt)(PurpleCipher *cipher, const guchar input[], size_t in_len, guchar output[], size_t out_size);
- /** The set salt function */
- void (*set_salt)(PurpleCipher *cipher, const guchar *salt, size_t len);
- /** The set key function */
- void (*set_key)(PurpleCipher *cipher, const guchar *key, size_t len);
- /** The get key size function */
- size_t (*get_key_size)(PurpleCipher *cipher);
- /** The set batch mode function */
- void (*set_batch_mode)(PurpleCipher *cipher, PurpleCipherBatchMode mode);
- /** The get batch mode function */
- PurpleCipherBatchMode (*get_batch_mode)(PurpleCipher *cipher);
- /** The get block size function */
- size_t (*get_block_size)(PurpleCipher *cipher);
- void (*_purple_reserved1)(void);
- void (*_purple_reserved2)(void);
- void (*_purple_reserved3)(void);
- void (*_purple_reserved4)(void);
- * Purple Hash is an opaque data structure and should not be used directly.
-struct _PurpleHashClass {
- GObjectClass parent_class;
- /** The reset function */
- void (*reset)(PurpleHash *hash);
- /** The reset state function */
- void (*reset_state)(PurpleHash *hash);
- /** The append data function */
- void (*append)(PurpleHash *hash, const guchar *data, size_t len);
- /** The digest function */
- gboolean (*digest)(PurpleHash *hash, guchar digest[], size_t len);
- /** The get digest size function */
- size_t (*get_digest_size)(PurpleHash *hash);
- /** The get block size function */
- size_t (*get_block_size)(PurpleHash *hash);
- void (*_purple_reserved1)(void);
- void (*_purple_reserved2)(void);
- void (*_purple_reserved3)(void);
- void (*_purple_reserved4)(void);
-/*****************************************************************************/
-/*****************************************************************************/
- * purple_cipher_get_type:
- * Returns: The #GType for the Cipher object.
-GType purple_cipher_get_type(void);
- * Resets a cipher to it's default value
- * Note: If you have set an IV you will have to set it after resetting
-void purple_cipher_reset(PurpleCipher *cipher);
- * purple_cipher_reset_state:
- * Resets a cipher state to it's default value, but doesn't touch stateless
- * That means, IV and digest will be wiped out, but keys, ops or salt
- * will remain untouched.
-void purple_cipher_reset_state(PurpleCipher *cipher);
- * purple_cipher_set_iv:
- * @iv: The initialization vector to set
- * @len: The len of the IV
- * Sets the initialization vector for a cipher
- * Note: This should only be called right after a cipher is created or reset
-void purple_cipher_set_iv(PurpleCipher *cipher, guchar *iv, size_t len);
- * purple_cipher_append:
- * @data: The data to append
- * @len: The length of the data
- * Appends data to the cipher context
-void purple_cipher_append(PurpleCipher *cipher, const guchar *data, size_t len);
- * purple_cipher_digest:
- * @digest: The return buffer for the digest
- * @len: The length of the buffer
- * Digests a cipher context
-gboolean purple_cipher_digest(PurpleCipher *cipher, guchar digest[], size_t len);
- * purple_cipher_digest_to_str:
- * @digest_s: The return buffer for the string digest
- * @len: The length of the buffer
- * Converts a guchar digest into a hex string
-gboolean purple_cipher_digest_to_str(PurpleCipher *cipher, gchar digest_s[], size_t len);
- * purple_cipher_get_digest_size:
- * @cipher: The cipher whose digest size to get
- * Gets the digest size of a cipher
- * Returns: The digest size of the cipher
-size_t purple_cipher_get_digest_size(PurpleCipher *cipher);
- * purple_cipher_encrypt:
- * @input: The data to encrypt
- * @in_len: The length of the data
- * @output: The output buffer
- * @out_size: The size of the output buffer
- * Encrypts data using the cipher
- * Returns: A length of data that was outputed or -1, if failed
-ssize_t purple_cipher_encrypt(PurpleCipher *cipher, const guchar input[], size_t in_len, guchar output[], size_t out_size);
- * purple_cipher_decrypt:
- * @input: The data to encrypt
- * @in_len: The length of the returned value
- * @output: The output buffer
- * @out_size: The size of the output buffer
- * Decrypts data using the cipher
- * Returns: A length of data that was outputed or -1, if failed
-ssize_t purple_cipher_decrypt(PurpleCipher *cipher, const guchar input[], size_t in_len, guchar output[], size_t out_size);
- * purple_cipher_set_salt:
- * @cipher: The cipher whose salt to set
- * @len: The length of the salt
- * Sets the salt on a cipher
-void purple_cipher_set_salt(PurpleCipher *cipher, const guchar *salt, size_t len);
- * purple_cipher_set_key:
- * @cipher: The cipher whose key to set
- * @len: The size of the key
- * Sets the key on a cipher
-void purple_cipher_set_key(PurpleCipher *cipher, const guchar *key, size_t len);
- * purple_cipher_get_key_size:
- * @cipher: The cipher whose key size to get
- * Gets the size of the key if the cipher supports it
- * Returns: The size of the key
-size_t purple_cipher_get_key_size(PurpleCipher *cipher);
- * purple_cipher_set_batch_mode:
- * @cipher: The cipher whose batch mode to set
- * @mode: The batch mode under which the cipher should operate
- * Sets the batch mode of a cipher
-void purple_cipher_set_batch_mode(PurpleCipher *cipher, PurpleCipherBatchMode mode);
- * purple_cipher_get_batch_mode:
- * @cipher: The cipher whose batch mode to get
- * Gets the batch mode of a cipher
- * Returns: The batch mode under which the cipher is operating
-PurpleCipherBatchMode purple_cipher_get_batch_mode(PurpleCipher *cipher);
- * purple_cipher_get_block_size:
- * @cipher: The cipher whose block size to get
- * Gets the block size of a cipher
- * Returns: The block size of the cipher
-size_t purple_cipher_get_block_size(PurpleCipher *cipher);
-/*****************************************************************************/
-/*****************************************************************************/
- * purple_hash_get_type:
- * Returns: The #GType for the Hash object.
-GType purple_hash_get_type(void);
- * Resets a hash to it's default value
- * Note: If you have set an IV you will have to set it after resetting
-void purple_hash_reset(PurpleHash *hash);
- * purple_hash_reset_state:
- * Resets a hash state to it's default value, but doesn't touch stateless
- * That means, IV and digest will be wiped out, but keys, ops or salt
- * will remain untouched.
-void purple_hash_reset_state(PurpleHash *hash);
- * @data: The data to append
- * @len: The length of the data
- * Appends data to the hash context
-void purple_hash_append(PurpleHash *hash, const guchar *data, size_t len);
- * @digest: The return buffer for the digest
- * @len: The length of the buffer
- * Digests a hash context
-gboolean purple_hash_digest(PurpleHash *hash, guchar digest[], size_t len);
- * purple_hash_digest_to_str:
- * @digest_s: The return buffer for the string digest
- * @len: The length of the buffer
- * Converts a guchar digest into a hex string
-gboolean purple_hash_digest_to_str(PurpleHash *hash, gchar digest_s[], size_t len);
- * purple_hash_get_digest_size:
- * @hash: The hash whose digest size to get
- * Gets the digest size of a hash
- * Returns: The digest size of the hash
-size_t purple_hash_get_digest_size(PurpleHash *hash);
- * purple_hash_get_block_size:
- * @hash: The hash whose block size to get
- * Gets the block size of a hash
- * Returns: The block size of the hash
-size_t purple_hash_get_block_size(PurpleHash *hash);
-#endif /* PURPLE_CIPHER_H */
--- a/libpurple/ciphers/aescipher.c Thu Jun 15 10:48:26 2017 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,725 +0,0 @@
- * 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
- * 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
- * Written by Tomek Wasilczyk <twasilczyk@pidgin.im>
-#if defined(HAVE_GNUTLS)
-# define PURPLE_AES_USE_GNUTLS 1
-# include <gnutls/gnutls.h>
-# include <gnutls/crypto.h>
-# define PURPLE_AES_USE_NSS 1
-# warning "No GnuTLS or NSS support"
-#define PURPLE_AES_BLOCK_SIZE 16
-/******************************************************************************
- *****************************************************************************/
-#define PURPLE_AES_CIPHER_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_AES_CIPHER, PurpleAESCipherPrivate))
- guchar iv[PURPLE_AES_BLOCK_SIZE];
- PurpleCipherBatchMode batch_mode;
-} PurpleAESCipherPrivate;
-/******************************************************************************
- *****************************************************************************/
-/*******************************************************************************
- ******************************************************************************/
-static GParamSpec *properties[PROP_LAST];
-/******************************************************************************
- *****************************************************************************/
-typedef gboolean (*purple_aes_cipher_crypt_func)(
- const guchar *input, guchar *output, size_t len,
- guchar iv[PURPLE_AES_BLOCK_SIZE], guchar key[32], guint key_size,
- PurpleCipherBatchMode batch_mode);
-purple_aes_cipher_reset(PurpleCipher *cipher)
- PurpleAESCipherPrivate *priv = PURPLE_AES_CIPHER_GET_PRIVATE(cipher);
- g_return_if_fail(priv != NULL);
- memset(priv->iv, 0, sizeof(priv->iv));
- memset(priv->key, 0, sizeof(priv->key));
- priv->key_size = 32; /* 256bit */
-purple_aes_cipher_set_iv(PurpleCipher *cipher, guchar *iv, size_t len)
- PurpleAESCipherPrivate *priv = PURPLE_AES_CIPHER_GET_PRIVATE(cipher);
- if ((len > 0 && iv == NULL) ||
- (len != 0 && len != sizeof(priv->iv))) {
- purple_debug_error("cipher-aes", "invalid IV length\n");
- memset(priv->iv, 0, sizeof(priv->iv));
- memcpy(priv->iv, iv, len);
- g_object_notify_by_pspec(G_OBJECT(cipher), properties[PROP_IV]);
-purple_aes_cipher_set_key(PurpleCipher *cipher, const guchar *key, size_t len)
- PurpleAESCipherPrivate *priv = PURPLE_AES_CIPHER_GET_PRIVATE(cipher);
- if ((len > 0 && key == NULL) ||
- (len != 0 && len != 16 && len != 24 && len != 32)) {
- purple_debug_error("cipher-aes", "invalid key length\n");
- memset(priv->key, 0, sizeof(priv->key));
- memcpy(priv->key, key, len);
- g_object_notify_by_pspec(G_OBJECT(cipher), properties[PROP_KEY]);
-purple_aes_cipher_pad_pkcs7(const guchar input[], size_t in_len, size_t *out_len)
- int padding_len, total_len;
- g_return_val_if_fail(input != NULL, NULL);
- g_return_val_if_fail(out_len != NULL, NULL);
- padding_len = PURPLE_AES_BLOCK_SIZE - (in_len % PURPLE_AES_BLOCK_SIZE);
- total_len = in_len + padding_len;
- g_assert((total_len % PURPLE_AES_BLOCK_SIZE) == 0);
- padded = g_new(guchar, total_len);
- memcpy(padded, input, in_len);
- memset(padded + in_len, padding_len, padding_len);
-purple_aes_cipher_unpad_pkcs7(guchar input[], size_t in_len)
- g_return_val_if_fail(input != NULL, -1);
- g_return_val_if_fail(in_len > 0, -1);
- padding_len = input[in_len - 1];
- if (padding_len == 0 || padding_len > PURPLE_AES_BLOCK_SIZE ||
- padding_len > in_len) {
- purple_debug_warning("cipher-aes",
- "Invalid padding length: %d (total %" G_GSIZE_FORMAT ") - "
- "most probably, the key was invalid\n",
- out_len = in_len - padding_len;
- for (i = 0; i < padding_len; i++) {
- if (input[out_len + i] != padding_len) {
- purple_debug_warning("cipher-aes",
- "Padding doesn't match at pos %d (found %02x, "
- "most probably, the key was invalid\n",
- i, input[out_len + i], padding_len);
- memset(input + out_len, 0, padding_len);
-#ifdef PURPLE_AES_USE_GNUTLS
-static gnutls_cipher_hd_t
-purple_aes_cipher_gnutls_crypt_init(guchar iv[PURPLE_AES_BLOCK_SIZE], guchar key[32],
- gnutls_cipher_hd_t handle;
- gnutls_cipher_algorithm_t algorithm;
- gnutls_datum_t key_info, iv_info;
- algorithm = GNUTLS_CIPHER_AES_128_CBC;
- else if (key_size == 24)
- algorithm = GNUTLS_CIPHER_AES_192_CBC;
- else if (key_size == 32)
- algorithm = GNUTLS_CIPHER_AES_256_CBC;
- g_return_val_if_reached(NULL);
- key_info.size = key_size;
- iv_info.size = PURPLE_AES_BLOCK_SIZE;
- ret = gnutls_cipher_init(&handle, algorithm, &key_info, &iv_info);
- purple_debug_error("cipher-aes",
- "gnutls_cipher_init failed: %d\n", ret);
-purple_aes_cipher_gnutls_encrypt(const guchar *input, guchar *output, size_t len,
- guchar iv[PURPLE_AES_BLOCK_SIZE], guchar key[32], guint key_size,
- PurpleCipherBatchMode batch_mode)
- gnutls_cipher_hd_t handle;
- /* We have to simulate ECB mode, which is not supported by GnuTLS. */
- if (batch_mode == PURPLE_CIPHER_BATCH_MODE_ECB) {
- for (i = 0; i < len / PURPLE_AES_BLOCK_SIZE; i++) {
- int offset = i * PURPLE_AES_BLOCK_SIZE;
- guchar iv_local[PURPLE_AES_BLOCK_SIZE];
- memcpy(iv_local, iv, sizeof(iv_local));
- succ = purple_aes_cipher_gnutls_encrypt(
- input + offset, output + offset,
- iv_local, key, key_size,
- PURPLE_CIPHER_BATCH_MODE_CBC);
- handle = purple_aes_cipher_gnutls_crypt_init(iv, key, key_size);
- ret = gnutls_cipher_encrypt2(handle, (guchar *)input, len, output, len);
- gnutls_cipher_deinit(handle);
- purple_debug_error("cipher-aes",
- "gnutls_cipher_encrypt2 failed: %d\n", ret);
-purple_aes_cipher_gnutls_decrypt(const guchar *input, guchar *output, size_t len,
- guchar iv[PURPLE_AES_BLOCK_SIZE], guchar key[32], guint key_size,
- PurpleCipherBatchMode batch_mode)
- gnutls_cipher_hd_t handle;
- /* We have to simulate ECB mode, which is not supported by GnuTLS. */
- if (batch_mode == PURPLE_CIPHER_BATCH_MODE_ECB) {
- for (i = 0; i < len / PURPLE_AES_BLOCK_SIZE; i++) {
- int offset = i * PURPLE_AES_BLOCK_SIZE;
- guchar iv_local[PURPLE_AES_BLOCK_SIZE];
- memcpy(iv_local, iv, sizeof(iv_local));
- succ = purple_aes_cipher_gnutls_decrypt(
- input + offset, output + offset,
- iv_local, key, key_size,
- PURPLE_CIPHER_BATCH_MODE_CBC);
- handle = purple_aes_cipher_gnutls_crypt_init(iv, key, key_size);
- ret = gnutls_cipher_decrypt2(handle, input, len, output, len);
- gnutls_cipher_deinit(handle);
- purple_debug_error("cipher-aes",
- "gnutls_cipher_decrypt2 failed: %d\n", ret);
-#elif defined(PURPLE_AES_USE_NSS)
- PK11Context *enc_context;
-} PurpleAESCipherNSSContext;
-purple_aes_cipher_nss_cleanup(PurpleAESCipherNSSContext *context)
- g_return_if_fail(context != NULL);
- if (context->enc_context != NULL)
- PK11_DestroyContext(context->enc_context, TRUE);
- if (context->sec_param != NULL)
- SECITEM_FreeItem(context->sec_param, TRUE);
- if (context->sym_key != NULL)
- PK11_FreeSymKey(context->sym_key);
- if (context->slot != NULL)
- PK11_FreeSlot(context->slot);
- memset(context, 0, sizeof(PurpleAESCipherNSSContext));
-purple_aes_cipher_nss_crypt(const guchar *input, guchar *output, size_t len,
- guchar iv[PURPLE_AES_BLOCK_SIZE], guchar key[32], guint key_size,
- CK_ATTRIBUTE_TYPE operation, CK_MECHANISM_TYPE cipher_mech)
- PurpleAESCipherNSSContext context;
- SECItem key_item, iv_item;
- unsigned int outlen_tmp = 0;
- memset(&context, 0, sizeof(PurpleAESCipherNSSContext));
- if (NSS_NoDB_Init(NULL) != SECSuccess) {
- purple_debug_error("cipher-aes",
- "NSS_NoDB_Init failed: %d\n", PR_GetError());
- context.slot = PK11_GetBestSlot(cipher_mech, NULL);
- if (context.slot == NULL) {
- purple_debug_error("cipher-aes",
- "PK11_GetBestSlot failed: %d\n", PR_GetError());
- key_item.type = siBuffer;
- key_item.len = key_size;
- context.sym_key = PK11_ImportSymKey(context.slot, cipher_mech,
- PK11_OriginUnwrap, CKA_ENCRYPT, &key_item, NULL);
- if (context.sym_key == NULL) {
- purple_debug_error("cipher-aes",
- "PK11_ImportSymKey failed: %d\n", PR_GetError());
- purple_aes_cipher_nss_cleanup(&context);
- iv_item.type = siBuffer;
- iv_item.len = PURPLE_AES_BLOCK_SIZE;
- context.sec_param = PK11_ParamFromIV(cipher_mech, &iv_item);
- if (context.sec_param == NULL) {
- purple_debug_error("cipher-aes",
- "PK11_ParamFromIV failed: %d\n", PR_GetError());
- purple_aes_cipher_nss_cleanup(&context);
- context.enc_context = PK11_CreateContextBySymKey(cipher_mech, operation,
- context.sym_key, context.sec_param);
- if (context.enc_context == NULL) {
- purple_debug_error("cipher-aes",
- "PK11_CreateContextBySymKey failed: %d\n",
- purple_aes_cipher_nss_cleanup(&context);
- ret = PK11_CipherOp(context.enc_context, output, &outlen, len,
- if (ret != SECSuccess) {
- purple_debug_error("cipher-aes",
- "PK11_CipherOp failed: %d\n", PR_GetError());
- purple_aes_cipher_nss_cleanup(&context);
- ret = PK11_DigestFinal(context.enc_context, output + outlen, &outlen_tmp,
- if (ret != SECSuccess) {
- purple_debug_error("cipher-aes",
- "PK11_DigestFinal failed: %d\n", PR_GetError());
- purple_aes_cipher_nss_cleanup(&context);
- purple_aes_cipher_nss_cleanup(&context);
- if (outlen != (int)len) {
- purple_debug_error("cipher-aes",
- "resulting length doesn't match: %d (expected: %"
- G_GSIZE_FORMAT ")\n", outlen, len);
-static CK_MECHANISM_TYPE
-purple_aes_cipher_nss_batch_mode(PurpleCipherBatchMode batch_mode)
- case PURPLE_CIPHER_BATCH_MODE_CBC:
- case PURPLE_CIPHER_BATCH_MODE_ECB:
-purple_aes_cipher_nss_encrypt(const guchar *input, guchar *output, size_t len,
- guchar iv[PURPLE_AES_BLOCK_SIZE], guchar key[32], guint key_size,
- PurpleCipherBatchMode batch_mode)
- return purple_aes_cipher_nss_crypt(input, output, len, iv, key, key_size,
- CKA_ENCRYPT, purple_aes_cipher_nss_batch_mode(batch_mode));
-purple_aes_cipher_nss_decrypt(const guchar *input, guchar *output, size_t len,
- guchar iv[PURPLE_AES_BLOCK_SIZE], guchar key[32], guint key_size,
- PurpleCipherBatchMode batch_mode)
- return purple_aes_cipher_nss_crypt(input, output, len, iv, key, key_size,
- CKA_DECRYPT, purple_aes_cipher_nss_batch_mode(batch_mode));
-#endif /* PURPLE_AES_USE_NSS */
-purple_aes_cipher_encrypt(PurpleCipher *cipher, const guchar input[],
- size_t in_len, guchar output[], size_t out_size)
- PurpleAESCipherPrivate *priv = PURPLE_AES_CIPHER_GET_PRIVATE(cipher);
- purple_aes_cipher_crypt_func encrypt_func;
- input_padded = purple_aes_cipher_pad_pkcs7(input, in_len, &out_len);
- if (out_len > out_size) {
- purple_debug_error("cipher-aes", "Output buffer too small (%"
- G_GSIZE_FORMAT " > %" G_GSIZE_FORMAT ")",
- memset(input_padded, 0, out_len);
-#if defined(PURPLE_AES_USE_GNUTLS)
- encrypt_func = purple_aes_cipher_gnutls_encrypt;
-#elif defined(PURPLE_AES_USE_NSS)
- encrypt_func = purple_aes_cipher_nss_encrypt;
- purple_debug_error("cipher-aes", "No matching encrypt_func\n");
- succ = encrypt_func(input_padded, output, out_len, priv->iv,
- priv->key, priv->key_size, priv->batch_mode);
- memset(input_padded, 0, out_len);
- memset(output, 0, out_len);
-purple_aes_cipher_decrypt(PurpleCipher *cipher, const guchar input[],
- size_t in_len, guchar output[], size_t out_size)
- PurpleAESCipherPrivate *priv = PURPLE_AES_CIPHER_GET_PRIVATE(cipher);
- purple_aes_cipher_crypt_func decrypt_func;
- if (in_len > out_size) {
- purple_debug_error("cipher-aes", "Output buffer too small\n");
- if ((in_len % PURPLE_AES_BLOCK_SIZE) != 0 || in_len == 0) {
- purple_debug_error("cipher-aes", "Malformed data\n");
-#if defined(PURPLE_AES_USE_GNUTLS)
- decrypt_func = purple_aes_cipher_gnutls_decrypt;
-#elif defined(PURPLE_AES_USE_NSS)
- decrypt_func = purple_aes_cipher_nss_decrypt;
- purple_debug_error("cipher-aes", "No matching decrypt_func\n");
- succ = decrypt_func(input, output, in_len, priv->iv, priv->key,
- priv->key_size, priv->batch_mode);
- memset(output, 0, in_len);
- out_len = purple_aes_cipher_unpad_pkcs7(output, in_len);
- memset(output, 0, in_len);
-purple_aes_cipher_get_key_size(PurpleCipher *cipher)
- PurpleAESCipherPrivate *priv = PURPLE_AES_CIPHER_GET_PRIVATE(cipher);
-purple_aes_cipher_set_batch_mode(PurpleCipher *cipher,
- PurpleCipherBatchMode mode)
- PurpleAESCipherPrivate *priv = PURPLE_AES_CIPHER_GET_PRIVATE(cipher);
- if (mode != PURPLE_CIPHER_BATCH_MODE_CBC &&
- mode != PURPLE_CIPHER_BATCH_MODE_ECB)
- purple_debug_error("cipher-aes", "unsupported batch mode\n");
- priv->batch_mode = mode;
- g_object_notify_by_pspec(G_OBJECT(cipher), properties[PROP_BATCH_MODE]);
-static PurpleCipherBatchMode
-purple_aes_cipher_get_batch_mode(PurpleCipher *cipher)
- PurpleAESCipherPrivate *priv = PURPLE_AES_CIPHER_GET_PRIVATE(cipher);
- return priv->batch_mode;
-purple_aes_cipher_get_block_size(PurpleCipher *cipher)
- return PURPLE_AES_BLOCK_SIZE;
-/******************************************************************************
- *****************************************************************************/
-purple_aes_cipher_get_property(GObject *obj, guint param_id, GValue *value,
- PurpleCipher *cipher = PURPLE_CIPHER(obj);
- g_value_set_enum(value,
- purple_cipher_get_batch_mode(cipher));
- G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
-purple_aes_cipher_set_property(GObject *obj, guint param_id,
- const GValue *value, GParamSpec *pspec)
- PurpleCipher *cipher = PURPLE_CIPHER(obj);
- purple_cipher_set_batch_mode(cipher,
- g_value_get_enum(value));
- guchar *iv = (guchar *)g_value_get_string(value);
- purple_cipher_set_iv(cipher, iv, strlen((gchar*)iv));
- purple_cipher_set_key(cipher, (guchar *)g_value_get_string(value),
- purple_aes_cipher_get_key_size(cipher));
- G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
-purple_aes_cipher_class_init(PurpleAESCipherClass *klass) {
- GObjectClass *obj_class = G_OBJECT_CLASS(klass);
- PurpleCipherClass *cipher_class = PURPLE_CIPHER_CLASS(klass);
- obj_class->get_property = purple_aes_cipher_get_property;
- obj_class->set_property = purple_aes_cipher_set_property;
- cipher_class->reset = purple_aes_cipher_reset;
- cipher_class->set_iv = purple_aes_cipher_set_iv;
- cipher_class->encrypt = purple_aes_cipher_encrypt;
- cipher_class->decrypt = purple_aes_cipher_decrypt;
- cipher_class->set_key = purple_aes_cipher_set_key;
- cipher_class->get_key_size = purple_aes_cipher_get_key_size;
- cipher_class->set_batch_mode = purple_aes_cipher_set_batch_mode;
- cipher_class->get_batch_mode = purple_aes_cipher_get_batch_mode;
- cipher_class->get_block_size = purple_aes_cipher_get_block_size;
- g_type_class_add_private(klass, sizeof(PurpleAESCipherPrivate));
- properties[PROP_BATCH_MODE] = g_param_spec_enum("batch-mode",
- "batch-mode", "batch-mode", PURPLE_TYPE_CIPHER_BATCH_MODE,
- PURPLE_CIPHER_BATCH_MODE_CBC,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
- properties[PROP_IV] = g_param_spec_string("iv", "iv", "iv", NULL,
- G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
- properties[PROP_KEY] = g_param_spec_string("key", "key", "key", NULL,
- G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
- g_object_class_install_properties(obj_class, PROP_LAST, properties);
-purple_aes_cipher_init(PurpleCipher *cipher) {
- purple_cipher_reset(cipher);
-/******************************************************************************
- *****************************************************************************/
-purple_aes_cipher_get_type(void) {
- static const GTypeInfo info = {
- sizeof(PurpleAESCipherClass),
- (GClassInitFunc)purple_aes_cipher_class_init,
- sizeof(PurpleAESCipher),
- (GInstanceInitFunc)purple_aes_cipher_init,
- type = g_type_register_static(PURPLE_TYPE_CIPHER,
-purple_aes_cipher_new(void) {
- return g_object_new(PURPLE_TYPE_AES_CIPHER, NULL);
--- a/libpurple/ciphers/aescipher.h Thu Jun 15 10:48:26 2017 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
- * 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
- * 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_AES_CIPHER_H
-#define PURPLE_AES_CIPHER_H
- * @section_id: libpurple-aescipher
- * @short_description: <filename>ciphers/aescipher.h</filename>
-#define PURPLE_TYPE_AES_CIPHER (purple_aes_cipher_get_type())
-#define PURPLE_AES_CIPHER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_AES_CIPHER, PurpleAESCipher))
-#define PURPLE_AES_CIPHER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_AES_CIPHER, PurpleAESCipherClass))
-#define PURPLE_IS_AES_CIPHER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_AES_CIPHER))
-#define PURPLE_IS_AES_CIPHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((obj), PURPLE_TYPE_AES_CIPHER))
-#define PURPLE_AES_CIPHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_AES_CIPHER, PurpleAESCipherClass))
-typedef struct _PurpleAESCipher PurpleAESCipher;
-typedef struct _PurpleAESCipherClass PurpleAESCipherClass;
-struct _PurpleAESCipher {
-struct _PurpleAESCipherClass {
- PurpleCipherClass gparent;
- void (*_purple_reserved1)(void);
- void (*_purple_reserved2)(void);
- void (*_purple_reserved3)(void);
- void (*_purple_reserved4)(void);
-GType purple_aes_cipher_get_type(void);
-PurpleCipher *purple_aes_cipher_new(void);
-#endif /* PURPLE_AES_CIPHER_H */
--- a/libpurple/ciphers/des3cipher.c Thu Jun 15 10:48:26 2017 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,524 +0,0 @@
- * Original des taken from gpg
- * des.c - 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.
- * 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
- * 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
-/******************************************************************************
- *****************************************************************************/
-#define PURPLE_DES3_CIPHER_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_DES3_CIPHER, PurpleDES3CipherPrivate))
-typedef struct _PurpleDES3CipherPrivate PurpleDES3CipherPrivate;
-struct _PurpleDES3CipherPrivate
- PurpleCipherBatchMode mode;
- /* First key for encryption */
- /* Second key for decryption */
- /* Third key for encryption */
-/******************************************************************************
- *****************************************************************************/
-/******************************************************************************
- *****************************************************************************/
-static GObjectClass *parent_class = NULL;
-static GParamSpec *properties[PROP_LAST];
-/******************************************************************************
- *****************************************************************************/
-purple_des3_cipher_get_key_size(PurpleCipher *cipher)
- * 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.
-purple_des3_cipher_set_key(PurpleCipher *cipher, const guchar *key, size_t len)
- PurpleDES3Cipher *des3_cipher = PURPLE_DES3_CIPHER(cipher);
- PurpleDES3CipherPrivate *priv = PURPLE_DES3_CIPHER_GET_PRIVATE(des3_cipher);
- g_return_if_fail(len == 24);
- purple_cipher_set_key(PURPLE_CIPHER(priv->key1), key + 0,
- purple_cipher_get_key_size(PURPLE_CIPHER(priv->key1)));
- purple_cipher_set_key(PURPLE_CIPHER(priv->key2), key + 8,
- purple_cipher_get_key_size(PURPLE_CIPHER(priv->key2)));
- purple_cipher_set_key(PURPLE_CIPHER(priv->key3), key + 16,
- purple_cipher_get_key_size(PURPLE_CIPHER(priv->key3)));
- g_object_notify_by_pspec(G_OBJECT(cipher), properties[PROP_KEY]);
-purple_des3_cipher_ecb_encrypt(PurpleDES3Cipher *des3_cipher, const guchar input[],
- size_t in_len, guchar output[], size_t out_size)
- guint8 buf[8] = {0,0,0,0,0,0,0,0};
- PurpleDES3CipherPrivate *priv = PURPLE_DES3_CIPHER_GET_PRIVATE(des3_cipher);
- g_return_val_if_fail(out_size >= in_len, -1);
- while (offset + 8 <= in_len) {
- purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key1),
- input + offset, output + offset, 0);
- purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key2),
- output + offset, buf, 1);
- purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key3),
- buf, output + offset, 0);
- g_return_val_if_fail(in_len >= offset, -1);
- out_len += in_len - offset;
- g_return_val_if_fail(out_size >= out_len, -1);
- purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key1),
- buf, output + offset, 0);
- purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key2),
- output + offset, buf, 1);
- purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key3),
- buf, output + offset, 0);
-purple_des3_cipher_cbc_encrypt(PurpleDES3Cipher *des3_cipher, const guchar input[],
- size_t in_len, guchar output[], size_t out_size)
- PurpleDES3CipherPrivate *priv = PURPLE_DES3_CIPHER_GET_PRIVATE(des3_cipher);
- memcpy(buf, priv->iv, 8);
- g_return_val_if_fail(out_size >= in_len, -1);
- while (offset + 8 <= in_len) {
- for (i = 0; i < 8; i++)
- buf[i] ^= input[offset + i];
- purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key1),
- buf, output + offset, 0);
- purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key2),
- output + offset, buf, 1);
- purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key3),
- buf, output + offset, 0);
- memcpy(buf, output+offset, 8);
- g_return_val_if_fail(in_len >= offset, -1);
- out_len += in_len - offset;
- g_return_val_if_fail(out_size >= out_len, -1);
- buf[i++] ^= input[tmp];
- purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key1),
- buf, output + offset, 0);
- purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key2),
- output + offset, buf, 1);
- purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key3),
- buf, output + offset, 0);
-purple_des3_cipher_encrypt(PurpleCipher *cipher, const guchar input[],
- size_t in_len, guchar output[], size_t out_size)
- PurpleDES3Cipher *des3_cipher = PURPLE_DES3_CIPHER(cipher);
- PurpleDES3CipherPrivate *priv = PURPLE_DES3_CIPHER_GET_PRIVATE(des3_cipher);
- if (priv->mode == PURPLE_CIPHER_BATCH_MODE_ECB) {
- return purple_des3_cipher_ecb_encrypt(des3_cipher, input, in_len, output, out_size);
- } else if (priv->mode == PURPLE_CIPHER_BATCH_MODE_CBC) {
- return purple_des3_cipher_cbc_encrypt(des3_cipher, input, in_len, output, out_size);
- g_return_val_if_reached(0);
-purple_des3_cipher_ecb_decrypt(PurpleDES3Cipher *des3_cipher, const guchar input[],
- size_t in_len, guchar output[], size_t out_size)
- guint8 buf[8] = {0,0,0,0,0,0,0,0};
- PurpleDES3CipherPrivate *priv = PURPLE_DES3_CIPHER_GET_PRIVATE(des3_cipher);
- g_return_val_if_fail(out_size >= in_len, -1);
- while (offset + 8 <= in_len) {
- /* NOTE: Apply key in reverse */
- purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key3),
- input + offset, output + offset, 1);
- purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key2),
- output + offset, buf, 0);
- purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key1),
- buf, output + offset, 1);
- g_return_val_if_fail(in_len >= offset, -1);
- out_len += in_len - offset;
- g_return_val_if_fail(out_size >= out_len, -1);
- purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key3),
- buf, output + offset, 1);
- purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key2),
- output + offset, buf, 0);
- purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key1),
- buf, output + offset, 1);
-purple_des3_cipher_cbc_decrypt(PurpleDES3Cipher *des3_cipher, const guchar input[],
- size_t in_len, guchar output[], size_t out_size)
- guint8 buf[8] = {0,0,0,0,0,0,0,0};
- PurpleDES3CipherPrivate *priv = PURPLE_DES3_CIPHER_GET_PRIVATE(des3_cipher);
- g_return_val_if_fail(out_size >= in_len, -1);
- memcpy(link, priv->iv, 8);
- while (offset + 8 <= in_len) {
- purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key3),
- input + offset, output + offset, 1);
- purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key2),
- output + offset, buf, 0);
- purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key1),
- buf, output + offset, 1);
- for (i = 0; i < 8; i++)
- output[offset + i] ^= link[i];
- memcpy(link, input + offset, 8);
- g_return_val_if_fail(in_len >= offset, -1);
- out_len += in_len - offset;
- g_return_val_if_fail(out_size >= out_len, -1);
- purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key3),
- buf, output + offset, 1);
- purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key2),
- output + offset, buf, 0);
- purple_des_cipher_ecb_crypt(PURPLE_DES_CIPHER(priv->key1),
- buf, output + offset, 1);
- for (i = 0; i < 8; i++)
- output[offset + i] ^= link[i];
-purple_des3_cipher_decrypt(PurpleCipher *cipher, const guchar input[],
- size_t in_len, guchar output[], size_t out_size)
- PurpleDES3Cipher *des3_cipher = PURPLE_DES3_CIPHER(cipher);
- PurpleDES3CipherPrivate *priv = PURPLE_DES3_CIPHER_GET_PRIVATE(cipher);
- if (priv->mode == PURPLE_CIPHER_BATCH_MODE_ECB) {
- return purple_des3_cipher_ecb_decrypt(des3_cipher, input, in_len, output, out_size);
- } else if (priv->mode == PURPLE_CIPHER_BATCH_MODE_CBC) {
- return purple_des3_cipher_cbc_decrypt(des3_cipher, input, in_len, output, out_size);
- g_return_val_if_reached(0);
-purple_des3_cipher_set_batch_mode(PurpleCipher *cipher, PurpleCipherBatchMode mode)
- PurpleDES3Cipher *des3_cipher = PURPLE_DES3_CIPHER(cipher);
- PurpleDES3CipherPrivate *priv = PURPLE_DES3_CIPHER_GET_PRIVATE(des3_cipher);
- g_object_notify_by_pspec(G_OBJECT(cipher), properties[PROP_BATCH_MODE]);
-static PurpleCipherBatchMode
-purple_des3_cipher_get_batch_mode(PurpleCipher *cipher)
- PurpleDES3Cipher *des3_cipher = PURPLE_DES3_CIPHER(cipher);
- PurpleDES3CipherPrivate *priv = PURPLE_DES3_CIPHER_GET_PRIVATE(des3_cipher);
-purple_des3_cipher_set_iv(PurpleCipher *cipher, guchar *iv, size_t len)
- PurpleDES3Cipher *des3_cipher = PURPLE_DES3_CIPHER(cipher);
- PurpleDES3CipherPrivate *priv = PURPLE_DES3_CIPHER_GET_PRIVATE(des3_cipher);
- g_return_if_fail(len == 8);
- memcpy(priv->iv, iv, len);
- g_object_notify_by_pspec(G_OBJECT(cipher), properties[PROP_IV]);
-/******************************************************************************
- *****************************************************************************/
-purple_des3_cipher_get_property(GObject *obj, guint param_id, GValue *value,
- PurpleCipher *cipher = PURPLE_CIPHER(obj);
- g_value_set_enum(value,
- purple_cipher_get_batch_mode(cipher));
- G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
-purple_des3_cipher_set_property(GObject *obj, guint param_id,
- const GValue *value, GParamSpec *pspec)
- PurpleCipher *cipher = PURPLE_CIPHER(obj);
- purple_cipher_set_batch_mode(cipher,
- g_value_get_enum(value));
- guchar *iv = (guchar *)g_value_get_string(value);
- purple_cipher_set_iv(cipher, iv, strlen((gchar*)iv));
- purple_cipher_set_key(cipher, (guchar *)g_value_get_string(value),
- purple_des3_cipher_get_key_size(cipher));
- G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
-purple_des3_cipher_finalize(GObject *obj)
- PurpleDES3Cipher *des3_cipher = PURPLE_DES3_CIPHER(obj);
- PurpleDES3CipherPrivate *priv = PURPLE_DES3_CIPHER_GET_PRIVATE(des3_cipher);
- g_object_unref(G_OBJECT(priv->key1));
- g_object_unref(G_OBJECT(priv->key2));
- g_object_unref(G_OBJECT(priv->key3));
- memset(priv->iv, 0, sizeof(priv->iv));
- parent_class->finalize(obj);
-purple_des3_cipher_class_init(PurpleDES3CipherClass *klass) {
- GObjectClass *obj_class = G_OBJECT_CLASS(klass);
- PurpleCipherClass *cipher_class = PURPLE_CIPHER_CLASS(klass);
- parent_class = g_type_class_peek_parent(klass);
- obj_class->finalize = purple_des3_cipher_finalize;
- obj_class->get_property = purple_des3_cipher_get_property;
- obj_class->set_property = purple_des3_cipher_set_property;
- cipher_class->set_iv = purple_des3_cipher_set_iv;
- cipher_class->encrypt = purple_des3_cipher_encrypt;
- cipher_class->decrypt = purple_des3_cipher_decrypt;
- cipher_class->set_key = purple_des3_cipher_set_key;
- cipher_class->set_batch_mode = purple_des3_cipher_set_batch_mode;
- cipher_class->get_batch_mode = purple_des3_cipher_get_batch_mode;
- cipher_class->get_key_size = purple_des3_cipher_get_key_size;
- g_type_class_add_private(klass, sizeof(PurpleDES3CipherPrivate));
- properties[PROP_BATCH_MODE] = g_param_spec_enum("batch-mode", "batch-mode",
- "batch-mode", PURPLE_TYPE_CIPHER_BATCH_MODE, 0,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
- properties[PROP_IV] = g_param_spec_string("iv", "iv", "iv", NULL,
- G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
- properties[PROP_KEY] = g_param_spec_string("key", "key", "key", NULL,
- G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
- g_object_class_install_properties(obj_class, PROP_LAST, properties);
-purple_des3_cipher_init(PurpleCipher *cipher) {
- PurpleDES3Cipher *des3_cipher = PURPLE_DES3_CIPHER(cipher);
- PurpleDES3CipherPrivate *priv = PURPLE_DES3_CIPHER_GET_PRIVATE(des3_cipher);
- priv->key1 = purple_des_cipher_new();
- priv->key2 = purple_des_cipher_new();
- priv->key3 = purple_des_cipher_new();
-/******************************************************************************
- *****************************************************************************/
-purple_des3_cipher_get_type(void) {
- static const GTypeInfo info = {
- sizeof(PurpleDES3CipherClass),
- (GClassInitFunc)purple_des3_cipher_class_init,
- sizeof(PurpleDES3Cipher),
- (GInstanceInitFunc)purple_des3_cipher_init,
- type = g_type_register_static(PURPLE_TYPE_CIPHER,
-purple_des3_cipher_new(void) {
- return g_object_new(PURPLE_TYPE_DES3_CIPHER, NULL);
--- a/libpurple/ciphers/des3cipher.h Thu Jun 15 10:48:26 2017 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
- * 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
- * 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_DES3_CIPHER_H
-#define PURPLE_DES3_CIPHER_H
- * @section_id: libpurple-des3cipher
- * @short_description: <filename>ciphers/des3cipher.h</filename>
- * @title: Triple-DES Cipher
-#define PURPLE_TYPE_DES3_CIPHER (purple_des3_cipher_get_type())
-#define PURPLE_DES3_CIPHER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_DES3_CIPHER, PurpleDES3Cipher))
-#define PURPLE_DES3_CIPHER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_DES3_CIPHER, PurpleDES3CipherClass))
-#define PURPLE_IS_DES3_CIPHER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_DES3_CIPHER))
-#define PURPLE_IS_DES3_CIPHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((obj), PURPLE_TYPE_DES3_CIPHER))
-#define PURPLE_DES3_CIPHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_DES3_CIPHER, PurpleDES3CipherClass))
-typedef struct _PurpleDES3Cipher PurpleDES3Cipher;
-typedef struct _PurpleDES3CipherClass PurpleDES3CipherClass;
-struct _PurpleDES3Cipher {
-struct _PurpleDES3CipherClass {
- PurpleCipherClass gparent;
- void (*_purple_reserved1)(void);
- void (*_purple_reserved2)(void);
- void (*_purple_reserved3)(void);
- void (*_purple_reserved4)(void);
-GType purple_des3_cipher_get_type(void);
-PurpleCipher *purple_des3_cipher_new(void);
-#endif /* PURPLE_DES3_CIPHER_H */
--- a/libpurple/ciphers/descipher.c Thu Jun 15 10:48:26 2017 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,581 +0,0 @@
- * Original des taken from gpg
- * des.c - 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.
- * 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
- * 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
-/******************************************************************************
- *****************************************************************************/
-#define PURPLE_DES_CIPHER_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_DES_CIPHER, PurpleDESCipherPrivate))
- guint32 encrypt_subkeys[32];
- guint32 decrypt_subkeys[32];
-} PurpleDESCipherPrivate;
-/******************************************************************************
- *****************************************************************************/
-/******************************************************************************
- *****************************************************************************/
-static GObjectClass *parent_class = NULL;
-static GParamSpec *properties[PROP_LAST];
- * The s-box values are permuted according to the 'primitive function P'
-static 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 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 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 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 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 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 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 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 guint32 leftkey_swap[16] = {
- 0x00000000, 0x00000001, 0x00000100, 0x00000101, 0x00010000, 0x00010001,
- 0x00010100, 0x00010101, 0x01000000, 0x01000001, 0x01000100, 0x01000101,
- 0x01010000, 0x01010001, 0x01010100, 0x01010101
-static 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
-static 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; \
- * This performs the 'initial permutation' for the data to be encrypted or
-#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.
-purple_des_cipher_key_schedule(const guint8 * rawkey, guint32 * subkey) {
- guint32 left, right, work;
- 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);
- 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);
- 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 >> 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.
-purple_des_cipher_set_key(PurpleCipher *cipher, const guchar *key, size_t len) {
- PurpleDESCipher *des_cipher = PURPLE_DES_CIPHER(cipher);
- PurpleDESCipherPrivate *priv = PURPLE_DES_CIPHER_GET_PRIVATE(des_cipher);
- g_return_if_fail(len == 8);
- purple_des_cipher_key_schedule(key, priv->encrypt_subkeys);
- for(i = 0; i < 32; i += 2) {
- priv->decrypt_subkeys[i] = priv->encrypt_subkeys[30 - i];
- priv->decrypt_subkeys[i + 1] = priv->encrypt_subkeys[31 - i];
- g_object_notify_by_pspec(G_OBJECT(cipher), properties[PROP_KEY]);
-purple_des_cipher_get_key_size(PurpleCipher *cipher)
- * Electronic Codebook Mode DES encryption/decryption of data according to
-purple_des_cipher_ecb_crypt(PurpleDESCipher *des_cipher, const guint8 * from, guint8 * to,
- guint32 left, right, work;
- PurpleDESCipherPrivate *priv = PURPLE_DES_CIPHER_GET_PRIVATE(des_cipher);
- keys = mode ? priv->decrypt_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)
-purple_des_cipher_encrypt(PurpleCipher *cipher, const guchar input[],
- size_t in_len, guchar output[], size_t out_size)
- PurpleDESCipher *des_cipher = PURPLE_DES_CIPHER(cipher);
- guint8 buf[8] = {0,0,0,0,0,0,0,0};
- g_return_val_if_fail(out_size >= in_len, -1);
- while(offset + 8 <= in_len) {
- purple_des_cipher_ecb_crypt(des_cipher, input + offset, output + offset, 0);
- g_return_val_if_fail(in_len >= offset, -1);
- out_len += in_len - offset;
- g_return_val_if_fail(out_size >= out_len, -1);
- purple_des_cipher_ecb_crypt(des_cipher, buf, output + offset, 0);
-purple_des_cipher_decrypt(PurpleCipher *cipher, const guchar input[],
- size_t in_len, guchar output[], size_t out_size)
- PurpleDESCipher *des_cipher = PURPLE_DES_CIPHER(cipher);
- guint8 buf[8] = {0,0,0,0,0,0,0,0};
- g_return_val_if_fail(out_size >= in_len, -1);
- while(offset + 8 <= in_len) {
- purple_des_cipher_ecb_crypt(des_cipher, input + offset, output + offset, 1);
- g_return_val_if_fail(in_len >= offset, -1);
- out_len += in_len - offset;
- g_return_val_if_fail(out_size >= out_len, -1);
- purple_des_cipher_ecb_crypt(des_cipher, buf, output + offset, 1);
-/******************************************************************************
- *****************************************************************************/
-purple_des_cipher_set_property(GObject *obj, guint param_id,
- const GValue *value, GParamSpec *pspec)
- PurpleCipher *cipher = PURPLE_CIPHER(obj);
- purple_cipher_set_key(cipher, (guchar *)g_value_get_string(value),
- purple_des_cipher_get_key_size(cipher));
- G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
-purple_des_cipher_class_init(PurpleDESCipherClass *klass)
- GObjectClass *obj_class = G_OBJECT_CLASS(klass);
- PurpleCipherClass *cipher_class = PURPLE_CIPHER_CLASS(klass);
- parent_class = g_type_class_peek_parent(klass);
- obj_class->set_property = purple_des_cipher_set_property;
- cipher_class->encrypt = purple_des_cipher_encrypt;
- cipher_class->decrypt = purple_des_cipher_decrypt;
- cipher_class->set_key = purple_des_cipher_set_key;
- cipher_class->get_key_size = purple_des_cipher_get_key_size;
- g_type_class_add_private(klass, sizeof(PurpleDESCipherPrivate));
- properties[PROP_KEY] = g_param_spec_string("key", "key", "key", NULL,
- G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
- g_object_class_install_properties(obj_class, PROP_LAST, properties);
-/******************************************************************************
- *****************************************************************************/
-purple_des_cipher_get_type(void) {
- static const GTypeInfo info = {
- .class_size = sizeof(PurpleDESCipherClass),
- .class_init = (GClassInitFunc)purple_des_cipher_class_init,
- .instance_size = sizeof(PurpleDESCipher),
- .instance_init = (GInstanceInitFunc)purple_cipher_reset,
- type = g_type_register_static(PURPLE_TYPE_CIPHER,
- * purple_des_cipher_new:
- * Creates a new #PurpleCipher instance which implements the DES block cipher.
- * Return Value: The new DES implementation of #PurpleCipher.
-purple_des_cipher_new(void) {
- return g_object_new(PURPLE_TYPE_DES_CIPHER, NULL);
--- a/libpurple/ciphers/descipher.h Thu Jun 15 10:48:26 2017 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
- * 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
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#ifndef PURPLE_DES_CIPHER_H
-#define PURPLE_DES_CIPHER_H
- * @section_id: libpurple-descipher
- * @short_description: <filename>ciphers/descipher.h</filename>
-#define PURPLE_TYPE_DES_CIPHER (purple_des_cipher_get_type())
-#define PURPLE_DES_CIPHER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_DES_CIPHER, PurpleDESCipher))
-#define PURPLE_DES_CIPHER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_DES_CIPHER, PurpleDESCipherClass))
-#define PURPLE_IS_DES_CIPHER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_DES_CIPHER))
-#define PURPLE_IS_DES_CIPHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((obj), PURPLE_TYPE_DES_CIPHER))
-#define PURPLE_DES_CIPHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_DES_CIPHER, PurpleDESCipherClass))
-typedef struct _PurpleDESCipher PurpleDESCipher;
-typedef struct _PurpleDESCipherClass PurpleDESCipherClass;
-struct _PurpleDESCipher {
-struct _PurpleDESCipherClass {
- PurpleCipherClass gparent;
- void (*_purple_reserved1)(void);
- void (*_purple_reserved2)(void);
- void (*_purple_reserved3)(void);
- void (*_purple_reserved4)(void);
-GType purple_des_cipher_get_type(void);
-PurpleCipher *purple_des_cipher_new(void);
-int purple_des_cipher_ecb_crypt(PurpleDESCipher *des_cipher, const guint8 * from, guint8 * to, int mode);
-#endif /* PURPLE_DES_CIPHER_H */
--- a/libpurple/ciphers/md4hash.c Thu Jun 15 10:48:26 2017 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,311 +0,0 @@
- * 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>
-#define MD4_DIGEST_SIZE 16
-#define MD4_BLOCK_WORDS 16
-#define MD4_HASH_WORDS 4
-#define PURPLE_MD4_HASH_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_MD4_HASH, PurpleMD4HashPrivate))
-/******************************************************************************
- *****************************************************************************/
- guint32 hash[MD4_HASH_WORDS];
- guint32 block[MD4_BLOCK_WORDS];
-/******************************************************************************
- *****************************************************************************/
-static GObjectClass *parent_class = NULL;
-/******************************************************************************
- *****************************************************************************/
-#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))
-lshift(guint32 x, unsigned int s) {
- return (((x << s) & 0xffffffff) | (x >> (32 - s)));
-F(guint32 x, guint32 y, guint32 z) {
- return ((x & y) | ((~x) & z));
-G(guint32 x, guint32 y, guint32 z) {
- return ((x & y) | (x & z) | (y & z));
-H(guint32 x, guint32 y, guint32 z) {
-le32_to_cpu_array(guint32 *buf, unsigned int words) {
- *buf = GUINT_FROM_LE(*buf);
-cpu_to_le32_array(guint32 *buf, unsigned int words) {
- *buf = GUINT_TO_LE(*buf);
-md4_transform(guint32 *hash, guint32 const *in) {
- 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);
-md4_transform_helper(PurpleHash *hash) {
- PurpleMD4HashPrivate *priv = PURPLE_MD4_HASH_GET_PRIVATE(hash);
- le32_to_cpu_array(priv->block, sizeof(priv->block) / sizeof(guint32));
- md4_transform(priv->hash, priv->block);
-/******************************************************************************
- *****************************************************************************/
-purple_md4_hash_reset(PurpleHash *hash) {
- PurpleMD4HashPrivate *priv = PURPLE_MD4_HASH_GET_PRIVATE(hash);
- priv->hash[0] = 0x67452301;
- priv->hash[1] = 0xefcdab89;
- priv->hash[2] = 0x98badcfe;
- priv->hash[3] = 0x10325476;
- memset(priv->block, 0, sizeof(priv->block));
-purple_md4_hash_append(PurpleHash *hash, const guchar *data, size_t len) {
- PurpleMD4HashPrivate *priv = PURPLE_MD4_HASH_GET_PRIVATE(hash);
- const guint32 avail = sizeof(priv->block) - (priv->byte_count & 0x3f);
- priv->byte_count += len;
- memcpy((char *)priv->block +
- (sizeof(priv->block) - avail),
- memcpy((char *)priv->block +
- (sizeof(priv->block) - avail),
- md4_transform_helper(hash);
- while(len >= sizeof(priv->block)) {
- memcpy(priv->block, data, sizeof(priv->block));
- md4_transform_helper(hash);
- data += sizeof(priv->block);
- len -= sizeof(priv->block);
- memcpy(priv->block, data, len);
-purple_md4_hash_digest(PurpleHash *hash, guchar *out, size_t len)
- PurpleMD4HashPrivate *priv = PURPLE_MD4_HASH_GET_PRIVATE(hash);
- const unsigned int offset = priv->byte_count & 0x3f;
- gchar *p = (gchar *)priv->block + offset;
- gint padding = 56 - (offset + 1);
- memset(p, 0x00, padding + sizeof(guint64));
- md4_transform_helper(hash);
- p = (gchar *)priv->block;
- priv->block[14] = priv->byte_count << 3;
- priv->block[15] = priv->byte_count >> 29;
- le32_to_cpu_array(priv->block,
- (sizeof(priv->block) - sizeof(guint64)) /
- md4_transform(priv->hash, priv->block);
- cpu_to_le32_array(priv->hash, sizeof(priv->hash) / sizeof(guint32));
- memcpy(out, priv->hash, sizeof(priv->hash));
-purple_md4_hash_get_digest_size(PurpleHash *hash)
-purple_md4_hash_get_block_size(PurpleHash *hash)
- /* This does not change (in this case) */
-/******************************************************************************
- *****************************************************************************/
-purple_md4_hash_class_init(PurpleMD4HashClass *klass) {
- PurpleHashClass *hash_class = PURPLE_HASH_CLASS(klass);
- parent_class = g_type_class_peek_parent(klass);
- g_type_class_add_private(klass, sizeof(PurpleMD4HashPrivate));
- hash_class->reset = purple_md4_hash_reset;
- hash_class->reset_state = purple_md4_hash_reset;
- hash_class->append = purple_md4_hash_append;
- hash_class->digest = purple_md4_hash_digest;
- hash_class->get_digest_size = purple_md4_hash_get_digest_size;
- hash_class->get_block_size = purple_md4_hash_get_block_size;
-/******************************************************************************
- *****************************************************************************/
-purple_md4_hash_get_type(void) {
- static const GTypeInfo info = {
- sizeof(PurpleMD4HashClass),
- (GClassInitFunc)purple_md4_hash_class_init,
- (GInstanceInitFunc)purple_hash_reset,
- type = g_type_register_static(PURPLE_TYPE_HASH,
-purple_md4_hash_new(void) {
- return g_object_new(PURPLE_TYPE_MD4_HASH, NULL);
--- a/libpurple/ciphers/md4hash.h Thu Jun 15 10:48:26 2017 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
- * 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
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#ifndef PURPLE_MD4_HASH_H
-#define PURPLE_MD4_HASH_H
- * @section_id: libpurple-md4hash
- * @short_description: <filename>ciphers/md4hash.h</filename>
-#define PURPLE_TYPE_MD4_HASH (purple_md4_hash_get_type())
-#define PURPLE_MD4_HASH(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_MD4_HASH, PurpleMD4Hash))
-#define PURPLE_MD4_HASH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_MD4_HASH, PurpleMD4HashClass))
-#define PURPLE_IS_MD4_HASH(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_MD4_HASH))
-#define PURPLE_IS_MD4_HASH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((obj), PURPLE_TYPE_MD4_HASH))
-#define PURPLE_MD4_HASH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_MD4_HASH, PurpleMD4HashClass))
-typedef struct _PurpleMD4Hash PurpleMD4Hash;
-typedef struct _PurpleMD4HashClass PurpleMD4HashClass;
-struct _PurpleMD4HashClass {
- PurpleHashClass parent;
- void (*_purple_reserved1)(void);
- void (*_purple_reserved2)(void);
- void (*_purple_reserved3)(void);
- void (*_purple_reserved4)(void);
-GType purple_md4_hash_get_type(void);
-PurpleHash *purple_md4_hash_new(void);
-#endif /* PURPLE_MD4_HASH_H */
--- a/libpurple/ciphers/pbkdf2cipher.c Thu Jun 15 10:48:26 2017 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,392 +0,0 @@
- * 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
- * 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
- * Written by Tomek Wasilczyk <twasilczyk@pidgin.im>
-#include "pbkdf2cipher.h"
-#define PBKDF2_HASH_MAX_LEN 128
-/******************************************************************************
- *****************************************************************************/
-#define PURPLE_PBKDF2_CIPHER_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_PBKDF2_CIPHER, PurplePBKDF2CipherPrivate))
- GChecksumType hash_type;
-} PurplePBKDF2CipherPrivate;
-/******************************************************************************
- *****************************************************************************/
-/*******************************************************************************
- ******************************************************************************/
-static GObjectClass *parent_class = NULL;
-static GParamSpec *properties[PROP_LAST];
-/******************************************************************************
- *****************************************************************************/
-purple_pbkdf2_cipher_reset(PurpleCipher *cipher)
- PurplePBKDF2CipherPrivate *priv = PURPLE_PBKDF2_CIPHER_GET_PRIVATE(cipher);
- g_return_if_fail(priv != NULL);
- purple_cipher_reset_state(cipher);
-purple_pbkdf2_cipher_reset_state(PurpleCipher *cipher)
- PurplePBKDF2CipherPrivate *priv = PURPLE_PBKDF2_CIPHER_GET_PRIVATE(cipher);
- g_return_if_fail(priv != NULL);
- purple_cipher_set_salt(cipher, NULL, 0);
- purple_cipher_set_key(cipher, NULL, 0);
-purple_pbkdf2_cipher_get_digest_size(PurpleCipher *cipher)
- PurplePBKDF2CipherPrivate *priv = PURPLE_PBKDF2_CIPHER_GET_PRIVATE(cipher);
- g_return_val_if_fail(priv != NULL, 0);
-purple_pbkdf2_cipher_set_salt(PurpleCipher *cipher, const guchar *salt, size_t len)
- PurplePBKDF2CipherPrivate *priv = PURPLE_PBKDF2_CIPHER_GET_PRIVATE(cipher);
- g_return_if_fail(priv != NULL);
- g_return_if_fail(salt != NULL);
- priv->salt = g_memdup(salt, len);
-purple_pbkdf2_cipher_set_key(PurpleCipher *cipher, const guchar *key,
- PurplePBKDF2CipherPrivate *priv = PURPLE_PBKDF2_CIPHER_GET_PRIVATE(cipher);
- g_return_if_fail(priv != NULL);
- if (priv->passphrase != NULL) {
- memset(priv->passphrase, 0, priv->passphrase_len);
- g_free(priv->passphrase);
- priv->passphrase = NULL;
- priv->passphrase_len = 0;
- g_return_if_fail(key != NULL);
- priv->passphrase = g_memdup(key, len);
- priv->passphrase_len = len;
-/* inspired by gnutls 3.1.10, pbkdf2-sha1.c */
-purple_pbkdf2_cipher_digest(PurpleCipher *cipher, guchar digest[], size_t len)
- PurplePBKDF2CipherPrivate *priv = PURPLE_PBKDF2_CIPHER_GET_PRIVATE(cipher);
- guchar halfkey[PBKDF2_HASH_MAX_LEN], halfkey_hash[PBKDF2_HASH_MAX_LEN];
- guint halfkey_count, halfkey_pad, halfkey_no;
- g_return_val_if_fail(priv != NULL, FALSE);
- g_return_val_if_fail(digest != NULL, FALSE);
- g_return_val_if_fail(len >= priv->out_len, FALSE);
- g_return_val_if_fail(priv->iter_count > 0, FALSE);
- g_return_val_if_fail(priv->passphrase != NULL ||
- priv->passphrase_len == 0, FALSE);
- g_return_val_if_fail(priv->salt != NULL || priv->salt_len == 0,
- g_return_val_if_fail(priv->out_len > 0, FALSE);
- g_return_val_if_fail(priv->out_len < 0xFFFFFFFFU, FALSE);
- salt_ext_len = priv->salt_len + 4;
- halfkey_len = g_checksum_type_get_length(priv->hash_type);
- if (halfkey_len <= 0 || halfkey_len > PBKDF2_HASH_MAX_LEN) {
- purple_debug_error("pbkdf2", "Unsupported hash function. "
- "(digest size: %" G_GSIZE_FORMAT ")\n", halfkey_len);
- halfkey_count = ((priv->out_len - 1) / halfkey_len) + 1;
- halfkey_pad = priv->out_len - (halfkey_count - 1) * halfkey_len;
- salt_ext = g_new(guchar, salt_ext_len);
- if (priv->salt_len > 0)
- memcpy(salt_ext, priv->salt, priv->salt_len);
- for (halfkey_no = 1; halfkey_no <= halfkey_count; halfkey_no++) {
- memset(halfkey, 0, halfkey_len);
- for (iter_no = 1; iter_no <= priv->iter_count; iter_no++) {
- hmac = g_hmac_new(priv->hash_type,
- (const guchar*)priv->passphrase,
- purple_debug_error("pbkdf2",
- "Couldn't create new hmac cipher\n");
- salt_ext[salt_ext_len - 4] =
- (halfkey_no & 0xff000000) >> 24;
- salt_ext[salt_ext_len - 3] =
- (halfkey_no & 0x00ff0000) >> 16;
- salt_ext[salt_ext_len - 2] =
- (halfkey_no & 0x0000ff00) >> 8;
- salt_ext[salt_ext_len - 1] =
- (halfkey_no & 0x000000ff) >> 0;
- g_hmac_update(hmac, salt_ext, salt_ext_len);
- g_hmac_update(hmac, halfkey_hash, halfkey_len);
- g_hmac_get_digest(hmac, halfkey_hash, &halfkey_len);
- for (i = 0; i < halfkey_len; i++)
- halfkey[i] ^= halfkey_hash[i];
- memcpy(digest + (halfkey_no - 1) * halfkey_len, halfkey,
- (halfkey_no == halfkey_count) ? halfkey_pad :
-/******************************************************************************
- *****************************************************************************/
-purple_pbkdf2_cipher_get_property(GObject *obj, guint param_id, GValue *value,
- PurplePBKDF2Cipher *cipher = PURPLE_PBKDF2_CIPHER(obj);
- PurplePBKDF2CipherPrivate *priv = PURPLE_PBKDF2_CIPHER_GET_PRIVATE(cipher);
- g_value_set_int(value, priv->hash_type);
- g_value_set_uint(value, priv->iter_count);
- g_value_set_uint(value, priv->out_len);
- G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
-purple_pbkdf2_cipher_set_property(GObject *obj, guint param_id,
- const GValue *value, GParamSpec *pspec)
- PurpleCipher *cipher = PURPLE_CIPHER(obj);
- PurplePBKDF2CipherPrivate *priv = PURPLE_PBKDF2_CIPHER_GET_PRIVATE(cipher);
- priv->hash_type = g_value_get_int(value);
- priv->iter_count = g_value_get_uint(value);
- priv->out_len = g_value_get_uint(value);
- G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
-purple_pbkdf2_cipher_finalize(GObject *obj)
- PurpleCipher *cipher = PURPLE_CIPHER(obj);
- purple_pbkdf2_cipher_reset(cipher);
- parent_class->finalize(obj);
-purple_pbkdf2_cipher_class_init(PurplePBKDF2CipherClass *klass) {
- GObjectClass *obj_class = G_OBJECT_CLASS(klass);
- PurpleCipherClass *cipher_class = PURPLE_CIPHER_CLASS(klass);
- parent_class = g_type_class_peek_parent(klass);
- obj_class->finalize = purple_pbkdf2_cipher_finalize;
- obj_class->get_property = purple_pbkdf2_cipher_get_property;
- obj_class->set_property = purple_pbkdf2_cipher_set_property;
- cipher_class->reset = purple_pbkdf2_cipher_reset;
- cipher_class->reset_state = purple_pbkdf2_cipher_reset_state;
- cipher_class->digest = purple_pbkdf2_cipher_digest;
- cipher_class->get_digest_size = purple_pbkdf2_cipher_get_digest_size;
- cipher_class->set_salt = purple_pbkdf2_cipher_set_salt;
- cipher_class->set_key = purple_pbkdf2_cipher_set_key;
- g_type_class_add_private(klass, sizeof(PurplePBKDF2CipherPrivate));
- properties[PROP_HASH_TYPE] = g_param_spec_int("hash-type", "hash-type", "hash-type",
- G_MININT, G_MAXINT, -1,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS);
- properties[PROP_ITER_COUNT] = g_param_spec_uint("iter-count", "iter-count",
- G_MAXUINT, 0, G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS);
- properties[PROP_OUT_LEN] = g_param_spec_uint("out-len", "out-len",
- G_MAXUINT, 0, G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS);
- g_object_class_install_properties(obj_class, PROP_LAST, properties);
-purple_pbkdf2_cipher_init(PurpleCipher *cipher)
- PurplePBKDF2CipherPrivate *priv =
- PURPLE_PBKDF2_CIPHER_GET_PRIVATE(cipher);
- purple_cipher_reset(cipher);
-/******************************************************************************
- *****************************************************************************/
-purple_pbkdf2_cipher_get_type(void) {
- static const GTypeInfo info = {
- sizeof(PurplePBKDF2CipherClass),
- (GClassInitFunc)purple_pbkdf2_cipher_class_init,
- sizeof(PurplePBKDF2Cipher),
- (GInstanceInitFunc)purple_pbkdf2_cipher_init,
- type = g_type_register_static(PURPLE_TYPE_CIPHER,
-purple_pbkdf2_cipher_new(GChecksumType hash_type) {
- return g_object_new(PURPLE_TYPE_PBKDF2_CIPHER,
- "hash-type", hash_type,
-purple_pbkdf2_cipher_get_hash_type(const PurplePBKDF2Cipher *cipher) {
- PurplePBKDF2CipherPrivate *priv = NULL;
- g_return_val_if_fail(PURPLE_IS_PBKDF2_CIPHER(cipher), -1);
- priv = PURPLE_PBKDF2_CIPHER_GET_PRIVATE(cipher);
- return priv->hash_type;
--- a/libpurple/ciphers/pbkdf2cipher.h Thu Jun 15 10:48:26 2017 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
- * 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
- * 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_PBKDF2_CIPHER_H
-#define PURPLE_PBKDF2_CIPHER_H
- * @section_id: libpurple-pbkdf2cipher
- * @short_description: <filename>ciphers/pbkdf2cipher.h</filename>
- * @title: PBKDF2 Cipher
-#define PURPLE_TYPE_PBKDF2_CIPHER (purple_pbkdf2_cipher_get_type())
-#define PURPLE_PBKDF2_CIPHER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_PBKDF2_CIPHER, PurplePBKDF2Cipher))
-#define PURPLE_PBKDF2_CIPHER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_PBKDF2_CIPHER, PurplePBKDF2CipherClass))
-#define PURPLE_IS_PBKDF2_CIPHER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_PBKDF2_CIPHER))
-#define PURPLE_IS_PBKDF2_CIPHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((obj), PURPLE_TYPE_PBKDF2_CIPHER))
-#define PURPLE_PBKDF2_CIPHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_PBKDF2_CIPHER, PurplePBKDF2CipherClass))
-typedef struct _PurplePBKDF2Cipher PurplePBKDF2Cipher;
-typedef struct _PurplePBKDF2CipherClass PurplePBKDF2CipherClass;
-struct _PurplePBKDF2Cipher {
-struct _PurplePBKDF2CipherClass {
- PurpleCipherClass gparent;
- void (*_purple_reserved1)(void);
- void (*_purple_reserved2)(void);
- void (*_purple_reserved3)(void);
- void (*_purple_reserved4)(void);
-GType purple_pbkdf2_cipher_get_type(void);
-PurpleCipher *purple_pbkdf2_cipher_new(GChecksumType hash_type);
-GChecksumType purple_pbkdf2_cipher_get_hash_type(const PurplePBKDF2Cipher *cipher);
-#endif /* PURPLE_PBKDF2_CIPHER_H */
--- a/libpurple/ciphers/rc4cipher.c Thu Jun 15 10:48:26 2017 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,262 +0,0 @@
- * 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
- * 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
-/*******************************************************************************
- ******************************************************************************/
-#define PURPLE_RC4_CIPHER_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_RC4_CIPHER, PurpleRC4CipherPrivate))
-} PurpleRC4CipherPrivate;
-/******************************************************************************
- *****************************************************************************/
-/******************************************************************************
- *****************************************************************************/
-static GObjectClass *parent_class = NULL;
-static GParamSpec *properties[PROP_LAST];
-/******************************************************************************
- *****************************************************************************/
-purple_rc4_cipher_reset(PurpleCipher *cipher) {
- PurpleRC4Cipher *rc4_cipher = PURPLE_RC4_CIPHER(cipher);
- PurpleRC4CipherPrivate *priv = PURPLE_RC4_CIPHER_GET_PRIVATE(rc4_cipher);
- for(i = 0; i < 256; i++)
- /* default is 5 bytes (40bit key) */
-purple_rc4_cipher_set_key(PurpleCipher *cipher, const guchar *key, size_t len) {
- PurpleRC4Cipher *rc4_cipher = PURPLE_RC4_CIPHER(cipher);
- PurpleRC4CipherPrivate *priv = PURPLE_RC4_CIPHER_GET_PRIVATE(rc4_cipher);
- state = &priv->state[0];
- for(i = 0; i < 256; i++)
- y = (key[x] + state[i] + y) % 256;
- g_object_notify_by_pspec(G_OBJECT(cipher), properties[PROP_KEY]);
-purple_rc4_cipher_encrypt(PurpleCipher *cipher, const guchar input[], size_t in_len,
- guchar output[], size_t out_size)
- PurpleRC4Cipher *rc4_cipher = PURPLE_RC4_CIPHER(cipher);
- PurpleRC4CipherPrivate *priv = PURPLE_RC4_CIPHER_GET_PRIVATE(rc4_cipher);
- state = &priv->state[0];
- for(i = 0; i < in_len; i++)
- y = (state[x] + y) % 256;
- z = state[x] + (state[y]) % 256;
- output[i] = input[i] ^ state[z];
-/******************************************************************************
- *****************************************************************************/
-purple_rc4_cipher_set_property(GObject *obj, guint param_id,
- const GValue *value, GParamSpec *pspec)
- PurpleCipher *cipher = PURPLE_CIPHER(obj);
- PurpleRC4Cipher *rc4_cipher = PURPLE_RC4_CIPHER(obj);
- purple_rc4_cipher_set_key_len(rc4_cipher, g_value_get_int(value));
- guchar *key = (guchar *)g_value_get_string(value);
- purple_rc4_cipher_set_key(cipher, key, strlen((gchar *) key));
- G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
-purple_rc4_cipher_get_property(GObject *obj, guint param_id, GValue *value,
- PurpleRC4Cipher *rc4_cipher = PURPLE_RC4_CIPHER(obj);
- purple_rc4_cipher_get_key_len(rc4_cipher));
- G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
-purple_rc4_cipher_class_init(PurpleRC4CipherClass *klass) {
- GObjectClass *obj_class = G_OBJECT_CLASS(klass);
- PurpleCipherClass *cipher_class = PURPLE_CIPHER_CLASS(klass);
- parent_class = g_type_class_peek_parent(klass);
- obj_class->set_property = purple_rc4_cipher_set_property;
- obj_class->get_property = purple_rc4_cipher_get_property;
- cipher_class->reset = purple_rc4_cipher_reset;
- cipher_class->encrypt = purple_rc4_cipher_encrypt;
- cipher_class->set_key = purple_rc4_cipher_set_key;
- g_type_class_add_private(klass, sizeof(PurpleRC4CipherPrivate));
- properties[PROP_KEY_LEN] = g_param_spec_int("key-len", "key-len", "key-len",
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
- properties[PROP_KEY] = g_param_spec_string("key", "key", "key", NULL,
- G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
- g_object_class_install_properties(obj_class, PROP_LAST, properties);
-purple_rc4_cipher_init(PurpleCipher *cipher) {
- purple_rc4_cipher_reset(cipher);
-/******************************************************************************
- *****************************************************************************/
-purple_rc4_cipher_get_type(void) {
- static const GTypeInfo info = {
- sizeof(PurpleRC4CipherClass),
- (GClassInitFunc)purple_rc4_cipher_class_init,
- sizeof(PurpleRC4Cipher),
- (GInstanceInitFunc)purple_rc4_cipher_init,
- type = g_type_register_static(PURPLE_TYPE_CIPHER,
-purple_rc4_cipher_new(void) {
- return g_object_new(PURPLE_TYPE_RC4_CIPHER, NULL);
-purple_rc4_cipher_set_key_len(PurpleRC4Cipher *rc4_cipher,
- PurpleRC4CipherPrivate *priv;
- g_return_if_fail(PURPLE_IS_RC4_CIPHER(rc4_cipher));
- priv = PURPLE_RC4_CIPHER_GET_PRIVATE(rc4_cipher);
- priv->key_len = key_len;
- g_object_notify_by_pspec(G_OBJECT(rc4_cipher), properties[PROP_KEY_LEN]);
-purple_rc4_cipher_get_key_len(PurpleRC4Cipher *rc4_cipher)
- PurpleRC4CipherPrivate *priv;
- g_return_val_if_fail(PURPLE_IS_RC4_CIPHER(rc4_cipher), 0);
- priv = PURPLE_RC4_CIPHER_GET_PRIVATE(rc4_cipher);
--- a/libpurple/ciphers/rc4cipher.h Thu Jun 15 10:48:26 2017 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
- * 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
- * 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_RC4_CIPHER_H
-#define PURPLE_RC4_CIPHER_H
- * @section_id: libpurple-rc4cipher
- * @short_description: <filename>ciphers/rc4cipher.h</filename>
-#define PURPLE_TYPE_RC4_CIPHER (purple_rc4_cipher_get_type())
-#define PURPLE_RC4_CIPHER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_RC4_CIPHER, PurpleRC4Cipher))
-#define PURPLE_RC4_CIPHER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_RC4_CIPHER, PurpleRC4CipherClass))
-#define PURPLE_IS_RC4_CIPHER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_RC4_CIPHER))
-#define PURPLE_IS_RC4_CIPHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((obj), PURPLE_TYPE_RC4_CIPHER))
-#define PURPLE_RC4_CIPHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_RC4_CIPHER, PurpleRC4CipherClass))
-typedef struct _PurpleRC4Cipher PurpleRC4Cipher;
-typedef struct _PurpleRC4CipherClass PurpleRC4CipherClass;
-struct _PurpleRC4Cipher {
-struct _PurpleRC4CipherClass {
- PurpleCipherClass gparent;
- void (*_purple_reserved1)(void);
- void (*_purple_reserved2)(void);
- void (*_purple_reserved3)(void);
- void (*_purple_reserved4)(void);
-GType purple_rc4_cipher_get_type(void);
-PurpleCipher *purple_rc4_cipher_new(void);
-gint purple_rc4_cipher_get_key_len(PurpleRC4Cipher *rc4_cipher);
-void purple_rc4_cipher_set_key_len(PurpleRC4Cipher *rc4_cipher, gint key_len);
-#endif /* PURPLE_RC4_CIPHER_H */
--- a/libpurple/core.c Thu Jun 15 10:48:26 2017 +0300
+++ b/libpurple/core.c Fri Jun 30 15:03:16 2017 +0300
@@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
#include "conversation.h"
--- a/libpurple/eventloop.c Thu Jun 15 10:48:26 2017 +0300
+++ b/libpurple/eventloop.c Fri Jun 30 15:03:16 2017 +0300
@@ -21,69 +21,88 @@
-static PurpleEventLoopUiOps *eventloop_ui_ops = NULL;
+#define PURPLE_GLIB_READ_COND (G_IO_IN | G_IO_HUP | G_IO_ERR) +#define PURPLE_GLIB_WRITE_COND (G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL) +typedef struct _PurpleIOClosure { + PurpleInputFunction function; purple_timeout_add(guint interval, GSourceFunc function, gpointer data)
- PurpleEventLoopUiOps *ops = purple_eventloop_get_ui_ops();
- return ops->timeout_add(interval, function, data);
+ return g_timeout_add(interval, function, data); purple_timeout_add_seconds(guint interval, GSourceFunc function, gpointer data)
- PurpleEventLoopUiOps *ops = purple_eventloop_get_ui_ops();
- if (ops->timeout_add_seconds)
- return ops->timeout_add_seconds(interval, function, data);
- return ops->timeout_add(1000 * interval, function, data);
+ return g_timeout_add_seconds(interval, function, data); purple_timeout_remove(guint tag)
- PurpleEventLoopUiOps *ops = purple_eventloop_get_ui_ops();
+ return g_source_remove(tag); +purple_io_invoke(GIOChannel *source, GIOCondition condition, gpointer data) + PurpleIOClosure *closure = data; + PurpleInputCondition purple_cond = 0; - return ops->timeout_remove(tag);
+ if (condition & PURPLE_GLIB_READ_COND) + purple_cond |= PURPLE_INPUT_READ; + if (condition & PURPLE_GLIB_WRITE_COND) + purple_cond |= PURPLE_INPUT_WRITE; + closure->function(closure->data, g_io_channel_unix_get_fd(source), purple_input_add(int source, PurpleInputCondition condition, PurpleInputFunction func, gpointer user_data)
- PurpleEventLoopUiOps *ops = purple_eventloop_get_ui_ops();
+ PurpleIOClosure *closure = g_new0(PurpleIOClosure, 1); + closure->function = func; + closure->data = user_data; + if (condition & PURPLE_INPUT_READ) + cond |= PURPLE_GLIB_READ_COND; + if (condition & PURPLE_INPUT_WRITE) + cond |= PURPLE_GLIB_WRITE_COND; - return ops->input_add(source, condition, func, user_data);
+ channel = g_io_channel_win32_new_socket(source); + channel = g_io_channel_unix_new(source); + closure->result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, + cond, purple_io_invoke, closure, g_free); + g_io_channel_unref(channel); + return closure->result; purple_input_remove(guint tag)
- PurpleEventLoopUiOps *ops = purple_eventloop_get_ui_ops();
- return ops->input_remove(tag);
-purple_input_get_error(int fd, int *error)
- PurpleEventLoopUiOps *ops = purple_eventloop_get_ui_ops();
- if (ops->input_get_error)
- int ret = ops->input_get_error(fd, error);
- return getsockopt(fd, SOL_SOCKET, SO_ERROR, error, &len);
+ return g_source_remove(tag); @@ -95,47 +114,3 @@
-purple_eventloop_set_ui_ops(PurpleEventLoopUiOps *ops)
- eventloop_ui_ops = ops;
-purple_eventloop_get_ui_ops(void)
- g_return_val_if_fail(eventloop_ui_ops != NULL, NULL);
- return eventloop_ui_ops;
-/**************************************************************************
- **************************************************************************/
-static PurpleEventLoopUiOps *
-purple_eventloop_ui_ops_copy(PurpleEventLoopUiOps *ops)
- PurpleEventLoopUiOps *ops_new;
- g_return_val_if_fail(ops != NULL, NULL);
- ops_new = g_new(PurpleEventLoopUiOps, 1);
-purple_eventloop_ui_ops_get_type(void)
- type = g_boxed_type_register_static("PurpleEventLoopUiOps",
- (GBoxedCopyFunc)purple_eventloop_ui_ops_copy,
- (GBoxedFreeFunc)g_free);
--- a/libpurple/eventloop.h Thu Jun 15 10:48:26 2017 +0300
+++ b/libpurple/eventloop.h Fri Jun 30 15:03:16 2017 +0300
@@ -31,8 +31,6 @@
-#define PURPLE_TYPE_EVENTLOOP_UI_OPS (purple_eventloop_ui_ops_get_type())
* @PURPLE_INPUT_READ: A read condition.
@@ -57,99 +55,6 @@
typedef void (*PurpleInputFunction)(gpointer, gint, PurpleInputCondition);
-typedef struct _PurpleEventLoopUiOps PurpleEventLoopUiOps;
- * PurpleEventLoopUiOps:
- * @timeout_add: Should create a callback timer with an interval measured in
- * milliseconds. The supplied @function should be called every
- * @interval seconds until it returns %FALSE, after which it
- * should not be called again.
- * <sbr/>Analogous to g_timeout_add in glib.
- * <sbr/>Note: On Win32, this function may be called from a thread
- * other than the libpurple thread. You should make sure to detect
- * this situation and to only call "function" from the libpurple
- * <sbr/>See purple_timeout_add().
- * <sbr/>@interval: the interval in
- * <emphasis>milliseconds</emphasis> between
- * <sbr/>@data: arbitrary data to be passed to @function at each
- * <sbr/>Returns: a handle for the timeout, which can be passed to
- * @timeout_remove: Should remove a callback timer. Analogous to
- * g_source_remove() in glib.
- * <sbr/>See purple_timeout_remove().
- * <sbr/>@handle: an identifier for a timeout, as returned by
- * <sbr/>Returns: %TRUE if the timeout identified by @handle
- * was found and removed.
- * @input_add: Should add an input handler. Analogous to g_io_add_watch_full()
- * <sbr/>See purple_input_add().
- * <sbr/>@fd: a file descriptor to watch for events
- * <sbr/>@cond: a bitwise OR of events on @fd for which @func
- * <sbr/>@func: a callback to fire whenever a relevant event on
- * <sbr/>@user_data: arbitrary data to pass to @fd.
- * <sbr/>Returns: an identifier for this input handler, which can
- * be passed to @input_remove.
- * @input_remove: Should remove an input handler. Analogous to g_source_remove()
- * <sbr/>See purple_input_remove().
- * <sbr/>@handle: an identifier, as returned by #input_add.
- * <sbr/>Returns: %TRUE if the input handler was found and
- * @input_get_error: If implemented, should get the current error status for an
- * <sbr/>Implementation of this UI op is optional. Implement
- * it if the UI's sockets or event loop needs to customize
- * determination of socket error status. If unimplemented,
- * <literal>getsockopt(2)</literal> will be used instead.
- * <sbr/>See purple_input_get_error().
- * @timeout_add_seconds: If implemented, should create a callback timer with an
- * interval measured in seconds. Analogous to
- * g_timeout_add_seconds() in glib.
- * <sbr/>This allows UIs to group timers for better power
- * efficiency. For this reason, @interval may be rounded
- * <sbr/>Implementation of this UI op is optional. If it's
- * not implemented, calls to purple_timeout_add_seconds()
- * will be serviced by @timeout_add.
- * <sbr/>See purple_timeout_add_seconds().
- * An abstraction of an application's mainloop; libpurple will use this to
- * watch file descriptors and schedule timed callbacks. If your application
- * uses the glib mainloop, there is an implementation of this struct in
- * <filename>libpurple/example/nullclient.c</filename> which you can use
-struct _PurpleEventLoopUiOps
- /* TODO Who is responsible for freeing @data? */
- guint (*timeout_add)(guint interval, GSourceFunc function, gpointer data);
- gboolean (*timeout_remove)(guint handle);
- guint (*input_add)(int fd, PurpleInputCondition cond,
- PurpleInputFunction func, gpointer user_data);
- gboolean (*input_remove)(guint handle);
- int (*input_get_error)(int fd, int *error);
- guint (*timeout_add_seconds)(guint interval, GSourceFunc function,
- void (*_purple_reserved1)(void);
- void (*_purple_reserved2)(void);
- void (*_purple_reserved3)(void);
- void (*_purple_reserved4)(void);
/**************************************************************************/
@@ -231,24 +136,6 @@
gboolean purple_input_remove(guint handle);
- * purple_input_get_error:
- * @fd: The input file descriptor.
- * @error: A pointer to an #int which on return will have the error, or
- * Get the current error status for an input.
- * The return value and error follow getsockopt() with a level of SOL_SOCKET and an
- * option name of SO_ERROR, and this is how the error is determined if the UI does not
- * implement the input_get_error UI op.
- * Returns: 0 if there is no error; -1 if there is an error, in which case
-purple_input_get_error(int fd, int *error);
* @pipefd: Array used to return file descriptors for both ends of pipe.
@@ -267,36 +154,6 @@
purple_input_pipe(int pipefd[2]);
-/**************************************************************************/
-/* UI Registration Functions */
-/**************************************************************************/
- * purple_eventloop_ui_ops_get_type:
- * Returns: The #GType for the #PurpleEventLoopUiOps boxed structure.
-GType purple_eventloop_ui_ops_get_type(void);
- * purple_eventloop_set_ui_ops:
- * @ops: The UI operations structure.
- * Sets the UI operations structure to be used for accounts.
-void purple_eventloop_set_ui_ops(PurpleEventLoopUiOps *ops);
- * purple_eventloop_get_ui_ops:
- * Returns the UI operations structure used for accounts.
- * Returns: The UI operations structure in use.
-PurpleEventLoopUiOps *purple_eventloop_get_ui_ops(void);
#endif /* _PURPLE_EVENTLOOP_H_ */
--- a/libpurple/example/nullclient.c Thu Jun 15 10:48:26 2017 +0300
+++ b/libpurple/example/nullclient.c Fri Jun 30 15:03:16 2017 +0300
@@ -36,84 +36,6 @@
- * The following eventloop functions are used in both pidgin and purple-text. If your
- * application uses glib mainloop, you can safely use this verbatim.
-#define PURPLE_GLIB_READ_COND (G_IO_IN | G_IO_HUP | G_IO_ERR)
-#define PURPLE_GLIB_WRITE_COND (G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL)
-typedef struct _PurpleGLibIOClosure {
- PurpleInputFunction function;
-static void purple_glib_io_destroy(gpointer data)
-static gboolean purple_glib_io_invoke(GIOChannel *source, GIOCondition condition, gpointer data)
- PurpleGLibIOClosure *closure = data;
- PurpleInputCondition purple_cond = 0;
- if (condition & PURPLE_GLIB_READ_COND)
- purple_cond |= PURPLE_INPUT_READ;
- if (condition & PURPLE_GLIB_WRITE_COND)
- purple_cond |= PURPLE_INPUT_WRITE;
- closure->function(closure->data, g_io_channel_unix_get_fd(source),
-static guint glib_input_add(gint fd, PurpleInputCondition condition,
- PurpleInputFunction function, gpointer data)
- PurpleGLibIOClosure *closure = g_new0(PurpleGLibIOClosure, 1);
- closure->function = function;
- if (condition & PURPLE_INPUT_READ)
- cond |= PURPLE_GLIB_READ_COND;
- if (condition & PURPLE_INPUT_WRITE)
- cond |= PURPLE_GLIB_WRITE_COND;
- channel = g_io_channel_win32_new_socket(fd);
- channel = g_io_channel_unix_new(fd);
- closure->result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT,
- cond, purple_glib_io_invoke, closure, purple_glib_io_destroy);
- g_io_channel_unref(channel);
- return closure->result;
-static PurpleEventLoopUiOps glib_eventloops =
-/*** End of the eventloop functions. ***/
/*** Conversation uiops ***/
null_write_conv(PurpleConversation *conv, PurpleMessage *msg)
@@ -189,10 +111,6 @@
purple_core_set_ui_ops(&null_core_uiops);
- /* Set the uiops for the eventloop. If your client is glib-based, you can safely
- * copy this verbatim. */
- purple_eventloop_set_ui_ops(&glib_eventloops);
/* Now that all the essential stuff has been set, let's try to init the core. It's
* necessary to provide a non-NULL name for the current ui to the core. This name
* is used by stuff that depends on this ui, for example the ui-specific plugins. */
--- a/libpurple/glibcompat.h Thu Jun 15 10:48:26 2017 +0300
+++ b/libpurple/glibcompat.h Fri Jun 30 15:03:16 2017 +0300
@@ -63,6 +63,11 @@
+#if !GLIB_CHECK_VERSION(2, 44, 0) +#define G_IO_ERROR_CONNECTION_CLOSED G_IO_ERROR_BROKEN_PIPE /******************************************************************************
*****************************************************************************/
--- a/libpurple/marshallers.list Thu Jun 15 10:48:26 2017 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-VOID:POINTER,POINTER,OBJECT
-BOOLEAN:OBJECT,POINTER,STRING
-VOID:STRING,STRING,DOUBLE
-VOID:ENUM,STRING,STRING,BOOLEAN
-VOID:STRING,STRING,OBJECT,OBJECT
-VOID:POINTER,POINTER,OBJECT,OBJECT
--- a/libpurple/media.c Thu Jun 15 10:48:26 2017 +0300
+++ b/libpurple/media.c Fri Jun 30 15:03:16 2017 +0300
@@ -29,7 +29,6 @@
#include "media/backend-fs2.h"
-#include "marshallers.h"
#endif /* USE_GSTREAMER */
@@ -224,41 +223,33 @@
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
purple_media_signals[S_ERROR] = g_signal_new("error", G_TYPE_FROM_CLASS(klass),
- G_SIGNAL_RUN_LAST, 0, NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
+ G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_STRING);
purple_media_signals[CANDIDATES_PREPARED] = g_signal_new("candidates-prepared", G_TYPE_FROM_CLASS(klass),
- G_SIGNAL_RUN_LAST, 0, NULL, NULL,
- purple_smarshal_VOID__STRING_STRING,
+ G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 2, G_TYPE_STRING,
purple_media_signals[CODECS_CHANGED] = g_signal_new("codecs-changed", G_TYPE_FROM_CLASS(klass),
- G_SIGNAL_RUN_LAST, 0, NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
+ G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_STRING);
purple_media_signals[LEVEL] = g_signal_new("level", G_TYPE_FROM_CLASS(klass),
- G_SIGNAL_RUN_LAST, 0, NULL, NULL,
- purple_smarshal_VOID__STRING_STRING_DOUBLE,
+ G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 3, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_DOUBLE);
purple_media_signals[NEW_CANDIDATE] = g_signal_new("new-candidate", G_TYPE_FROM_CLASS(klass),
- G_SIGNAL_RUN_LAST, 0, NULL, NULL,
- purple_smarshal_VOID__POINTER_POINTER_OBJECT,
+ G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 3, G_TYPE_POINTER,
G_TYPE_POINTER, PURPLE_TYPE_MEDIA_CANDIDATE);
purple_media_signals[STATE_CHANGED] = g_signal_new("state-changed", G_TYPE_FROM_CLASS(klass),
- G_SIGNAL_RUN_LAST, 0, NULL, NULL,
- purple_smarshal_VOID__ENUM_STRING_STRING,
+ G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 3, PURPLE_MEDIA_TYPE_STATE,
G_TYPE_STRING, G_TYPE_STRING);
purple_media_signals[STREAM_INFO] = g_signal_new("stream-info", G_TYPE_FROM_CLASS(klass),
- G_SIGNAL_RUN_LAST, 0, NULL, NULL,
- purple_smarshal_VOID__ENUM_STRING_STRING_BOOLEAN,
+ G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 4, PURPLE_MEDIA_TYPE_INFO_TYPE,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
purple_media_signals[CANDIDATE_PAIR_ESTABLISHED] = g_signal_new("candidate-pair-established", G_TYPE_FROM_CLASS(klass),
- G_SIGNAL_RUN_LAST, 0, NULL, NULL,
- purple_smarshal_VOID__POINTER_POINTER_OBJECT_OBJECT,
+ G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 4, G_TYPE_POINTER, G_TYPE_POINTER,
PURPLE_TYPE_MEDIA_CANDIDATE, PURPLE_TYPE_MEDIA_CANDIDATE);
g_type_class_add_private(klass, sizeof(PurpleMediaPrivate));
--- a/libpurple/media/backend-iface.c Thu Jun 15 10:48:26 2017 +0300
+++ b/libpurple/media/backend-iface.c Fri Jun 30 15:03:16 2017 +0300
@@ -23,8 +23,6 @@
#include "backend-iface.h"
-#include "marshallers.h"
@@ -67,34 +65,29 @@
G_PARAM_STATIC_STRINGS));
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_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, 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_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 2, 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_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, 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_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, 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_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_STRING,
PURPLE_TYPE_MEDIA_CANDIDATE,
PURPLE_TYPE_MEDIA_CANDIDATE);
--- a/libpurple/mediamanager.c Thu Jun 15 10:48:26 2017 +0300
+++ b/libpurple/mediamanager.c Fri Jun 30 15:03:16 2017 +0300
@@ -27,7 +27,6 @@
#include "mediamanager.h"
-#include "marshallers.h"
#include <media/backend-fs2.h>
#endif /* USE_GSTREAMER */
@@ -172,8 +171,7 @@
purple_media_manager_signals[INIT_MEDIA] = g_signal_new ("init-media",
G_TYPE_FROM_CLASS (klass),
- purple_smarshal_BOOLEAN__OBJECT_POINTER_STRING,
G_TYPE_BOOLEAN, 3, PURPLE_TYPE_MEDIA,
G_TYPE_POINTER, G_TYPE_STRING);
@@ -181,16 +179,14 @@
g_signal_new ("init-private-media",
G_TYPE_FROM_CLASS (klass),
- 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),
- purple_smarshal_VOID__FLAGS_FLAGS,
G_TYPE_NONE, 2, PURPLE_MEDIA_TYPE_CAPS,
@@ -198,8 +194,7 @@
g_signal_new("elements-changed",
G_TYPE_FROM_CLASS(klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
- g_cclosure_marshal_VOID__VOID,
g_type_class_add_private(klass, sizeof(PurpleMediaManagerPrivate));
--- a/libpurple/plugins/Makefile.am Thu Jun 15 10:48:26 2017 +0300
+++ b/libpurple/plugins/Makefile.am Fri Jun 30 15:03:16 2017 +0300
@@ -11,8 +11,6 @@
autoaccept_la_LDFLAGS = -module @PLUGIN_LDFLAGS@
buddynote_la_LDFLAGS = -module @PLUGIN_LDFLAGS@
-caesarcipher_la_LDFLAGS = -module @PLUGIN_LDFLAGS@
-caesarcipher_consumer_la_LDFLAGS = -module @PLUGIN_LDFLAGS@
codeinline_la_LDFLAGS = -module @PLUGIN_LDFLAGS@
debug_example_la_LDFLAGS = -module @PLUGIN_LDFLAGS@
helloworld_la_LDFLAGS = -module @PLUGIN_LDFLAGS@
@@ -44,8 +42,6 @@
- caesarcipher_consumer.la \
@@ -58,8 +54,6 @@
autoaccept_la_SOURCES = autoaccept.c
buddynote_la_SOURCES = buddynote.c
-caesarcipher_la_SOURCES = caesarcipher.c caesarcipher.h
-caesarcipher_consumer_la_SOURCES = caesarcipher_consumer.c
codeinline_la_SOURCES = codeinline.c
debug_example_la_SOURCES = debug_example.c
helloworld_la_SOURCES = helloworld.c
@@ -77,8 +71,6 @@
autoaccept_la_LIBADD = @PURPLE_LIBS@
buddynote_la_LIBADD = @PURPLE_LIBS@
-caesarcipher_la_LIBADD = @PURPLE_LIBS@
-caesarcipher_consumer_la_LIBADD = @PURPLE_LIBS@
codeinline_la_LIBADD = @PURPLE_LIBS@
idle_la_LIBADD = @PURPLE_LIBS@
joinpart_la_LIBADD = @PURPLE_LIBS@
@@ -128,11 +120,9 @@
# This part allows people to build their own plugins in here.
--- a/libpurple/plugins/caesarcipher.c Thu Jun 15 10:48:26 2017 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,212 +0,0 @@
- * An example plugin that demonstrates exporting of a cipher object
- * type to be used in another plugin.
- * This plugin only provides the CaesarCipher type. See caesarcipher_consumer
- * Copyright (C) 2013, Ankit Vani <a@nevitus.org>
- * 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
-/* When writing a third-party plugin, do not include libpurple's internal.h
- * included below. This file is for internal libpurple use only. We're including
- * it here for our own convenience. */
-/* This file defines PURPLE_PLUGINS and includes all the libpurple headers */
-#include "caesarcipher.h"
-#define CAESAR_CIPHER_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE((obj), CAESAR_TYPE_CIPHER, CaesarCipherPrivate))
-/******************************************************************************
- *****************************************************************************/
-caesar_shift(const guchar input[], size_t in_len, guchar output[], gint8 offset)
- for (i = 0; i < in_len; ++i) {
- if (input[i] >= 'a' && input[i] <= 'z')
- output[i] = (((input[i] - 'a') + offset + 26) % 26) + 'a';
- else if (input[i] >= 'A' && input[i] <= 'Z')
- output[i] = (((input[i] - 'A') + offset + 26) % 26) + 'A';
-caesar_cipher_set_offset(PurpleCipher *cipher, gint8 offset)
- CaesarCipherPrivate *priv = CAESAR_CIPHER_GET_PRIVATE(cipher);
- priv->offset = offset % 26;
-caesar_cipher_encrypt(PurpleCipher *cipher, const guchar input[], size_t in_len,
- guchar output[], size_t out_size)
- CaesarCipherPrivate *priv = CAESAR_CIPHER_GET_PRIVATE(cipher);
- g_return_val_if_fail(out_size > in_len, -1);
- caesar_shift(input, in_len, output, priv->offset);
-caesar_cipher_decrypt(PurpleCipher *cipher, const guchar input[], size_t in_len,
- guchar output[], size_t out_size)
- CaesarCipherPrivate *priv = CAESAR_CIPHER_GET_PRIVATE(cipher);
- g_return_val_if_fail(out_size > in_len, -1);
- caesar_shift(input, in_len, output, -priv->offset);
-caesar_cipher_set_key(PurpleCipher *cipher, const guchar *key, size_t len)
- caesar_cipher_set_offset(cipher, len);
-/******************************************************************************
- *****************************************************************************/
-caesar_cipher_set_property(GObject *obj, guint param_id, const GValue *value,
- PurpleCipher *cipher = PURPLE_CIPHER(obj);
- caesar_cipher_set_offset(cipher, g_value_get_schar(value));
- G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
-/* initialize the cipher object. used in PURPLE_DEFINE_TYPE. */
-caesar_cipher_init(CaesarCipher *cipher)
- /* classic caesar cipher uses a shift of 3 */
- CAESAR_CIPHER_GET_PRIVATE(cipher)->offset = 3;
-/* initialize the cipher class. used in PURPLE_DEFINE_TYPE. */
-caesar_cipher_class_init(PurpleCipherClass *klass)
- GObjectClass *obj_class = G_OBJECT_CLASS(klass);
- obj_class->set_property = caesar_cipher_set_property;
- g_type_class_add_private(obj_class, sizeof(CaesarCipherPrivate));
- klass->encrypt = caesar_cipher_encrypt;
- klass->decrypt = caesar_cipher_decrypt;
- klass->set_key = caesar_cipher_set_key;
- g_object_class_install_property(obj_class, PROP_OFFSET,
- g_param_spec_char("offset", "offset",
- "The offset by which to shift alphabets",
- * define the CaesarCipher type. this function defines
- * caesar_cipher_get_type() and caesar_cipher_register_type().
-PURPLE_DEFINE_TYPE(CaesarCipher, caesar_cipher, PURPLE_TYPE_CIPHER);
-G_MODULE_EXPORT PurpleCipher *
- return g_object_new(CAESAR_TYPE_CIPHER, NULL);
-/******************************************************************************
- *****************************************************************************/
-static PurplePluginInfo *
-plugin_query(GError **error)
- const gchar * const authors[] = {
- "Ankit Vani <a@nevitus.org>",
- return purple_plugin_info_new(
- "id", "core-caesarcipher",
- "name", N_("Caesar Cipher Provider Example"),
- "version", DISPLAY_VERSION,
- "category", N_("Example"),
- "summary", N_("An example plugin that demonstrates exporting of a "
- "description", N_("An example plugin that demonstrates exporting of "
- "a cipher object type to be used in another "
- "website", PURPLE_WEBSITE,
- "abi-version", PURPLE_ABI_VERSION,
-plugin_load(PurplePlugin *plugin, GError **error)
- /* register the CaesarCipher type in the type system */
- caesar_cipher_register_type(plugin);
-plugin_unload(PurplePlugin *plugin, GError **error)
-PURPLE_PLUGIN_INIT(caesarcipher, plugin_query, plugin_load, plugin_unload);
--- a/libpurple/plugins/caesarcipher.h Thu Jun 15 10:48:26 2017 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
- * An example plugin that demonstrates exporting of a cipher object
- * type to be used in another plugin.
- * Copyright (C) 2013, Ankit Vani <a@nevitus.org>
- * 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
-#ifndef _CAESAR_CIPHER_H_
-#define _CAESAR_CIPHER_H_
-#define CAESAR_TYPE_CIPHER (caesar_cipher_get_type())
-#define CAESAR_CIPHER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), CAESAR_TYPE_CIPHER, CaesarCipher))
-#define CAESAR_CIPHER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), CAESAR_TYPE_CIPHER, CaesarCipherClass))
-#define CAESAR_IS_CIPHER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), CAESAR_TYPE_CIPHER))
-#define CAESAR_IS_CIPHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), CAESAR_TYPE_CIPHER))
-#define CAESAR_CIPHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), CAESAR_TYPE_CIPHER, CaesarCipherClass))
-typedef struct _CaesarCipher CaesarCipher;
-typedef struct _CaesarCipherClass CaesarCipherClass;
- * A caesar cipher object.
- * The Caesar cipher is one of the simplest and most widely known encryption
- * techniques. It is a type of substitution cipher in which each letter in the
- * plaintext is replaced by a letter some fixed number of positions down the
-/* The base class for all CaesarCipher's. */
-struct _CaesarCipherClass
- PurpleCipherClass gparent;
- * Returns the GType for the CaesarCipher object.
-G_MODULE_EXPORT GType caesar_cipher_get_type(void);
- * Creates a new CaesarCipher instance and returns it.
-G_MODULE_EXPORT PurpleCipher *caesar_cipher_new(void);
-#endif /* _CAESAR_CIPHER_H_ */
--- a/libpurple/plugins/caesarcipher_consumer.c Thu Jun 15 10:48:26 2017 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,117 +0,0 @@
- * An example plugin that demonstrates usage of a cipher object type
- * registered in another plugin.
- * This plugin requires the caesarcipher plugin to be loaded to use the
- * Copyright (C) 2013, Ankit Vani <a@nevitus.org>
- * 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
-/* When writing a third-party plugin, do not include libpurple's internal.h
- * included below. This file is for internal libpurple use only. We're including
- * it here for our own convenience. */
-/* This file defines PURPLE_PLUGINS and includes all the libpurple headers */
-#include "caesarcipher.h"
-debug_cipher(PurpleCipher *cipher, const gchar *input)
- gchar ciphertext[512], plaintext[512];
- purple_debug_info("caesarcipher_consumer", "Encrypting...");
- purple_debug_info("caesarcipher_consumer", "INPUT: %s\n", input);
- purple_cipher_encrypt(cipher, (const guchar *)input, strlen(input),
- (guchar *)ciphertext, 512);
- purple_debug_info("caesarcipher_consumer", "OUTPUT: %s\n", ciphertext);
- purple_debug_info("caesarcipher_consumer", "Decrypting...");
- purple_debug_info("caesarcipher_consumer", "INPUT: %s\n", ciphertext);
- purple_cipher_decrypt(cipher, (const guchar *)ciphertext,
- strlen(ciphertext), (guchar *)plaintext, 512);
- purple_debug_info("caesarcipher_consumer", "OUTPUT: %s\n", plaintext);
-static PurplePluginInfo *
-plugin_query(GError **error)
- const gchar * const authors[] = {
- "Ankit Vani <a@nevitus.org>",
- /* we need to ensure the object provider is loaded for its type to be
- * registered in the type system. */
- const gchar * const dependencies[] = {
- return purple_plugin_info_new(
- "id", "core-caesarcipher_consumer",
- "name", N_("Caesar Cipher Consumer Example"),
- "version", DISPLAY_VERSION,
- "category", N_("Example"),
- "summary", N_("An example plugin that demonstrates usage of a "
- "loaded cipher type."),
- "description", N_("An example plugin that demonstrates usage of "
- "a cipher object type registered in another "
- "website", PURPLE_WEBSITE,
- "abi-version", PURPLE_ABI_VERSION,
- "dependencies", dependencies,
-plugin_load(PurplePlugin *plugin, GError **error)
- PurpleCipher *cipher = caesar_cipher_new();
- purple_debug_info("caesarcipher_consumer", "Created caesar cipher "
- debug_cipher(cipher, "Input string for cipher!");
- purple_cipher_set_key(cipher, NULL, 13);
- purple_debug_info("caesarcipher_consumer", "Offset set to 13.\n");
- debug_cipher(cipher, "An0ther input 4 cipher..");
- g_object_unref(cipher);
- purple_debug_info("caesarcipher_consumer", "Destroyed caesar cipher "
-plugin_unload(PurplePlugin *plugin, GError **error)
-PURPLE_PLUGIN_INIT(caesarcipher_consumer, plugin_query, plugin_load, plugin_unload);
--- a/libpurple/plugins/keyrings/Makefile.am Thu Jun 15 10:48:26 2017 +0300
+++ b/libpurple/plugins/keyrings/Makefile.am Fri Jun 30 15:03:16 2017 +0300
@@ -5,10 +5,14 @@
plugindir = @PURPLE_PLUGINDIR@
-internalkeyring_la_CFLAGS = $(AM_CPPFLAGS)
+internalkeyring_la_CFLAGS = $(AM_CPPFLAGS) $(NETTLE_CFLAGS) internalkeyring_la_LDFLAGS = -module @PLUGIN_LDFLAGS@
internalkeyring_la_SOURCES = internalkeyring.c
-internalkeyring_la_LIBADD = @PURPLE_LIBS@
+internalkeyring_la_LIBADD = @PURPLE_LIBS@ $(NETTLE_LIBS) @@ -56,8 +60,12 @@
--- a/libpurple/plugins/keyrings/internalkeyring.c Thu Jun 15 10:48:26 2017 +0300
+++ b/libpurple/plugins/keyrings/internalkeyring.c Fri Jun 30 15:03:16 2017 +0300
@@ -31,8 +31,9 @@
-#include "ciphers/aescipher.h"
-#include "ciphers/pbkdf2cipher.h"
+#include <nettle/pbkdf2.h> #define INTKEYRING_NAME N_("Internal keyring")
#define INTKEYRING_DESCRIPTION N_("This plugin provides the default password " \
@@ -45,7 +46,7 @@
#define INTKEYRING_PBKDF2_ITERATIONS 10000
#define INTKEYRING_PBKDF2_ITERATIONS_MIN 1000
#define INTKEYRING_PBKDF2_ITERATIONS_MAX 1000000000
-#define INTKEYRING_KEY_LEN (256/8)
+#define INTKEYRING_KEY_LEN AES256_KEY_SIZE #define INTKEYRING_ENCRYPT_BUFF_LEN 1000
#define INTKEYRING_ENCRYPTED_MIN_LEN 50
#define INTKEYRING_ENCRYPTION_METHOD "pbkdf2-sha256-aes256"
@@ -150,33 +151,16 @@
static intkeyring_buff_t *
intkeyring_derive_key(const gchar *passphrase, intkeyring_buff_t *salt)
g_return_val_if_fail(passphrase != NULL, NULL);
- cipher = purple_pbkdf2_cipher_new(G_CHECKSUM_SHA256);
- g_object_set(G_OBJECT(cipher), "iter_count",
- GUINT_TO_POINTER(purple_prefs_get_int(INTKEYRING_PREFS
- "pbkdf2_iterations")), NULL);
- g_object_set(G_OBJECT(cipher), "out_len", GUINT_TO_POINTER(
- INTKEYRING_KEY_LEN), NULL);
- purple_cipher_set_salt(cipher, salt->data, salt->len);
- purple_cipher_set_key(cipher, (const guchar*)passphrase,
ret = intkeyring_buff_new(g_new(guchar, INTKEYRING_KEY_LEN),
- succ = purple_cipher_digest(cipher, ret->data, ret->len);
- g_object_unref(cipher);
- intkeyring_buff_free(ret);
+ pbkdf2_hmac_sha256(strlen(passphrase), (const uint8_t *)passphrase, + purple_prefs_get_int(INTKEYRING_PREFS"pbkdf2_iterations"), + salt->len, salt->data, ret->len, ret->data); @@ -230,10 +214,11 @@
intkeyring_encrypt(intkeyring_buff_t *key, const gchar *str)
+ struct CBC_CTX(struct aes256_ctx, AES_BLOCK_SIZE) ctx; guchar plaintext[INTKEYRING_ENCRYPT_BUFF_LEN];
size_t plaintext_len, text_len, verify_len;
guchar encrypted_raw[INTKEYRING_ENCRYPT_BUFF_LEN];
@@ -249,31 +234,38 @@
g_return_val_if_fail(plaintext_len + verify_len <= sizeof(plaintext),
- cipher = purple_aes_cipher_new();
- g_return_val_if_fail(cipher != NULL, NULL);
memset(plaintext, 0, plaintext_len);
memcpy(plaintext, str, text_len);
memcpy(plaintext + plaintext_len, INTKEYRING_VERIFY_STR, verify_len);
plaintext_len += verify_len;
- iv = intkeyring_gen_salt(purple_cipher_get_block_size(cipher));
+ padding_len = AES_BLOCK_SIZE - (plaintext_len % AES_BLOCK_SIZE); + if (plaintext_len + padding_len > INTKEYRING_ENCRYPT_BUFF_LEN) { + purple_debug_error("keyring-internal", + "Internal keyring encrypt buffer too small"); + memset(plaintext + plaintext_len, padding_len, padding_len); + plaintext_len += padding_len; + iv = intkeyring_gen_salt(AES_BLOCK_SIZE); g_return_val_if_fail(iv != NULL, NULL);
- purple_cipher_set_iv(cipher, iv->data, iv->len);
- purple_cipher_set_key(cipher, key->data, key->len);
- purple_cipher_set_batch_mode(cipher,
- PURPLE_CIPHER_BATCH_MODE_CBC);
+ aes256_set_encrypt_key(&ctx.ctx, key->data); + CBC_SET_IV(&ctx, iv->data); memcpy(encrypted_raw, iv->data, iv->len);
- encrypted_size = purple_cipher_encrypt(cipher,
- plaintext, plaintext_len, encrypted_raw + iv->len,
- sizeof(encrypted_raw) - iv->len);
+ CBC_ENCRYPT(&ctx, aes256_encrypt, plaintext_len, + encrypted_raw + iv->len, plaintext); + encrypted_size = plaintext_len; encrypted_size += iv->len;
memset(plaintext, 0, plaintext_len);
intkeyring_buff_free(iv);
- g_object_unref(cipher);
@@ -285,42 +277,63 @@
intkeyring_decrypt(intkeyring_buff_t *key, const gchar *str)
+ struct CBC_CTX(struct aes256_ctx, AES_BLOCK_SIZE) ctx; size_t iv_len, verify_len, text_len;
guchar plaintext[INTKEYRING_ENCRYPT_BUFF_LEN];
const gchar *verify_str = NULL;
g_return_val_if_fail(key != NULL, NULL);
g_return_val_if_fail(str != NULL, NULL);
- cipher = purple_aes_cipher_new();
- g_return_val_if_fail(cipher != NULL, NULL);
encrypted_raw = g_base64_decode(str, &encrypted_size);
g_return_val_if_fail(encrypted_raw != NULL, NULL);
- iv_len = purple_cipher_get_block_size(cipher);
+ iv_len = AES_BLOCK_SIZE; if (encrypted_size < iv_len) {
- purple_cipher_set_iv(cipher, encrypted_raw, iv_len);
- purple_cipher_set_key(cipher, key->data, key->len);
- purple_cipher_set_batch_mode(cipher,
- PURPLE_CIPHER_BATCH_MODE_CBC);
+ aes256_set_decrypt_key(&ctx.ctx, key->data); + CBC_SET_IV(&ctx, encrypted_raw); + CBC_DECRYPT(&ctx, aes256_decrypt, encrypted_size - iv_len, + plaintext, encrypted_raw + iv_len); + plaintext_len = encrypted_size - iv_len; - plaintext_len = purple_cipher_decrypt(cipher,
- encrypted_raw + iv_len, encrypted_size - iv_len,
- plaintext, sizeof(plaintext));
+ padding_len = plaintext[plaintext_len - 1]; + if (padding_len == 0 || padding_len > AES_BLOCK_SIZE || + padding_len > plaintext_len) { + purple_debug_warning("internal-keyring", + "Invalid padding length: %d (total %" G_GSIZE_FORMAT + ") - most probably, the key was invalid\n", + padding_len, plaintext_len);
- g_object_unref(cipher);
+ plaintext_len -= padding_len; + for (i = 0; i < padding_len; ++i) { + if (plaintext[plaintext_len + i] != padding_len) { + purple_debug_warning("internal-keyring", + "Padding doesn't match at pos %d (found %02x, " + "most probably, the key was invalid\n", + i, plaintext[plaintext_len + i], padding_len); + memset(plaintext + plaintext_len, 0, padding_len); verify_len = strlen(INTKEYRING_VERIFY_STR);
/* Don't remove the len > 0 check! */
if (plaintext_len > 0 && (gsize)plaintext_len > verify_len &&
--- a/libpurple/protocols/facebook/Makefile.am Thu Jun 15 10:48:26 2017 +0300
+++ b/libpurple/protocols/facebook/Makefile.am Fri Jun 30 15:03:16 2017 +0300
@@ -1,12 +1,9 @@
pkgdir = @PURPLE_PLUGINDIR@
@@ -25,17 +22,6 @@
-marshal.c: $(srcdir)/marshaller.list marshal.h
- $(AM_V_GEN)echo "#include \"marshal.h\"" > $@
- $(AM_V_at)$(GLIB_GENMARSHAL) --prefix=fb_marshal --body $(srcdir)/marshaller.list >> $@
-marshal.h: $(srcdir)/marshaller.list
- $(AM_V_GEN)$(GLIB_GENMARSHAL) --prefix=fb_marshal --header $(srcdir)/marshaller.list > $@
libfacebook_la_LDFLAGS = -module @PLUGIN_LDFLAGS@
--- a/libpurple/protocols/facebook/Makefile.mingw Thu Jun 15 10:48:26 2017 +0300
+++ b/libpurple/protocols/facebook/Makefile.mingw Fri Jun 30 15:03:16 2017 +0300
@@ -42,7 +42,6 @@
@@ -85,18 +84,11 @@
$(TARGET).dll: $(PURPLE_DLL).a $(OBJECTS)
$(CC) -shared $(OBJECTS) $(LIB_PATHS) $(LIBS) $(DLL_LD_FLAGS) -o $(TARGET).dll
-marshal.c: marshaller.list marshal.h
- @echo "#include \"marshal.h\"" > $@
- @$(GLIB_GENMARSHAL) --prefix=fb_marshal --body marshaller.list >> $@
-marshal.h: marshaller.list
- @$(GLIB_GENMARSHAL) --prefix=fb_marshal --header marshaller.list > $@
- rm -f $(OBJECTS) marshal.c marshal.h
include $(PIDGIN_COMMON_TARGETS)
--- a/libpurple/protocols/facebook/api.c Thu Jun 15 10:48:26 2017 +0300
+++ b/libpurple/protocols/facebook/api.c Fri Jun 30 15:03:16 2017 +0300
@@ -28,7 +28,6 @@
@@ -68,6 +67,7 @@
@@ -88,6 +88,9 @@
fb_api_sticker(FbApi *api, FbId sid, FbApiMessage *msg);
+fb_api_contacts_delta(FbApi *api, const gchar *delta_cursor); G_DEFINE_TYPE(FbApi, fb_api, G_TYPE_OBJECT);
@@ -185,6 +188,7 @@
+ g_free(priv->contacts_delta); @@ -287,8 +291,7 @@
G_TYPE_FROM_CLASS(klass),
@@ -303,8 +306,7 @@
G_TYPE_FROM_CLASS(klass),
@@ -320,8 +322,7 @@
G_TYPE_FROM_CLASS(klass),
- fb_marshal_VOID__POINTER,
@@ -341,12 +342,27 @@
G_TYPE_FROM_CLASS(klass),
- fb_marshal_VOID__POINTER_BOOLEAN,
2, G_TYPE_POINTER, G_TYPE_BOOLEAN);
+ * FbApi::contacts-delta: + * @added: The #GSList of added #FbApiUser's. + * @removed: The #GSList of strings with removed user ids. + * Like 'contacts', but only the deltas. + g_signal_new("contacts-delta", + G_TYPE_FROM_CLASS(klass), + 2, G_TYPE_POINTER, G_TYPE_POINTER); @@ -358,10 +374,9 @@
G_TYPE_FROM_CLASS(klass),
- fb_marshal_VOID__OBJECT,
@@ -374,8 +389,7 @@
G_TYPE_FROM_CLASS(klass),
- fb_marshal_VOID__POINTER,
@@ -390,8 +404,7 @@
G_TYPE_FROM_CLASS(klass),
- fb_marshal_VOID__POINTER,
@@ -406,8 +419,7 @@
G_TYPE_FROM_CLASS(klass),
- fb_marshal_VOID__POINTER,
@@ -423,8 +435,7 @@
G_TYPE_FROM_CLASS(klass),
- fb_marshal_VOID__POINTER,
@@ -441,12 +452,27 @@
G_TYPE_FROM_CLASS(klass),
- fb_marshal_VOID__INT64,
+ * FbApi::thread-kicked: + * @thrd: The #FbApiThread. + * Emitted upon the reply of a thread request when the user is no longer + * part of that thread. This is emitted as a result of #fb_api_thread(). + g_signal_new("thread-kicked", + G_TYPE_FROM_CLASS(klass), * @thrds: The #GSList of #FbApiThread's.
@@ -458,8 +484,7 @@
G_TYPE_FROM_CLASS(klass),
- fb_marshal_VOID__POINTER,
@@ -474,8 +499,7 @@
G_TYPE_FROM_CLASS(klass),
- fb_marshal_VOID__POINTER,
@@ -762,6 +786,9 @@
+ purple_http_request_header_set(req, "User-Agent", FB_API_AGENT); + purple_http_request_header_set(req, "Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); data = fb_http_params_close(params, NULL);
purple_http_request_set_contents(req, data, -1);
ret = purple_http_request(priv->gc, req, callback, api);
@@ -794,12 +821,16 @@
case FB_API_QUERY_CONTACTS_AFTER:
name = "FetchContactsFullWithAfterQuery";
+ case FB_API_QUERY_CONTACTS_DELTA: + name = "FetchContactsDeltaQuery"; case FB_API_QUERY_STICKER:
name = "FetchStickersWithPreviewsQuery";
case FB_API_QUERY_THREAD:
+ case FB_API_QUERY_SEQ_ID: case FB_API_QUERY_THREADS:
name = "ThreadListQuery";
@@ -883,7 +914,7 @@
/* Write the information string */
fb_thrift_write_field(thft, FB_THRIFT_TYPE_STRING, 2, 1);
- fb_thrift_write_str(thft, "");
+ fb_thrift_write_str(thft, FB_API_MQTT_AGENT); /* Write the UNKNOWN ("cp"?) */
fb_thrift_write_field(thft, FB_THRIFT_TYPE_I64, 3, 2);
@@ -1029,7 +1060,7 @@
values = fb_json_values_new(root);
- fb_json_values_add(values, FB_JSON_TYPE_STR, TRUE,
+ fb_json_values_add(values, FB_JSON_TYPE_STR, FALSE, "$.viewer.message_threads.sync_sequence_id");
fb_json_values_add(values, FB_JSON_TYPE_INT, TRUE,
"$.viewer.message_threads.unread_count");
@@ -1045,7 +1076,13 @@
priv->sid = g_ascii_strtoll(str, NULL, 10);
priv->unread = fb_json_values_next_int(values, 0);
- fb_api_connect_queue(api);
+ fb_api_error(api, FB_API_ERROR_GENERAL, + _("Failed to get sync_sequence_id")); + fb_api_connect_queue(api); @@ -1087,7 +1124,7 @@
bldr = fb_json_bldr_new(JSON_NODE_OBJECT);
fb_json_bldr_add_str(bldr, "1", "0");
- fb_api_http_query(api, FB_API_QUERY_THREADS, bldr,
+ fb_api_http_query(api, FB_API_QUERY_SEQ_ID, bldr, fb_api_connect_queue(api);
@@ -1363,7 +1400,11 @@
if (purple_strequal(str, "ExternalUrl")) {
params = fb_http_params_new_parse(url, TRUE);
- text = fb_http_params_dup_str(params, "u", NULL);
+ if (g_str_has_prefix(url, FB_API_FBRPC_PREFIX)) { + text = fb_http_params_dup_str(params, "target_url", NULL); + text = fb_http_params_dup_str(params, "u", NULL); fb_http_params_free(params);
@@ -1396,8 +1437,7 @@
values = fb_json_values_new(root);
fb_json_values_add(values, FB_JSON_TYPE_STR, FALSE, "$.xmaGraphQL");
fb_json_values_add(values, FB_JSON_TYPE_INT, FALSE, "$.fbid");
- fb_json_values_set_array(values, FALSE, "$.deltaNewMessage"
+ fb_json_values_set_array(values, FALSE, "$.attachments"); while (fb_json_values_update(values, &err)) {
str = fb_json_values_next_str(values, NULL);
@@ -1439,25 +1479,40 @@
+fb_api_cb_publish_ms_new_message(FbApi *api, JsonNode *root, GSList *msgs, GError **error); +fb_api_cb_publish_ms_event(FbApi *api, JsonNode *root, GSList *events, FbApiEventType type, GError **error); fb_api_cb_publish_ms(FbApi *api, GByteArray *pload)
FbApiPrivate *priv = api->priv;
+ {"deltaNewMessage", 0, 1}, + {"deltaThreadName", FB_API_EVENT_TYPE_THREAD_TOPIC, 0}, + {"deltaParticipantsAddedToGroupThread", FB_API_EVENT_TYPE_THREAD_USER_ADDED, 0}, + {"deltaParticipantLeftGroupThread", FB_API_EVENT_TYPE_THREAD_USER_REMOVED, 0}, /* Read identifier string (for Facebook employees) */
thft = fb_thrift_new(pload, 0);
@@ -1497,39 +1552,100 @@
+ arr = fb_json_node_get_arr(root, "$.deltas", NULL); + elms = json_array_get_elements(arr); + for (l = elms; l != NULL; l = l->next) { + JsonObject *o = json_node_get_object(l->data); + for (i = 0; i < G_N_ELEMENTS(event_types); i++) { + if ((node = json_object_get_member(o, event_types[i].member))) { + if (event_types[i].is_message) { + msgs = fb_api_cb_publish_ms_new_message( + events = fb_api_cb_publish_ms_event( + api, node, events, event_types[i].type, &err + if (G_UNLIKELY(err != NULL)) { + if (G_LIKELY(err == NULL)) { + msgs = g_slist_reverse(msgs); + g_signal_emit_by_name(api, "messages", msgs); + events = g_slist_reverse(events); + g_signal_emit_by_name(api, "events", events); + fb_api_error_emit(api, err); + g_slist_free_full(msgs, (GDestroyNotify) fb_api_message_free); + g_slist_free_full(events, (GDestroyNotify) fb_api_event_free); +fb_api_cb_publish_ms_new_message(FbApi *api, JsonNode *root, GSList *msgs, GError **error) + FbApiPrivate *priv = api->priv; values = fb_json_values_new(root);
fb_json_values_add(values, FB_JSON_TYPE_INT, FALSE,
- "$.deltaNewMessage.messageMetadata.offlineThreadingId");
+ "$.messageMetadata.offlineThreadingId"); fb_json_values_add(values, FB_JSON_TYPE_INT, FALSE,
- "$.deltaNewMessage.messageMetadata.actorFbId");
+ "$.messageMetadata.actorFbId"); fb_json_values_add(values, FB_JSON_TYPE_INT, FALSE,
- "$.deltaNewMessage.messageMetadata"
".threadKey.otherUserFbId");
fb_json_values_add(values, FB_JSON_TYPE_INT, FALSE,
- "$.deltaNewMessage.messageMetadata"
".threadKey.threadFbId");
fb_json_values_add(values, FB_JSON_TYPE_INT, FALSE,
- "$.deltaNewMessage.messageMetadata.timestamp");
+ "$.messageMetadata.timestamp"); fb_json_values_add(values, FB_JSON_TYPE_STR, FALSE,
- "$.deltaNewMessage.body");
fb_json_values_add(values, FB_JSON_TYPE_INT, FALSE,
- "$.deltaNewMessage.stickerId");
fb_json_values_add(values, FB_JSON_TYPE_STR, FALSE,
- "$.deltaNewMessage.messageMetadata.messageId");
- fb_json_values_set_array(values, TRUE, "$.deltas");
- while (fb_json_values_update(values, &err)) {
+ "$.messageMetadata.messageId"); + if (fb_json_values_update(values, &err)) { id = fb_json_values_next_int(values, 0);
/* Ignore everything but new messages */
/* Ignore sequential duplicates */
if (id == priv->lastmid) {
fb_util_debug_info("Ignoring duplicate %" FB_ID_FORMAT, id);
@@ -1565,7 +1681,7 @@
str = fb_json_values_next_str(values, NULL);
node = fb_json_values_get_root(values);
@@ -1573,20 +1689,97 @@
if (G_UNLIKELY(err != NULL)) {
+ g_propagate_error(error, err); - if (G_LIKELY(err == NULL)) {
- msgs = g_slist_reverse(msgs);
- g_signal_emit_by_name(api, "messages", msgs);
- fb_api_error_emit(api, err);
+ g_object_unref(values); +fb_api_cb_publish_ms_event(FbApi *api, JsonNode *root, GSList *events, FbApiEventType type, GError **error) + FbJsonValues *values = NULL; + FbJsonValues *values_inner = NULL; + values = fb_json_values_new(root); + fb_json_values_add(values, FB_JSON_TYPE_INT, FALSE, + "$.messageMetadata.threadKey.threadFbId"); + fb_json_values_add(values, FB_JSON_TYPE_INT, FALSE, + "$.messageMetadata.actorFbId"); + case FB_API_EVENT_TYPE_THREAD_TOPIC: + fb_json_values_add(values, FB_JSON_TYPE_STR, FALSE, + case FB_API_EVENT_TYPE_THREAD_USER_ADDED: + values_inner = fb_json_values_new(root); + fb_json_values_add(values_inner, FB_JSON_TYPE_INT, FALSE, + /* use the text field for the full name */ + fb_json_values_add(values_inner, FB_JSON_TYPE_STR, FALSE, + fb_json_values_set_array(values_inner, FALSE, + "$.addedParticipants"); + case FB_API_EVENT_TYPE_THREAD_USER_REMOVED: + fb_json_values_add(values, FB_JSON_TYPE_INT, FALSE, + "$.leftParticipantFbId"); + /* use the text field for the kick message */ + fb_json_values_add(values, FB_JSON_TYPE_STR, FALSE, + "$.messageMetadata.adminText"); - g_slist_free_full(msgs, (GDestroyNotify) fb_api_message_free);
+ fb_json_values_update(values, &err); + event = fb_api_event_dup(NULL, FALSE); + event->tid = fb_json_values_next_int(values, 0); + event->uid = fb_json_values_next_int(values, 0); + if (type == FB_API_EVENT_TYPE_THREAD_TOPIC) { + event->text = fb_json_values_next_str_dup(values, NULL); + } else if (type == FB_API_EVENT_TYPE_THREAD_USER_REMOVED) { + /* overwrite actor with subject */ + event->uid = fb_json_values_next_int(values, 0); + event->text = fb_json_values_next_str_dup(values, NULL); + } else if (type == FB_API_EVENT_TYPE_THREAD_USER_ADDED) { + while (fb_json_values_update(values_inner, &err)) { + FbApiEvent *devent = fb_api_event_dup(event, FALSE); + devent->uid = fb_json_values_next_int(values_inner, 0); + devent->text = fb_json_values_next_str_dup(values_inner, NULL); + events = g_slist_prepend(events, devent); + fb_api_event_free(event); + g_object_unref(values_inner);
+ if (G_UNLIKELY(err != NULL)) { + g_propagate_error(error, err); + events = g_slist_prepend(events, event); @@ -2043,25 +2236,16 @@
fb_api_http_query(api, FB_API_QUERY_CONTACT, bldr, fb_api_cb_contact);
-fb_api_cb_contacts(PurpleHttpConnection *con, PurpleHttpResponse *res,
+fb_api_cb_contacts_nodes(FbApi *api, JsonNode *root, GSList *users)
FbApiPrivate *priv = api->priv;
- if (!fb_api_http_chk(api, con, res, &root)) {
values = fb_json_values_new(root);
fb_json_values_add(values, FB_JSON_TYPE_STR, FALSE,
@@ -2072,8 +2256,12 @@
"$.structured_name.text");
fb_json_values_add(values, FB_JSON_TYPE_STR, FALSE,
- fb_json_values_set_array(values, FALSE, "$.viewer.messenger_contacts"
+ is_array = (JSON_NODE_TYPE(root) == JSON_NODE_ARRAY); + fb_json_values_set_array(values, FALSE, "$"); while (fb_json_values_update(values, &err)) {
str = fb_json_values_next_str(values, "0");
@@ -2083,6 +2271,9 @@
if ((!purple_strequal(str, "ARE_FRIENDS") &&
(uid != priv->uid)) || (uid == 0))
@@ -2094,20 +2285,123 @@
user->csum = fb_api_user_icon_checksum(user->icon);
users = g_slist_prepend(users, user);
- values = fb_json_values_new(root);
+/* base64(contact:<our id>:<their id>:<whatever>) */ +fb_api_cb_contacts_parse_removed(FbApi *api, JsonNode *node, GSList *users) + char *decoded = (char *) g_base64_decode(json_node_get_string(node), &len); + g_return_val_if_fail(decoded[len] == '\0', users); + g_return_val_if_fail(len == strlen(decoded), users); + g_return_val_if_fail(g_str_has_prefix(decoded, "contact:"), users); + split = g_strsplit_set(decoded, ":", 4); + g_return_val_if_fail(g_strv_length(split) == 4, users); + users = g_slist_prepend(users, g_strdup(split[2])); +fb_api_cb_contacts(PurpleHttpConnection *con, PurpleHttpResponse *res, + const gchar *delta_cursor; + FbApiPrivate *priv = api->priv; + if (!fb_api_http_chk(api, con, res, &root)) { + croot = fb_json_node_get(root, "$.viewer.messenger_contacts.deltas", NULL); + is_delta = (croot != NULL); + croot = fb_json_node_get(root, "$.viewer.messenger_contacts", NULL); + node = fb_json_node_get(croot, "$.nodes", NULL); + users = fb_api_cb_contacts_nodes(api, node, users); + GSList *removed = NULL; + JsonArray *arr = fb_json_node_get_arr(croot, "$.nodes", NULL); + GList *elms = json_array_get_elements(arr); + for (l = elms; l != NULL; l = l->next) { + if ((node = fb_json_node_get(l->data, "$.added", NULL))) { + added = fb_api_cb_contacts_nodes(api, node, added); + if ((node = fb_json_node_get(l->data, "$.removed", NULL))) { + removed = fb_api_cb_contacts_parse_removed(api, node, removed); + g_signal_emit_by_name(api, "contacts-delta", added, removed); + g_slist_free_full(added, (GDestroyNotify) fb_api_user_free); + g_slist_free_full(removed, (GDestroyNotify) g_free); + values = fb_json_values_new(croot); + fb_json_values_add(values, FB_JSON_TYPE_BOOL, FALSE, + "$.page_info.has_next_page"); fb_json_values_add(values, FB_JSON_TYPE_STR, FALSE,
- "$.viewer.messenger_contacts.page_info.end_cursor");
+ "$.page_info.delta_cursor"); + fb_json_values_add(values, FB_JSON_TYPE_STR, FALSE, + "$.page_info.end_cursor"); fb_json_values_update(values, NULL);
+ complete = !fb_json_values_next_bool(values, FALSE); + delta_cursor = fb_json_values_next_str(values, NULL); cursor = fb_json_values_next_str(values, NULL);
if (G_UNLIKELY(err == NULL)) {
- complete = (cursor == NULL);
- g_signal_emit_by_name(api, "contacts", users, complete);
+ if (is_delta || complete) { + g_free(priv->contacts_delta); + priv->contacts_delta = g_strdup(is_delta ? cursor : delta_cursor); + g_signal_emit_by_name(api, "contacts", users, complete); fb_api_contacts_after(api, cursor);
@@ -2118,14 +2412,25 @@
g_slist_free_full(users, (GDestroyNotify) fb_api_user_free);
fb_api_contacts(FbApi *api)
+ g_return_if_fail(FB_IS_API(api)); + if (priv->contacts_delta) { + fb_api_contacts_delta(api, priv->contacts_delta); bldr = fb_json_bldr_new(JSON_NODE_OBJECT);
fb_json_bldr_arr_begin(bldr, "0");
fb_json_bldr_add_str(bldr, NULL, "user");
@@ -2153,6 +2458,24 @@
+fb_api_contacts_delta(FbApi *api, const gchar *delta_cursor) + bldr = fb_json_bldr_new(JSON_NODE_OBJECT); + fb_json_bldr_add_str(bldr, "0", delta_cursor); + fb_json_bldr_arr_begin(bldr, "1"); + fb_json_bldr_add_str(bldr, NULL, "user"); + fb_json_bldr_arr_end(bldr); + fb_json_bldr_add_str(bldr, "2", G_STRINGIFY(FB_API_CONTACTS_COUNT)); + fb_api_http_query(api, FB_API_QUERY_CONTACTS_DELTA, bldr, fb_api_connect(FbApi *api, gboolean invisible)
@@ -2603,6 +2926,7 @@
values = fb_json_values_new(root);
@@ -2638,6 +2962,7 @@
while (fb_json_values_update(values, &err)) {
str = fb_json_values_next_str(values, "0");
uid = FB_ID_FROM_STR(str);
user = fb_api_user_dup(NULL, FALSE);
@@ -2656,8 +2981,7 @@
- if ((g_slist_length(thrd->users) < 2) || !haself) {
- fb_api_thread_reset(thrd, TRUE);
+ if (num_users < 2 || !haself) { @@ -2693,8 +3017,12 @@
if (!fb_api_thread_parse(api, &thrd, node, &err)) {
if (G_LIKELY(err == NULL)) {
- fb_api_error(api, FB_API_ERROR_GENERAL,
- _("Failed to parse thread information"));
+ g_signal_emit_by_name(api, "thread-kicked", &thrd); + fb_api_error(api, FB_API_ERROR_GENERAL, + _("Failed to parse thread information")); fb_api_error_emit(api, err);
@@ -2738,7 +3066,7 @@
values = fb_json_values_new(root);
- fb_json_values_add(values, FB_JSON_TYPE_STR, TRUE, "$.thread_fbid");
+ fb_json_values_add(values, FB_JSON_TYPE_STR, TRUE, "$.id"); fb_json_values_update(values, &err);
FB_API_ERROR_EMIT(api, err,
@@ -2785,8 +3113,8 @@
json = fb_json_bldr_close(bldr, JSON_NODE_ARRAY, NULL);
prms = fb_http_params_new();
- fb_http_params_set_str(prms, "to", json);
- fb_api_http_req(api, FB_API_URL_THREADS, "createThread", "POST",
+ fb_http_params_set_str(prms, "recipients", json); + fb_api_http_req(api, FB_API_URL_THREADS, "createGroup", "POST", prms, fb_api_cb_thread_create);
@@ -2807,7 +3135,7 @@
prms = fb_http_params_new();
fb_http_params_set_str(prms, "to", json);
- fb_http_params_set_strf(prms, "id", "t_id.%" FB_ID_FORMAT, tid);
+ fb_http_params_set_strf(prms, "id", "t_%" FB_ID_FORMAT, tid); fb_api_http_req(api, FB_API_URL_PARTS, "addMembers", "POST",
prms, fb_api_cb_http_bool);
@@ -2825,7 +3153,7 @@
prms = fb_http_params_new();
- fb_http_params_set_strf(prms, "id", "t_id.%" FB_ID_FORMAT, tid);
+ fb_http_params_set_strf(prms, "id", "t_%" FB_ID_FORMAT, tid); @@ -2850,7 +3178,7 @@
prms = fb_http_params_new();
fb_http_params_set_str(prms, "name", topic);
- fb_http_params_set_strf(prms, "tid", "t_id.%" FB_ID_FORMAT, tid);
+ fb_http_params_set_int(prms, "tid", tid); fb_api_http_req(api, FB_API_URL_TOPIC, "setThreadName",
"messaging.setthreadname", prms,
--- a/libpurple/protocols/facebook/api.h Thu Jun 15 10:48:26 2017 +0300
+++ b/libpurple/protocols/facebook/api.h Fri Jun 30 15:03:16 2017 +0300
@@ -77,6 +77,13 @@
#define FB_API_WHOST "https://www.facebook.com"
+ * The fbrpc URL prefix used in links shared from the mobile app. +#define FB_API_FBRPC_PREFIX "fbrpc://facebook/nativethirdparty" @@ -91,6 +98,30 @@
#define FB_API_SECRET "374e60f8b9bb6b8cbb30f78030438895"
+ * The part of the user agent that looks like the official client, since the + * server started checking this. +#define FB_ORCA_AGENT "[FBAN/Orca-Android;FBAV/109.0.0.17.70;FBPN/com.facebook.orca;FBLC/en_US;FBBV/52182662]" + * The HTTP User-Agent header. +#define FB_API_AGENT "Facebook plugin / Purple / 0.9.5 " FB_ORCA_AGENT + * The client information string sent in the MQTT CONNECT message +#define FB_API_MQTT_AGENT FB_API_AGENT * The URL for attachment URL requests.
@@ -131,7 +162,7 @@
* The URL for thread management requests.
-#define FB_API_URL_THREADS FB_API_GHOST "/me/threads"
+#define FB_API_URL_THREADS FB_API_GHOST "/me/group_threads" @@ -165,10 +196,8 @@
- * 5: low_res_cover_size
-#define FB_API_QUERY_CONTACTS 10153856456271729
+#define FB_API_QUERY_CONTACTS 10154444360806729 * FB_API_QUERY_CONTACTS_AFTER:
@@ -182,10 +211,24 @@
- * 6: low_res_cover_size
-#define FB_API_QUERY_CONTACTS_AFTER 10153856456281729
+#define FB_API_QUERY_CONTACTS_AFTER 10154444360816729 + * FB_API_QUERY_CONTACTS_DELTA: + * The query hash for the `FetchContactsDeltaQuery`. +#define FB_API_QUERY_CONTACTS_DELTA 10154444360801729 @@ -256,6 +299,16 @@
#define FB_API_QUERY_THREADS 10153919752026729
+ * A variant of ThreadListQuery with sequence ID +#define FB_API_QUERY_SEQ_ID 10155268192741729 * The query hash for the `XMAQuery`.
--- a/libpurple/protocols/facebook/data.c Thu Jun 15 10:48:26 2017 +0300
+++ b/libpurple/protocols/facebook/data.c Fri Jun 30 15:03:16 2017 +0300
@@ -243,6 +243,10 @@
g_object_get_property(G_OBJECT(priv->api), fb_props_strs[i],
str = g_value_get_string(&val);
+ if (purple_strequal(fb_props_strs[i], "token") && !purple_account_get_remember_password(acct)) { purple_account_set_string(acct, fb_props_strs[i], str);
--- a/libpurple/protocols/facebook/facebook.c Thu Jun 15 10:48:26 2017 +0300
+++ b/libpurple/protocols/facebook/facebook.c Fri Jun 30 15:03:16 2017 +0300
@@ -68,15 +68,18 @@
- return purple_blist_get_default_group();
+ title = _("Facebook Friends"); + title = _("Facebook Non-Friends"); - grp = purple_blist_find_group(_("Facebook Non-Friends"));
+ grp = purple_blist_find_group(title); if (G_UNLIKELY(grp == NULL)) {
- grp = purple_group_new(_("Facebook Non-Friends"));
+ grp = purple_group_new(title); for (n = purple_blist_get_root(); n != NULL; n = n->next) {
@@ -86,9 +89,10 @@
/* Append to the end of the buddy list */
purple_blist_add_group(grp, node);
- node = PURPLE_BLIST_NODE(grp);
- purple_blist_node_set_transient(node, TRUE);
- purple_blist_node_set_bool(node, "collapsed", TRUE);
+ node = PURPLE_BLIST_NODE(grp); + purple_blist_node_set_bool(node, "collapsed", TRUE); @@ -98,16 +102,13 @@
fb_buddy_add_nonfriend(PurpleAccount *acct, FbApiUser *user)
FB_ID_TO_STR(user->uid, uid);
- bdy = purple_buddy_new(acct, uid, NULL);
+ bdy = purple_buddy_new(acct, uid, user->name); grp = fb_get_group(FALSE);
- node = PURPLE_BLIST_NODE(bdy);
- purple_blist_node_set_transient(node, TRUE);
purple_buddy_set_server_alias(bdy, user->name);
purple_blist_add_buddy(bdy, NULL, grp, NULL);
@@ -212,6 +213,28 @@
+fb_sync_contacts_add_timeout(FbData *fata) + gc = fb_data_get_connection(fata); + acct = purple_connection_get_account(gc); + sync = purple_account_get_int(acct, "sync-interval", 5); + purple_account_set_int(acct, "sync-interval", 1); + fb_data_add_timeout(fata, "sync-contacts", sync, fb_cb_sync_contacts, fb_cb_api_contacts(FbApi *api, GSList *users, gboolean complete, gpointer data)
@@ -220,9 +243,6 @@
GValue val = G_VALUE_INIT;
@@ -272,7 +292,6 @@
purple_blist_add_buddy(bdy, NULL, grp, NULL);
- purple_buddy_set_protocol_data(bdy, GINT_TO_POINTER(TRUE));
purple_buddy_set_server_alias(bdy, user->name);
csum = purple_buddy_icons_get_checksum_for_user(bdy);
@@ -288,20 +307,6 @@
- buddies = purple_blist_find_buddies(acct, NULL);
- while (buddies != NULL) {
- bata = purple_buddy_get_protocol_data(bdy);
- buddies = g_slist_delete_link(buddies, buddies);
- if (GPOINTER_TO_INT(bata)) {
- purple_buddy_set_protocol_data(bdy, NULL);
- } else if (purple_buddy_get_group(bdy) != grpn) {
- purple_blist_remove_buddy(bdy);
if (state != PURPLE_CONNECTION_CONNECTED) {
status = purple_account_get_active_status(acct);
type = purple_status_get_status_type(status);
@@ -311,16 +316,52 @@
fb_api_connect(api, pstat == PURPLE_STATUS_INVISIBLE);
- sync = purple_account_get_int(acct, "sync-interval", 30);
+ fb_sync_contacts_add_timeout(fata); +fb_cb_api_contacts_delta(FbApi *api, GSList *added, GSList *removed, gpointer data) + gchar uid[FB_ID_STRMAX];
- purple_account_set_int(acct, "sync-interval", 5);
+ gc = fb_data_get_connection(fata); + acct = purple_connection_get_account(gc); + grp = fb_get_group(TRUE); + grpn = fb_get_group(FALSE); + for (l = added; l != NULL; l = l->next) { + FB_ID_TO_STR(user->uid, uid); + bdy = purple_blist_find_buddy(acct, uid); + if ((bdy != NULL) && (purple_buddy_get_group(bdy) == grpn)) { + purple_blist_remove_buddy(bdy); + bdy = purple_buddy_new(acct, uid, NULL); + purple_blist_add_buddy(bdy, NULL, grp, NULL); + purple_buddy_set_server_alias(bdy, user->name);
- fb_data_add_timeout(fata, "sync-contacts", sync, fb_cb_sync_contacts,
+ for (l = removed; l != NULL; l = l->next) { + bdy = purple_blist_find_buddy(acct, l->data); + purple_blist_remove_buddy(bdy); + fb_sync_contacts_add_timeout(fata); @@ -397,8 +438,18 @@
case FB_API_EVENT_TYPE_THREAD_USER_ADDED:
if (purple_blist_find_buddy(acct, uid) == NULL) {
- g_hash_table_insert(fetch, &event->tid, event);
+ FbApiUser *user = fb_api_user_dup(NULL, FALSE); + user->uid = event->uid; + user->name = g_strdup(event->text); + fb_buddy_add_nonfriend(acct, user); + fb_api_user_free(user); + g_hash_table_insert(fetch, &event->tid, event); purple_chat_conversation_add_user(chat, uid, NULL, 0,
@@ -406,7 +457,7 @@
case FB_API_EVENT_TYPE_THREAD_USER_REMOVED:
- purple_chat_conversation_remove_user(chat, uid, NULL);
+ purple_chat_conversation_remove_user(chat, uid, event->text); @@ -664,6 +715,39 @@
+fb_cb_api_thread_kicked(FbApi *api, FbApiThread *thrd, gpointer data) + gchar tid[FB_ID_STRMAX]; + PurpleChatConversation *chat; + FB_ID_TO_STR(thrd->tid, tid); + gc = fb_data_get_connection(fata); + acct = purple_connection_get_account(gc); + chat = purple_conversations_find_chat_with_account(tid, acct); + PurpleRequestCommonParameters *cpar; + cpar = purple_request_cpar_from_connection(gc); + purple_notify_error(gc, + _("Failed to Join Chat"), + _("You have been removed from this chat"), + purple_conversation_write_system_message(PURPLE_CONVERSATION(chat), + _("You have been removed from this chat"), 0); + purple_serv_got_chat_left(gc, purple_chat_conversation_get_id(chat)); fb_cb_api_threads(FbApi *api, GSList *thrds, gpointer data)
@@ -743,11 +827,32 @@
+fb_mark_read(FbData *fata, FbId id, gboolean thread) + gc = fb_data_get_connection(fata); + acct = purple_connection_get_account(gc); + api = fb_data_get_api(fata); + if (!fb_data_get_unread(fata, id) || + (purple_account_get_bool(acct, "mark-read-available", FALSE) && + fb_api_is_invisible(api))) + fb_data_set_unread(fata, id, FALSE); + fb_api_read(api, id, thread); fb_cb_conv_read(gpointer data)
@@ -763,15 +868,9 @@
fb_data_clear_timeout(fata, tname, FALSE);
- if (!purple_conversation_has_focus(conv) ||
- !fb_data_get_unread(fata, id))
+ if (purple_conversation_has_focus(conv)) { + fb_mark_read(fata, id, PURPLE_IS_CHAT_CONVERSATION(conv));
- api = fb_data_get_api(fata);
- fb_data_set_unread(fata, id, FALSE);
- fb_api_read(api, id, PURPLE_IS_CHAT_CONVERSATION(conv));
@@ -918,6 +1017,10 @@
G_CALLBACK(fb_cb_api_contacts),
+ G_CALLBACK(fb_cb_api_contacts_delta), G_CALLBACK(fb_cb_api_error),
@@ -942,6 +1045,10 @@
G_CALLBACK(fb_cb_api_thread_create),
+ G_CALLBACK(fb_cb_api_thread_kicked), G_CALLBACK(fb_cb_api_threads),
@@ -961,7 +1068,7 @@
G_CALLBACK(fb_cb_conv_deleting),
- if (!fb_data_load(fata)) {
+ if (!fb_data_load(fata) || !purple_account_get_remember_password(acct)) { user = purple_account_get_username(acct);
pass = purple_connection_get_password(gc);
purple_connection_update_progress(gc, _("Authenticating"),
@@ -1437,13 +1544,17 @@
protocol->options = OPT_PROTO_CHAT_TOPIC;
opt = purple_account_option_int_new(_("Buddy list sync interval"),
opts = g_list_prepend(opts, opt);
- opt = purple_account_option_bool_new(_("Mark messages as read"),
+ opt = purple_account_option_bool_new(_("Mark messages as read on focus"), opts = g_list_prepend(opts, opt);
+ opt = purple_account_option_bool_new(_("Mark messages as read only when available"), + "mark-read-available", FALSE); + opts = g_list_prepend(opts, opt); opt = purple_account_option_bool_new(_("Show self messages"),
opts = g_list_prepend(opts, opt);
--- a/libpurple/protocols/facebook/marshaller.list Thu Jun 15 10:48:26 2017 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
--- a/libpurple/protocols/facebook/mqtt.c Thu Jun 15 10:48:26 2017 +0300
+++ b/libpurple/protocols/facebook/mqtt.c Fri Jun 30 15:03:16 2017 +0300
@@ -31,7 +31,6 @@
#include "queuedoutputstream.h"
@@ -97,8 +96,7 @@
G_TYPE_FROM_CLASS(klass),
@@ -114,8 +112,7 @@
G_TYPE_FROM_CLASS(klass),
- fb_marshal_VOID__OBJECT,
@@ -131,8 +128,7 @@
G_TYPE_FROM_CLASS(klass),
@@ -148,8 +144,7 @@
G_TYPE_FROM_CLASS(klass),
- fb_marshal_VOID__STRING_BOXED,
2, G_TYPE_STRING, G_TYPE_BYTE_ARRAY);
@@ -440,8 +435,10 @@
/* Not enough data yet, try again later */
+ g_buffered_input_stream_fill_async(priv->input, -1, + G_PRIORITY_DEFAULT, priv->cancellable, + fb_mqtt_cb_fill, mqtt); @@ -450,28 +447,22 @@
} while ((byte & 128) != 0);
- /* Add header to size */
+ /* Add header to size */ - g_byte_array_set_size(priv->rbuf, size);
+ g_byte_array_set_size(priv->rbuf, size); - /* TODO: Use g_input_stream_read_all_async() when available. */
- /* TODO: Alternately, it would be nice to let the
- * FbMqttMessage directly use the GBufferedInputStream
- * buffer instead of copying it, provided it's consumed
- * before the next read.
- g_input_stream_read_async(G_INPUT_STREAM(priv->input),
- priv->rbuf->data, priv->rbuf->len,
- G_PRIORITY_DEFAULT, priv->cancellable,
- fb_mqtt_cb_read_packet, mqtt);
- g_buffered_input_stream_fill_async(priv->input, -1,
- G_PRIORITY_DEFAULT, priv->cancellable,
- fb_mqtt_cb_fill, mqtt);
+ /* TODO: Use g_input_stream_read_all_async() when available. */ + /* TODO: Alternately, it would be nice to let the + * FbMqttMessage directly use the GBufferedInputStream + * buffer instead of copying it, provided it's consumed + * before the next read. + g_input_stream_read_async(G_INPUT_STREAM(priv->input), + priv->rbuf->data, priv->rbuf->len, + G_PRIORITY_DEFAULT, priv->cancellable, + fb_mqtt_cb_read_packet, mqtt); --- a/libpurple/protocols/jabber/tests/Makefile.am Thu Jun 15 10:48:26 2017 +0300
+++ b/libpurple/protocols/jabber/tests/Makefile.am Fri Jun 30 15:03:16 2017 +0300
@@ -33,5 +33,4 @@
--- a/libpurple/protocols/oscar/tests/Makefile.am Thu Jun 15 10:48:26 2017 +0300
+++ b/libpurple/protocols/oscar/tests/Makefile.am Fri Jun 30 15:03:16 2017 +0300
@@ -19,5 +19,4 @@
--- a/libpurple/protocols/simple/Makefile.am Thu Jun 15 10:48:26 2017 +0300
+++ b/libpurple/protocols/simple/Makefile.am Fri Jun 30 15:03:16 2017 +0300
@@ -14,6 +14,7 @@
libsimple_la_LDFLAGS = -module @PLUGIN_LDFLAGS@
+libsimple_la_LIBADD = $(NETTLE_LIBS) @@ -27,7 +28,7 @@
pkg_LTLIBRARIES = libsimple.la
libsimple_la_SOURCES = $(SIMPLESOURCES)
-libsimple_la_LIBADD = @PURPLE_LIBS@
+libsimple_la_LIBADD += @PURPLE_LIBS@ @@ -36,4 +37,5 @@
-I$(top_builddir)/libpurple \
--- a/libpurple/protocols/simple/ntlm.c Thu Jun 15 10:48:26 2017 +0300
+++ b/libpurple/protocols/simple/ntlm.c Fri Jun 30 15:03:16 2017 +0300
@@ -26,8 +26,10 @@
-#include "ciphers/descipher.h"
-#include "ciphers/md4hash.h"
@@ -112,6 +114,7 @@
* Create a 64bit DES key by taking a 56bit key and adding
* a parity bit after every 7th bit.
@@ -130,19 +133,15 @@
- * helper function for purple cipher.c
+ * helper function for des encryption des_ecb_encrypt(const guint8 *plaintext, guint8 *result, const guint8 *key)
- cipher = purple_des_cipher_new();
- purple_cipher_set_key(cipher, key, 8);
- encsiz = purple_cipher_encrypt(cipher, plaintext, 8, result, 8);
- g_warn_if_fail(encsiz == 8);
- g_object_unref(cipher);
+ des_set_key(&ctx, key); + des_encrypt(&ctx, DES_BLOCK_SIZE, result, plaintext); @@ -201,10 +200,12 @@
buffer[i] = (char)(g_random_int() & 0xff);
+#endif /* HAVE_NETTLE */ purple_ntlm_gen_type3(const gchar *username, const gchar *passw, const gchar *hostname, const gchar *domain, const guint8 *nonce, guint32 *flags)
unsigned char lm_hpw[21];
@@ -219,7 +220,7 @@
unsigned char magic[] = { 0x4B, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25 };
unsigned char nt_hpw[21];
@@ -320,10 +321,9 @@
- hash = purple_md4_hash_new();
- purple_hash_append(hash, (guint8 *)nt_pw, 2 * lennt);
- purple_hash_digest(hash, nt_hpw, sizeof(nt_hpw));
+ md4_update(&ctx, 2 * lennt, (uint8_t *)nt_pw); + md4_digest(&ctx, MD4_DIGEST_SIZE, nt_hpw); memset(nt_hpw + 16, 0, 5);
calc_resp(nt_hpw, nonce, nt_resp);
@@ -344,4 +344,8 @@
+ /* Used without support enabled */ + g_return_val_if_reached(NULL); +#endif /* HAVE_NETTLE */ --- a/libpurple/protocols/simple/simple.c Thu Jun 15 10:48:26 2017 +0300
+++ b/libpurple/protocols/simple/simple.c Fri Jun 30 15:03:16 2017 +0300
@@ -265,11 +265,8 @@
- const char *authdomain;
- authdomain = purple_account_get_string(sip->account, "authdomain", "");
authuser = purple_account_get_string(sip->account, "authuser", sip->username);
if(!authuser || strlen(authuser) < 1) {
@@ -287,6 +284,13 @@
} else if(auth->type == 2) { /* NTLM */
+ const gchar *authdomain; + authdomain = purple_account_get_string(sip->account, if(auth->nc == 3 && auth->nonce) {
/* TODO: Don't hardcode "purple" as the hostname */
ret = purple_ntlm_gen_type3(authuser, sip->password, "purple", authdomain, (const guint8 *)auth->nonce, &auth->flags);
@@ -296,6 +300,10 @@
tmp = g_strdup_printf("NTLM qop=\"auth\", realm=\"%s\", targetname=\"%s\", gssapi-data=\"\"", auth->realm, auth->target);
+ /* Used without support enabled */ + g_return_val_if_reached(NULL); +#endif /* HAVE_NETTLE */ sprintf(noncecount, "%08d", auth->nc++);
@@ -350,6 +358,7 @@
if(!g_ascii_strncasecmp(hdr, "NTLM", 4)) {
purple_debug_info("simple", "found NTLM\n");
parts = g_strsplit(hdr+5, "\",", 0);
@@ -382,6 +391,11 @@
+ purple_debug_error("simple", "NTLM auth unsupported without " + "libnettle support. Please rebuild with " + "libnettle support for this feature.\n"); +#endif /* HAVE_NETTLE */ } else if(!g_ascii_strncasecmp(hdr, "DIGEST", 6)) {
purple_debug_info("simple", "found DIGEST\n");
--- a/libpurple/protocols/simple/simple.h Thu Jun 15 10:48:26 2017 +0300
+++ b/libpurple/protocols/simple/simple.h Fri Jun 30 15:03:16 2017 +0300
@@ -28,7 +28,6 @@
#include "circularbuffer.h"
--- a/libpurple/purple.h.in Thu Jun 15 10:48:26 2017 +0300
+++ b/libpurple/purple.h.in Fri Jun 30 15:03:16 2017 +0300
@@ -53,7 +53,6 @@
#include <circularbuffer.h>
--- a/libpurple/smiley-list.c Thu Jun 15 10:48:26 2017 +0300
+++ b/libpurple/smiley-list.c Fri Jun 30 15:03:16 2017 +0300
@@ -26,6 +26,8 @@
#include "smiley-parser.h"
#define PURPLE_SMILEY_LIST_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_SMILEY_LIST, \
PurpleSmileyListPrivate))
--- a/libpurple/stun.c Thu Jun 15 10:48:26 2017 +0300
+++ b/libpurple/stun.c Fri Jun 30 15:03:16 2017 +0300
@@ -254,7 +254,7 @@
ifc.ifc_req = buffer_ifr;
ioctl(source, SIOCGIFCONF, &ifc);
+ it = (guchar *)buffer_ifr; it_end = it + ifc.ifc_len;
ifr = (struct ifreq*)(gpointer)it;
--- a/libpurple/tests/Makefile.am Thu Jun 15 10:48:26 2017 +0300
+++ b/libpurple/tests/Makefile.am Fri Jun 30 15:03:16 2017 +0300
@@ -6,28 +6,16 @@
-test_des_SOURCES=test_des.c
-test_des_LDADD=$(COMMON_LIBS)
-test_des3_SOURCES=test_des3.c
-test_des3_LDADD=$(COMMON_LIBS)
test_image_SOURCES=test_image.c
test_image_LDADD=$(COMMON_LIBS)
-test_md4_SOURCES=test_md4.c
-test_md4_LDADD=$(COMMON_LIBS)
test_smiley_SOURCES=test_smiley.c
test_smiley_LDADD=$(COMMON_LIBS)
@@ -51,8 +39,7 @@
--- a/libpurple/tests/test_des.c Thu Jun 15 10:48:26 2017 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
- * 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
- * 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 "ciphers/descipher.h"
-test_des_cipher(const gchar *in, const gchar *key, const gchar *out, size_t len) {
- PurpleCipher *cipher = NULL;
- guchar *decrypt = NULL, *encrypt = NULL, *answer = NULL;
- decrypt = g_memdup(in, len + 1);
- encrypt = g_memdup(out, len + 1);
- cipher = purple_des_cipher_new();
- purple_cipher_set_key(cipher, (const guchar *)key, 8);
- answer = g_new0(guchar, len + 1);
- ret = purple_cipher_encrypt(cipher, decrypt, len, answer, len);
- g_assert_cmpmem(encrypt, len, answer, len);
- answer = g_new0(guchar, len + 1);
- ret = purple_cipher_decrypt(cipher, encrypt, len, answer, len);
- g_assert_cmpmem(decrypt, len, answer, len);
- g_object_unref(G_OBJECT(cipher));
-test_des_cipher_12345678(void) {
- "\x3b\x38\x98\x37\x15\x20\xf7\x5e",
- "\x06\x22\x05\xac\x6a\x0d\x55\xdd",
-test_des_cipher_abcdefgh(void) {
- "\x3b\x38\x98\x37\x15\x20\xf7\x5e",
- "\x62\xe0\xc6\x8c\x48\xe4\x75\xed",
-main(gint argc, gchar **argv) {
- g_test_init(&argc, &argv, NULL);
- g_test_add_func("/cipher/des/12345678",
- test_des_cipher_12345678);
- g_test_add_func("/cipher/des/abcdefgh",
- test_des_cipher_abcdefgh);
--- a/libpurple/tests/test_des3.c Thu Jun 15 10:48:26 2017 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,245 +0,0 @@
- * 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
- * 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 "ciphers/des3cipher.h"
-/******************************************************************************
- * See http://csrc.nist.gov/groups/ST/toolkit/examples.html
- * and some NULL things I made up
- *****************************************************************************/
-test_des3_cipher(const gchar *in, const gchar *key, const gchar *iv,
- const gchar *out, size_t len, PurpleCipherBatchMode mode)
- PurpleCipher *cipher = NULL;
- guchar *decrypt = NULL, *encrypt = NULL, *answer = NULL;
- decrypt = g_memdup(in, len + 1);
- encrypt = g_memdup(out, len + 1);
- cipher = purple_des3_cipher_new();
- purple_cipher_set_key(cipher, (const guchar *)key, 24);
- purple_cipher_set_batch_mode(cipher, mode);
- purple_cipher_set_iv(cipher, (guchar *)iv, 8);
- answer = g_new0(guchar, len + 1);
- ret = purple_cipher_encrypt(cipher, decrypt, len, answer, len);
- g_assert_cmpmem(encrypt, len, answer, len);
- answer = g_new0(guchar, len + 1);
- ret = purple_cipher_decrypt(cipher, encrypt, len, answer, len);
- g_assert_cmpmem(decrypt, len, answer, len);
- g_object_unref(G_OBJECT(cipher));
-test_des3_cipher_ecb_nist1(void) {
- "\x6B\xC1\xBE\xE2\x2E\x40\x9F\x96\xE9\x3D\x7E\x11\x73\x93\x17\x2A"
- "\xAE\x2D\x8A\x57\x1E\x03\xAC\x9C\x9E\xB7\x6F\xAC\x45\xAF\x8E\x51",
- "\x01\x23\x45\x67\x89\xAB\xCD\xEF"
- "\x23\x45\x67\x89\xAB\xCD\xEF\x01"
- "\x45\x67\x89\xAB\xCD\xEF\x01\x23",
- "00000000", /* ignored */
- "\x71\x47\x72\xF3\x39\x84\x1D\x34\x26\x7F\xCC\x4B\xD2\x94\x9C\xC3"
- "\xEE\x11\xC2\x2A\x57\x6A\x30\x38\x76\x18\x3F\x99\xC0\xB6\xDE\x87",
- PURPLE_CIPHER_BATCH_MODE_ECB
-test_des3_cipher_ecb_nist2(void) {
- "\x6B\xC1\xBE\xE2\x2E\x40\x9F\x96\xE9\x3D\x7E\x11\x73\x93\x17\x2A"
- "\xAE\x2D\x8A\x57\x1E\x03\xAC\x9C\x9E\xB7\x6F\xAC\x45\xAF\x8E\x51",
- "\x01\x23\x45\x67\x89\xAB\xCD\xEF"
- "\x23\x45\x67\x89\xAB\xCD\xEF\x01"
- "\x01\x23\x45\x67\x89\xAB\xCD\xEF",
- "00000000", /* ignored */
- "\x06\xED\xE3\xD8\x28\x84\x09\x0A\xFF\x32\x2C\x19\xF0\x51\x84\x86"
- "\x73\x05\x76\x97\x2A\x66\x6E\x58\xB6\xC8\x8C\xF1\x07\x34\x0D\x3D",
- PURPLE_CIPHER_BATCH_MODE_ECB
-test_des3_cipher_ecb_null_key(void) {
- "\x16\xf4\xb3\x77\xfd\x4b\x9e\xca",
- "\x38\x00\x88\x6a\xef\xcb\x00\xad"
- "\x5d\xe5\x29\x00\x7d\x98\x64\x4c"
- "\x86\x00\x7b\xd3\xc7\x00\x7b\x32",
- "00000000", /* ignored */
- "\xc0\x60\x30\xa1\xb7\x25\x42\x44",
- PURPLE_CIPHER_BATCH_MODE_ECB
-test_des3_cipher_ecb_null_text(void) {
- "\x65\x73\x34\xc1\x19\x00\x79\x65",
- "\x32\x64\xda\x10\x13\x6a\xfe\x1e"
- "\x37\x54\xd1\x2c\x41\x04\x10\x40"
- "\xaf\x1c\x75\x2b\x51\x3a\x03\xf5",
- "00000000", /* ignored */
- "\xe5\x80\xf6\x12\xf8\x4e\xd9\x6c",
- PURPLE_CIPHER_BATCH_MODE_ECB
-test_des3_cipher_ecb_null_key_and_text(void) {
- "\xdf\x7f\x00\x92\xe7\xc1\x49\xd2",
- "\x0e\x41\x00\xc4\x8b\xf0\x6e\xa1"
- "\x66\x49\x42\x63\x22\x00\xf0\x99"
- "\x6b\x22\xc1\x37\x9c\x00\xe4\x8f",
- "00000000", /* ignored */
- "\x73\xd8\x1f\x1f\x50\x01\xe4\x79",
- PURPLE_CIPHER_BATCH_MODE_ECB
-test_des3_cipher_cbc_nist1(void) {
- "\x6B\xC1\xBE\xE2\x2E\x40\x9F\x96\xE9\x3D\x7E\x11\x73\x93\x17\x2A"
- "\xAE\x2D\x8A\x57\x1E\x03\xAC\x9C\x9E\xB7\x6F\xAC\x45\xAF\x8E\x51",
- "\x01\x23\x45\x67\x89\xAB\xCD\xEF"
- "\x23\x45\x67\x89\xAB\xCD\xEF\x01"
- "\x45\x67\x89\xAB\xCD\xEF\x01\x23",
- "\xF6\x9F\x24\x45\xDF\x4F\x9B\x17",
- "\x20\x79\xC3\xD5\x3A\xA7\x63\xE1\x93\xB7\x9E\x25\x69\xAB\x52\x62"
- "\x51\x65\x70\x48\x1F\x25\xB5\x0F\x73\xC0\xBD\xA8\x5C\x8E\x0D\xA7",
- PURPLE_CIPHER_BATCH_MODE_CBC
-test_des3_cipher_cbc_nist2(void) {
- "\x6B\xC1\xBE\xE2\x2E\x40\x9F\x96\xE9\x3D\x7E\x11\x73\x93\x17\x2A"
- "\xAE\x2D\x8A\x57\x1E\x03\xAC\x9C\x9E\xB7\x6F\xAC\x45\xAF\x8E\x51",
- "\x01\x23\x45\x67\x89\xAB\xCD\xEF"
- "\x23\x45\x67\x89\xAB\xCD\xEF\x01"
- "\x01\x23\x45\x67\x89\xAB\xCD\xEF",
- "\xF6\x9F\x24\x45\xDF\x4F\x9B\x17",
- "\x74\x01\xCE\x1E\xAB\x6D\x00\x3C\xAF\xF8\x4B\xF4\x7B\x36\xCC\x21"
- "\x54\xF0\x23\x8F\x9F\xFE\xCD\x8F\x6A\xCF\x11\x83\x92\xB4\x55\x81",
- PURPLE_CIPHER_BATCH_MODE_CBC
-test_des3_cipher_cbc_null_key(void) {
- "\x16\xf4\xb3\x77\xfd\x4b\x9e\xca",
- "\x38\x00\x88\x6a\xef\xcb\x00\xad"
- "\x5d\xe5\x29\x00\x7d\x98\x64\x4c"
- "\x86\x00\x7b\xd3\xc7\x00\x7b\x32",
- "\x31\x32\x33\x34\x35\x36\x37\x38",
- "\x52\xe7\xde\x96\x39\x87\x87\xdb",
- PURPLE_CIPHER_BATCH_MODE_CBC
-test_des3_cipher_cbc_null_text(void) {
- "\x65\x73\x34\xc1\x19\x00\x79\x65",
- "\x32\x64\xda\x10\x13\x6a\xfe\x1e"
- "\x37\x54\xd1\x2c\x41\x04\x10\x40"
- "\xaf\x1c\x75\x2b\x51\x3a\x03\xf5",
- "\x7C\xAF\x0D\x57\x1E\x57\x10\xDA",
- "\x40\x12\x0e\x00\x85\xff\x6c\xc2",
- PURPLE_CIPHER_BATCH_MODE_CBC
-test_des3_cipher_cbc_null_key_and_text(void) {
- "\xdf\x7f\x00\x92\xe7\xc1\x49\xd2",
- "\x0e\x41\x00\xc4\x8b\xf0\x6e\xa1"
- "\x66\x49\x42\x63\x22\x00\xf0\x99"
- "\x6b\x22\xc1\x37\x9c\x00\xe4\x8f",
- "\x01\x19\x0D\x2c\x40\x67\x89\x67",
- "\xa7\xc1\x10\xbe\x9b\xd5\x8a\x67",
- PURPLE_CIPHER_BATCH_MODE_CBC
-main(gint argc, gchar **argv) {
- g_test_init(&argc, &argv, NULL);
- g_test_add_func("/cipher/des3/ecb nist1",
- test_des3_cipher_ecb_nist1);
- g_test_add_func("/cipher/des3/ecb nist2",
- test_des3_cipher_ecb_nist2);
- g_test_add_func("/cipher/des3/ecb null key",
- test_des3_cipher_ecb_null_key);
- g_test_add_func("/cipher/des3/ecb null text",
- test_des3_cipher_ecb_null_text);
- g_test_add_func("/cipher/des3/ebc null key and text",
- test_des3_cipher_ecb_null_key_and_text);
- g_test_add_func("/cipher/des3/cbc nist1",
- test_des3_cipher_cbc_nist1);
- g_test_add_func("/cipher/des3/cbc nist2",
- test_des3_cipher_cbc_nist2);
- g_test_add_func("/cipher/des3/cbc null key",
- test_des3_cipher_cbc_null_key);
- g_test_add_func("/cipher/des3/cbc null text",
- test_des3_cipher_cbc_null_text);
- g_test_add_func("/cipher/des3/cbc null key and text",
- test_des3_cipher_cbc_null_key_and_text);
--- a/libpurple/tests/test_image.c Thu Jun 15 10:48:26 2017 +0300
+++ b/libpurple/tests/test_image.c Fri Jun 30 15:03:16 2017 +0300
@@ -21,6 +21,7 @@
--- a/libpurple/tests/test_md4.c Thu Jun 15 10:48:26 2017 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,107 +0,0 @@
- * 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
- * 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 "ciphers/md4hash.h"
-test_md4hash(gchar *data, gchar *digest) {
- PurpleHash *hash = NULL;
- hash = purple_md4_hash_new();
- purple_hash_append(hash, (guchar *)data, strlen(data));
- ret = purple_hash_digest_to_str(hash, cdigest, sizeof(cdigest));
- g_assert_cmpstr(digest, ==, cdigest);
-test_md4hash_empty_string(void) {
- "31d6cfe0d16ae931b73c59d7e0c089c0");
- "bde52cb31de33e46245e05fbdbd6fb24");
-test_md4hash_abc(void) {
- "a448017aaf21d8525fc10ae87aa6729d");
-test_md4hash_message_digest(void) {
- test_md4hash("message digest",
- "d9130a8164549fe818874806e1c7014b");
-test_md4hash_a_to_z(void) {
- test_md4hash("abcdefghijklmnopqrstuvwxyz",
- "d79e1c308aa5bbcdeea8ed63df412da9");
-test_md4hash_A_to_Z_a_to_z_0_to_9(void) {
- test_md4hash("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
- "043f8582f241db351ce627e153e7f0e4");
-test_md4hash_1_to_0_eight_times(void) {
- test_md4hash("12345678901234567890123456789012345678901234567890123456789012345678901234567890",
- "e33b4ddc9c38f2199c3e7b164fcc0536");
-main(gint argc, gchar **argv) {
- g_test_init(&argc, &argv, NULL);
- g_test_add_func("/hash/md4/empty-string",
- test_md4hash_empty_string);
- g_test_add_func("/hash/md4/a",
- g_test_add_func("/hash/md4/abc",
- g_test_add_func("/hash/md4/message digest",
- test_md4hash_message_digest);
- g_test_add_func("/hash/md4/a to z",
- g_test_add_func("/hash/md4/A to Z, a to z, 0 to 9" ,
- test_md4hash_A_to_Z_a_to_z_0_to_9);
- g_test_add_func("/hash/md4/1 to 0 eight times",
- test_md4hash_1_to_0_eight_times);
--- a/libpurple/tests/test_smiley.c Thu Jun 15 10:48:26 2017 +0300
+++ b/libpurple/tests/test_smiley.c Fri Jun 30 15:03:16 2017 +0300
@@ -21,6 +21,7 @@
--- a/libpurple/xfer.c Thu Jun 15 10:48:26 2017 +0300
+++ b/libpurple/xfer.c Fri Jun 30 15:03:16 2017 +0300
@@ -1920,12 +1920,14 @@
gsize size, const gchar *mimetype)
PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer);
+ gpointer old_thumbnail_data; g_return_if_fail(priv != NULL);
/* Hold onto these in case they are equal to passed-in pointers */
- gpointer *old_thumbnail_data = priv->thumbnail_data;
- const gchar *old_mimetype = priv->thumbnail_mimetype;
+ old_thumbnail_data = priv->thumbnail_data; + old_mimetype = priv->thumbnail_mimetype; if (thumbnail && size > 0) {
priv->thumbnail_data = g_memdup(thumbnail, size);
--- a/pidgin/Makefile.am Thu Jun 15 10:48:26 2017 +0300
+++ b/pidgin/Makefile.am Fri Jun 30 15:03:16 2017 +0300
@@ -4,6 +4,7 @@
data/pidgin.appdata.xml.in \
@@ -55,7 +56,6 @@
@@ -72,7 +72,6 @@
@@ -85,6 +84,7 @@
@@ -103,7 +103,6 @@
@@ -121,7 +120,6 @@
@@ -172,18 +170,22 @@
libpidgininclude_HEADERS = \
-libpidgin_la_builtheaders = gtkdebug.html.h
+libpidgin_la_builtheaders = pidgin.gresource.h +libpidgin_la_builtsources = pidgin.gresource.c -BUILT_SOURCES = $(libpidgin_la_builtheaders)
+BUILT_SOURCES = $(libpidgin_la_builtheaders) $(libpidgin_la_builtsources) -CLEANFILES = gtkdebug.html.h
+CLEANFILES = pidgin.gresource.h pidgin.gresource.c
- $(AM_V_GEN)echo "static const char $*_html[] = {" > $@
- $(AM_V_at)$(sedpath) -e 's/^[ ]\+//g' -e 's/[ ]\+/ /g' $< | $(xxdpath) -i | sed -e 's/\(0x[0-9a-f][0-9a-f]\)$$/\1, 0x00/' >> $@
- $(AM_V_at)echo "};" >> $@
+%.gresource.h: %.gresource.xml + $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --generate-header --target $@ --c-name $* --sourcedir $(srcdir) $< -gtkdebug.c: gtkdebug.html.h
+%.gresource.c: %.gresource.xml + $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --generate-source --target $@ --c-name $* --sourcedir $(srcdir) $< +pidgin.gresource.c: gtkdebug.html +pidgin.gresource.h: gtkdebug.html +gtkdebug.c: pidgin.gresource.h libpidgin_la_DEPENDENCIES = @LIBOBJS@ $(LIBPIDGIN_WIN32RES)
libpidgin_la_LDFLAGS = -export-dynamic -no-undefined \
@@ -199,7 +201,6 @@
--- a/pidgin/Makefile.mingw Thu Jun 15 10:48:26 2017 +0300
+++ b/pidgin/Makefile.mingw Fri Jun 30 15:03:16 2017 +0300
@@ -71,7 +71,6 @@
--- a/pidgin/gtkdebug.c Thu Jun 15 10:48:26 2017 +0300
+++ b/pidgin/gtkdebug.c Fri Jun 30 15:03:16 2017 +0300
@@ -40,7 +40,7 @@
-#include "gtkdebug.html.h"
+#include "pidgin.gresource.h" @@ -409,7 +409,10 @@
+ GBytes *resource_bytes; @@ -586,7 +589,25 @@
frame = pidgin_create_webview(FALSE, &win->text, NULL);
pidgin_webview_set_format_functions(PIDGIN_WEBVIEW(win->text),
PIDGIN_WEBVIEW_ALL ^ PIDGIN_WEBVIEW_SMILEY ^ PIDGIN_WEBVIEW_IMAGE);
- pidgin_webview_load_html_string(PIDGIN_WEBVIEW(win->text), gtkdebug_html);
+ resource = pidgin_get_resource(); + resource_bytes = g_resource_lookup_data(resource, + "/im/pidgin/Pidgin/gtkdebug.html", + G_RESOURCE_LOOKUP_FLAGS_NONE, + if (G_UNLIKELY(resource_bytes == NULL || error != NULL)) { + gchar *msg = g_strdup_printf("Unable to load debug window HTML: %s\n", + error ? error->message : "Unknown error"); + pidgin_webview_load_html_string(PIDGIN_WEBVIEW(win->text), msg); + gconstpointer gtkdebug_html; + gtkdebug_html = g_bytes_get_data(resource_bytes, NULL); + pidgin_webview_load_html_string(PIDGIN_WEBVIEW(win->text), + g_bytes_unref(resource_bytes); gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0);
--- a/pidgin/gtkdialogs.c Thu Jun 15 10:48:26 2017 +0300
+++ b/pidgin/gtkdialogs.c Fri Jun 30 15:03:16 2017 +0300
@@ -696,12 +696,6 @@
- g_string_append(str, "<dt>X Session Management:</dt><dd>Enabled</dd>");
- g_string_append(str, "<dt>X Session Management:</dt><dd>Disabled</dd>");
g_string_append(str, "<dt>XScreenSaver:</dt><dd>Enabled</dd>");
--- a/pidgin/gtkeventloop.c Thu Jun 15 10:48:26 2017 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,124 +0,0 @@
- * Pidgin is the legal property of its developers, whose names are too numerous
- * to list here. Please refer to the COPYRIGHT file distributed with this
- * 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 "gtkeventloop.h"
-#define PIDGIN_READ_COND (G_IO_IN | G_IO_HUP | G_IO_ERR)
-#define PIDGIN_WRITE_COND (G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL)
-typedef struct _PidginIOClosure {
- PurpleInputFunction function;
-static gboolean pidgin_io_invoke(GIOChannel *source, GIOCondition condition, gpointer data)
- PidginIOClosure *closure = data;
- PurpleInputCondition purple_cond = 0;
- if (condition & PIDGIN_READ_COND)
- purple_cond |= PURPLE_INPUT_READ;
- if (condition & PIDGIN_WRITE_COND)
- purple_cond |= PURPLE_INPUT_WRITE;
- purple_debug_misc("gtk_eventloop",
- "CLOSURE: callback for %d, fd is %d\n",
- closure->result, g_io_channel_unix_get_fd(source));
- purple_debug_misc("gtk_eventloop",
- "CLOSURE received GIOCondition of 0x%x, which does not"
- " match 0x%x (READ) or 0x%x (WRITE)\n",
- condition, PIDGIN_READ_COND, PIDGIN_WRITE_COND);
- closure->function(closure->data, g_io_channel_unix_get_fd(source),
-static guint pidgin_input_add(gint fd, PurpleInputCondition condition, PurpleInputFunction function,
- PidginIOClosure *closure = g_new0(PidginIOClosure, 1);
- closure->function = function;
- if (condition & PURPLE_INPUT_READ)
- cond |= PIDGIN_READ_COND;
- if (condition & PURPLE_INPUT_WRITE)
- cond |= PIDGIN_WRITE_COND;
- channel = g_io_channel_win32_new_socket(fd);
- channel = g_io_channel_unix_new(fd);
- closure->result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond,
- pidgin_io_invoke, closure, g_free);
- purple_debug_misc("gtk_eventloop",
- "CLOSURE: adding input watcher %d for fd %d\n",
- g_io_channel_unref(channel);
- return closure->result;
-static PurpleEventLoopUiOps eventloop_ops =
- NULL, /* input_get_error */
-pidgin_eventloop_get_ui_ops(void)
--- a/pidgin/gtkeventloop.h Thu Jun 15 10:48:26 2017 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
- * Pidgin is the legal property of its developers, whose names are too numerous
- * to list here. Please refer to the COPYRIGHT file distributed with this
- * 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 _PIDGINEVENTLOOP_H_
-#define _PIDGINEVENTLOOP_H_
- * @section_id: pidgin-gtkeventloop
- * @short_description: <filename>gtkeventloop.h</filename>
- * @title: Event Loop Implementation
- * pidgin_eventloop_get_ui_ops:
- * Returns the GTK+ event loop UI operations structure.
- * Returns: The GTK+ event loop UI operations structure.
-PurpleEventLoopUiOps *pidgin_eventloop_get_ui_ops(void);
-#endif /* _PIDGINEVENTLOOP_H_ */
--- a/pidgin/gtksession.c Thu Jun 15 10:48:26 2017 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,414 +0,0 @@
-/* Pidgin is the legal property of its developers, whose names are too numerous
- * to list here. Please refer to the COPYRIGHT file distributed with this
- * 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 <X11/ICE/ICElib.h>
-#include <X11/SM/SMlib.h>
-#define ERROR_LENGTH 512
-static IceIOErrorHandler ice_installed_io_error_handler;
-static SmcConn session = NULL;
-static gchar *myself = NULL;
-static gboolean had_first_save = FALSE;
-static gboolean session_managed = FALSE;
-/* ICE belt'n'braces stuff */
-struct ice_connection_info {
-static void ice_process_messages(gpointer data, gint fd,
- PurpleInputCondition condition) {
- struct ice_connection_info *conninfo = (struct ice_connection_info*) data;
- IceProcessMessagesStatus status;
- /* please don't block... please! */
- status = IceProcessMessages(conninfo->connection, NULL, NULL);
- if (status == IceProcessMessagesIOError) {
- purple_debug(PURPLE_DEBUG_INFO, "Session Management",
- "ICE IO error, closing connection... ");
- /* IO error, please disconnect */
- IceSetShutdownNegotiation(conninfo->connection, False);
- IceCloseConnection(conninfo->connection);
- if (purple_debug_is_verbose()) {
- purple_debug_misc("Session Management",
- /* cancel the handler */
- purple_input_remove(conninfo->input_id);
-static void ice_connection_watch(IceConn connection, IcePointer client_data,
- Bool opening, IcePointer *watch_data) {
- struct ice_connection_info *conninfo = NULL;
- purple_debug_misc("Session Management",
- "Handling new ICE connection...");
- /* ensure ICE connection is not passed to child processes */
- if (fcntl(IceConnectionNumber(connection), F_SETFD, FD_CLOEXEC) != 0)
- purple_debug_warning("gtksession", "couldn't set FD_CLOEXEC\n");
- conninfo = g_new(struct ice_connection_info, 1);
- conninfo->connection = connection;
- /* watch the connection */
- conninfo->input_id = purple_input_add(IceConnectionNumber(connection), PURPLE_INPUT_READ,
- ice_process_messages, conninfo);
- *watch_data = conninfo;
- purple_debug(PURPLE_DEBUG_INFO, "Session Management",
- "Handling closed ICE connection... \n");
- /* get the input ID back and stop watching it */
- conninfo = (struct ice_connection_info*) *watch_data;
- purple_input_remove(conninfo->input_id);
- if (purple_debug_is_verbose()) {
- purple_debug_misc("Session Management",
- "ICE connection handled.");
-/* We call any handler installed before (or after) ice_init but
- * avoid calling the default libICE handler which does an exit().
- * This means we do nothing by default, which is probably correct,
- * the connection will get closed by libICE
-static void ice_io_error_handler(IceConn connection) {
- purple_debug(PURPLE_DEBUG_INFO, "Session Management",
- "Handling ICE IO error... ");
- if (ice_installed_io_error_handler)
- (*ice_installed_io_error_handler)(connection);
- if (purple_debug_is_verbose()) {
- purple_debug_misc("Session Management",
- "ICE IO error handled.");
-static void ice_init(void) {
- IceIOErrorHandler default_handler;
- ice_installed_io_error_handler = IceSetIOErrorHandler(NULL);
- default_handler = IceSetIOErrorHandler(ice_io_error_handler);
- if (ice_installed_io_error_handler == default_handler)
- ice_installed_io_error_handler = NULL;
- IceAddConnectionWatch(ice_connection_watch, NULL);
- if (purple_debug_is_verbose()) {
- purple_debug_misc("Session Management", "ICE initialized.");
-/* my magic utility function */
-static gchar **session_make_command(gchar *client_id, gchar *config_dir) {
- if (config_dir) i += 2; /* we will specify purple's user dir */
- ret = g_new(gchar *, i);
- ret[j++] = g_strdup(myself);
- ret[j++] = g_strdup("--session");
- ret[j++] = g_strdup(client_id);
- ret[j++] = g_strdup("--config");
- ret[j++] = g_strdup(config_dir);
- ret[j++] = g_strdup("--display");
- ret[j++] = g_strdup((gchar *)gdk_display_get_name(gdk_display_get_default()));
-/* SM callback handlers */
-static void session_save_yourself(SmcConn conn, SmPointer data, int save_type,
- Bool shutdown, int interact_style, Bool fast) {
- if (had_first_save == FALSE && save_type == SmSaveLocal &&
- interact_style == SmInteractStyleNone && !shutdown &&
- /* this is just a dry run, spit it back */
- purple_debug(PURPLE_DEBUG_INFO, "Session Management",
- "Received first save_yourself\n");
- SmcSaveYourselfDone(conn, True);
- /* tum ti tum... don't add anything else here without *
- * reading SMlib.PS from an X.org ftp server near you */
- purple_debug(PURPLE_DEBUG_INFO, "Session Management",
- "Received save_yourself\n");
- if (save_type == SmSaveGlobal || save_type == SmSaveBoth) {
- /* may as well do something ... */
- /* or not -- save_prefs(); */
- SmcSaveYourselfDone(conn, True);
-static void session_die(SmcConn conn, SmPointer data) {
- purple_debug(PURPLE_DEBUG_INFO, "Session Management",
-static void session_save_complete(SmcConn conn, SmPointer data) {
- purple_debug(PURPLE_DEBUG_INFO, "Session Management",
- "Received save_complete\n");
-static void session_shutdown_cancelled(SmcConn conn, SmPointer data) {
- purple_debug(PURPLE_DEBUG_INFO, "Session Management",
- "Received shutdown_cancelled\n");
-/* utility functions stolen from Gnome-client */
-static void session_set_value(SmcConn conn, gchar *name, char *type,
- int num_vals, SmPropValue *vals) {
- g_return_if_fail(conn);
- prop.num_vals = num_vals;
- SmcSetProperties(conn, 1, proplist);
-static void session_set_string(SmcConn conn, gchar *name, gchar *value) {
- g_return_if_fail(name);
- val.length = strlen (value)+1;
- session_set_value(conn, name, SmARRAY8, 1, &val);
-static void session_set_gchar(SmcConn conn, gchar *name, gchar value) {
- g_return_if_fail(name);
- session_set_value(conn, name, SmCARD8, 1, &val);
-static void session_set_array(SmcConn conn, gchar *name, gchar *array[]) {
- g_return_if_fail (name);
- /* We count the number of elements in our array. */
- for (ptr = array, argc = 0; *ptr ; ptr++, argc++) /* LOOP */;
- /* Now initialize the 'vals' array. */
- vals = g_new (SmPropValue, argc);
- for (ptr = array, i = 0 ; i < argc ; ptr++, i++) {
- vals[i].length = strlen (*ptr);
- session_set_value(conn, name, SmLISTofARRAY8, argc, vals);
-pidgin_session_init(gchar *argv0, gchar *previous_id, gchar *config_dir)
- SmcCallbacks callbacks;
- gchar *client_id = NULL;
- gchar error[ERROR_LENGTH] = "";
- /* session is already established, what the hell is going on? */
- purple_debug(PURPLE_DEBUG_WARNING, "Session Management",
- "Duplicated call to pidgin_session_init!\n");
- if (g_getenv("SESSION_MANAGER") == NULL) {
- purple_debug(PURPLE_DEBUG_ERROR, "Session Management",
- "No SESSION_MANAGER found, aborting.\n");
- callbacks.save_yourself.callback = session_save_yourself;
- callbacks.die.callback = session_die;
- callbacks.save_complete.callback = session_save_complete;
- callbacks.shutdown_cancelled.callback = session_shutdown_cancelled;
- callbacks.save_yourself.client_data = NULL;
- callbacks.die.client_data = NULL;
- callbacks.save_complete.client_data = NULL;
- callbacks.shutdown_cancelled.client_data = NULL;
- purple_debug(PURPLE_DEBUG_INFO, "Session Management",
- "Connecting with previous ID %s\n", previous_id);
- purple_debug(PURPLE_DEBUG_INFO, "Session Management",
- "Connecting with no previous ID\n");
- session = SmcOpenConnection(NULL, "session", SmProtoMajor, SmProtoMinor, SmcSaveYourselfProcMask |
- SmcDieProcMask | SmcSaveCompleteProcMask | SmcShutdownCancelledProcMask,
- &callbacks, previous_id, &client_id, ERROR_LENGTH, error);
- if (error[0] != '\0') {
- purple_debug(PURPLE_DEBUG_ERROR, "Session Management",
- "Connection failed with error: %s\n", error);
- purple_debug(PURPLE_DEBUG_ERROR, "Session Management",
- "Connetion failed with unknown error.\n");
- tmp = SmcVendor(session);
- purple_debug(PURPLE_DEBUG_INFO, "Session Management",
- "Connected to manager (%s) with client ID %s\n",
- session_managed = TRUE;
- gdk_x11_set_sm_client_id(client_id);
- tmp = g_get_current_dir();
- session_set_string(session, SmCurrentDirectory, tmp);
- tmp = g_strdup_printf("%d", (int) getpid());
- session_set_string(session, SmProcessID, tmp);
- tmp = g_strdup(g_get_user_name());
- session_set_string(session, SmUserID, tmp);
- session_set_gchar(session, SmRestartStyleHint, (gchar) SmRestartIfRunning);
- session_set_string(session, SmProgram, (gchar *) g_get_prgname());
- myself = g_strdup(argv0);
- purple_debug(PURPLE_DEBUG_MISC, "Session Management",
- "Using %s as command\n", myself);
- cmd = session_make_command(NULL, config_dir);
- session_set_array(session, SmCloneCommand, cmd);
- /* this is currently useless, but gnome-session warns 'the following applications will not
- save their current status' bla bla if we don't have it and the user checks 'Save Session'
- cmd = g_new(gchar *, 2);
- cmd[0] = g_strdup("/bin/true");
- session_set_array(session, SmDiscardCommand, cmd);
- cmd = session_make_command(client_id, config_dir);
- session_set_array(session, SmRestartCommand, cmd);
- if (session == NULL) /* no session to close */
- SmcCloseConnection(session, 0, NULL);
- purple_debug(PURPLE_DEBUG_INFO, "Session Management",
- "Connection closed.\n");
--- a/pidgin/gtksession.h Thu Jun 15 10:48:26 2017 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
- * Pidgin is the legal property of its developers, whose names are too numerous
- * to list here. Please refer to the COPYRIGHT file distributed with this
- * 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 _PIDGINSESSION_H_
-#define _PIDGINSESSION_H_
- * @section_id: pidgin-gtksession
- * @short_description: <filename>gtksession.h</filename>
- * @title: X Windows Session Management
-/**************************************************************************/
-/* X Windows session subsystem */
-/**************************************************************************/
- * @argv0: The first argument passed into the program. This
- * will be the name of the executable, e.g. 'purple'
- * @previous_id: An optional session ID to use. This can be NULL.
- * @config_dir: The path to the configuration directory used by
- * this instance of this program, e.g. '/home/user/.purple'
- * Register this instance of Pidgin with the user's current session
-void pidgin_session_init(gchar *argv0, gchar *previous_id, gchar *config_dir);
- * Unregister this instance of Pidgin with the user's current session
-void pidgin_session_end(void);
-#endif /* _PIDGINSESSION_H_ */
--- a/pidgin/gtkwebview.c Thu Jun 15 10:48:26 2017 +0300
+++ b/pidgin/gtkwebview.c Fri Jun 30 15:03:16 2017 +0300
@@ -24,7 +24,6 @@
-#include "marshallers.h"
@@ -1344,45 +1343,44 @@
G_TYPE_FROM_CLASS(gobject_class),
G_STRUCT_OFFSET(PidginWebViewClass, buttons_update),
- NULL, 0, g_cclosure_marshal_VOID__INT,
G_TYPE_NONE, 1, G_TYPE_INT);
signals[TOGGLE_FORMAT] = g_signal_new("format-toggled",
G_TYPE_FROM_CLASS(gobject_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET(PidginWebViewClass, toggle_format),
- NULL, 0, g_cclosure_marshal_VOID__INT,
G_TYPE_NONE, 1, G_TYPE_INT);
signals[CLEAR_FORMAT] = g_signal_new("format-cleared",
G_TYPE_FROM_CLASS(gobject_class),
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET(PidginWebViewClass, clear_format),
- NULL, 0, g_cclosure_marshal_VOID__VOID,
signals[UPDATE_FORMAT] = g_signal_new("format-updated",
G_TYPE_FROM_CLASS(gobject_class),
G_STRUCT_OFFSET(PidginWebViewClass, update_format),
- NULL, 0, g_cclosure_marshal_VOID__VOID,
signals[CHANGED] = g_signal_new("changed",
G_TYPE_FROM_CLASS(gobject_class),
G_STRUCT_OFFSET(PidginWebViewClass, changed),
- NULL, NULL, g_cclosure_marshal_VOID__VOID,
signals[HTML_APPENDED] = g_signal_new("html-appended",
G_TYPE_FROM_CLASS(gobject_class),
G_STRUCT_OFFSET(PidginWebViewClass, html_appended),
- g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, WEBKIT_TYPE_DOM_RANGE,
signals[INSERT_IMAGE] = g_signal_new("insert-image",
G_TYPE_FROM_CLASS(gobject_class), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(PidginWebViewClass, insert_image),
- pidgin_webview_insert_image_accu, NULL,
- purple_smarshal_BOOLEAN__OBJECT, G_TYPE_BOOLEAN, 1,
+ pidgin_webview_insert_image_accu, NULL, NULL, --- a/pidgin/libpidgin.c Thu Jun 15 10:48:26 2017 +0300
+++ b/pidgin/libpidgin.c Fri Jun 30 15:03:16 2017 +0300
@@ -29,7 +29,6 @@
@@ -50,7 +49,6 @@
-#include "gtkeventloop.h"
@@ -63,7 +61,6 @@
#include "gtksavedstatuses.h"
#include "gtksmiley-theme.h"
@@ -294,11 +291,6 @@
@@ -317,7 +309,7 @@
g_hash_table_destroy(ui_info);
+ g_application_quit(g_application_get_default()); static GHashTable *pidgin_ui_get_info(void)
@@ -378,6 +370,12 @@
+pidgin_activate_cb(GApplication *application, gpointer user_data) + purple_blist_set_visible(TRUE); show_usage(const char *name, gboolean terse)
@@ -422,6 +420,7 @@
int pidgin_start(int argc, char *argv[])
gboolean opt_force_online = FALSE;
gboolean opt_help = FALSE;
gboolean opt_login = FALSE;
@@ -452,6 +451,7 @@
struct option long_options[] = {
{"config", required_argument, NULL, 'c'},
@@ -689,6 +689,9 @@
purple_debug_set_enabled(debug_enabled);
purple_debug_set_colored(debug_colored);
+ /* Call this here as GtkApplication calls gtk_init() in + * g_application_register() and we don't necessarily want to exit(). gui_check = gtk_init_check(&argc, &argv);
const char *display = gdk_display_get_name(gdk_display_get_default());
@@ -703,6 +706,26 @@
+ app = G_APPLICATION(gtk_application_new("im.pidgin.Pidgin", + G_APPLICATION_NON_UNIQUE)); + g_object_set(app, "register-session", TRUE, NULL); + g_signal_connect(app, "activate", + G_CALLBACK(pidgin_activate_cb), NULL); + if (!g_application_register(app, NULL, &error)) { + purple_debug_error("gtk", + "Unable to register GApplication: %s\n", + g_free(segfault_message); search_path = g_build_filename(purple_user_dir(), "gtk-3.0.css", NULL);
@@ -726,7 +749,6 @@
purple_core_set_ui_ops(pidgin_core_get_ui_ops());
- purple_eventloop_set_ui_ops(pidgin_eventloop_get_ui_ops());
if (!purple_core_init(PIDGIN_UI)) {
@@ -771,9 +793,6 @@
- pidgin_session_init(argv[0], opt_session_arg, opt_config_dir_arg);
g_free(opt_config_dir_arg);
@@ -845,7 +864,23 @@
+ /* TODO: Use GtkApplicationWindow or add a window instead */ + g_application_hold(app); + ret = g_application_run(app, 0, NULL); + /* Make sure purple has quit in case something in GApplication + * has caused g_application_run() to finish on its own. This can + * happen, for example, if the desktop session is ending. + if (purple_get_core() != NULL) { + /* Now that we're sure purple_core_quit() has been called, g_free(segfault_message);
@@ -858,5 +893,5 @@
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/pidgin.gresource.xml Fri Jun 30 15:03:16 2017 +0300
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?> + <gresource prefix="/im/pidgin/Pidgin"> + <file compressed="true">gtkdebug.html</file> --- a/po/POTFILES.in Thu Jun 15 10:48:26 2017 +0300
+++ b/po/POTFILES.in Fri Jun 30 15:03:16 2017 +0300
@@ -57,8 +57,6 @@
libpurple/plugins/autoaccept.c
libpurple/plugins/buddynote.c
-libpurple/plugins/caesarcipher.c
-libpurple/plugins/caesarcipher_consumer.c
libpurple/plugins/dbus-example.c
libpurple/plugins/filectl.c