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 _DM_TREE_TYPEDEF_H
     18 #define _DM_TREE_TYPEDEF_H
     19 
     20 /*========================================================================
     21         Header Name: dm_tree_typedef.h
     22 
     23     General Description: This file gives the data type definitions used
     24                        by the DMTNM module.
     25 ========================================================================*/
     26 
     27 #include "syncml_dm_data_types.h"  /*data defns of UA global data types*/
     28 #include "xpl_Time.h"
     29 #include "dmbuffer.h"
     30 #include "dmtData.hpp"
     31 #include "dmt.hpp"
     32 
     33 #ifdef __cplusplus
     34 extern "C" {
     35 #endif
     36 
     37 /*========================================================================
     38                             ENUMS
     39 ========================================================================*/
     40 enum
     41 {
     42   SYNCML_DM_GET_ON_LIST_STRUCT,    /* ?list=Struct found in URI */
     43   SYNCML_DM_GET_ON_LIST_STRUCTDATA /* ?list=StructData found in URI */
     44 
     45 };
     46 typedef UINT8 SYNCML_DM_GET_ON_LIST_T;
     47 
     48 enum
     49 {
     50   SYNCML_DM_SERIALIZATION_SUCCESS,
     51   SYNCML_DM_SERIALIZATION_FAIL,
     52   SYNCML_DM_TREE_TRAVERSING_OVER
     53 };
     54 typedef UINT16 SYNCML_DM_SERIALIZATION_STATUS_T;
     55 
     56 enum
     57 {
     58   SYNCML_DM_REQUEST_TYPE_API,
     59   SYNCML_DM_REQUEST_TYPE_SERVER,
     60   SYNCML_DM_REQUEST_TYPE_INTERNAL
     61 };
     62 typedef UINT8 SYNCML_DM_REQUEST_TYPE_T;
     63 
     64 
     65 #ifdef __cplusplus
     66 }
     67 #endif
     68 /*========================================================================
     69                    STRUCTURES AND OTHER TYPEDEFS
     70 ========================================================================*/
     71 
     72 
     73 /*class used for returning the data for GET operation */
     74 class DMGetData
     75 {
     76 public:
     77 
     78   inline DMGetData() {
     79    m_nFormat = SYNCML_DM_FORMAT_INVALID;
     80 #ifdef LOB_SUPPORT
     81    m_chunkOffset = 0L; 		// offset
     82    chunkData = NULL;
     83 #endif
     84   }
     85 
     86   inline ~DMGetData() {}
     87 
     88   inline void clear()
     89   {
     90      m_nFormat = SYNCML_DM_FORMAT_INVALID;
     91      m_TotalSize = -1;
     92      m_oMimeType.clear();
     93      m_oData.clear();
     94   }
     95 
     96   SYNCML_DM_RET_STATUS_T set(SYNCML_DM_FORMAT_T wFormat,
     97                              CPCHAR pData,
     98                              UINT32 dataLength,
     99                              CPCHAR pMimeType);
    100 
    101   SYNCML_DM_RET_STATUS_T set(const DmtData & data, CPCHAR pMimeType);
    102 
    103   inline CPCHAR getCharData() const { return (CPCHAR)m_oData.getBuffer(); }
    104 
    105   inline CPCHAR getType() const { return (CPCHAR)m_oMimeType.getBuffer(); }
    106 
    107   inline void* operator new(size_t dwSize)   {return (DmAllocMem(dwSize)); }
    108 
    109   inline void operator delete(void *pvBuf)  { DmFreeMem(pvBuf); }
    110 
    111 #ifdef LOB_SUPPORT
    112   SYNCML_DM_RET_STATUS_T set(DmtDataChunk  *dmtChunk, UINT32 dmtChunkoffset);
    113   void clearESNData();
    114   void  SetESN(BOOLEAN isESN) {m_bESN = isESN;}
    115   BOOLEAN  IsESN() const {return m_bESN;}
    116 #else
    117   BOOLEAN  IsESN() const {return FALSE;}
    118 #endif
    119   DMBuffer           m_oMimeType;
    120   SYNCML_DM_FORMAT_T m_nFormat;
    121   DMBuffer           m_oData;
    122   int m_TotalSize;
    123 
    124 #ifdef LOB_SUPPORT
    125   UINT32 m_chunkOffset; 		// offset
    126   DmtDataChunk *chunkData;
    127    BOOLEAN  m_bESN;
    128 #endif
    129 
    130 };
    131 
    132 
    133 /*class used for ADD on  a node*/
    134 class DMAddData : public DMGetData
    135 {
    136 public:
    137 
    138    DMAddData ()
    139    {
    140 	clear();
    141    }
    142   inline void clear()
    143   {
    144      DMGetData::clear();
    145      m_oURI.clear();
    146   }
    147 
    148   inline CPCHAR getURI() const { return (CPCHAR)m_oURI.getBuffer(); }
    149 
    150   SYNCML_DM_RET_STATUS_T set(CPCHAR pURI,
    151                             SYNCML_DM_FORMAT_T wFormat,
    152                             CPCHAR pData,
    153                             UINT32 dataLength,
    154                             CPCHAR pMimeType);
    155 
    156   SYNCML_DM_RET_STATUS_T set(SYNCML_DM_FORMAT_T wFormat, CPCHAR pMimeType);
    157 
    158   SYNCML_DM_RET_STATUS_T set(CPCHAR pURI, const DmtData & data, CPCHAR pMimeType);
    159 #ifdef LOB_SUPPORT
    160   void clearESNData()
    161 {   DMGetData::clearESNData();
    162      m_bLastChunk = FALSE;
    163 }
    164   BOOLEAN  IsLastChunk() const {return m_bLastChunk;}
    165   SYNCML_DM_RET_STATUS_T set(CPCHAR pURI,
    166   							DmtDataChunk  *dmtChunk,
    167   							UINT32 dmtChunkoffset,
    168   							BOOLEAN isLastChunk);
    169    BOOLEAN  m_bLastChunk;
    170 #endif
    171 
    172 
    173   DMBuffer m_oURI;
    174 };
    175 
    176 
    177 
    178 struct SYNCML_DM_GET_ON_LIST_RET_DATA_T
    179 {
    180   DMGetData *psRetData;
    181   DMString  _pbURI;
    182   DMString m_strStartURI;
    183   DMString m_strNextChild;
    184 
    185   inline SYNCML_DM_GET_ON_LIST_RET_DATA_T() {psRetData=NULL;}
    186 };
    187 
    188 
    189 /*structure for passing properties in ADD*/
    190 class DMAddNodeProp : public DMAddData
    191 {
    192 public:
    193 
    194    DMAddNodeProp ()
    195    {
    196      m_nFlags = 0;
    197      m_nFormat = SYNCML_DM_FORMAT_NODE;
    198 #ifndef DM_IGNORE_TSTAMP_AND_VERSION
    199      m_nTStamp = 0;
    200      m_nVerNo = 0;
    201 #endif
    202 
    203      m_oURI.allocate(SYNCML_DM_URI_MAX_TOTAL_LENGTH);
    204      m_oName.allocate(SYNCML_DM_MAX_TITLE_LENGTH);
    205      m_oTitle.allocate(SYNCML_DM_MAX_TITLE_LENGTH);
    206      m_oMimeType.allocate(SYNCML_DM_MAX_TITLE_LENGTH);
    207      m_oData.allocate(SYNCML_DM_MAX_TITLE_LENGTH);
    208 #ifdef LOB_SUPPORT
    209      m_oESNFileName.allocate(SYNCML_DM_URI_MAX_TOTAL_LENGTH);
    210 #endif
    211    }
    212 
    213    inline void clear()
    214    {
    215       DMAddData::clear();
    216       m_oName.clear();
    217       m_oTitle.clear();
    218 #ifdef LOB_SUPPORT
    219      m_oESNFileName.clear();
    220 #endif
    221       m_nFlags = 0;
    222       m_nFormat = SYNCML_DM_FORMAT_NODE;
    223 #ifndef DM_IGNORE_TSTAMP_AND_VERSION
    224       m_nTStamp = 0;
    225       m_nVerNo = 0;
    226 #endif
    227       m_oOPiData.clear();
    228    }
    229 
    230 
    231    SYNCML_DM_RET_STATUS_T set(CPCHAR pName,
    232                               CPCHAR pTitle,
    233                               SYNCML_DM_FORMAT_T wFormat,
    234                               CPCHAR pData,
    235                               UINT32 dataLength,
    236                               CPCHAR pMimeType,
    237                               UINT16 flag);
    238 
    239 
    240    inline CPCHAR getName() const { return (CPCHAR)m_oName.getBuffer(); }
    241 
    242    inline CPCHAR getTitle() const { return (CPCHAR)m_oTitle.getBuffer(); }
    243 
    244 #ifdef LOB_SUPPORT
    245    inline CPCHAR getESNFileName() const { return (CPCHAR)m_oESNFileName.getBuffer(); }
    246    SYNCML_DM_RET_STATUS_T setESNFileName(CPCHAR pFileName);
    247 #endif
    248 #ifndef DM_IGNORE_TSTAMP_AND_VERSION
    249    XPL_CLK_CLOCK_T m_nTStamp;
    250    UINT16 m_nVerNo;
    251 #endif
    252 
    253 
    254    UINT16    m_nFlags;
    255 #ifdef LOB_SUPPORT
    256   DMBuffer m_oESNFileName;
    257 #endif
    258    DMBuffer m_oName;
    259    DMBuffer m_oTitle;
    260    DMBuffer m_oOPiData;
    261 };
    262 
    263 #endif  /*DM_TREE_TYPEDEF_H*/
    264