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

akonadi

dialphonenumberaction.cpp
00001 /*
00002     This file is part of Akonadi Contact.
00003 
00004     Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
00005 
00006     This library is free software; you can redistribute it and/or modify it
00007     under the terms of the GNU Library General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or (at your
00009     option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful, but WITHOUT
00012     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00013     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00014     License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to the
00018     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00019     02110-1301, USA.
00020 */
00021 
00022 #include "dialphonenumberaction.h"
00023 
00024 #include "contactactionssettings.h"
00025 #include "qdialer.h"
00026 #include "qskypedialer.h"
00027 #ifdef Q_OS_WINCE
00028 #include "qwincedialer.h"
00029 #endif // Q_OS_WINCE
00030 
00031 #include <kabc/phonenumber.h>
00032 #include <kconfig.h>
00033 #include <kconfiggroup.h>
00034 #include <klocale.h>
00035 #include <kmessagebox.h>
00036 #include <krun.h>
00037 
00038 using namespace Akonadi;
00039 
00040 static QString strippedDialNumber( const QString &number )
00041 {
00042   QString result;
00043 
00044   for ( int i = 0; i < number.length(); ++i ) {
00045     const QChar character = number.at( i );
00046     if ( character.isDigit() || (character == QLatin1Char( '+' ) && i == 0) )
00047       result += character;
00048   }
00049 
00050   return result;
00051 }
00052 
00053 void DialPhoneNumberAction::dialNumber( const KABC::PhoneNumber &number )
00054 {
00055   // synchronize
00056   ContactActionsSettings::self()->readConfig();
00057 
00058   QDialer *dialer = NULL;
00059   // we handle skype separated
00060   if ( ContactActionsSettings::self()->dialPhoneNumberAction() == ContactActionsSettings::UseSkype ) {
00061     dialer = new QSkypeDialer( QLatin1String( "AkonadiContacts" ) );
00062   }
00063 #ifdef Q_OS_WINCE
00064   else if ( ContactActionsSettings::self()->dialPhoneNumberAction() == ContactActionsSettings::UseWinCE ) {
00065     dialer = new QWinCEDialer( QLatin1String( "AkonadiContacts" ) );
00066   }
00067 #endif // Q_OS_WINCE
00068   if ( dialer ) {
00069     if ( !dialer->dialNumber( strippedDialNumber( number.number().trimmed() ) ) ) {
00070       KMessageBox::sorry( 0, dialer->errorMessage() );
00071     }
00072     delete dialer;
00073     return;
00074   }
00075 
00076   QString command = ContactActionsSettings::self()->phoneCommand();
00077 
00078   if ( command.isEmpty() ) {
00079     KMessageBox::sorry( 0, i18n( "There is no application set which could be executed. Please go to the settings dialog and configure one." ) );
00080     return;
00081   }
00082 
00083   /*
00084    * %N the raw number
00085    * %n the number with all additional non-number characters removed
00086    */
00087   command = command.replace( QLatin1String( "%N" ), number.number() );
00088   command = command.replace( QLatin1String( "%n" ), strippedDialNumber( number.number().trimmed() ) );
00089 
00090   KRun::runCommand( command, 0 );
00091 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Thu Aug 2 2012 15:25:18 by doxygen 1.7.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.8.5 API Reference

Skip menu "kdepimlibs-4.8.5 API Reference"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • 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