localisation/apparchitecture/inc/apaproc.h
branchSymbian3
changeset 57 b8d18c84f71c
equal deleted inserted replaced
56:aa99f2208aad 57:b8d18c84f71c
       
     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 // The main startup of the AppArc server
       
    15 // 
       
    16 // apaproc.h
       
    17 //
       
    18 
       
    19 #ifndef __APAPROC_H__
       
    20 #define __APAPROC_H__
       
    21 
       
    22 #include <e32std.h>
       
    23 #include <e32base.h>
       
    24 #include <f32file.h>	// class RFs
       
    25 #include <apadef.h>
       
    26 #include <apaid.h>
       
    27 
       
    28 class CApaApplication;
       
    29 class CApaDocument;
       
    30 class RApaApplication;
       
    31 class RFile;
       
    32 class CFileStore;
       
    33 class CPersistentStore;
       
    34 class CStreamDictionary;
       
    35 class TApaApplicationFactory;
       
    36 class CStreamStore;
       
    37 
       
    38 class CApaParentProcessMonitor;
       
    39 
       
    40 /** Maintains a list of documents and all of the potentially shared resources used 
       
    41 by documents.
       
    42 
       
    43 This includes the application DLLs. The class also supplies utility functions 
       
    44 that provide the basic structure for persisted document files.
       
    45 
       
    46 The class deals with the loading of application DLLs and manages the creation 
       
    47 and destruction of application (CApaApplication) objects and document (CApaDocument) 
       
    48 objects.
       
    49 
       
    50 The class is derived from by the UI framework and further derivation by the 
       
    51 UI application is not necessary unless it needs to add extra utility functions 
       
    52 for the use of applications.
       
    53 
       
    54 @publishedAll
       
    55 @released
       
    56 @see CApaApplication
       
    57 @see CApaDocument */
       
    58 class CApaProcess : public CBase
       
    59 	{
       
    60 public:
       
    61 	IMPORT_C static CApaProcess* NewL(const RFs& aFs);
       
    62 	IMPORT_C void ResetL();
       
    63 	// static utility functions
       
    64 	IMPORT_C static CStreamDictionary* ReadRootStreamLC(RFs& aFs,CFileStore*& aStore, const TDesC& aDocFullFileName, TUint aFileMode); // opens aDocFileName as aStore and returns the stream dictionary contained in its root stream on the cleanup stack
       
    65 	IMPORT_C static CStreamDictionary* ReadRootStreamLC(CFileStore*& aStore, const RFile& aFile);
       
    66 	IMPORT_C static void WriteRootStreamL(CPersistentStore& aStore, CStreamDictionary& aStreamDic, const CApaApplication& aApp);
       
    67 	IMPORT_C static void WriteRootStreamL(CPersistentStore& aStore, CStreamDictionary& aStreamDic, const TApaAppIdentifier& aAppId);
       
    68 	IMPORT_C static TApaAppIdentifier ReadAppIdentifierL(const CStreamStore& aStore, const CStreamDictionary& aStreamDic);
       
    69 	IMPORT_C static void WriteAppIdentifierL(CStreamStore& aStore, CStreamDictionary& aStreamDic, const TApaAppIdentifier& aAppId);
       
    70 	// document management
       
    71 	IMPORT_C CApaDocument* AddNewDocumentL(TApaApplicationFactory aApplicationFactory);
       
    72 	IMPORT_C CApaDocument* OpenNewDocumentL(CFileStore*& aStore, CStreamDictionary*& aStreamDic, const TDesC& aDocFullFileName, TUint aFileMode); // Open a file and restore the contained document
       
    73 	IMPORT_C void DestroyDocument(CApaDocument* aDoc); // Removes a doc (identified by the object) from the list and destroys it. Also removes the app and closes the AppDll if appropriate.
       
    74 	// setter functions
       
    75 	IMPORT_C void SetMainDocument(CApaDocument* aDocument);
       
    76 	IMPORT_C void SetMainDocFileName(const TDesC& aMainDocFileName); // panics if the descriptor is too long
       
    77 	IMPORT_C void SetMainDocFileNameL(const TDesC& aMainDocFileName);
       
    78 	// accessor functions
       
    79 	IMPORT_C TPtrC MainDocFileName() const;
       
    80 	inline RFs& FsSession() const;
       
    81 	inline CApaDocument* MainDocument() const;
       
    82 
       
    83 	IMPORT_C ~CApaProcess();
       
    84 protected:
       
    85 	IMPORT_C CApaProcess();
       
    86 	IMPORT_C CApaProcess(const RFs& aFs);
       
    87 	IMPORT_C void ConstructL();
       
    88 	IMPORT_C void ConstructL(TProcessId aParentProcessId);
       
    89 
       
    90 	IMPORT_C virtual void CApaProcess_Reserved1();
       
    91 	IMPORT_C virtual void CApaProcess_Reserved2();
       
    92 private:
       
    93 	RApaApplication* AddAppL(TApaApplicationFactory aApplicationFactory);
       
    94 	void RemoveApp(RApaApplication* aApp);
       
    95 	CApaDocument* CreateDocL(CApaApplication* aApp);
       
    96 	RApaApplication* FindAppInListL(const TDesC& aAppFileName,TUid aUid) const; // returns NULL if not in list
       
    97 	static void DoReadRootStreamL(CStreamDictionary& aStreamDictionary, const CFileStore& aStore);
       
    98 	void DeleteAllDocs();
       
    99 	void MarkApplicationForAsyncRemoval(const CApaApplication* aApp);
       
   100 	static TInt IdleRemoveApplications(TAny* aApaProcess);
       
   101 	void RemoveMarkedApplications();
       
   102 private:
       
   103 	CArrayPtrFlat<RApaApplication>* iAppList; // array of apps in use
       
   104 	CArrayPtrFlat<CApaDocument>* iDocList; // array of documents (1 main + n embedded)
       
   105 	CApaDocument* iMainDoc;
       
   106 	HBufC* iMainDocFileName;
       
   107 	RFs iFsSession; // file server session for doc store
       
   108 	CIdle* iAsyncAppRemover;
       
   109 	CApaParentProcessMonitor* iMonitor;
       
   110 	TInt iCApaProcess_Reserved1;
       
   111 	};
       
   112 
       
   113 
       
   114 
       
   115 // inlines //
       
   116 
       
   117 /** Returns a handle to the file server session used by this application process.
       
   118 @return The file server session. */
       
   119 inline RFs& CApaProcess::FsSession()const
       
   120 	{ return (RFs&)iFsSession; } //lint !e1536 Exposing low access member - Kept for backward BC
       
   121 
       
   122 /** Returns a pointer to the main document.
       
   123 @return A pointer to the main document. */
       
   124 inline CApaDocument* CApaProcess::MainDocument()const
       
   125 	{ return iMainDoc; }
       
   126 	
       
   127 #endif	// __APAPROC_H__