diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2014-01-29 17:31:05 +0100 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2014-01-30 11:29:17 +0100 |
commit | e8f28a176ac965e8b7d1168acc88d6ff1f9bd7fa (patch) | |
tree | 39894f2e487c6858d7a7244247b8a530b698b0bd | |
parent | 8cb095be81e9d20be51d943b4bb2b36cc46450fe (diff) | |
parent | 6bd36fff499df665cadd9427b85714266668a4af (diff) |
Merge branch 'master' into next-merge
Conflicts:
configure.ac
extensions/Connection_Interface_Renaming.xml
src/idle-connection.c
tests/twisted/constants.py
-rw-r--r-- | NEWS | 7 | ||||
-rw-r--r-- | extensions/Connection_Interface_IRC_Command1.xml | 53 | ||||
-rw-r--r-- | extensions/Connection_Interface_Renaming.xml | 98 | ||||
-rw-r--r-- | extensions/Makefile.am | 5 | ||||
-rw-r--r-- | extensions/all.xml | 2 | ||||
-rw-r--r-- | src/idle-connection.c | 100 | ||||
-rw-r--r-- | src/idle-muc-channel.c | 4 | ||||
-rw-r--r-- | src/idle-parser.c | 4 | ||||
-rw-r--r-- | tests/twisted/Makefile.am | 1 | ||||
-rw-r--r-- | tests/twisted/irc-command.py | 31 |
10 files changed, 188 insertions, 117 deletions
@@ -1,3 +1,10 @@ +telepathy-idle 0.2.0 (2013-10-03) +================================= + +This is a new stable branch, recommended for GNOME 3.10-based distributions. + +No code changes since 0.1.17. + telepathy-idle 0.1.17 (2013-09-18) ================================== diff --git a/extensions/Connection_Interface_IRC_Command1.xml b/extensions/Connection_Interface_IRC_Command1.xml new file mode 100644 index 0000000..4b38bdb --- /dev/null +++ b/extensions/Connection_Interface_IRC_Command1.xml @@ -0,0 +1,53 @@ +<?xml version="1.0" ?> +<node name="/Connection_Interface_IRC_Command1" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> + <tp:copyright> Copyright (C) 2013 Collabora Limited </tp:copyright> + <tp:license xmlns="http://www.w3.org/1999/xhtml"> + <p>This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version.</p> + +<p>This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details.</p> + +<p>You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</p> + </tp:license> + <interface name="im.telepathy.v1.Connection.Interface.IRCCommand1" + tp:causes-havoc='not well-tested'> + <tp:requires interface="im.telepathy.v1.Connection"/> + <method name="Send" tp:name-for-bindings="Send"> + <arg direction="in" name="Command" type="s"> + <tp:docstring> + The command followed by its arguments. + </tp:docstring> + </arg> + <tp:docstring xmlns="http://www.w3.org/1999/xhtml"> + <p>Send an arbitrary IRC command to the server.</p> + <p>For example, an IRC client receiving <code>/bip blreset</code> from + the user might call this method with <code>BIP blreset</code> as + argument which will send <code>BIP blreset</code> to the server.</p> + <p>The command is supplied in UTF-8 (because strings on D-Bus are + always UTF-8). It is transcoded into the connection's configured + character set, if different, before sending to the server.</p> + </tp:docstring> + <tp:possible-errors> + <tp:error name="im.telepathy.v1.Error.Disconnected"/> + <tp:error name="im.telepathy.v1.Error.NetworkError"/> + <tp:error name="im.telepathy.v1.Error.InvalidArgument"> + <tp:docstring> + The connection manager MAY raise this error for commands that + have a more appropriate D-Bus API. + </tp:docstring> + </tp:error> + </tp:possible-errors> + </method> + <tp:docstring> + An interface to send arbitrary IRC commands to the server. + </tp:docstring> + </interface> +</node> +<!-- vim:set sw=2 sts=2 et ft=xml: --> diff --git a/extensions/Connection_Interface_Renaming.xml b/extensions/Connection_Interface_Renaming.xml deleted file mode 100644 index e4bf0e7..0000000 --- a/extensions/Connection_Interface_Renaming.xml +++ /dev/null @@ -1,98 +0,0 @@ -<?xml version="1.0" ?> -<node name="/Connection_Interface_Renaming" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> - <tp:copyright> Copyright (C) 2005, 2006 Collabora Limited </tp:copyright> - <tp:copyright> Copyright (C) 2005, 2006 Nokia Corporation </tp:copyright> - <tp:copyright> Copyright (C) 2006 INdT </tp:copyright> - <tp:license xmlns="http://www.w3.org/1999/xhtml"> - <p>This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version.</p> - -<p>This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details.</p> - -<p>You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</p> - </tp:license> - <interface name="im.telepathy.v1.Connection.Interface.Renaming" - tp:causes-havoc='not well-tested'> - <tp:requires interface="im.telepathy.v1.Connection"/> - <signal name="Renamed" tp:name-for-bindings="Renamed"> - <arg name="Original" type="u" tp:type="Contact_Handle"> - <tp:docstring> - The handle of the original identifier - </tp:docstring> - </arg> - <arg name="New" type="u" tp:type="Contact_Handle"> - <tp:docstring> - The handle of the new identifier - </tp:docstring> - </arg> - <tp:docstring xmlns="http://www.w3.org/1999/xhtml"> - <p>Emitted when the unique identifier of a contact on the server - changes.</p> - - <p>Any channels associated with the contact's original handle will - continue to be to that handle, and so are no longer useful (unless - the contact renames back, or another contact connects with that - unique ID). Clients may open a similar channel associated with the - new handle to continue communicating with the contact.</p> - - <p>For example, if a GUI client associates text - channels with chat windows, it should detach the old channel - from the chat window, closing it, and associate a channel to the - new handle with the same window.</p> - - <p>If the contact's old handle is in any of the member lists of - a channel which has the groups interface, it will be removed from - the channel and the new handle will be added. The resulting - <tp:dbus-ref - namespace="im.telepathy.v1.Channel.Interface.Group">MembersChanged</tp:dbus-ref> - signal must be emitted <em>after</em> the - <tp:member-ref>Renamed</tp:member-ref> signal; the reason should be - RENAMED. - </p> - - <p>The handles may be either general-purpose or channel-specific. - If the original handle is general-purpose, the new handle must be - general-purpose; if the original handle is channel-specific, the - new handle must be channel-specific in the same channel. - </p> - </tp:docstring> - </signal> - <method name="RequestRename" tp:name-for-bindings="Request_Rename"> - <arg direction="in" name="Identifier" type="s"> - <tp:docstring> - The desired identifier - </tp:docstring> - </arg> - <tp:docstring xmlns="http://www.w3.org/1999/xhtml"> - <p>Request that the user's own identifier is changed on the server. - If successful, a <tp:member-ref>Renamed</tp:member-ref> signal will - be emitted for the current "self handle" as returned by <tp:dbus-ref - namespace="im.telepathy.v1.Connection">GetSelfHandle</tp:dbus-ref>.</p> - <p>It is protocol-dependent how the identifier that's actually - used will be derived from the supplied identifier; some sort of - normalization might take place.</p> - </tp:docstring> - <tp:possible-errors> - <tp:error name="im.telepathy.v1.Error.Disconnected"/> - <tp:error name="im.telepathy.v1.Error.NetworkError"/> - <tp:error name="im.telepathy.v1.Error.NotAvailable"/> - <tp:error name="im.telepathy.v1.Error.InvalidArgument"/> - <tp:error name="im.telepathy.v1.Error.PermissionDenied"/> - </tp:possible-errors> - </method> - <tp:docstring> - An interface on connections to support protocols where the unique - identifiers of contacts can change. Because handles are immutable, - this is represented by a pair of handles, that representing the - old name, and that representing the new one. - </tp:docstring> - </interface> -</node> -<!-- vim:set sw=2 sts=2 et ft=xml: --> diff --git a/extensions/Makefile.am b/extensions/Makefile.am index 8812839..b4d67f8 100644 --- a/extensions/Makefile.am +++ b/extensions/Makefile.am @@ -2,7 +2,8 @@ tools_dir = $(top_srcdir)/tools EXTRA_DIST = \ all.xml \ - Connection_Interface_Renaming.xml + Connection_Interface_IRC_Command1.xml \ + $(NULL) noinst_LTLIBRARIES = libidle-extensions.la @@ -32,7 +33,7 @@ DROP_NAMESPACE = sed -e 's@xmlns:tp="http://telepathy\.freedesktop\.org/wiki/Dbu XSLTPROCFLAGS = --nonet --novalid _gen/all.xml: all.xml $(wildcard $(srcdir)/*.xml) - @$(mkdir_p) _gen + @$(MKDIR_P) _gen $(AM_V_GEN)$(XSLTPROC) $(XSLTPROCFLAGS) \ --xinclude $(tools_dir)/identity.xsl \ $< > $@ diff --git a/extensions/all.xml b/extensions/all.xml index 3ed5d93..6b76837 100644 --- a/extensions/all.xml +++ b/extensions/all.xml @@ -22,7 +22,7 @@ License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</p> </tp:license> -<xi:include href="Connection_Interface_Renaming.xml"/> +<xi:include href="Connection_Interface_IRC_Command1.xml"/> <tp:generic-types> <tp:external-type name="Contact_Handle" type="u" diff --git a/src/idle-connection.c b/src/idle-connection.c index fb08399..e123f7f 100644 --- a/src/idle-connection.c +++ b/src/idle-connection.c @@ -41,7 +41,7 @@ #include "idle-server-connection.h" #include "server-tls-manager.h" -#include "extensions/extensions.h" /* Renaming */ +#include "extensions/extensions.h" /* IRCCommand */ #define DEFAULT_KEEPALIVE_INTERVAL 30 /* sec */ #define MISSED_KEEPALIVES_BEFORE_DISCONNECTING 3 @@ -60,11 +60,13 @@ static gboolean flush_queue_faster = FALSE; static void _aliasing_iface_init(gpointer, gpointer); static void _renaming_iface_init(gpointer, gpointer); +static void irc_command_iface_init(gpointer, gpointer); G_DEFINE_TYPE_WITH_CODE(IdleConnection, idle_connection, TP_TYPE_BASE_CONNECTION, G_IMPLEMENT_INTERFACE(TP_TYPE_SVC_CONNECTION_INTERFACE_ALIASING1, _aliasing_iface_init); G_IMPLEMENT_INTERFACE(TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACT_INFO1, idle_contact_info_iface_init); - G_IMPLEMENT_INTERFACE(IDLE_TYPE_SVC_CONNECTION_INTERFACE_RENAMING, _renaming_iface_init); + G_IMPLEMENT_INTERFACE(TP_TYPE_SVC_CONNECTION_INTERFACE_RENAMING1, _renaming_iface_init); + G_IMPLEMENT_INTERFACE(IDLE_TYPE_SVC_CONNECTION_INTERFACE_IRC_COMMAND1, irc_command_iface_init); ); typedef struct _IdleOutputPendingMsg IdleOutputPendingMsg; @@ -432,7 +434,7 @@ static void idle_connection_finalize (GObject *object) { static const gchar * interfaces_always_present[] = { TP_IFACE_CONNECTION_INTERFACE_ALIASING1, TP_IFACE_CONNECTION_INTERFACE_CONTACT_INFO1, - IDLE_IFACE_CONNECTION_INTERFACE_RENAMING, + TP_IFACE_CONNECTION_INTERFACE_RENAMING1, NULL}; const gchar * const *idle_connection_get_implemented_interfaces (void) { @@ -1068,7 +1070,9 @@ static IdleParserHandlerResult _nick_handler(IdleParser *parser, IdleParserMessa tp_base_connection_set_self_handle(TP_BASE_CONNECTION(conn), new_handle); } - idle_svc_connection_interface_renaming_emit_renamed(IDLE_SVC_CONNECTION_INTERFACE_RENAMING(conn), old_handle, new_handle); + tp_svc_connection_interface_renaming1_emit_renamed(conn, old_handle, new_handle, + tp_handle_inspect (tp_base_connection_get_handles ( + TP_BASE_CONNECTION (conn), TP_HANDLE_TYPE_CONTACT), new_handle)); idle_connection_emit_queued_aliases_changed(conn); @@ -1374,11 +1378,15 @@ static gboolean _send_rename_request(IdleConnection *obj, const gchar *nick, DBu return TRUE; } -static void idle_connection_request_rename(IdleSvcConnectionInterfaceRenaming *iface, const gchar *nick, DBusGMethodInvocation *context) { +static void +idle_connection_request_rename (TpSvcConnectionInterfaceRenaming1 *iface, + const gchar *nick, + DBusGMethodInvocation *context) +{ IdleConnection *conn = IDLE_CONNECTION(iface); if (_send_rename_request(conn, nick, context)) - idle_svc_connection_interface_renaming_return_from_request_rename(context); + tp_svc_connection_interface_renaming1_return_from_request_rename(context); } static void idle_connection_set_aliases(TpSvcConnectionInterfaceAliasing1 *iface, GHashTable *aliases, DBusGMethodInvocation *context) { @@ -1502,9 +1510,9 @@ static void _aliasing_iface_init(gpointer g_iface, gpointer iface_data) { } static void _renaming_iface_init(gpointer g_iface, gpointer iface_data) { - IdleSvcConnectionInterfaceRenamingClass *klass = (IdleSvcConnectionInterfaceRenamingClass *) g_iface; + TpSvcConnectionInterfaceRenaming1Class *klass = g_iface; -#define IMPLEMENT(x) idle_svc_connection_interface_renaming_implement_##x (\ +#define IMPLEMENT(x) tp_svc_connection_interface_renaming1_implement_##x (\ klass, idle_connection_##x) IMPLEMENT(request_rename); #undef IMPLEMENT @@ -1532,3 +1540,79 @@ idle_connection_fill_contact_attributes (TpBaseConnection *base, TP_BASE_CONNECTION_CLASS (idle_connection_parent_class)-> fill_contact_attributes (base, dbus_interface, handle, attributes); } + +typedef struct +{ + const gchar *command; + const gchar *error_msg; +} IrcCommandCheck; + +static const IrcCommandCheck commands[] = { + { "INVITE", "Use the Group API on room channels" }, + { "JOIN", "Use the Group API on room channels" }, + { "KICK", "Use the Group API on room channels" }, + { "PART", "Use the Group API on room channels" }, + { "PRIVMSG", "Use text channels" }, + { "QUIT", "Disconnect the connection" }, + { "TOPIC", "Use the Subject API on room channels" }, + { NULL, NULL } +}; + +/* Return FALSE and set @error if @command is not meant to be used with + * IRC_Command.Send() as we have proper Telepathy API for it. */ +static gboolean +check_irc_command (IdleConnection *self, + const gchar *full_command, + GError **error) +{ + gchar **splitted; + guint i; + + splitted = g_strsplit (full_command, " ", 0); + + for (i = 0; commands[i].command != NULL; i++) + { + if (g_ascii_strcasecmp (splitted[0], commands[i].command) == 0) + { + g_set_error_literal (error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT, + commands[i].error_msg); + + g_strfreev (splitted); + return FALSE; + } + } + + g_strfreev (splitted); + return TRUE; +} + +static void +idle_connection_irc_command_send (IdleSvcConnectionInterfaceIRCCommand1 *iface, + const gchar *command, + DBusGMethodInvocation *context) +{ + IdleConnection *self = IDLE_CONNECTION(iface); + GError *error = NULL; + + if (!check_irc_command (self, command, &error)) + { + dbus_g_method_return_error (context, error); + g_error_free (error); + return; + } + + _send_with_priority (self, command, SERVER_CMD_NORMAL_PRIORITY); + + dbus_g_method_return (context); +} + +static void irc_command_iface_init(gpointer g_iface, + gpointer iface_data) +{ + IdleSvcConnectionInterfaceIRCCommand1Class *klass = g_iface; + +#define IMPLEMENT(x) idle_svc_connection_interface_irc_command1_implement_##x (\ + klass, idle_connection_irc_command_##x) + IMPLEMENT(send); +#undef IMPLEMENT +} diff --git a/src/idle-muc-channel.c b/src/idle-muc-channel.c index ed97cfa..fe9439c 100644 --- a/src/idle-muc-channel.c +++ b/src/idle-muc-channel.c @@ -841,11 +841,7 @@ void idle_muc_channel_namereply(IdleMUCChannel *chan, GValueArray *args) { for (guint i = 1; (i + 1) < args->n_values; i += 2) { TpHandle handle = g_value_get_uint(g_value_array_get_nth(args, i)); -#if GLIB_CHECK_VERSION(2, 31, 0) gchar modechar = g_value_get_schar(g_value_array_get_nth(args, i + 1)); -#else - gchar modechar = g_value_get_char(g_value_array_get_nth(args, i + 1)); -#endif if (handle == tp_base_connection_get_self_handle (base_conn)) { guint remove = MODE_FLAG_OPERATOR_PRIVILEGE | MODE_FLAG_VOICE_PRIVILEGE | MODE_FLAG_HALFOP_PRIVILEGE; diff --git a/src/idle-parser.c b/src/idle-parser.c index 159e6cc..6f0885c 100644 --- a/src/idle-parser.c +++ b/src/idle-parser.c @@ -541,11 +541,7 @@ static gboolean _parse_atom(IdleParser *parser, GValueArray *arr, char atom, con if (atom == 'C') { g_value_init(&val, G_TYPE_CHAR); -#if GLIB_CHECK_VERSION(2, 31, 0) g_value_set_schar(&val, modechar); -#else - g_value_set_char(&val, modechar); -#endif g_value_array_append(arr, &val); g_value_unset(&val); diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am index 966c708..ded35b5 100644 --- a/tests/twisted/Makefile.am +++ b/tests/twisted/Makefile.am @@ -23,6 +23,7 @@ TWISTED_TESTS = \ channels/muc-destroy.py \ channels/room-list-channel.py \ channels/room-list-multiple.py \ + irc-command.py \ messages/accept-invalid-nicks.py \ messages/contactinfo-request.py \ messages/invalid-utf8.py \ diff --git a/tests/twisted/irc-command.py b/tests/twisted/irc-command.py new file mode 100644 index 0000000..6ec27da --- /dev/null +++ b/tests/twisted/irc-command.py @@ -0,0 +1,31 @@ +""" +Test Messages interface implementation +""" + +from idletest import exec_test +from servicetest import call_async +import constants as cs +import dbus + +def test(q, bus, conn, stream): + conn.Connect() + q.expect('dbus-signal', signal='StatusChanged', + args=[cs.CONN_STATUS_CONNECTED, cs.CSR_REQUESTED]) + + irc_cmd = dbus.Interface(conn, cs.CONN + '.Interface.IRCCommand1') + + call_async(q, irc_cmd, 'Send', 'badger mushroom snake') + + q.expect('stream-BADGER', data=['mushroom', 'snake']) + + q.expect('dbus-return', method='Send') + + # We are not supposed to use this API to send messages + call_async(q, irc_cmd, 'Send', 'PRIVMSG badger :oh hi') + + q.expect('dbus-error', method='Send', name=cs.INVALID_ARGUMENT) + + call_async(q, conn, 'Disconnect') + +if __name__ == '__main__': + exec_test(test) |