• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

kmobiletools

calldialogimpl.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002    Copyright (C) 2007
00003    by Marco Gulino <marco@kmobiletools.org>
00004 
00005    This program is free software; you can redistribute it and/or modify
00006    it under the terms of the GNU General Public License as published by
00007    the Free Software Foundation; either version 2 of the License, or
00008    (at your option) any later version.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013    GNU General Public License for more details.
00014 
00015    You should have received a copy of the GNU General Public License
00016    along with this program; if not, write to the
00017    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018    Boston, MA 02110-1301, USA.
00019  ***************************************************************************/
00020 #include "calldialogimpl.h"
00021 #include <k3activelabel.h>
00022 #include <qtimer.h>
00023 #include <qlabel.h>
00024 #include <kdebug.h>
00025 
00026 #include <libkmobiletools/engine.h>
00027 #include <libkmobiletools/weaver.h>
00028 
00029 callDialogImpl::callDialogImpl(KMobileTools::Engine *engine, QWidget *parent, const char *name)
00030  : KDialog(parent), b_dialing(false), b_labelSet(false)
00031 {
00032     ui.setupUi(this);
00033     setObjectName(QLatin1String(name));
00034     setWindowFlags(Qt::WindowStaysOnTopHint);
00035     this->engine=engine;
00036     kDebug() <<"callDialogImpl::callDialogImpl()";
00037     disconnect(ui.timerStart, SIGNAL(linkClicked(const QString &)), ui.timerStart, SLOT(openLink(const QString &)));
00038     connect(ui.timerStart, SIGNAL(linkClicked(const QString &)), this, SLOT(slotTimerStart()));
00039     ui.timerStack->setCurrentIndex(0);
00040     resize(minimumSize());
00041 }
00042 
00043 
00044 callDialogImpl::~callDialogImpl()
00045 {
00046 }
00047 
00048 void callDialogImpl::slotTimerStart()
00049 {
00050     ui.timerStack->setCurrentIndex(1);
00051     time.start();
00052     slotTimerPoll();
00053     QTimer *p_timer=new QTimer(this);
00054     p_timer->setSingleShot(false);
00055     connect(p_timer, SIGNAL(timeout()), this, SLOT(slotTimerPoll()));
00056     p_timer->start(1000);
00057 }
00058 
00059 void callDialogImpl::slotTimerPoll()
00060 {
00061     ui.timer->setText( QTime().addMSecs(time.elapsed()).toString() );
00062 }
00063 
00064 #include "calldialogimpl.moc"
00065 
00066 
00070 void callDialogImpl::done(int r)
00071 {
00073     if(b_dialing) {
00074         QTimer::singleShot(500, this, SLOT(accept()));
00075         endCall();
00076         return;
00077     }
00078     KDialog::done(r);
00079 }
00080 
00081 
00085 int callDialogImpl::call(const QString &number, const QString &showName)
00086 {
00087     this->number=number;
00088     if(showName.isNull())
00089     {
00090         setWindowTitle(i18n("KMobileTools - Calling %1",number) );
00091         ui.lInfo->setText(i18n("<qt>Calling phone number: <b>%1</b><br/><br/></qt>",
00092                 number));
00093     }
00094     else
00095     {
00096         ui.lInfo->setText(i18n("<qt>Calling <b>%1</b><br/>Phone number: <b>%2</b><br/><br/></qt>",
00097                 showName, number));
00098         setWindowTitle(windowTitle().arg(showName));
00099     }
00100     connect(engine->ThreadWeaver(), SIGNAL(suspended()), this, SLOT(triggerCall()));
00101     engine->suspendStatusJobs( true );
00102     engine->ThreadWeaver()->suspend();
00103     kDebug() <<"callDialogImpl: suspending jobs in engine";
00104     ui.lStatus->setText(i18n("Suspending current tasks before calling."));
00105     return exec();
00106 }
00107 
00108 
00112 void callDialogImpl::triggerCall()
00113 {
00114     disconnect(engine->ThreadWeaver(), SIGNAL(suspended()), this, SLOT(triggerCall()));
00115     b_dialing=true;
00116     ui.lStatus->setText(i18n("Dialing number."));
00117     kDebug() <<"callDialogImpl: jobs suspended, now dialing number";
00118     ui.lStatus->setText(i18n("Phone status: calling."));
00119     engine->slotDial( KMobileTools::Engine::DIAL_DIAL, number );
00120 
00121 }
00122 
00123 
00127 void callDialogImpl::endCall()
00128 {
00129     if( ! b_labelSet )
00130     {
00131         b_labelSet=true;
00132         ui.lStatus->setText(i18n("Phone status: closing call."));
00133         QTimer::singleShot(100, this, SLOT(endCall()) );
00134         return;
00135     }
00136     engine->slotDial( KMobileTools::Engine::DIAL_HANGUP );
00137     engine->suspendStatusJobs( false );
00138     kDebug() <<"DevicePart: call finished, now resuming job queue";
00139     engine->ThreadWeaver()->resume();
00140     b_dialing=false;
00141 }

kmobiletools

Skip menu "kmobiletools"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
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