Tue, 04 Dec 2018 02:44:33 +0000
Merged in default (pull request #441)
Drop libpurple DBus interface
Approved-by: Elliott Sales de Andrade
Approved-by: Gary Kramlich
Approved-by: Eion Robb
--- a/ChangeLog.API Fri Nov 30 17:27:13 2018 -0600 +++ b/ChangeLog.API Tue Dec 04 02:44:33 2018 +0000 @@ -425,6 +425,7 @@ * purple_core_ensure_single_instance. Check via GApplication or whatever is appropriate for your UI. * purple_core_migrate + * Removed the general Purple DBus interface * purple_dnsquery_a_account * purple_event_loop_{get|set}_ui_ops. Manually drive the GLib event loop yourself. See GLib Main Event Loop docs.
--- a/doc/finch.1.in Fri Nov 30 17:27:13 2018 -0600 +++ b/doc/finch.1.in Tue Dec 04 02:44:33 2018 +0000 @@ -590,8 +590,6 @@ .br \fIhttps://developer.pidgin.im/\fR .br -\fBpurple-remote\fR(1) -.br \fBpidgin\fR(1) .SH LICENSE
--- a/doc/pidgin.1.in Fri Nov 30 17:27:13 2018 -0600 +++ b/doc/pidgin.1.in Tue Dec 04 02:44:33 2018 +0000 @@ -34,8 +34,7 @@ many common features found in other clients, as well as many unique features. Pidgin is not endorsed by or affiliated with America Online, ICQ, or Microsoft. .PP -Pidgin can be extended by plugins written in multiple programming languages and -controlled through DBus or \fBpurple-remote\fR. +Pidgin can be extended by plugins written in multiple programming languages. .SH OPTIONS The following options are provided by Pidgin using the standard GNU @@ -570,8 +569,6 @@ .br \fIhttps://developer.pidgin.im/\fR .br -\fBpurple-remote\fR(1) -.br \fBfinch\fR(1) .SH LICENSE
--- a/doc/reference/libpurple/libpurple-docs.xml Fri Nov 30 17:27:13 2018 -0600 +++ b/doc/reference/libpurple/libpurple-docs.xml Tue Dec 04 02:44:33 2018 +0000 @@ -44,7 +44,6 @@ <xi:include href="xml/conversationtypes.xml" /> <xi:include href="xml/conversations.xml" /> <xi:include href="xml/countingnode.xml" /> - <xi:include href="xml/dbus-maybe.xml" /> <xi:include href="xml/debug.xml" /> <xi:include href="xml/e2ee.xml" /> <xi:include href="xml/eventloop.xml" /> @@ -133,16 +132,7 @@ <xi:include href="xml/backend-iface.xml" /> <xi:include href="xml/enum-types.xml" /> </chapter> - - <chapter id="dbus"> - <title>D-Bus Server APIs</title> - - <xi:include href="xml/dbus-bindings.xml" /> - <xi:include href="xml/dbus-purple.xml" /> - <xi:include href="xml/dbus-server.xml" /> - <xi:include href="xml/dbus-useful.xml" /> - </chapter> - </part> + </part> <part id="signals"> <title>Purple-signals Reference</title> @@ -154,7 +144,6 @@ <xi:include href="signals_connection.xml" /> <xi:include href="signals_conversation.xml" /> <xi:include href="signals_core.xml" /> - <xi:include href="signals_dbus_server.xml" /> <xi:include href="signals_xfer.xml" /> <xi:include href="signals_log.xml" /> <xi:include href="signals_notify.xml" />
--- a/doc/reference/libpurple/meson.build Fri Nov 30 17:27:13 2018 -0600 +++ b/doc/reference/libpurple/meson.build Tue Dec 04 02:44:33 2018 +0000 @@ -8,14 +8,8 @@ 'tests', 'win32', 'backend-fs2.h', - 'dbus-define-api.h', - 'dbus-types.h', 'glibcompat.h', 'internal.h', - 'purple-client.h', - 'purple-client-bindings.h', - 'purple-client-bindings1.h', - 'purple-client-bindings2.h', ] # Extra options to supply to gtkdoc-scan. @@ -46,7 +40,6 @@ 'signals_connection.xml', 'signals_conversation.xml', 'signals_core.xml', - 'signals_dbus_server.xml', 'signals_jabber.xml', 'signals_log.xml', 'signals_notify.xml',
--- a/doc/reference/libpurple/signals_dbus_server.xml Fri Nov 30 17:27:13 2018 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -<?xml version='1.0' encoding="ISO-8859-1"?> -<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" - "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [ -]> -<chapter id="chapter-signals-dbus-server"> -<title>D-Bus Server signals</title> - -<refsect1 id="dbus_server.signals" role="signal_proto"> -<title role="signal_proto.title">List of signals</title> -<synopsis> - "<link linkend="dbus_server-dbus-method-called">dbus-method-called</link>" - "<link linkend="dbus_server-dbus-introspect">dbus-introspect</link>" -</synopsis> -</refsect1> - -<refsect1 id="dbus_server.signal-details" role="signals"> -<title role="signals.title">Signal details</title> - -<refsect2 id="dbus_server-dbus-method-called" role="signal"> - <title>The <literal>"dbus-method-called"</literal> signal</title> -<programlisting> -gboolean user_function (DBusConnection *connection, - DBusMessage *message, - gpointer user_data) -</programlisting> - <para> -Emitted when a dbus method is going to be called. - </para> - <variablelist role="params"> - <varlistentry> - <term><parameter>connection</parameter> :</term> - <listitem><simpara>The DBus connection.</simpara></listitem> - </varlistentry> - <varlistentry> - <term><parameter>message</parameter> :</term> - <listitem><simpara>The DBus message.</simpara></listitem> - </varlistentry> - <varlistentry> - <term><parameter>user_data</parameter> :</term> - <listitem><simpara>user data set when the signal handler was connected.</simpara></listitem> - </varlistentry> - <varlistentry> - <term><emphasis>Returns</emphasis> :</term> - <listitem><simpara>TRUE if signal handler handled the method. ???.</simpara></listitem> - </varlistentry> - </variablelist> -</refsect2> - -<refsect2 id="dbus_server-dbus-introspect" role="signal"> - <title>The <literal>"dbus-introspect"</literal> signal</title> -<programlisting> -void user_function (GList **bidings_list, - gpointer user_data) -</programlisting> - <para> -???. - </para> - <variablelist role="params"> - <varlistentry> - <term><parameter>bindings_list</parameter> :</term> - <listitem><simpara>???.</simpara></listitem> - </varlistentry> - <varlistentry> - <term><parameter>user_data</parameter> :</term> - <listitem><simpara>user data set when the signal handler was connected.</simpara></listitem> - </varlistentry> - </variablelist> -</refsect2> - -</refsect1> - -</chapter>
--- a/finch/plugins/pietray.py Fri Nov 30 17:27:13 2018 -0600 +++ b/finch/plugins/pietray.py Tue Dec 04 02:44:33 2018 +0000 @@ -1,5 +1,8 @@ #!/usr/bin/env python +# NOTICE: This script is currently broken as the libpurple DBus +# bindings have been removed. +# # This is a dbus script to show a docklet for Finch. This should work # for any 'compatible' purple client. #
--- a/libpurple/account.c Fri Nov 30 17:27:13 2018 -0600 +++ b/libpurple/account.c Tue Dec 04 02:44:33 2018 +0000 @@ -23,7 +23,6 @@ #include "accounts.h" #include "core.h" -#include "dbus-maybe.h" #include "debug.h" #include "network.h" #include "notify.h" @@ -2415,7 +2414,6 @@ if(old_err) g_free(old_err->description); - PURPLE_DBUS_UNREGISTER_POINTER(old_err); g_free(old_err); } @@ -2892,8 +2890,6 @@ priv->system_log = NULL; priv->privacy_type = PURPLE_ACCOUNT_PRIVACY_ALLOW_ALL; - - PURPLE_DBUS_REGISTER_POINTER(account, PurpleAccount); } /* Called when done constructing */ @@ -2989,7 +2985,6 @@ if(priv->system_log) purple_log_free(priv->system_log); - PURPLE_DBUS_UNREGISTER_POINTER(priv->current_error); if (priv->current_error) { g_free(priv->current_error->description); g_free(priv->current_error); @@ -3015,8 +3010,6 @@ priv->permit = g_slist_delete_link(priv->permit, priv->permit); } - PURPLE_DBUS_UNREGISTER_POINTER(account); - parent_class->finalize(object); }
--- a/libpurple/accounts.c Fri Nov 30 17:27:13 2018 -0600 +++ b/libpurple/accounts.c Tue Dec 04 02:44:33 2018 +0000 @@ -21,7 +21,6 @@ #include "internal.h" #include "accounts.h" #include "core.h" -#include "dbus-maybe.h" #include "debug.h" #include "enums.h" #include "network.h" @@ -411,7 +410,6 @@ description = g_strdup(""); current_error = g_new0(PurpleConnectionErrorInfo, 1); - PURPLE_DBUS_REGISTER_POINTER(current_error, PurpleConnectionErrorInfo); current_error->type = type; current_error->description = description; @@ -868,7 +866,6 @@ g_return_if_fail(account != NULL); err = g_new0(PurpleConnectionErrorInfo, 1); - PURPLE_DBUS_REGISTER_POINTER(err, PurpleConnectionErrorInfo); err->type = type; err->description = g_strdup(description);
--- a/libpurple/buddy.c Fri Nov 30 17:27:13 2018 -0600 +++ b/libpurple/buddy.c Tue Dec 04 02:44:33 2018 +0000 @@ -22,7 +22,6 @@ */ #include "internal.h" #include "glibcompat.h" -#include "dbus-maybe.h" #include "util.h" #define PURPLE_BUDDY_GET_PRIVATE(obj) \ @@ -532,7 +531,6 @@ static void purple_buddy_init(GTypeInstance *instance, gpointer klass) { - PURPLE_DBUS_REGISTER_POINTER(PURPLE_BUDDY(instance), PurpleBuddy); } static void @@ -587,8 +585,6 @@ g_free(priv->local_alias); g_free(priv->server_alias); - PURPLE_DBUS_UNREGISTER_POINTER(buddy); - G_OBJECT_CLASS(parent_class)->finalize(object); }
--- a/libpurple/buddyicon.c Fri Nov 30 17:27:13 2018 -0600 +++ b/libpurple/buddyicon.c Tue Dec 04 02:44:33 2018 +0000 @@ -23,7 +23,6 @@ #include "internal.h" #include "buddyicon.h" #include "conversation.h" -#include "dbus-maybe.h" #include "debug.h" #include "image.h" #include "util.h" @@ -292,7 +291,6 @@ /* This does not zero. See purple_buddy_icon_new() for * information on which function allocates which member. */ icon = g_slice_new(PurpleBuddyIcon); - PURPLE_DBUS_REGISTER_POINTER(icon, PurpleBuddyIcon); icon->account = account; icon->username = g_strdup(username); @@ -372,7 +370,6 @@ g_free(icon->checksum); g_object_unref(icon->img); - PURPLE_DBUS_UNREGISTER_POINTER(icon); g_slice_free(PurpleBuddyIcon, icon); } }
--- a/libpurple/buddylist.c Fri Nov 30 17:27:13 2018 -0600 +++ b/libpurple/buddylist.c Tue Dec 04 02:44:33 2018 +0000 @@ -23,7 +23,6 @@ #include "internal.h" #include "buddylist.h" #include "conversation.h" -#include "dbus-maybe.h" #include "debug.h" #include "notify.h" #include "pounce.h" @@ -2119,8 +2118,6 @@ { PurpleBuddyList *blist = PURPLE_BUDDY_LIST(instance); - PURPLE_DBUS_REGISTER_POINTER(blist, PurpleBuddyList); - PURPLE_BUDDY_LIST_GET_PRIVATE(blist)->buddies = g_hash_table_new_full( (GHashFunc)_purple_blist_hbuddy_hash, (GEqualFunc)_purple_blist_hbuddy_equal, @@ -2133,8 +2130,6 @@ { g_hash_table_destroy(PURPLE_BUDDY_LIST_GET_PRIVATE(object)->buddies); - PURPLE_DBUS_UNREGISTER_POINTER(object); - G_OBJECT_CLASS(parent_class)->finalize(object); }
--- a/libpurple/chat.c Fri Nov 30 17:27:13 2018 -0600 +++ b/libpurple/chat.c Tue Dec 04 02:44:33 2018 +0000 @@ -22,7 +22,6 @@ */ #include "internal.h" #include "chat.h" -#include "dbus-maybe.h" #include "util.h" #define PURPLE_CHAT_GET_PRIVATE(obj) \ @@ -221,7 +220,6 @@ static void purple_chat_init(GTypeInstance *instance, gpointer klass) { - PURPLE_DBUS_REGISTER_POINTER(PURPLE_CHAT(instance), PurpleChat); } /* Called when done constructing */ @@ -249,8 +247,6 @@ g_free(priv->alias); g_hash_table_destroy(priv->components); - PURPLE_DBUS_UNREGISTER_POINTER(object); - G_OBJECT_CLASS(blistnode_parent_class)->finalize(object); }
--- a/libpurple/connection.c Fri Nov 30 17:27:13 2018 -0600 +++ b/libpurple/connection.c Tue Dec 04 02:44:33 2018 +0000 @@ -26,7 +26,6 @@ #include "account.h" #include "buddylist.h" #include "connection.h" -#include "dbus-maybe.h" #include "debug.h" #include "enums.h" #include "http.h" @@ -786,8 +785,6 @@ purple_connection_set_state(gc, PURPLE_CONNECTION_CONNECTING); connections = g_list_append(connections, gc); - - PURPLE_DBUS_REGISTER_POINTER(gc, PurpleConnection); } /* Called when done constructing */ @@ -876,8 +873,6 @@ purple_str_wipe(priv->password); g_free(priv->display_name); - PURPLE_DBUS_UNREGISTER_POINTER(gc); - G_OBJECT_CLASS(parent_class)->finalize(object); }
--- a/libpurple/contact.c Fri Nov 30 17:27:13 2018 -0600 +++ b/libpurple/contact.c Tue Dec 04 02:44:33 2018 +0000 @@ -22,7 +22,6 @@ */ #include "contact.h" -#include "dbus-maybe.h" #include "internal.h" /* TODO: this needs to die */ #include "util.h" @@ -301,8 +300,6 @@ if (ops && ops->new_node) ops->new_node(PURPLE_BLIST_NODE(contact)); - - PURPLE_DBUS_REGISTER_POINTER(contact, PurpleContact); } /* GObject finalize function */ @@ -311,8 +308,6 @@ { g_free(PURPLE_CONTACT_GET_PRIVATE(object)->alias); - PURPLE_DBUS_UNREGISTER_POINTER(object); - G_OBJECT_CLASS(parent_class)->finalize(object); }
--- a/libpurple/conversation.c Fri Nov 30 17:27:13 2018 -0600 +++ b/libpurple/conversation.c Tue Dec 04 02:44:33 2018 +0000 @@ -25,7 +25,6 @@ #include "buddylist.h" #include "cmds.h" #include "conversation.h" -#include "dbus-maybe.h" #include "debug.h" #include "enums.h" #include "notify.h"
--- a/libpurple/conversationtypes.c Fri Nov 30 17:27:13 2018 -0600 +++ b/libpurple/conversationtypes.c Tue Dec 04 02:44:33 2018 +0000 @@ -22,7 +22,6 @@ #include "internal.h" #include "glibcompat.h" #include "conversationtypes.h" -#include "dbus-maybe.h" #include "debug.h" #include "enums.h" @@ -416,8 +415,6 @@ /* GObject initialization function */ static void purple_im_conversation_init(GTypeInstance *instance, gpointer klass) { - PURPLE_DBUS_REGISTER_POINTER(PURPLE_IM_CONVERSATION(instance), - PurpleIMConversation); } /* Called when done constructing */ @@ -487,8 +484,6 @@ purple_im_conversation_stop_typing_timeout(im); purple_im_conversation_stop_send_typed_timeout(im); - PURPLE_DBUS_UNREGISTER_POINTER(im); - G_OBJECT_CLASS(parent_class)->finalize(object); } @@ -1392,9 +1387,6 @@ { PurpleChatConversationPrivate *priv = PURPLE_CHAT_CONVERSATION_GET_PRIVATE(instance); - PURPLE_DBUS_REGISTER_POINTER(PURPLE_CHAT_CONVERSATION(instance), - PurpleChatConversation); - priv->users = g_hash_table_new_full(_purple_conversation_user_hash, _purple_conversation_user_equal, g_free, g_object_unref); } @@ -1479,8 +1471,6 @@ priv->topic = NULL; priv->nick = NULL; - PURPLE_DBUS_UNREGISTER_POINTER(chat); - G_OBJECT_CLASS(parent_class)->finalize(object); } @@ -1824,7 +1814,6 @@ static void purple_chat_user_init(GTypeInstance *instance, gpointer klass) { - PURPLE_DBUS_REGISTER_POINTER(PURPLE_CHAT_USER(instance), PurpleChatUser); } /* Called when done constructing */ @@ -1856,8 +1845,6 @@ g_free(priv->alias_key); g_free(priv->name); - PURPLE_DBUS_UNREGISTER_POINTER(cb); - cb_parent_class->finalize(object); }
--- a/libpurple/core.c Fri Nov 30 17:27:13 2018 -0600 +++ b/libpurple/core.c Tue Dec 04 02:44:33 2018 +0000 @@ -50,16 +50,6 @@ #include "theme-manager.h" #include "util.h" -#ifdef HAVE_DBUS -# ifndef DBUS_API_SUBJECT_TO_CHANGE -# define DBUS_API_SUBJECT_TO_CHANGE -# endif -# include <dbus/dbus.h> -# include "dbus-purple.h" -# include "dbus-server.h" -# include "dbus-bindings.h" -#endif - struct PurpleCore { char *ui; @@ -152,10 +142,6 @@ ops->debug_ui_init(); } -#ifdef HAVE_DBUS - purple_dbus_init(); -#endif - purple_cmds_init(); purple_protocols_init(); @@ -266,10 +252,6 @@ static_proto_unload(); purple_protocols_uninit(); -#ifdef HAVE_DBUS - purple_dbus_uninit(); -#endif - purple_cmds_uninit(); purple_log_uninit(); _purple_message_uninit();
--- a/libpurple/dbus-analyze-functions.py Fri Nov 30 17:27:13 2018 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,714 +0,0 @@ -from __future__ import absolute_import, division, print_function - -import argparse -import fileinput -import re -import sys - - -# types translated into "int" -simpletypes = ["int", "gint", "guint", "gboolean", "size_t", "gssize", - "time_t"] - -# List "excluded" contains functions that shouldn't be exported via -# DBus. If you remove a function from this list, please make sure -# that it does not break "make" with the configure option -# "--enable-dbus" turned on. - -excluded = [ - # I don't remember why this function is excluded; something to do - # with the fact that it takes a (const) GList as a parameter. - "purple_presence_add_list", - - # These functions are excluded because they involve value of the - # type PurpleConvPlacementFunc, which is a pointer to a function and - # (currently?) can't be translated into a DBus type. Normally, - # functions with untranslatable types are skipped, but this script - # assumes that all non-pointer type names beginning with "Purple" - # are enums, which is not true in this case. - "purple_conversation_placement_add_fnc", - "purple_conversation_placement_get_fnc", - "purple_conversation_placement_get_current_func", - "purple_conversation_placement_set_current_func", - - # Similar to the above: - "purple_account_set_register_callback", - "purple_account_unregister", - - # Similar to the above: - "purple_protocol_server_iface_unregister_user", - - # Similar to the above, again - "purple_menu_action_new", - "purple_menu_action_set_callback", - "purple_menu_action_get_callback", - - # These functions are excluded because they involve setting arbitrary - # data via pointers for protocols and UIs. This just won't work. - "purple_blist_get_ui_data", - "purple_blist_set_ui_data", - "purple_blist_node_get_ui_data", - "purple_blist_node_set_ui_data", - "purple_buddy_get_protocol_data", - "purple_buddy_set_protocol_data", - - # This is excluded because this script treats PurpleLogReadFlags* - # as pointer to a struct, instead of a pointer to an enum. This - # causes a compilation error. Someone should fix this script. - "purple_log_read", - - # Similiar to the above: - "purple_notify_is_valid_ui_handle", -] - -# This is a list of functions that return a GList* or GSList * whose elements -# are strings, not pointers to objects. -stringlists = [ - "purple_prefs_get_path_list", - "purple_prefs_get_string_list", - "purple_uri_list_extract_filenames", - "purple_uri_list_extract_uris", - "purple_prefs_get_children_names", -] - -# This is a list of functions that return a GList* or GSList* that should -# not be freed. Ideally, this information should be obtained from the gtk-doc -# documentation at some point. -constlists = [ - "purple_account_get_status_types", - "purple_accounts_get_all", - "purple_account_option_get_list", - "purple_connections_get_all", - "purple_connections_get_connecting", - "purple_conversations_get_all", - "purple_conversations_get_ims", - "purple_conversations_get_chats", - "purple_chat_conversation_get_users", - "purple_chat_conversation_get_ignored", - "purple_mime_document_get_fields", - "purple_mime_document_get_parts", - "purple_mime_part_get_fields", - "purple_notify_user_info_get_entries", - "purple_request_fields_get_required", - "purple_request_field_list_get_selected", - "purple_request_field_list_get_items", - "purple_savedstatuses_get_all", - "purple_status_type_get_attrs", - "purple_presence_get_statuses", - "purple_conversation_get_message_history", -] - -pointer = "#pointer#" - - -class MyException(Exception): - pass - - -def ctopascal(name): - newname = "" - for word in name.split("_"): - newname += word.capitalize() - return newname - - -class Parameter(object): - def __init__(self, type, name): - self.name = name - self.type = type - - def fromtokens(tokens, parameternumber=-1): - if len(tokens) == 0: - raise MyException() - if len(tokens) == 1 or tokens[-1] == pointer: - if parameternumber >= 0: - return Parameter(tokens, "param%i" % (parameternumber, )) - else: - raise MyException() - else: - return Parameter(tokens[:-1], tokens[-1]) - - fromtokens = staticmethod(fromtokens) - - -class Binding(object): - def __init__(self, functiontext, paramtexts, output=None): - self.function = Parameter.fromtokens(functiontext.split()) - - if self.function.name in excluded: - raise MyException() - - self.params = [] - for i in range(len(paramtexts)): - self.params.append(Parameter.fromtokens(paramtexts[i].split(), i)) - - self.call = "%s(%s)" % (self.function.name, - ", ".join(param.name for param in self.params)) - - self.output = output - - def process(self): - for param in self.params: - self.processinput(param.type, param.name) - - self.processoutput(self.function.type, "RESULT") - self.flush() - - def processinput(self, type, name): - const = False - unsigned = False - if type[0] == "const": - type = type[1:] - const = True - - if type[0] == "unsigned": - type = type[1:] - unsigned = True - - if len(type) == 1: - # simple types (int, gboolean, etc.) and enums - if type[0] in simpletypes or ( - type[0].startswith("Purple") and - not type[0].endswith("Callback")): - return self.inputsimple(type, name, unsigned) - - # pointers ... - if len(type) == 2 and type[1] == pointer: - # strings - if type[0] in ["char", "gchar"]: - if const: - return self.inputstring(type, name, unsigned) - else: - raise MyException() - - elif type[0] == "GHashTable": - return self.inputhash(type, name) - - # known object types are transformed to integer handles - elif type[0].startswith("Purple"): - return self.inputpurplestructure(type, name) - - # special case for *_get_data functions, be careful here... - elif (type[0] == "size_t" or type[0] == "gsize") and name == "len": - return self.inputgetdata(type, name) - - # unknown pointers are always replaced with NULL - else: - return self.inputpointer(type, name) - - raise MyException() - - def processoutput(self, type, name): - const = False - unsigned = False - # the "void" type is simple ... - if type == ["void"]: - return self.outputvoid(type, name) - - if type[0] == "const": - type = type[1:] - const = True - - if type[0] == "unsigned": - type = type[1:] - unsigned = True - - # a string - if type == ["char", pointer] or type == ["gchar", pointer]: - return self.outputstring(type, name, const) - - # simple types (ints, booleans, enums, ...) - if (len(type) == 1 and - (type[0] in simpletypes or type[0].startswith("Purple"))): - return self.outputsimple(type, name, unsigned) - - # pointers ... - if len(type) == 2 and type[1] == pointer: - # handles - if type[0].startswith("Purple"): - return self.outputpurplestructure(type, name) - - if type[0] in ["GList", "GSList"]: - return self.outputlist(type, name) - - # Special case for *_get_data functions - if type[0] == "gconstpointer": - return self.outputgetdata(type, name) - - raise MyException() - - -class ClientBinding(Binding): - def __init__(self, functiontext, paramtexts, knowntypes, headersonly, - **kwargs): - Binding.__init__(self, functiontext, paramtexts, **kwargs) - self.knowntypes = knowntypes - self.headersonly = headersonly - self.paramshdr = [] - self.decls = [] - self.inputparams = [] - self.outputparams = [] - self.returncode = [] - - def flush(self): - paramslist = ", ".join(self.paramshdr) - if paramslist == "": - paramslist = "void" - print("%s %s(%s)" % (self.functiontype, self.function.name, - paramslist), - end=' ', - file=self.output) - - if self.headersonly: - print(";", file=self.output) - return - - print("{", file=self.output) - - for decl in self.decls: - print(decl, file=self.output) - - print('dbus_g_proxy_call(purple_proxy, "%s", NULL,' % ( - ctopascal(self.function.name), ), - file=self.output) - - for type_name in self.inputparams: - print("\t%s, %s, " % type_name, end=' ', file=self.output) - print("G_TYPE_INVALID,", file=self.output) - - for type_name in self.outputparams: - print("\t%s, &%s, " % type_name, end=' ', file=self.output) - print("G_TYPE_INVALID);", file=self.output) - - for code in self.returncode: - print(code, file=self.output) - - print("}\n", file=self.output) - - def definepurplestructure(self, type): - if self.headersonly and type[0] not in self.knowntypes: - print("struct _%s;" % (type[0], ), file=self.output) - print("typedef struct _%s %s;" % (type[0], type[0]), - file=self.output) - self.knowntypes.append(type[0]) - - def inputsimple(self, type, name, us): - self.paramshdr.append("%s %s" % (type[0], name)) - if us: - self.inputparams.append(("G_TYPE_UINT", name)) - else: - self.inputparams.append(("G_TYPE_INT", name)) - - def inputstring(self, type, name, us): - if us: - self.paramshdr.append("const unsigned char *%s" % (name, )) - else: - self.paramshdr.append("const char *%s" % (name, )) - self.inputparams.append(("G_TYPE_STRING", name)) - - def inputpurplestructure(self, type, name): - self.paramshdr.append("const %s *%s" % (type[0], name)) - self.inputparams.append(("G_TYPE_INT", - "GPOINTER_TO_INT(%s)" % (name, ))) - self.definepurplestructure(type) - - def inputpointer(self, type, name): - name += "_NULL" - self.paramshdr.append("const %s *%s" % (type[0], name)) - self.inputparams.append(("G_TYPE_INT", "0")) - - def inputhash(self, type, name): - self.paramshdr.append("const GHashTable *%s" % (name, )) - self.inputparams.append( - ('dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_STRING)', - name)) - - def outputvoid(self, type, name): - self.functiontype = "void" - - def outputstring(self, type, name, const): - self.functiontype = "char*" - self.decls.append("char *%s = NULL;" % (name, )) - self.outputparams.append(("G_TYPE_STRING", name)) -# self.returncode.append("NULLIFY(%s);" % (name, )) - self.returncode.append("return %s;" % (name, )) - - def outputsimple(self, type, name, us): - self.functiontype = type[0] - self.decls.append("%s %s = 0;" % (type[0], name)) - if us: - self.outputparams.append(("G_TYPE_UINT", name)) - else: - self.outputparams.append(("G_TYPE_INT", name)) - self.returncode.append("return %s;" % (name, )) - - # we could add "const" to the return type but this would probably - # be a nuisance - def outputpurplestructure(self, type, name): - name = name + "_ID" - self.functiontype = "%s*" % (type[0], ) - self.decls.append("int %s = 0;" % (name, )) - self.outputparams.append(("G_TYPE_INT", "%s" % (name, ))) - self.returncode.append("return (%s*) GINT_TO_POINTER(%s);" % (type[0], - name)) - self.definepurplestructure(type) - - def outputlist(self, type, name): - self.functiontype = "%s*" % (type[0], ) - self.decls.append("GArray *%s;" % (name, )) - self.outputparams.append( - ('dbus_g_type_get_collection("GArray", G_TYPE_INT)', name)) - self.returncode.append("return garray_int_to_%s(%s);" % - (type[0].lower(), name)) - - # Special case for *_get_data functions, don't need client bindings, - # but do need the name so it doesn't crash - def inputgetdata(self, type, name): - raise MyException() - - def outputgetdata(self, type, name): - raise MyException() - - -class ServerBinding(Binding): - def __init__(self, functiontext, paramtexts, **kwargs): - Binding.__init__(self, functiontext, paramtexts, **kwargs) - self.dparams = "" - self.cparams = [] - self.cdecls = [] - self.ccode = [] - self.cparamsout = [] - self.ccodeout = [] - self.argfunc = "dbus_message_get_args" - - def flush(self): - print("static DBusMessage*", file=self.output) - print("%s_DBUS(DBusMessage *message_DBUS, DBusError *error_DBUS) {" % - self.function.name, - file=self.output) - - print("\tDBusMessage *reply_DBUS;", file=self.output) - - for decl in self.cdecls: - print(decl, file=self.output) - - print("\t%s(message_DBUS, error_DBUS," % (self.argfunc, ), end=' ', - file=self.output) - for param in self.cparams: - print("DBUS_TYPE_%s, &%s," % param, end=' ', file=self.output) - print("DBUS_TYPE_INVALID);", file=self.output) - - print("\tCHECK_ERROR(error_DBUS);", file=self.output) - - for code in self.ccode: - print(code, file=self.output) - - print("\treply_DBUS = dbus_message_new_method_return (message_DBUS);", - file=self.output) - - print("\tdbus_message_append_args(reply_DBUS,", end=' ', - file=self.output) - for param in self.cparamsout: - if type(param) is str: - print("%s," % (param, ), end=' ', file=self.output) - else: - print("DBUS_TYPE_%s, &%s," % param, end=' ', file=self.output) - print("DBUS_TYPE_INVALID);", file=self.output) - - for code in self.ccodeout: - print(code, file=self.output) - - print("\treturn reply_DBUS;\n}\n", file=self.output) - - def addstring(self, *items): - for item in items: - self.dparams += item + r"\0" - - def addintype(self, type, name): - self.addstring("in", type, name) - - def addouttype(self, type, name): - self.addstring("out", type, name) - - # input parameters - - def inputsimple(self, type, name, us): - if us: - self.cdecls.append("\tdbus_uint32_t %s;" % (name, )) - self.cparams.append(("UINT32", name)) - self.addintype("u", name) - else: - self.cdecls.append("\tdbus_int32_t %s;" % (name, )) - self.cparams.append(("INT32", name)) - self.addintype("i", name) - - def inputstring(self, type, name, us): - if us: - self.cdecls.append("\tconst unsigned char *%s;" % (name, )) - else: - self.cdecls.append("\tconst char *%s;" % (name, )) - self.cparams.append(("STRING", name)) - self.ccode.append( - "\t%s = (%s && %s[0]) ? %s : NULL;" % (name, name, name, name)) - self.addintype("s", name) - - def inputhash(self, type, name): - self.argfunc = "purple_dbus_message_get_args" - self.cdecls.append("\tDBusMessageIter %s_ITER;" % (name, )) - self.cdecls.append("\tGHashTable *%s;" % (name, )) - self.cparams.append(("ARRAY", "%s_ITER" % (name, ))) - self.ccode.append( - "\t%s = purple_dbus_iter_hash_table(&%s_ITER, error_DBUS);" % ( - name, - name)) - self.ccode.append("\tCHECK_ERROR(error_DBUS);") - self.ccodeout.append("\tg_hash_table_destroy(%s);" % (name, )) - self.addintype("a{ss}", name) - - def inputpurplestructure(self, type, name): - self.cdecls.append("\tdbus_int32_t %s_ID;" % (name, )) - self.cdecls.append("\t%s *%s;" % (type[0], name)) - self.cparams.append(("INT32", name + "_ID")) - self.ccode.append( - "\tPURPLE_DBUS_ID_TO_POINTER(%s, %s_ID, %s, error_DBUS);" % ( - name, - name, - type[0])) - self.addintype("i", name) - - def inputpointer(self, type, name): - self.cdecls.append("\tdbus_int32_t %s_NULL;" % (name, )) - self.cdecls.append("\t%s *%s;" % (type[0], name)) - self.cparams.append(("INT32", name + "_NULL")) - self.ccode.append("\t%s = NULL;" % (name, )) - self.addintype("i", name) - - # output parameters - - def outputvoid(self, type, name): - self.ccode.append("\t%s;" % (self.call, )) # just call the function - - def outputstring(self, type, name, const): - if const: - self.cdecls.append("\tconst char *%s;" % (name, )) - else: - self.cdecls.append("\tchar *%s;" % (name, )) - self.ccode.append("\tif ((%s = %s) == NULL)" % (name, self.call)) - self.ccode.append("\t\t%s = \"\";" % (name, )) - self.cparamsout.append(("STRING", name)) - self.addouttype("s", name) - if not const: - self.ccodeout.append("\tg_free(%s);" % (name, )) - - def outputsimple(self, type, name, us): - if us: - self.cdecls.append("\tdbus_uint32_t %s;" % (name, )) - self.cparamsout.append(("UINT32", name)) - self.addouttype("u", name) - else: - self.cdecls.append("\tdbus_int32_t %s;" % (name, )) - self.cparamsout.append(("INT32", name)) - self.addouttype("i", name) - self.ccode.append("\t%s = %s;" % (name, self.call)) - - def outputpurplestructure(self, type, name): - self.cdecls.append("\tdbus_int32_t %s;" % (name, )) - self.ccode.append( - "\tPURPLE_DBUS_POINTER_TO_ID(%s, %s, error_DBUS);" % (name, - self.call)) - self.cparamsout.append(("INT32", name)) - self.addouttype("i", name) - - # GList*, GSList*, assume that list is a list of objects - # unless the function is in stringlists - def outputlist(self, type, name): - self.cdecls.append("\tdbus_int32_t %s_LEN;" % (name, )) - self.ccodeout.append("\tg_free(%s);" % (name, )) - - self.cdecls.append("\t%s *list;" % (type[0], )) - - if self.function.name in stringlists: - self.cdecls.append("\tchar **%s;" % (name, )) - self.ccode.append("\tlist = %s;" % (self.call, )) - self.ccode.append( - "\t%s = (char **)purple_%s_to_array(list, &%s_LEN);" % ( - name, - type[0], - name)) - self.cparamsout.append( - "DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &%s, %s_LEN" % (name, - name)) - if self.function.name not in constlists: - type_name = type[0].lower()[1:] - self.ccodeout.append( - "\tg_%s_foreach(list, (GFunc)g_free, NULL);" % ( - type_name, )) - self.ccodeout.append("\tg_%s_free(list);" % (type_name, )) - self.addouttype("as", name) - else: - self.cdecls.append("\tdbus_int32_t *%s;" % (name, )) - self.ccode.append("\tlist = %s;" % (self.call, )) - self.ccode.append("\t%s = purple_dbusify_%s(list, &%s_LEN);" % ( - name, - type[0], - name)) - if self.function.name not in constlists: - type_name = type[0].lower()[1:] - self.ccode.append("\tg_%s_free(list);" % (type_name, )) - self.cparamsout.append( - "DBUS_TYPE_ARRAY, DBUS_TYPE_INT32, &%s, %s_LEN" % (name, name)) - self.addouttype("ai", name) - - # Special case for *_get_data functions - def inputgetdata(self, type, name): - self.cdecls.append("\tsize_t %s = 0;" % (name, )) - return True - - def outputgetdata(self, type, name): - # This is a total hack, but self.call is set up before the parameters - # are processed, so we can't tell it to pass a parameter by reference. - params = ', '.join('&len' if param.name == 'len' else param.name - for param in self.params) - self.call = "%s(%s)" % (self.function.name, params) - - self.cdecls.append("\tgconstpointer %s;" % (name, )) - self.ccode.append("\t%s = %s;" % (name, self.call)) - self.cparamsout.append("DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &%s, %s" % ( - name, - "len")) - self.addouttype("ay", name) - - -class BindingSet(object): - regexp = r"^(\w[^()]*)\(([^()]*)\)\s*;\s*$" - - def __init__(self, inputfile, fprefix, output=None): - self.inputiter = iter(inputfile) - self.functionregexp = re.compile( - "^%s(\w[^()]*)\(([^()]*)\)\s*;\s*$" % (fprefix, )) - self.typeregexp = re.compile("^\w+\s*\*?\s*$") - self.output = output - - def process(self): - print("/* Generated by %s. Do not edit! */" % (sys.argv[0], ), - file=self.output) - - for line in self.inputiter: - words = line.split() - if len(words) == 0: # empty line - continue - if line[0] == "#": # preprocessor directive - continue - if words[0] in ["typedef", "struct", "enum", "static"]: - continue - - # accumulate lines until the parentheses are balance or an - # empty line has been encountered - myline = line.strip() - while (myline.count("(") > myline.count(")") or - self.typeregexp.match(myline)): - newline = next(self.inputiter).strip() - if len(newline) == 0: - break - myline += " " + newline - - # is this a function declaration? - thematch = self.functionregexp.match( - myline.replace("*", " " + pointer + " ")) - - if thematch is None: - continue - - functiontext = thematch.group(1) - paramstext = thematch.group(2).strip() - - if (paramstext == "void") or (paramstext == ""): - paramtexts = [] - else: - paramtexts = paramstext.split(",") - - try: - self.processfunction(functiontext, paramtexts) - except MyException: - pass - except: - raise - - self.flush() - - -class ServerBindingSet (BindingSet): - def __init__(self, inputfile, fprefix, **kwargs): - BindingSet.__init__(self, inputfile, fprefix, **kwargs) - self.functions = [] - - def processfunction(self, functiontext, paramtexts): - binding = ServerBinding(functiontext, paramtexts, output=self.output) - binding.process() - self.functions.append((binding.function.name, binding.dparams)) - - def flush(self): - print("static PurpleDBusBinding bindings_DBUS[] = { ", - file=self.output) - for function, params in self.functions: - print('{"%s", "%s", %s_DBUS},' % - (ctopascal(function), params, function), file=self.output) - - print("{NULL, NULL, NULL}", file=self.output) - print("};", file=self.output) - - print("#define PURPLE_DBUS_REGISTER_BINDINGS(handle) " - "purple_dbus_register_bindings(handle, bindings_DBUS)", - file=self.output) - - -class ClientBindingSet (BindingSet): - def __init__(self, inputfile, fprefix, headersonly, **kwargs): - BindingSet.__init__(self, inputfile, fprefix, **kwargs) - self.functions = [] - self.knowntypes = [] - self.headersonly = headersonly - - def processfunction(self, functiontext, paramtexts): - binding = ClientBinding(functiontext, paramtexts, self.knowntypes, - self.headersonly, output=self.output) - binding.process() - - def flush(self): - pass - - -# Main program - -parser = argparse.ArgumentParser() -parser.add_argument('input', nargs='*', - help='Input files (or stdin if not specified)') -parser.add_argument('-o', '--output', - help='Output to file instead of stdout') -parser.add_argument('-a', '--append', action='store_true', - help='Append to file instead of overwriting it') -parser.add_argument('-e', '--export-only', action='store_true', - help='Prefix functions for export') -parser.add_argument('-c', '--client', action='store_true', - help='Produce client bindings instead of server bindings') -parser.add_argument('-H', '--headers', action='store_true', - help='Produce headers only') -args = parser.parse_args() - -if args.export_only: - fprefix = "DBUS_EXPORT\s+" -else: - fprefix = "" - -myinput = fileinput.input(args.input) -if args.output is not None: - output = open(args.output, 'a' if args.append else 'w') -else: - output = None - -if args.client: - bindings = ClientBindingSet(myinput, fprefix, args.headers, output=output) -else: - bindings = ServerBindingSet(myinput, fprefix, output=output) - -bindings.process()
--- a/libpurple/dbus-analyze-signals.py Fri Nov 30 17:27:13 2018 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ -# This program takes a C source as the input and produces the list of -# all signals registered. -# -# Output is: -# <signal name="Changed"> -# <arg name="new_value" type="b"/> -# </signal> -from __future__ import absolute_import, division, print_function - -import argparse -import fileinput -import re -import sys - - -# List "excluded" contains signals that shouldn't be exported via -# DBus. If you remove a signal from this list, please make sure -# that it does not break "make" with the configure option -# "--enable-dbus" turned on. - -excluded = [ - # purple_dbus_signal_emit_purple prevents our "dbus-method-called" - # signal from being propagated to dbus. - "dbus-method-called", -] - -registerregex = re.compile( - "purple_signal_register[^;]+\"([\w\-]+)\"[^;]+(purple_marshal_\w+)[^;]+;") -nameregex = re.compile('[-_][a-z]') - -parser = argparse.ArgumentParser() -parser.add_argument('input', nargs='*', - help='Input files (or stdin if not specified)') -parser.add_argument('-o', '--output', type=argparse.FileType('w'), - help='Output to file instead of stdout') -cmd_args = parser.parse_args() - -print("/* Generated by %s. Do not edit! */" % (sys.argv[0], ), - file=cmd_args.output) -print("const char *dbus_signals = ", file=cmd_args.output) -input = ''.join(list(fileinput.input(cmd_args.input))) -for match in registerregex.finditer(input): - signal = match.group(1) - marshal = match.group(2) - if signal in excluded: - continue - - signal = nameregex.sub(lambda x: x.group()[1].upper(), '-' + signal) - print("\" <signal name='%s'>\\n\"" % (signal, ), file=cmd_args.output) - - args = marshal.split('_') - # ['purple', 'marshal', <return type>, '', args...] - if len(args) > 4: - for arg in args[4:]: - if arg == "POINTER": - type = 'p' - elif arg == "ENUM": - type = 'i' - elif arg == "INT": - type = 'i' - elif arg == "UINT": - type = 'u' - elif arg == "INT64": - type = 'x' - elif arg == "UINT64": - type = 't' - elif arg == "BOOLEAN": - type = 'b' - print("\" <arg type='%s'/>\\n\"" % (type, ), - file=cmd_args.output) - - print("\" </signal>\\n\"", file=cmd_args.output) - -print(";", file=cmd_args.output)
--- a/libpurple/dbus-analyze-types.py Fri Nov 30 17:27:13 2018 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ -# This program takes a C header/source as the input and produces -# -# with --keyword=enum: the list of all enums -# with --keyword=struct: the list of all structs -# -# the output styles: -# -# --enum DBUS_POINTER_NAME1, -# DBUS_POINTER_NAME2, -# DBUS_POINTER_NAME3, -# -# --list NAME1 -# NAME2 -# NAME3 -# - -from __future__ import absolute_import, division, print_function - -import argparse -import fileinput -import re -import sys - - -def toprint(match, line): - if args.verbatim: - return line - else: - return args.pattern % match - - -parser = argparse.ArgumentParser() -parser.add_argument('input', nargs='*', - help='Input files (or stdin if not specified)') -parser.add_argument('-o', '--output', type=argparse.FileType('w'), - help='Output to file instead of stdout') -parser.add_argument('--keyword', default='struct', - help='What keyword to search') -parser.add_argument('--pattern', default='%s', - help='String pattern used to print matches') -parser.add_argument('--verbatim', action='store_true', - help='Return full line of match instead of match itself') -args = parser.parse_args() - -structregexp1 = re.compile( - r"^(typedef\s+)?%s\s+\w+\s+(\w+)\s*;" % (args.keyword, )) -structregexp2 = re.compile(r"^(typedef\s+)?%s" % (args.keyword, )) -structregexp3 = re.compile(r"^}\s+(\w+)\s*;") - -print("/* Generated by %s. Do not edit! */" % (sys.argv[0], ), - file=args.output) - -myinput = fileinput.input(args.input) - -for line in myinput: - match = structregexp1.match(line) - if match is not None: - print(toprint(match.group(2), line), file=args.output) - continue - - match = structregexp2.match(line) - if match is not None: - while True: - if args.verbatim: - print(line.rstrip(), file=args.output) - line = next(myinput) - match = structregexp3.match(line) - if match is not None: - print(toprint(match.group(1), line), file=args.output) - break - if line[0] not in " \t{\n": - if args.verbatim: - print(line, file=args.output) - break
--- a/libpurple/dbus-bindings.h Fri Nov 30 17:27:13 2018 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,107 +0,0 @@ -/* purple - * - * Purple is the legal property of its developers, whose names are too numerous - * to list here. Please refer to the COPYRIGHT file distributed with this - * source distribution. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA - * - */ - -#ifndef _PURPLE_DBUS_BINDINGS_H_ -#define _PURPLE_DBUS_BINDINGS_H_ -/** - * SECTION:dbus-bindings - * @section_id: libpurple-dbus-bindings - * @short_description: <filename>dbus-bindings.h</filename> - * @title: DBUS Bindings - */ - -#include <dbus/dbus.h> -#include <dbus/dbus-glib-lowlevel.h> -#include <glib.h> - -G_BEGIN_DECLS - -gint purple_dbus_pointer_to_id(gconstpointer node); -gpointer purple_dbus_id_to_pointer(gint id, PurpleDBusType *type); -gint purple_dbus_pointer_to_id_error(gconstpointer ptr, DBusError *error); -gpointer purple_dbus_id_to_pointer_error(gint id, PurpleDBusType *type, - const char *typename, DBusError *error); - -#define NULLIFY(id) id = purple_emptystr_to_null(id) - -#define CHECK_ERROR(error) if (dbus_error_is_set(error)) return NULL; - -#define PURPLE_DBUS_ID_TO_POINTER(ptr, id, type, error) \ - G_STMT_START { \ - ptr = (type*) purple_dbus_id_to_pointer_error \ - (id, PURPLE_DBUS_TYPE(type), #type, error); \ - CHECK_ERROR(error); \ - } G_STMT_END - - -#define PURPLE_DBUS_POINTER_TO_ID(id, ptr, error) \ - G_STMT_START { \ - id = purple_dbus_pointer_to_id_error(ptr,error); \ - CHECK_ERROR(error); \ - } G_STMT_END - - -dbus_bool_t -purple_dbus_message_get_args (DBusMessage *message, - DBusError *error, - int first_arg_type, - ...); -dbus_bool_t -purple_dbus_message_get_args_valist (DBusMessage *message, - DBusError *error, - int first_arg_type, - va_list var_args); - -dbus_bool_t -purple_dbus_message_iter_get_args (DBusMessageIter *iter, - DBusError *error, - int first_arg_type, - ...); - -dbus_bool_t -purple_dbus_message_iter_get_args_valist (DBusMessageIter *iter, - DBusError *error, - int first_arg_type, - va_list var_args); - -dbus_int32_t* purple_dbusify_GList(GList *list, dbus_int32_t *len); -dbus_int32_t* purple_dbusify_GSList(GSList *list, dbus_int32_t *len); -gpointer* purple_GList_to_array(GList *list, dbus_int32_t *len); -gpointer* purple_GSList_to_array(GSList *list, dbus_int32_t *len); -GHashTable *purple_dbus_iter_hash_table(DBusMessageIter *iter, DBusError *error); - -const char* purple_emptystr_to_null(const char *str); -const char* purple_null_to_emptystr(const char *s); - -typedef struct { - const char *name; - const char *parameters; - DBusMessage* (*handler)(DBusMessage *request, DBusError *error); -} PurpleDBusBinding; - -void purple_dbus_register_bindings(void *handle, PurpleDBusBinding *bindings); - -DBusConnection *purple_dbus_get_connection(void); - -G_END_DECLS - -#endif
--- a/libpurple/dbus-define-api.h Fri Nov 30 17:27:13 2018 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -/* - * purple - * - * Purple is the legal property of its developers, whose names are too numerous - * to list here. Please refer to the COPYRIGHT file distributed with this - * source distribution. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA - * - */ -#ifndef __GI_SCANNER__ /* hide this file from g-ir-scanner */ -#error "This file is not a valid C code and is not intended to be compiled." - -/* This file contains some of the macros from other header files as - function declarations. This does not make sense in C, but it - provides type information for the dbus-analyze-functions.py - program, which makes these macros callable by DBUS. */ - -/* buddylist.h */ -gboolean PURPLE_BUDDY_IS_ONLINE(PurpleBuddy *buddy); - -/* connection.h */ -gboolean PURPLE_CONNECTION_IS_CONNECTED(PurpleConnection *connection); - -#endif /* __GI_SCANNER__ */
--- a/libpurple/dbus-maybe.h Fri Nov 30 17:27:13 2018 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ -/* - * purple - * - * Purple is the legal property of its developers, whose names are too numerous - * to list here. Please refer to the COPYRIGHT file distributed with this - * source distribution. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA - * - */ -#ifndef _PURPLE_DBUS_MAYBE_H_ -#define _PURPLE_DBUS_MAYBE_H_ -/** - * SECTION:dbus-maybe - * @section_id: libpurple-dbus-maybe - * @short_description: <filename>dbus-maybe.h</filename> - * @title: DBUS Wrappers - * - * This file contains macros that wrap calls to the purple dbus module. - * These macros call the appropriate functions if the build includes - * dbus support and do nothing otherwise. See "dbus-server.h" for - * documentation. - */ - -#ifdef HAVE_DBUS - -#ifndef DBUS_API_SUBJECT_TO_CHANGE -#define DBUS_API_SUBJECT_TO_CHANGE -#endif - -#include "dbus-server.h" - -/* this provides a type check */ -#define PURPLE_DBUS_REGISTER_POINTER(ptr, type) { \ - type *typed_ptr = ptr; \ - purple_dbus_register_pointer(typed_ptr, PURPLE_DBUS_TYPE(type)); \ -} -#define PURPLE_DBUS_UNREGISTER_POINTER(ptr) purple_dbus_unregister_pointer(ptr) - -#else /* !HAVE_DBUS */ - -#define PURPLE_DBUS_REGISTER_POINTER(ptr, type) { \ - if (ptr) {} \ -} - -#define PURPLE_DBUS_UNREGISTER_POINTER(ptr) - -#endif /* HAVE_DBUS */ - -#endif
--- a/libpurple/dbus-purple.h Fri Nov 30 17:27:13 2018 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -/* - * purple - * - * Purple is the legal property of its developers, whose names are too numerous - * to list here. Please refer to the COPYRIGHT file distributed with this - * source distribution. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA - * - */ - -#ifndef _DBUS_PURPLE_H_ -#define _DBUS_PURPLE_H_ -/** - * SECTION:dbus-purple - * @section_id: libpurple-dbus-purple - * @short_description: <filename>dbus-purple.h</filename> - * @title: DBUS Purple defines - */ - -#define PURPLE_DBUS_SERVICE "im.pidgin.purple.PurpleService" -#define PURPLE_DBUS_PATH "/im/pidgin/purple/PurpleObject" -#define PURPLE_DBUS_INTERFACE "im.pidgin.purple.PurpleInterface" - -#endif /* _DBUS_PURPLE_H_ */
--- a/libpurple/dbus-server.c Fri Nov 30 17:27:13 2018 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,839 +0,0 @@ -/* - * purple - * - * Purple is the legal property of its developers, whose names are too numerous - * to list here. Please refer to the COPYRIGHT file distributed with this - * source distribution. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA - * - */ - -#ifndef DBUS_API_SUBJECT_TO_CHANGE -#define DBUS_API_SUBJECT_TO_CHANGE -#endif - -/* Allow the code below to see deprecated functions, so we can continue to - * export them via DBus. */ -#undef PURPLE_DISABLE_DEPRECATED - -#include "internal.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "account.h" -#include "buddylist.h" -#include "conversation.h" -#include "dbus-purple.h" -#include "dbus-server.h" -#include "dbus-useful.h" -#include "dbus-bindings.h" -#include "debug.h" -#include "core.h" -#include "savedstatuses.h" -#include "smiley.h" -#include "smiley-list.h" -#include "util.h" -#include "xmlnode.h" - - -/**************************************************************************/ -/* Purple DBUS pointer registration mechanism */ -/**************************************************************************/ - -/* - * Here we include the list of #PURPLE_DBUS_DEFINE_TYPE statements for - * all structs defined in purple. This file has been generated by the - * #dbus-analyze-types.py script. - */ - -#include "dbus-types.ch" - -/* - * The following three hashtables map are used to translate between - * pointers (nodes) and the corresponding handles (ids). - */ - -static GHashTable *map_node_id; -static GHashTable *map_id_node; -static GHashTable *map_id_type; - -static gchar *init_error; -static int dbus_request_name_reply = DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER; - -gboolean purple_dbus_is_owner(void) -{ - return(DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER == dbus_request_name_reply); -} - -/* - * This function initializes the pointer-id traslation system. It - * creates the three above hashtables and defines parents of some types. - */ -void -purple_dbus_init_ids(void) -{ - map_id_node = g_hash_table_new(g_direct_hash, g_direct_equal); - map_id_type = g_hash_table_new(g_direct_hash, g_direct_equal); - map_node_id = g_hash_table_new(g_direct_hash, g_direct_equal); - - PURPLE_DBUS_TYPE(PurpleBuddy)->parent = PURPLE_DBUS_TYPE(PurpleBlistNode); - PURPLE_DBUS_TYPE(PurpleContact)->parent = PURPLE_DBUS_TYPE(PurpleBlistNode); - PURPLE_DBUS_TYPE(PurpleChat)->parent = PURPLE_DBUS_TYPE(PurpleBlistNode); - PURPLE_DBUS_TYPE(PurpleGroup)->parent = PURPLE_DBUS_TYPE(PurpleBlistNode); -} - -void -purple_dbus_register_pointer(gpointer node, PurpleDBusType *type) -{ - static gint last_id = 0; - - g_return_if_fail(map_node_id); - g_return_if_fail(g_hash_table_lookup(map_node_id, node) == NULL); - - last_id++; - g_hash_table_insert(map_node_id, node, GINT_TO_POINTER(last_id)); - g_hash_table_insert(map_id_node, GINT_TO_POINTER(last_id), node); - g_hash_table_insert(map_id_type, GINT_TO_POINTER(last_id), type); -} - -void -purple_dbus_unregister_pointer(gpointer node) -{ - gpointer id = g_hash_table_lookup(map_node_id, node); - - g_hash_table_remove(map_node_id, node); - g_hash_table_remove(map_id_node, GINT_TO_POINTER(id)); - g_hash_table_remove(map_id_type, GINT_TO_POINTER(id)); -} - -gint -purple_dbus_pointer_to_id(gconstpointer node) -{ - gint id = GPOINTER_TO_INT(g_hash_table_lookup(map_node_id, node)); - if ((id == 0) && (node != NULL)) - { - if (purple_debug_is_verbose()) - purple_debug_warning("dbus", - "Need to register an object with the dbus subsystem." - " (If you are not a developer, please ignore this message.)\n"); - return 0; - } - return id; -} - -gpointer -purple_dbus_id_to_pointer(gint id, PurpleDBusType *type) -{ - PurpleDBusType *objtype; - - objtype = (PurpleDBusType*)g_hash_table_lookup(map_id_type, - GINT_TO_POINTER(id)); - - while (objtype != type && objtype != NULL) - objtype = objtype->parent; - - if (objtype == type) - return g_hash_table_lookup(map_id_node, GINT_TO_POINTER(id)); - else - return NULL; -} - -gint -purple_dbus_pointer_to_id_error(gconstpointer ptr, DBusError *error) -{ - gint id = purple_dbus_pointer_to_id(ptr); - - if (ptr != NULL && id == 0) - dbus_set_error(error, "im.pidgin.purple.ObjectNotFound", - "The return object is not mapped (this is a Purple error)"); - - return id; -} - -gpointer -purple_dbus_id_to_pointer_error(gint id, PurpleDBusType *type, - const char *typename, DBusError *error) -{ - gpointer ptr = purple_dbus_id_to_pointer(id, type); - - if (ptr == NULL && id != 0) - dbus_set_error(error, "im.pidgin.purple.InvalidHandle", - "%s object with ID = %i not found", typename, id); - - return ptr; -} - - -/**************************************************************************/ -/* Modified versions of some DBus functions */ -/**************************************************************************/ - -dbus_bool_t -purple_dbus_message_get_args(DBusMessage *message, - DBusError *error, int first_arg_type, ...) -{ - dbus_bool_t retval; - va_list var_args; - - va_start(var_args, first_arg_type); - retval = purple_dbus_message_get_args_valist(message, error, first_arg_type, var_args); - va_end(var_args); - - return retval; -} - -dbus_bool_t -purple_dbus_message_get_args_valist(DBusMessage *message, - DBusError *error, int first_arg_type, va_list var_args) -{ - DBusMessageIter iter; - - dbus_message_iter_init(message, &iter); - return purple_dbus_message_iter_get_args_valist(&iter, error, first_arg_type, var_args); -} - -dbus_bool_t -purple_dbus_message_iter_get_args(DBusMessageIter *iter, - DBusError *error, int first_arg_type, ...) -{ - dbus_bool_t retval; - va_list var_args; - - va_start(var_args, first_arg_type); - retval = purple_dbus_message_iter_get_args_valist(iter, error, first_arg_type, var_args); - va_end(var_args); - - return retval; -} - -#define TYPE_IS_CONTAINER(typecode) \ - ((typecode) == DBUS_TYPE_STRUCT || \ - (typecode) == DBUS_TYPE_DICT_ENTRY || \ - (typecode) == DBUS_TYPE_VARIANT || \ - (typecode) == DBUS_TYPE_ARRAY) - - -dbus_bool_t -purple_dbus_message_iter_get_args_valist(DBusMessageIter *iter, - DBusError *error, int first_arg_type, va_list var_args) -{ - int spec_type, msg_type, i; - - spec_type = first_arg_type; - - for (i = 0; spec_type != DBUS_TYPE_INVALID; i++) - { - msg_type = dbus_message_iter_get_arg_type(iter); - - if (msg_type != spec_type) - { - dbus_set_error(error, DBUS_ERROR_INVALID_ARGS, - "Argument %d is specified to be of type \"%i\", but " - "is actually of type \"%i\"\n", i, - spec_type, msg_type); - return FALSE; - } - - if (!TYPE_IS_CONTAINER(spec_type)) - { - gpointer ptr; - ptr = va_arg (var_args, gpointer); - dbus_message_iter_get_basic(iter, ptr); - } - else - { - DBusMessageIter *sub; - sub = va_arg (var_args, DBusMessageIter*); - dbus_message_iter_recurse(iter, sub); - purple_debug_info("dbus", "subiter %p:%p\n", sub, * (gpointer*) sub); - break; /* for testing only! */ - } - - spec_type = va_arg(var_args, int); - if (!dbus_message_iter_next(iter) && spec_type != DBUS_TYPE_INVALID) - { - dbus_set_error (error, DBUS_ERROR_INVALID_ARGS, - "Message has only %d arguments, but more were expected", i); - return FALSE; - } - } - - return TRUE; -} - - - -/**************************************************************************/ -/* Useful functions */ -/**************************************************************************/ - -const char *purple_emptystr_to_null(const char *str) -{ - if (str == NULL || str[0] == 0) - return NULL; - else - return str; -} - -const char * -purple_null_to_emptystr(const char *s) -{ - if (s) - return s; - else - return ""; -} - -dbus_int32_t * -purple_dbusify_GList(GList *list, dbus_int32_t *len) -{ - dbus_int32_t *array; - int i; - GList *elem; - - *len = g_list_length(list); - array = g_new0(dbus_int32_t, *len); - for (i = 0, elem = list; elem != NULL; elem = elem->next, i++) - array[i] = purple_dbus_pointer_to_id(elem->data); - - return array; -} - -dbus_int32_t * -purple_dbusify_GSList(GSList *list, dbus_int32_t *len) -{ - dbus_int32_t *array; - int i; - GSList *elem; - - *len = g_slist_length(list); - array = g_new0(dbus_int32_t, *len); - for (i = 0, elem = list; elem != NULL; elem = elem->next, i++) - array[i] = purple_dbus_pointer_to_id(elem->data); - - return array; -} - -gpointer * -purple_GList_to_array(GList *list, dbus_int32_t *len) -{ - gpointer *array; - int i; - GList *elem; - - *len = g_list_length(list); - array = g_new0(gpointer, *len); - for (i = 0, elem = list; elem != NULL; elem = elem->next, i++) - array[i] = elem->data; - - return array; -} - -gpointer * -purple_GSList_to_array(GSList *list, dbus_int32_t *len) -{ - gpointer *array; - int i; - GSList *elem; - - *len = g_slist_length(list); - array = g_new0(gpointer, *len); - for (i = 0, elem = list; elem != NULL; elem = elem->next, i++) - array[i] = elem->data; - - return array; -} - -GHashTable * -purple_dbus_iter_hash_table(DBusMessageIter *iter, DBusError *error) -{ - GHashTable *hash; - - /* we do not need to destroy strings because they are part of the message */ - hash = g_hash_table_new(g_str_hash, g_str_equal); - - do { - char *key, *value; - DBusMessageIter subiter; - - if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_DICT_ENTRY) - goto error; - /* With all due respect to Dijkstra, - * this goto is for exception - * handling, and it is ok because it - * avoids duplication of the code - * responsible for destroying the hash - * table. Exceptional instructions - * for exceptional situations. - */ - - dbus_message_iter_recurse(iter, &subiter); - if (!purple_dbus_message_iter_get_args(&subiter, error, - DBUS_TYPE_STRING, &key, - DBUS_TYPE_STRING, &value, - DBUS_TYPE_INVALID)) - goto error; /* same here */ - - g_hash_table_insert(hash, key, value); - } while (dbus_message_iter_next(iter)); - - return hash; - -error: - g_hash_table_destroy(hash); - return NULL; -} - -/**************************************************************/ -/* DBus bindings ... */ -/**************************************************************/ - -static DBusConnection *purple_dbus_connection; - -DBusConnection * -purple_dbus_get_connection(void) -{ - return purple_dbus_connection; -} - -#include "dbus-bindings.ch" -#include "dbus-signals.ch" - -static gboolean -purple_dbus_dispatch_cb(DBusConnection *connection, - DBusMessage *message, void *user_data) -{ - const char *name; - PurpleDBusBinding *bindings; - int i; - - bindings = (PurpleDBusBinding*) user_data; - - if (!dbus_message_has_path(message, PURPLE_DBUS_PATH)) - return FALSE; - - name = dbus_message_get_member(message); - - if (name == NULL) - return FALSE; - - if (dbus_message_get_type(message) != DBUS_MESSAGE_TYPE_METHOD_CALL) - return FALSE; - - for (i = 0; bindings[i].name; i++) - if (purple_strequal(name, bindings[i].name)) - { - DBusMessage *reply; - DBusError error; - - dbus_error_init(&error); - - reply = bindings[i].handler(message, &error); - - if (reply == NULL && dbus_error_is_set(&error)) - reply = dbus_message_new_error (message, - error.name, error.message); - - if (reply != NULL) - { - dbus_connection_send(connection, reply, NULL); - dbus_message_unref(reply); - } - - return TRUE; /* return reply! */ - } - - return FALSE; -} - - -static const char * -dbus_gettext(const char **ptr) -{ - const char *text = *ptr; - *ptr += strlen(text) + 1; - return text; -} - -static void -purple_dbus_introspect_cb(GList **bindings_list, void *bindings) -{ - *bindings_list = g_list_prepend(*bindings_list, bindings); -} - -static DBusMessage *purple_dbus_introspect(DBusMessage *message) -{ - DBusMessage *reply; - GString *str; - GList *bindings_list, *node; - const char *signals; - const char *type; - const char *pointer_type; - - str = g_string_sized_new(0x1000); /* TODO: why this size? */ - - g_string_append(str, "<!DOCTYPE node PUBLIC '-//freedesktop//DTD D-BUS Object Introspection 1.0//EN' 'http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd'>\n"); - g_string_append_printf(str, "<node name='%s'>\n", PURPLE_DBUS_PATH); - g_string_append(str, " <interface name='org.freedesktop.DBus.Introspectable'>\n <method name='Introspect'>\n <arg name='data' direction='out' type='s'/>\n </method>\n </interface>\n\n"); - - g_string_append_printf(str, " <interface name='%s'>\n", PURPLE_DBUS_INTERFACE); - - bindings_list = NULL; - purple_signal_emit(purple_dbus_get_handle(), "dbus-introspect", &bindings_list); - - for (node = bindings_list; node; node = node->next) - { - PurpleDBusBinding *bindings; - int i; - - bindings = (PurpleDBusBinding*)node->data; - - for (i = 0; bindings[i].name; i++) - { - const char *text; - - g_string_append_printf(str, " <method name='%s'>\n", bindings[i].name); - - text = bindings[i].parameters; - while (*text) - { - const char *name, *direction, *type; - - direction = dbus_gettext(&text); - type = dbus_gettext(&text); - name = dbus_gettext(&text); - - g_string_append_printf(str, - " <arg name='%s' type='%s' direction='%s'/>\n", - name, type, direction); - } - g_string_append(str, " </method>\n"); - } - } - - if (sizeof(int) == sizeof(dbus_int32_t)) - pointer_type = "type='i'"; - else - pointer_type = "type='x'"; - - signals = dbus_signals; - while ((type = strstr(signals, "type='p'")) != NULL) { - g_string_append_len(str, signals, type - signals); - g_string_append(str, pointer_type); - signals = type + sizeof("type='p'") - 1; - } - g_string_append(str, signals); - - g_string_append(str, " </interface>\n</node>\n"); - - reply = dbus_message_new_method_return(message); - dbus_message_append_args(reply, DBUS_TYPE_STRING, &(str->str), - DBUS_TYPE_INVALID); - g_string_free(str, TRUE); - g_list_free(bindings_list); - - return reply; -} - -static DBusHandlerResult -purple_dbus_dispatch(DBusConnection *connection, - DBusMessage *message, void *user_data) -{ - if (purple_signal_emit_return_1(purple_dbus_get_handle(), - "dbus-method-called", connection, message)) - return DBUS_HANDLER_RESULT_HANDLED; - - if (dbus_message_is_method_call(message, DBUS_INTERFACE_INTROSPECTABLE, "Introspect") && - dbus_message_has_path(message, PURPLE_DBUS_PATH)) - { - DBusMessage *reply; - reply = purple_dbus_introspect(message); - dbus_connection_send (connection, reply, NULL); - dbus_message_unref(reply); - return DBUS_HANDLER_RESULT_HANDLED; - } - - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; -} - -void -purple_dbus_register_bindings(void *handle, PurpleDBusBinding *bindings) -{ - purple_signal_connect(purple_dbus_get_handle(), "dbus-method-called", - handle, - PURPLE_CALLBACK(purple_dbus_dispatch_cb), - bindings); - purple_signal_connect(purple_dbus_get_handle(), "dbus-introspect", - handle, - PURPLE_CALLBACK(purple_dbus_introspect_cb), - bindings); -} - -static void -purple_dbus_dispatch_init(void) -{ - static DBusObjectPathVTable vtable = {NULL, &purple_dbus_dispatch, NULL, NULL, NULL, NULL}; - DBusError error; - - dbus_error_init(&error); - purple_dbus_connection = dbus_bus_get(DBUS_BUS_STARTER, &error); - - if (purple_dbus_connection == NULL) - { - init_error = g_strdup_printf(N_("Failed to get connection: %s"), error.message); - dbus_error_free(&error); - return; - } - - /* Do not allow libdbus to exit on connection failure (This may - work around random exit(1) on SIGPIPE errors) */ - dbus_connection_set_exit_on_disconnect (purple_dbus_connection, FALSE); - - if (!dbus_connection_register_object_path(purple_dbus_connection, - PURPLE_DBUS_PATH, &vtable, NULL)) - { - init_error = g_strdup_printf(N_("Failed to get name: %s"), error.name); - dbus_error_free(&error); - return; - } - - dbus_request_name_reply = dbus_bus_request_name(purple_dbus_connection, - PURPLE_DBUS_SERVICE, 0, &error); - - if (dbus_error_is_set(&error)) - { - dbus_connection_unref(purple_dbus_connection); - purple_dbus_connection = NULL; - init_error = g_strdup_printf(N_("Failed to get serv name: %s"), error.name); - dbus_error_free(&error); - return; - } - - dbus_connection_setup_with_g_main(purple_dbus_connection, NULL); - - purple_signal_register(purple_dbus_get_handle(), "dbus-method-called", - purple_marshal_BOOLEAN__POINTER_POINTER, - G_TYPE_BOOLEAN, 2, G_TYPE_POINTER, G_TYPE_POINTER); - - purple_signal_register(purple_dbus_get_handle(), "dbus-introspect", - purple_marshal_VOID__POINTER, G_TYPE_NONE, 1, - G_TYPE_POINTER); /* pointer to a pointer */ - - PURPLE_DBUS_REGISTER_BINDINGS(purple_dbus_get_handle()); - - if (purple_debug_is_verbose()) - purple_debug_misc("dbus", "initialized"); -} - - - -/**************************************************************************/ -/* Signals */ -/**************************************************************************/ - - - -static char * -purple_dbus_convert_signal_name(const char *purple_name) -{ - int purple_index, g_index; - char *g_name = g_new(char, strlen(purple_name) + 1); - gboolean capitalize_next = TRUE; - - for (purple_index = g_index = 0; purple_name[purple_index]; purple_index++) - if (purple_name[purple_index] != '-' && purple_name[purple_index] != '_') - { - if (capitalize_next) - g_name[g_index++] = g_ascii_toupper(purple_name[purple_index]); - else - g_name[g_index++] = purple_name[purple_index]; - capitalize_next = FALSE; - } else - capitalize_next = TRUE; - - g_name[g_index] = 0; - - return g_name; -} - -#define my_arg(type) (ptr != NULL ? * ((type *)ptr) : va_arg(data, type)) - -static gboolean -purple_dbus_message_append_values(DBusMessageIter *iter, - int number, GType *types, va_list data) -{ - int i; - gboolean error = FALSE; - - for (i = 0; i < number; i++) - { - const char *str; - int id; - gint xint; - guint xuint; - gint64 xint64; - guint64 xuint64; - gboolean xboolean; - gpointer ptr = NULL; - gpointer val; - - switch (types[i]) - { - case G_TYPE_INT: - xint = my_arg(gint); - dbus_message_iter_append_basic(iter, DBUS_TYPE_INT32, &xint); - break; - case G_TYPE_UINT: - xuint = my_arg(guint); - dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT32, &xuint); - break; - case G_TYPE_INT64: - xint64 = my_arg(gint64); - dbus_message_iter_append_basic(iter, DBUS_TYPE_INT64, &xint64); - break; - case G_TYPE_UINT64: - xuint64 = my_arg(guint64); - dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT64, &xuint64); - break; - case G_TYPE_BOOLEAN: - xboolean = my_arg(gboolean); - dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &xboolean); - break; - case G_TYPE_STRING: - str = purple_null_to_emptystr(my_arg(char*)); - if (!g_utf8_validate(str, -1, NULL)) { - gchar *tmp; - purple_debug_error("dbus", "Invalid UTF-8 string passed to signal, emitting salvaged string!\n"); - tmp = purple_utf8_salvage(str); - dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &tmp); - g_free(tmp); - } else { - dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &str); - } - break; - default: - if (G_TYPE_IS_OBJECT(types[i]) || - G_TYPE_IS_BOXED(types[i]) || - types[i] == G_TYPE_POINTER ) - { - val = my_arg(gpointer); - id = purple_dbus_pointer_to_id(val); - if (id == 0 && val != NULL) - error = TRUE; /* Some error happened. */ - dbus_message_iter_append_basic(iter, - (sizeof(id) == sizeof(dbus_int32_t)) ? DBUS_TYPE_INT32 : DBUS_TYPE_INT64, &id); - } - else if (G_TYPE_IS_ENUM(types[i])) - { - xint = my_arg(gint); - dbus_message_iter_append_basic(iter, DBUS_TYPE_INT32, &xint); - } - else /* no conversion implemented */ - { - g_return_val_if_reached(TRUE); - } - } - } - return error; -} - -#undef my_arg - -void -purple_dbus_signal_emit_purple(const char *name, int num_values, - GType *types, va_list vargs) -{ - DBusMessage *signal; - DBusMessageIter iter; - char *newname; - - if (purple_dbus_connection == NULL) - return; - - /* - * The test below is a hack that prevents our "dbus-method-called" - * signal from being propagated to dbus. What we really need is a - * flag for each signal that states whether this signal is to be - * dbus-propagated or not. - */ - if (purple_strequal(name, "dbus-method-called")) - return; - - newname = purple_dbus_convert_signal_name(name); - signal = dbus_message_new_signal(PURPLE_DBUS_PATH, PURPLE_DBUS_INTERFACE, newname); - dbus_message_iter_init_append(signal, &iter); - - if (purple_dbus_message_append_values(&iter, num_values, types, vargs)) - if (purple_debug_is_verbose()) - purple_debug_warning("dbus", - "The signal \"%s\" caused some dbus error." - " (If you are not a developer, please ignore this message.)\n", - name); - - dbus_connection_send(purple_dbus_connection, signal, NULL); - - g_free(newname); - dbus_message_unref(signal); -} - -const char * -purple_dbus_get_init_error(void) -{ - return init_error; -} - -void * -purple_dbus_get_handle(void) -{ - static int handle; - - return &handle; -} - -void -purple_dbus_init(void) -{ - dbus_g_thread_init(); - - purple_dbus_init_ids(); - - g_free(init_error); - init_error = NULL; - purple_dbus_dispatch_init(); - if (init_error != NULL) - purple_debug_error("dbus", "%s\n", init_error); -} - -void -purple_dbus_uninit(void) -{ - DBusError error; - if (!purple_dbus_connection) - return; - - dbus_error_init(&error); - dbus_connection_unregister_object_path(purple_dbus_connection, PURPLE_DBUS_PATH); - dbus_bus_release_name(purple_dbus_connection, PURPLE_DBUS_SERVICE, &error); - dbus_error_free(&error); - dbus_connection_unref(purple_dbus_connection); - purple_dbus_connection = NULL; - purple_signals_disconnect_by_handle(purple_dbus_get_handle()); - g_free(init_error); - init_error = NULL; -} -
--- a/libpurple/dbus-server.h Fri Nov 30 17:27:13 2018 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,229 +0,0 @@ -/* purple - * - * Purple is the legal property of its developers, whose names are too numerous - * to list here. Please refer to the COPYRIGHT file distributed with this - * source distribution. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA - */ - -#ifndef _PURPLE_DBUS_SERVER_H_ -#define _PURPLE_DBUS_SERVER_H_ -/** - * SECTION:dbus-server - * @section_id: libpurple-dbus-server - * @short_description: <filename>dbus-server.h</filename> - * @title: DBUS Server - * @see_also: <link linkend="chapter-signals-dbus-server">D-Bus Server signals</link> - */ - -#include <glib.h> - -#include "dbus-purple.h" - -G_BEGIN_DECLS - -typedef struct _PurpleDBusType PurpleDBusType; - -/** - * PurpleDBusType: - * - * Types of pointers are identified by the ADDRESS of a PurpleDbusType - * object. This way, plugins can easily access types defined in purple - * proper as well as introduce their own types that will not conflict - * with those introduced by other plugins. - * - * The structure PurpleDbusType has only one element (PurpleDBusType::parent), a - * contains a pointer to the parent type, or %NULL if the type has no - * parent. Parent means the same as the base class in object oriented - * programming. - */ -struct _PurpleDBusType { - PurpleDBusType *parent; -}; - -#include "dbus-bindings.h" - -/* By convention, the PurpleDBusType variable representing each structure - PurpleSomeStructure has the name PURPLE_DBUS_TYPE_PurpleSomeStructure. - The following macros facilitate defining such variables - - #PURPLE_DBUS_DECLARE_TYPE declares an extern variable representing a - given type, for use in header files. - - #PURPLE_DBUS_DEFINE_TYPE defines a variable representing a given - type, use in .c files. It defines a new type without a parent; for - types with a parent use #PURPLE_DBUS_DEFINE_INHERITING_TYPE. - */ - -#define PURPLE_DBUS_TYPE(type) (&PURPLE_DBUS_TYPE_##type) - - -#define PURPLE_DBUS_DECLARE_TYPE(type) \ - extern PurpleDBusType PURPLE_DBUS_TYPE_##type; - -#define PURPLE_DBUS_DEFINE_TYPE(type) \ - PurpleDBusType PURPLE_DBUS_TYPE_##type = { NULL }; - -#define PURPLE_DBUS_DEFINE_INHERITING_TYPE(type, parent) \ - PurpleDBusType PURPLE_DBUS_TYPE_##type = { PURPLE_DBUS_TYPE(parent) }; - -#define PURPLE_DBUS_RETURN_FALSE_IF_DISABLED(plugin) \ - if (purple_dbus_get_init_error() != NULL) \ - { \ - gchar *title; \ - title = g_strdup_printf("Unable to Load %s Plugin", \ - purple_plugin_info_get_name(purple_plugin_get_info(plugin))); \ - purple_notify_error(NULL, title, \ - _("Purple's D-BUS server is not running for the reason listed below"), \ - _(purple_dbus_get_init_error()), NULL); \ - g_free(title); \ - return FALSE; \ - } - -/** - * purple_dbus_init_ids: - * - * Initializes purple dbus pointer registration engine. - * - * Remote dbus applications need a way of addressing objects exposed - * by purple to the outside world. In purple itself, these objects (such - * as PurpleBuddy and company) are identified by pointers. The purple - * dbus pointer registration engine converts pointers to handles and - * back. - * - * In order for an object to participate in the scheme, it must - * register itself and its type with the engine. This registration - * allocates an integer id which can be resolved to the pointer and - * back. - * - * Handles are not persistent. They are reissued every time purple is - * started. This is not good; external applications that use purple - * should work even whether purple was restarted in the middle of the - * interaction. - * - * Pointer registration is only a temporary solution. When PurpleBuddy - * and similar structures have been converted into gobjects, this - * registration will be done automatically by objects themselves. - * - * By the way, this kind of object-handle translation should be so - * common that there must be a library (maybe even glib) that - * implements it. I feel a bit like reinventing the wheel here. - */ -void purple_dbus_init_ids(void); - -/** - * purple_dbus_register_pointer: - * @node: The pointer to register. - * @type: Type of that pointer. - * - * Registers a typed pointer. - */ -void purple_dbus_register_pointer(gpointer node, PurpleDBusType *type); - -/** - * purple_dbus_unregister_pointer: - * @node: The pointer to register. - * - * Unregisters a pointer previously registered with - * purple_dbus_register_pointer. - */ -void purple_dbus_unregister_pointer(gpointer node); - -/** - * purple_dbus_signal_emit_purple: - * @name: The name of the signal ("bla-bla-blaa") - * @num_values: The number of parameters. - * @types: Array of GTypes representing the types of the parameters. - * @vargs: A va_list containing the actual parameters. - * - * Emits a dbus signal. - */ -void purple_dbus_signal_emit_purple(const char *name, int num_values, - GType *types, va_list vargs); - -/** - * purple_dbus_get_init_error: - * - * Returns whether Purple's D-BUS subsystem is up and running. If it's - * NOT running then #purple_dbus_dispatch_init failed for some reason, - * and a message should have been purple_debug_error()'ed. - * - * Purple plugins that use D-BUS should use the - * PURPLE_DBUS_RETURN_FALSE_IF_DISABLED macro to short-circuit - * initialization if Purple's D-BUS subsystem is not running. - * - * Returns: If the D-BUS subsystem started with no problems then this - * will return NULL and everything will be hunky dory. If - * there was an error initializing the D-BUS subsystem then - * this will return an error message explaining why. - */ -const char *purple_dbus_get_init_error(void); - -/** - * purple_dbus_get_handle: - * - * Returns the dbus subsystem handle. - * - * Returns: The dbus subsystem handle. - */ -void *purple_dbus_get_handle(void); - -/** - * purple_dbus_is_owner: - * - * Determines whether this instance owns the DBus service name - */ -gboolean purple_dbus_is_owner(void); - -/** - * purple_dbus_init: - * - * Starts Purple's D-BUS server. It is responsible for handling DBUS - * requests from other applications. - */ -void purple_dbus_init(void); - -/** - * purple_dbus_uninit: - * - * Uninitializes Purple's D-BUS server. - */ -void purple_dbus_uninit(void); - -/** - * DBUS_EXPORT: - * - * Macro #DBUS_EXPORT expands to nothing. It is used to indicate to the - * dbus-analyze-functions.py script that the given function should be - * available to other applications through DBUS. If - * dbus-analyze-functions.py is run without the "--export-only" option, - * this prefix is ignored. - */ -#ifndef DBUS_EXPORT -#define DBUS_EXPORT -#endif - -/* - Here we include the list of #PURPLE_DBUS_DECLARE_TYPE statements for - all structs defined in purple. This file has been generated by the - #dbus-analyze-types.py script. -*/ - -#include "dbus-types.h" - -G_END_DECLS - -#endif /* _PURPLE_DBUS_SERVER_H_ */
--- a/libpurple/dbus-useful.c Fri Nov 30 17:27:13 2018 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,76 +0,0 @@ -/* - * purple - * - * Purple is the legal property of its developers, whose names are too numerous - * to list here. Please refer to the COPYRIGHT file distributed with this - * source distribution. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA - * - */ -#include <string.h> -#include <glib.h> - -#include "dbus-useful.h" -#include "accounts.h" -#include "conversation.h" -#include "util.h" - - -PurpleAccount * -purple_accounts_find_ext(const char *name, const char *protocol_id, - gboolean (*account_test)(const PurpleAccount *account)) -{ - PurpleAccount *result = NULL; - GList *l; - char *who; - - if (name) - who = g_strdup(purple_normalize(NULL, name)); - else - who = NULL; - - for (l = purple_accounts_get_all(); l != NULL; l = l->next) { - PurpleAccount *account = (PurpleAccount *)l->data; - - if (who && !purple_strequal(purple_normalize(NULL, purple_account_get_username(account)), who)) - continue; - - if (protocol_id && !purple_strequal(purple_account_get_protocol_id(account), protocol_id)) - continue; - - if (account_test && !account_test(account)) - continue; - - result = account; - break; - } - - g_free(who); - - return result; -} - -PurpleAccount *purple_accounts_find_any(const char *name, const char *protocol) -{ - return purple_accounts_find_ext(name, protocol, NULL); -} - -PurpleAccount *purple_accounts_find_connected(const char *name, const char *protocol) -{ - return purple_accounts_find_ext(name, protocol, purple_account_is_connected); -} - -
--- a/libpurple/dbus-useful.h Fri Nov 30 17:27:13 2018 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -/* - * purple - * - * Purple is the legal property of its developers, whose names are too numerous - * to list here. Please refer to the COPYRIGHT file distributed with this - * source distribution. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA - * - */ -#ifndef _PURPLE_DBUS_USEFUL_H_ -#define _PURPLE_DBUS_USEFUL_H_ -/** - * SECTION:dbus-useful - * @section_id: libpurple-dbus-useful - * @short_description: <filename>dbus-useful.h</filename> - * @title: Misc functions for DBUS server - */ - -#include "conversation.h" - -G_BEGIN_DECLS - -PurpleAccount *purple_accounts_find_ext(const char *name, const char *protocol_id, - gboolean (*account_test)(const PurpleAccount *account)); - -PurpleAccount *purple_accounts_find_any(const char *name, const char *protocol); - -PurpleAccount *purple_accounts_find_connected(const char *name, const char *protocol); - -G_END_DECLS - -#endif
--- a/libpurple/group.c Fri Nov 30 17:27:13 2018 -0600 +++ b/libpurple/group.c Tue Dec 04 02:44:33 2018 +0000 @@ -21,7 +21,6 @@ * */ -#include "dbus-maybe.h" #include "group.h" #include "internal.h" /* TODO: we need to kill this */ @@ -288,7 +287,6 @@ /* GObject initialization function */ static void purple_group_init(GTypeInstance *instance, gpointer klass) { - PURPLE_DBUS_REGISTER_POINTER(PURPLE_GROUP(instance), PurpleGroup); } /* Called when done constructing */ @@ -311,8 +309,6 @@ purple_group_finalize(GObject *object) { g_free(PURPLE_GROUP_GET_PRIVATE(object)->name); - PURPLE_DBUS_UNREGISTER_POINTER(object); - G_OBJECT_CLASS(parent_class)->finalize(object); }
--- a/libpurple/keyring.c Fri Nov 30 17:27:13 2018 -0600 +++ b/libpurple/keyring.c Tue Dec 04 02:44:33 2018 +0000 @@ -27,7 +27,6 @@ #include "core.h" #include "debug.h" #include "internal.h" -#include "dbus-maybe.h" #include "plugins.h" struct _PurpleKeyring @@ -488,7 +487,6 @@ purple_keyring_set_inuse(keyring, TRUE, NULL, NULL); } - PURPLE_DBUS_REGISTER_POINTER(keyring, PurpleKeyring); purple_signal_emit(purple_keyring_get_handle(), "keyring-register", keyring_id, keyring); if (purple_debug_is_verbose()) { @@ -516,7 +514,6 @@ purple_signal_emit(purple_keyring_get_handle(), "keyring-unregister", keyring_id, keyring); - PURPLE_DBUS_UNREGISTER_POINTER(keyring); inuse = purple_keyring_get_inuse(); fallback = purple_keyring_find_keyring_by_id(PURPLE_DEFAULT_KEYRING);
--- a/libpurple/log.c Fri Nov 30 17:27:13 2018 -0600 +++ b/libpurple/log.c Tue Dec 04 02:44:33 2018 +0000 @@ -21,7 +21,6 @@ #include "internal.h" #include "account.h" -#include "dbus-maybe.h" #include "debug.h" #include "glibcompat.h" #include "image-store.h" @@ -80,7 +79,6 @@ /* IMPORTANT: Make sure to initialize all the members of PurpleLog */ log = g_slice_new(PurpleLog); - PURPLE_DBUS_REGISTER_POINTER(log, PurpleLog); log->type = type; log->name = g_strdup(purple_normalize(account, name)); @@ -107,7 +105,6 @@ if (log->time) g_date_time_unref(log->time); - PURPLE_DBUS_UNREGISTER_POINTER(log); g_slice_free(PurpleLog, log); }
--- a/libpurple/meson.build Fri Nov 30 17:27:13 2018 -0600 +++ b/libpurple/meson.build Tue Dec 04 02:44:33 2018 +0000 @@ -99,7 +99,6 @@ 'conversations.h', 'core.h', 'countingnode.h', - 'dbus-maybe.h', 'debug.h', 'e2ee.h', 'eventloop.h', @@ -243,180 +242,26 @@ enums_h, ] -if enable_dbus - -# purple dbus server - -dbus_sources = [ - 'dbus-server.c', - 'dbus-useful.c' -] -dbus_headers = [ - 'dbus-server.h', - 'dbus-bindings.h', - 'dbus-purple.h', - 'dbus-useful.h', - 'dbus-define-api.h', -] -dbus_exported = [ - 'dbus-useful.h', - 'dbus-define-api.h', - 'account.h', - 'accounts.h', - 'blistnode.h', - 'buddy.h', - 'buddylist.h', - 'buddyicon.h', - 'connection.h', - 'conversation.h', - 'conversationtypes.h', - 'conversations.h', - 'core.h', - 'xfer.h', - 'log.h', - 'notify.h', - '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' -] - -purple_build_coreheaders = purple_coreheaders + purple_mediaheaders -purple_build_coreheaders += purple_builtheaders - - -# We should probably make this better -dbus_signals = purple_coresources + ['protocols/irc/irc.c', 'protocols/jabber/jabber.c'] - -dbus_analyze_functions = files('dbus-analyze-functions.py')[0] -dbus_analyze_signals = files('dbus-analyze-signals.py')[0] -dbus_analyze_types = files('dbus-analyze-types.py')[0] - -dbus_types_c = custom_target('dbus_types_c', - input : purple_build_coreheaders, - output : 'dbus-types.ch', - command : [python, dbus_analyze_types, '-o', '@OUTPUT@', - '--pattern=PURPLE_DBUS_DEFINE_TYPE(%s)', '@INPUT@']) - -dbus_types_h = custom_target('dbus_types_h', - input : purple_build_coreheaders, - output : 'dbus-types.h', - command : [python, dbus_analyze_types, '-o', '@OUTPUT@', - '--pattern=PURPLE_DBUS_DECLARE_TYPE(%s)', '@INPUT@'], - install : true, - install_dir : join_paths(get_option('includedir'), 'libpurple')) - -dbus_bindings_c = custom_target('dbus_bindings_c', - input : dbus_exported, - output : 'dbus-bindings.ch', - command : [python, dbus_analyze_functions, '-o', '@OUTPUT@', - '@INPUT@']) - -dbus_signals_c = custom_target('dbus_signals_c', - input : dbus_signals, - output : 'dbus-signals.ch', - command : [python, dbus_analyze_signals, '-o', '@OUTPUT@', - '@INPUT@']) - -dbus_builtheaders = [dbus_types_h] -dbus_builtsources = [dbus_types_c, dbus_bindings_c, dbus_signals_c] - -# libpurple-client - -purple_client_bindings_h1 = custom_target('purple_client_bindings_h1', - input : purple_build_coreheaders, - output : 'purple-client-bindings1.h', - command : [ - python, dbus_analyze_types, - '--keyword=enum', '--verbatim', '-o', '@OUTPUT@', '@INPUT@' - ] -) - -purple_client_bindings_h2 = custom_target('purple_client_bindings_h2', - input : dbus_exported, - output : 'purple-client-bindings2.h', - command : [ - python, dbus_analyze_functions, - '--client', '--headers', '-o', '@OUTPUT@', '@INPUT@' - ] -) - -purple_client_bindings_h = custom_target('purple_client_bindings_h', - input : [purple_client_bindings_h1, purple_client_bindings_h2], - output : 'purple-client-bindings.h', - capture : true, - command : ['cat', '@INPUT@']) - -purple_client_bindings_c = custom_target('purple_client_bindings_c', - input : dbus_exported, - output : 'purple-client-bindings.ch', - command : [ - python, dbus_analyze_functions, - '--client', '-o', '@OUTPUT@', '@INPUT@' - ] -) - -libpurple_client = library('purple-client', - 'purple-client.c', purple_client_bindings_c, purple_client_bindings_h, - version : PURPLE_LIB_VERSION, - dependencies : [dbus, dbus_glib], - install : true) - -# scripts - -install_data(['purple-remote', 'purple-send', 'purple-send-async'], - install_dir : get_option('bindir')) - -else - -dbus_sources = [] -dbus_headers = [] -dbus_builtsources = [] -dbus_builtheaders = [] - -endif - libpurple_inc = include_directories('.') libpurple = library('purple', purple_coresources + purple_builtsources + - dbus_sources + dbus_builtsources + - purple_builtheaders + dbus_builtheaders, + purple_builtheaders, include_directories : [toplevel_inc, libpurple_inc], install : true, version : PURPLE_LIB_VERSION, dependencies : # static_link_libs - [dbus, dbus_glib, dnsapi, ws2_32, glib, gio, gplugin, libxml, + [dnsapi, ws2_32, glib, gio, gplugin, libxml, farstream, gstreamer, gstreamer_video, gstreamer_app, json, math]) libpurple_dep = declare_dependency( - # Ensure purple/dbus headers built before any dependencies: - sources : [purple_builtheaders, dbus_builtheaders], + # Ensure purple headers built before any dependencies: + sources : [purple_builtheaders], include_directories : [toplevel_inc, libpurple_inc], link_with : libpurple, dependencies : [gstreamer, gplugin, glib, gio]) -if enable_dbus - -# purple-client-example - -purple_client_example = executable('purple-client-example', - 'purple-client-example.c', purple_client_bindings_h, - link_with : [libpurple_client, libpurple], - dependencies : [dbus, dbus_glib, glib], - install : true) - -endif - -install_headers(purple_coreheaders + dbus_headers, +install_headers(purple_coreheaders, subdir : 'libpurple') install_headers(purple_mediaheaders, @@ -434,15 +279,12 @@ if enable_introspection introspection_sources = (purple_coreheaders + purple_builtheaders + - dbus_headers + purple_mediaheaders) + purple_mediaheaders) Purple_gir_includes = ['GObject-2.0', 'Gio-2.0'] if PLUGINS Purple_gir_includes += ['GPlugin-0.0'] endif - if enable_dbus - Purple_gir_includes += ['DBus-1.0', 'DBusGLib-1.0'] - endif if enable_gst Purple_gir_includes += ['Gst-1.0'] endif
--- a/libpurple/message.c Fri Nov 30 17:27:13 2018 -0600 +++ b/libpurple/message.c Tue Dec 04 02:44:33 2018 +0000 @@ -20,7 +20,6 @@ */ #include "internal.h" -#include "dbus-maybe.h" #include "glibcompat.h" #include "debug.h" @@ -241,7 +240,6 @@ PurpleMessage *msg = PURPLE_MESSAGE(instance); PurpleMessagePrivate *priv = PURPLE_MESSAGE_GET_PRIVATE(msg); - PURPLE_DBUS_REGISTER_POINTER(msg, PurpleMessage); priv->id = ++max_id; g_hash_table_insert(messages, GINT_TO_POINTER(max_id), msg);
--- a/libpurple/notify.c Fri Nov 30 17:27:13 2018 -0600 +++ b/libpurple/notify.c Tue Dec 04 02:44:33 2018 +0000 @@ -21,7 +21,6 @@ #define _PURPLE_NOTIFY_C_ #include "internal.h" -#include "dbus-maybe.h" #include "notify.h" static PurpleNotifyUiOps *notify_ui_ops = NULL; @@ -441,7 +440,6 @@ PurpleNotifyUserInfoEntry *user_info_entry; user_info_entry = g_new0(PurpleNotifyUserInfoEntry, 1); - PURPLE_DBUS_REGISTER_POINTER(user_info_entry, PurpleNotifyUserInfoEntry); user_info_entry->label = g_strdup(label); user_info_entry->value = g_strdup(value); user_info_entry->type = PURPLE_NOTIFY_USER_INFO_ENTRY_PAIR; @@ -456,7 +454,6 @@ g_free(user_info_entry->label); g_free(user_info_entry->value); - PURPLE_DBUS_UNREGISTER_POINTER(user_info_entry); g_free(user_info_entry); } @@ -466,7 +463,6 @@ PurpleNotifyUserInfo *user_info; user_info = g_new0(PurpleNotifyUserInfo, 1); - PURPLE_DBUS_REGISTER_POINTER(user_info, PurpleNotifyUserInfo); g_queue_init(&user_info->entries); return user_info; @@ -484,7 +480,6 @@ } g_queue_clear(&user_info->entries); - PURPLE_DBUS_UNREGISTER_POINTER(user_info); g_free(user_info); }
--- a/libpurple/plugins.c Fri Nov 30 17:27:13 2018 -0600 +++ b/libpurple/plugins.c Tue Dec 04 02:44:33 2018 +0000 @@ -23,7 +23,6 @@ #include "core.h" #include "debug.h" -#include "dbus-maybe.h" #include "enums.h" #include "plugins.h" @@ -368,7 +367,6 @@ static void purple_plugin_info_init(GTypeInstance *instance, gpointer klass) { - PURPLE_DBUS_REGISTER_POINTER(PURPLE_PLUGIN_INFO(instance), PurplePluginInfo); } /* Set method for GObject properties */ @@ -483,8 +481,6 @@ g_free(priv->ui_requirement); g_free(priv->error); - PURPLE_DBUS_UNREGISTER_POINTER(object); - parent_class->finalize(object); }
--- a/libpurple/plugins/dbus-buddyicons-example.py Fri Nov 30 17:27:13 2018 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -#!/usr/bin/env python -# -# Print the aliases of buddies who have a buddy-icon set. -# -# Purple is the legal property of its developers, whose names are too numerous -# to list here. Please refer to the COPYRIGHT file distributed with this -# source distribution. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA -# - -from __future__ import absolute_import, division, print_function - -import dbus - - -bus = dbus.SessionBus() -obj = bus.get_object("im.pidgin.purple.PurpleService", - "/im/pidgin/purple/PurpleObject") -purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface") - -node = purple.PurpleBlistGetRoot() -while node != 0: - if purple.PurpleBlistNodeIsBuddy(node): - icon = purple.PurpleBuddyGetIcon(node) - if icon != 0: - print(purple.PurpleBuddyGetAlias(node)) - node = purple.PurpleBlistNodeNext(node, 0)
--- a/libpurple/plugins/dbus-example.c Fri Nov 30 17:27:13 2018 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,166 +0,0 @@ -/* - * This is an example of a purple dbus plugin. After enabling this - * plugin, the following commands should work from the command line: - * - * prompt$ purple-send DbusExampleGetHelloObject - * - * returns, say: int32 74 - * - * prompt$ purple-send DbusExampleGetText int32:74 - * - * returns: string "Hello." - * - * prompt$ purple-send DbusExampleSetText int32:74 string:Bye! - * - * prompt$ purple-send DbusExampleGetText int32:74 - * - * returns: string "Bye!" - * - * Purple is the legal property of its developers, whose names are too numerous - * to list here. Please refer to the COPYRIGHT file distributed with this - * source distribution. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA - */ - -/* 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. */ -#include "internal.h" - -/* This file defines PURPLE_PLUGINS and includes all the libpurple headers */ -#include <purple.h> - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#define DBUS_API_SUBJECT_TO_CHANGE -#include "dbus-maybe.h" -#include "dbus-bindings.h" - -typedef struct { - char *text; -} PurpleText; - -/* This makes the structure PurpleText visible to the purple-dbus type - system. It defines PurpleText as a type with no parent. From now - on, we will be able to register pointers to structures of this - type. You to dbus-define types you want to be directly accessible - by external applications. */ -PURPLE_DBUS_DEFINE_TYPE(PurpleText) - -/* Here we make four functions accessible to other applications by - DBus. These functions can access types defined in purple proper - (PurpleBuddy) as well as the types defined in the plugin (PurpleText). */ -DBUS_EXPORT PurpleText* dbus_example_get_hello_object(void); -DBUS_EXPORT void dbus_example_set_text(PurpleText *obj, const char *text); -DBUS_EXPORT const char *dbus_example_get_text(PurpleText *obj); -DBUS_EXPORT const char *dbus_example_get_buddy_name(PurpleBuddy *buddy); - -/* This file has been generated by the #dbus-analize-functions.py - script. It contains dbus wrappers for the four functions declared - above. */ -#include "dbus-example-bindings.ch" - -/* This is the PurpleText object we want to make publicly visible. */ -static PurpleText hello; - -/* Here come the definitions of the four exported functions. */ -DBUS_EXPORT PurpleText* dbus_example_get_hello_object(void) -{ - return &hello; -} - -DBUS_EXPORT void dbus_example_set_text(PurpleText *obj, const char *text) -{ - if (obj != NULL) { - g_free(obj->text); - obj->text = g_strdup(text); - } -} - -DBUS_EXPORT const char *dbus_example_get_text(PurpleText *obj) -{ - if (obj != NULL) - return obj->text; - else - return NULL; -} - -DBUS_EXPORT const char *dbus_example_get_buddy_name(PurpleBuddy *buddy) -{ - return purple_buddy_get_name(buddy); -} - -/* And now standard plugin stuff */ - -static PurplePluginInfo * -plugin_query(GError **error) -{ - const gchar * const authors[] = { - "Piotr Zielinski (http://cl.cam.ac.uk/~pz215)", - NULL - }; - - return purple_plugin_info_new( - "id", "dbus-example", - "name", N_("DBus Example"), - "version", DISPLAY_VERSION, - "category", N_("Example"), - "summary", N_("DBus Plugin Example"), - "description", N_("DBus Plugin Example"), - "authors", authors, - "website", PURPLE_WEBSITE, - "abi-version", PURPLE_ABI_VERSION, - NULL - ); -} - -static gboolean -plugin_load(PurplePlugin *plugin, GError **error) -{ - PURPLE_DBUS_RETURN_FALSE_IF_DISABLED(plugin); - - /* First, we have to register our four exported functions with the - main purple dbus loop. Without this statement, the purple dbus - code wouldn't know about our functions. */ - PURPLE_DBUS_REGISTER_BINDINGS(plugin); - - /* Then, we register the hello object of type PurpleText. Note that - pointer registrations / unregistrations are completely dynamic; - they don't have to be made when the plugin is loaded / - unloaded. Without this statement the dbus purple code wouldn't - know about the hello object. */ - PURPLE_DBUS_REGISTER_POINTER(&hello, PurpleText); - - hello.text = g_strdup("Hello."); - - return TRUE; -} - - -static gboolean -plugin_unload(PurplePlugin *plugin, GError **error) -{ - g_free(hello.text); - - /* It is necessary to unregister all pointers registered by the module. */ - PURPLE_DBUS_UNREGISTER_POINTER(&hello); - - return TRUE; -} - -PURPLE_PLUGIN_INIT(dbus_example, plugin_query, plugin_load, plugin_unload);
--- a/libpurple/plugins/meson.build Fri Nov 30 17:27:13 2018 -0600 +++ b/libpurple/plugins/meson.build Tue Dec 04 02:44:33 2018 +0000 @@ -77,17 +77,4 @@ dependencies : [libpurple_dep], name_prefix : '', ) - - if enable_dbus - dbus_example_bindings_c = custom_target('dbus_example_bindings_c', - input : 'dbus-example.c', - output : 'dbus-example-bindings.ch', - command : [python, - meson.source_root() + '/libpurple/dbus-analyze-functions.py', - '--export-only', '-o', '@OUTPUT@', '@INPUT@']) - - dbus_example = library('dbus-example', 'dbus-example.c', dbus_example_bindings_c, - dependencies : [libpurple_dep, dbus], - name_prefix : '') - endif # enable_dbus endif # PLUGINS
--- a/libpurple/plugins/startup.py Fri Nov 30 17:27:13 2018 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -#!/usr/bin/env python -# -# Makes sure only one purple instance is running -# -# Purple is the legal property of its developers, whose names are too numerous -# to list here. Please refer to the COPYRIGHT file distributed with this -# source distribution. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA -# - -from __future__ import absolute_import, division, print_function - -import os -import sys - -import dbus - - -if len(sys.argv) == 1: - print("Usage:", sys.argv[0], "<purple-client> [arguments]") - print("\nExample:\n ", sys.argv[0], "pidgin -d -c /my/home") - sys.exit(1) - -home = os.path.expanduser('~/.purple/') -for arg in range(1, len(sys.argv[1:])): - if sys.argv[arg] == "-c": - home = os.path.expanduser(sys.argv[arg + 1]) - break - -bus = dbus.SessionBus() - -try: - obj = bus.get_object("im.pidgin.purple.PurpleService", - "/im/pidgin/purple/PurpleObject") - purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface") - userdir = purple.PurpleUserDir() - if not os.path.isabs(userdir): - userdir = os.path.join(purple.PurpleHomeDir(), userdir) - if home == userdir: - print("Already running.") - purple.PurpleBlistShow() - else: - print("Starting client from a different home directory.") - raise -except: - os.execlp(sys.argv[1], " ".join(sys.argv[2:]))
--- a/libpurple/presence.c Fri Nov 30 17:27:13 2018 -0600 +++ b/libpurple/presence.c Tue Dec 04 02:44:33 2018 +0000 @@ -21,7 +21,6 @@ #include "internal.h" #include "glibcompat.h" #include "debug.h" -#include "dbus-maybe.h" #include "presence.h" #define PURPLE_PRESENCE_GET_PRIVATE(obj) \ @@ -418,8 +417,6 @@ static void purple_presence_init(GTypeInstance *instance, gpointer klass) { - PURPLE_DBUS_REGISTER_POINTER(PURPLE_PRESENCE(instance), PurplePresence); - PURPLE_PRESENCE_GET_PRIVATE(instance)->status_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); @@ -448,8 +445,6 @@ g_hash_table_destroy(priv->status_table); - PURPLE_DBUS_UNREGISTER_POINTER(object); - parent_class->finalize(object); }
--- a/libpurple/protocol.c Fri Nov 30 17:27:13 2018 -0600 +++ b/libpurple/protocol.c Tue Dec 04 02:44:33 2018 +0000 @@ -20,7 +20,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA * */ -#include "dbus-maybe.h" #include "protocol.h" static GObjectClass *parent_class; @@ -140,7 +139,6 @@ static void purple_protocol_init(GTypeInstance *instance, gpointer klass) { - PURPLE_DBUS_REGISTER_POINTER(PURPLE_PROTOCOL(instance), PurpleProtocol); } static void @@ -174,8 +172,6 @@ account_options_free(protocol); icon_spec_free(protocol); - PURPLE_DBUS_UNREGISTER_POINTER(protocol); - parent_class->finalize(object); }
--- a/libpurple/purple-client-example.c Fri Nov 30 17:27:13 2018 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -/* - * purple - * - * Purple is the legal property of its developers, whose names are too numerous - * to list here. Please refer to the COPYRIGHT file distributed with this - * source distribution. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA - * - */ -#ifndef DBUS_API_SUBJECT_TO_CHANGE -#define DBUS_API_SUBJECT_TO_CHANGE -#endif - -#include <stdio.h> -#include <stdlib.h> - -#include "purple-client.h" - -/* - This example demonstrates how to use libpurple-client to communicate - with purple. The names and signatures of functions provided by - libpurple-client are the same as those in purple. However, all - structures (such as PurpleAccount) are opaque, that is, you can only - use pointer to them. In fact, these pointers DO NOT actually point - to anything, they are just integer identifiers of assigned to these - structures by purple. So NEVER try to dereference these pointers. - Integer ids as disguised as pointers to provide type checking and - prevent mistakes such as passing an id of PurpleAccount when an id of - PurpleBuddy is expected. According to glib manual, this technique is - portable. -*/ - -int main (int argc, char **argv) -{ - GList *alist, *node; - - purple_init(); - - alist = purple_accounts_get_all(); - for (node = alist; node != NULL; node = node->next) - { - PurpleAccount *account = (PurpleAccount*) node->data; - char *name = purple_account_get_username(account); - g_print("Name: %s\n", name); - g_free(name); - } - g_list_free(alist); - - return 0; -}
--- a/libpurple/purple-client.c Fri Nov 30 17:27:13 2018 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,103 +0,0 @@ -/* - * purple - * - * Purple is the legal property of its developers, whose names are too numerous - * to list here. Please refer to the COPYRIGHT file distributed with this - * source distribution. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA - * - */ -#ifndef DBUS_API_SUBJECT_TO_CHANGE -#define DBUS_API_SUBJECT_TO_CHANGE -#endif - -#include <dbus/dbus-glib.h> -#include <stdio.h> -#include <stdlib.h> - -#include "dbus-purple.h" -#include "purple-client.h" - -static DBusGConnection *bus; -static DBusGProxy *purple_proxy; - -static GList *garray_int_to_glist(GArray *array) -{ - GList *list = NULL; - gsize i; - - for (i = 0; i < array->len; i++) - list = g_list_append(list, GINT_TO_POINTER(g_array_index(array,gint,i))); - - g_array_free(array, TRUE); - return list; -} - -static GSList *garray_int_to_gslist(GArray *array) -{ - GSList *list = NULL; - gsize i; - - for (i = 0; i < array->len; i++) - list = g_slist_append(list, GINT_TO_POINTER(g_array_index(array,gint,i))); - - g_array_free(array, TRUE); - return list; -} - -#include "purple-client-bindings.ch" - -static void lose(const char *fmt, ...) G_GNUC_NORETURN G_GNUC_PRINTF (1, 2); -static void lose_gerror(const char *prefix, GError *error) G_GNUC_NORETURN; - -static void -lose(const char *str, ...) -{ - va_list args; - - va_start(args, str); - - vfprintf(stderr, str, args); - fputc('\n', stderr); - - va_end(args); - - exit(1); -} - -static void -lose_gerror(const char *prefix, GError *error) -{ - lose("%s: %s", prefix, error->message); -} - -void purple_init(void) -{ - GError *error = NULL; - - bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error); - if (!bus) - lose_gerror ("Couldn't connect to session bus", error); - - purple_proxy = dbus_g_proxy_new_for_name (bus, - PURPLE_DBUS_SERVICE, - PURPLE_DBUS_PATH, - PURPLE_DBUS_INTERFACE); - - if (!purple_proxy) - lose_gerror ("Couldn't connect to the Purple Service", error); -} -
--- a/libpurple/purple-client.h Fri Nov 30 17:27:13 2018 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -/* - * purple - * - * Purple is the legal property of its developers, whose names are too numerous - * to list here. Please refer to the COPYRIGHT file distributed with this - * source distribution. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA - * - */ -#ifndef _PURPLE_CLIENT_H_INCLUDED_ -#define _PURPLE_CLIENT_H_INCLUDED_ - -#include <glib.h> -#include <glib-object.h> -#include "purple-client-bindings.h" - -G_BEGIN_DECLS - -void purple_init(void); - -G_END_DECLS - -#endif
--- a/libpurple/purple-notifications-example Fri Nov 30 17:27:13 2018 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,91 +0,0 @@ -#!/usr/bin/env python - -# This is a simple purple notification server. -# It shows notifications when your buddy signs on or you get an IM message. -# -# This script requires Python 2.4 and PyGTK bindings -# -# Note that all function names are resolved dynamically, no -# purple-specific library is needed. - -from __future__ import absolute_import, division, print_function - -import os - -import dbus -import dbus.glib -import dbus.decorators -import gobject - - -def ensureimconversation(conversation, account, name): - if conversation != 0: - return conversation - else: - # 1 = PURPLE_CONV_IM - return purple.PurpleConversationNew(1, account, name) - - -def receivedimmsg(account, name, message, conversation, flags): - buddy = purple.PurpleFindBuddy(account, name) - if buddy != 0: - alias = purple.PurpleBuddyGetAlias(buddy) - else: - alias = name - - text = "%s says %s" % (alias, message) - code = os.spawnlp(os.P_WAIT, "xmessage", "xmessage", "-buttons", - "'So what?','Show me',Close,Abuse", text) - - if code == 101: # so what? - pass - else: - conversation = ensureimconversation(conversation, account, name) - - if code == 102: # show me - window = purple.PurpleConversationGetWindow(conversation) - purple.PurpleConvWindowRaise(window) - - if code == 103: # close - purple.PurpleConversationDestroy(conversation) - - if code == 104: # abuse - im = purple.PurpleConversationGetImData(conversation) - purple.PurpleConvImSend(im, "Go away you f...") - - -def buddysignedon(buddyid): - alias = purple.PurpleBuddyGetAlias(buddyid) - text = "%s is online" % alias - - code = os.spawnlp(os.P_WAIT, "xmessage", "xmessage", "-buttons", - "'So what?','Let's talk'", text) - - if code == 101: # so what? - pass - - if code == 102: # talk - name = purple.PurpleBuddyGetName(buddyid) - account = purple.PurpleBuddyGetAccount(buddyid) - purple.PurpleConversationNew(1, account, name) - - -bus = dbus.SessionBus() -obj = bus.get_object("im.pidgin.purple.PurpleService", - "/im/pidgin/purple/PurpleObject") -purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface") - -bus.add_signal_receiver(receivedimmsg, - dbus_interface="im.pidgin.purple.PurpleInterface", - signal_name="ReceivedImMsg") - -bus.add_signal_receiver(buddysignedon, - dbus_interface="im.pidgin.purple.PurpleInterface", - signal_name="BuddySignedOn") - -print("This is a simple purple notification server.") -print("It shows notifications when your buddy signs on or you get an " - "IM message.") - -loop = gobject.MainLoop() -loop.run()
--- a/libpurple/purple-remote Fri Nov 30 17:27:13 2018 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,266 +0,0 @@ -#!/usr/bin/env python - -from __future__ import absolute_import, division, print_function - -import codecs -import re -import sys -try: - from urllib.parse import unquote -except ImportError: - from urllib import unquote -import xml.dom.minidom - -import dbus - - -sys.stdin = codecs.getwriter('utf-8')(sys.stdin) -sys.stdout = codecs.getwriter('utf-8')(sys.stdout) - -xml.dom.minidom.Element.all = xml.dom.minidom.Element.getElementsByTagName - -obj = None -try: - obj = dbus.SessionBus().get_object("im.pidgin.purple.PurpleService", - "/im/pidgin/purple/PurpleObject") -except: - pass - -purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface") - - -class CheckedObject(object): - def __init__(self, obj): - self.obj = obj - - def __getattr__(self, attr): - return CheckedAttribute(self, attr) - - -class CheckedAttribute(object): - def __init__(self, cobj, attr): - self.cobj = cobj - self.attr = attr - - def __call__(self, *args): - result = self.cobj.obj.__getattr__(self.attr)(*args) - if result == 0: - raise Exception("Error: %s %s returned %s" % - (self.attr, args, result)) - return result - - -def show_help(requested=False): - print("""This program uses D-Bus to communicate with purple. - -Usage: - - %s "command1" "command2" ... - -Each command is of one of the three types: - - [protocol:]commandname?param1=value1¶m2=value2&... - FunctionName?param1=value1¶m2=value2&... - FunctionName(value1,value2,...) - -The second and third form are provided for completeness but their use -is not recommended; use purple-send or purple-send-async instead. The -second form uses introspection to find out the parameter names and -their types, therefore it is rather slow. - -Examples of commands: - - jabber:goim?screenname=testone@localhost&message=hi - jabber:gochat?room=TestRoom&server=conference.localhost - jabber:getinfo?screenname=testone@localhost - jabber:addbuddy?screenname=my friend - - setstatus?status=away&message=don't disturb - getstatus - getstatusmessage - quit - - PurpleAccountsFindConnected?name=&protocol=jabber - PurpleAccountsFindConnected(,jabber) -""" % (sys.argv[0], )) - if (requested): - sys.exit(0) - else: - sys.exit(1) - - -cpurple = CheckedObject(purple) - -urlregexp = r"^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?" - - -def extendlist(list, length, fill): - if len(list) < length: - return list + [fill] * (length - len(list)) - else: - return list - - -def convert(value): - try: - return int(value) - except: - return value - - -def findaccount(accountname, protocolname): - try: - # prefer connected accounts - account = cpurple.PurpleAccountsFindConnected(accountname, - protocolname) - return account - except: - # try to get any account and connect it - account = cpurple.PurpleAccountsFindAny(accountname, protocolname) - purple.PurpleAccountSetStatusVargs(account, "online", 1) - purple.PurpleAccountConnect(account) - return account - - -def execute(uri): - match = re.match(urlregexp, uri) - protocol = match.group(2) - if protocol == "xmpp": - protocol = "jabber" - if protocol is not None: - protocol = "prpl-" + protocol - command = match.group(5) - paramstring = match.group(7) - params = {} - if paramstring is not None: - for param in paramstring.split("&"): - key, value = extendlist(param.split("=", 1), 2, "") - params[key] = unquote(value) - - accountname = params.get("account", "") - - if command == "goim": - account = findaccount(accountname, protocol) - conversation = cpurple.PurpleConversationNew(1, account, - params["screenname"]) - if "message" in params: - im = cpurple.PurpleConversationGetImData(conversation) - purple.PurpleConvImSend(im, params["message"]) - return None - - elif command == "gochat": - account = findaccount(accountname, protocol) - connection = cpurple.PurpleAccountGetConnection(account) - return purple.PurpleServJoinChat(connection, params) - - elif command == "addbuddy": - account = findaccount(accountname, protocol) - return cpurple.PurpleBlistRequestAddBuddy(account, - params["screenname"], - params.get("group", ""), - "") - - elif command == "setstatus": - current = purple.PurpleSavedstatusGetCurrent() - - if "status" in params: - status_id = params["status"] - status_type = purple.PurplePrimitiveGetTypeFromId(status_id) - else: - status_type = purple.PurpleSavedstatusGetType(current) - status_id = purple.PurplePrimitiveGetIdFromType(status_type) - - if "message" in params: - message = params["message"] - else: - message = purple.PurpleSavedstatusGetMessage(current) - - if "account" in params: - accounts = [cpurple.PurpleAccountsFindAny(accountname, protocol)] - - for account in accounts: - status = purple.PurpleAccountGetStatus(account, status_id) - type = purple.PurpleStatusGetType(status) - purple.PurpleSavedstatusSetSubstatus(current, account, type, - message) - purple.PurpleSavedstatusActivateForAccount(current, account) - else: - saved = purple.PurpleSavedstatusNew("", status_type) - purple.PurpleSavedstatusSetMessage(saved, message) - purple.PurpleSavedstatusActivate(saved) - - return None - - elif command == "getstatus": - current = purple.PurpleSavedstatusGetCurrent() - status_type = purple.PurpleSavedstatusGetType(current) - status_id = purple.PurplePrimitiveGetIdFromType(status_type) - return status_id - - elif command == "getstatusmessage": - current = purple.PurpleSavedstatusGetCurrent() - return purple.PurpleSavedstatusGetMessage(current) - - elif command == "getinfo": - account = findaccount(accountname, protocol) - connection = cpurple.PurpleAccountGetConnection(account) - return purple.ServGetInfo(connection, params["screenname"]) - - elif command == "quit": - return purple.PurpleCoreQuit() - - elif command == "uri": - return None - - else: - match = re.match(r"(\w+)\s*\(([^)]*)\)", command) - if match is not None: - name = match.group(1) - argstr = match.group(2) - if argstr == "": - args = [] - else: - args = argstr.split(",") - fargs = [] - for arg in args: - fargs.append(convert(arg.strip())) - return purple.__getattr__(name)(*fargs) - else: - # Introspect the object to get parameter names and types. This is - # slow because the entire introspection info must be downloaded. - interface = dbus.Interface(obj, - "org.freedesktop.DBus.Introspectable") - data = interface.Introspect() - introspect = xml.dom.minidom.parseString(data).documentElement - for method in introspect.all("method"): - if command == method.getAttribute("name"): - methodparams = [] - for arg in method.all("arg"): - if arg.getAttribute("direction") == "in": - value = params[arg.getAttribute("name")] - type = arg.getAttribute("type") - if type == "s": - methodparams.append(value) - elif type == "i": - methodparams.append(int(value)) - else: - raise Exception( - "Don't know how to handle type \"%s\"" % ( - type, )) - return purple.__getattr__(command)(*methodparams) - show_help() - - -if len(sys.argv) == 1: - show_help() -elif sys.argv[1] == "--help" or sys.argv[1] == "-h": - show_help(True) -elif obj is None: - print("No existing libpurple instance detected.") - sys.exit(1) - -for arg in sys.argv[1:]: - output = execute(arg) - - if output is not None: - print(output)
--- a/libpurple/purple-send Fri Nov 30 17:27:13 2018 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -#!/bin/sh - -METHOD_NAME=$1 - -if test -z "$METHOD_NAME" -then - cat <<EOF -This program calls purple API functions using DBus and prints the return value. -If you are not interested in the return value, use purple-send-async. - -Usage: - - $0 method-name type1:parameter1 type2:parameter2 ... - -This shell script just invokes dbus-send, see man dbus-send for how -to specify the parameters. - -Examples: - - $0 PurpleAccountsFindConnected string: string:jabber - $0 PurpleAccountsGetAll - $0 PurpleCoreQuit - -Use dbus-viewer to get the list of supported functions and their parameters. -EOF - exit 1 -fi - -shift -dbus-send --dest=im.pidgin.purple.PurpleService --print-reply --type=method_call /im/pidgin/purple/PurpleObject im.pidgin.purple.PurpleInterface.$METHOD_NAME "$@" -
--- a/libpurple/purple-send-async Fri Nov 30 17:27:13 2018 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -#!/bin/sh - -METHOD_NAME=$1 - -if test -z "$METHOD_NAME" -then - cat <<EOF -This program calls purple API functions using DBus. As opposed to purple-send, -it does not print the return value. - -Usage: - - $0 method-name type1:parameter1 type2:parameter2 ... - -This shell script just invokes dbus-send, see man dbus-send for how -to specify the parameters. - -Examples: - - $0 PurpleCoreQuit - -Use dbus-viewer to get the list of supported functions and their parameters. -EOF - exit 1 -fi - -shift -dbus-send --dest=im.pidgin.purple.PurpleService --type=method_call /im/pidgin/purple/PurpleObject im.pidgin.purple.PurpleInterface.$METHOD_NAME "$@" -
--- a/libpurple/savedstatuses.c Fri Nov 30 17:27:13 2018 -0600 +++ b/libpurple/savedstatuses.c Tue Dec 04 02:44:33 2018 +0000 @@ -24,7 +24,6 @@ #include "idle.h" #include "notify.h" #include "savedstatuses.h" -#include "dbus-maybe.h" #include "request.h" #include "status.h" #include "util.h" @@ -108,7 +107,6 @@ g_free(substatus->message); purple_request_close_with_handle(substatus); - PURPLE_DBUS_UNREGISTER_POINTER(substatus); g_free(substatus); } @@ -127,7 +125,6 @@ free_saved_status_sub(substatus); } purple_request_close_with_handle(status); - PURPLE_DBUS_UNREGISTER_POINTER(status); g_free(status); } @@ -417,7 +414,6 @@ ret->message = data; } - PURPLE_DBUS_REGISTER_POINTER(ret, PurpleSavedStatusSub); return ret; } @@ -513,7 +509,6 @@ ret->substatuses = g_list_prepend(ret->substatuses, new); } - PURPLE_DBUS_REGISTER_POINTER(ret, PurpleSavedStatus); return ret; } @@ -563,7 +558,6 @@ g_return_val_if_fail(purple_savedstatus_find(title) == NULL, NULL); status = g_new0(PurpleSavedStatus, 1); - PURPLE_DBUS_REGISTER_POINTER(status, PurpleSavedStatus); status->title = g_strdup(title); status->type = type; set_creation_time(status, time(NULL)); @@ -641,7 +635,6 @@ if (substatus == NULL) { substatus = g_new0(PurpleSavedStatusSub, 1); - PURPLE_DBUS_REGISTER_POINTER(substatus, PurpleSavedStatusSub); substatus->account = (PurpleAccount *)account; saved_status->substatuses = g_list_prepend(saved_status->substatuses, substatus); }
--- a/libpurple/signals.c Fri Nov 30 17:27:13 2018 -0600 +++ b/libpurple/signals.c Tue Dec 04 02:44:33 2018 +0000 @@ -20,7 +20,6 @@ */ #include "internal.h" -#include "dbus-maybe.h" #include "debug.h" #include "signals.h" @@ -466,12 +465,6 @@ va_end(tmp); } - -#ifdef HAVE_DBUS - purple_dbus_signal_emit_purple(signal, signal_data->num_values, - signal_data->value_types, args); -#endif /* HAVE_DBUS */ - } void * @@ -518,13 +511,6 @@ return 0; } -#ifdef HAVE_DBUS - G_VA_COPY(tmp, args); - purple_dbus_signal_emit_purple(signal, signal_data->num_values, - signal_data->value_types, tmp); - va_end(tmp); -#endif /* HAVE_DBUS */ - for (l = signal_data->handlers; l != NULL; l = l_next) { void *ret_val = NULL;
--- a/libpurple/smiley-list.c Fri Nov 30 17:27:13 2018 -0600 +++ b/libpurple/smiley-list.c Tue Dec 04 02:44:33 2018 +0000 @@ -21,7 +21,6 @@ #include "smiley-list.h" -#include "dbus-maybe.h" #include "debug.h" #include "smiley-parser.h" #include "trie.h" @@ -65,8 +64,6 @@ g_free, NULL); priv->shortcut_map = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); - - PURPLE_DBUS_REGISTER_POINTER(list, PurpleSmileyList); } static void @@ -87,8 +84,6 @@ } g_list_free(priv->smileys); - PURPLE_DBUS_UNREGISTER_POINTER(sl); - G_OBJECT_CLASS(purple_smiley_list_parent_class)->finalize(obj); }
--- a/libpurple/smiley.c Fri Nov 30 17:27:13 2018 -0600 +++ b/libpurple/smiley.c Tue Dec 04 02:44:33 2018 +0000 @@ -20,7 +20,6 @@ */ #include "smiley.h" -#include "dbus-maybe.h" #define PURPLE_SMILEY_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_SMILEY, PurpleSmileyPrivate)) @@ -59,7 +58,6 @@ static void purple_smiley_init(PurpleSmiley *smiley) { - PURPLE_DBUS_REGISTER_POINTER(smiley, PurpleSmiley); } static void @@ -68,8 +66,6 @@ g_free(priv->shortcut); - PURPLE_DBUS_UNREGISTER_POINTER(smiley); - G_OBJECT_CLASS(purple_smiley_parent_class)->finalize(obj); }
--- a/libpurple/status.c Fri Nov 30 17:27:13 2018 -0600 +++ b/libpurple/status.c Tue Dec 04 02:44:33 2018 +0000 @@ -23,7 +23,6 @@ #include "buddylist.h" #include "core.h" -#include "dbus-maybe.h" #include "debug.h" #include "notify.h" #include "prefs.h" @@ -209,7 +208,6 @@ g_return_val_if_fail(primitive != PURPLE_STATUS_UNSET, NULL); status_type = g_new0(PurpleStatusType, 1); - PURPLE_DBUS_REGISTER_POINTER(status_type, PurpleStatusType); status_type->primitive = primitive; status_type->saveable = saveable; @@ -315,7 +313,6 @@ g_list_foreach(status_type->attrs, (GFunc)purple_status_attribute_destroy, NULL); g_list_free(status_type->attrs); - PURPLE_DBUS_UNREGISTER_POINTER(status_type); g_free(status_type); } @@ -448,7 +445,6 @@ g_return_val_if_fail(value_type != NULL, NULL); attr = g_new0(PurpleStatusAttribute, 1); - PURPLE_DBUS_REGISTER_POINTER(attr, PurpleStatusAttribute); attr->id = g_strdup(id); attr->name = g_strdup(name); @@ -467,7 +463,6 @@ purple_value_free(attr->value_type); - PURPLE_DBUS_UNREGISTER_POINTER(attr); g_free(attr); } @@ -1165,8 +1160,6 @@ { PurpleStatus *status = PURPLE_STATUS(instance); - PURPLE_DBUS_REGISTER_POINTER(status, PurpleStatus); - PURPLE_STATUS_GET_PRIVATE(status)->attr_values = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, (GDestroyNotify)purple_value_free); @@ -1203,8 +1196,6 @@ { g_hash_table_destroy(PURPLE_STATUS_GET_PRIVATE(object)->attr_values); - PURPLE_DBUS_UNREGISTER_POINTER(object); - parent_class->finalize(object); }
--- a/libpurple/tests/meson.build Fri Nov 30 17:27:13 2018 -0600 +++ b/libpurple/tests/meson.build Tue Dec 04 02:44:33 2018 +0000 @@ -18,7 +18,7 @@ c_args: [ '-DTEST_DATA_DIR="@0@/data"'.format(meson.current_source_dir()) ], - dependencies: [libpurple_dep, glib, dbus, dbus_glib] + dependencies: [libpurple_dep, glib] ) foreach prog : PROGS @@ -26,7 +26,7 @@ c_args : [ '-DTEST_DATA_DIR="@0@/data"'.format(meson.current_source_dir()) ], - dependencies : [libpurple_dep, glib, dbus, dbus_glib], + dependencies : [libpurple_dep, glib], link_with: test_ui, ) test(prog, e)
--- a/libpurple/xfer.c Fri Nov 30 17:27:13 2018 -0600 +++ b/libpurple/xfer.c Tue Dec 04 02:44:33 2018 +0000 @@ -22,7 +22,6 @@ #include "internal.h" #include "glibcompat.h" -#include "dbus-maybe.h" #include "enums.h" #include "image-store.h" #include "xfer.h" @@ -2125,8 +2124,6 @@ PurpleXfer *xfer = PURPLE_XFER(instance); PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); - PURPLE_DBUS_REGISTER_POINTER(xfer, PurpleXfer); - priv->ui_ops = purple_xfers_get_ui_ops(); priv->current_buffer_size = FT_INITIAL_BUFFER_SIZE; priv->fd = -1; @@ -2190,8 +2187,6 @@ g_free(priv->thumbnail_data); g_free(priv->thumbnail_mimetype); - PURPLE_DBUS_UNREGISTER_POINTER(xfer); - parent_class->finalize(object); }
--- a/libpurple/xmlnode.c Fri Nov 30 17:27:13 2018 -0600 +++ b/libpurple/xmlnode.c Tue Dec 04 02:44:33 2018 +0000 @@ -32,7 +32,6 @@ #include <string.h> #include <glib.h> -#include "dbus-maybe.h" #include "util.h" #include "xmlnode.h" @@ -50,8 +49,6 @@ node->name = g_strdup(name); node->type = type; -// PURPLE_DBUS_REGISTER_POINTER(node, PurpleXmlNode); - return node; } @@ -402,7 +399,6 @@ if(node->namespace_map) g_hash_table_destroy(node->namespace_map); -// PURPLE_DBUS_UNREGISTER_POINTER(node); g_free(node); }
--- a/meson.build Fri Nov 30 17:27:13 2018 -0600 +++ b/meson.build Tue Dec 04 02:44:33 2018 +0000 @@ -721,31 +721,6 @@ endif ####################################################################### -# Check for D-Bus libraries -####################################################################### - -# dbus doesn't compile for win32 at the moment -enable_dbus = get_option('dbus') and not IS_WIN32 - -if enable_dbus - dbus_binding_tool = find_program('dbus-binding-tool') - enable_dbus = dbus_binding_tool.found() -endif - -if enable_dbus - dbus = dependency('dbus-1', version : '>= 0.60', required : force_deps) - dbus_glib = dependency('dbus-glib-1', version : '>= 0.60', required : force_deps) - enable_dbus = dbus.found() and dbus_glib.found() -else - dbus = [] - dbus_glib = [] -endif - -if enable_dbus - conf.set('HAVE_DBUS', true) -endif - -####################################################################### # Check for Unity and Messaging Menu # Remove when Ubuntu 16.04 is EOL ####################################################################### @@ -876,23 +851,6 @@ endif endif -####################################################################### -# Check for Python -####################################################################### - -# Python scripts are used to auto-generate about 3000 lines of C -# and XML code that wraps (part of) the existing API so that -# it is now accessible through D-Bus. - -if enable_dbus - if meson.version().version_compare('>=0.38.0') - python3_mod = import('python3') - python = python3_mod.find_python() - else - python = find_program('python3') - endif -endif - if get_option('plugins') conf.set('PURPLE_PLUGINS', 1) PLUGINS = true @@ -1074,7 +1032,6 @@ message('Protocols to link statically.. : @0@'.format(STATIC_PRPLS)) message('') message('Build with GStreamer support.. : ' + enable_gst.to_string()) -message('Build with D-Bus support...... : ' + enable_dbus.to_string()) message('Build with voice and video.... : ' + enable_vv.to_string()) message('Build with GNU Libidn......... : ' + get_option('idn').to_string()) message('Build with Nettle support..... : ' + enable_nettle.to_string())
--- a/meson_options.txt Fri Nov 30 17:27:13 2018 -0600 +++ b/meson_options.txt Tue Dec 04 02:44:33 2018 +0000 @@ -80,9 +80,6 @@ option('glib-errors-trace', type : 'boolean', value : false, description : 'print backtraces for glib errors') -option('dbus', type : 'boolean', value : true, - description : 'enable D-Bus support') - option('unity-integration', type : 'boolean', value : false, description : 'compile with support for unity integration plugin')
--- a/pidgin/meson.build Fri Nov 30 17:27:13 2018 -0600 +++ b/pidgin/meson.build Tue Dec 04 02:44:33 2018 +0000 @@ -158,7 +158,6 @@ include_directories : [toplevel_inc], version : PURPLE_LIB_VERSION, dependencies : [ - dbus, enchant, glib, gstreamer_video,
--- a/pidgin/plugins/meson.build Fri Nov 30 17:27:13 2018 -0600 +++ b/pidgin/plugins/meson.build Tue Dec 04 02:44:33 2018 +0000 @@ -2,7 +2,7 @@ subdir('gevolution') endif -if enable_dbus +if false subdir('musicmessaging') endif
--- a/pidgin/plugins/musicmessaging/musicmessaging.c Fri Nov 30 17:27:13 2018 -0600 +++ b/pidgin/plugins/musicmessaging/musicmessaging.c Tue Dec 04 02:44:33 2018 +0000 @@ -19,6 +19,10 @@ * 02111-1301, USA. */ +/* NOTICE: This plugin is currently broken as the libpurple DBus bindings + * have been removed. + */ + #include "internal.h" #include "pidgin.h"
--- a/po/POTFILES.in Fri Nov 30 17:27:13 2018 -0600 +++ b/po/POTFILES.in Tue Dec 04 02:44:33 2018 +0000 @@ -45,8 +45,6 @@ libpurple/conversation.c libpurple/conversationtypes.c libpurple/data/purple-url-handler.desktop.in.in -libpurple/dbus-server.c -libpurple/dbus-server.h libpurple/http.c libpurple/keyring.c libpurple/log.c @@ -57,7 +55,6 @@ libpurple/plugins.c libpurple/plugins/autoaccept.c libpurple/plugins/buddynote.c -libpurple/plugins/dbus-example.c libpurple/plugins/filectl.c libpurple/plugins/idle.c libpurple/plugins/joinpart.c