[telepathy-qt4/master] Added TelepathyQt4Farsight tiny library.

Andre Moreira Magalhaes (andrunko) andre.magalhaes at collabora.co.uk
Tue Apr 21 09:37:20 PDT 2009


The library is a convenience library to create a Telepathy Farsight Channel
given a TelepathyQt4 StreamedMediaChannel.
---
 TelepathyQt4/Farsight/Channel                    |   13 ++++
 TelepathyQt4/Farsight/Makefile.am                |   33 +++++++++
 TelepathyQt4/Farsight/TelepathyQt4Farsight.pc.in |   11 +++
 TelepathyQt4/Farsight/channel.cpp                |   81 ++++++++++++++++++++++
 TelepathyQt4/Farsight/channel.h                  |   40 +++++++++++
 TelepathyQt4/Makefile.am                         |    5 ++
 configure.ac                                     |    4 +-
 examples/Makefile.am                             |    3 +-
 8 files changed, 188 insertions(+), 2 deletions(-)
 create mode 100644 TelepathyQt4/Farsight/Channel
 create mode 100644 TelepathyQt4/Farsight/Makefile.am
 create mode 100644 TelepathyQt4/Farsight/TelepathyQt4Farsight.pc.in
 create mode 100644 TelepathyQt4/Farsight/channel.cpp
 create mode 100644 TelepathyQt4/Farsight/channel.h

