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

akonadi

  • 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 
54 
55 QSflPhoneDialer::QSflPhoneDialer( const QString &applicationName )
56  : QDialer( applicationName )
57 {
58 }
59 
60 QSflPhoneDialer::~QSflPhoneDialer()
61 {
62 }
63 
64 bool QSflPhoneDialer::initializeSflPhone()
65 {
66  // first check whether dbus interface is available yet
67  if ( !isSflPhoneServiceRegistered() ) {
68 
69  // it could be skype is not running yet, so start it now
70  if ( !QProcess::startDetached( QLatin1String( "sflphone-client-kde" ), QStringList() ) ) {
71  mErrorMessage = i18n( "Unable to start sflphone-client-kde process, check that sflphone-client-kde executable is in your PATH variable." );
72  return false;
73  }
74 
75  const int runs = 100;
76  for ( int i = 0; i < runs; ++i ) {
77  if ( !isSflPhoneServiceRegistered() ) {
78  ::sleep( 2 );
79  } else {
80  return true;
81  }
82  }
83  }
84  return true;
85 }
86 
87 bool QSflPhoneDialer::dialNumber(const QString &number)
88 {
89  if ( !initializeSflPhone() ) {
90  return false;
91  }
92 
93  QStringList arguments;
94  arguments << QLatin1String("--place-call");
95  arguments << number;
96  if (!QProcess::startDetached( QLatin1String( "sflphone-client-kde" ), arguments)) {
97  return false;
98  }
99 
100  return true;
101 }
102 
103 bool QSflPhoneDialer::sendSms(const QString &number, const QString &text)
104 {
105  if ( !initializeSflPhone() ) {
106  return false;
107  }
108 
109  QStringList arguments;
110  arguments << QLatin1String("--send-text");
111  arguments << number;
112  arguments << QLatin1String("--message");
113  arguments << text;
114  if (!QProcess::startDetached( QLatin1String( "sflphone-client-kde" ), arguments)) {
115  return false;
116  }
117  return true;
118 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Tue Nov 26 2013 09:03:18 by doxygen 1.8.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.11.3 API Reference

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