installationservices/swinstallationfw/inc/siftransportserver.h
branchRCL_3
changeset 26 8b7f4e561641
parent 25 7333d7932ef7
child 27 e8965914fac7
equal deleted inserted replaced
25:7333d7932ef7 26:8b7f4e561641
     1 /*
       
     2 * Copyright (c) 2008-2009 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: 
       
    15 * The server side of the SIF Transport library
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 /**
       
    21  @file
       
    22  @internalComponent
       
    23 */
       
    24 
       
    25 #ifndef SIFTRANSPORTSERVER_H
       
    26 #define SIFTRANSPORTSERVER_H
       
    27 
       
    28 #include <f32file.h>
       
    29 #include <scs/scsserver.h>
       
    30 #include <usif/sif/sifcommon.h>
       
    31 #include <usif/sif/siftransporttask.h>
       
    32 #include "siftransportcommon.h"
       
    33 
       
    34 namespace Usif
       
    35 	{
       
    36 	// forward declaration
       
    37 	class CSifTransportServer;
       
    38 
       
    39 	/**
       
    40 	A SIF Transport session. It is instantiated by the @see CSifTransportServer class in response
       
    41 	to an incoming connection. The session instantiates an asynchronous request (an instance
       
    42 	of the @see CSifTransportRequest class) and hands over the processing of a request to it.
       
    43 	*/
       
    44 	class CSifTransportSession : public CScsSession
       
    45 		{
       
    46 	public:
       
    47 		/** Creates an instance of the CSifTransportSession class. */
       
    48 		static CSifTransportSession* NewL(CSifTransportServer &aServer, TransportTaskFactory::GenerateTask aTaskFactory);
       
    49 
       
    50 		/** Destroys an instance of the CSifTransportSession class. */
       
    51 		virtual ~CSifTransportSession();
       
    52 
       
    53 		/** Implements the CScsSession interface */
       
    54 		virtual TBool DoServiceL(TInt aFunction, const RMessage2& aMessage);
       
    55 
       
    56 	private:
       
    57 		CSifTransportSession(CSifTransportServer &aServer, TransportTaskFactory::GenerateTask aTaskFactory);
       
    58 
       
    59 		TransportTaskFactory::GenerateTask iTaskFactory;
       
    60 		TBool iExclusiveOperation;
       
    61 		};
       
    62 
       
    63 	/**
       
    64 	A SIF Transport server. It is instantiated by the system when a client submits a connection request.
       
    65 	The server instantiates a SIF Transport session object in response to an incoming software management
       
    66 	request and hands over further processing to it.
       
    67 	
       
    68 	This is a transient server which means that it is instantiated in response to an incoming connection
       
    69 	and shuts down itself, after timeout specified in @see StartTransportServer, if there are no sessions.
       
    70 	*/
       
    71 	class CSifTransportServer : public CScsServer
       
    72 		{
       
    73 	public:
       
    74 		/** Creates an instance of the CSifTransportSession class. */
       
    75 		IMPORT_C static CScsServer* NewSifTransportServerLC();
       
    76 
       
    77 		/** Destroys an instance of the CSifTransportServer class. */
       
    78 		virtual ~CSifTransportServer();
       
    79 
       
    80 		/** Implements the CScsServer interface */
       
    81 		virtual CScsSession* DoNewSessionL(const RMessage2& aMessage);
       
    82 
       
    83 	private:
       
    84 		friend TInt StartTransportServer(const TDesC& aServerName, const TVersion& aVersion, TransportTaskFactory::GenerateTask aTaskFactory, TInt aShutdownPeriodUs);
       
    85 		static CSifTransportServer* NewLC(const TDesC& aServerName, const TVersion& aVersion, TransportTaskFactory::GenerateTask aTaskFactory, TInt aShutdownPeriodUs);
       
    86 
       
    87 		CSifTransportServer(const TVersion& aVersion, TransportTaskFactory::GenerateTask aFactory);
       
    88 		void ConstructL(const TDesC& aServerName, TInt aShutdownPeriodUs);
       
    89 
       
    90 		TransportTaskFactory::GenerateTask iTaskFactory;
       
    91 		};
       
    92 
       
    93 	/**
       
    94 	A SIF Transport request. An instance of this object is created by @see CSifTransportSession
       
    95 	class to represent an asynchronous software management request. The request takes a task
       
    96 	factory in the @see CSifTransportRequest::CreateAndExecuteL() method and uses it to
       
    97 	instantiate an appropriate task and execute it.
       
    98 	 */
       
    99 	class CSifTransportRequest : public CAsyncRequest
       
   100 		{
       
   101 	public:
       
   102 		/** Creates an instance of the CSifTransportRequest class. */
       
   103 		static void CreateAndExecuteL(TInt aFunction, CSifTransportSession* aSession, TransportTaskFactory::GenerateTask aTaskFactory, const RMessage2& aMessage);
       
   104 		
       
   105 		/** Destroys an instance of the CSifTransportRequest class. */
       
   106 		virtual ~CSifTransportRequest();
       
   107 
       
   108 	private:
       
   109 		CSifTransportRequest(TInt aFunction, CSifTransportSession* aSession, const RMessage2& aMessage);
       
   110 		void PrepareParamsL();
       
   111 		void SetupRequestL(TransportTaskFactory::GenerateTask aTaskFactory);
       
   112 		TInt AdoptFileHandle(TInt aFunction, const RMessage2& aMessage);
       
   113 		
       
   114 		void ProcessTaskResultsL();
       
   115 		void ProcessOpaqueResultsL();
       
   116 		void LaunchTask();
       
   117 
       
   118 		// Implement CAsyncRequest and CActive
       
   119 		virtual void DoCleanup();
       
   120 		virtual void DoCancel();
       
   121 		virtual void RunL();
       
   122 
       
   123 	private:
       
   124 		enum { EInvalidComponentId = -1 };
       
   125 
       
   126 		RFile iFile;
       
   127 		TInt iFunction;
       
   128 		const TSecurityContext iSecurityContext;
       
   129 		TComponentId iComponentId;
       
   130 
       
   131 		// Task to be executed by the server and its params
       
   132 		CSifTransportTask* iTask;
       
   133 		TTransportTaskParams iParams;
       
   134 		TBool iTaskComplete;
       
   135 		};
       
   136 
       
   137 	// The string below must be up to 16 characters, otherwise it will be truncated
       
   138 	_LIT(KSifTransportServerRequestError, "SifTransportError");
       
   139 
       
   140 	} // End of namespace Usif
       
   141 
       
   142 #endif	// #ifndef SIFTRANSPORTSERVER_H