[kmobiletools] KDE/kdepim/kmobiletools/kmobiletools

Matthias Lechner matthias at lmme.de
Sat Jun 9 18:13:46 CEST 2007


SVN commit 673256 by lechner:

More API changes


 M  +8 -6      engines/at_engine/at_engine.cpp  
 M  +5 -0      engines/at_engine/at_engine.h  
 M  +0 -7      libkmobiletools/engine.cpp  
 M  +0 -24     libkmobiletools/engine.h  
 M  +26 -0     libkmobiletools/enginedata.cpp  
 M  +45 -0     libkmobiletools/enginedata.h  
 M  +2 -2      libkmobiletools/homepage.cpp  
 M  +6 -6      mainpart/devicehome.cpp  


--- trunk/KDE/kdepim/kmobiletools/kmobiletools/engines/at_engine/at_engine.cpp #673255:673256
@@ -55,7 +55,7 @@
     device=NULL;
 //     p_smsList = new SMSList();
     queue_sms=false;
-    connect( this, SIGNAL(connected()), this, SLOT(slotFetchInfos()) );
+    connect( this, SIGNAL(engineData().connected()), this, SLOT(slotFetchInfos()) );
 }
 
 
@@ -116,7 +116,7 @@
     } else kDebug() << "Device found on " << foundDevice()->foundPath() << endl;
     */
     device=new KMobileTools::SerialManager(this, this->objectName(), engineData().property("devicePath").toString(), initStrings() );
-    connect(device, SIGNAL(disconnected()), SIGNAL(disconnected() ) );
+    connect(device, SIGNAL(disconnected()), this, SLOT(connectionStateChanged()));
     connect(device, SIGNAL(error()), SIGNAL(error() ) );
     p_lastJob=new initPhoneJob(device, this);
     enqueueJob( p_lastJob );
@@ -135,10 +135,10 @@
     switch( job->type() ){
         case KMobileTools::Job::initPhone:
             kDebug() << "Device is connected: " << device->isConnected() << endl;
-            setPhoneConnected(device->isConnected() );
-            if( device->isConnected() ) emit connected(); break;
+            engineData().setPhoneConnected( device->isConnected() );
+            break;
         case KMobileTools::Job::pollStatus:
-            emit signalStrengthChanged( ((PollStatus*) job)->phoneSignal() );
+            engineData().setSignalStrength( ((PollStatus*) job)->phoneSignal() );
             emit chargeChanged( ((PollStatus*) job)->phoneCharge() );
             emit chargeTypeChanged( ((PollStatus*) job)->phoneChargeType() );
             emit ringing( ((PollStatus*) job)->ringing() );
@@ -710,5 +710,7 @@
             enqueueTPJob(new TestPhoneDeviceJob(*it, this) );
 }
 
+void AT_Engine::connectionStateChanged() {
+    engineData().setPhoneConnected( device->isConnected() );
+}
 
-
--- trunk/KDE/kdepim/kmobiletools/kmobiletools/engines/at_engine/at_engine.h #673255:673256
@@ -96,6 +96,7 @@
         void searchPhones(Connection connections, const QStringList &bluetoothDevices, const QStringList &customDevices);
         QList<TestPhoneDeviceJob*> l_testphonejobs;
         void enqueueTPJob(TestPhoneDeviceJob*);
+
 public slots:
     void slotPollStatus();
     void processSlot(KMobileTools::Job* );
@@ -129,6 +130,10 @@
 protected slots:
     void slotFetchCalendar();
     void slotSwitchToFSMode();
+
+private slots:
+    void connectionStateChanged();
+
 signals:
     void foundDeviceData(FindDeviceDataJob*);
 };
--- trunk/KDE/kdepim/kmobiletools/kmobiletools/libkmobiletools/engine.cpp #673255:673256
@@ -70,10 +70,6 @@
 
         int i_suspendStatusJobs;
 
-        /**
-         * True if phone is connected.
-         */
-        bool b_connected;
         bool b_ownweaver;
 
         KMobileTools::EngineData enginedata;
@@ -99,7 +95,6 @@
     d->s_totalSMS = 0;
     d->i_suspendStatusJobs=0;
     EnginesList::instance()->append( this );
-    d->b_connected=false;
 }
 
 
