appfw/apparchitecture/apserv/apsnnapps.h
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 // Copyright (c) 2007-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 // apsnnapps.h
       
    15 //
       
    16 
       
    17 #ifndef APSNNAPPS_H
       
    18 #define APSNNAPPS_H
       
    19 
       
    20 #include <e32base.h>
       
    21 #include <f32file.h>
       
    22 #include <s32file.h>
       
    23 #include <badesca.h>	// typedef CDesCArray
       
    24 
       
    25 #include "apsnnappupdates.h"
       
    26 
       
    27 // classes referenced
       
    28 class CApaAppArcServer;
       
    29 class CApsNonNativeApplicationsUpdateList;
       
    30 
       
    31 _LIT(KLitPathForTemporaryNonNativeResourceAndIconFiles, "\\private\\10003a3f\\temp\\NonNativeUpdates\\");
       
    32 
       
    33 /**
       
    34 @internalComponent
       
    35 */
       
    36 NONSHARABLE_CLASS(CApsNonNativeApplicationsManager) : public CBase
       
    37 	{
       
    38 public:
       
    39 	static CApsNonNativeApplicationsManager* NewL(CApaAppArcServer& aServ, RFs& aFs);
       
    40 	~CApsNonNativeApplicationsManager();
       
    41 
       
    42 private:
       
    43 	CApsNonNativeApplicationsManager(CApaAppArcServer& aServ, RFs& aFs);
       
    44 
       
    45 public:
       
    46 	void NotifyScanComplete();
       
    47 	void PrepareNonNativeApplicationsUpdatesL();
       
    48 	void RegisterNonNativeApplicationL(const RMessage2& aMessage);
       
    49 	void DeregisterNonNativeApplicationL(const RMessage2& aMessage);
       
    50 #ifdef _DEBUG
       
    51 	void ForceFailInNonNativeApplicationsUpdatesL();
       
    52 	void ForcePanicInNonNativeApplicationsUpdatesL();
       
    53 	void ForcePanicInNonNativeApplicationsRollbackL();
       
    54 #endif
       
    55 	void CommitNonNativeApplicationsUpdatesL(const RMessage2& aMessage);
       
    56 	void RollbackNonNativeApplicationsUpdates();
       
    57 	static void RecoverFromUpdateLogL(RFs& aFs);
       
    58 
       
    59 private:
       
    60 	void DoRegisterNonNativeApplicationL(const RMessage2& aMessage);
       
    61 	void AbortNonNativeApplicationsUpdates();
       
    62 	static void StaticAbortNonNativeApplicationsUpdates(TAny* aSelf);
       
    63 	void CheckForUpdateAppsLockL();
       
    64 
       
    65 private:
       
    66 	CApaAppArcServer& iServ;
       
    67 	RFs& iFs;
       
    68 	RMessage2 iNotifyOnScanCompleteMsg;
       
    69 	TBool iNonNativeApplicationsUpdateAppsLock;
       
    70 	CApsNonNativeApplicationsUpdateList* iUpdateList;
       
    71 	};
       
    72 
       
    73 class RApsUpdateLog;
       
    74 
       
    75 /**
       
    76 This class holds a list of updates to the non-native apps registry that should
       
    77 be performed as one transaction, along with code to execute / rollback the updates.
       
    78 
       
    79 
       
    80 
       
    81 Update list structure:
       
    82 
       
    83 These are the possible valid types of list:
       
    84 (* means "can occur 0 or more times", ? means "can occur 0 or 1 times")
       
    85 
       
    86 EPerformed*, EPerforming?, ENew*
       
    87 EPerformed*, ERollingBack?, ERolledBack*, ENew*
       
    88 
       
    89 The list can be destructed in any of these states:
       
    90 
       
    91 EPerformed*, ERolledBack*, ENew*
       
    92 
       
    93 @internalComponent
       
    94 */
       
    95 NONSHARABLE_CLASS(CApsNonNativeApplicationsUpdateList) : public CBase
       
    96 	{
       
    97 public:
       
    98 	static CApsNonNativeApplicationsUpdateList* NewL(RFs& aFs);
       
    99 	static void RecoverFromUpdateLogL(RFs& aFs, RFile& aFile);
       
   100 	~CApsNonNativeApplicationsUpdateList();
       
   101 
       
   102 private:
       
   103 	CApsNonNativeApplicationsUpdateList(RFs& aFs);
       
   104 	void RecoverFromUpdateLogL(RFile& aFile);
       
   105 
       
   106 public:
       
   107 	void Append(CApsNonNativeApplicationsUpdate* aUpdate);
       
   108 	void ExecuteL();
       
   109 
       
   110 private:
       
   111 	void Rollback(CApsNonNativeApplicationsUpdate* aStartPoint, RApsUpdateLog& aUpdateLog);
       
   112 	void SetLogWriteStream(RWriteStream* aStream);
       
   113 	void InternalizeL(RReadStream& aStream, TInt& aPosition);
       
   114 	void InternalizeActionL(RReadStream& aStream, int& aPosition);
       
   115 	void InternalizeNewUpdateL(RReadStream& aStream, TInt& aPosition, CApsNonNativeApplicationsUpdate::TLogUpdateType aType, TUid aUid);
       
   116 	void InternalizePerformUpdateL(RReadStream& aStream, TInt& aPosition, CApsNonNativeApplicationsUpdate::TLogUpdateType aType, TUid aUid);
       
   117 	void InternalizeRollbackUpdateL(RReadStream& aStream, TInt& aPosition, CApsNonNativeApplicationsUpdate::TLogUpdateType aType, TUid aUid);
       
   118 
       
   119 private:
       
   120 	RFs& iFs;
       
   121 	CApsNonNativeApplicationsUpdate* iUpdateListHead;
       
   122 	CApsNonNativeApplicationsUpdate* iLogReplayCurrentUpdate;
       
   123 	TBool iEEndOfUpdateRequiredToFixLog; // for recovering from the log. This is ETrue if we've reached a beta stopping point.
       
   124 	};
       
   125 
       
   126 
       
   127 /*
       
   128 This class opens & owns the recovery log file
       
   129 
       
   130 Recovery log structure:
       
   131 
       
   132 As updates are performed, they are written to a log. The log's format on disk is documented here.
       
   133 
       
   134 When we read the log in, there are certain points that are considered to be "valid stopping points"
       
   135 These points are at the end of every useful section of data. When we keep track of the stream-position
       
   136 during internalization, we make sure that the position we record is always at one of these points, never
       
   137 between them.
       
   138 This means that we can then truncate the log to the last of these points and then append new operations to the
       
   139 log.
       
   140 There are two types of stopping points, i've called them alpha and beta. At an alpha stopping point we
       
   141 can start appending new operations to the log immediately. At a beta stopping point, we must append a
       
   142 EEndOfUpdate marker first.
       
   143 
       
   144 
       
   145 These points are denoted in the structure below with "--- stopping point ---"
       
   146 
       
   147 LogStructure =
       
   148 {
       
   149 	(NewUpdateSection,
       
   150 	PerformUpdateSection)*
       
   151 	RollbackUpdateSection*
       
   152 }
       
   153 
       
   154 NewUpdateSection = 
       
   155 {
       
   156 	Int8  ENewUpdate
       
   157 	Int8  TLogUpdateType
       
   158 	Int32 TUid
       
   159 	... dependent on update type ...
       
   160 	--- alpha stopping point ---
       
   161 }
       
   162 
       
   163 PerformUpdateSection =
       
   164 {
       
   165 	Int8  EPerformUpdate
       
   166 	Int8  TLogUpdateType
       
   167 	Int32 TUid
       
   168 	--- beta stopping point ---
       
   169 	(UpdateContinuationSection | UpdateStateChangeSection)*
       
   170 	Int8  EEndOfUpdate
       
   171 	--- alpha stopping point ---
       
   172 }
       
   173 
       
   174 RollbackUpdateSection =
       
   175 {
       
   176 	Int8  ERollbackUpdate
       
   177 	Int8  TLogUpdateType
       
   178 	Int32 TUid
       
   179 	--- beta stopping point ---
       
   180 	(UpdateContinuationSection | UpdateStateChangeSection)*
       
   181 	Int8  EEndOfUpdate
       
   182 	--- alpha stopping point ---
       
   183 }
       
   184 
       
   185 UpdateContinuationSection =
       
   186 {
       
   187 	Int8 EUpdateContinuation
       
   188 	... dependent on update type ...
       
   189 	--- beta stopping point ---
       
   190 }
       
   191 
       
   192 UpdateStateChangeSection =
       
   193 {
       
   194 	Int8 EChangeOfUpdateState
       
   195 	Int8 TState
       
   196 	--- beta stopping point ---
       
   197 }
       
   198 
       
   199 @internalComponent
       
   200 */
       
   201 NONSHARABLE_CLASS(RApsUpdateLog) 
       
   202 	{
       
   203 public:
       
   204 	RApsUpdateLog(RFs& aFs);
       
   205 	void OpenL();
       
   206 	void Open(RFile& aFile, TUint aSeekPos);
       
   207 	void Close();
       
   208 	CDesCArray& NewRegistrationFiles();
       
   209 	CDesCArray& DrivesAffected();
       
   210 	RWriteStream& LogWriteStream();
       
   211 private:
       
   212 	RFs& iFs;
       
   213 	CDesCArray* iFilesRegistered;
       
   214 	CDesCArray* iDrivesAffected;
       
   215 	RFileWriteStream iLogWriteStream;
       
   216 	TFileName iLogFileName;
       
   217 	};
       
   218 
       
   219 #endif // APSNNAPPS_H