Home | History | Annotate | Download | only in hdr
      1 /*
      2  * Copyright (C) 2014 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef SYNCML_DM_WBXMLREADER_H
     18 #define SYNCML_DM_WBXMLREADER_H
     19 
     20 #ifndef __cplusplus
     21 #error "This is a C++ header file; it requires C++ to compile."
     22 #endif
     23 
     24 #include "SyncML_DM_Reader.H"
     25 #include "SyncML_DM_FileHandle.H"
     26 #include "syncml_dm_data_types.h"
     27 #include "dm_tree_typedef.h"
     28 
     29 class SyncML_DM_WBXMLReader : public SyncML_DM_Reader
     30 {
     31 
     32 public:
     33 
     34   /* Class constructor */
     35   SyncML_DM_WBXMLReader(DMFileHandler* fileHandle) : SyncML_DM_Reader(fileHandle) { }
     36 
     37   /* Reads a byte of data from the file handle */
     38   virtual SYNCML_DM_RET_STATUS_T readByte(UINT8 *bYte);
     39 
     40   /* Reads an opaque encoded block of data from the file handle
     41    * returning the length and a buffer holding the data.
     42        */
     43   SYNCML_DM_RET_STATUS_T readOpaque(DMBuffer *pBuffer);
     44   SYNCML_DM_RET_STATUS_T readOpaque(UINT8 *pBuffer, UINT8 nSize);
     45 
     46   /* Reads a node from the file handle
     47    *
     48    * The stopByte is defined by the calling function and its pointer is passed.
     49    */
     50   virtual SYNCML_DM_RET_STATUS_T readNode(DMAddNodeProp* node,
     51                                           UINT8* stopByte);
     52 
     53   /* Read the WBXML string table header from the file handle */
     54   SYNCML_DM_RET_STATUS_T readHeader();
     55 
     56   /* Read a log record from the RW plugin log file */
     57   SYNCML_DM_RET_STATUS_T readOneLogRecord(SYNCML_DM_PLUGIN_COMMAND_T* cmdType,
     58                                           DMBuffer  *cmdURI,
     59                                           SYNCML_DM_PLUGIN_COMMAND_ATTRIBUTE_T * attribute,
     60                                           DMAddNodeProp* props,
     61                                           UINT8* stopByte);
     62 
     63   /* Read a log record from the commit log file */
     64   SYNCML_DM_RET_STATUS_T readOneCommitLogRecord(SYNCML_DM_COMMAND_T* cmdType,
     65                                           DMBuffer  *sourceFileName,
     66                                           DMBuffer  *targetFileName,
     67                                           UINT8* stopByte);
     68     /* Operators to allocate and delete memory for operation */
     69   void* operator new(size_t sz);
     70   void operator delete(void* buf);
     71 
     72 private:
     73   SYNCML_DM_RET_STATUS_T skipTag(UINT8* pByte);
     74 
     75   SYNCML_DM_RET_STATUS_T readLen(UINT32 *pLen);
     76 
     77   SYNCML_DM_RET_STATUS_T readOpaqueTag(UINT8* pByte, UINT8 *pBuffer, UINT8 nSize);
     78 
     79   SYNCML_DM_RET_STATUS_T readOpaqueTag(UINT8* pByte, DMBuffer * pBuffer);
     80 
     81   SYNCML_DM_RET_STATUS_T checkNextByteIsEndTag(UINT8* pByte);
     82 
     83   SYNCML_DM_RET_STATUS_T readNodeName(DMAddNodeProp* nodeProps, UINT8* pByte);
     84 #ifdef LOB_SUPPORT
     85   SYNCML_DM_RET_STATUS_T readESNFileName(DMAddNodeProp* nodeProps, UINT8* pByte);
     86 #endif
     87   SYNCML_DM_RET_STATUS_T readAccess(DMAddNodeProp* nodeProps, UINT8* pByte);
     88 
     89   SYNCML_DM_RET_STATUS_T readScope(DMAddNodeProp* nodeProps, UINT8* pByte);
     90 
     91   SYNCML_DM_RET_STATUS_T readClassID(DMAddNodeProp* nodeProps, UINT8* pByte);
     92 
     93   SYNCML_DM_RET_STATUS_T readFormat(DMAddNodeProp* nodeProps, UINT8* pByte);
     94 
     95   SYNCML_DM_RET_STATUS_T readFormatOld(DMAddNodeProp* nodeProps, UINT8* pByte);
     96 
     97   SYNCML_DM_RET_STATUS_T readMime(DMAddNodeProp* nodeProps, UINT8* pByte);
     98 
     99   SYNCML_DM_RET_STATUS_T readData(DMAddNodeProp* nodeProps, UINT8* pByte);
    100 
    101   SYNCML_DM_RET_STATUS_T readOPiData(DMAddNodeProp* nodeProps, UINT8* pByte);
    102 
    103   SYNCML_DM_RET_STATUS_T readTitle(DMAddNodeProp* nodeProps, UINT8* pByte);
    104 
    105   SYNCML_DM_RET_STATUS_T readFlag(DMAddNodeProp* nodeProps, UINT8* pByte);
    106 
    107 #ifndef DM_IGNORE_TSTAMP_AND_VERSION
    108   SYNCML_DM_RET_STATUS_T readTStamp(DMAddNodeProp* nodeProps, UINT8* pByte);
    109 
    110   SYNCML_DM_RET_STATUS_T readIntTStamp(DMAddNodeProp* nodeProps, UINT8* pByte);
    111 
    112   SYNCML_DM_RET_STATUS_T readVersion(DMAddNodeProp* nodeProps, UINT8* pByte);
    113 #endif
    114 };
    115 
    116 #endif /* SYNCML_DM_WBXMLREADER_H */
    117