[kmobiletools] KDE/kdepim/kmobiletools

Marco Gulino marco at kmobiletools.org
Fri Jun 22 21:29:09 CEST 2007


SVN commit 679016 by gulino:

Adding Destination header too.
Clearing Sender when doing setSender();


 M  +17 -14    kmobiletools/libkmobiletools/sms.cpp  
 M  +7 -6      kmobiletools/libkmobiletools/sms.h  
 M  +3 -5      tests/testlibkmobiletools/testlibkmobiletools.cpp  


--- trunk/KDE/kdepim/kmobiletools/kmobiletools/libkmobiletools/sms.cpp #679015:679016
@@ -77,6 +77,10 @@
         return rv;
     }
 };
+class DestinationPrivate {
+public:
+    DestinationPrivate() {}
+};
 
 Sender::Sender() : KMime::Headers::Generics::Structured(), d(new SenderPrivate) {
 }
@@ -121,13 +125,11 @@
     return d->numbers;
 }
 
-/*Destination::Destination() : KMime::Headers::Generics::Structured() {
+Destination::Destination() : Sender(), d(new DestinationPrivate) {
 }
+const char *Destination::type() const { return "Destination"; }
 
-Destination::~Destination() {}
 
-const char *Destination::type() { return "Destination"; }
-*/
 SMS::SMS() : KMime::Content(),
     d(new SMSPrivate(this) )
 {
@@ -409,8 +411,8 @@
     if(h) ret+= h->as7BitString()+'\n';
     h=sender();
     if(h) ret+= h->as7BitString()+'\n';
-//     h=to();
-//     if(h) ret+= h->as7BitString()+'\n';
+    h=destination();
+    if(h) ret+= h->as7BitString()+'\n';
     return ret + Content::assembleHeaders();
 }
 
@@ -422,28 +424,29 @@
 void SMS::setSender(const QString& number, const QString &displayname) {
     Sender *fromh=sender();
     if(!fromh) fromh=new Sender();
+    fromh->clear();
     fromh->addNumber(number, displayname);
     setHeader(fromh);
 }
-/*
-void SMS::addTo(const QString& number, const QString &displayname) {
-    Destination * h=to();
+
+void SMS::addDestination(const QString& number, const QString &displayname) {
+    Destination * h=destination();
     if(!h) {
         h=new Destination;
         setHeader(h);
     }
-    h->addAddress(number.toUtf8(), displayname);
+    h->addNumber(number.toUtf8(), displayname);
 }
-*/
+
 Sender *SMS::sender() const
 {
     return dynamic_cast<Sender*>(const_cast<SMS*>(this)->getHeaderByType("Sender") );
 }
-/*
-KMime::Headers::To *SMS::to() const
+
+Destination *SMS::destination() const
 {
     return dynamic_cast<Destination*>(const_cast<SMS*>(this)->getHeaderByType("Destination") );
-}*/
+}
 
 QString SMS::getFrom() const
 {
--- trunk/KDE/kdepim/kmobiletools/kmobiletools/libkmobiletools/sms.h #679015:679016
@@ -33,6 +33,7 @@
 
 class SMSPrivate;
 class SenderPrivate;
+class DestinationPrivate;
 namespace KMobileTools {
 typedef QHash<QString,QString> PhoneNumbers;
 
@@ -51,14 +52,14 @@
 private:
     SenderPrivate *const d;
 };
-/*class KMOBILETOOLS_EXPORT Destination : public KMime::Headers::Generics::Structured
+class KMOBILETOOLS_EXPORT Destination : public Sender
 {
 public:
     Destination();
-    virtual ~Destination();
-    virtual const char *type();
+    virtual const char *type() const;
+private:
+    DestinationPrivate *const d;
 };
-*/
 
 class KMOBILETOOLS_EXPORT SMS : public KMime::Content
 {
@@ -115,10 +116,10 @@
     // Headers
     KMime::Headers::Date *date() const;
    Sender *sender() const;
-//    Destination *to()   const;
+   Destination *destination()   const;
 
    void setSender(const QString& number, const QString &displayname=QString() );
-//    void addTo  (const QString& number, const QString &displayname=QString() );
+   void addDestination(const QString& number, const QString &displayname=QString() );
 
 protected:
     virtual QByteArray assembleHeaders();
--- trunk/KDE/kdepim/kmobiletools/tests/testlibkmobiletools/testlibkmobiletools.cpp #679015:679016
@@ -71,12 +71,10 @@
     out << "Raw content: " << sms->body() << endl;
     sms->setDateTime( KDateTime(QDate(2002,7,2), QTime(21,12,13) ) );
     out << "Set date time to " << sms->getDateTime().toString() << endl;
-    sms->setSender( "test at kde.org", "Destination Name");
+    sms->setSender( "+39123456789", "Sender Name");
     out << "Added numbers: Sender=" << sms->sender()->as7BitString() << endl;
-//     for(int i=0; i<sms->to()->prettyAddresses().size(); i++)
-//         out << endl << sms->to()->prettyAddresses().at(i);
-//     out << "; to=";
-//     sms->to()->prettyAddresses();
+    sms->addDestination("+22123456789", "Destination Name #1");
+    sms->addDestination("+33345678923", "Destination Name #2 testing some special chars.. #@1\"<>, ");
     out << endl;
     sms->assemble();
     out << "****************** SMS Serialization ******************\n"


More information about the kmobiletools mailing list