brandingserver/BSServer/cbssession.h
changeset 31 9dbc70490d9a
equal deleted inserted replaced
30:1fa9b890f29c 31:9dbc70490d9a
       
     1 /*
       
     2 * Copyright (c) 2006 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 the License "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:  cbssession.h
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __CBSSESSION_H__
       
    21 #define __CBSSESSION_H__
       
    22 
       
    23 #include <e32base.h>
       
    24 #include <s32mem.h>
       
    25 #include "rbsobjowningptrarray.h"
       
    26 #include "bsserverdefs.h"
       
    27 #include "mbsbackupobserver.h"
       
    28 
       
    29 class CBSServer;
       
    30 class CBSBrandHandler;
       
    31 class MBSElement;
       
    32 class CBSStorageManager;
       
    33 
       
    34 /**
       
    35  * Service side session.
       
    36  *
       
    37  * @lib
       
    38  * @since
       
    39  */
       
    40  class CBSSession : public CSession2,
       
    41                     public MBSBackupObserver
       
    42     {
       
    43     
       
    44     
       
    45     public:
       
    46     	
       
    47     	/**
       
    48     	 * Class for encapsulating the session information.
       
    49     	 */
       
    50     	NONSHARABLE_CLASS( CBSSessionInfo ): public CBase
       
    51     		{
       
    52     		public:
       
    53 	    		
       
    54 	    		/**
       
    55 	    		 * Creates a new CBSSessionInfo
       
    56 	    		 *
       
    57 	    		 * @param aFileName the filename of the process, that created 
       
    58 	    		 *        this session
       
    59 	    		 * @param aCaption a caption of the process, that created this 
       
    60 	    		 *        session
       
    61 	    		 * @param aThreadId thread id where this session was created
       
    62 	    		 * @param aProcessId processId of the process, that created 
       
    63 	    		 *        this session
       
    64 	    		 * @return a new CBSSessionInfo instance
       
    65 	    		 */
       
    66 	    		static CBSSessionInfo* NewL( const TDesC& aFileName, 
       
    67 	    		                             const TDesC& aCaption,
       
    68 	    		                             TThreadId aThreadId,
       
    69 	    		                             TProcessId aProcessId );
       
    70         	    /**
       
    71                  * Destructor.
       
    72                  */  		
       
    73 	    		~CBSSessionInfo();
       
    74 	    		
       
    75     		private: 
       
    76 
       
    77                 /**
       
    78                  * Symbian second-phase constructor
       
    79                  *
       
    80 	    		 * @param aFileName the filename of the process, that created 
       
    81 	    		 *        this session
       
    82 	    		 * @param aCaption a caption of the process, that created this 
       
    83 	    		 *        session
       
    84                  */                    
       
    85 	    		void ConstructL( const TDesC& aFileName, 
       
    86 	    		                 const TDesC& aCaption );
       
    87 
       
    88                 /**
       
    89                  * Constructor.
       
    90 	    		 *
       
    91 	    		 * @param aThreadId thread id where this session was created
       
    92 	    		 * @param aProcessId processId of the process, that created 
       
    93 	    		 *        this session
       
    94                  */
       
    95 	    		CBSSessionInfo( TThreadId aThreadId, TProcessId aProcessId );
       
    96 			
       
    97 			public: 
       
    98 
       
    99 			    /**
       
   100                  * Returns the filename of the process, that created this 
       
   101                  * session.
       
   102                  *
       
   103                  * @return a filename
       
   104                  */ 
       
   105 				const TDesC& FileName();
       
   106 
       
   107 			    /**
       
   108                  * Returns the caption of the process, that created this 
       
   109 	    		 * session.
       
   110                  *
       
   111                  * @return a caption
       
   112                  */ 
       
   113 				const TDesC& Caption();
       
   114 
       
   115 			    /**
       
   116                  * Returns the thread id where this session was created.
       
   117                  *
       
   118                  * @return a thread id
       
   119                  */ 
       
   120 				TThreadId ThreadId();
       
   121 				
       
   122 			    /**
       
   123                  * Returns the processId of the process, that created 
       
   124 	    		 * this session.
       
   125                  *
       
   126                  * @return a process id
       
   127                  */ 
       
   128 				TProcessId ProcessId();
       
   129 				
       
   130 			private: // data
       
   131 				
       
   132                 /**
       
   133                  * Filename
       
   134                  * Own.
       
   135                  */
       
   136 				HBufC* 		iFileName;
       
   137 
       
   138                 /**
       
   139                  * Caption
       
   140                  * Own.
       
   141                  */
       
   142 			  	HBufC*      iCaption;
       
   143 			  	
       
   144                 /**
       
   145                  * Thread Id.
       
   146                  */
       
   147 			  	TThreadId  	iThreadId;
       
   148 
       
   149                 /**
       
   150                  * Process Id.
       
   151                  */
       
   152 			  	TProcessId  iProcessId;			  	
       
   153     		};      
       
   154     
       
   155     
       
   156     public:     // Constructors and destructors
       
   157         static CBSSession* NewL();
       
   158         virtual ~CBSSession();
       
   159 
       
   160 
       
   161     protected:  // C++ constructors
       
   162     	/**
       
   163         * C++ default constructor.
       
   164         */
       
   165         CBSSession();
       
   166 
       
   167         /**
       
   168         * Symbian OS constructor
       
   169         */
       
   170 		void ConstructL();
       
   171 
       
   172     public:     // Methods derived from CSession2
       
   173     	/**
       
   174     	* From CSession2
       
   175     	*/
       
   176         void CreateL();
       
   177     	/**
       
   178     	* From CSession2
       
   179     	*/
       
   180         void ServiceL( const RMessage2 &aMessage );
       
   181     	/**
       
   182     	* From CSession2
       
   183     	*/
       
   184         void ServiceError( const RMessage2& aMessage,
       
   185                            TInt aError );
       
   186 		
       
   187     public:     // From MBSBackupObserver
       
   188     
       
   189     	/*
       
   190     	* @see MBSBackupObserver
       
   191     	*/
       
   192 		void HandleBackupStateL( TBackupState aState );
       
   193 
       
   194 	public: // New methods
       
   195 		
       
   196         /**
       
   197         *
       
   198         */
       
   199         CBSServer* Server() { return (CBSServer*) CSession2::Server(); }
       
   200 
       
   201 
       
   202 		TBool MatchSessionL( const TDesC& aApplicationId,
       
   203 							 const TDesC& aBrandId,
       
   204 							 TLanguage aLanguageId,
       
   205 							 TInt aReserved );
       
   206 							 
       
   207 		TBool MatchSessionUninstallL( const TDesC& aApplicationId,
       
   208 								 const TDesC& aBrandId);
       
   209 								 
       
   210 		void BrandUpdatedL( const TDesC& aApplicationId,
       
   211 							 const TDesC& aBrandId,
       
   212 							 TLanguage aLanguageId,
       
   213 							 TInt aReserved );
       
   214 
       
   215 
       
   216 
       
   217 	    /**
       
   218          * Returns the filename of the process, that created this 
       
   219          * session.
       
   220          *
       
   221          * @return a filename
       
   222          */ 
       
   223 		const TDesC& FileName();
       
   224 
       
   225 	    /**
       
   226          * Returns the caption of the process, that created this 
       
   227 		 * session.
       
   228          *
       
   229          * @return a caption
       
   230          */ 
       
   231 		const TDesC& Caption();
       
   232 
       
   233 	    /**
       
   234          * Returns the thread id where this session was created.
       
   235          *
       
   236          * @return a thread id
       
   237          */ 
       
   238 		TInt ThreadId( TThreadId& aThreadId );
       
   239 		
       
   240 	    /**
       
   241          * Returns the processId of the process, that created 
       
   242 		 * this session.
       
   243          *
       
   244          * @return a process id
       
   245          */
       
   246         TInt ProcessId( TProcessId& aProcessId );
       
   247 
       
   248         /**
       
   249          * Returns, if the session info for this object is available.
       
   250          *
       
   251          * @return ETrue, if information about this object is available;
       
   252          *         EFalse otherwise
       
   253          */
       
   254         TBool InfoAvailable();
       
   255 
       
   256         
       
   257     private:    // New methods
       
   258 
       
   259         /**
       
   260 		*  Dispatch clients message
       
   261 		*
       
   262 		*  @since
       
   263 		*  @param aMessage client's message
       
   264         */
       
   265         TBool DispatchMessageL( const RMessage2 &aMessage );
       
   266 
       
   267 
       
   268 		/**
       
   269 		* Initializes the server
       
   270 		* @param aMessage client's message
       
   271 		*/
       
   272         void InitUpdateL( const RMessage2 &aMessage, TTransactionType aType );
       
   273 
       
   274 		/**
       
   275 		* Initializes the server
       
   276 		* @param aMessage client's message
       
   277 		*/
       
   278         void InitAccessL( const RMessage2 &aMessage );
       
   279 
       
   280 
       
   281 		/**
       
   282 		* Get text type branding item
       
   283 		* @param aMessage client's message
       
   284 		*/
       
   285         void GetTextL( const RMessage2 &aMessage );
       
   286 
       
   287 		/**
       
   288 		* Get text type branding item
       
   289 		* @param aMessage client's message
       
   290 		*/
       
   291         void GetBufferL( const RMessage2 &aMessage );
       
   292 
       
   293 		/**
       
   294 		* Get integer type branding item
       
   295 		* @param aMessage client's message
       
   296 		*/
       
   297         void GetIntL( const RMessage2 &aMessage );
       
   298 
       
   299 		/**
       
   300 		* Get file type branding item
       
   301 		* @param aMessage client's message
       
   302 		*/
       
   303         void GetFileL( const RMessage2 &aMessage );
       
   304 
       
   305 		/**
       
   306 		* Prepares several textual type branding items.
       
   307 		* These have to be fetched with GetSeveralText.
       
   308 		* @param aMessage client's message
       
   309 		*/
       
   310         void PrepareSeveralL( const RMessage2 &aMessage );
       
   311 
       
   312 		/**
       
   313 		* Gets the several textual branding items
       
   314 		* previously prepared.
       
   315 		* @param aMessage client's message
       
   316 		*/
       
   317         void GetSeveralL( const RMessage2 &aMessage );
       
   318 
       
   319 
       
   320 		/**
       
   321 		* Prepares several structure type branding items.
       
   322 		* These have to be fetched with GetStructure.
       
   323 		* @param aMessage client's message
       
   324 		*/
       
   325         void PrepareStructureL( const RMessage2 &aMessage );
       
   326 
       
   327 		/**
       
   328 		* Gets the several structure type branding items
       
   329 		* previously prepared.
       
   330 		* @param aMessage client's message
       
   331 		*/
       
   332         void GetStructureL( const RMessage2 &aMessage );
       
   333 
       
   334 		void isBrandUpdateRequiredL (const RMessage2 &aMessage);
       
   335 
       
   336 
       
   337 
       
   338 		/**
       
   339 		* 
       
   340 		* 
       
   341 		* @param aMessage client's message
       
   342 		*/
       
   343         void InstallL( const RMessage2 &aMessage );
       
   344 
       
   345 		/**
       
   346 		* 
       
   347 		* 
       
   348 		* @param aMessage client's message
       
   349 		*/
       
   350         void ReplaceL( const RMessage2 &aMessage );
       
   351 
       
   352 
       
   353 		/**
       
   354 		* 
       
   355 		* 
       
   356 		* @param aMessage client's message
       
   357 		*/
       
   358         void AppendL( const RMessage2 &aMessage );
       
   359 		
       
   360 		/**
       
   361 		* 
       
   362 		* 
       
   363 		* @param aMessage client's message
       
   364 		*/
       
   365 		MBSElement* InternalizeElementL( RReadStream& aStream, TBool aAppending = EFalse );
       
   366 
       
   367 
       
   368 		/**
       
   369 		* Cancels the transaction
       
   370 		*/
       
   371         void StartTransactionL( const RMessage2 &aMessage );
       
   372 
       
   373 
       
   374 		/**
       
   375 		* Cancels the transaction
       
   376 		*/
       
   377         void CancelTransactionL( const RMessage2 &aMessage );
       
   378 
       
   379 		/**
       
   380 		* Finishes the transaction
       
   381 		*/
       
   382         void StopTransactionL( const RMessage2 &aMessage );
       
   383 
       
   384 
       
   385 		/**
       
   386 		* Internalize element ids
       
   387 		*/
       
   388         void InternalizeElementIdsL( RReadStream& aStream, RBSObjOwningPtrArray<HBufC8>& aArray );
       
   389 
       
   390 		/**
       
   391 		* 
       
   392 		* 
       
   393 		* @param aMessage client's message
       
   394 		*/
       
   395         void RemoveBrandL( const RMessage2 &aMessage );
       
   396 
       
   397 
       
   398 		/**
       
   399 		* 
       
   400 		* 
       
   401 		* @param aMessage client's message
       
   402 		*/
       
   403         void RemoveApplicationL( const RMessage2 &aMessage );
       
   404 
       
   405 		void PrepareAppendL();
       
   406 		
       
   407 		void PrepareReplaceL();
       
   408 		
       
   409 		TInt GetNewVersionL();
       
   410 
       
   411 
       
   412         /**
       
   413          * Extracts some information from the specified RMessage2
       
   414          * and saves it.
       
   415          *
       
   416          * @param aMessage a message from a client
       
   417          */
       
   418         void ExtractInfoL( const RMessage2& aMessage );
       
   419 
       
   420     private:    // Data
       
   421     	TBool iInitialized;
       
   422     	TBool iAppending;
       
   423     	TBool iAccessInit;
       
   424     	TBool iWriteNeeded;
       
   425     	
       
   426     	// is backup process currently active
       
   427     	TBool iBackupActive;
       
   428     	
       
   429     	HBufC* iBrandId;
       
   430     	HBufC* iDefaultBrandId;
       
   431     	HBufC* iApplicationId;
       
   432     	TLanguage iLanguageId;
       
   433     
       
   434         TInt iValue;
       
   435         HBufC* iText;
       
   436         CBSBrandHandler* iBranding;
       
   437         CBufFlat* iSeveralData;
       
   438         HBufC8*		iBuffer;
       
   439         TBool iMessageCompleted;
       
   440         
       
   441         CBSStorageManager* iStorageManager;
       
   442         
       
   443         TBool iObserverActive;
       
   444         RMessage2 iObserverMessage;
       
   445         
       
   446         // To send backup event to client
       
   447         TBool iIsBackup ;
       
   448 		TInt iReserved;
       
   449         
       
   450         /**
       
   451          * Contains information about this object.
       
   452          * Own.
       
   453          */
       
   454         CBSSessionInfo* iSessionInfo;
       
   455 		
       
   456     };
       
   457 
       
   458 #endif      //  __CBSSESSION_H__
       
   459 
       
   460 
       
   461 //  END OF FILE
       
   462