Tue, 27 Nov 2018 16:42:53 -0600
libpurple: Drop DBus API bindings
This patch drops the general libpurple DBus API bindings. These
bindings were generated using the old DBus library and reached far
and wide within libpurple. Now that GObject introspection exists,
if we need a general DBus API like this, a plugin can do it
dynamically using the introspection. Although, I believe that more
use-case specific plugins/interfaces should be made, if needed,
instead.
--- a/ChangeLog.API Tue Oct 02 16:08:50 2018 -0500 +++ b/ChangeLog.API Tue Nov 27 16:42:53 2018 -0600 @@ -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/reference/libpurple/libpurple-docs.xml Tue Oct 02 16:08:50 2018 -0500 +++ b/doc/reference/libpurple/libpurple-docs.xml Tue Nov 27 16:42:53 2018 -0600 @@ -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 Tue Oct 02 16:08:50 2018 -0500 +++ b/doc/reference/libpurple/meson.build Tue Nov 27 16:42:53 2018 -0600 @@ -8,8 +8,6 @@ 'tests', 'win32', 'backend-fs2.h', - 'dbus-define-api.h', - 'dbus-types.h', 'glibcompat.h', 'internal.h', ] @@ -42,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 Tue Oct 02 16:08:50 2018 -0500 +++ /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/libpurple/dbus-analyze-functions.py Tue Oct 02 16:08:50 2018 -0500 +++ /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 Tue Oct 02 16:08:50 2018 -0500 +++ /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 Tue Oct 02 16:08:50 2018 -0500 +++ /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 Tue Oct 02 16:08:50 2018 -0500 +++ /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 Tue Oct 02 16:08:50 2018 -0500 +++ /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 Tue Oct 02 16:08:50 2018 -0500 +++ /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 Tue Oct 02 16:08:50 2018 -0500 +++ /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 Tue Oct 02 16:08:50 2018 -0500 +++ /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 Tue Oct 02 16:08:50 2018 -0500 +++ /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 Tue Oct 02 16:08:50 2018 -0500 +++ /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 Tue Oct 02 16:08:50 2018 -0500 +++ /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/meson.build Tue Oct 02 16:08:50 2018 -0500 +++ b/libpurple/meson.build Tue Nov 27 16:42:53 2018 -0600 @@ -99,7 +99,6 @@ 'conversations.h', 'core.h', 'countingnode.h', - 'dbus-maybe.h', 'debug.h', 'e2ee.h', 'eventloop.h', @@ -243,122 +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] - -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]) -install_headers(purple_coreheaders + dbus_headers, +install_headers(purple_coreheaders, subdir : 'libpurple') install_headers(purple_mediaheaders, @@ -376,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/tests/meson.build Tue Oct 02 16:08:50 2018 -0500 +++ b/libpurple/tests/meson.build Tue Nov 27 16:42:53 2018 -0600 @@ -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/po/POTFILES.in Tue Oct 02 16:08:50 2018 -0500 +++ b/po/POTFILES.in Tue Nov 27 16:42:53 2018 -0600 @@ -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