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_CLASS_H
     18 #define _DM_TREE_CLASS_H
     19 
     20 #ifndef __cplusplus
     21 #error "This is a C++ header file; it requires C++ to compile."
     22 #endif
     23 
     24 //------------------------------------------------------------------------
     25 //            Header Name: dm_tree_class.H
     26 //
     27 //  General Description: This file contains prototypes, data type
     28 //                       definitions and constants required to access DMTNM
     29 //                       API's and the definition of DMTree class
     30 //------------------------------------------------------------------------
     31 
     32 #include "dm_tree_plugin_root_node_class.H"
     33 #include "dmtPlugin.hpp"
     34 #include "dmvector.h"
     35 #include "dmdefs.h"
     36 #include "dmMetaDataManager.h"
     37 #include "dmPluginManager.h"
     38 #include "SyncML_DM_Archiver.H"
     39 #include "file_manager.h"
     40 #include "dmLockCtxMgr.h"
     41 #include "dmACLManager.h"
     42 #include "dmSubscriptionManager.h"
     43 #include "SYNCML_DM_TreeMount.H"
     44 
     45 #ifdef LOB_SUPPORT
     46 #include "dm_tree_default_ESN_class.H" //header file for class defn
     47 #endif
     48 
     49 
     50 //------------------------------------------------------------------------
     51 //                        CONSTANTS
     52 //------------------------------------------------------------------------
     53 
     54 
     55 #define REPLACE_CMD_LENGTH_IN_ACL     8
     56 #define GET_CMD_LENGTH_IN_ACL         4
     57 #define ADD_CMD_LENGTH_IN_ACL         4
     58 #define DELETE_CMD_LENGTH_IN_ACL      7
     59 #define EXEC_CMD_LENGTH_IN_ACL        5
     60 
     61 #define REPLACE_CMD_IN_ACL   "Replace="
     62 #define GET_CMD_IN_ACL       "Get="
     63 #define ADD_CMD_IN_ACL       "Add="
     64 #define DELETE_CMD_IN_ACL    "Delete="
     65 #define EXEC_CMD_IN_ACL      "Exec="
     66 
     67 #define SYNCML_DM_PROP         ("?prop=")
     68 #define SYNCML_DM_LIST         ("?list=")
     69 #define SYNCML_DM_STRUCT       ("Struct")
     70 #define SYNCML_DM_STRUCT_DATA  ("StructData")
     71 #define SYNCML_DM_TNDS         ("TNDS")
     72 
     73 #define SYNCML_DM_PROP_LENGTH  6
     74 #define SYNCML_DM_LIST_LENGTH  6
     75 
     76 #define SYNCML_DM_NULL_STRING        ("null")
     77 #define SYNCML_DM_NULL_STRING_LENGTH 4
     78 
     79 #define FORMAT_LENGTH 10
     80 
     81 #define SIZE_LENGTH   10
     82 #define VERSION_LENGTH 5
     83 #define TSTAMP_LENGTH 20
     84 
     85 #define FIRST_SERVER_INDEX_IN_LOOKUP_TABLE   1
     86 #define MAX_SERVER_INDEX_IN_LOOKUP_TABLE     (SYNCML_DM_MAX_SERVER_ALLOWED)
     87 
     88 #define ROOT_NODE_NAME  (".")
     89 #define ROOT_NODE_ACL   ("Add=*&Replace=*&Get=*&Delete=*")  //YXU
     90 
     91 #define SYNCML_DM_ASCII_EXCLAMATION ('!')
     92 #define SYNCML_DM_ASCII_DOLLAR      ('$')
     93 #define SYNCML_DM_ASCII_MINUS       ('-')
     94 #define SYNCML_DM_ASCII_ZERO        ('0')
     95 #define SYNCML_DM_ASCII_NINE        ('9')
     96 #define SYNCML_DM_ASCII_EQUAL_TO    ('=')
     97 #define SYNCML_DM_ASCII_ATTHERATE   ('@')
     98 #define SYNCML_DM_ASCII_CAPITAL_A   ('A')
     99 #define SYNCML_DM_ASCII_CAPITAL_D   ('D')
    100 #define SYNCML_DM_ASCII_CAPITAL_E   ('E')
    101 #define SYNCML_DM_ASCII_CAPITAL_F   ('F')
    102 #define SYNCML_DM_ASCII_CAPITAL_G   ('G')
    103 #define SYNCML_DM_ASCII_CAPITAL_N   ('N')
    104 #define SYNCML_DM_ASCII_CAPITAL_R   ('R')
    105 #define SYNCML_DM_ASCII_CAPITAL_S   ('S')
    106 #define SYNCML_DM_ASCII_CAPITAL_V   ('V')
    107 #define SYNCML_DM_ASCII_CAPITAL_Z   ('Z')
    108 #define SYNCML_DM_ASCII_UNDERSCORE  ('_')
    109 #define SYNCML_DM_ASCII_80         0x80
    110 #define SYNCML_DM_ASCII_FF         0xFF
    111 
    112 #define SYNCML_DM_ASCII_SMALL_A     ('a')
    113 #define SYNCML_DM_ASCII_SMALL_F     ('f')
    114 #define SYNCML_DM_ASCII_SMALL_Z     ('z')
    115 #define SYNCML_DM_ASCII_TILDE       ('~')
    116 
    117 #define SYNCML_DM_ASCII_CAPITAL_CL   ("CL")
    118 #define SYNCML_DM_AME      ("ame")
    119 #define SYNCML_DM_ORMAT    ("ormat")
    120 #define SYNCML_DM_IZE      ("ize")
    121 #define SYNCML_DM_ERNO     ("erNo")
    122 #define SYNCML_DM_EPLACE   ("eplace")
    123 #define SYNCML_DM_ET       ("et")
    124 #define SYNCML_DM_DD       ("dd")
    125 #define SYNCML_DM_ELETE    ("elete")
    126 #define SYNCML_DM_XEC      ("xec")
    127 #define SYNCML_DM_TITLE    ("Title")
    128 #define SYNCML_DM_TYPE     ("Type")
    129 #define SYNCML_DM_TSTAMP   ("TStamp")
    130 
    131 #define SYNCML_DM_SEG_LEN_AFTER_PERCENTAGE (2)
    132 #define SYNCML_DMTNM_MAX_ENCODED_ACL_LENGTH (48)
    133 #define SYNCML_DM_RELATIVE_URI_OFFSET_LENGTH (2)
    134 
    135 //#define DM_ISP_LOCK  "/data/dm/tmp/isp"
    136 #define DM_ISP_LOCK  "/data/data/com.android.omadm.service/files/dm/tmp/isp"
    137 
    138 //------------------------------------------------------------------------
    139 //                 STRUCTURES AND OTHER TYPEDEFS
    140 //------------------------------------------------------------------------
    141 struct LIST_STRUCT_OR_STRUCT_DATA_INFO_T
    142 {
    143   LIST_STRUCT_OR_STRUCT_DATA_INFO_T() {Clear();}
    144 
    145   void Clear()  {
    146     psCurrent = NULL;
    147   }
    148   DMNode *psCurrent;
    149 };
    150 
    151 //------------------------------------------------------------------------
    152 //                  GLOBAL VARIABLE DECLARATIONS
    153 //------------------------------------------------------------------------
    154 //------------------------------------------------------------------------
    155 //                    FUNCTION PROTOTYPES
    156 //------------------------------------------------------------------------
    157 //------------------------------------------------------------------------
    158 //                          CLASS
    159 //------------------------------------------------------------------------
    160 
    161 //Definition of DMTree class
    162 class DMTree
    163 {
    164 
    165   enum {
    166      CLEAN = -1,
    167      DIRTY = 0,
    168      REPLACED = 1,
    169      ADDED =2,
    170      DELETED = 1
    171   };
    172 
    173 public:
    174     friend class DMTreeCacheCurrentTime;
    175     //Constructor
    176     DMTree();
    177 
    178     //Destructor
    179     ~DMTree();
    180 
    181     //Overloading new and delete operators
    182     inline void* operator new(size_t dwSize)
    183     {
    184        return (DmAllocMem(dwSize));
    185     }
    186 
    187     inline void operator delete(void *pvBuf)
    188     {
    189        DmFreeMem(pvBuf);
    190     }
    191 
    192 
    193     //Method that UA will call to let DMTNM initialize data members
    194     //that should not be set/reset through constructor
    195     SYNCML_DM_RET_STATUS_T Init();
    196 
    197     SYNCML_DM_RET_STATUS_T DeInit(BOOLEAN bIsDestructor);
    198 
    199     //Method to Initiallize and get first item from list
    200     SYNCML_DM_RET_STATUS_T InitListAndGetListFirstItem(CPCHAR pbURI,
    201                                                           SYNCML_DM_GET_ON_LIST_T bGetOnList,
    202                                                           SYNCML_DM_GET_ON_LIST_RET_DATA_T& ppsReturnData);
    203     //Method to  get next item from list
    204     SYNCML_DM_RET_STATUS_T GetListNextItem(SYNCML_DM_GET_ON_LIST_RET_DATA_T& ppsReturnData);
    205 
    206     //method to initialise the list for serialization process
    207     SYNCML_DM_RET_STATUS_T InitSerializationList(DMNode * serializeRoot);
    208 
    209     //method to return properties for serialization one by one
    210     SYNCML_DM_SERIALIZATION_STATUS_T GetSerializationListNextItem(DMNode **ppsRetNode,
    211                                                                       INT32& nEndTagsNumber );
    212 
    213 
    214     //Method to get the name of the Parent node when the value of
    215     //the child node is given
    216     BOOLEAN GetParentOfKeyValue(CPCHAR pbvalueOfKey,
    217                                   CPCHAR pKey,
    218                                   CPCHAR pSubtreeURI,
    219                                   DMString& strResult);
    220 
    221     //To add a node
    222     SYNCML_DM_RET_STATUS_T Add( DMAddData & oAddData,
    223                                                      SYNCML_DM_REQUEST_TYPE_T eRequestType );
    224 
    225     //To delete a node/subtree
    226     SYNCML_DM_RET_STATUS_T Delete(CPCHAR pbURI,
    227                                                          SYNCML_DM_REQUEST_TYPE_T eRequestType);
    228 
    229     //To exec a URI
    230     SYNCML_DM_RET_STATUS_T Exec(CPCHAR pbUri,
    231                                  CPCHAR pExecData,
    232                                  DMString & oExecResult,
    233                                  CPCHAR szCorrelator = NULL );
    234 
    235     //To get value of a node
    236    SYNCML_DM_RET_STATUS_T Get(CPCHAR pbUri,
    237                                                    DMGetData & oReturnData,
    238                                                    SYNCML_DM_REQUEST_TYPE_T eRequestType);
    239 
    240 
    241     //To get attributes of a node
    242     SYNCML_DM_RET_STATUS_T GetAttributes(CPCHAR pbUri,
    243                                                                       DmtAttributes& attrs,
    244                                                                       SYNCML_DM_REQUEST_TYPE_T eRequestType);
    245 
    246 
    247     //To replace a node's value/property value
    248     SYNCML_DM_RET_STATUS_T Replace( DMAddData & oReplaceData,
    249                                                              SYNCML_DM_REQUEST_TYPE_T eRequestType );
    250 
    251     //To set links of a de-serialized node
    252     SYNCML_DM_RET_STATUS_T AddNode(DMNode **psNodeObject,
    253                                     const DMAddNodeProp & oAddNodeProperties,
    254                                     DMNode* pNewNode = NULL );
    255 
    256     //Invoked by Archiver to get a pointer to the root node
    257     //Archiver then uses this object to traverse the tree
    258     //(using different traversal mechanism)
    259     inline DMNode* GetRootNode() { return( m_psRoot); }
    260 
    261 
    262     //To validate and Parse URI
    263     SYNCML_DM_URI_RESULT_T URIValidateAndParse(CPCHAR pbUri) const;
    264 
    265     //To decode the ACL to get back actual server names
    266     static SYNCML_DM_RET_STATUS_T DecodeACL(const UINT8 *pbEncodedACL,
    267                                                 UINT8 **ppbDecodedACL,
    268                                                 UINT16 *pwDecodedACLLength);
    269 
    270     //Detach the node from tree
    271     void DetachNodeFromTree(DMNode *);
    272 
    273     //Move to public as it may be used by notification manager
    274     //This method will return a pointer to the node(which is the
    275     //last segment in the URI)
    276     DMNode* FindNodeByURI(CPCHAR pURI);
    277 
    278     SYNCML_DM_RET_STATUS_T  getChildren( CPCHAR uri,
    279                                            DMMap<DMString, UINT32>& childrenMap,
    280                                            DMTNM_NODE_TYPE nodeType,
    281                                            SYNCML_DM_REQUEST_TYPE_T eRequestType);
    282 
    283     SYNCML_DM_RET_STATUS_T  getLeafChildren( CPCHAR uri,
    284                                                 DMMap<DMString, UINT32>& childrenMap,
    285                                                 SYNCML_DM_REQUEST_TYPE_T eRequestType);
    286 
    287     SYNCML_DM_RET_STATUS_T  getInteriorChildren( CPCHAR uri,
    288                                                    DMMap<DMString, UINT32>& childrenMap,
    289                                                    SYNCML_DM_REQUEST_TYPE_T eRequestType);
    290 
    291     SYNCML_DM_RET_STATUS_T  setLeafChildren( CPCHAR uri,
    292                                                 DMMap<DMString, UINT32>& childrenMap );
    293 
    294     SYNCML_DM_RET_STATUS_T  rollback( DMMap<DMString, UINT32> oldChildrenMap,
    295                                        DMMap<DMString, UINT32>& newChildrenMap,
    296                                        INT8 actionList[],
    297                                        INT8 deleteList[] );
    298 
    299     SYNCML_DM_RET_STATUS_T  handleNewChildren( DMMap<DMString, UINT32> oldChildrenMap,
    300                                                     DMMap<DMString, UINT32>& newChildrenMap,
    301                                                     INT8 actionList[],
    302                                                     INT8 deleteList[] );
    303 
    304     SYNCML_DM_RET_STATUS_T  handleOldChildren( DMMap<DMString, UINT32> oldChildrenMap,
    305                                                    DMMap<DMString, UINT32>& newChildrenMap,
    306                                                    INT8 actionList[],
    307                                                    INT8 deleteList[] );
    308 
    309     // return the associated Archive that the node is in.
    310     SyncML_DM_Archive * GetArchive(const DMNode * node);
    311 
    312     /* SessionStart functions call this to set the server Id. */
    313     SYNCML_DM_RET_STATUS_T SetServerId (CPCHAR p_ServerId);
    314 
    315     /* The DMTNM calls this to get the current server Id. */
    316     inline CPCHAR GetServerId() const { return (m_strPrincipal.c_str() );}
    317 
    318     /* Set CcnRef. */
    319     SYNCML_DM_RET_STATUS_T SetConRef (CPCHAR p_ConRef);
    320 
    321     /* Get COnRef */
    322     inline CPCHAR GetConRef() const { return (m_strConRef.c_str() );}
    323 
    324     // default leaf/interior node creation (except plug-ins)
    325     static DMNode* CreateNodeObj( SYNCML_DM_FORMAT_T bFormat, BOOLEAN isESN, CPCHAR pbFileName);
    326 
    327 
    328     DMNode* CreateSkeletonNode( CPCHAR szURI );
    329 
    330     static BOOLEAN GetLastSegmentOfURI( DMString& strURI, DMString& strLastSegment );
    331 
    332     void DeleteNodesFromTree(DMNode * startNode);
    333 
    334     UINT16 readOneWordFromTree(DMNode * pNode, UINT16 defaultValue);
    335 
    336     void UnloadArchive(DMNode * psStartNode );
    337 
    338     void  SubstituteNode( DMNode* pOldNode, DMNode* pNewNode );
    339 
    340     inline const DmtOPINodeData* GetCachedOPINodeData() { return &m_oOPICacheData;}
    341     SYNCML_DM_RET_STATUS_T SetOPINodeData( CPCHAR szURI, const DmtOverlayPluginData& oData );
    342 
    343     SYNCML_DM_RET_STATUS_T GetAccNodeValue (CPCHAR pParentName,
    344                                             CPCHAR pSubNode,
    345                                             DMGetData & oAccData);
    346 
    347     SYNCML_DM_RET_STATUS_T GetDefAccountAddrInfo(CPCHAR pAccProfileName,
    348                                                  DMGetData& oAddr,
    349                                                  DMGetData& oAddrType,
    350                                                  DMGetData& oPortNbr);
    351 
    352     SYNCML_DM_RET_STATUS_T GetServerAuthInfo(CPCHAR pAccProfileName,
    353                                              CPCHAR pAuthType,
    354                                              DMGetData& oAuthName,
    355                                              DMGetData& oAuthSecret,
    356                                              DMGetData& oAuthData,
    357                                              DMString&  oAuthDataUri);
    358 
    359     SYNCML_DM_RET_STATUS_T GetHttpAuthInfo(CPCHAR pAccProfileName,
    360                                              DMGetData& oAuthType,
    361                                              DMGetData& oAuthName,
    362                                              DMGetData& oAuthSecret,
    363                                              DMGetData& oAuthData,
    364                                              DMString&  oAuthDataUri);
    365 
    366     SYNCML_DM_RET_STATUS_T GetClientAuthInfo(CPCHAR pAccProfileName,
    367                                              CPCHAR pAuthType,
    368                                              DMGetData& oAuthName,
    369                                              DMGetData& oAuthSecret,
    370                                              DMGetData& oAuthData,
    371                                              DMString&  oAuthDataUri,
    372                                              DMGetData& oAuthType );
    373 
    374     SYNCML_DM_RET_STATUS_T GetAuthInfo(CPCHAR pAccProfileName,
    375                                        CPCHAR pAuthLevel,
    376                                        CPCHAR pAuthType,
    377                                        DMGetData& oAuthType,
    378                                        DMGetData& oAuthName,
    379                                        DMGetData& oAuthSecret,
    380                                        DMGetData& oAuthData,
    381                                        DMString&  oAuthDataUri);
    382 
    383     SYNCML_DM_RET_STATUS_T GetLastClientAuthType(CPCHAR pAccProfileName,
    384                                                  DMGetData& oClientAuthType);
    385 
    386     SYNCML_DM_RET_STATUS_T SetLastClientAuthType(CPCHAR pAccProfileName,
    387                                                  CPCHAR pClientAuthType);
    388 
    389 
    390     // Utility method used to convert SYNCML_DM_FORMAT_T type format to string
    391     static SYNCML_DM_RET_STATUS_T ConvertFormat(SYNCML_DM_FORMAT_T format,
    392                                   DMString & strFormat);
    393 
    394     // Utility method used to convert string format to SYNCML_DM_FORMAT_T type
    395     static SYNCML_DM_FORMAT_T ConvertFormatStr(const DMString& formatStr);
    396 
    397     BOOLEAN IsVersion_12() { return m_bVersion_1_2; }
    398 
    399     // Verify if URI is blocked - feature isn't available
    400     BOOLEAN IsUriEnabled(CPCHAR szURI)	const;
    401 
    402 #ifdef LOB_SUPPORT
    403     SYNCML_DM_RET_STATUS_T IsESN(CPCHAR pbURI, BOOLEAN &isESN);
    404 #endif
    405     DMMetaDataManager & GetMetaDataManager();
    406     DMPluginManager &  GetPluginManager();
    407     SyncML_DM_Archiver &  GetArchiver();
    408     DMLockContextManager &  GetLockContextManager();
    409     DMSubscriptionManager &  GetSubscriptionManager();
    410 
    411     void CheckMemoryAging();
    412     SYNCML_DM_RET_STATUS_T ReleaseLock( INT32 nLockID ,SYNCML_DM_COMMAND_T command = SYNCML_DM_RELEASE );
    413     SYNCML_DM_RET_STATUS_T SaveFile(SYNCML_DM_FILE_TYPE_T eFileType);
    414     SYNCML_DM_RET_STATUS_T RevertFile(SYNCML_DM_FILE_TYPE_T eFileType);
    415     SYNCML_DM_RET_STATUS_T Flush();
    416     void  GetTreeMountEntry (CPCHAR& p_Uri,
    417                                          CPCHAR& p_TreePath,
    418                                           UINT16  index ) const;
    419 
    420     SYNCML_DM_RET_STATUS_T RecoverPlugin();
    421     CPCHAR                 GetWritableFileSystemFullPath( DMString & path );
    422     BOOLEAN                IsInitialized() const;
    423     UINT16                 GetMaxPathDepth() const;
    424     UINT16                 GetMaxTotalPathLength() const;
    425     UINT16                 GetMaxPathSegmentLength() const;
    426 
    427 
    428 private:
    429     //FOR getStruct to free the list
    430     inline void FreeListStruct() {  psListInfo.Clear(); }
    431 
    432 
    433     //To find the next sibling  while traversing the child list
    434     DMNode* FindNodeInNextSiblingsList(DMNode *psFindNode,
    435                                             CPCHAR pbURISegment) const;
    436 
    437 
    438     //To insert a newly added child in the Child list
    439     SYNCML_DM_RET_STATUS_T InsertNodeIntoNextSiblingsList(DMNode *psNextSiblingStartNode,
    440                                                           DMNode *psInsertNode);
    441 
    442     BOOLEAN ParentExistsForPluginNode( CPCHAR pURI, DMNode *psNode) const;
    443 
    444     //To parse the ACL string and replace with server Indices
    445     SYNCML_DM_RET_STATUS_T ParseACL(UINT8* pACL);
    446 
    447 
    448     SYNCML_DM_RET_STATUS_T CheckDeleteForNode(DMNode *psDeletingNode,
    449                                                                         CPCHAR pbURI);
    450 
    451     SYNCML_DM_RET_STATUS_T DeleteNode(DMNode *psDeletingNode,
    452                                       CPCHAR pbURI,
    453                                       DMStringVector & aDeletedChildren);
    454 
    455     //To check if the server is allowed to do the DM operation
    456     SYNCML_DM_RET_STATUS_T IsValidServer(CPCHAR pURI,
    457                                          SYNCML_DM_ACCESS_TYPE_T accessType,
    458                                          SYNCML_DM_REQUEST_TYPE_T eRequestType,
    459                                          BOOLEAN bCheckAccess,
    460                                          BOOLEAN bIsCheckLocal,
    461                                          DMMetaPCharVector* pChildDependNodes = NULL);
    462 
    463     //To get all the child names for GET on Interior node
    464     SYNCML_DM_RET_STATUS_T GetChildren( CPCHAR szURI,
    465                                       const DMNode *psNode,
    466                                       SYNCML_DM_REQUEST_TYPE_T eRequestType,
    467                                       DMString& strChildren ) const;
    468 
    469     //To get number of child on Interior node
    470     UINT16 GetChildrenCount(const DMNode *psNode) const;
    471 
    472     //validates the segment (grammar of node name)
    473     BOOLEAN IsValidSegment(CPCHAR pbSegment, UINT8 bSegmentLength);
    474 
    475     SYNCML_DM_RET_STATUS_T CheckDeleteForPluginNodes(SYNCML_DM_REQUEST_TYPE_T eRequestType,
    476                                                                                  CPCHAR pbURI,
    477                                                                                  DMNode *psProxyNode,
    478                                                                                  DMStringVector & aChildren);
    479 
    480     SYNCML_DM_RET_STATUS_T CheckDeleteForPluginNode(SYNCML_DM_REQUEST_TYPE_T eRequestType,
    481                                                                                 CPCHAR pbURI,
    482                                                                                 PDmtNode ptrNode,
    483                                                                                 DMStringVector & aChildren,
    484                                                                                 BOOLEAN bIsParent);
    485 
    486     BOOLEAN GetPluginURI(CPCHAR szURI, DMString& strURI, DMString& strShortURI ) const;
    487 
    488     BOOLEAN LoadSkeletonParentArchive( DMNode* pNode );
    489 
    490     SYNCML_DM_RET_STATUS_T GetListItemData(SYNCML_DM_GET_ON_LIST_RET_DATA_T& ppsReturnData);
    491 
    492     DMNode*  GetOPINode( CPCHAR szURI );
    493 
    494     void  ResetOPICache();
    495     SYNCML_DM_RET_STATUS_T  OnOPiDelete( CPCHAR szURI );
    496     SYNCML_DM_RET_STATUS_T  OnOPiAdd( CPCHAR szURI, DmtOverlayPluginData& data );
    497     void  CheckOpiSync( DMNode* pNode, char* szURI, const char* szLastSegment );
    498     void  OpiSync( DMNode* pNode, const char* szURI );
    499     void  CheckForIndirectUpdates( CPCHAR szURI, const DMMetaPCharVector& asChildDepend, DMNode* inNode );
    500     void  CheckURIForIndirectUpdates( CPCHAR szChild, CPCHAR szURI, DMNode* inNode );
    501 #ifdef LOB_SUPPORT
    502     void  ResetESNCache();
    503     void RemoveESNCache(CPCHAR szURI );
    504     DMNode*  GetESN( CPCHAR szURI );
    505     void  SetESNCache( CPCHAR szURI , DMNode* pESN);
    506    void   LogDeleteForESN(DMNode *psDeletingNode);
    507 #endif
    508     void                   LoadMaxValues();
    509 
    510     SYNCML_DM_RET_STATUS_T InternalInit();
    511     void                   InternalDeInit();
    512     SYNCML_DM_RET_STATUS_T RecoverPluginFromFile( const DMString&  file_bak_name );
    513     SYNCML_DM_RET_STATUS_T ReadCommandFromFile( DMFileHandler    *fileHandle,
    514                                                 DMBuffer&        cmdURI );
    515 
    516     BOOLEAN NeedCheckParent( const DMString&  strURI,
    517                              DMNode *psReplacingNode,
    518                              BOOLEAN bInPlugin,
    519                              SYNCML_DM_FORMAT_T  bFormat,
    520                              SYNCML_DM_REQUEST_TYPE_T eRequestType);
    521 
    522     SYNCML_DM_RET_STATUS_T ReplaceACLProperty( const DMString&  strURI,
    523                                                BOOLEAN          bInPlugin,
    524                                                const DMString&  strPluginURI,
    525                                                DMAddData&       oReplaceData,
    526                                                DMNode*          psReplacingNode );
    527 
    528     SYNCML_DM_RET_STATUS_T ReplaceTitleProperty( const DMString&  strURI,
    529                                                  BOOLEAN          bInPlugin,
    530                                                  const DMString&  strPluginURI,
    531                                                  DMAddData&       oReplaceData,
    532                                                  DMNode*          psReplacingNode );
    533 
    534     SYNCML_DM_RET_STATUS_T AddNodeInternal( DMAddData & oAddData,
    535                                             SYNCML_DM_REQUEST_TYPE_T eRequestType );
    536 
    537     SYNCML_DM_RET_STATUS_T ReplaceNodeInternal( const DMString&        strURI,
    538                                                 DMAddData&             oReplaceData,
    539                                                 DMNode*                psReplacingNode,
    540                                                 DMMetaPCharVector&     asChildDepend );
    541 
    542     SYNCML_DM_RET_STATUS_T PrepareNamePropertyReplace( const DMString&        strURI,
    543                                                        BOOLEAN                bInPlugin,
    544                                                        DMAddData&             oReplaceData,
    545                                                        DMNode*                psReplacingNode );
    546 
    547     SYNCML_DM_RET_STATUS_T CheckReplacingNodeName( DMAddData& oReplaceData,
    548                                                    DMNode*    psReplacingNode );
    549 
    550     SYNCML_DM_RET_STATUS_T ReplaceProperty( const DMString&         strURI,
    551                                             BOOLEAN                bInPlugin,
    552                                             const DMString&        strPluginURI,
    553                                             DMAddData&             oReplaceData,
    554                                             DMNode*                psReplacingNode,
    555                                             SYNCML_DM_RET_STATUS_T wURIValidateRetCode );
    556 
    557     SYNCML_DM_RET_STATUS_T ReplaceNameProperty( const DMString&         strURI,
    558                                                  BOOLEAN                bInPlugin,
    559                                                  const DMString&        strPluginURI,
    560                                                  DMAddData&             oReplaceData,
    561                                                  DMNode*                psReplacingNode,
    562                                                  SYNCML_DM_RET_STATUS_T wURIValidateRetCode );
    563 
    564     SYNCML_DM_RET_STATUS_T FixACL( const DMString& strURI,
    565                                    DMAddData&      oReplaceData );
    566 
    567     SYNCML_DM_RET_STATUS_T SetACL(CPCHAR szURI);
    568 
    569     BOOLEAN VerifyArchiveReadAccess(CPCHAR szURI);
    570     BOOLEAN VerifyArchiveWriteAccess(CPCHAR szURI);
    571 
    572     SYNCML_DM_RET_STATUS_T AddAutoNodes(CPCHAR szURI,
    573                                     SYNCML_DM_REQUEST_TYPE_T eRequestType,
    574                                     DMToken & oAutoNodes);
    575 
    576     SYNCML_DM_RET_STATUS_T LogEvent(SYNCML_DM_COMMAND_T type,
    577                                     CPCHAR pbURI,
    578                                     CPCHAR szNewName = NULL);
    579 
    580     SYNCML_DM_RET_STATUS_T LogEvent(CPCHAR pbURI,
    581                                     const DMStringVector & aDeletedChildren);
    582 
    583 #ifdef LOB_SUPPORT
    584     SYNCML_DM_RET_STATUS_T  LogESNCommandForArchiver(CPCHAR pbURI,
    585                                                       DMNode * inNode);
    586 #endif
    587 
    588 private:
    589 #ifndef DM_NO_LOCKING
    590   DMCriticalSection m_csInitLock;
    591 #endif
    592 
    593   SYNCML_DM_TreeMount       m_oTreeMountObj;
    594   mutable DMMetaDataManager m_oMDFObj;
    595   DMPluginManager             m_oPluginManager;
    596   SyncML_DM_Archiver        m_oArchiver;
    597   CMultipleFileManager      m_oFileManager;
    598   DMLockContextManager       m_oLockContextManager;
    599   DMAclManager              m_oACLObj;
    600   DMSubscriptionManager          m_oEvtObj;
    601   CEnv                      m_oEnv;
    602   SYNCML_DM_RET_STATUS_T    m_init_status;
    603 
    604   DMString                  m_strPrincipal; /* Server ID */
    605   DMString			m_strConRef;
    606 
    607   DMNode                    *m_psRoot;   //The root node object
    608 
    609   // the following 3 members are used for OPI support and cached by "FindNode" function
    610   DmtOPINodeData        m_oOPICacheData;
    611   PDMPlugin                  m_ptrCacheOPI;
    612   DMOverlayDataPluginNode   *m_pOPINode;
    613   BOOLEAN                   m_bVersion_1_2;
    614 
    615 #ifdef LOB_SUPPORT
    616     DMNode                  *m_pESN;   //The External Storage Node
    617     DMString                m_strESNPath; //URI of the ESN
    618 #endif
    619 
    620   LIST_STRUCT_OR_STRUCT_DATA_INFO_T psListInfo;
    621   UINT16  m_wMaxDepth;
    622   UINT16  m_wMaxTotLen;
    623   UINT16  m_wMaxSegLen;
    624   INT32    m_nRefCount; // number of users
    625 
    626   static const UINT8        *m_pDataFormatTable[];
    627   XPL_CLK_CLOCK_T           m_currentTime; // cached current time value
    628 };
    629 
    630 //Definition of DMTreeLastAccessedTime class
    631 //can be used to cache system call to XPL_CLK_GetClock,
    632 //which may occur quite frequently to update LastAccessedTime of archives
    633 class DMTreeCacheCurrentTime
    634 {
    635 	BOOLEAN m_resetCacheOnDestruct;
    636 	DMTree* m_tree;
    637 
    638 public:
    639 	DMTreeCacheCurrentTime(DMTree* tree)
    640 	{
    641 		m_resetCacheOnDestruct = (tree->m_currentTime==0);
    642 		m_tree = tree;
    643 		if (m_resetCacheOnDestruct)
    644 			tree->m_currentTime = XPL_CLK_GetClock();
    645 
    646 	}
    647 	~DMTreeCacheCurrentTime()
    648 	{
    649 		if (m_resetCacheOnDestruct)
    650 			m_tree->m_currentTime = 0;
    651 	}
    652 };
    653 
    654 #ifdef __cplusplus
    655 extern "C" {
    656 #endif
    657 extern DMTree               dmTreeObj;
    658 #ifdef __cplusplus
    659 }
    660 #endif
    661 
    662 //---------------------------------------------------------------------
    663 #endif  // _DM_TREE_CLASS_H
    664