[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/network/kcall
From:       George Kiagiadakis <gkiagiad () csd ! uoc ! gr>
Date:       2009-06-18 9:50:44
Message-ID: 1245318644.829435.12139.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 983413 by gkiagia:

Remove the callwindow kpart and merge all its functionality in kcall_handler.

 M  +0 -1      CMakeLists.txt  
 D             callwindowpart/CMakeLists.txt  
 D             callwindowpart/abstractmediahandler.cpp  
 D             callwindowpart/abstractmediahandler.h  
 D             callwindowpart/callwindowpart.cpp  
 D             callwindowpart/callwindowpart.h  
 D             callwindowpart/callwindowpart_p.cpp  
 D             callwindowpart/callwindowpart_p.h  
 D             callwindowpart/farsight/mediadevices.cpp  
 D             callwindowpart/farsight/mediadevices.h  
 D             callwindowpart/farsight/mediahandler.cpp  
 D             callwindowpart/farsight/mediahandler.h  
 D             callwindowpart/kcall_callwindowpart.desktop  
 M  +76 -15    kcall_handler/CMakeLists.txt  
 A             kcall_handler/abstractmediahandler.cpp   \
callwindowpart/abstractmediahandler.cpp#983412 [License: LGPL (v2.1+)]  A             \
kcall_handler/abstractmediahandler.h   callwindowpart/abstractmediahandler.h#983412 \
[License: LGPL (v2.1+)]  M  +65 -49    kcall_handler/callwindow.cpp  
 M  +7 -4      kcall_handler/callwindow.h  
 A             kcall_handler/channelhandler.cpp   \
callwindowpart/callwindowpart_p.cpp#983412 [License: GPL (v2+)]  A             \
kcall_handler/channelhandler.h   callwindowpart/callwindowpart_p.h#983412 [License: \
GPL (v2+)]  A             kcall_handler/farsight (directory)  
 A             kcall_handler/farsight/mediadevices.cpp   \
callwindowpart/farsight/mediadevices.cpp#983412 [License: LGPL (v2.1+)]  A            \
kcall_handler/farsight/mediadevices.h   callwindowpart/farsight/mediadevices.h#983412 \
[License: LGPL (v2.1+)]  A             kcall_handler/farsight/mediahandler.cpp   \
callwindowpart/farsight/mediahandler.cpp#983412 [License: LGPL (v2.1+)]  A            \
kcall_handler/farsight/mediahandler.h   callwindowpart/farsight/mediahandler.h#983412 \
[License: LGPL (v2.1+)]


--- trunk/playground/network/kcall/CMakeLists.txt #983412:983413
@@ -11,7 +11,6 @@
 add_definitions(${KDE4_DEFINITIONS})
 
 add_subdirectory(kcall_handler)
