xdmprotocols/XcapProtocol/inc/XcapDocument.h
branchRCL_3
changeset 35 fbd2e7cec7ef
parent 0 c8caa15ef882
child 12 e6a66db4e9d0
equal deleted inserted replaced
34:2669f8761a99 35:fbd2e7cec7ef
       
     1 /*
       
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: CXcapDocument
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef __XCAPDOCUMENT__
       
    22 #define __XCAPDOCUMENT__
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <XdmDocument.h>
       
    26 
       
    27 //CONSTANTS
       
    28 const TUint KETagBufferMaxLength                       = 64;
       
    29 _LIT8( KSlash,                                         "/" );
       
    30 _LIT8( KUserDirName,                                   "users/" );
       
    31 _LIT8( KGlobalDirName,                                 "global/" );
       
    32 _LIT8( KXcapGlobalDocName,                             "index" );
       
    33 
       
    34 //FORWARD DECLARATIONS
       
    35 class RXcapCache;
       
    36 class CXdmEngine;
       
    37 class CXdmNamespace;
       
    38 class CXcapProtocol;
       
    39 class CXcapAppUsage;
       
    40 class MXdmOperation;
       
    41 class CXcapDocumentNode;
       
    42 class CXdmOperationFactory;
       
    43 
       
    44 //CLASS DECLARATION
       
    45 class CXcapDocument : public CXdmDocument
       
    46     {
       
    47     public:
       
    48         
       
    49         /**
       
    50         * Symbian OS default constructor.
       
    51         * @param TInt Default Access Point ID
       
    52         * @return CXdmDocOperation*
       
    53         */     
       
    54         static CXcapDocument* NewL( TXdmDocType aDocumentType,
       
    55                                     const TDesC& aDocumentName,
       
    56                                     const CXdmEngine& aXdmEngine,
       
    57                                     const CXcapProtocol& aXcapProtocol );
       
    58         
       
    59         /**
       
    60         * Symbian OS default constructor.
       
    61         * @param TInt Default Access Point ID
       
    62         * @return CXdmDocOperation*
       
    63         */     
       
    64         static CXcapDocument* NewL( TXdmDocType aDocumentType,
       
    65                                     const TDesC8& aDocumentName,
       
    66                                     const CXdmEngine& aXdmEngine,
       
    67                                     const CXcapProtocol& aXcapProtocol );
       
    68         
       
    69         /**
       
    70         * Set one option
       
    71         * @return void
       
    72         * @param The completed update operation
       
    73         */
       
    74         void SetOption( TInt aOption );
       
    75         
       
    76         /**
       
    77         * Symbian OS default constructor.
       
    78         * @param TInt Default Access Point ID
       
    79         * @return CXdmDocOperation*
       
    80         */                         
       
    81         TXdmDocType DocumentType() const;
       
    82         
       
    83         /**
       
    84         * Symbian OS default constructor.
       
    85         * @param TInt Default Access Point ID
       
    86         * @return CXdmDocOperation*
       
    87         */  
       
    88         void NotifyResolverCompleteL( TInt aError );
       
    89         
       
    90         /**
       
    91         * Symbian OS default constructor.
       
    92         * @param TInt Default Access Point ID
       
    93         * @return CXdmDocOperation*
       
    94         */     
       
    95         void StartInternalL( TRequestStatus& aStatus );
       
    96         
       
    97         /**
       
    98         * Symbian OS default constructor.
       
    99         * @param TInt Default Access Point ID
       
   100         * @return CXdmDocOperation*
       
   101         */     
       
   102         void CancelUpdate(); 
       
   103 
       
   104         /**
       
   105         * Destructor.
       
   106         */      
       
   107         virtual ~CXcapDocument();
       
   108     
       
   109     public:  //Exported methods
       
   110         
       
   111         /**
       
   112         * Symbian OS default constructor.
       
   113         * @param TInt Default Access Point ID
       
   114         * @return CXdmDocOperation*
       
   115         */     
       
   116         IMPORT_C TDesC8& ETag();
       
   117         
       
   118         /**
       
   119         * Symbian OS default constructor.
       
   120         * @param TInt Default Access Point ID
       
   121         * @return CXdmDocOperation*
       
   122         */     
       
   123         IMPORT_C void SetETag( const TDesC8& aETagDesc );
       
   124         
       
   125         /**
       
   126         * Symbian OS default constructor.
       
   127         * @param TInt Default Access Point ID
       
   128         * @return CXdmDocOperation*
       
   129         */     
       
   130         IMPORT_C TInt DataLength() const;
       
   131         
       
   132         /**
       
   133         * Symbian OS default constructor.
       
   134         * @param TInt Default Access Point ID
       
   135         * @return CXdmDocOperation*
       
   136         */     
       
   137         IMPORT_C CXcapAppUsage& ApplicationUsage() const;
       
   138         
       
   139         /**
       
   140         * Symbian OS default constructor.
       
   141         * @param TInt Default Access Point ID
       
   142         * @return CXdmDocOperation*
       
   143         */     
       
   144         IMPORT_C CXcapDocument* TempCopyL();
       
   145         
       
   146         /**
       
   147         * Symbian OS default constructor.
       
   148         * @param TInt Default Access Point ID
       
   149         * @return CXdmDocOperation*
       
   150         */     
       
   151         IMPORT_C void RemoveData( CXcapDocumentNode* aDocumentNode );
       
   152         
       
   153         /**
       
   154         * Symbian OS default constructor.
       
   155         * @param TInt Default Access Point ID
       
   156         * @return CXdmDocOperation*
       
   157         */     
       
   158         IMPORT_C CXcapProtocol& Protocol() const;
       
   159         
       
   160         /**
       
   161         * Reset the document subset
       
   162         */
       
   163         IMPORT_C virtual void ResetSubset();
       
   164         
       
   165     private:  //From CXdmDocument
       
   166         
       
   167         /**
       
   168         * Construct an "anonymous" entry point for this document.
       
   169         * This node effectively becomes the root of this document.
       
   170         * 
       
   171         */
       
   172         CXdmDocumentNode* CreateRootL();
       
   173 
       
   174         /**
       
   175         * Return the time stamp for this document
       
   176         *
       
   177 		* @return TTime 
       
   178         */
       
   179         TTime TimeStamp() const;
       
   180         
       
   181         /**
       
   182         * Return an error document for a failed update
       
   183         * 
       
   184         * NOTE: The returning object will be NULL in case
       
   185         *       the used protocol does not support this feature.
       
   186         *
       
   187 		* @return CXdmDocument* The error document
       
   188         */
       
   189         CXdmDocumentNode* ErrorRoot();
       
   190               
       
   191         /*
       
   192         * Reset the contents of this document model.
       
   193         */
       
   194         void ResetContents();
       
   195         
       
   196     public:  //From CXdmDocument
       
   197     
       
   198         /**
       
   199         * Return the root element of this document
       
   200         *
       
   201         * @return CXdmDocumentNode The root element of the document
       
   202         *
       
   203         * NOTE: The returning node may or may not contain any data,
       
   204         *       since, in the case that this document model does not
       
   205         *       have content yet, the element is a simple "entry point"
       
   206         *       to the whole document. Thus, for instance, if the client
       
   207         *       application requests the Xdm Engine to fetch a particular
       
   208         *       document, the root element points to nothing until the 
       
   209         *       request has been completed.
       
   210         *         
       
   211         */
       
   212         CXdmDocumentNode* DocumentRoot() const;
       
   213         
       
   214     private:  //From MXdmNamespaceContainer
       
   215         
       
   216         /**
       
   217         * Return the number of namespace declarations
       
   218         * @return TInt Namespace declaration count
       
   219         */
       
   220         TInt Count() const;
       
   221         
       
   222         /**
       
   223         * Copies the request data
       
   224         * @param aRequestData Data to be sent
       
   225         */
       
   226         void AppendNamespaceL( const TDesC8& aUri, const TDesC8& aPrefix );
       
   227         
       
   228         /**
       
   229         * Remove a namespace from the document
       
   230         * @param TDesC8& URI of the namespace
       
   231         * @param TDesC8& Prefix of the namespace
       
   232         */
       
   233         void RemoveNamespace( const TDesC8& aUri );
       
   234         
       
   235         /**
       
   236         * Copies the request data
       
   237         * @param aRequestData Data to be sent
       
   238         */
       
   239         TPtrC8 Uri( const TDesC8& aPrefix ) const;
       
   240         
       
   241         /**
       
   242         * Fetch the aIndex-th URI
       
   243         * @param TInt The index of the desired URI string
       
   244         * @return TPtrC URI string
       
   245         */
       
   246         TPtrC8 Uri( TInt aIndex ) const;
       
   247         
       
   248         /**
       
   249         * Fetch the aIndex-th prefix
       
   250         * @param TDesC8 The index of the desired prefix string
       
   251         * @return TPtrC Prefix string
       
   252         */
       
   253         TPtrC8 Prefix( TInt aIndex ) const;
       
   254     
       
   255         /**
       
   256         * Resets namespaces from the document
       
   257         *
       
   258         * @return void
       
   259         */
       
   260         void ResetNamespaces();
       
   261     
       
   262     private:
       
   263         
       
   264         /**
       
   265         * Symbian OS default constructor.
       
   266         * @param TInt Default Access Point ID
       
   267         * @return CXdmDocOperation*
       
   268         */     
       
   269         CXcapDocument( TXdmDocType aDocumentType,
       
   270                        const CXdmEngine& aXdmEngine,
       
   271                        const CXcapProtocol& aXcapProtocol );
       
   272         
       
   273         /**
       
   274         * From CActive.
       
   275         * @return void
       
   276         */
       
   277 		void RunL();
       
   278 
       
   279         /**
       
   280         * From CActive.
       
   281         * @return void
       
   282         */
       
   283 		void DoCancel();
       
   284 		
       
   285 	    /**
       
   286         * Symbian OS default constructor.
       
   287         * @param TInt Default Access Point ID
       
   288         * @return CXdmDocOperation*
       
   289         */    
       
   290 		void InstallAppUsageL();
       
   291 		
       
   292 		/**
       
   293         * Symbian OS default constructor.
       
   294         * @param TInt Default Access Point ID
       
   295         * @return CXdmDocOperation*
       
   296         */    
       
   297 		void UpdateDocumentInfoL( RXcapCache* aCacheClient );
       
   298 		
       
   299 		/**
       
   300         * Symbian OS default constructor.
       
   301         * @param TInt Default Access Point ID
       
   302         * @return CXdmDocOperation*
       
   303         */     
       
   304         void StartUpdateL();
       
   305         
       
   306         /**
       
   307         * Symbian OS default constructor.
       
   308         * @param TInt Default Access Point ID
       
   309         * @return CXdmDocOperation*
       
   310         */    
       
   311         void SaveClientStatus( TRequestStatus& aClientStatus );
       
   312         
       
   313         /**
       
   314         * Handle a failed update operation
       
   315         * @return void
       
   316         * @param CXdmDocOperation* The failed operation
       
   317         */
       
   318         void HandleErrorL();
       
   319         
       
   320         /**
       
   321         * Handle a successful update operation
       
   322         * @return void
       
   323         * @param The completed update operation
       
   324         */
       
   325         void HandleRequestCompletionL();
       
   326         
       
   327         /**
       
   328         * Handle a successful update operation
       
   329         * @return void
       
   330         * @param The completed update operation
       
   331         */
       
   332         void ResolveAsyncConflictL();
       
   333         
       
   334         /**
       
   335         * Handle a successful update operation
       
   336         * @return void
       
   337         * @param The completed update operation
       
   338         */
       
   339         void CreateTempCopyL();
       
   340         
       
   341         /**
       
   342         * Handle a successful update operation
       
   343         * @return void
       
   344         * @param The completed update operation
       
   345         */
       
   346         void ActivateOperationL();
       
   347         
       
   348         /**
       
   349         * Handle a successful update operation
       
   350         * @return void
       
   351         * @param The completed update operation
       
   352         */
       
   353         void CheckOperationQueueL();
       
   354         
       
   355         /**
       
   356         * Handle a successful update operation
       
   357         * @return void
       
   358         * @param The completed update operation
       
   359         */
       
   360         void DequeueOperation( MXdmOperation* aOperation );
       
   361         
       
   362         /**
       
   363         * Handle a successful update operation
       
   364         * @return void
       
   365         * @param The completed update operation
       
   366         */
       
   367         void DequeueAll();
       
   368         
       
   369         /**
       
   370         * Append an element to the path identifying the 
       
   371         * the current document subset
       
   372         * @return void
       
   373         */
       
   374         void AppendPathPartL( const TDesC& aString );
       
   375         
       
   376         /**
       
   377         * Return the current document subset (including descendants)
       
   378         * @return void
       
   379         */
       
   380         CXdmDocumentNode* CurrentExtent() const;
       
   381 
       
   382         /**
       
   383         * Handle a successful update operation
       
   384         * @return void
       
   385         * @param The completed update operation
       
   386         */                            
       
   387         HBufC8* EightBitNameLC();                                       
       
   388         
       
   389         /**
       
   390         * Handle a successful update operation
       
   391         * @return void
       
   392         * @param The completed update operation
       
   393         */    
       
   394         TBool IsGlobalTree( const TDesC8& aAuid );
       
   395         
       
   396         /**
       
   397         * Symbian OS default constructor.
       
   398         * @param TInt Default Access Point ID
       
   399         * @return CXdmDocOperation*
       
   400         */     
       
   401         void ConstructL();
       
   402         
       
   403         /**
       
   404         * Symbian OS default constructor.
       
   405         * @param TInt Default Access Point ID
       
   406         * @return CXdmDocOperation*
       
   407         */     
       
   408         void ConstructL( const TDesC8& aDocumentName );
       
   409         
       
   410     private:  //Data
       
   411 
       
   412         enum TXcapDocumentState
       
   413             {
       
   414             EXdmDocIdle = 0,
       
   415             EXdmDocUpdating,
       
   416             EResolvingAsyncConflict,
       
   417             ERetryingFailedOperation
       
   418             };
       
   419         
       
   420         TInt                                    iDataLength;
       
   421         TInt                                    iUpdateIndex;
       
   422         TInt                                    iOperationCount;
       
   423         TUint                                   iOptions;
       
   424         TTime                                   iLastAccess;
       
   425         TTime                                   iLastModification;
       
   426         HBufC8*                                 iEightBitName;
       
   427         TXdmDocType                             iDocumentType;
       
   428         CXcapDocument*                          iTempCopy;
       
   429         CXcapAppUsage*                          iAppUsage;
       
   430         CXcapDocumentNode*                      iDocumentRoot;
       
   431         CXdmDocumentNode*                       iErrorRoot;
       
   432         TXcapDocumentState                      iDocumentState;
       
   433         CXcapProtocol&                          iXcapProtocol;
       
   434         TBuf8<KETagBufferMaxLength>             iETagBuffer;
       
   435         RPointerArray<CXdmNamespace>            iNamespaces;
       
   436     };
       
   437 
       
   438 #endif      //__XCAPDOCUMENT__
       
   439             
       
   440 // End of File