[telepathy-gabble/telepathy-gabble-0.8] Add a compile-time switch (on by default) for assuming file transfer to be supported

Simon McVittie simon.mcvittie at collabora.co.uk
Wed Dec 2 04:50:52 PST 2009


This is a stable branch, so we shouldn't break clients that assume that
file transfer is always-on, even though they're wrong. Distributions
can disable this assumption once they've verified that they don't ship
any clients that rely on it.
---
 configure.ac                 |   10 ++++++++++
 src/capabilities.c           |    9 +++++++++
 src/ft-manager.c             |   11 +++++++++++
 tests/twisted/Makefile.am    |    7 +++++++
 tests/twisted/caps_helper.py |   10 +++++++++-
 5 files changed, 46 insertions(+), 1 deletions(-)

diff --git a/configure.ac b/configure.ac
index f3a5f5d..d0c4931 100644
--- a/configure.ac
+++ b/configure.ac
@@ -106,6 +106,16 @@ if test x$enable_handle_leak_debug = xyes; then
   HANDLE_LEAK_DEBUG_CFLAGS="-rdynamic"
 fi
 
+enable_assumed_ft_cap=yes
+AC_ARG_ENABLE([assumed-ft-cap],
+  AC_HELP_STRING([--disable-assumed-ft-cap],
+    [do not assume that we have a client capable of receiving file transfers]),
+    [enable_assumed_ft_cap="$enableval"], [])
+if test "x$enable_assumed_ft_cap" = xyes; then
+  AC_DEFINE(ENABLE_ASSUMED_FT_CAP, [], [--enable-assumed-ft-cap])
+fi
+AM_CONDITIONAL([ENABLE_ASSUMED_FT_CAP], [test "x$enable_assumed_ft_cap" = xyes])
+
 AC_SUBST(HANDLE_LEAK_DEBUG_CFLAGS)
 
 AC_SUBST([ENABLE_CODING_STYLE_CHECKS])
diff --git a/src/capabilities.c b/src/capabilities.c
index a509972..78c5760 100644
--- a/src/capabilities.c
+++ b/src/capabilities.c
@@ -51,7 +51,16 @@ static const Feature self_advertised_features[] =
   { FEATURE_FIXED, NS_IBB, PRESENCE_CAP_IBB},
   { FEATURE_FIXED, NS_TUBES, PRESENCE_CAP_SI_TUBES},
   { FEATURE_FIXED, NS_BYTESTREAMS, PRESENCE_CAP_BYTESTREAMS},
+
+#ifdef ENABLE_ASSUMED_FT_CAP
+  /* For backwards compatibility, the default behaviour of the stable
+   * branch is to say that we can receive file transfers, even if no
+   * client seems to be able to. Disable with
+   * ./configure --disable-assumed-ft-cap */
+  { FEATURE_FIXED, NS_FILE_TRANSFER, PRESENCE_CAP_SI_FILE_TRANSFER},
+#else
   { FEATURE_OPTIONAL, NS_FILE_TRANSFER, PRESENCE_CAP_SI_FILE_TRANSFER},
+#endif
 
   { FEATURE_BUNDLE_COMPAT, NS_GOOGLE_FEAT_VOICE, PRESENCE_CAP_GOOGLE_VOICE},
   { FEATURE_OPTIONAL, NS_GOOGLE_FEAT_VIDEO, PRESENCE_CAP_GOOGLE_VIDEO },
diff --git a/src/ft-manager.c b/src/ft-manager.c
index f8473af..8c8d9de 100644
--- a/src/ft-manager.c
+++ b/src/ft-manager.c
@@ -18,6 +18,8 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include <config.h>
+
 #define _BSD_SOURCE
 #define _XOPEN_SOURCE /* glibc2 needs this */
 #include <time.h>
@@ -657,7 +659,16 @@ gabble_ft_manager_get_contact_caps (GabbleCapsChannelManager *manager,
 
   if (handle == base->self_handle)
     {
+#ifdef ENABLE_ASSUMED_FT_CAP
+      /* For backwards compatibility, the default behaviour of the stable
+       * branch is to say that we can receive file transfers, even if no
+       * client seems to be able to. Disable with
+       * ./configure --disable-assumed-ft-cap */
+      add_file_transfer_channel_class (arr, handle);
+      return;
+#else
       presence = conn->self_presence;
+#endif
     }
   else
     {
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index e50cdc1..5a2dca8 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -182,10 +182,17 @@ else
 DEBUGGING_PYBOOL = False
 endif
 
+if ENABLE_ASSUMED_FT_CAP
+ENABLE_ASSUMED_FT_CAP_PYBOOL = True
+else
+ENABLE_ASSUMED_FT_CAP_PYBOOL = False
+endif
+
 config.py: Makefile
 	$(QUIET_GEN) { \
 		echo "PACKAGE_STRING = \"$(PACKAGE_STRING)\""; \
 		echo "DEBUGGING = $(DEBUGGING_PYBOOL)"; \
+		echo "ENABLE_ASSUMED_FT_CAP = $(ENABLE_ASSUMED_FT_CAP_PYBOOL)"; \
 	} > $@
 
 BUILT_SOURCES = config.py
diff --git a/tests/twisted/caps_helper.py b/tests/twisted/caps_helper.py
index e208410..7c1c16c 100644
--- a/tests/twisted/caps_helper.py
+++ b/tests/twisted/caps_helper.py
@@ -8,7 +8,7 @@ from gabbletest import make_result_iq, make_presence
 from servicetest import EventPattern, assertEquals, assertContains, \
         assertDoesNotContain
 
-from config import PACKAGE_STRING
+from config import PACKAGE_STRING, ENABLE_ASSUMED_FT_CAP
 import ns
 import constants as cs
 
@@ -59,6 +59,14 @@ VARIABLE_CAPS = (
     ns.TUBES + '/dbus#com.example.Xiangqi',
     ])
 
+if ENABLE_ASSUMED_FT_CAP:
+    # For backwards compatibility, the default behaviour of the stable
+    # branch is to say that we can receive file transfers, even if no
+    # client seems to be able to. Disable with
+    # ./configure --disable-assumed-ft-cap */
+    VARIABLE_CAPS.remove(ns.FILE_TRANSFER)
+    FIXED_CAPS.append(ns.FILE_TRANSFER)
+
 def check_caps(namespaces, desired):
     """Assert that all the FIXED_CAPS are supported, and of the VARIABLE_CAPS,
     every capability in desired is supported, and every other capability is
-- 
1.5.6.5




More information about the telepathy-commits mailing list