kmobiletools
calldialogimpl.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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 }