syncmlfw/dm/callbackServer/inc/nsmldmcallbackserver.h
changeset 0 b497e44ab2fc
equal deleted inserted replaced
-1:000000000000 0:b497e44ab2fc
       
     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:  DM callback server header file
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __NSMLDMCALLBACKSERVER_H__
       
    21 #define __NSMLDMCALLBACKSERVER_H__
       
    22 
       
    23 // ---------------------------------------------------------------------------
       
    24 // Includes
       
    25 // ---------------------------------------------------------------------------
       
    26 #include <e32base.h>
       
    27 #include <badesca.h>
       
    28 #include <e32property.h>
       
    29 
       
    30 #include "nsmldmcallbackserverdefs.h"
       
    31 
       
    32 // ---------------------------------------------------------------------------
       
    33 // Panic reasons
       
    34 // ---------------------------------------------------------------------------
       
    35 
       
    36 enum TNSmlDmCallbackServerPanic
       
    37     {
       
    38     ECleanupCreateError,
       
    39     EMainSchedulerError
       
    40     };
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // Class forwards
       
    44 // ---------------------------------------------------------------------------
       
    45 class CNSmlDmDbHandler;
       
    46 struct TSmlDmMappingInfo;
       
    47 
       
    48 // ---------------------------------------------------------------------------
       
    49 // class CNSmlDmCallbackServer
       
    50 // ---------------------------------------------------------------------------
       
    51 /**
       
    52 * CNSmlDmCallbackServer is a Symbian OS server which owns the tree db handler
       
    53 * i.e. the tree db can be accessed only via IPC through this server.
       
    54 *
       
    55 *  @since
       
    56 */
       
    57 class CNSmlDmCallbackServer : public CServer2
       
    58 	{
       
    59 public:
       
    60 
       
    61 	/**
       
    62 	* Panics the server
       
    63 	* @param	aPanic			Panic code
       
    64 	*/
       
    65     static void PanicServer( TNSmlDmCallbackServerPanic aPanic );
       
    66 
       
    67 	/**
       
    68 	* Launches server thread
       
    69 	* @param	aStarted		Semaphore which is signallede when server
       
    70 	*							is started
       
    71 	*/
       
    72     static TInt ThreadFunction( TAny* aStarted );
       
    73 
       
    74 	/**
       
    75 	* Increase session count
       
    76 	*/
       
    77     void Increase();
       
    78 
       
    79 	/**
       
    80 	* Decrease session count
       
    81 	*/
       
    82     void Decrease();
       
    83 
       
    84 	/**
       
    85 	* Return session count
       
    86 	* @return			Session count
       
    87 	*/
       
    88 	TInt Count();
       
    89 	
       
    90 	/**
       
    91 	* Return pointer to db handler class
       
    92 	* @return			Pointer to db handler
       
    93 	*/
       
    94 	CNSmlDmDbHandler* DbHandler();
       
    95 	
       
    96 	/**
       
    97 	* Two-phased constructor
       
    98 	* @return						Pointer to newly created module instance
       
    99 	*/
       
   100     static CNSmlDmCallbackServer* NewL();
       
   101 
       
   102 	/**
       
   103 	* Destructor
       
   104 	*/
       
   105 	virtual ~CNSmlDmCallbackServer();
       
   106    
       
   107 public:
       
   108  	/**
       
   109 	* Creates new session
       
   110 	* @param	aVersion		Version for checking
       
   111 	* @param	aMessage		IPC message
       
   112 	*/
       
   113     CSession2* NewSessionL( const TVersion& aVersion,
       
   114     	const RMessage2& aMessage ) const;
       
   115 
       
   116 
       
   117 private:    
       
   118 	/**
       
   119 	* Constructor
       
   120 	*/
       
   121 	CNSmlDmCallbackServer();
       
   122 
       
   123 	/**
       
   124 	* Second phase constructor
       
   125 	*/
       
   126     void ConstructL();
       
   127     
       
   128 
       
   129 private:
       
   130 	/**
       
   131 	* Pointer to Dbhandler class
       
   132 	*/
       
   133     CNSmlDmDbHandler* iDbHandler;
       
   134 
       
   135 	/**
       
   136 	* Session count
       
   137 	*/
       
   138 	TInt iCount;
       
   139 	};
       
   140 
       
   141 // ---------------------------------------------------------------------------
       
   142 // class CNSmlDmCallbackSession 
       
   143 // ---------------------------------------------------------------------------
       
   144 /**
       
   145 * CNSmlDmCallbackSession is a Symbian OS server side session class which
       
   146 * handles the messages from one client
       
   147 *
       
   148 *  @since
       
   149 */
       
   150 class CNSmlDmCallbackSession : public CSession2
       
   151 	{
       
   152 public:
       
   153 	/**
       
   154 	* Two-phased constructor
       
   155 	* @param	aServer			Pointer to server (owner)
       
   156 	* @return					Pointer to newly created module instance
       
   157 	*/
       
   158 	static CNSmlDmCallbackSession* NewL( CNSmlDmCallbackServer& aServer);
       
   159 
       
   160     /**
       
   161     Handles the servicing of a client request that has been passed
       
   162     to the server.
       
   163 
       
   164 	@param aMessage The message containing the details of the client request.
       
   165     */
       
   166 	void ServiceL( const RMessage2 &aMessage );
       
   167 
       
   168 private:
       
   169 	
       
   170 	/**
       
   171 	* Called and TRAPped in ServiceL function. Directed to correct opertaion
       
   172 	* by aMessage.Function() information
       
   173 
       
   174 	@param aMessage		The message containing the details of the client
       
   175 	*					request.
       
   176     */
       
   177     void DispatchMessageL( const RMessage2 &aMessage );
       
   178 	    
       
   179 	/**
       
   180 	* SetServer IPC called. Sets the current server id into to db handler
       
   181 
       
   182 	@param aMessage		The message containing the details of the client
       
   183 	*					request.
       
   184     */
       
   185     void SetServerL( const RMessage2& aMessage );
       
   186 
       
   187 	/**
       
   188 	* Get Luid IPC called.Gets luid from Db handler
       
   189 
       
   190 	@param aMessage		The message containing the details of the client
       
   191 	*					request.
       
   192     */
       
   193     void GetLuidL( const RMessage2& aMessage );
       
   194 
       
   195 	/**
       
   196 	* Get Uri segment list IPC called. Gives list to the client
       
   197 
       
   198 	@param aMessage		The message containing the details of the client
       
   199 	*					request.
       
   200     */
       
   201     void GetUriSegListL( const RMessage2& aMessage );
       
   202 
       
   203 	/**
       
   204 	* Close connection IPC called. Closes connection and decreases session
       
   205 	* count. If Count is 0, server terminates itself.
       
   206 
       
   207 	@param aMessage		The message containing the details of the client
       
   208 	*					request.
       
   209     */
       
   210     void CloseConnectionL( const RMessage2& aMessage );
       
   211 
       
   212 	/**
       
   213 	* Generate luid IPC called. Gets the luid from db handler and return
       
   214 	* the length to client
       
   215 
       
   216 	@param aMessage		The message containing the details of the client
       
   217 	*request.
       
   218     */
       
   219     void GenerateLuidL(const RMessage2& aMessage );
       
   220 
       
   221 	/**
       
   222 	* Generate luidlist IPC called. Gets the list from db handler and makes
       
   223 	* it flat adn returns the length to client
       
   224 
       
   225 	@param aMessage		The message containing the details of the client
       
   226 	*request.
       
   227     */
       
   228     void GenerateUriSegListL(const RMessage2& aMessage );
       
   229 
       
   230 	/**
       
   231 	* Add mapping IPC called. Adds mappping by calling db handler
       
   232 
       
   233 	@param aMessage		The message containing the details of the client
       
   234 	*request.
       
   235     */
       
   236     void AddMappingInfoL( const RMessage2& aMessage );
       
   237 
       
   238 	/**
       
   239 	* Remove mapping IPC called. Removes mapping by alling db handler
       
   240 
       
   241 	@param aMessage		The message containing the details of the client
       
   242 	*request.
       
   243     */
       
   244     void RemoveMappingInfoL( const RMessage2& aMessage );
       
   245 
       
   246 	/**
       
   247 	* Rename mapping IPC called. Renames mapping by calling db handler
       
   248 
       
   249 	@param aMessage		The message containing the details of the client
       
   250 	*request.
       
   251     */
       
   252     void RenameMappingInfoL( const RMessage2& aMessage );
       
   253 
       
   254 	/**
       
   255 	* Update mapping IPC called. Updates mapping by calling db handler
       
   256 
       
   257 	@param aMessage		The message containing the details of the client
       
   258 	*request.
       
   259     */
       
   260     void UpdateMappingInfoL(const RMessage2& aMessage );
       
   261 
       
   262 	/**
       
   263 	* Delete ACL IPC called. Deletes correct ACL info by calling db handler
       
   264 
       
   265 	@param aMessage		The message containing the details of the client
       
   266 	*request.
       
   267     */
       
   268     void DeleteAclL(const RMessage2& aMessage );
       
   269 
       
   270 	/**
       
   271 	* Update ACL IPC called. Updates correct ACL info by calling db handler
       
   272 
       
   273 	@param aMessage		The message containing the details of the client
       
   274 	*request.
       
   275     */
       
   276     void UpdateAclL(const RMessage2& aMessage );
       
   277 
       
   278 	/**
       
   279 	* Get ACL length IPC called. Gets correct ACL info by calling db handler
       
   280 	* and return the length to client
       
   281 
       
   282 	@param aMessage		The message containing the details of the client
       
   283 	*request.
       
   284     */
       
   285     void GetAclLengthL(const RMessage2& aMessage );
       
   286 
       
   287 	/**
       
   288 	* Get ACL IPC called. Returns the correct ACL info to client
       
   289 
       
   290 	@param aMessage		The message containing the details of the client
       
   291 	*request.
       
   292     */
       
   293     void GetAclL(const RMessage2& aMessage );
       
   294 
       
   295 	/**
       
   296 	* Check ACL IPC called. Checks the asked ACL rights
       
   297 
       
   298 	@param aMessage		The message containing the details of the client
       
   299 	*request.
       
   300     */
       
   301     void CheckAclL(const RMessage2& aMessage );
       
   302 
       
   303 	/**
       
   304 	* Default ACLs to server IPC called. Sets the deafult acls to server
       
   305 	* by calling db handler
       
   306 
       
   307 	@param aMessage		The message containing the details of the client
       
   308 	*request.
       
   309     */
       
   310     void DefaultAclsToServerL(const RMessage2& aMessage );
       
   311 
       
   312 
       
   313 	/**
       
   314 	* Default ACLs to children IPC called. Sets the deafult acls to children
       
   315 	* which does not contain the earlier set acls.
       
   316 
       
   317 	@param aMessage		The message containing the details of the client
       
   318 	*request.
       
   319     */
       
   320   	void DefaultAclsToChildrenL(const RMessage2& aMessage);
       
   321 
       
   322 	/**
       
   323 	* Erase server id IPC called. Erases references to current server id
       
   324 	* by calling db handler
       
   325 
       
   326 	@param aMessage		The message containing the details of the client
       
   327 	*request.
       
   328     */
       
   329     void EraseServerIdL(const RMessage2& aMessage );
       
   330 
       
   331 	/**
       
   332 	* Atomic start indication
       
   333 	@param aMessage		The message containing the details of the client
       
   334 	*request.
       
   335     */
       
   336     void StartAtomic(const RMessage2& aMessage );
       
   337     
       
   338 	/**
       
   339 	* Commands inside the atomic committed
       
   340 	@param aMessage		The message containing the details of the client
       
   341 	*request.
       
   342     */
       
   343     void CommitAtomicL(const RMessage2& aMessage );
       
   344 
       
   345 	/**
       
   346 	* Commads inside atomic rolled back
       
   347 	@param aMessage		The message containing the details of the client
       
   348 	*request.
       
   349     */
       
   350     void RollbackAtomic(const RMessage2& aMessage );
       
   351 
       
   352 private:
       
   353 
       
   354 	/**
       
   355 	* Second phase constructor
       
   356     */
       
   357 	void ConstructL();
       
   358 
       
   359 	/**
       
   360 	* Constructor
       
   361     */
       
   362 	CNSmlDmCallbackSession( CNSmlDmCallbackServer& aServer);
       
   363 
       
   364 	/**
       
   365 	* Destructor
       
   366     */
       
   367 	~CNSmlDmCallbackSession();
       
   368 	
       
   369 private:
       
   370 	/**
       
   371 	* Pointer to server
       
   372     */
       
   373     CNSmlDmCallbackServer& iServer;
       
   374 
       
   375 	/**
       
   376 	* Flat segment list
       
   377     */
       
   378     CBufBase *iSegList;
       
   379 
       
   380 	/**
       
   381 	* Luid in case of getting luid
       
   382     */
       
   383     HBufC8* iLuid;
       
   384 
       
   385 	/**
       
   386 	* ACL info in case of getting ACL
       
   387     */
       
   388     CBufBase* iACL;
       
   389 
       
   390 	/**
       
   391 	* ACL URI in case of getting ACL
       
   392     */
       
   393     HBufC8* iACLUri;
       
   394 
       
   395 	/**
       
   396 	* Uri segment list in list format
       
   397     */
       
   398     CArrayFixFlat <TSmlDmMappingInfo>* iUriSegList;
       
   399     
       
   400 	/**
       
   401 	* List of acl uris in case of atomic
       
   402     */
       
   403    	RPointerArray<HBufC8> iAtomicAclURIs;
       
   404 
       
   405 	/**
       
   406 	* List of acl values in case of atomic
       
   407     */
       
   408 	RPointerArray<HBufC8> iAtomicAcls;
       
   409 	
       
   410 	/**
       
   411 	* True when atomic operation is going on
       
   412     */
       
   413 	TBool iAtomic;
       
   414 	};
       
   415 
       
   416 
       
   417 TInt LaunchServer();
       
   418 
       
   419 #endif // __NSMLDMCALLBACKSERVER_H__