• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepimlibs API Reference
  • KDE Home
  • Contact Us
 

akonadi

  • sources
  • kde-4.12
  • kdepimlibs
  • akonadi
  • contact
  • actions
qekigadialer.cpp
1 /*
2  Copyright (c) 2013 Montel Laurent <montel@kde.org>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 
19 */
20 
21 #include "qekigadialer.h"
22 
23 #include "../dbusconnectionpool.h"
24 
25 #include <KLocalizedString>
26 
27 #include <QDBusConnectionInterface>
28 
29 #include <QtCore/QProcess>
30 #include <QtDBus/QDBusConnection>
31 #include <QtDBus/QDBusConnectionInterface>
32 #include <QtDBus/QDBusInterface>
33 #include <QtDBus/QDBusReply>
34 #include <QDebug>
35 
36 #include <unistd.h>
37 
38 static bool isEkigaServiceRegistered()
39 {
40  const QLatin1String service( "org.ekiga.Ekiga" );
41 
42  QDBusConnectionInterface *interface = QDBusConnection::systemBus().interface();
43  if ( interface->isServiceRegistered( service ) ) {
44  return true;
45  }
46 
47  interface = Akonadi::DBusConnectionPool::threadConnection().interface();
48  if ( interface->isServiceRegistered( service ) ) {
49  return true;
50  }
51  return false;
52 }
53 
54 static QDBusInterface* searchEkigaDBusInterface()
55 {
56  const QLatin1String service( "org.ekiga.Ekiga" );
57  const QLatin1String path( "/org/ekiga/Ekiga" );
58 
59  QDBusInterface *interface = new QDBusInterface( service, path, QString(), QDBusConnection::systemBus() );
60  if ( !interface->isValid() ) {
61  delete interface;
62  interface = new QDBusInterface( service, path, QString(), Akonadi::DBusConnectionPool::threadConnection() );
63  }
64 
65  return interface;
66 }
67 
68 QEkigaDialer::QEkigaDialer( const QString &applicationName )
69  : QDialer( applicationName ), mInterface( 0 )
70 {
71 }
72 
73 QEkigaDialer::~QEkigaDialer()
74 {
75  delete mInterface;
76 }
77 
78 bool QEkigaDialer::initializeEkiga()
79 {
80  // first check whether dbus interface is available yet
81  if ( !isEkigaServiceRegistered() ) {
82 
83  // it could be skype is not running yet, so start it now
84  if ( !QProcess::startDetached( QLatin1String( "ekiga" ), QStringList() ) ) {
85  mErrorMessage = i18n( "Unable to start ekiga process, check that ekiga executable is in your PATH variable." );
86  return false;
87  }
88 
89  const int runs = 100;
90  for ( int i = 0; i < runs; ++i ) {
91  if ( !isEkigaServiceRegistered() ) {
92  ::sleep( 2 );
93  } else {
94  break;
95  }
96  }
97  }
98 
99  // check again for the dbus interface
100  mInterface = searchEkigaDBusInterface();
101 
102  if ( !mInterface->isValid() ) {
103  delete mInterface;
104  mInterface = 0;
105 
106  mErrorMessage = i18n( "Ekiga Public API (D-Bus) seems to be disabled." );
107  return false;
108  }
109 
110  return true;
111 }
112 
113 bool QEkigaDialer::dialNumber(const QString &number)
114 {
115  if ( !initializeEkiga() ) {
116  return false;
117  }
118  QDBusReply<void> reply = mInterface->call( QLatin1String( "Call" ), number );
119  return true;
120 }
121 
122 bool QEkigaDialer::sendSms(const QString &, const QString &)
123 {
124  mErrorMessage = i18n( "Sending an SMS is currently not supported on Ekiga" );
125  return false;
126 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:00:27 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi

Skip menu "akonadi"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Modules
  • Related Pages

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal