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_WBXMLARCHIVE_H 18 #define SYNCML_DM_WBXMLARCHIVE_H 19 20 #ifndef __cplusplus 21 #error "This is a C++ header file; it requires C++ to compile." 22 #endif 23 24 /*================================================================================================== 25 26 Header Name: SyncML_DM_WBXMLArchive.H 27 28 General Description: This class provides the implementation of WBXML logging in the file system 29 30 ==================================================================================================*/ 31 32 #include "SyncML_DM_Archive.H" 33 #include "SyncML_DM_WBXMLWriter.H" 34 #include "SyncML_DM_WBXMLReader.H" 35 #include "syncml_dm_data_types.h" 36 #ifdef LOB_SUPPORT 37 #include "SyncML_Commit_Log.H" 38 #endif 39 40 class DMTree; 41 class CEnv; 42 43 /*================================================================================================== 44 CLASS DECLARATION 45 ==================================================================================================*/ 46 class SyncML_DM_WBXMLArchive : public SyncML_DM_Archive 47 { 48 49 public: 50 51 /* The default WBXML header used for string table lookups 52 */ 53 static const UINT8 DEFAULT_FILE_HEADER[] ; 54 55 static const char FILE_EXTENSION[] ; 56 57 /* The list of tag values for WBXML encoding */ 58 enum 59 { 60 WBXML_VERSION = 0x01, /* WBXML spec ver 1.1 (this is what our xml-to-wbxml tool does) */ 61 PUBLIC_ID = 0x01, /* Unknown or missing identifier; must be <=127 */ 62 CHARSET = 0x6A /* charset is UTF-8; value must be <=127 */ 63 }; 64 65 enum WBXML_TAGS 66 { 67 TAG_CONTENT_MASK = 0x40, 68 FILE_START_TAG = 0x1F, 69 TREE_START_TAG = 0x1E, 70 NODE_START_TAG = 0x1D, 71 NAME_START_TAG = 0x1C, 72 ACL_START_TAG = 0x1B, 73 ACCESS_START_TAG = 0x1A, 74 SCOPE_START_TAG = 0x19, 75 CLASSID_START_TAG = 0x18, 76 FORMAT_START_TAG = 0x17, 77 TYPE_START_TAG = 0x16, 78 FLAGS_START_TAG = 0x15, //DP substitution for SCOPE/CALSSID 79 TSTAMP_INT_START_TAG = 0x14, // DP: integer timestamp representation 80 FORMAT_NEW_START_TAG = 0x13, 81 URI_START_TAG = 0x12, 82 83 DATA_START_TAG = 0x08, //leave space 0x20-0x27 for urbana expansion 84 PLURAL_START_TAG = 0x09, 85 OPI_DATA_START_TAG = 0x0A, 86 TITLE_START_TAG = 0x10, 87 TSTAMP_START_TAG = 0x11, 88 VERSION_START_TAG = 0x07, 89 #ifdef LOB_SUPPORT 90 ESN_File_NAME_START_TAG = 0x20, 91 #endif 92 LOG_START_TAG = 0x21, 93 ENTRY_START_TAG = 0x22, 94 CMDTYPE_START_TAG = 0x23, 95 SOURCE_FILE_TAG = 0x24, 96 TARGET_FILE_TAG = 0x25, 97 END_TAG = 0x01 98 }; 99 100 enum 101 { 102 OPAQUE_CODE = 0xC3, 103 STRING_TABLE = 0x00 104 }; 105 106 /* Class constructor */ 107 SyncML_DM_WBXMLArchive( CEnv* env, CPCHAR pURI, CPCHAR path) ; 108 ~SyncML_DM_WBXMLArchive() ; 109 110 111 112 /* Deserializes a set of tree files from the file system, 113 * creates nodes and passes them to the tree 114 */ 115 virtual SYNCML_DM_RET_STATUS_T deserialize(DMTree* tree, 116 BOOLEAN bIsReload = FALSE); 117 118 /* Serializes a sub tree of data into the proper mount 119 * list referenced WBXML file 120 */ 121 virtual SYNCML_DM_RET_STATUS_T serialize(DMTree* tree) ; 122 /* Accessor for the last modification time of the archive 123 */ 124 virtual XPL_CLK_CLOCK_T getLastModifiedTime() ; 125 126 //Get last persisted time 127 virtual XPL_CLK_CLOCK_T getLastSavedTime() ; 128 129 // Check permission (flags from xpl_File.h) 130 virtual BOOLEAN verifyPermission(XPL_FS_OPEN_MODE_T permission) const; 131 132 virtual void serializeDone() ; 133 #ifdef LOB_SUPPORT 134 // Rollback operation for ESN 135 virtual SYNCML_DM_RET_STATUS_T rollbackESN(DMTree* tree); 136 virtual SYNCML_DM_RET_STATUS_T commitESN(DMTree* tree); 137 SyncML_Commit_Log* GetCommitLogHandler(); 138 SYNCML_DM_RET_STATUS_T CloseCommitLog(); 139 SYNCML_DM_RET_STATUS_T PlayCommitLog(); 140 #endif 141 private: 142 SYNCML_DM_RET_STATUS_T deserializeFile(DMTree* tree, CPCHAR szFileName, BOOLEAN bWFS); 143 #ifdef LOB_SUPPORT 144 SyncML_Commit_Log *commitLog; 145 #endif 146 XPL_CLK_CLOCK_T lastSavedTime; 147 CEnv *m_pEnv; 148 }; 149 150 #endif /* SYNCML_DM_WBXMLARCHIVE_H */ 151