1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
/*
Kopete Oscar Protocol
oscarmessage.h - Oscar Message Object
Copyright (c) 2005 Matt Rogers <mattr@kde.org>
Copyright (c) 2005 Conrad Hoffmann <conrausch@gmx.de>
Copyright (c) 2005 Gustavo Pichorim Boiko <gustavo.boiko@kdemail.net>
Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
*************************************************************************
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
*************************************************************************
*/
#ifndef _OSCARMESSAGE_H_
#define _OSCARMESSAGE_H_
#include <tqglobal.h>
#include <tqstring.h>
#include <tqcstring.h>
#include <tqdatetime.h>
#include "kopete_export.h"
#include "oscartypes.h"
class QTextCodec;
namespace Oscar
{
/**
* This class is responsible for holding all the details
* of a message and includes the following:
* \li channel ( type )
* \li encoding
*/
class KOPETE_EXPORT Message
{
public:
enum {
Normal = 0x0000,
AutoResponse = 0x0001,
WWP = 0x0002,
EMail = 0x0004,
ChatRoom = 0x0008,
Request = 0x0100,
StatusMessageRequest = 0x0200
};
enum Encoding {
UserDefined,
UTF8,
UCS2
};
Message();
Message( Encoding messageEncoding, const TQByteArray& messageText, int channel, int properties, TQDateTime timestamp );
Message( Encoding messageEncoding, const TQCString& messageText, int channel, int properties, TQDateTime timestamp );
Message( Encoding messageEncoding, const TQString& messageText, int channel, int properties, TQDateTime timestamp, TQTextCodec* codec = 0 );
/** Get the sender of the message */
TQString sender() const;
/** Set the sender of the message */
void setSender( const TQString& sender );
/** Get the receiver of the message */
TQString receiver() const;
/** Set the receiver of the message */
void setReceiver( const TQString& receiver);
/** get the message text */
TQString text( TQTextCodec* codec ) const;
/** set the message text */
void setText( Encoding newEncoding, const TQString& newText, TQTextCodec* codec = 0);
/** get the message text as a bytearray for decoding */
TQByteArray textArray() const;
/** set the message text as a bytearray for decoding */
void setTextArray( const TQByteArray& newTextArray );
/** set the mesasge text as a bytearray for decoding */
void setTextArray( const TQCString& newTextArray );
/** get the message properties */
int properties() const;
/** ask about a specific property */
bool hasProperty( int prop ) const;
/** add a property to the message */
void addProperty( int prop );
/** get the channel ( type ) of the message */
int type() const;
/** set the channel ( type ) of the message */
void setType( int newType );
/** get the timestamp of the message */
TQDateTime timestamp() const;
/** set the timestamp of the message */
void setTimestamp( TQDateTime ts );
/** get the ICBM cookie of the message */
TQByteArray icbmCookie() const;
/** set the ICBM cookie of the message */
void setIcbmCookie( const TQByteArray& cookie );
/** get the protocol version (channel 2 messages only) */
int protocolVersion() const;
/** prepare for handling of different protocol versions */
void setProtocolVersion( int version );
/** get the channel 2 counter value of the message */
int channel2Counter() const; // channel 2 message have an additional counter whose value needs be kept in a request response
/** set the channel 2 counter value */
void setChannel2Counter( int value );
/** get the message (content) type */
int messageType() const;
/** set the message (content) type */
void setMessageType( int type );
/** get the exchange for the chat room this message is for */
Oscar::WORD exchange() const;
/** set the exchange for the chat room this message is for */
void setExchange( Oscar::WORD );
/** get the chat room that this message is for */
TQString chatRoom() const;
/** set the chat room that this message is for */
void setChatRoom( const TQString& );
/** get the message encoding */
Encoding encoding() const;
/** set the message encoding */
void setEncoding( Encoding newEncoding );
operator bool() const;
private:
//TODO d-pointer
TQString m_sender;
TQString m_receiver;
int m_channel;
int m_properties;
int m_messageType;
int m_protocolVersion;
int m_channel2Counter;
TQByteArray m_icbmCookie;
TQByteArray m_textArray;
TQDateTime m_timestamp;
Oscar::WORD m_exchange;
TQString m_chatRoom;
Encoding m_encoding;
};
}
//kate: indent-mode csands; auto-insert-doxygen on; tab-width 4;
#endif
|