@@ -264,7 +259,5 @@
     return ret;
 }
 
-void Engine::setPhoneConnected(bool b) { d->b_connected=b; }
-bool Engine::phoneConnected() { return d->b_connected; }
 
 #include "engine.moc"
--- trunk/KDE/kdepim/kmobiletools/kmobiletools/libkmobiletools/engine.h #673255:673256
@@ -156,12 +156,6 @@
         int smsSlot();
 
         /**
-         * Retrieves if phone is connected.
-         *
-         * @return true if phone is connected.
-         */
-        bool phoneConnected();
-        /**
          * Shows if mobile phone can encode text in PDU mode.
          *
          * @return true if mobile phone is PDU able.
@@ -292,8 +286,6 @@
         KMobileTools::EngineData& engineData();
 
     protected Q_SLOTS:
-        void setPhoneConnected(bool);
-
         /**
          * This slot is called whenever an enqueued job has been finished.
          * Reimplement this method to further process the data that the job
@@ -308,17 +300,8 @@
          * This signal is emitted when KMobileTools finish a task.
          */
         void jobFinished( KMobileTools::Job::JobType );
-        /**
-         * This signal is emitted when the phone is disconnected.
-         */
-        void disconnected();
 
         /**
-         * This signal is emitted when the phone is connected.
-         */
-        void connected();
-
-        /**
          * This signal is emitted when an error is occurred.
          */
         void errorOccured();
@@ -331,13 +314,6 @@
         /**
          * This signal is emitted every phone poll.
          *
-         * @param signalStrength the signal level in percentual.
-         */
-        void signalStrengthChanged( int signalStrength );
-
-        /**
-         * This signal is emitted every phone poll.
-         *
          * @param charge the charge level in percentual.
          */
         void chargeChanged( int charge );
--- trunk/KDE/kdepim/kmobiletools/kmobiletools/libkmobiletools/enginedata.cpp #673255:673256
@@ -33,6 +33,8 @@
     public:
         EngineDataPrivate() : engine(NULL), i_manufacturer(KMobileTools::Engine::Unknown) {}
         KMobileTools::Engine *engine;
+        bool b_connected;               // phone connected?
+        int i_signalStrength;           // signal strength in percent
         QString s_manufacturer;         // manufacturer raw string
         int i_manufacturer;             // enum value?
         QString s_model;                // phone model
@@ -90,4 +92,28 @@
 ContactsList *EngineData::contactsList() const { return d->p_addresseeList; }
 void EngineData::setContactsList(ContactsList* cl) { d->p_addresseeList=cl; }
 
+void EngineData::setPhoneConnected( bool b ) {
+    // did the connection state change?
+    if( d->b_connected != b ) {
+        if( b )
+            emit connected();
+        else
+            emit disconnected();
+    }
 
+    d->b_connected=b;
+}
+bool EngineData::phoneConnected() const {
+    return d->b_connected;
+}
+
+int EngineData::signalStrength() const {
+    return d->i_signalStrength;
+}
+
+void EngineData::setSignalStrength( int signalStrength ) {
+    if( signalStrength != d->i_signalStrength )
+        emit signalStrengthChanged( signalStrength );
+
+    d->i_signalStrength = signalStrength;
+}
--- trunk/KDE/kdepim/kmobiletools/kmobiletools/libkmobiletools/enginedata.h #673255:673256
@@ -48,6 +48,34 @@
             ~EngineData();
 
             /**
+            * Retrieves if phone is connected.
+            *
+            * @return true if phone is connected.
+            */
+            bool phoneConnected() const;
+
+            /**
+            * Sets if phone is connected.
+            *
+            * @return true if phone is connected.
+            */
+            void setPhoneConnected(bool);
+
+            /**
+             * Returns the phone's signal strength
+             * 
+             * @return the signal strength in percent
+             */
+            int signalStrength() const;
+
+            /**
+             * Sets the phone's signal strength
+             * 
+             * @p signalStrength the signal strength in percent
+             */
+            void setSignalStrength( int signalStrength );
+
+            /**
              * Sets phone manufacturer as returned by the mobile phone.
              *
              * @param manufacturer the manufacturer string.
@@ -167,7 +195,24 @@
              */
             KCal::Event::List *calendar();
 
