• 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
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 #include <QDebug>
34 
35 #include <unistd.h>
36 
37 static bool isSflPhoneServiceRegistered()
38 {
39  const QLatin1String service( "org.sflphone.SFLphone" );
40 
41  QDBusConnectionInterface *interface = QDBusConnection::systemBus().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 
53 QSflPhoneDialer::QSflPhoneDialer( const QString &applicationName )
54  : QDialer( applicationName )
55 {
56 }
57 
58 QSflPhoneDialer::~QSflPhoneDialer()
59 {
60 }
61 
62 bool QSflPhoneDialer::initializeSflPhone()
63 {
64  // first check whether dbus interface is available yet
65  if ( !isSflPhoneServiceRegistered() ) {
66 
67  // it could be skype is not running yet, so start it now
68  if ( !QProcess::startDetached( QLatin1String( "sflphone-client-kde" ), QStringList() ) ) {
69  mErrorMessage = i18n( "Unable to start sflphone-client-kde process, check that sflphone-client-kde executable is in your PATH variable." );
70  return false;
71  }
72 
73  const int runs = 100;
74  for ( int i = 0; i < runs; ++i ) {
75  if ( !isSflPhoneServiceRegistered() ) {
76  ::sleep( 2 );
77  } else {
78  return true;
79  }
80  }
81  }
82  return true;
83 }
84 
85 bool QSflPhoneDialer::dialNumber(const QString &number)
86 {
87  if ( !initializeSflPhone() ) {
88  return false;
89  }
90 
91  QStringList arguments;
92  arguments << QLatin1String("--place-call");
93  arguments << number;
94  if (!QProcess::startDetached( QLatin1String( "sflphone-client-kde" ), arguments)) {
95  return false;
96  }
97 
98  return true;
99 }
100 
101 bool QSflPhoneDialer::sendSms(const QString &number, const QString &text)
102 {
103  if ( !initializeSflPhone() ) {
104  return false;
105  }
106 
107  QStringList arguments;
108  arguments << QLatin1String("--send-text");
109  arguments << number;
110  arguments << QLatin1String("--message");
111  arguments << text;
112  if (!QProcess::startDetached( QLatin1String( "sflphone-client-kde" ), arguments)) {
113  return false;
114  }
115  return true;
116 }
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