src/include/common/push/CTPMessage.h

00001 /*
00002  * Funambol is a mobile platform developed by Funambol, Inc. 
00003  * Copyright (C) 2003 - 2007 Funambol, Inc.
00004  * 
00005  * This program is free software; you can redistribute it and/or modify it under
00006  * the terms of the GNU Affero General Public License version 3 as published by
00007  * the Free Software Foundation with the addition of the following permission
00008  * added to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED
00009  * WORK IN WHICH THE COPYRIGHT IS OWNED BY FUNAMBOL, FUNAMBOL DISCLAIMS THE
00010  * WARRANTY OF NON INFRINGEMENT  OF THIRD PARTY RIGHTS.
00011  * 
00012  * This program is distributed in the hope that it will be useful, but WITHOUT
00013  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00014  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 
00015  * details.
00016  * 
00017  * You should have received a copy of the GNU Affero General Public License
00018  * along with this program; if not, see http://www.gnu.org/licenses or write to
00019  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00020  * MA 02110-1301 USA.
00021  * 
00022  * You can contact Funambol, Inc. headquarters at 643 Bair Island Road, Suite
00023  * 305, Redwood City, CA 94063, USA, or at email address info@funambol.com.
00024  * 
00025  * The interactive user interfaces in modified source and object code versions
00026  * of this program must display Appropriate Legal Notices, as required under
00027  * Section 5 of the GNU Affero General Public License version 3.
00028  * 
00029  * In accordance with Section 7(b) of the GNU Affero General Public License
00030  * version 3, these Appropriate Legal Notices must retain the display of the
00031  * "Powered by Funambol" logo. If the display of the logo is not reasonably
00032  * feasible for technical reasons, the Appropriate Legal Notices must display
00033  * the words "Powered by Funambol".
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

Generated on Fri Jul 25 15:04:15 2008 for Funambol C++ Client Library by  doxygen 1.5.1