diff --git a/TelepathyQt4/Farsight/Channel b/TelepathyQt4/Farsight/Channel
new file mode 100644
index 0000000..aa4c93e
--- /dev/null
+++ b/TelepathyQt4/Farsight/Channel
@@ -0,0 +1,13 @@
+#ifndef _TelepathyQt4_Farsight_Channel_HEADER_GUARD_
+#define _TelepathyQt4_Farsight_Channel_HEADER_GUARD_
+
+#ifndef IN_TELEPATHY_QT4_HEADER
+#define IN_TELEPATHY_QT4_HEADER
+#endif
+
+#include <TelepathyQt4/Farsight/channel.h>
+
+#undef IN_TELEPATHY_QT4_HEADER
+
+#endif
+// vim:set ft=cpp:
diff --git a/TelepathyQt4/Farsight/Makefile.am b/TelepathyQt4/Farsight/Makefile.am
new file mode 100644
index 0000000..95fe3dd
--- /dev/null
+++ b/TelepathyQt4/Farsight/Makefile.am
@@ -0,0 +1,33 @@
+AM_CPPFLAGS = \
+	-I$(top_srcdir) \
+	-I$(top_builddir) \
+	$(QTCORE_CFLAGS) \
+	$(QTDBUS_CFLAGS) \
+	$(TP_GLIB_CFLAGS) \
+	$(TP_FARSIGHT_CFLAGS) \
+	$(TP_QT4_CFLAGS)
+
+lib_LTLIBRARIES = libtelepathy-qt4-farsight.la
+
+# The quoting here is unnecessary but harmless, and has the useful side-effect
+# that vim quickfix mode (:make) doesn't interpret the libtool --mode=link
+# command as an error message in a bizarrely named file
+libtelepathy_qt4_farsight_la_LDFLAGS = \
+    -version-info "$(LT_CURRENT)":"$(LT_REVISION)":"$(LT_AGE)" -static
+libtelepathy_qt4_farsight_la_LIBADD = \
+	$(QTCORE_LIBS) \
+	$(QTDBUS_LIBS) \
+	$(TP_GLIB_LIBS) \
+	$(TP_FARSIGHT_LIBS) \
+	$(top_builddir)/TelepathyQt4/libtelepathy-qt4.la
+
+libtelepathy_qt4_farsight_la_DEPENDENCIES = Makefile.am
+
+libtelepathy_qt4_farsight_la_SOURCES = \
+    channel.cpp
+
+tpqt4farsightincludedir = \
+    $(includedir)/telepathy-1.0/TelepathyQt4/Farsight
+tpqt4farsightinclude_HEADERS = \
+    Channel \
+    channel.h
diff --git a/TelepathyQt4/Farsight/TelepathyQt4Farsight.pc.in b/TelepathyQt4/Farsight/TelepathyQt4Farsight.pc.in
new file mode 100644
index 0000000..392b95d
--- /dev/null
+++ b/TelepathyQt4/Farsight/TelepathyQt4Farsight.pc.in
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: Telepathy-Qt4-Farsight
+Description: Qt4 Telepathy Farsight utility library for the Telepathy framework
+Version: @VERSION@
+Requires.private: QtCore >= 4.5, QtDBus >= 4.5, TelepathyQt4
+Libs: -L${libdir} -ltelepathy-qt4-farsight
+Cflags: -I${includedir}/telepathy-1.0
diff --git a/TelepathyQt4/Farsight/channel.cpp b/TelepathyQt4/Farsight/channel.cpp
new file mode 100644
index 0000000..5772c98
--- /dev/null
+++ b/TelepathyQt4/Farsight/channel.cpp
@@ -0,0 +1,81 @@
+/*
+ * This file is part of TelepathyQt4
+ *
+ * Copyright © 2009 Collabora Ltd. <http://www.collabora.co.uk/>
+ * Copyright © 2009 Nokia Corporation
+ *
+ * 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
+ * Lesser 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 St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <TelepathyQt4/Farsight/Channel>
+
+#include "TelepathyQt4/debug-internal.h"
+
+#include <TelepathyQt4/Channel>
+#include <TelepathyQt4/Connection>
+#include <TelepathyQt4/StreamedMediaChannel>
+
+#include <telepathy-glib/channel.h>
+#include <telepathy-glib/connection.h>
+#include <telepathy-glib/dbus.h>
+
+namespace Tp
+{
+
+TfChannel *tfChannelCreate(const StreamedMediaChannelPtr &channel)
+{
+    TpDBusDaemon *dbus = tp_dbus_daemon_dup(0);
+
+    if (!dbus) {
+        warning() << "Unable to connect to D-Bus";
+        return 0;
+    }
+
+    ConnectionPtr connection = channel->connection();
+
+    TpConnection *gconnection = tp_connection_new(dbus,
+            connection->busName().toAscii(),
+            connection->objectPath().toAscii(),
+            0);
+    g_object_unref(dbus);
+    dbus = 0;
+
+    if (!gconnection) {
+        warning() << "Unable to construct TpConnection";
+        return 0;
+    }
+
+    TpChannel *gchannel = tp_channel_new(gconnection,
+            channel->objectPath().toAscii(),
+            TELEPATHY_INTERFACE_CHANNEL_TYPE_STREAMED_MEDIA,
+            (TpHandleType) channel->targetHandleType(),
+            channel->targetHandle(),
+            0);
+    g_object_unref(gconnection);
+    gconnection = 0;
+
+    if (!gchannel) {
+        warning() << "Unable to construct TpChannel";
+        return 0;
+    }
+
+    TfChannel *ret = tf_channel_new(gchannel);
+    g_object_unref(gchannel);
+    gchannel = 0;
+
+    return ret;
+}
+
+} // Tp
diff --git a/TelepathyQt4/Farsight/channel.h b/TelepathyQt4/Farsight/channel.h
new file mode 100644
index 0000000..61ce400
--- /dev/null
+++ b/TelepathyQt4/Farsight/channel.h
@@ -0,0 +1,40 @@
+/*
+ * This file is part of TelepathyQt4
+ *
+ * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
+ * Copyright (C) 2009 Nokia Corporation
+ *
+ * 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
+ * Lesser 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 St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef _TelepathyQt4_Farsight_channel_h_HEADER_GUARD_
+#define _TelepathyQt4_Farsight_channel_h_HEADER_GUARD_
+
+#ifndef IN_TELEPATHY_QT4_HEADER
+#error IN_TELEPATHY_QT4_HEADER
+#endif
+
+#include <TelepathyQt4/Types>
+
+#include <telepathy-farsight/channel.h>
+
+namespace Tp
+{
+
+TfChannel *tfChannelCreate(const StreamedMediaChannelPtr &channel);
+
+} // Tp
+
+#endif
diff --git a/TelepathyQt4/Makefile.am b/TelepathyQt4/Makefile.am
index d12c412..32f587e 100644
--- a/TelepathyQt4/Makefile.am
+++ b/TelepathyQt4/Makefile.am
@@ -1,6 +1,11 @@
 # We need to build this directory before the Prototype subdirectory
+DIST_SUBDIRS = Prototype Farsight
 SUBDIRS = . Prototype
 
+if ENABLE_TP_FARSIGHT
+SUBDIRS += Farsight
+endif
+
 tpqt4includedir=$(includedir)/telepathy-1.0/TelepathyQt4
 genincludedir=$(tpqt4includedir)/_gen
 
diff --git a/configure.ac b/configure.ac
index ba212a5..d01e2e9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -209,7 +209,7 @@ AC_SUBST(TP_FARSIGHT_LIBS)
 if test no = "$have_tp_fs"; then
   AC_MSG_WARN([telepathy-farsight not found: not all examples will be built])
 fi
-AM_CONDITIONAL([ENABLE_TP_FARSIGHT_EXAMPLES],
+AM_CONDITIONAL([ENABLE_TP_FARSIGHT],
   [test yes = "$have_tp_glib" && test yes = "$have_tp_fs" &&
    test yes = "$have_qt_glib_main_loop"])
 
@@ -249,6 +249,8 @@ DX_INIT_DOXYGEN(TelepathyQt4, doxygen.cfg, doc)
 AC_OUTPUT([
     Makefile
     TelepathyQt4/Makefile
+    TelepathyQt4/Farsight/Makefile
+    TelepathyQt4/Farsight/TelepathyQt4Farsight.pc
     TelepathyQt4/Prototype/Makefile
     TelepathyQt4/Prototype/TpQt4Prototype.pc
     TelepathyQt4/TelepathyQt4.pc
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 4dadcf2..27b621a 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -1,5 +1,6 @@
+DIST_SUBDIRS = extensions accounts roster call
 SUBDIRS = extensions accounts roster
 
-if ENABLE_TP_FARSIGHT_EXAMPLES
+if ENABLE_TP_FARSIGHT
 SUBDIRS += call
 endif
-- 
1.5.6.5




More information about the telepathy-commits mailing list