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 #include "base/fscapi.h"
00041 #include "syncml/core/SyncNotification.h"
00042 #include "base/util/ArrayList.h"
00043
00044 #include "push/CTPParam.h"
00045
00046
00047 using namespace std;
00048
00052 #define CM_AUTH 0x01
00053 #define CM_READY 0x02
00054 #define CM_BYE 0x03
00055
00059 #define ST_OK 0x20
00060 #define ST_JUMP 0x37
00061 #define ST_ERROR 0x50
00062 #define ST_NOT_AUTHENTICATED 0x41 // Server auth failed, nonce param received
00063 #define ST_UNAUTHORIZED 0x42 // Server auth failed at 1st try, nonce param received
00064 #define ST_FORBIDDEN 0x43 // No Server auth, no nonce param
00065 #define ST_SYNC 0x29
00066 #define ST_RETRY 0x53
00067
00068
00069 #define MAX_MESSAGE_SIZE 256
00070 #include "base/globalsdef.h"
00071
00072 BEGIN_NAMESPACE
00073
00074
00075 class CTPMessage {
00076
00077 private:
00078
00084 SyncNotification* np;
00085
00086
00093 int32_t packageLength;
00094
00099 int32_t bufferLength;
00100
00115 char* buffer;
00119 int32_t fromLength;
00120 void setFromLength(int v) { fromLength = v; }
00121
00126 char* from;
00127
00128
00133 int8_t protocolVersion;
00134
00153 int8_t genericCommand;
00154
00158 void initialize();
00159
00160 public:
00161
00162
00168 ArrayList params;
00169
00173 CTPMessage();
00174
00180 CTPMessage(const char* package, int maxPackageLen = 0);
00181
00185 ~CTPMessage();
00186
00193 int32_t parse(const char* package, int32_t maxPackageLen = 0);
00194
00200 char* toByte();
00201
00206 void setPackageLength(int32_t v) { packageLength = v; }
00207
00211 int getPackageLength() { return packageLength; }
00212
00216 void setBufferLength(int32_t v) { bufferLength = v; }
00217
00221 int32_t getBufferLength() { return bufferLength; }
00222
00227 char* getBuffer() { return buffer; }
00228
00232 void setGenericCommand(int8_t c) { genericCommand = c; }
00233
00237 int8_t getGenericCommand() { return genericCommand; }
00238
00242 void setProtocolVersion(int8_t c) { protocolVersion = c; }
00243
00247 int8_t getProtocolVersion() { return protocolVersion; }
00248
00252 SyncNotification* getSyncNotification() { return np; }
00253
00257 int32_t getFromLength() { return fromLength; }
00258
00263 char* getFrom() { return from; }
00264
00269 void addParam(CTPParam* p);
00270 };
00271
00272
00273
00274 END_NAMESPACE
00275
00277 #endif