• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

akonadi/contact

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 "qskypedialer.h"
00026 
00027 #include <kabc/phonenumber.h>
00028 #include <kconfig.h>
00029 #include <kconfiggroup.h>
00030 #include <klocale.h>
00031 #include <kmessagebox.h>
00032 #include <krun.h>
00033 
00034 using namespace Akonadi;
00035 
00036 static QString strippedNumber( const QString &number )
00037 {
00038   QString result;
00039 
00040   for ( int i = 0; i < number.length(); ++i ) {
00041     const QChar character = number.at( i );
00042     if ( character.isDigit() || (character == QLatin1Char( '+' ) && i == 0) )
00043       result += character;
00044   }
00045 
00046   return result;
00047 }
00048 
00049 void DialPhoneNumberAction::dialNumber( const KABC::PhoneNumber &number )
00050 {
00051   // synchronize
00052   ContactActionsSettings::self()->readConfig();
00053 
00054   // we handle skype separated
00055   if ( ContactActionsSettings::self()->dialPhoneNumberAction() == ContactActionsSettings::UseSkype ) {
00056     QSkypeDialer dialer( QLatin1String( "AkonadiContacts" ) );
00057     if ( !dialer.dialNumber( strippedNumber( number.number().trimmed() ) ) ) {
00058       KMessageBox::sorry( 0, dialer.errorMessage() );
00059     }
00060     return;
00061   }
00062 
00063   QString command = ContactActionsSettings::self()->phoneCommand();
00064 
00065   if ( command.isEmpty() ) {
00066     KMessageBox::sorry( 0, i18n( "There is no application set which could be executed. Please go to the settings dialog and configure one." ) );
00067     return;
00068   }
00069 
00070   /*
00071    * %N the raw number
00072    * %n the number with all additional non-number characters removed
00073    */
00074   command = command.replace( QLatin1String( "%N" ), number.number() );
00075   command = command.replace( QLatin1String( "%n" ), strippedNumber( number.number().trimmed() ) );
00076 
00077   KRun::runCommand( command, 0 );
00078 }

akonadi/contact

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

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kblog
  • kcal
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.6.2-20100208
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal