diff options
-rw-r--r-- | extensions/Connection_Interface_Irc_Command.xml | 46 | ||||
-rw-r--r-- | extensions/all.xml | 1 | ||||
-rw-r--r-- | src/idle-connection.c | 24 | ||||
-rw-r--r-- | tests/twisted/Makefile.am | 1 | ||||
-rw-r--r-- | tests/twisted/irc-command.py | 26 |
5 files changed, 98 insertions, 0 deletions
diff --git a/extensions/Connection_Interface_Irc_Command.xml b/extensions/Connection_Interface_Irc_Command.xml new file mode 100644 index 0000000..625bd9f --- /dev/null +++ b/extensions/Connection_Interface_Irc_Command.xml @@ -0,0 +1,46 @@ +<?xml version="1.0" ?> +<node name="/Connection_Interface_Irc_Command" 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="org.freedesktop.Telepathy.Connection.Interface.IrcCommand1" + tp:causes-havoc='not well-tested'> + <tp:requires interface="org.freedesktop.Telepathy.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> + </tp:docstring> + <tp:possible-errors> + <tp:error name="org.freedesktop.Telepathy.Error.Disconnected"/> + <tp:error name="org.freedesktop.Telepathy.Error.NetworkError"/> + <tp:error name="org.freedesktop.Telepathy.Error.NotAvailable"/> + <tp:error name="org.freedesktop.Telepathy.Error.InvalidArgument"/> + <tp:error name="org.freedesktop.Telepathy.Error.PermissionDenied"/> + </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/all.xml b/extensions/all.xml index 3ed5d93..7e846bb 100644 --- a/extensions/all.xml +++ b/extensions/all.xml @@ -23,6 +23,7 @@ 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_Command.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 9ba1d23..7f0aad6 100644 --- a/src/idle-connection.c +++ b/src/idle-connection.c @@ -65,12 +65,14 @@ static void _free_alias_pair(gpointer data, gpointer user_data) 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_ALIASING, _aliasing_iface_init); G_IMPLEMENT_INTERFACE(TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACT_INFO, 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_CONTACTS, tp_contacts_mixin_iface_init); + G_IMPLEMENT_INTERFACE(IDLE_TYPE_SVC_CONNECTION_INTERFACE_IRC_COMMAND, irc_command_iface_init); ); typedef struct _IdleOutputPendingMsg IdleOutputPendingMsg; @@ -1569,3 +1571,25 @@ static void _renaming_iface_init(gpointer g_iface, gpointer iface_data) { #undef IMPLEMENT } +static void +idle_connection_irc_command_send (IdleSvcConnectionInterfaceIrcCommand *iface, + const gchar *command, + DBusGMethodInvocation *context) +{ + IdleConnection *self = IDLE_CONNECTION(iface); + + _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) +{ + IdleSvcConnectionInterfaceIrcCommandClass *klass = (IdleSvcConnectionInterfaceIrcCommandClass *) g_iface; + +#define IMPLEMENT(x) idle_svc_connection_interface_irc_command_implement_##x (\ + klass, idle_connection_irc_command_##x) + IMPLEMENT(send); +#undef IMPLEMENT +} 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..1073b6a --- /dev/null +++ b/tests/twisted/irc-command.py @@ -0,0 +1,26 @@ +""" +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') + + call_async(q, conn, 'Disconnect') + +if __name__ == '__main__': + exec_test(test) |