deviceencryption/DevEncDmAdapter/inc/DevEncAdapter.h
changeset 0 6a9f87576119
equal deleted inserted replaced
-1:000000000000 0:6a9f87576119
       
     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:  Camera Control DM Adapter.
       
    15 *
       
    16 */
       
    17 #ifndef __DEVENCADAPTER_H
       
    18 #define __DEVENCADAPTER_H
       
    19 
       
    20 // INCLUDES
       
    21 #include <e32base.h>
       
    22 #include <smldmadapter.h>
       
    23 #include <centralrepository.h>
       
    24 #include <featurecontrol.h>
       
    25 #include <DevEncEngineConstants.h>
       
    26 #include <DevEncDiskUtils.h>
       
    27 #include <DevEncKeyUtils.h>
       
    28 #include <DevEncSession.h>
       
    29 
       
    30 enum TDevEncCommand
       
    31     {
       
    32     EDmDecrypt = 0,
       
    33     EDmEncryptDefault,
       
    34     EDmEncryptBackup,
       
    35     EDmEncryptRestore
       
    36     };
       
    37     
       
    38 
       
    39 // CLASS DECLARATION
       
    40 
       
    41 /**
       
    42 * Adapter class
       
    43 * Provides DM adapter interface
       
    44 */
       
    45 class CDevEncAdapter : public CSmlDmAdapter
       
    46     {
       
    47     
       
    48     public: // Constructors, destructor
       
    49         /**
       
    50         * Create instance of CDevEncAdapter
       
    51         * @param aDmCallBack
       
    52         * @return Instance of CDevEncAdapter
       
    53         */    
       
    54         static CDevEncAdapter* NewL( MSmlDmCallback* aDmCallback );
       
    55 
       
    56         /**
       
    57         * Create instance of CDevEncAdapter
       
    58         * @param aDmCallBack
       
    59         * @return Instance of CDevEncAdapter
       
    60         */   
       
    61         static CDevEncAdapter* NewLC( MSmlDmCallback* aDmCallback );
       
    62 
       
    63         /**
       
    64         * C++ Destructor
       
    65         */
       
    66         virtual ~CDevEncAdapter();
       
    67 
       
    68     public:
       
    69 	    /**
       
    70 	    * The function returns current version of the DDF.
       
    71 	    * By asking current DDF versions from adapters DM Module can control
       
    72 	    * possible changes in the data structure and send the changed DDF
       
    73 	    * description to a management server.
       
    74 	    * This function is always called after DDFStructureL.
       
    75         * @param aVersion DDF version of the adapter. (filled by the adapter)
       
    76 	    * @publishedPartner
       
    77 	    * @prototype
       
    78 	    */
       
    79 	    void DDFVersionL( CBufBase& aVersion );
       
    80 	
       
    81 	    /**
       
    82 	    * The function for filling the DDF structure of the adapter
       
    83 	    * This function is only called once, immediately after the adapter is created.
       
    84 	    * @param aDDFObject	Reference to root object. A DM adapter starts filling
       
    85 		         the data structure by calling AddChildObjectL to the root object and
       
    86 				 so describes the DDF of the adapter. 
       
    87 	    * @publishedPartner
       
    88 	    * @prototype
       
    89 	    */
       
    90         void DDFStructureL( MSmlDmDDFObject& aDDF );
       
    91 	
       
    92 	    /**
       
    93 	    * The function creates new leaf objects, or replaces data in existing leaf
       
    94 	    * objects. The information about the success of the command should be
       
    95 	    * returned by calling SetStatusL function of MSmlDmCallback callback
       
    96 	    * interface. This makes it possible to buffer the commands. However, all
       
    97 	    * the status codes for buffered commands must be returned at the latest when
       
    98 	    * the adapter's CompleteOutstandingCmdsL() is called.
       
    99 	    * @param aURI			URI of the object
       
   100 	    * @param aLUID		LUID of the object (if the adapter has earlier returned a
       
   101 	 	     				LUID to the DM Module). For new objects, this is the LUID
       
   102  			    			inherited through the parent node.
       
   103  	    * @param aObject		Data of the object. 
       
   104 	    * @param aType		MIME type of the object
       
   105 	    * @param aStatusRef	Reference to correct command, i.e. this reference
       
   106 	 					must be used when calling the SetStatusL of this command
       
   107 	    * @publishedPartner
       
   108 	    * @prototype
       
   109 	    */
       
   110 	    void UpdateLeafObjectL( const TDesC8& aURI, 
       
   111 	                            const TDesC8& aLUID,
       
   112 			                    const TDesC8& aObject, 
       
   113 			 				    const TDesC8& aType,
       
   114 							    TInt aStatusRef 
       
   115 							  );
       
   116 		
       
   117         /**
       
   118 	    * The function creates new leaf objects, or replaces data in existing leaf
       
   119 	    * objects, in the case where data is large enough to be streamed. The
       
   120 	    * information about the success of the command should be returned by calling
       
   121 	    * SetStatusL function of MSmlDmCallback callback interface. This makes it
       
   122 	    * possible to buffer the commands.  However, all the status codes for buffered
       
   123 	    * commands must be returned at the latest when the CompleteOutstandingCmdsL()
       
   124 	    * of adapter is called.
       
   125 	    * @param aURI		URI of the object
       
   126 	    * @param aLUID		LUID of the object (if the adapter has earlier returned a
       
   127     						LUID to the DM Module). For new objects, this is the LUID
       
   128 	    					inherited through the parent node.
       
   129 	    * @param aStream	Data of the object. Adapter should create write stream
       
   130 		    				and return, when data is written to stream by DM agent,
       
   131 			    			StreamCommittedL() is called by DM engine
       
   132 	    * @param aType		MIME type of the object
       
   133 	    * @param aStatusRef	Reference to correct command, i.e. this reference
       
   134     						must be used when calling the SetStatusL of this
       
   135 		    				command.
       
   136 	    * @publishedPartner
       
   137 	    * @prototype
       
   138 	    */
       
   139 	    void UpdateLeafObjectL( const TDesC8& aURI, 
       
   140 	                            const TDesC8& aLUID,
       
   141 								RWriteStream*& aStream, 
       
   142 								const TDesC8& aType,
       
   143 		 						TInt aStatusRef 
       
   144 		 				      );
       
   145 	
       
   146 	    /**
       
   147 	    * The function deletes an object and its child objects. The SetStatusL
       
   148 	    * should be used as described in UpdateLeafObjectL()
       
   149 	    * @param aURI		URI of the object
       
   150 	    * @param aLUID		LUID of the object (if the adapter have earlier returned
       
   151     						LUID to the DM Module).
       
   152 	    * @param aStatusRef	Reference to correct command, i.e. this reference must
       
   153 						be used when calling the SetStatusL of this command.
       
   154         * @publishedPartner
       
   155 	    * @prototype
       
   156 	    */
       
   157 	    void DeleteObjectL( const TDesC8& aURI, 
       
   158 	                        const TDesC8& aLUID,
       
   159 							TInt aStatusRef 
       
   160 					      );
       
   161 	
       
   162 	    /**
       
   163 	    * The function fetches data of a leaf object. The SetStatusL should be used
       
   164 	    * as described in UpdateLeafObjectL(). The data is returned by using the
       
   165 	    * SetResultsL function of MSmlCallback callback interface, and may be streamed.
       
   166 	    * @param aURI			URI of the object
       
   167 	    * @param aLUID			LUID of the object (if the adapter have earlier
       
   168     							returned LUID to the DM Module).   
       
   169 	    * @param aType 			MIME type of the object
       
   170 	    * @param aResultsRef	Reference to correct results, i.e. this reference
       
   171     							must be used when returning the result by calling
       
   172 	    						the SetResultsL.
       
   173 	    * @param aStatusRef		Reference to correct command, i.e. this reference
       
   174 		    					must be used when calling the SetStatusL of this
       
   175     							command.
       
   176 	    * @publishedPartner
       
   177 	    * @prototype
       
   178 	    */
       
   179 	    void FetchLeafObjectL( const TDesC8& aURI, 
       
   180 	                           const TDesC8& aLUID,
       
   181 							   const TDesC8& aType, 
       
   182 							   TInt aResultsRef,
       
   183 							   TInt aStatusRef 
       
   184 							 );
       
   185 	
       
   186 	    /**
       
   187 	    * The function fetches the size of the data of a leaf object. The size is
       
   188 	    * in bytes, and must reflect the number of bytes that will be transferred
       
   189 	    * when the framework calls FetchLeafObjectL. The SetStatusL should be used
       
   190 	    * as described in FetchLeafObjectL(). The size value is returned by using
       
   191 	    * the SetResultsL function of MSmlCallback callback interface, and must be
       
   192 	    * a decimal integer expressed as a string, eg. "1234".
       
   193 	    * Results from this call MUST NOT be streamed.
       
   194 	    * @param aURI			URI of the object
       
   195 	    * @param aLUID			LUID of the object (if the adapter have earlier
       
   196     							returned LUID to the DM Module).   
       
   197 	    * @param aType 			MIME type of the object
       
   198 	    * @param aResultsRef	Reference to correct results, i.e. this reference
       
   199     							must be used when returning the result by calling
       
   200 	    						the SetResultsL.
       
   201 	    * @param aStatusRef		Reference to correct command, i.e. this reference
       
   202      							must be used when calling the SetStatusL of this
       
   203 	    						command.
       
   204 	    * @publishedPartner
       
   205 	    * @prototype
       
   206 	    */
       
   207 	    void FetchLeafObjectSizeL( const TDesC8& aURI, 
       
   208 	                               const TDesC8& aLUID,
       
   209 								   const TDesC8& aType, 
       
   210 								   TInt aResultsRef,
       
   211 								   TInt aStatusRef 
       
   212 								 );
       
   213 	    /**
       
   214 	    * The function fetches URI list. An adapter returns the list of URI segments
       
   215 	    * under the given URI be separated by slash ("/"). The URI segment names for
       
   216 	    * new objects must be given by the adapter.
       
   217 	    * The list is returned by calling the SetResultsL function of MSmlCallback
       
   218 	    * callback interface.	Results from this call MUST NOT be streamed.
       
   219 	    * @param aParentURI					URI of the parent object
       
   220 	    * @param aParentLUID				LUID of the parent object (if the
       
   221     										adapter have earlier returned LUID to
       
   222 		    								the DM Module).   
       
   223 	    * @param aPreviousURISegmentList	URI list with mapping LUID information,
       
   224 			    							which is known by DM engine. An adapter
       
   225 				    						can use this information when verifying
       
   226 					    					if old objects still exists. An adapter
       
   227 						    				also knows what objects are new to DM
       
   228 							    			engine and can provide LUID mapping for
       
   229 								    		them. aPreviousURISegmentList parameter
       
   230 									    	(see above) helps to recognise new
       
   231     										objects.
       
   232 	    * @param aResultsRef				Reference to correct results, i.e. this
       
   233     										reference must be used when returning
       
   234 	    									the result by calling the SetResultsL.
       
   235 	    * @param aStatusRef					Reference to correct command, i.e. this
       
   236 		    								reference must be used when calling the
       
   237 			    							SetStatusL of this command.
       
   238 	    * @publishedPartner
       
   239 	    * @prototype
       
   240 	    */
       
   241 	    void ChildURIListL( const TDesC8& aURI, 
       
   242 	                        const TDesC8& aLUID,
       
   243 					        const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList,
       
   244 					        TInt aResultsRef, 
       
   245 					        TInt aStatusRef 
       
   246 					      );
       
   247 	
       
   248         /**
       
   249 	    * The function adds node object. In some cases an implementation of the
       
   250 	    * function may be empty function, if the node object does not need concrete
       
   251 	    * database update. Still this function may be helpful to an adapter, i.e. in
       
   252 	    * passing mapping LUID of the node to DM Module. The SetStatusL should be
       
   253 	    * used as described in UpdateLeafObjectL()
       
   254 	    * @param aURI			URI of the object
       
   255 	    * @param aParentLUID	LUID of the parent object (if the adapter have
       
   256      							earlier returned LUID to the DM Module).   
       
   257 	    * @param aStatusRef		Reference to correct command, i.e. this reference
       
   258 		    					must be used when calling the SetStatusL of this
       
   259 			    				command.
       
   260 	    * @publishedPartner
       
   261 	    * @prototype
       
   262 	    */
       
   263 	    void AddNodeObjectL( const TDesC8& aURI, 
       
   264 	                         const TDesC8& aParentLUID,
       
   265 		  					 TInt aStatusRef 
       
   266 		  				   );
       
   267 
       
   268 	    /**
       
   269 	    * The function implements execute command. The information about the success
       
   270 	    * of the command should be returned by calling SetStatusL function of
       
   271 	    * MSmlDmCallback callback interface. This makes it possible to buffer the
       
   272 	    * commands.
       
   273 	    * However, all the status codes for buffered commands must be returned at
       
   274 	    * the latest when the CompleteOutstandingCmdsL() of adapter is called.
       
   275 	    * @param aURI			URI of the command
       
   276 	    * @param aLUID			LUID of the object (if the adapter have earlier
       
   277     							returned LUID to the DM Module).   
       
   278 	    * @param aArgument		Argument for the command
       
   279 	    * @param aType			MIME type of the object 
       
   280 	    * @param aStatusRef		Reference to correct command, i.e. this reference
       
   281     							must be used when calling the SetStatusL of this
       
   282 	    						command.
       
   283 	    * @publishedPartner
       
   284 	    * @prototype
       
   285 	    */
       
   286 	    void ExecuteCommandL( const TDesC8& aURI, 
       
   287 	                          const TDesC8& aLUID,
       
   288 							  const TDesC8& aArgument, 
       
   289 							  const TDesC8& aType,
       
   290 							  TInt aStatusRef 
       
   291 							);
       
   292 
       
   293 	    /**
       
   294 	    * The function implements execute command. The information about the
       
   295 	    * success of the command should be returned by calling SetStatusL function
       
   296 	    * of MSmlDmCallback callback interface. This makes it possible to buffer the
       
   297 	    * commands.
       
   298 	    * However, all the status codes for buffered commands must be returned at
       
   299 	    * the latest when the CompleteOutstandingCmdsL() of adapter is called.
       
   300 	    * @param aURI			URI of the command
       
   301 	    * @param aLUID			LUID of the object (if the adapter have earlier
       
   302     							returned LUID to the DM Module).   
       
   303 	    * @param aStream		Argument for the command. Adapter should create
       
   304 		    					write stream and return, when data is written to
       
   305 			    				stream by DM agent, StreamCommittedL() is called by
       
   306 				    			DM engine
       
   307 	    * @param aType			MIME type of the object 
       
   308 	    * @param aStatusRef		Reference to correct command, i.e. this reference
       
   309     							must be used when calling the SetStatusL of this
       
   310 	    						command.
       
   311 	    * @publishedPartner
       
   312 	    * @prototype
       
   313 	    */
       
   314 	    void ExecuteCommandL( const TDesC8& aURI, 
       
   315 	                          const TDesC8& aLUID,
       
   316 							  RWriteStream*& aStream, 
       
   317 							  const TDesC8& aType,
       
   318 							  TInt aStatusRef 
       
   319 							);
       
   320 
       
   321 	    /**
       
   322 	    * The function implements copy command. The information about the success of
       
   323 	    * the command should be returned by calling SetStatusL function of
       
   324 	    * MSmlDmCallback callback interface. This makes it possible to buffer the
       
   325 	    * commands.
       
   326 	    * However, all the status codes for buffered commands must be returned at
       
   327 	    * the latest when the CompleteOutstandingCmdsL() of adapter is called.
       
   328 	    * @param aTargetURI		Target URI for the command
       
   329 	    * @param aSourceLUID	LUID of the target object (if one exists, and if the adapter
       
   330     							has	earlier returned a LUID to the DM Module).   
       
   331 	    * @param aSourceURI		Source URI for the command
       
   332 	    * @param aSourceLUID	LUID of the source object (if the adapter has
       
   333     							earlier returned a LUID to the DM Module).   
       
   334 	    * @param aType			MIME type of the objects
       
   335 	    * @param aStatusRef		Reference to correct command, i.e. this reference
       
   336     							must be used when calling the SetStatusL of this
       
   337 	    						command.
       
   338 	    * @publishedPartner
       
   339 	    * @prototype
       
   340 	    */
       
   341 	    void CopyCommandL( const TDesC8& aTargetURI, 
       
   342 	                       const TDesC8& aTargetLUID,
       
   343 						   const TDesC8& aSourceURI, 
       
   344 						   const TDesC8& aSourceLUID,
       
   345 						   const TDesC8& aType, 
       
   346 						   TInt aStatusRef 
       
   347 						 );
       
   348 
       
   349 	    /**
       
   350 	    * The function indicates start of Atomic command.
       
   351 	    * @publishedPartner
       
   352 	    * @prototype
       
   353 	    */
       
   354 	    void StartAtomicL();
       
   355 	
       
   356 	    /**
       
   357 	    * The function indicates successful end of Atomic command. The adapter
       
   358 	    * should commit all changes issued between StartAtomicL() and
       
   359 	    * CommitAtomicL()
       
   360 	    * @publishedPartner
       
   361 	    * @prototype
       
   362 	    */
       
   363 	    void CommitAtomicL();
       
   364 	
       
   365 	    /**
       
   366 	    * The function indicates unsuccessful end of Atomic command. The adapter
       
   367 	    * should rollback all changes issued between StartAtomicL() and
       
   368 	    * RollbackAtomicL(). If rollback fails for a command, adapter should use
       
   369 	    * SetStatusL() to indicate it.
       
   370 	    * @publishedPartner
       
   371 	    * @prototype
       
   372 	    */
       
   373 	    void RollbackAtomicL();
       
   374 	
       
   375 	    /**
       
   376         * Returns ETrue if adapter supports streaming otherwise EFalse.
       
   377 	    * @param aItemSize size limit for stream usage
       
   378         * @return TBool ETrue for streaming support
       
   379 	    * @publishedPartner
       
   380 	    * @prototype
       
   381         */
       
   382 	    TBool StreamingSupport( TInt& aItemSize );
       
   383 	
       
   384 	    /**
       
   385         * Called when stream returned from UpdateLeafObjectL or ExecuteCommandL has
       
   386 	    * been written to and committed. Not called when fetching item.
       
   387 	    * @publishedPartner
       
   388 	    * @prototype
       
   389         */	
       
   390 	    void StreamCommittedL();
       
   391 	
       
   392 	    /**
       
   393 	    * The function tells the adapter that all the commands of the message that
       
   394 	    * can be passed to the adapter have now been passed.  This indicates that
       
   395 	    * the adapter must supply status codes and results to any buffered commands.
       
   396 	    * This must be done at latest by the time this function returns.
       
   397 	    * This function is used at the end of SyncML messages, and during processing
       
   398 	    * of Atomic.   In the case of Atomic processing, the function will be
       
   399 	    * followed by a call to CommitAtomicL or RollbackAtomicL.
       
   400 	    * @publishedPartner
       
   401 	    * @prototype
       
   402 	    */
       
   403 	    void CompleteOutstandingCmdsL();
       
   404 
       
   405     private: // New methods
       
   406         void FillNodeInfoL( MSmlDmDDFObject& aDDFObject, 
       
   407                             TSmlDmAccessTypes& aAccessTypes, 
       
   408                             MSmlDmDDFObject::TScope aScope,
       
   409                             MSmlDmDDFObject::TDFFormat aFormat, 
       
   410                             MSmlDmDDFObject::TOccurence aOccurence,
       
   411                             const TDesC8& aDescription,
       
   412                             const TDesC8& aMIMEType );
       
   413         
       
   414         TPtrC8 CDevEncAdapter::LastURISeg( const TDesC8& aURI );
       
   415 
       
   416         HBufC8* CDevEncAdapter::AskPassWordL();
       
   417         
       
   418         TBool CheckBatteryL();
       
   419 
       
   420     private: // Constructor
       
   421         /**
       
   422         * Symbian 2nd phase constructor
       
   423         */
       
   424         void ConstructL();
       
   425 
       
   426         /**
       
   427         * C++ Constructor
       
   428         */    
       
   429         CDevEncAdapter( TAny* aEcomArguments );
       
   430                                                                                  
       
   431     private: // Data
       
   432         CDevEncDiskUtils*   iDiskUtils;
       
   433         CDevEncKeyUtils*    iKeyUtils;
       
   434         CDevEncSession*     iPhoneMemorySession;
       
   435         CDevEncSession*     iMemoryCardSession;
       
   436         TInt                iStatusRef;
       
   437         TInt                iResultRef;
       
   438         HBufC8*             iPkcs5Key;
       
   439         CRepository*        iUiCenRep;
       
   440         TBool               iPhoneMemOpPending;
       
   441         TBool               iMemCardOpPending;
       
   442         TInt                iPendingCommand;
       
   443         RTimer              iTimer;
       
   444         
       
   445     };
       
   446 
       
   447 #endif // __CDevEncAdapter_H
       
   448 
       
   449 // End Of File
       
   450