+        Q_SIGNALS:
+            /**
+            * This signal is emitted when the phone is disconnected.
+            */
+            void disconnected();
+    
+            /**
+            * This signal is emitted when the phone is connected.
+            */
+            void connected();
 
+            /**
+            * This signal is emitted whenever the signal strength has changed.
+            *
+            * @param signalStrength the signal level in percent
+            */
+            void signalStrengthChanged( int signalStrength );
+
         private:
             EngineDataPrivate *const d;
     };
--- trunk/KDE/kdepim/kmobiletools/kmobiletools/libkmobiletools/homepage.cpp #673255:673256
@@ -172,7 +172,7 @@
             deviceIFace=new DeviceIFace_stub( kapp->dcopClient(), "kmobiletools", Q3CString((*it).latin1() ) );
             if ( deviceIFace->isConnected() )
 #endif
-            if ( KMobileTools::EnginesList::instance()->find(*it)->phoneConnected() ) // ### FIXME
+            if ( KMobileTools::EnginesList::instance()->find(*it)->constEngineData().phoneConnected() ) // ### FIXME
                 stringStatus=i18n("Device connected");
             else
             {
@@ -231,7 +231,7 @@
                 .arg(i18n("Please wait while KMobileTools tries to find the right device for your mobile phone.") );
         break;
     default:
-        if( engine->phoneConnected() )
+        if( engine->constEngineData().phoneConnected() )
         {
             SMSList *l=engine->constEngineData().smsList();
             htmlData+="<ul><li><b>%8</b></li></ul><p>%1 %2</p><p>%3 %4</p><div align='right'><a href=\"infopage:1\">%7</a></div>";
--- trunk/KDE/kdepim/kmobiletools/kmobiletools/mainpart/devicehome.cpp #673255:673256
@@ -316,10 +316,10 @@
         emit deleteThis( objectName() );
         return;
     }
-    connect(engine, SIGNAL(connected()), this, SLOT(devConnected()) );
-    connect(engine, SIGNAL(disconnected()), this, SLOT(devDisconnected() ) );
-    connect(engine, SIGNAL(connected() ), this, SLOT(enableWidgets() ) );
-    connect(engine, SIGNAL(disconnected() ), this, SLOT(disableWidgets() ) );
+    connect(&(engine->constEngineData()), SIGNAL(connected()), this, SLOT(devConnected()) );
+    connect(&(engine->constEngineData()), SIGNAL(disconnected()), this, SLOT(devDisconnected() ) );
+    connect(&(engine->constEngineData()), SIGNAL(connected()), this, SLOT(enableWidgets() ) );
+    connect(&(engine->constEngineData()), SIGNAL(disconnected() ), this, SLOT(disableWidgets() ) );
     connect(engine, SIGNAL(phoneBookChanged() ), SLOT(updatePB()) );
     connect(engine, SIGNAL(phoneBookChanged(int, const ContactsList& ) ), SLOT(updatePB(int, const ContactsList& ) ) );
     connect(engine, SIGNAL(smsFoldersAdded() ), SLOT(addSMSFolders()) );
@@ -1064,7 +1064,7 @@
     signalLabel=new QLabel(i18n("Signal"), statusBarExtension->statusBar());
     if(!engine) return;
     connect(engine, SIGNAL(charge(int ) ), batteryProgress, SLOT(setValue(int ) ) );
-    connect(engine, SIGNAL(signalStrengthChanged( int ) ), signalProgress, SLOT(setValue( int ) ) );
+    connect(&(engine->constEngineData()), SIGNAL(signalStrengthChanged( int ) ), signalProgress, SLOT(setValue( int ) ) );
     connect(engine, SIGNAL(networkNameChanged( const QString &) ), networkLabel, SLOT(setText(const QString& ) ) );
 //     connect(engine, SIGNAL( jobEnqueued(KMobileTools::Job *) ), statusBarBox, SLOT(slotJobEnqueued(KMobileTools::Job* ) ) );
 }
@@ -1150,7 +1150,7 @@
 void DeviceHome::slotDial()
 {
     if( !ui.number_dial->currentText().length()) return;
-    if(! engine->phoneConnected())
+    if(! engine->constEngineData().phoneConnected())
     {
         errNotConnected();
         return;


More information about the kmobiletools mailing list