00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef SMSJOB
00023 #define SMSJOB
00024
00025 #include <libkmobiletools/engine.h>
00026 #include "at_jobs.h"
00027 #include "atabilities.h"
00028
00029
00032 class ATSMS : public KMobileTools::SMS
00033 {
00034 public:
00035 ATSMS(const QStringList & numbers, const QString & text );
00036 ATSMS(const QStringList & numbers, const QString & text, const KDateTime & datetime );
00037 virtual ~ATSMS();
00039 bool isMultiPart() { return concatenated; }
00041
00044 uint getReferenceNumber() { return referenceNumber; }
00050 void merge( ATSMS *asms );
00052
00055 virtual QString getText() const;
00059 bool hasPart( uint num ) { return multiPart && multiPart->at(num); }
00063 uint getSequenceNumber() { return sequenceNumber-1; }
00064 static ATSMS *fromSMS(KMobileTools::SMS *);
00065 protected:
00066 void setMultiPart( uint refNumber, uint seqNumber, uint mesCount);
00067 bool concatenated;
00068 uint referenceNumber, sequenceNumber, maxMessages;
00069 Q3PtrVector<ATSMS> *multiPart;
00070 friend class SMSDecoder;
00071 };
00072
00073
00082 class SMSDecoder
00083 {
00084 public:
00086 SMSDecoder() {}
00087 ATSMS *decodeSMS( const QString &abuffer, bool incoming );
00088 ATSMS *decodeSMS( const QString &abuffer, uint index, uint stat );
00089 protected:
00090 inline bool hasMR() { return HAS_MR(SMTL); }
00091 inline bool hasTimeStamp() { return HAS_TIMESTAMP(SMTL); }
00092 KDateTime datetime;
00093 QString message;
00094 int timezone;
00095 uint referenceNumber, sequenceNumber, maxMessages;
00096 bool concatenated;
00097 uint SMTL, DCS;
00098 uint bitsLeft, userDataLen;
00099 uint bitBuffer;
00100 uint getByte();
00101 inline void skipBytes( uint cnt ) { buffer.remove( 0, 2*cnt ); }
00102 QString buffer;
00103 void parseUserDataHeader();
00104 uint getDecimal();
00105 QString getNumber( uint len );
00106 uint get7Bit();
00107 QString getUserMessage();
00108 int charset;
00109 };
00110
00117 class SMSEncoder
00118 {
00119 public:
00120 SMSEncoder( const QStringList &, const QString & ) {}
00121 SMSEncoder( const QString &, const QString & );
00122 int getMessageCount() { return 0; }
00123 enum encodingType
00124 { SevenBit=0x1, EightBit=0x2, UCS2=0x4 };
00125 static QString encodeText(const QString &o_text, int encodingType);
00126 static QString encodeNumber( const QString &_number );
00127 static QString encodeSMS( const QString &number, const QString &message );
00128 protected:
00129
00130 };
00131
00137 class FetchSMS : public kmobiletoolsATJob
00138 {
00139 public:
00140 FetchSMS( KMobileTools::Job *pjob, KMobileTools::SMS::SMSType type, KMobileTools::SerialManager *device, bool lastSlot, AT_Engine* parent = 0 );
00141 SMSList *smsList;
00142 JobType type() { return KMobileTools::Job::fetchSMS; }
00143 bool last() { return b_last;}
00144 protected:
00145 SMSDecoder decoder;
00146 KMobileTools::SMS::SMSType fetchType;
00147 int index, stat;
00148 void run();
00149 bool b_last;
00150 virtual void addToList( ATSMS *sms );
00151 };
00152
00159 class UpdateSMS : public FetchSMS
00160 {
00161 public:
00162 UpdateSMS( KMobileTools::Job *pjob, SMSList *smsList, KMobileTools::SMS::SMSType type, KMobileTools::SerialManager *device, AT_Engine* parent = 0 );
00163 JobType type() { return KMobileTools::Job::fetchSMS; }
00164 protected:
00165 virtual void addToList( ATSMS *sms );
00166 };
00167
00168
00169 class SendStoredSMS : public kmobiletoolsATJob
00170 {
00171 public:
00172 SendStoredSMS( KMobileTools::Job *pjob, KMobileTools::SMS *sms, KMobileTools::SerialManager *device, AT_Engine* parent = 0 );
00173 JobType type() { return KMobileTools::Job::sendStoredSMS; }
00174 protected:
00175 void run();
00176 KMobileTools::SMS *p_sms;
00177 };
00178
00179
00183 class SendSMS : public kmobiletoolsATJob
00184 {
00185 public:
00186 SendSMS( KMobileTools::Job *pjob, KMobileTools::SMS *sms, KMobileTools::SerialManager *device, AT_Engine* parent = 0 );
00187 SendSMS( KMobileTools::Job *pjob, const QString& number, const QString& text, KMobileTools::SerialManager *device, AT_Engine* parent = 0 );
00188 JobType type() { return KMobileTools::Job::sendSMS; }
00189 bool succeeded() { return true; }
00190 protected:
00191 void run();
00192 bool pdu;
00193 bool sendSingleSMS(const QString &number, const QString &text);
00194 ATSMS *p_sms;
00195 };
00196
00200 class StoreSMS : public kmobiletoolsATJob
00201 {
00202 public:
00203 StoreSMS( KMobileTools::Job *pjob, KMobileTools::SMS *sms, KMobileTools::SerialManager *device, AT_Engine* parent = 0 );
00204 StoreSMS( KMobileTools::Job *pjob, const QString &number, const QString &text, KMobileTools::SerialManager *device, AT_Engine* parent = 0 );
00205 JobType type() { return KMobileTools::Job::storeSMS; }
00206 bool succeeded() { return true; }
00207 int savedIndex() { return i_savedIndex;}
00208 protected:
00209 void run();
00210 int i_savedIndex;
00211 int storeSingleSMS(const QString &number, const QString &text);
00212 bool pdu;
00213 ATSMS *p_sms;
00214 };
00215
00216
00220 class DeleteSMS : public kmobiletoolsATJob
00221 {
00222 public:
00223 DeleteSMS( KMobileTools::Job *pjob, KMobileTools::SMS *sms, KMobileTools::SerialManager *device, AT_Engine* parent = 0 );
00224 JobType type() { return KMobileTools::Job::delSMS; }
00225 bool succeeded() { return true; }
00226 KMobileTools::SMS *sms() { return p_sms;}
00227 protected:
00228 KMobileTools::SMS *p_sms;
00229 void run();
00230 bool b_succeeded;
00231 };
00232
00233
00234
00235 #endif