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

akonadi

  • 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
35#include <unistd.h>
36
37static bool isEkigaServiceRegistered()
38{
39 const QLatin1String service("org.ekiga.Ekiga");
40
41 QDBusConnectionInterface *interface = QDBusConnection::sessionBus().interface();
42 if (interface->isServiceRegistered(service)) {
43 return true;
44 }
45
46 interface = Akonadi::DBusConnectionPool::threadConnection().interface();
47 if (interface->isServiceRegistered(service)) {
48 return true;
49 }
50 return false;
51}
52
53static QDBusInterface *searchEkigaDBusInterface()
54{
55 const QLatin1String service("org.ekiga.Ekiga");
56 const QLatin1String path("/org/ekiga/Ekiga");
57
58 QDBusInterface *interface = new QDBusInterface(service, path, QString(), QDBusConnection::sessionBus());
59 if (!interface->isValid()) {
60 delete interface;
61 interface = new QDBusInterface(service, path, QString(), Akonadi::DBusConnectionPool::threadConnection());
62 }
63
64 return interface;
65}
66
67QEkigaDialer::QEkigaDialer(const QString &applicationName)
68 : QDialer(applicationName), mInterface(0)
69{
70}
71
72QEkigaDialer::~QEkigaDialer()
73{
74 delete mInterface;
75}
76
77bool QEkigaDialer::initializeEkiga()
78{
79 // first check whether dbus interface is available yet
80 if (!isEkigaServiceRegistered()) {
81
82 // it could be skype is not running yet, so start it now
83 if (!QProcess::startDetached(QLatin1String("ekiga"), QStringList())) {
84 mErrorMessage = i18n("Unable to start ekiga process, check that ekiga executable is in your PATH variable.");
85 return false;
86 }
87
88 const int runs = 100;
89 for (int i = 0; i < runs; ++i) {
90 if (!isEkigaServiceRegistered()) {
91 ::sleep(2);
92 } else {
93 break;
94 }
95 }
96 }
97
98 // check again for the dbus interface
99 mInterface = searchEkigaDBusInterface();
100
101 if (!mInterface->isValid()) {
102 delete mInterface;
103 mInterface = 0;
104
105 mErrorMessage = i18n("Ekiga Public API (D-Bus) seems to be disabled.");
106 return false;
107 }
108
109 return true;
110}
111
112bool QEkigaDialer::dialNumber(const QString &number)
113{
114 if (!initializeEkiga()) {
115 return false;
116 }
117 QDBusReply<void> reply = mInterface->call(QLatin1String("Call"), number);
118 return true;
119}
120
121bool QEkigaDialer::sendSms(const QString &number, const QString &text)
122{
123 Q_UNUSED(number);
124 Q_UNUSED(text);
125 mErrorMessage = i18n("Sending an SMS is currently not supported on Ekiga.");
126 return false;
127}
128
Akonadi
FreeBusyManager::Singleton.
Definition: actionstatemanager_p.h:28
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jul 21 2022 00:00:00 by doxygen 1.9.5 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-4.14.10 API Reference

Skip menu "kdepimlibs-4.14.10 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
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