[kmobiletools] KDE/kdepim/kmobiletools

Marco Gulino marco at kmobiletools.org
Tue Jun 5 15:50:09 CEST 2007


SVN commit 671753 by gulino:

Forwardporting commit 671716


 M  +7 -0      kmobiletools/engines/at_engine/at_engine.cpp  
 M  +2 -1      kmobiletools/engines/at_engine/sms_jobs.cpp  
 M  +11 -0     tests/kserialdeviceemulator/commandslist.cpp  
 M  +2 -0      tests/kserialdeviceemulator/commandslist.h  
 M  +26 -20    tests/kserialdeviceemulator/kserialdeviceemulator.cpp  


--- trunk/KDE/kdepim/kmobiletools/kmobiletools/engines/at_engine/at_engine.cpp #671752:671753
@@ -305,6 +305,13 @@
     diffSMSList()->clear();
     if(queue_sms) return;
     QStringList sl_slots=config()->at_smsslots();
+    if( ! sl_slots.count() ) {
+        kDebug() << "**** WARNING - this phone is NOT reporting having SMS slots. Perhaps it can't provide SMS. I'm trying anyway to fetch them.\n";
+        p_lastJob=new FetchSMS(p_lastJob, SMS::All, device, true, this );
+        enqueueJob(p_lastJob);
+        queue_sms=true;
+        return;
+    }
     for (QStringList::iterator it=sl_slots.begin(); it!=sl_slots.end(); ++it)
     {
         p_lastJob=new SelectSMSSlot( p_lastJob, (*it), device, this );
--- trunk/KDE/kdepim/kmobiletools/kmobiletools/engines/at_engine/sms_jobs.cpp #671752:671753
@@ -409,7 +409,7 @@
 
 void FetchSMS::run()
 {
-    int sms_Slot;
+    int sms_Slot=0;
     QString buffer;
     buffer=p_device->sendATCommand(this,  "AT+CPMS?\r" );
     buffer=kmobiletoolsATJob::parseInfo( buffer);
@@ -425,6 +425,7 @@
     if (in_memslot=="ME" || in_memslot== "MT" || in_memslot=="OM" || in_memslot=="IM") sms_Slot= SMS::Phone;
     if (in_memslot=="SM" || in_memslot== "MT" || in_memslot=="OM" || in_memslot=="IM") sms_Slot= SMS::SIM;
 //     kDebug() << "Current SMS Slot:" << in_memslot << ";" << memslot2 << ";" << memslot3 << ";\n";
+    if(! sms_Slot) sms_Slot=SMS::Phone; // if we've no slots just assign the SMS to the phone as default.
     
     // Get the slot number
     int numSlot;
--- trunk/KDE/kdepim/kmobiletools/tests/kserialdeviceemulator/commandslist.cpp #671752:671753
@@ -53,11 +53,22 @@
     QFile file(filen);
     if (! file.exists()) return;
     clear();
+    b_hassmsslots=true;
     file.open(QIODevice::ReadOnly);
     uint i=0;
     Q3TextStream stream(&file);
     while ( !stream.atEnd() ) {
         line=stream.readLine();
+        if(line.left(1) == "#") {
+        // Command-comment
+            if (line.left(2) == "##") { // Command directive
+                if (line.contains("NOSMSSLOTS")) {
+                    b_hassmsslots=false;
+                    kDebug() << "Setting NO sms slots\n";
+                }
+            }
+            continue;
+        }
         if(line.left(3) == ">>>")
         {
             if(cmd.length() && answer.length())
--- trunk/KDE/kdepim/kmobiletools/tests/kserialdeviceemulator/commandslist.h #671752:671753
@@ -53,8 +53,10 @@
     static CommandsList *instance() { return p_instance; }
     void loadFile(const QString &filen);
     Command searchCmd(const QString &cmd);
+    bool hasSMSSlots() { return b_hassmsslots; }
     private:
         static CommandsList *p_instance;
+        bool b_hassmsslots;
 
 };
 
--- trunk/KDE/kdepim/kmobiletools/tests/kserialdeviceemulator/kserialdeviceemulator.cpp #671752:671753
@@ -176,33 +176,39 @@
     if( regexpPB.search(cmd)!=-1 || regexpSMS.search(cmd)!=-1 || regexpSlot.search(cmd)!=-1 )
     {
         bool isSMS=(regexpSMS.search(cmd)!=-1 || (regexpSlot.search(cmd)!=-1 && regexpSlot.cap(1) == "AT+CPMS") );
+        if(isSMS && !CommandsList::instance()->hasSMSSlots()) {
+            command=CommandsList::instance()->searchCmd(cmd);
+            kDebug() << "NO SMS Slots to be found\n";
+        }
+        else {
 //         kDebug() << "Searching for sms:" << isSMS << endl;
-        regexpSlot.setPattern( "(AT\\+CP[MB]S)=\"*[\\w]+\"*");
-        bool rightSlot=false;
-        for(Q3ValueList<Command>::ConstIterator it=CommandsList::instance()->begin(); it!=CommandsList::instance()->end(); ++it)
-        {
-            if(regexpSlot.search( (*it).cmd() )!=-1)
+            regexpSlot.setPattern( "(AT\\+CP[MB]S)=\"*[\\w]+\"*");
+            bool rightSlot=false;
+            for(Q3ValueList<Command>::ConstIterator it=CommandsList::instance()->begin(); it!=CommandsList::instance()->end(); ++it)
             {
-                // If we're searching for a SMS slot and we've found a PB one, or vice versa, just continue the loop.
-                if( (regexpSlot.cap(1)=="AT+CPMS" && !isSMS ) || (regexpSlot.cap(1)=="AT+CPBS" && isSMS ) ) continue;
-                if( smsSlot==(*it).cmd() || pbSlot==(*it).cmd() )
+                if(regexpSlot.search( (*it).cmd() )!=-1)
                 {
-//                     kDebug() << "Searching for slot ok; was searching for " << (*it).origPos() << endl;
-                    rightSlot=true;
+                    // If we're searching for a SMS slot and we've found a PB one, or vice versa, just continue the loop.
+                    if( (regexpSlot.cap(1)=="AT+CPMS" && !isSMS ) || (regexpSlot.cap(1)=="AT+CPBS" && isSMS ) ) continue;
+                    if( smsSlot==(*it).cmd() || pbSlot==(*it).cmd() )
+                    {
+                        kDebug() << "Searching for slot ok; was searching for " << (*it).origPos() << endl;
+                        rightSlot=true;
+                    }
+                    else
+                    {
+                        kDebug() << "Was searching for a slot, but we've found another one: index: " << (*it).origPos() << endl;
+                        rightSlot=false;
+                    }
+                    continue;
                 }
-                else
+                if(rightSlot && (*it).cmd()==cmd)
                 {
-//                     kDebug() << "Was searching for a slot, but we've found another one: index: " << (*it).origPos() << endl;
-                    rightSlot=false;
+                    command=(*it);
+                    kDebug() << "Found correct slot command: " << command.origPos() << endl;
+                    break;
                 }
-                continue;
             }
-            if(rightSlot && (*it).cmd()==cmd)
-            {
-                command=(*it);
-//                 kDebug() << "Found correct slot command: " << command.origPos() << endl;
-                break;
-            }
         }
     } else command=CommandsList::instance()->searchCmd(cmd);
     if(command.isNull())


More information about the kmobiletools mailing list