[Telepathy-commits] [telepathy-qt4/master] Add the beginnings of a call example using telepathy-farsight

Simon McVittie simon.mcvittie at collabora.co.uk
Mon Mar 9 07:29:51 PDT 2009


---
 configure.ac                    |   16 ++++++++-
 examples/Makefile.am            |    4 ++
 examples/call/Makefile.am       |   32 ++++++++++++++++
 examples/call/farsight-glue.cpp |   75 +++++++++++++++++++++++++++++++++++++++
 examples/call/farsight-glue.h   |   37 +++++++++++++++++++
 examples/call/main.cpp          |    5 +++
 6 files changed, 168 insertions(+), 1 deletions(-)
 create mode 100644 examples/call/Makefile.am
 create mode 100644 examples/call/farsight-glue.cpp
 create mode 100644 examples/call/farsight-glue.h
 create mode 100644 examples/call/main.cpp

diff --git a/configure.ac b/configure.ac
index f9dd045..254ce40 100644
--- a/configure.ac
+++ b/configure.ac
@@ -199,6 +199,19 @@ fi
 AM_CONDITIONAL([ENABLE_TP_GLIB_TESTS],
   [test yes = "$have_tp_glib" && test yes = "$have_qt_glib_main_loop"])
 
+dnl Check for telepathy-farsight... if we have that too, we can build an
+dnl audio/video calling example
+PKG_CHECK_MODULES(TP_FARSIGHT, [telepathy-farsight >= 0.0.4], [have_tp_fs=yes],
+                  [have_tp_fs=no])
+AC_SUBST(TP_FARSIGHT_CFLAGS)
+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],
+  [test yes = "$have_tp_glib" && test yes = "$have_tp_fs" &&
+   test yes = "$have_qt_glib_main_loop"])
+
 AC_PATH_PROGS([PINOCCHIO], [telepathy-pinocchio], [none],
   [$PATH:/usr/local/libexec:/usr/libexec:/usr/lib/telepathy])
 AC_PATH_PROGS([PINOCCHIO_CTL], [pinocchio-ctl], [none])
@@ -240,8 +253,9 @@ AC_OUTPUT([
     TelepathyQt4/TelepathyQt4.pc
     doxygen.cfg
     examples/Makefile
-    examples/extensions/Makefile
     examples/accounts/Makefile
+    examples/call/Makefile
+    examples/extensions/Makefile
     examples/roster/Makefile
     m4/Makefile
     spec/Makefile
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 4523c79..4dadcf2 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -1 +1,5 @@
 SUBDIRS = extensions accounts roster
+
+if ENABLE_TP_FARSIGHT_EXAMPLES
+SUBDIRS += call
+endif
diff --git a/examples/call/Makefile.am b/examples/call/Makefile.am
new file mode 100644
index 0000000..4593521
--- /dev/null
+++ b/examples/call/Makefile.am
@@ -0,0 +1,32 @@
+AM_CXXFLAGS = \
+	$(ERROR_CXXFLAGS) \
+	$(QTCORE_CFLAGS) \
+	$(QTGUI_CFLAGS) \
+	$(QTDBUS_CFLAGS) \
+	$(TP_FARSIGHT_CFLAGS) \
+	$(TP_QT4_CFLAGS)
+
+noinst_PROGRAMS = call
+
+call_LDADD = \
+	$(QTGUI_LIBS) \
+	$(QTDBUS_LIBS) \
+	$(TP_FARSIGHT_LIBS) \
+	$(top_builddir)/TelepathyQt4/libtelepathy-qt4.la
+
+call_SOURCES = \
+	main.cpp \
+	farsight-glue.cpp \
+	farsight-glue.h
+
+nodist_call_SOURCES =
+
+BUILT_SOURCES = \
+	$(nodist_call_SOURCES)
+
+CLEANFILES = \
+	$(BUILT_SOURCES)
+
+_gen/%.moc.hpp: %.h
+	$(mkdir_p) _gen
+	$(MOC) @QTCORE_CFLAGS@ @QTDBUS_CFLAGS@ @TP_FARSIGHT_CFLAGS@ -I$(top_builddir) -I$(top_srcdir) -i $< -o $@
diff --git a/examples/call/farsight-glue.cpp b/examples/call/farsight-glue.cpp
new file mode 100644
index 0000000..00266e5
--- /dev/null
+++ b/examples/call/farsight-glue.cpp
@@ -0,0 +1,75 @@
+/*
+ * Very basic Telepathy-Qt <-> Telepathy-Farsight integration.
+ *
+ * Copyright (C) 2008-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
+ */
+
+#include "farsight-glue.h"
+
+#include <QDebug>
+
+#include <telepathy-farsight/channel.h>
+#include <telepathy-glib/channel.h>
+#include <telepathy-glib/connection.h>
+#include <telepathy-glib/dbus.h>
+#include <TelepathyQt4/Client/Connection>
+#include <TelepathyQt4/Client/StreamedMediaChannel>
+
+TfChannel *tfChannelFromQt(const Telepathy::Client::Connection *connection,
+        const Telepathy::Client::StreamedMediaChannel *channel)
+{
+    TpDBusDaemon *dbus = tp_dbus_daemon_dup(0);
+    if (!dbus) {
+        qWarning() << "Unable to connect to D-Bus";
+        return 0;
+    }
+
+    TpConnection *gconnection = tp_connection_new(dbus,
+            connection->busName().toAscii(),
+            connection->objectPath().toAscii(),
+            0);
+    g_object_unref(dbus);
+    dbus = 0;
+
+    if (!gconnection) {
+        qWarning() << "Unable to construct TpConnection";
+        return 0;
+    }
+
+    TpChannel *gchannel = tp_channel_new(gconnection,
+            channel->objectPath().toAscii(),
+            TELEPATHY_INTERFACE_CHANNEL_TYPE_STREAMED_MEDIA,
+            TP_UNKNOWN_HANDLE_TYPE, 0, 0);
+    g_object_unref(gconnection);
+    gconnection = 0;
+
+    if (!gchannel) {
+        qWarning() << "Unable to construct TpChannel";
+        return 0;
+    }
+
+    TfChannel *ret = tf_channel_new(gchannel);
+    g_object_unref(gchannel);
+    gchannel = 0;
+
+    if (!ret) {
+        qWarning() << "Unable to construct TfChannel";
+        return 0;
+    }
+    return ret;
+}
diff --git a/examples/call/farsight-glue.h b/examples/call/farsight-glue.h
new file mode 100644
index 0000000..83dc9c6
--- /dev/null
+++ b/examples/call/farsight-glue.h
@@ -0,0 +1,37 @@
+/*
+ * Very basic Telepathy-Qt <-> Telepathy-Farsight integration.
+ *
+ * Copyright (C) 2008-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_examples_call_farsight_h_HEADER_GUARD_
+#define _TelepathyQt4_examples_call_farsight_h_HEADER_GUARD_
+
+#include <telepathy-farsight/channel.h>
+
+namespace Telepathy {
+namespace Client {
+    class Connection;
+    class StreamedMediaChannel;
+} // Client
+} // Telepathy
+
+TfChannel *tfChannelFromQt(const Telepathy::Client::Connection *connection,
+        const Telepathy::Client::StreamedMediaChannel *channel);
+
+#endif
diff --git a/examples/call/main.cpp b/examples/call/main.cpp
new file mode 100644
index 0000000..9877b12
--- /dev/null
+++ b/examples/call/main.cpp
@@ -0,0 +1,5 @@
+int main(int argc, char **argv)
+{
+    // nothing here yet
+    return 0;
+}
-- 
1.5.6.5




More information about the telepathy-commits mailing list