commonuisupport/uikon/srvinc/EIKBAKSV.H
changeset 0 2f259fa3e83a
child 4 8ca85d2f0db7
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @internalComponent
       
    19 */
       
    20 
       
    21 #ifndef __EIKBAKSV_H__
       
    22 #define __EIKBAKSV_H__
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <baksrv.h>
       
    26 #include <babackup.h>
       
    27 #include <badesca.h>
       
    28 #include <w32std.h>
       
    29 #include <apgcli.h>
       
    30 
       
    31 enum TEikBackupServPanic
       
    32 	{
       
    33 	EBadInternalState = 0,
       
    34 	};
       
    35 
       
    36 class MAppStarterObserver
       
    37 	{
       
    38 public:
       
    39 	virtual void HandleAppsStarted() = 0;
       
    40 	};
       
    41 
       
    42 class MAppShutterObserver
       
    43 	{
       
    44 public:
       
    45 	virtual void HandleAppsClosedL(TBool aAllAppsClosed) = 0;
       
    46 	};
       
    47 
       
    48 class CEikServAppShutter;
       
    49 class CEikServBackupServer;
       
    50 
       
    51 NONSHARABLE_CLASS(CEikServBackupSession) : public CBaServBackupSession, public MAppShutterObserver
       
    52 	{
       
    53 public:
       
    54 	static CEikServBackupSession* NewL();
       
    55 	~CEikServBackupSession();
       
    56 public: // from CBaServBackupSession
       
    57 	void HandleError(TInt aError);
       
    58 private: // from MAppShutterObserver
       
    59 	void HandleAppsClosedL(TBool aAllAppsClosed);
       
    60 private:
       
    61 	inline CEikServBackupSession() :CBaServBackupSession() {} 
       
    62 private: // from CBaServBackupSession
       
    63 	TCompletionType CloseAllFilesL(const RMessage2& aMessage);
       
    64 	void RestartAll();
       
    65 	void ServiceL(const RMessage2& aMessage);
       
    66 	void ServiceError(const RMessage2& aMessage,TInt aError);
       
    67 private:
       
    68 	static void CleanupCloseAllFiles(TAny* aPtr);
       
    69 	void DoRestartAll();
       
    70 	void PanicClientL(const RMessage2& aMessage,TEikBackupServPanic aCode);
       
    71 private:
       
    72 	CEikServAppShutter* iAppShutter;
       
    73 	};
       
    74 
       
    75 class CAppShutter;
       
    76 
       
    77 NONSHARABLE_CLASS(CAppWatcher) : public CActive
       
    78 	{
       
    79 public:
       
    80 	static CAppWatcher* NewL(TThreadId aThreadId,CAppShutter& aAppShutter,const CEikServBackupSession::TClosedFile& aClosedFile);
       
    81 	~CAppWatcher();
       
    82 	const CEikServBackupSession::TClosedFile& Info() const;
       
    83 private:
       
    84 	CAppWatcher(CAppShutter& aAppShutter,const CEikServBackupSession::TClosedFile& aClosedFile);
       
    85 	void ConstructL(TThreadId aThreadId);
       
    86 private: // from CActive
       
    87 	void DoCancel();
       
    88 	void RunL();
       
    89 	TInt RunError(TInt aError);
       
    90 private:
       
    91 	CAppShutter& iAppShutter;
       
    92 	CEikServBackupSession::TClosedFile iClosedFile;
       
    93 	RThread iThread;
       
    94 	};
       
    95 
       
    96 NONSHARABLE_CLASS(CAppShutter) : public CBase
       
    97 	{
       
    98 public:
       
    99 	static CAppShutter* StartL(MAppShutterObserver& aObserver,
       
   100 				   CArrayFix<CEikServBackupSession::TClosedFile>& aClosedFiles,
       
   101 				   CBaBackupServer& aBackupServer);
       
   102 
       
   103 	~CAppShutter();
       
   104 	void HandleAppClosedL(const CEikServBackupSession::TClosedFile& aClosedFile);
       
   105 private:
       
   106 	CAppShutter(MAppShutterObserver& aObserver,
       
   107  		    CArrayFix<CEikServBackupSession::TClosedFile>& aClosedFiles,
       
   108 		    CBaBackupServer& aBackupServer);
       
   109 
       
   110 	void ConstructL();
       
   111 	static TInt TimerCallBackL(TAny* aPtr);
       
   112 	void HandleTimerCallBackL();
       
   113 	void NextL();
       
   114 	TBool IsWgIdValid(TInt aWgId);
       
   115 	void CheckCompleteL();
       
   116 private:
       
   117 	NONSHARABLE_CLASS(CShutterTimer) : public CPeriodic
       
   118 		{
       
   119 	public:
       
   120 		static CShutterTimer* NewL(TInt aPriority);
       
   121 	protected: // from CActive
       
   122 		TInt RunError(TInt aError);
       
   123 	private:
       
   124 		CShutterTimer(TInt aPriority);
       
   125 		};
       
   126 private:
       
   127 	MAppShutterObserver& iObserver;
       
   128 	RWsSession iWsSession;
       
   129 	RArray<RWsSession::TWindowGroupChainInfo>* iWgIds;
       
   130 	CArrayFix<CEikServBackupSession::TClosedFile>& iClosedFiles;
       
   131 	CArrayPtr<CAppWatcher>* iAppWatchers;
       
   132 	CShutterTimer* iTimer;
       
   133 	TInt iNextWgIndex;
       
   134 	CBaBackupServer& iBackupServer;
       
   135 	TInt iCheckCount;
       
   136 	};
       
   137 
       
   138 NONSHARABLE_CLASS(CEikServAppShutter) : public CBase
       
   139 	{
       
   140 public:
       
   141 	CEikServAppShutter(const RMessage2& aMessage);
       
   142 	~CEikServAppShutter();
       
   143 	void ConstructL(MAppShutterObserver& aObserver,
       
   144 			CArrayFix<CEikServBackupSession::TClosedFile>& aClosedFiles,
       
   145 			CBaBackupServer* aBackupServer);
       
   146 
       
   147 	const RMessage2& Message() const;
       
   148 private:
       
   149 	CAppShutter* iShutter;
       
   150 	RMessage2 iMessage;
       
   151 	};
       
   152 
       
   153 class CAppStarter;
       
   154 
       
   155 NONSHARABLE_CLASS(CEikServBackupServer) : public CBaBackupServer, public MAppStarterObserver
       
   156 	{
       
   157 public:
       
   158 	IMPORT_C static CEikServBackupServer* NewL();
       
   159 public:
       
   160 	~CEikServBackupServer();
       
   161 private: // from CBaBackupServer
       
   162 	void ConstructL();
       
   163 	void CompleteClosingFiles(CArrayFix<CBaServBackupSession::TClosedFile>* aClosedFiles);
       
   164 	TBool IsOtherClientBusy(TUint32 aUniqueClientId) const;
       
   165 private: // from CServer
       
   166 	CSession2* NewSessionL(const TVersion &aVersion, const RMessage2& aMessage ) const;
       
   167 private: // from MAppStarterObserver
       
   168 	void HandleAppsStarted();
       
   169 private:
       
   170 	CEikServBackupServer(TInt aPriority);
       
   171 	inline TBool IsOtherClientBusy(TUint32 aUniqueClientId);
       
   172 	inline TBool IsClientBusy(TUint32 aUniqueClientId);
       
   173 private:
       
   174 	CAppStarter* iAppStarter;
       
   175 	};
       
   176 
       
   177 
       
   178 NONSHARABLE_CLASS(CAppStarter) : public CActive
       
   179 	{// Active object wraps the task of starting up apps in a thread
       
   180 public:
       
   181 	static CAppStarter* NewL(MAppStarterObserver& aObserver,CArrayFix<CEikServBackupSession::TClosedFile>* aClosedFiles);
       
   182 	~CAppStarter();
       
   183 private:
       
   184 	CAppStarter(MAppStarterObserver& aObserver, CArrayFix<CEikServBackupSession::TClosedFile>* aClosedFiles);
       
   185 	void ConstructL();
       
   186 
       
   187 	static TInt ThreadEntryPoint(TAny* aParams);
       
   188 	void StartAppsL();// Main thread function
       
   189 private: // from CActive
       
   190 	void DoCancel();
       
   191 	void RunL();
       
   192 private:
       
   193 	MAppStarterObserver& iObserver;
       
   194 	CArrayFix<CEikServBackupSession::TClosedFile>* iClosedFiles;// Object owned by CBaBackupServer. Resource ownership
       
   195 																// transferred to derived CEikServBackupServer
       
   196 	RThread iThread;
       
   197 	};
       
   198 
       
   199 #endif	// __EIKBAKSV_H__