[Telepathy-commits] [telepathy-salut/master] Added new File channel type spec and got current code to compile.

Jonny Lamb jonny.lamb at collabora.co.uk
Fri Nov 21 03:45:58 PST 2008


20080716124438-8ed0e-719526712fb057566d999a8a06f0e209a6a65eb6.gz
---
 extensions/Channel_Type_File.xml          |  354 +++++++++++++++++++++++++++++
 extensions/Channel_Type_File_Transfer.xml |  269 ----------------------
 extensions/Makefile.am                    |    1 +
 extensions/channel.xml                    |    1 +
 src/file-transfer-mixin.c                 |  142 +-----------
 src/file-transfer-mixin.h                 |    5 +-
 src/salut-ft-channel.c                    |  190 +--------------
 7 files changed, 373 insertions(+), 589 deletions(-)
 create mode 100644 extensions/Channel_Type_File.xml
 delete mode 100644 extensions/Channel_Type_File_Transfer.xml

diff --git a/extensions/Channel_Type_File.xml b/extensions/Channel_Type_File.xml
new file mode 100644
index 0000000..5afcf24
--- /dev/null
+++ b/extensions/Channel_Type_File.xml
@@ -0,0 +1,354 @@
+<?xml version="1.0" ?>
+<node name="/Channel_Type_File" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
+  <tp:copyright>
+    Copyright (C) 2008 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
+Library 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.Channel.Type.File.DRAFT"
+    tp:causes-havoc="experimental">
+    <tp:requires interface="org.freedesktop.Telepathy.Channel"/>
+    <tp:docstring>
+      <p>A channel type for files offered for transferring.
+      The actual transmission of the data is done by reading or writing
+      a socket, the type of socket (local Unix, IPv4, etc.) when the File
+      channel is created.</p>
+
+      <p>The File channel type may be requested for handles of type
+      HANDLE_TYPE_CONTACT.</p>
+    </tp:docstring>
+
+    <property name="ContentType" type="s" access="read">
+      <tp:docstring xmlns="http://www.w3.org/1999/xhtml">
+        <p>The file's MIME type. This cannot change once the channel has
+        been created.</p>
+
+        <p>This property is mandatory. Protocols which do not have a
+        content-type property with file transfers should set this value to
+        application/octet-stream.</p>
+      </tp:docstring>
+    </property>
+
+    <property name="Filename" type="s" access="read">
+      <tp:docstring xmlns="http://www.w3.org/1999/xhtml">
+        <p>The name of the file on the sender's side. This is therefore given
+        as a suggested filename for the receiver. This cannot change
+        once the channel has been created.</p>
+
+        <p>If this property is an empty string, then its value is unspecified.</p>
+      </tp:docstring>
+    </property>
+
+    <property name="Size" type="t" access="read">
+      <tp:docstring xmlns="http://www.w3.org/1999/xhtml">
+        <p>The size of the file. If this property is set, then the file
+        transfer is guaranteed to be this size. This cannot change once
+        the channel has been created.</p>
+
+        <p>If this property is UINT64_MAX, then its value is unspecified.</p>
+      </tp:docstring>
+    </property>
+
+    <property name="EstimatedSize" type="t" access="read">
+      <tp:docstring xmlns="http://www.w3.org/1999/xhtml">
+        <p>An estimate of the size of the file. This property should be used
+        when the protocol doesn't allow exact file sizes (For example, accurate
+        to the nearest megabyte). This property should not be set if the Size
+        property can, or has, been set. This cannot change once the channel
+        has been created.</p>
+
+        <p>If this property is UINT64_MAX, then its value is unspecified.</p>
+      </tp:docstring>
+    </property>
+
+    <property name="ContentMD5" type="s" access="read">
+      <tp:docstring xmlns="http://www.w3.org/1999/xhtml">
+        <p>MD5 digest of the file as a string of 32 ASCII hex digits, which
+        SHOULD be lower-case if they are letters. This cannot change once
+        the channel has been created.</p>
+
+        <p>If this property is an empty string, then its value is unspecified.</p>
+      </tp:docstring>
+    </property>
+
+    <property name="Description" type="s" access="read">
+      <tp:docstring xmlns="http://www.w3.org/1999/xhtml">
+        <p>Description of the file transfer. This cannot change once the
+        channel has been created.</p>
+
+        <p>If this property is an empty string, then its value is unspecified.</p>
+      </tp:docstring>
+    </property>
+
+    <property name="AvailableSocketTypes" type="a{uau}"
+      tp:type="Supported_Socket_Map" access="read">
+      <tp:docstring xmlns="http://www.w3.org/1999/xhtml">
+        <p>A mapping from address types (members of Socket_Address_Type) to
+        arrays of access-control type (members of Socket_Access_Control)
+        that the connection manager supports for sockets with that
+        address type. For simplicity, if a CM supports offering a
+        particular type of file transfer, it is assumed to support accepting
+        it.</p>
+
+        <p>A typical value for a host that supports only Unix sockets:</p>
+
+        <pre>
+          {
+            Socket_Address_Type_Unix:
+              [Socket_Access_Control_Localhost, Socket_Access_Control_Credentials]
+            Socket_Address_Type_Abstract_Unix:
+              [Socket_Access_Control_Localhost, Socket_Access_Control_Credentials]
+          }
+        </pre>
+      </tp:docstring>
+    </property>
+
+    <property name="TransferredBytes" type="t" access="read">
+      <tp:docstring xmlns="http://www.w3.org/1999/xhtml">
+        <p>The number of bytes that have been transferred at the time of
+        requesting the property. This will be updated as the file transfer
+        continues.</p>
+      </tp:docstring>
+    </property>
+
+    <tp:enum name="File_Transfer_State">
+      <tp:enumvalue suffix="Local_Pending" value="0">
+        <tp:docstring>
+          The file transfer is waiting to be accepted/closed locally.
+        </tp:docstring>
+      </tp:enumvalue>
+      <tp:enumvalue suffix="Remote_Pending" value="1">
+        <tp:docstring>
+          The file transfer is waiting to be accepted/closed remotely.
+        </tp:docstring>
+      </tp:enumvalue>
+      <tp:enumvalue suffix="Open" value="2">
+        <tp:docstring>
+          The file transfer is open for traffic.
+        </tp:docstring>
+      </tp:enumvalue>
+      <tp:enumvalue suffix="Completed" value="3">
+        <tp:docstring>
+          The file transfer has been completed successfully.
+        </tp:docstring>
+      </tp:enumvalue>
+      <tp:enumvalue suffix="Canceled" value="4">
+        <tp:docstring>
+          The file transfer has been canceled.
+        </tp:docstring>
+      </tp:enumvalue>
+    </tp:enum>
+
+    <tp:enum name="File_Transfer_State_Change_Reason">
+      <tp:enumvalue suffix="None" value="0">
+        <tp:docstring>
+          No reason was specified.
+        </tp:docstring>
+      </tp:enumvalue>
+      <tp:enumvalue suffix="Local_Stopped" value="1">
+        <tp:docstring>
+          The file transfer was canceled by the local user.
+        </tp:docstring>
+      </tp:enumvalue>
+      <tp:enumvalue suffix="Remote_Stopped" value="2">
+        <tp:docstring>
+          The file transfer was canceled by the remote user.
+        </tp:docstring>
+      </tp:enumvalue>
+      <tp:enumvalue suffix="Local_Error" value="3">
+        <tp:docstring>
+          The file transfer was canceled because of a local error.
+        </tp:docstring>
+      </tp:enumvalue>
+      <tp:enumvalue suffix="Remote_Error" value="4">
+        <tp:docstring>
+          The file transfer was canceled because of a remote error.
+        </tp:docstring>
+      </tp:enumvalue>
+    </tp:enum>
+
+    <!-- Taken from org.freedesktop.Telepathy.Channel.Type.Tubes -->
+    <tp:enum name="Socket_Address_Type" type="u">
+      <tp:enumvalue suffix="Unix" value="0">
+        <tp:docstring>
+          A Unix socket. The variant contains a byte-array, signature 'ay',
+          containing the path of the socket.
+        </tp:docstring>
+      </tp:enumvalue>
+
+      <tp:enumvalue suffix="Abstract_Unix" value="1">
+        <tp:docstring>
+          An abstract Unix socket. The variant contains a byte-array,
+          signature 'ay', containing the path of the socket including the
+          leading null byte.
+        </tp:docstring>
+      </tp:enumvalue>
+
+      <tp:enumvalue suffix="IPv4" value="2">
+        <tp:docstring>
+          An IPv4 socket. The variant contains a Socket_Address_IPv4,
+          i.e. a structure with signature (sq)
+          in which the string is an IPv4 dotted-quad address literal
+          (and must not be a DNS name), while the 16-bit unsigned integer is
+          the port number.
+        </tp:docstring>
+      </tp:enumvalue>
+
+      <tp:enumvalue suffix="IPv6" value="3">
+        <tp:docstring>
+          An IPv6 socket. The variant contains a Socket_Address_IPv6,
+          i.e. a structure with signature (sq)
+          in which the string is an IPv6 address literal as specified in
+          RFC2373 (and must not be a DNS name), while the 16-bit unsigned
+          integer is the port number.
+        </tp:docstring>
+      </tp:enumvalue>
+
+    </tp:enum>
+
+    <!-- Taken from org.freedesktop.Telepathy.Channel.Type.Tubes -->
+    <tp:enum name="Socket_Access_Control" type="u">
+      <tp:enumvalue suffix="Localhost" value="0">
+        <tp:docstring>
+          The IP or Unix socket can be accessed by any local user (e.g.
+          a Unix socket that accepts all local connections, or an IP socket
+          listening on 127.0.0.1 (or ::1) or rejecting connections not from
+          that address). The associated variant must be ignored.
+        </tp:docstring>
+      </tp:enumvalue>
+      <tp:enumvalue suffix="Port" value="1">
+        <tp:docstring>
+          May only be used on IP sockets. The associated variant must contain
+          a struct Socket_Address_IPv4 (or Socket_Address_IPv6)
+          containing the string form of an IP address of the appropriate
+          version, and a port number. The socket can only be accessed if the
+          connecting process has that address and port number; all other
+          connections will be rejected.
+        </tp:docstring>
+      </tp:enumvalue>
+      <tp:enumvalue suffix="Netmask" value="2">
+        <tp:docstring>
+          May only be used on IP sockets. The associated variant must contain
+          a struct Socket_Netmask_IPv4 (or Socket_Netmask_IPv6) with
+          signature (sy), containing the string form of an
+          IP address of the appropriate version, and a prefix length "n".
+          The socket can only be accessed if the first n bits of the
+          connecting address match the first n bits of the given address.
+        </tp:docstring>
+      </tp:enumvalue>
+      <tp:enumvalue suffix="Credentials" value="3">
+        <tp:docstring xmlns="http://www.w3.org/1999/xhtml">
+          <p>The connecting process must send a single zero (NUL) byte when
+            it first connects, which is not considered to be part of the data
+            stream. If the operating system uses sendmsg() with SCM_CREDS or
+            SCM_CREDENTIALS to pass credentials over sockets, the connecting
+            process must do so if possible; if not, it must still send the
+            byte.</p>
+
+          <p>The listening process will disconnect the connection unless it
+            can determine by OS-specific means that the connecting process
+            has the same user ID as the listening process.</p>
+
+          <p>The associated variant must be ignored.</p>
+        </tp:docstring>
+      </tp:enumvalue>
+    </tp:enum>
+
+    <!-- Taken from org.freedesktop.Telepathy.Channel.Type.Tubes -->
+    <tp:mapping name="Supported_Socket_Map">
+      <tp:docstring>The supported socket address and access-control types
+        for tubes. See GetAvailableStreamTubeTypes.</tp:docstring>
+      <tp:member name="Address_Type" type="u" tp:type="Socket_Address_Type"/>
+      <tp:member name="Access_Control" type="au"
+        tp:type="Socket_Access_Control[]"/>
+    </tp:mapping>
+
+    <method name="AcceptFile">
+      <tp:docstring>
+        Accept a file transfer that's in the "local pending" state. The file 
+        transfer becomes open after this method is called.
+      </tp:docstring>
+      <arg direction="in" name="address_type" type="u" tp:type="Socket_Address_Type">
+        <tp:docstring>
+          The type of address the connection manager should listen on.
+        </tp:docstring>
+      </arg>
+      <arg direction="in" name="access_control" type="u" tp:type="Socket_Access_Control">
+        <tp:docstring>
+          The type of access control the connection manager should apply to
+          the socket.
+        </tp:docstring>
+      </arg>
+      <arg direction="in" name="access_control_param" type="v">
+        <tp:docstring>
+          A parameter for the access control type, to be interpreted as
+          specified in the documentation for the Socket_Access_Control enum.
+        </tp:docstring>
+      </arg>
+      <arg direction="out" name="address" type="v">
+        <tp:docstring>
+          The address on which the connection manager will listen for
+          connections for this file transfer.
+        </tp:docstring>
+      </arg>
+
+      <tp:possible-errors>
+        <tp:error name="org.freedesktop.Telepathy.Error.NotImplemented">
+          <tp:docstring>
+            The given address type or access-control mechanism is not supported.
+          </tp:docstring>
+        </tp:error>
+        <tp:error name="org.freedesktop.Telepathy.Error.NetworkError"/>
+        <tp:error name="org.freedesktop.Telepathy.Error.InvalidArgument"/>
+      </tp:possible-errors>
+    </method>
+
+    <signal name="FileTransferStateChanged">
+      <tp:docstring>
+        Emitted when the state of a file transfer changes.
+      </tp:docstring>
+      <arg name="state" type="u" tp:type="File_Transfer_State">
+        <tp:docstring>
+          The new state of the file transfer; see the File_Transfer_State enumeration.
+        </tp:docstring>
+      </arg>
+      <arg name="reason" type="u" tp:type="File_Transfer_State_Change_Reason">
+        <tp:docstring>
+          The reason for the state change; see the File_Transfer_State_Change_Reason
+          enumeration.
+          The value will always be File_Transfer_State_Change_Reason_None, except
+          when changing state to canceled.
+        </tp:docstring>
+      </arg>
+    </signal>
+
+    <signal name="TransferredBytesChanged">
+      <tp:docstring>
+        Emitted when the number of transferred bytes changes. This will not change
+        with every single byte change. Instead, the most frequent this signal will
+        be emmitted is once a second. This should be sufficient, and the
+        TransferredBytes property should not be polled.
+      </tp:docstring>
+      <arg name="count" type="t">
+        <tp:docstring>
+          The number of already transferred bytes.
+        </tp:docstring>
+      </arg>
+    </signal>
+  </interface>
+
+</node>
+<!-- vim:set sw=2 sts=2 et ft=xml: -->
diff --git a/extensions/Channel_Type_File_Transfer.xml b/extensions/Channel_Type_File_Transfer.xml
deleted file mode 100644
index 5593d11..0000000
--- a/extensions/Channel_Type_File_Transfer.xml
+++ /dev/null
@@ -1,269 +0,0 @@
-<?xml version="1.0" ?>
-<node name="/Channel_Type_File_Transfer" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
-  <tp:copyright>
-    Copyright (C) 2007 Collabora Limited
-  </tp:copyright>
-  <tp:license>
-    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.
-
-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
-Library General Public License for more details.
-
-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.
-  </tp:license>
-  <interface name="org.freedesktop.Telepathy.Channel.Type.FileTransfer" tp:name-const="CHANNEL_TYPE_FILE_TRANSFER">
-    <tp:requires interface="org.freedesktop.Telepathy.Channel"/>
-    <tp:docstring>
-      A channel type for offering and receiving files.
-      The actual transmission of the data is done by reading or writing 
-      a local Unix socket.
-      
-      The FileTransfer channel type may be requested for handles of type
-      HANDLE_TYPE_CONTACT and HANDLE_TYPE_ROOM.
-      TODO: Is sending to multiple persons implemented in anything?
-    </tp:docstring>
-
-    <tp:enum name="FileTransfer_State">
-      <tp:enumvalue suffix="LocalPending" value="0">
-        <tp:docstring>
-          The file transfer is waiting to be accepted/closed locally.
-        </tp:docstring>
-      </tp:enumvalue>
-      <tp:enumvalue suffix="RemotePending" value="1">
-        <tp:docstring>
-          The file transfer is waiting to be accepted/closed remotely.
-        </tp:docstring>
-      </tp:enumvalue>
-      <tp:enumvalue suffix="Open" value="2">
-        <tp:docstring>
-          The file transfer is open for traffic.
-        </tp:docstring>
-      </tp:enumvalue>
-    </tp:enum>
-
-    <tp:enum name="FileTransfer_Direction">
-      <tp:enumvalue suffix="Incoming" value="0">
-        <tp:docstring>
-          The file transfer is for an incoming file, i.e. a file offered
-          to this client.
-        </tp:docstring>
-      </tp:enumvalue>
-      <tp:enumvalue suffix="Outgoing" value="1">
-        <tp:docstring>
-          The file transfer is for an outgoing file, i.e. a file offered
-          by this client.
-        </tp:docstring>
-      </tp:enumvalue>
-    </tp:enum>
-
-    <tp:enum name="FileTransfer_CloseReason">
-      <tp:enumvalue suffix="Success" value="0">
-        <tp:docstring>
-          The file transfer was completed successfully.
-        </tp:docstring>
-      </tp:enumvalue>
-      <tp:enumvalue suffix="LocalStopped" value="1">
-        <tp:docstring>
-          The file transfer was closed by the local user.
-        </tp:docstring>
-      </tp:enumvalue>
-      <tp:enumvalue suffix="RemoteStopped" value="2">
-        <tp:docstring>
-          The file transfer was closed by the remote user.
-        </tp:docstring>
-      </tp:enumvalue>
-      <tp:enumvalue suffix="LocalError" value="3">
-        <tp:docstring>
-          The file transfer was closed because of a local error.
-        </tp:docstring>
-      </tp:enumvalue>
-      <tp:enumvalue suffix="RemoteError" value="4">
-        <tp:docstring>
-          The file transfer was closed because of a remote error.
-        </tp:docstring>
-      </tp:enumvalue>
-    </tp:enum>
-
-
-    <method name="ListFileTransfers">
-      <arg direction="out" type="a(uuuusa{sv})">
-        <tp:docstring>
-         Return an array of tuples, each representing a file transfer, with the
-         following members:
-
-         <ul>
-           <li>the file transfer's ID</li>
-           <li>the file transfer's initiator</li>
-           <li>the file transfer's direction, as described by the 
-               FileTransfer_Direction enum</li>
-           <li>the file transfer's state</li>
-           <li>the file's friendly filename, for displaying</li>
-           <li>the file's additional information</li>
-         </ul>
-        </tp:docstring>
-      </arg>
-    </method>
-
-    <method name="OfferFile">
-      <tp:docstring>
-        Offers a file for transmission.
-      </tp:docstring>
-      <arg direction="in" name="filename" type="s">
-        <tp:docstring>
-          The filename of the file that is to be transmitted, for displaying.
-        </tp:docstring>
-      </arg>
-      <arg direction="in" name="information" type="a{sv}">
-        <tp:docstring>
-          A dictionary of additional information about the file.
-          Common keys:
-          TODO
-        </tp:docstring>
-      </arg>
-      <arg direction="out" type="u">
-        <tp:docstring>
-          The ID of the new file transfer.
-        </tp:docstring>
-      </arg>
-    </method>
-
-    <signal name="NewFileTransfer">
-      <tp:docstring>
-        Emitted when a file transfer is created.
-      </tp:docstring>
-      <arg name="id" type="u">
-        <tp:docstring>
-          The ID of the new file transfer.
-        </tp:docstring>
-      </arg>
-      <arg name="initiator" type="u">
-        <tp:docstring>
-          The handle of the contact who initiated the file transfer.
-        </tp:docstring>
-      </arg>
-      <arg name="direction" type="u">
-        <tp:docstring>
-          The file transfer's direction, as described by the 
-          FileTransfer_Direction enum.
-        </tp:docstring>
-      </arg>
-      <arg name="state" type="u">
-        <tp:docstring>
-          The new file transfer's state.
-        </tp:docstring>
-      </arg>
-      <arg name="filename" type="s">
-        <tp:docstring>
-          The filename of the file that is to be transmitted, for displaying.
-        </tp:docstring>
-      </arg>
-      <arg name="information" type="a{sv}">
-        <tp:docstring>
-          The new file's additional information.
-        </tp:docstring>
-      </arg>
-    </signal>
-
-    <method name="AcceptFile">
-      <tp:docstring>
-        Accept a file transfer that's in the "local pending" state. The file 
-        transfer becomes open after this method is called.
-      </tp:docstring>
-      <arg direction="in" name="id" type="u">
-        <tp:docstring>
-          The ID of the file transfer to accept.
-        </tp:docstring>
-      </arg>
-    </method>
-
-    <signal name="FileTransferStateChanged">
-      <tp:docstring>
-        Emitted when the state of a file transfer changes.
-      </tp:docstring>
-      <arg name="id" type="u">
-        <tp:docstring>
-          The ID of the file transfer that changed state.
-        </tp:docstring>
-      </arg>
-      <arg name="state" type="u">
-        <tp:docstring>
-          The new state of the file transfer; see the FileTransfer_State enumeration.
-        </tp:docstring>
-      </arg>
-    </signal>
-
-    <method name="CloseFileTransfer">
-      <tp:docstring>
-        Close a file transfer.
-      </tp:docstring>
-      <arg direction="in" name="id" type="u">
-        <tp:docstring>
-          The ID of the file transfer to close.
-        </tp:docstring>
-      </arg>
-      <arg direction="in" name="reason" type="u">
-        <tp:docstring>
-          The reason why the file transfer is being closed; see the
-          FileTransfer_CloseReason enumeration.
-        </tp:docstring>
-      </arg>
-    </method>
-
-    <signal name="FileTransferClosed">
-      <tp:docstring>
-       Emitted when a file transfer has been closed. The ID of a closed file 
-       transfer is no longer valid. The ID may later be reused for a new 
-       file transfer.
-      </tp:docstring>
-      <arg name="id" type="u">
-        <tp:docstring>
-          The ID of the file transfer that was closed.
-        </tp:docstring>
-      </arg>
-      <arg name="reason" type="u">
-        <tp:docstring>
-          The reason why the file transfer was closed; see the
-          FileTransfer_CloseReason enumeration.
-        </tp:docstring>
-      </arg>
-    </signal>
-
-    <method name="GetLocalUnixSocketPath">
-      <tp:docstring>
-        Retreives the path to a local Unix socket, from which to read or write 
-        the file contents, depending on the direction of the file transfer.
-
-        Immediately after connecting to the socket, the client must send a 
-        single nul byte. This byte may be accompanied by credentials 
-        information on some operating systems that use sendmsg() with 
-        SCM_CREDS or SCM_CREDENTIALS to pass credentials over UNIX domain 
-        sockets.
-      </tp:docstring>
-      <arg direction="in" name="id" type="u">
-        <tp:docstring>
-          The ID of the file transfer to get an path for.
-        </tp:docstring>
-      </arg>
-      <arg direction="out" type="s">
-        <tp:docstring>
-          The Unix socket path.
-        </tp:docstring>
-      </arg>
-      <tp:possible-errors>
-        <tp:error name="org.freedesktop.Telepathy.Error.NotAvailable">
-          This file transfer is not in the "open" state.
-        </tp:error>
-      </tp:possible-errors>
-    </method>
-
-  </interface>
-
-</node>
-<!-- vim:set sw=2 sts=2 et ft=xml: -->
diff --git a/extensions/Makefile.am b/extensions/Makefile.am
index a1f7b81..a3edfaf 100644
--- a/extensions/Makefile.am
+++ b/extensions/Makefile.am
@@ -2,6 +2,7 @@ tools_dir = $(top_srcdir)/tools
 
 EXTRA_DIST = \
     Channel_Type_File_Transfer.xml \
