Qtopia Home - Classes - Hierachy - Annotated - Functions - Licenses - Reference

smsmessage.h

This is the verbatim text of the smsmessage.h include file. It is provided only for illustration; the copyright remains with Trolltech.


/**********************************************************************
** Copyright (C) 2000-2005 Trolltech AS.  All rights reserved.
**
** This file is part of the Qtopia Environment.
**
** Licensees holding a valid license agreement from Trolltech or any of its
** authorized distributors may use this file in accordance with
** the License Agreement provided with the Licensed Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
**   information about Trolltech's Commercial License Agreements.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/

#ifndef SMS_MESSAGE_H 
#define SMS_MESSAGE_H

#include <qstring.h>
#include <qdatetime.h>
#include <qdatastream.h>
#include <qcstring.h>
#include <qvaluelist.h>

#include <qtopia/quuid.h>

#include "gsm.h"

using namespace GSM;

class SMSMessagePartPrivate;
class SMSMessagePrivate;
class CBSMessagePrivate;
class QTextCodec;


class SMSMessagePart
{
public:
    SMSMessagePart();
    SMSMessagePart( const QString& text );
    SMSMessagePart( const QString& mimeType, const QByteArray& data );
    SMSMessagePart( const QString& mimeType, const QByteArray& data, uint position );
    SMSMessagePart( const SMSMessagePart& part );
    ~SMSMessagePart();

    SMSMessagePart& operator=( const SMSMessagePart& part );

    bool isText() const;
    QString text() const;
    QString mimeType() const;
    const QByteArray& data() const;
    uint position() const;

    friend QDataStream &operator>>( QDataStream &, SMSMessagePart &);
    friend QDataStream &operator<<( QDataStream &, const SMSMessagePart &);

private:
    SMSMessagePartPrivate *d;
};


class SMSMessage
{
    friend class SMSRequestAt;
    friend class SMSDeliverMessage;
    friend class SMSSubmitMessage;
public:
    SMSMessage();
    SMSMessage(const SMSMessage &);
    SMSMessage(const QString &recipient, const QString &txt, bool replyRequest = FALSE);
    ~SMSMessage();

    SMSMessage& operator=(const SMSMessage &);

    void setText(const QString &);
    QString text() const;

    void setTextCodec(QTextCodec *codec);
    QTextCodec *textCodec() const;

    void setForceGsm(bool force);
    bool forceGsm() const;

    void setBestScheme(SMSDataCodingScheme);
    SMSDataCodingScheme bestScheme() const;

    void setRecipient(const QString &);
    QString recipient() const;

    void setSender(const QString &);
    QString sender() const;

    void setServiceCenter(const QString &);
    QString serviceCenter() const;

    void setReplyRequest(bool on );
    bool replyRequest() const;

    void setStatusReportRequested(bool on );
    bool statusReportRequested() const;

    void setValidityPeriod(uint minutes);
    uint validityPeriod() const;

    void setGsmValidityPeriod(uint value);
    uint gsmValidityPeriod() const;

    void setTimestamp(const QDateTime &);
    QDateTime timestamp() const;

    void setHeaders(const QByteArray& value);
    const QByteArray& headers() const;

    void clearParts();
    void addPart( const SMSMessagePart& part );
    void addParts( const QValueList<SMSMessagePart>& parts );
    QValueList<SMSMessagePart> parts() const;

    enum MessageType {
	Normal, CellBroadCast, StatusReport
    };
    
    MessageType messageType() const;
   
    void computeSize( uint& numMessages, uint& spaceLeftInLast ) const;

    int destinationPort() const;
    void setDestinationPort(int value);

    int sourcePort() const;
    void setSourcePort(int value);

    QByteArray applicationData() const;
    void setApplicationData(const QByteArray& value);

    friend QDataStream &operator>>( QDataStream &, SMSMessage &);
    friend QDataStream &operator<<( QDataStream &, const SMSMessage &);

protected:
    void setMessageType(MessageType);

private:
    SMSMessagePrivate *d;

    int findPart( const QString& mimeType ) const;
    void removeParts( const QString& mimeType );
    void setFragmentHeader( uint refNum, uint part, uint numParts,
			    SMSDataCodingScheme scheme );
    void unpackHeaderParts();
};

class CBSMessage
{
public:
    CBSMessage();
    CBSMessage(const CBSMessage &);
    ~CBSMessage();

    enum GeographicalScope
    {
	CellWide	    = 0,
	PLMNWide	    = 1,
	LocationAreaWide    = 2,
	CellWide2	    = 3
    };

    enum Language
    {
	German	    = 0,
	English	    = 1,
	Italian	    = 2,
	French	    = 3,
	Spanish	    = 4,
	Dutch	    = 5,
	Swedish	    = 6,
	Danish	    = 7,
	Portuguese  = 8,
	Finnish	    = 9,
	Norwegian   = 10,
	Greek	    = 11,
	Turkish	    = 12
    };

    CBSMessage& operator=(const CBSMessage &);

    uint messageCode() const;
    void setMessageCode( uint code );

    GeographicalScope scope() const;
    void setScope( GeographicalScope scope );

    uint updateNumber() const;
    void setUpdateNumber( uint num );

    uint channel() const;
    void setChannel( uint chan );

    Language language() const;
    void setLanguage( Language lang );

    uint page() const;
    void setPage( uint page );

    uint numPages() const;
    void setNumPages( uint npages );

    void setText(const QString &);
    QString text() const;

    friend QDataStream &operator>>( QDataStream &, CBSMessage &);
    friend QDataStream &operator<<( QDataStream &, const CBSMessage &);

    bool operator==( const CBSMessage& other ) const;
    bool operator!=( const CBSMessage& other ) const;

    void print();

private:
    CBSMessagePrivate *d;
};

class PDUMessage
{
public:
    PDUMessage();
    PDUMessage(const QString &);
    ~PDUMessage();

    void fromHex(const QString &);
    QString toHex() const;

    void setBit(int b, bool on);
    void setBits(int offset, int len, int val);
    void setOctet(char *, uchar c);
    
    bool bit(int b);
    unsigned char bits(int offset, int len);
    unsigned char octet();
    
    void setAddress(const QString &, bool SCAddress);
    QString address(bool SCAddress);

    uint addressLength() const;
    
    QDateTime timeStamp();

    void setUserData(const QString &txt, SMSDataCodingScheme scheme, QTextCodec *codec, const QByteArray& headers );
    QString userData(SMSDataCodingScheme scheme, QTextCodec *codec, QByteArray *& headers, bool hasHeaders, bool implicitLength);

    SMSMessageType messageType();

    void reset() { mOffset = mData; }

    bool needOctets( uint num ) const { return ((uint)(mDataEnd - mOffset) >= num); }

    void done() { mDataEnd = mOffset; }

protected:
    char *mOffset;
    char *mDataEnd;

private:
    char *mData;
};


class SMSSubmitMessage: public PDUMessage
{
public:
    SMSSubmitMessage(const SMSMessage &m);

};

class SMSDeliverMessage: public PDUMessage
{
public:
    SMSDeliverMessage(const QString &pdu);

    SMSMessage unpack(QTextCodec *codec=0);

};

class CBSDeliverMessage: public PDUMessage
{
public:
    CBSDeliverMessage(const QString &pdu);

    CBSMessage unpack(QTextCodec *codec=0);

};

#endif


Copyright © 2005 Trolltech Trademarks
Qtopia version 2.2.0