00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef INCL_CTP_MESSAGE
00037 #define INCL_CTP_MESSAGE
00038
00040
00041
00042 #include "base/fscapi.h"
00043 #include "syncml/core/SyncNotification.h"
00044 #include "base/util/ArrayList.h"
00045
00046 #include "push/CTPParam.h"
00047
00048 BEGIN_NAMESPACE
00049
00053 #define CM_AUTH 0x01
00054 #define CM_READY 0x02
00055 #define CM_BYE 0x03
00056
00060 #define ST_OK 0x20
00061 #define ST_JUMP 0x37
00062 #define ST_ERROR 0x50
00063 #define ST_NOT_AUTHENTICATED 0x41 // Server auth failed, nonce param received
00064 #define ST_UNAUTHORIZED 0x42 // Server auth failed at 1st try, nonce param received
00065 #define ST_FORBIDDEN 0x43 // No Server auth, no nonce param
00066 #define ST_SYNC 0x29
00067 #define ST_RETRY 0x53
00068
00069
00070 #define MAX_MESSAGE_SIZE 256
00071 #include "base/globalsdef.h"
00072
00073 class CTPMessage {
00074
00075 private:
00076
00082 SyncNotification* np;
00083
00084
00091 int32_t packageLength;
00092
00097 int32_t bufferLength;
00098
00113 char* buffer;
00117 int32_t fromLength;
00118 void setFromLength(int v) { fromLength = v; }
00119
00124 char* from;
00125
00126
00131 int8_t protocolVersion;
00132
00151 int8_t genericCommand;
00152
00156 void initialize();
00157
00158 public:
00159
00160
00166 ArrayList params;
00167
00171 CTPMessage();
00172
00178 CTPMessage(const char* package, int maxPackageLen = 0);
00179
00183 ~CTPMessage();
00184
00191 int32_t parse(const char* package, int32_t maxPackageLen = 0);
00192
00198 char* toByte();
00199
00204 void setPackageLength(int32_t v) { packageLength = v; }
00205
00209 int getPackageLength() { return packageLength; }
00210
00214 void setBufferLength(int32_t v) { bufferLength = v; }
00215
00219 int32_t getBufferLength() { return bufferLength; }
00220
00225 char* getBuffer() { return buffer; }
00226
00230 void setGenericCommand(int8_t c) { genericCommand = c; }
00231
00235 int8_t getGenericCommand() { return genericCommand; }
00236
00240 void setProtocolVersion(int8_t c) { protocolVersion = c; }
00241
00245 int8_t getProtocolVersion() { return protocolVersion; }
00246
00250 SyncNotification* getSyncNotification() { return np; }
00251
00255 int32_t getFromLength() { return fromLength; }
00256
00261 char* getFrom() { return from; }
00262
00267 void addParam(CTPParam* p);
00268 };
00269
00270
00271
00272 END_NAMESPACE
00273
00275 #endif