+    Channel_Type_File.xml \
     channel.xml \
     OLPC_Buddy_Info.xml \
     OLPC_Activity_Properties.xml \
diff --git a/extensions/channel.xml b/extensions/channel.xml
index 14962f0..50497aa 100644
--- a/extensions/channel.xml
+++ b/extensions/channel.xml
@@ -24,5 +24,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA</p>
 
 <xi:include href="Channel_Type_File_Transfer.xml"/>
 <xi:include href="Channel_Future.xml"/>
+<xi:include href="Channel_Type_File.xml"/>
 
 </tp:spec>
diff --git a/src/file-transfer-mixin.c b/src/file-transfer-mixin.c
index bcccad0..c39c5dd 100644
--- a/src/file-transfer-mixin.c
+++ b/src/file-transfer-mixin.c
@@ -23,7 +23,7 @@
  * SECTION:file-transfer-mixin
  * @title: TpFileTransferMixin
  * @short_description: a mixin implementation of the file transfer channel type
- * @see_also: #SalutSvcChannelTypeFileTransfer
+ * @see_also: #SalutSvcChannelTypeFile
  *
  * This mixin can be added to a channel GObject class to implement the file
  * transfer channel type in a general way. It implements the list of transfers
@@ -265,7 +265,7 @@ tp_file_transfer_mixin_set_state (GObject *obj,
   if (transfer != NULL)
     {
       transfer->state = state;
-      salut_svc_channel_type_file_transfer_emit_file_transfer_state_changed (
+      salut_svc_channel_type_file_emit_file_transfer_state_changed (
               obj, id, state);
       return TRUE;
     }
@@ -381,42 +381,6 @@ tp_file_transfer_mixin_add_transfer (GObject *obj,
   return id;
 }
 
-/**
- * tp_file_transfer_mixin_emit_new_file_transfer:
- *
- * @obj: An object with the file transfer mixin
- * @id: The ID of the file transfer
- *
- * Emit NewFileTransfer for the file transfer with ID @id.
- *
- * Returns: TRUE if successful, FALSE if an error was thrown.
- */
-gboolean
-tp_file_transfer_mixin_emit_new_file_transfer (GObject *obj,
-                                               guint id,
-                                               GError **error)
-{
-  TpFileTransferMixin *mixin = TP_FILE_TRANSFER_MIXIN (obj);
-  _Transfer *transfer;
-
-  transfer = g_hash_table_lookup (mixin->priv->transfers, GINT_TO_POINTER (id));
-  if (transfer == NULL)
-    {
-      DEBUG ("invalid transfer id %u", id);
-      g_set_error (error, TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
-                   "invalid transfer id %u", id);
-      return FALSE;
-    }
-
-  DEBUG ("emitting NewFileTransfer for id %u", id);
-
-  salut_svc_channel_type_file_transfer_emit_new_file_transfer (obj, id,
-          transfer->initiator, transfer->direction, transfer->state,
-          transfer->filename, transfer->information);
-
-  return TRUE;
-}
-
 static GValue *
 get_file_transfer (guint id,
                    _Transfer *transfer)
@@ -509,27 +473,6 @@ tp_file_transfer_mixin_list_file_transfers (GObject *obj,
 }
 
 static void
-tp_file_transfer_mixin_list_file_transfers_async (SalutSvcChannelTypeFileTransfer *iface,
-                                                  DBusGMethodInvocation *context)
-{
-  GPtrArray *ret;
-  GError *error = NULL;
-
-  if (tp_file_transfer_mixin_list_file_transfers (G_OBJECT (iface), &ret,
-      &error))
-    {
-      salut_svc_channel_type_file_transfer_return_from_list_file_transfers (
-          context, ret);
-      g_ptr_array_free (ret, TRUE);
-    }
-  else
-    {
-      dbus_g_method_return_error (context, error);
-      g_error_free (error);
-    }
-}
-
-static void
 create_socket_path (TpFileTransferMixin *mixin)
 {
   gint fd;
@@ -596,79 +539,9 @@ tp_file_transfer_mixin_get_local_unix_socket_path (GObject *obj,
   return TRUE;
 }
 
-static void
-tp_file_transfer_mixin_get_local_unix_socket_path_async (SalutSvcChannelTypeFileTransfer *iface,
-                                                         guint id,
-                                                         DBusGMethodInvocation *context)
-{
-  GError *error = NULL;
-  gchar *path;
-
-  if (tp_file_transfer_mixin_get_local_unix_socket_path (G_OBJECT (iface), id, &path,
-      &error))
-    {
-      salut_svc_channel_type_file_transfer_return_from_get_local_unix_socket_path (
-          context, path);
-      g_free (path);
-    }
-  else
-    {
-      dbus_g_method_return_error (context, error);
-      g_error_free (error);
-    }
-}
-
-/**
- * tp_file_transfer_mixin_close_file_transfer:
- *
- * @obj: An object with this mixin
- * @id: The ID of the file transfer to close
- * @error: Used to return a pointer to a GError detailing any error
- *         that occurred.
- *
- * Close the file transfer with ID @id and emit FileTransferClosed.
- * Call this function from your implementation of the CloseFileTransfer
- * method on interface org.freedesktop.Telepathy.Channel.Type.FileTransfer.
- *
- * Returns: TRUE if successful, FALSE if an error was thrown.
- */
-gboolean
-tp_file_transfer_mixin_close_file_transfer (GObject *obj,
-                                            guint id,
-                                            SalutFileTransferCloseReason reason,
-                                            GError **error)
-{
-  TpFileTransferMixin *mixin = TP_FILE_TRANSFER_MIXIN (obj);
-  _Transfer *transfer;
-
-  transfer = g_hash_table_lookup (mixin->priv->transfers,
-                                  GINT_TO_POINTER (id));
-  if (transfer != NULL)
-    {
-      if (mixin->priv->local_path != NULL)
-        {
-          gchar *local_socket;
-          local_socket = get_local_unix_socket_path (mixin, id);
-          g_unlink (local_socket);
-          g_free (local_socket);
-        }
-      g_hash_table_remove (mixin->priv->transfers, GINT_TO_POINTER (id));
-      salut_svc_channel_type_file_transfer_emit_file_transfer_closed (obj,
-          id, reason);
-      return TRUE;
-    }
-  else
-    {
-      DEBUG ("invalid transfer id %u", id);
-      g_set_error (error, TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
-          "invalid transfer id %u", id);
-      return FALSE;
-    }
-}
-
 /**
  * tp_file_transfer_mixin_iface_init:
- * @g_iface: A pointer to the #SalutSvcChannelTypeFileTransferClass in an object
+ * @g_iface: A pointer to the #SalutSvcChannelTypeFileClass in an object
  * class
  * @iface_data: Ignored
  *
@@ -684,13 +557,4 @@ tp_file_transfer_mixin_close_file_transfer (GObject *obj,
 void
 tp_file_transfer_mixin_iface_init (gpointer g_iface, gpointer iface_data)
 {
-  SalutSvcChannelTypeFileTransferClass *klass =
-      (SalutSvcChannelTypeFileTransferClass *)g_iface;
-
-#define IMPLEMENT(x) salut_svc_channel_type_file_transfer_implement_##x (klass,\
-    tp_file_transfer_mixin_##x##_async)
-  IMPLEMENT (list_file_transfers);
-  IMPLEMENT (get_local_unix_socket_path);
-  /* OfferFile, AcceptFile and CloseFileTransfer not implemented here */
-#undef IMPLEMENT
 }
diff --git a/src/file-transfer-mixin.h b/src/file-transfer-mixin.h
index b0462d3..24e0bc5 100644
--- a/src/file-transfer-mixin.h
+++ b/src/file-transfer-mixin.h
@@ -28,6 +28,7 @@
 
 #include <extensions/_gen/svc.h>
 #include <extensions/_gen/enums.h>
+#include <extensions/_gen/interfaces.h>
 
 G_BEGIN_DECLS
 
@@ -114,16 +115,12 @@ TpFileTransferState tp_file_transfer_mixin_get_state (GObject *obj, guint id,
 guint tp_file_transfer_mixin_add_transfer (GObject *obj, TpHandle initiator,
     TpFileTransferDirection direction, TpFileTransferState state,
     const char *filename, GHashTable *information, gpointer user_data);
-gboolean tp_file_transfer_mixin_emit_new_file_transfer (GObject *obj, guint id,
-    GError **error);
 gboolean tp_file_transfer_mixin_get_file_transfer (GObject *obj, guint id,
     GValue **ret, GError **error);
 gboolean tp_file_transfer_mixin_list_file_transfers (GObject *obj,
     GPtrArray **ret, GError **error);
 gboolean tp_file_transfer_mixin_get_local_unix_socket_path (GObject *obj,
     guint id, gchar **ret, GError **error);
-gboolean tp_file_transfer_mixin_close_file_transfer (GObject *obj, guint id,
-    SalutFileTransferCloseReason reason, GError **error);
 
 G_END_DECLS
 
diff --git a/src/salut-ft-channel.c b/src/salut-ft-channel.c
index 58253f2..07d9dcb 100644
--- a/src/salut-ft-channel.c
+++ b/src/salut-ft-channel.c
@@ -47,7 +47,6 @@
 #include <telepathy-glib/interfaces.h>
 #include <telepathy-glib/dbus.h>
 
-
 static void
 channel_iface_init (gpointer g_iface, gpointer iface_data);
 static void
@@ -56,7 +55,7 @@ file_transfer_iface_init (gpointer g_iface, gpointer iface_data);
 G_DEFINE_TYPE_WITH_CODE (SalutFtChannel, salut_ft_channel, G_TYPE_OBJECT,
     G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL, channel_iface_init);
     G_IMPLEMENT_INTERFACE (TP_TYPE_CHANNEL_IFACE, NULL);
-    G_IMPLEMENT_INTERFACE (SALUT_TYPE_SVC_CHANNEL_TYPE_FILE_TRANSFER,
+    G_IMPLEMENT_INTERFACE (SALUT_TYPE_SVC_CHANNEL_TYPE_FILE,
                            file_transfer_iface_init);
 );
 
@@ -136,7 +135,7 @@ salut_ft_channel_get_property (GObject    *object,
         g_value_set_string (value, self->priv->object_path);
         break;
       case PROP_CHANNEL_TYPE:
-        g_value_set_static_string (value, TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER);
+        g_value_set_static_string (value, SALUT_IFACE_CHANNEL_TYPE_FILE);
         break;
       case PROP_HANDLE_TYPE:
         g_value_set_uint (value, TP_HANDLE_TYPE_CONTACT);
@@ -192,7 +191,7 @@ salut_ft_channel_set_property (GObject *object,
         tmp = g_value_get_string (value);
         g_assert (tmp == NULL
                   || !tp_strdiff (g_value_get_string (value),
-                         TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER));
+                         SALUT_IFACE_CHANNEL_TYPE_FILE));
         break;
       case PROP_XMPP_CONNECTION_MANAGER:
         self->priv->xmpp_connection_manager = g_value_get_object (value);
@@ -248,9 +247,6 @@ static void
 salut_ft_channel_dispose (GObject *object);
 static void
 salut_ft_channel_finalize (GObject *object);
-static gboolean
-do_close_file_transfer (SalutFtChannel *self, guint id,
-    SalutFileTransferCloseReason reason, GError **error);
 
 static void
 salut_ft_channel_class_init (SalutFtChannelClass *salut_ft_channel_class)
@@ -398,7 +394,7 @@ salut_ft_channel_get_channel_type (TpSvcChannel *iface,
                                    DBusGMethodInvocation *context)
 {
   tp_svc_channel_return_from_get_channel_type (context,
-      TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER);
+      SALUT_IFACE_CHANNEL_TYPE_FILE);
 }
 
 /**
@@ -474,26 +470,12 @@ error_cb (GibberFileTransfer *ft,
           const gchar *message,
           SalutFtChannel *self)
 {
-  guint id;
-  guint reason;
-
-  if (code == GIBBER_FILE_TRANSFER_ERROR_NOT_ACCEPTABLE)
-    reason = SALUT_FILETRANSFER_CLOSEREASON_REMOTESTOPPED;
-  else
-    reason = SALUT_FILETRANSFER_CLOSEREASON_REMOTEERROR;
-
-  id = GPOINTER_TO_INT (g_hash_table_lookup (self->priv->name_to_id, ft->id));
-  do_close_file_transfer (self, id, reason, NULL);
 }
 
 static void
 ft_finished_cb (GibberFileTransfer *ft,
                 SalutFtChannel *self)
 {
-  guint id;
-
-  id = GPOINTER_TO_INT (g_hash_table_lookup (self->priv->name_to_id, ft->id));
-  do_close_file_transfer (self, id, SALUT_FILETRANSFER_CLOSEREASON_SUCCESS, NULL);
 }
 
 static void
@@ -527,8 +509,6 @@ send_file_offer (SalutFtChannel *self,
         &val, NULL))
     {
       DEBUG ("Invalid transfer id %u", id);
-      do_close_file_transfer (self, id,
-          SALUT_FILETRANSFER_CLOSEREASON_LOCALERROR, NULL);
       return;
     }
   val_array = g_value_get_boxed (val);
@@ -557,8 +537,6 @@ send_file_offer (SalutFtChannel *self,
     ft->size = g_value_get_uint64 (val);
 
   gibber_file_transfer_offer (ft);
-
-  tp_file_transfer_mixin_emit_new_file_transfer (G_OBJECT (self), id, NULL);
 }
 
 /* passed as user_data to the callbacl for the "new-connection" signal
@@ -592,79 +570,6 @@ value_free (GValue *value)
   g_free (value);
 }
 
-static gboolean
-dup_hash_table_cb (gpointer key,
-                   gpointer value,
-                   gpointer user_data)
-{
-  GHashTable *dest = user_data;
-
-  g_hash_table_insert (dest, key, value);
-  return TRUE;
-}
-
-/**
- * salut_ft_channel_offer_file
- *
- * Implements DBus method OfferFile
- * on interface org.freedesktop.Telepathy.Channel.Type.FileTransfer
- */
-static void
-salut_ft_channel_offer_file (SalutSvcChannelTypeFileTransfer *channel,
-                             const gchar *filename,
-                             GHashTable *information,
-                             DBusGMethodInvocation *context)
-{
-  SalutFtChannel *self = SALUT_FT_CHANNEL (channel);
-  TpBaseConnection *base_connection =
-      TP_BASE_CONNECTION (self->priv->connection);
-  GHashTable *information_dup;
-  guint id;
-  GibberXmppConnection *connection = NULL;
-  SalutXmppConnectionManagerRequestConnectionResult request_result;
-  GError *error = NULL;
-
-  /* FIXME dbus calls g_hash_table_destroy() instead of g_hash_table_unref()
-   * so we have to copy the hash table, see freedesktop bug #11396
-   * (https://bugs.freedesktop.org/show_bug.cgi?id=11396) */
-  information_dup = g_hash_table_new_full (g_str_hash, g_str_equal,
-      (GDestroyNotify) g_free, (GDestroyNotify) value_free);
-  g_hash_table_foreach_steal (information, dup_hash_table_cb, information_dup);
-
-  id = tp_file_transfer_mixin_add_transfer (G_OBJECT (channel),
-      base_connection->self_handle, TP_FILE_TRANSFER_DIRECTION_OUTGOING,
-      TP_FILE_TRANSFER_STATE_REMOTE_PENDING, filename, information_dup, NULL);
-
-  request_result = salut_xmpp_connection_manager_request_connection (
-      self->priv->xmpp_connection_manager, self->priv->contact, &connection,
-      &error);
-
-  if (request_result ==
-      SALUT_XMPP_CONNECTION_MANAGER_REQUEST_CONNECTION_RESULT_DONE)
-    {
-      self->priv->xmpp_connection = connection;
-      send_file_offer (self, id);
-    }
-  else if (request_result ==
-           SALUT_XMPP_CONNECTION_MANAGER_REQUEST_CONNECTION_RESULT_PENDING)
-    {
-      NewConnectionData *data = g_new0 (NewConnectionData, 1);
-      data->self = self;
-      data->id = id;
-      g_signal_connect (self->priv->xmpp_connection_manager, "new-connection",
-          G_CALLBACK (xmpp_connection_manager_new_connection_cb), data);
-    }
-  else
-    {
-      DEBUG ("Request connection failed");
-      dbus_g_method_return_error (context, error);
-      g_error_free (error);
-      return;
-    }
-
-  salut_svc_channel_type_file_transfer_return_from_offer_file (context, id);
-}
-
 void
 salut_ft_channel_received_file_offer (SalutFtChannel *self,
                                       GibberXmppStanza *stanza,
@@ -693,24 +598,23 @@ salut_ft_channel_received_file_offer (SalutFtChannel *self,
 
   g_hash_table_insert (self->priv->name_to_id, (gchar *) ft->id,
       GINT_TO_POINTER (id));
-
-  tp_file_transfer_mixin_emit_new_file_transfer (G_OBJECT (self), id, NULL);
 }
 
 /**
  * salut_ft_channel_accept_file
  *
  * Implements D-Bus method AcceptFile
- * on interface org.freedesktop.Telepathy.Channel.Type.FileTransfer
+ * on interface org.freedesktop.Telepathy.Channel.Type.File
  */
 static void
-salut_ft_channel_accept_file (SalutSvcChannelTypeFileTransfer *iface,
+salut_ft_channel_accept_file (SalutSvcChannelTypeFile *iface,
                               guint id,
                               DBusGMethodInvocation *context)
 {
   SalutFtChannel *self = SALUT_FT_CHANNEL (iface);
   GibberFileTransfer *ft;
   GError *error = NULL;
+  GValue *out_address = { 0 };
 
   ft = get_file_transfer (self, id, &error);
   if (ft == NULL)
@@ -731,87 +635,21 @@ salut_ft_channel_accept_file (SalutSvcChannelTypeFileTransfer *iface,
       return;
     }
 
-  salut_svc_channel_type_file_transfer_return_from_accept_file (context);
-}
-
-/**
- * salut_ft_channel_close_file_transfer
- *
- * Implements D-Bus method CloseFileTransfer
- * on interface org.freedesktop.Telepathy.Channel.Type.FileTransfer
- */
-static void
-salut_ft_channel_close_file_transfer (SalutSvcChannelTypeFileTransfer *iface,
-                                      guint id,
-                                      SalutFileTransferCloseReason reason,
-                                      DBusGMethodInvocation *context)
-{
-  SalutFtChannel *self = SALUT_FT_CHANNEL (iface);
-  GibberFileTransfer *ft;
-  GError *error = NULL;
-
-  ft = get_file_transfer (self, id, &error);
-  if (ft == NULL)
-    {
-      dbus_g_method_return_error (context, error);
-      g_error_free (error);
-    }
-
-  gibber_file_transfer_cancel (ft, 406);
-
-  /* FIXME use the reason argument when added to the file transfer spec
-   * and check that the passed in argument is not
-   * SALUT_FILETRANSFER_CLOSEREASON_SUCCESS or REMOTEERROR/REMOTESTOPPED as
-   * it doesn't make sense. */
-  if (do_close_file_transfer (self, id,
-        SALUT_FILETRANSFER_CLOSEREASON_LOCALSTOPPED, &error))
-    {
-      salut_svc_channel_type_file_transfer_return_from_close_file_transfer (
-          context);
-    }
-  else
-    {
-      dbus_g_method_return_error (context, error);
-      g_error_free (error);
-    }
-}
-
-static gboolean
-do_close_file_transfer (SalutFtChannel *self,
-                        guint id,
-                        SalutFileTransferCloseReason reason,
-                        GError **error)
-{
-  /* reason is not used at the moment */
-  GibberFileTransfer *ft;
-
-  ft = get_file_transfer (self, id, error);
-  if (ft == NULL)
-    return FALSE;
-
-  g_hash_table_remove (self->priv->name_to_id, ft->id);
-  g_object_unref (ft);
-
-  DEBUG ("Closing file transfer %u with reason %d", id, reason);
+  g_value_init (out_address, G_TYPE_STRING);
 
-  return tp_file_transfer_mixin_close_file_transfer (G_OBJECT (self), id,
-      reason, error);
+  salut_svc_channel_type_file_return_from_accept_file (context, out_address);
 }
 
 static void
 file_transfer_iface_init (gpointer g_iface,
                           gpointer iface_data)
 {
-  SalutSvcChannelTypeFileTransferClass *klass =
-      (SalutSvcChannelTypeFileTransferClass *)g_iface;
+  SalutSvcChannelTypeFileClass *klass =
+      (SalutSvcChannelTypeFileClass *)g_iface;
 
   tp_file_transfer_mixin_iface_init (g_iface, iface_data);
-#define IMPLEMENT(x) salut_svc_channel_type_file_transfer_implement_##x (\
-    klass, salut_ft_channel_##x)
-  IMPLEMENT (offer_file);
-  IMPLEMENT (accept_file);
-  IMPLEMENT (close_file_transfer);
-#undef IMPLEMENT
+  salut_svc_channel_type_file_implement_accept_file (klass,
+        (salut_svc_channel_type_file_accept_file_impl) salut_ft_channel_accept_file);
 }
 
 
@@ -936,8 +774,6 @@ setup_local_socket (SalutFtChannel *self, guint id)
   io_channel = get_socket_channel (self, id);
   if (io_channel == NULL)
     {
-      do_close_file_transfer (self, id,
-          SALUT_FILETRANSFER_CLOSEREASON_LOCALERROR, NULL);
       return FALSE;
     }
 
-- 
1.5.6.5




More information about the Telepathy-commits mailing list