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

akonadi/contact

  • 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
36static 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
52QSflPhoneDialer::QSflPhoneDialer(const QString &applicationName)
53 : QDialer(applicationName)
54{
55}
56
57QSflPhoneDialer::~QSflPhoneDialer()
58{
59}
60
61bool 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
84bool 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
100bool 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}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Wed Jan 24 2024 00:00:00 by doxygen 1.10.0 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-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