kmobiletools
at_scanprogresspage.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
00021
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
00126
00127
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 }