src/include/common/spds/SyncMLProcessor.h

00001 
00019 #ifndef INCL_SYNCML_PROCESSOR
00020     #define INCL_SYNCML_PROCESSOR
00021 
00023     #include "base/util/ArrayList.h"
00024     #include "base/util/XMLProcessor.h"
00025     #include "spds/SyncSource.h"
00026     #include "spds/SyncItem.h"
00027     #include "spds/SyncItemStatus.h"
00028     #include "syncml/core/TagNames.h"
00029     #include "syncml/core/ObjectDel.h"
00030     #include "syncml/parser/Parser.h"
00031     #include "spds/SyncReport.h"
00032 
00033     /*
00034      * This class is responsible for the processing of the incoming messages.
00035      */
00036 
00037     class __declspec(dllexport) SyncMLProcessor : public XMLProcessor {
00038 
00039     private:
00040         
00041         /*
00042          * It include the common part of getSyncHdrStatusCode and getAlertStatusCode
00043          */
00044         int getStatusCode(SyncBody* syncBody, SyncSource* source, const char* commandName) EXTRA_SECTION_01;        
00045         /*
00046          * Returns the status code for the SyncHeader command included
00047          * in the message sent by the client.
00048          *
00049          * @param syncBody - the SyncBody content
00050          */
00051         int getSyncHeaderStatusCode(Status* s) EXTRA_SECTION_01; 
00052         /*
00053          * Returns the status code for the Alert relative to the given source.
00054          *
00055          * @param syncBody - the SyncBody content
00056          * @param sourceName - the name of the source
00057          */
00058         int getAlertStatusCode(Status* status, const char*  sourceName) EXTRA_SECTION_01;       
00059         
00060         /*
00061         * Return the command of the given commandName
00062         */
00063         AbstractCommand* getCommand(SyncBody* syncBody, const char* commandName, int index) EXTRA_SECTION_01;
00064         
00065          /*
00066         * To get a generic array element. It returns the <index> arrayElement it founds.
00067         * 0-based.
00068          */
00069         ArrayElement* getArrayElement(ArrayList* list, int index) EXTRA_SECTION_01;
00070 
00071     public:
00072 
00073         /*
00074          * Constructor
00075          */
00076         SyncMLProcessor();
00077 
00078         /*
00079         * Process a generic syncml message and return a SyncML object
00080         */
00081         SyncML* processMsg(char*  msg) EXTRA_SECTION_01;
00082 
00083         /*
00084          * Processes the initialization response. Returns 0 in case of success, an
00085          * error code in case of error.
00086          *
00087          * @param msg the response from the server
00088          */
00089         int processInitResponse(SyncSource& source, SyncML* syncml, Alert* alert) EXTRA_SECTION_01;
00090 
00091         int processSyncHdrStatus(SyncML* syncml) EXTRA_SECTION_01;
00092         int processAlertStatus(SyncSource& source, SyncML* syncml, ArrayList* alerts) EXTRA_SECTION_01;
00093 
00094         int processServerAlert(SyncSource& source, SyncML* syncml) EXTRA_SECTION_01;
00095         /*
00096         * Get the chal from a syncBody object. It is used to get the auth type and next nonce if needed
00097         */
00098         Chal* getChal(SyncBody* syncBody) EXTRA_SECTION_01;
00099         
00100         /*
00101         * Get server credential. It is used by the SyncManager to get the server credentials and check them
00102         */
00103         Cred* getServerCred(SyncHdr* syncHdr) EXTRA_SECTION_01;
00104         
00105 
00106         /*
00107          * Process the SyncBody and looks for the item status of the sent items.
00108          * It calls the setItemStatus method of the sync source. 
00109          */
00110         int processItemStatus(SyncSource& source, SyncBody* syncBody) EXTRA_SECTION_01;
00111 
00112         /*
00113          * Processes the response and get the Sync command of the given source
00114          *
00115          * @param source the source
00116          * @param syncml the syncML Object the response from the server
00117          */
00118         Sync* processSyncResponse(SyncSource& source, SyncML* syncml) EXTRA_SECTION_01;
00119 
00120         /*
00121          * Processes the map message response. Returns 0 in case of success. 
00122          * Currently it return always 0. TBD
00123          *
00124          * @param source the source
00125          * @param msg the response from the server
00126          */
00127         int processMapResponse(SyncSource& source, SyncBody* syncBody) EXTRA_SECTION_01;
00128 
00129         /*
00130          * Returns the SyncHeader/RespURI element of the given message. If the element is not
00131          * found it returns NULL. The returned respURI is allocated with the new operator
00132          * and must be discarded with delete by the caller.
00133          *
00134          * @param msg - the SyncHdr message - NOT NULL
00135          */
00136         const char* getRespURI(SyncHdr* msg) EXTRA_SECTION_01;
00137 
00138         /*
00139          * Returns an ArrayList containing the command given by commandName. It uses the getCommand method
00140          */
00141         ArrayList* getCommands(SyncBody* syncBody, const char* commandName) EXTRA_SECTION_01;
00142        
00143         /* To retrieve a (NULL terminated) list of source names from list of Alert commands from server.
00144          * @return: a new array of source names (NULL terminated) - must be freed by the caller.
00145          */
00146         char** getSortedSourcesFromServer(SyncML* syncml, int sourcesNumber);
00147 
00148         /* To retrieve a Sync pointer from ArrayList of Sync objects. 
00149          * It gets the order like the server sends
00150          */        
00151         Sync* getSyncResponse(SyncML* syncml, int index);
00152     };
00153 
00155 #endif

Generated on Fri Apr 27 12:29:18 2007 for Funambol C++ Client Library by  doxygen 1.5.2