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

kmobiletools

at_scanprogresspage.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002    Copyright (C) 2007
00003    by Marco Gulino <marco@kmobiletools.org>
00004 
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010 
00011 
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017 
00018    You should have received a copy of the GNU General Public License
00019    along with this program; if not, write to the
00020    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00021    Boston, MA 02110-1301, USA.
00022  ***************************************************************************/
00023 #include "at_scanprogresspage.h"
00024 #include "at_engine.h"
00025 #include "testphonedevice.h"
00026 #include <libkmobiletools/engineslist.h>
00027 #include <libkmobiletools/enginedata.h>
00028 #include "atengineconfig.h"
00029 #include <klocalizedstring.h>
00030 
00031 AT_ScanProgressPage::AT_ScanProgressPage(QWidget *parent)
00032  : ScanProgressPage(parent), totaljobs(0), donejobs(0)
00033 {
00034 }
00035 
00036 
00037 AT_ScanProgressPage::~AT_ScanProgressPage()
00038 {
00039 }
00040 
00041 #include "at_scanprogresspage.moc"
00042 
00043 
00044 
00048 bool AT_ScanProgressPage::isComplete() const {
00049     bool complete=(donejobs!=0 && totaljobs==donejobs);
00050     kDebug() <<"isComplete==" << complete <<" (progress=" << donejobs <<"/" << totaljobs <<")";
00051     return complete;
00052 }
00053 
00054 
00058 void AT_ScanProgressPage::cleanupPage()
00059 {
00060     kDebug() <<"AT_ScanProgressPage::cleanupPage()";
00061     ScanProgressPage::cleanupPage();
00062     disconnect(engine, SIGNAL(foundDeviceData(FindDeviceDataJob*)), this, SLOT(deviceProbed(FindDeviceDataJob*)) );
00064     totaljobs=0;
00065     l_devices.clear();
00066 }
00067 
00068 
00072 void AT_ScanProgressPage::initializePage() {
00073     kDebug() <<"AT_ScanProgressPage::initializePage()";
00074     wizard()->setProperty("scanprogress_id", wizard()->currentId());
00075     engine=(AT_Engine*) KMobileTools::EnginesList::instance()->wizardEngine();
00076     connect(engine, SIGNAL(foundDeviceData(FindDeviceDataJob*)), this, SLOT(deviceProbed(FindDeviceDataJob*)) );
00077     cfg=(ATDevicesConfig*) DEVCFG(wizard()->objectName() );
00078     startScan();
00079 }
00080 
00081 
00085 void AT_ScanProgressPage::deviceProbed(FindDeviceDataJob* job)
00086 {
00087     kDebug() <<"Job done:" << job->path() <<"; found:" << job->found();
00088     if(job->found()) l_devices+=job->data();
00089     donejobs++;
00090     setProgress( (donejobs*100)/totaljobs);
00091     emit completeChanged();
00092     if(donejobs && (donejobs==totaljobs) ) {
00093         setStatusString( i18nc("Wizard - probe finished", "All devices were analyzed.") );
00094         wizard()->next();
00095     }
00096         else setStatusString( i18nc("Wizard - probed device..", "%1 done.", job->path() ) );
00097 }
00098 
00099 
00103 void AT_ScanProgressPage::startScan()
00104 {
00105     donejobs=0;
00106     if(!cfg->at_connections() ) return;
00107     QStringList devices;
00108     TestPhoneDeviceJob *curjob;
00109     if(cfg->at_connections() & ATDevicesConfig::ConnectionUSB)
00110         for(uchar i=0; i<10; i++) {
00111             engine->enqueueJob( new FindDeviceDataJob(QString("/dev/ttyACM%1").arg(i), engine) );
00112             engine->enqueueJob(new FindDeviceDataJob(QString("/dev/ttyUSB%1").arg(i), engine) );
00113             totaljobs+=2;
00114         }
00115     if(cfg->at_connections() & ATDevicesConfig::ConnectionIrDA)
00116         for(uchar i=0; i<10; i++) {
00117             engine->enqueueJob(new FindDeviceDataJob(QString("/dev/ircomm%1").arg(i), engine) );
00118             totaljobs++;
00119         }
00120     if(cfg->at_connections() & ATDevicesConfig::ConnectionSerial)
00121         for(uchar i=0; i<10; i++) {
00122             engine->enqueueJob(new FindDeviceDataJob(QString("/dev/ttyS%1").arg(i), engine) );
00123             totaljobs++;
00124         }
00125 /*    if(cfg->at_connections() & ConnectionBluetooth)
00126         for(QStringList::ConstIterator it=bluetoothDevices.begin(); it!=bluetoothDevices.end(); ++it)
00127             engine->enqueueJob(new FindDeviceDataJob(*it, engine) );*/
00128     if(cfg->at_connections() & ATDevicesConfig::ConnectionUser)
00129         for(QStringList::ConstIterator it=cfg->at_userdevices().begin(); it!=cfg->at_userdevices().end(); ++it) {
00130             engine->enqueueJob(new FindDeviceDataJob(*it, engine) );
00131             totaljobs++;
00132         }
00133 }

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