-add_subdirectory(callwindowpart)
 
 set(kcall_SRCS
     main.cpp
--- trunk/playground/network/kcall/kcall_handler/CMakeLists.txt #983412:983413
@@ -1,21 +1,82 @@
+macro_optional_find_package(GStreamer)
+macro_log_feature(GSTREAMER_FOUND "GStreamer" "gstreamer 0.10 is required for kcall"
+                                    "http://gstreamer.freedesktop.org/modules/" \
FALSE "0.10")  
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
+macro_optional_find_package(GObject)
+macro_optional_find_package(GLIB2)
+macro_log_feature(GOBJECT_FOUND "GObject" "GObject is required for kcall"
+                                "http://www.gtk.org/download/" FALSE)
 
-set(kcall_handler_SRCS
-    main.cpp
-    callwindow.cpp
-    callhandler.cpp
-)
+macro_optional_find_package(TpFarsight)
+macro_log_feature(TPFARSIGHT_FOUND "telepathy-farsight" "telepathy-farsight is \
required for kcall" +                        \
"http://telepathy.freedesktop.org/releases/telepathy-farsight/" FALSE "0.0.4")  
-configure_file(org.freedesktop.Telepathy.Client.kcall_handler.service.in
-               org.freedesktop.Telepathy.Client.kcall_handler.service)
 
-kde4_add_executable(kcall_handler ${kcall_handler_SRCS})
-target_link_libraries(kcall_handler ${KDE4_KPARTS_LIBS} ${TELEPATHY_QT4_LIBRARIES})
+# dbus-glib and libxml2 are not really used, but headers from other libs include \
stuff from those, +# so we need their INCLUDE_DIR variable
+macro_optional_find_package(DbusGlib)
+macro_log_feature(DBUSGLIB_FOUND "dbus-glib" "dbus-glib is required for kcall"
+                                "http://dbus.freedesktop.org/releases/dbus-glib/" \
FALSE)  
-install(TARGETS kcall_handler ${INSTALL_TARGETS_DEFAULT_ARGS})
-install(FILES ${CMAKE_BINARY_DIR}/org.freedesktop.Telepathy.Client.kcall_handler.service
                
-        DESTINATION ${DBUS_SERVICES_INSTALL_DIR})
+macro_optional_find_package(LibXml2)
+macro_log_feature(LIBXML2_FOUND "LibXml2" "LibXml2 is required for kcall"
+                                    "http://xmlsoft.org/downloads.html" FALSE)
 
-# FIXME any better macro for ${XDG_DATA_DIRS} ?
-install(FILES kcall_handler.client DESTINATION \
${CMAKE_INSTALL_PREFIX}/share/telepathy/clients/) +include(CheckCXXSourceCompiles)
+set(CMAKE_REQUIRED_INCLUDES ${KDE4_INCLUDES})
+check_cxx_source_compiles("
+#include <QtCore/QtGlobal>
+int main()
+{
+#if defined(QT_NO_GLIB)
+#error \"Qt was compiled with Glib disabled\"
+#endif
+return 0;
+}"
+QT4_GLIB_SUPPORT)
+
+if (NOT QT4_GLIB_SUPPORT)
+    message(STATUS "WARNING: Qt4 is compiled without glib support. kcall will not \
work properly!") +endif (NOT QT4_GLIB_SUPPORT)
+
+if (GSTREAMER_FOUND AND GOBJECT_FOUND AND TPFARSIGHT_FOUND AND DBUSGLIB_FOUND AND \
LIBXML2_FOUND) +   set(BUILD_KCALL_HANDLER TRUE)
+else (GSTREAMER_FOUND AND GOBJECT_FOUND AND TPFARSIGHT_FOUND AND DBUSGLIB_FOUND AND \
LIBXML2_FOUND) +   set(BUILD_KCALL_HANDLER FALSE)
+endif (GSTREAMER_FOUND AND GOBJECT_FOUND AND TPFARSIGHT_FOUND AND DBUSGLIB_FOUND AND \
LIBXML2_FOUND) +
+
+if (BUILD_KCALL_HANDLER)
+   include_directories(${GSTREAMER_INCLUDE_DIR} ${GLIB2_INCLUDE_DIR} \
${DBUSGLIB_INCLUDE_DIR} +                       ${LIBXML2_INCLUDE_DIR} \
${TPFARSIGHT_INCLUDE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) +
+    set(kcall_handler_SRCS
+        main.cpp
+        callwindow.cpp
+        callhandler.cpp
+        channelhandler.cpp
+        abstractmediahandler.cpp
+        farsight/mediadevices.cpp
+        farsight/mediahandler.cpp
+    )
+
+    kde4_add_executable(kcall_handler ${kcall_handler_SRCS})
+    target_link_libraries(kcall_handler ${KDE4_KDEUI_LIBS}
+                                        ${TELEPATHY_QT4_LIBRARIES}
+                                        ${TELEPATHY_QT4_FARSIGHT_LIBRARIES}
+                                        ${GSTREAMER_LIBRARIES}
+                                        ${GOBJECT_LIBRARIES}
+                                        ${TPFARSIGHT_LIBRARIES})
+
+    install(TARGETS kcall_handler ${INSTALL_TARGETS_DEFAULT_ARGS})
+
+
+    configure_file(org.freedesktop.Telepathy.Client.kcall_handler.service.in
+                   org.freedesktop.Telepathy.Client.kcall_handler.service)
+    install(FILES ${CMAKE_BINARY_DIR}/org.freedesktop.Telepathy.Client.kcall_handler.service
 +            DESTINATION ${DBUS_SERVICES_INSTALL_DIR})
+
+    # FIXME any better macro for ${XDG_DATA_DIRS} ?
+    install(FILES kcall_handler.client DESTINATION \
${CMAKE_INSTALL_PREFIX}/share/telepathy/clients/) +
+endif (BUILD_KCALL_HANDLER)
--- trunk/playground/network/kcall/kcall_handler/callwindow.cpp #983412:983413
@@ -20,27 +20,30 @@
 #include <QtGui/QLabel>
 #include <KDebug>
 #include <KLocalizedString>
-#include <KPluginLoader>
-#include <KPluginFactory>
-#include <KParts/Part>
+#include <KAction>
+#include <KActionCollection>
+#include <KStatusBar>
+#include <TelepathyQt4/StreamedMediaChannel>
 
 struct CallWindow::Private
 {
-    KPluginLoader *loader;
-    KParts::Part *part;
+    QLabel *dummyLabel;
+    KAction *hangupAction;
+    ChannelHandler *channelHandler;
 };
 
 /*! This constructor is used to handle an incoming call, in which case
  * the specified \a channel must be ready and the call must have been accepted.
  */
 CallWindow::CallWindow(Tp::StreamedMediaChannelPtr channel)
-    : KParts::MainWindow(), d(new Private)
+    : KXmlGuiWindow(), d(new Private)
 {
-    init();
-    if ( d->part ) {
-        QMetaObject::invokeMethod(d->part, "handleStreamedMediaChannel",
-                                  Q_ARG(Tp::StreamedMediaChannelPtr, channel));
-    }
+    d->channelHandler = new ChannelHandler(this);
+    d->channelHandler->handleChannel(channel);
+    connect(d->channelHandler, SIGNAL(stateChanged(ChannelHandler::State)),
+            SLOT(setState(ChannelHandler::State)));
+
+    setupUi();
 }
 
 CallWindow::~CallWindow()
@@ -49,58 +52,71 @@
     delete d;
 }
 
-void CallWindow::init()
+void CallWindow::setupActions()
 {
-    d->part = NULL;
-    d->loader = new KPluginLoader("kcall_callwindowpart", KGlobal::mainComponent(), \
                this);
-    KPluginFactory *factory = d->loader->factory();
-    if ( factory ) {
-        d->part = factory->create<KParts::Part>(this, this);
-        //version check
-        int index = d->part->metaObject()->indexOfClassInfo("Interface version");
-        const char *version = d->part->metaObject()->classInfo(index).value();
-        if ( !version || version[0] != '0' ) {
-            kWarning() << "Incompatible plugin version loaded";
-            d->part->deleteLater();
-            d->part = NULL;
-        }
-    }
+    d->hangupAction = new KAction(KIcon("application-exit"), i18nc("@action", \
"Hangup"), this); +    connect(d->hangupAction, SIGNAL(triggered()), \
d->channelHandler, SLOT(hangupCall())); +    actionCollection()->addAction("hangup", \
d->hangupAction); +}
 
-    if ( d->part ) {
-        setCentralWidget(d->part->widget());
-    } else {
-        QLabel *label = new QLabel(i18nc("@info:status", "Could not load call window \
                part. "
-                                                         "Please check your \
                installation."), this);
-        label->setWordWrap(true);
-        setCentralWidget(label);
-    }
+void CallWindow::setupUi()
+{
+    d->dummyLabel = new QLabel("To be replaced by a real widget", this);
+    setCentralWidget(d->dummyLabel);
 
+    setupActions();
+
     setAutoSaveSettings(QLatin1String("CallWindow"));
-    setupGUI(QSize(320, 260), ToolBar | Keys | StatusBar | Save, \
                QLatin1String("callwindowui.rc"));
-    if ( d->part ) {
-        createGUI(d->part);
-    } else {
-        KXmlGuiWindow::createGUI(QLatin1String("callwindowui.rc"));
+    setupGUI(QSize(320, 260), Default, QLatin1String("callwindowui.rc"));
+}
+
+void CallWindow::setState(ChannelHandler::State state)
+{
+    switch (state) {
+    case ChannelHandler::Connecting:
+        setStatus(i18nc("@info:status", "Connecting..."));
+        d->hangupAction->setEnabled(false);
+        break;
+    case ChannelHandler::Ringing:
+        setStatus(i18nc("@info:status", "Ringing..."));
+        d->hangupAction->setEnabled(true);
+        break;
+    case ChannelHandler::InCall:
+        setStatus(i18nc("@info:status", "Talking..."));
+        d->hangupAction->setEnabled(true);
+        break;
+    case ChannelHandler::HangingUp:
+        setStatus(i18nc("@info:status", "Hanging up..."));
+        d->hangupAction->setEnabled(false);
+        break;
+    case ChannelHandler::Disconnected:
+        setStatus(i18nc("@info:status", "Disconnected."));
+        d->hangupAction->setEnabled(false);
+        break;
+    case ChannelHandler::Error:
+        setStatus(i18nc("@info:status", "Disconnected with error."));
+        d->hangupAction->setEnabled(false);
+        break;
     }
 }
 
+void CallWindow::setStatus(const QString & msg)
+{
+    statusBar()->showMessage(msg);
+}
+
 void CallWindow::onCallEnded(bool hasError)
 {
 }
 
 void CallWindow::closeEvent(QCloseEvent *event)
 {
-    if ( d->part ) {
-        bool canClose;
-        if ( QMetaObject::invokeMethod(d->part, "requestClose", Q_RETURN_ARG(bool, \
                canClose)) ) {
-            if ( !canClose ) {
-                kDebug() << "Ignoring close event";
-                connect(d->part, SIGNAL(callEnded(bool)), SLOT(close()));
-                event->ignore();
-            }
-        }
+    if ( !d->channelHandler->requestClose() ) {
+        kDebug() << "Ignoring close event";
+        connect(d->channelHandler, SIGNAL(callEnded(bool)), SLOT(close()));
+        event->ignore();
     }
-    KParts::MainWindow::closeEvent(event);
+    KXmlGuiWindow::closeEvent(event);
 }
 
 #include "callwindow.moc"
--- trunk/playground/network/kcall/kcall_handler/callwindow.h #983412:983413
@@ -17,10 +17,10 @@
 #ifndef CALLWINDOW_H
 #define CALLWINDOW_H
 
-#include <KParts/MainWindow>
-#include <TelepathyQt4/Contact>
+#include "channelhandler.h"
+#include <KXmlGuiWindow>
 
-class CallWindow : public KParts::MainWindow
+class CallWindow : public KXmlGuiWindow
 {
     Q_OBJECT
 public:
@@ -28,9 +28,12 @@
     virtual ~CallWindow();
 
 private:
-    void init();
+    void setupActions();
+    void setupUi();
 
 private slots:
+    void setState(ChannelHandler::State state);
+    void setStatus(const QString & msg);
     void onCallEnded(bool hasError);
 
 protected:


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic