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

akonadi/contact

  • sources
  • kde-4.14
  • kdepimlibs
  • akonadi
  • contact
  • actions
qsflphonedialer.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 "qsflphonedialer.h"
22 #include "../dbusconnectionpool.h"
23 
24 #include <KLocalizedString>
25 
26 #include <QDBusConnectionInterface>
27 
28 #include <QtCore/QProcess>
29 #include <QtDBus/QDBusConnection>
30 #include <QtDBus/QDBusConnectionInterface>
31 #include <QtDBus/QDBusInterface>
32 #include <QtDBus/QDBusReply>
33 
34 #include <unistd.h>
35 
36 static bool isSflPhoneServiceRegistered()
37 {
38  const QLatin1String service("org.sflphone.SFLphone");
39 
40  QDBusConnectionInterface *interface = QDBusConnection::sessionBus().interface();
41  if (interface->isServiceRegistered(service)) {
42  return true;
43  }
44 
45  interface = Akonadi::DBusConnectionPool::threadConnection().interface();
46  if (interface->isServiceRegistered(service)) {
47  return true;
48  }
49  return false;
50 }
51 
52 QSflPhoneDialer::QSflPhoneDialer(const QString &applicationName)
53  : QDialer(applicationName)
54 {
55 }
56 
57 QSflPhoneDialer::~QSflPhoneDialer()
58 {
59 }
60 
61 bool QSflPhoneDialer::initializeSflPhone()
62 {
63  // first check whether dbus interface is available yet
64  if (!isSflPhoneServiceRegistered()) {
65 
66  // it could be skype is not running yet, so start it now
67  if (!QProcess::startDetached(QLatin1String("sflphone-client-kde"), QStringList())) {
68  mErrorMessage = i18n("Unable to start sflphone-client-kde process, check that sflphone-client-kde executable is in your PATH variable.");
69  return false;
70  }
71 
72  const int runs = 100;
73  for (int i = 0; i < runs; ++i) {
74  if (!isSflPhoneServiceRegistered()) {
75  ::sleep(2);
76  } else {
77  return true;
78  }
79  }
80  }
81  return true;
82 }
83 
84 bool QSflPhoneDialer::dialNumber(const QString &number)
85 {
86  if (!initializeSflPhone()) {
87  return false;
88  }
89 
90  QStringList arguments;
91  arguments << QLatin1String("--place-call");
92  arguments << number;
93  if (!QProcess::startDetached(QLatin1String("sflphone-client-kde"), arguments)) {
94  return false;
95  }
96 
97  return true;
98 }
99 
100 bool QSflPhoneDialer::sendSms(const QString &number, const QString &text)
101 {
102  if (!initializeSflPhone()) {
103  return false;
104  }
105 
106  QStringList arguments;
107  arguments << QLatin1String("--send-text");
108  arguments << number;
109  arguments << QLatin1String("--message");
110  arguments << text;
111  if (!QProcess::startDetached(QLatin1String("sflphone-client-kde"), arguments)) {
112  return false;
113  }
114  return true;
115 }
QDBusConnection::interface
QDBusConnectionInterface * interface() const
QProcess::startDetached
bool startDetached(const QString &program, const QStringList &arguments, const QString &workingDirectory, qint64 *pid)
QDBusConnection::sessionBus
QDBusConnection sessionBus()
QDBusConnectionInterface::isServiceRegistered
QDBusReply< bool > isServiceRegistered(const QString &serviceName) const
QDBusConnectionInterface
QString
QStringList
QLatin1String
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:38:19 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi/contact

Skip menu "akonadi/contact"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

kdepimlibs API Reference

Skip menu "kdepimlibs 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

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