epoc32/include/mw/apaproc.h
branchSymbian3
changeset 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/mw/apaproc.h	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -0,0 +1,127 @@
     1.4 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// The main startup of the AppArc server
    1.18 +// 
    1.19 +// apaproc.h
    1.20 +//
    1.21 +
    1.22 +#ifndef __APAPROC_H__
    1.23 +#define __APAPROC_H__
    1.24 +
    1.25 +#include <e32std.h>
    1.26 +#include <e32base.h>
    1.27 +#include <f32file.h>	// class RFs
    1.28 +#include <apadef.h>
    1.29 +#include <apaid.h>
    1.30 +
    1.31 +class CApaApplication;
    1.32 +class CApaDocument;
    1.33 +class RApaApplication;
    1.34 +class RFile;
    1.35 +class CFileStore;
    1.36 +class CPersistentStore;
    1.37 +class CStreamDictionary;
    1.38 +class TApaApplicationFactory;
    1.39 +class CStreamStore;
    1.40 +
    1.41 +class CApaParentProcessMonitor;
    1.42 +
    1.43 +/** Maintains a list of documents and all of the potentially shared resources used 
    1.44 +by documents.
    1.45 +
    1.46 +This includes the application DLLs. The class also supplies utility functions 
    1.47 +that provide the basic structure for persisted document files.
    1.48 +
    1.49 +The class deals with the loading of application DLLs and manages the creation 
    1.50 +and destruction of application (CApaApplication) objects and document (CApaDocument) 
    1.51 +objects.
    1.52 +
    1.53 +The class is derived from by the UI framework and further derivation by the 
    1.54 +UI application is not necessary unless it needs to add extra utility functions 
    1.55 +for the use of applications.
    1.56 +
    1.57 +@publishedAll
    1.58 +@released
    1.59 +@see CApaApplication
    1.60 +@see CApaDocument */
    1.61 +class CApaProcess : public CBase
    1.62 +	{
    1.63 +public:
    1.64 +	IMPORT_C static CApaProcess* NewL(const RFs& aFs);
    1.65 +	IMPORT_C void ResetL();
    1.66 +	// static utility functions
    1.67 +	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
    1.68 +	IMPORT_C static CStreamDictionary* ReadRootStreamLC(CFileStore*& aStore, const RFile& aFile);
    1.69 +	IMPORT_C static void WriteRootStreamL(CPersistentStore& aStore, CStreamDictionary& aStreamDic, const CApaApplication& aApp);
    1.70 +	IMPORT_C static void WriteRootStreamL(CPersistentStore& aStore, CStreamDictionary& aStreamDic, const TApaAppIdentifier& aAppId);
    1.71 +	IMPORT_C static TApaAppIdentifier ReadAppIdentifierL(const CStreamStore& aStore, const CStreamDictionary& aStreamDic);
    1.72 +	IMPORT_C static void WriteAppIdentifierL(CStreamStore& aStore, CStreamDictionary& aStreamDic, const TApaAppIdentifier& aAppId);
    1.73 +	// document management
    1.74 +	IMPORT_C CApaDocument* AddNewDocumentL(TApaApplicationFactory aApplicationFactory);
    1.75 +	IMPORT_C CApaDocument* OpenNewDocumentL(CFileStore*& aStore, CStreamDictionary*& aStreamDic, const TDesC& aDocFullFileName, TUint aFileMode); // Open a file and restore the contained document
    1.76 +	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.
    1.77 +	// setter functions
    1.78 +	IMPORT_C void SetMainDocument(CApaDocument* aDocument);
    1.79 +	IMPORT_C void SetMainDocFileName(const TDesC& aMainDocFileName); // panics if the descriptor is too long
    1.80 +	IMPORT_C void SetMainDocFileNameL(const TDesC& aMainDocFileName);
    1.81 +	// accessor functions
    1.82 +	IMPORT_C TPtrC MainDocFileName() const;
    1.83 +	inline RFs& FsSession() const;
    1.84 +	inline CApaDocument* MainDocument() const;
    1.85 +
    1.86 +	IMPORT_C ~CApaProcess();
    1.87 +protected:
    1.88 +	IMPORT_C CApaProcess();
    1.89 +	IMPORT_C CApaProcess(const RFs& aFs);
    1.90 +	IMPORT_C void ConstructL();
    1.91 +	IMPORT_C void ConstructL(TProcessId aParentProcessId);
    1.92 +
    1.93 +	IMPORT_C virtual void CApaProcess_Reserved1();
    1.94 +	IMPORT_C virtual void CApaProcess_Reserved2();
    1.95 +private:
    1.96 +	RApaApplication* AddAppL(TApaApplicationFactory aApplicationFactory);
    1.97 +	void RemoveApp(RApaApplication* aApp);
    1.98 +	CApaDocument* CreateDocL(CApaApplication* aApp);
    1.99 +	RApaApplication* FindAppInListL(const TDesC& aAppFileName,TUid aUid) const; // returns NULL if not in list
   1.100 +	static void DoReadRootStreamL(CStreamDictionary& aStreamDictionary, const CFileStore& aStore);
   1.101 +	void DeleteAllDocs();
   1.102 +	void MarkApplicationForAsyncRemoval(const CApaApplication* aApp);
   1.103 +	static TInt IdleRemoveApplications(TAny* aApaProcess);
   1.104 +	void RemoveMarkedApplications();
   1.105 +private:
   1.106 +	CArrayPtrFlat<RApaApplication>* iAppList; // array of apps in use
   1.107 +	CArrayPtrFlat<CApaDocument>* iDocList; // array of documents (1 main + n embedded)
   1.108 +	CApaDocument* iMainDoc;
   1.109 +	HBufC* iMainDocFileName;
   1.110 +	RFs iFsSession; // file server session for doc store
   1.111 +	CIdle* iAsyncAppRemover;
   1.112 +	CApaParentProcessMonitor* iMonitor;
   1.113 +	TInt iCApaProcess_Reserved1;
   1.114 +	};
   1.115 +
   1.116 +
   1.117 +
   1.118 +// inlines //
   1.119 +
   1.120 +/** Returns a handle to the file server session used by this application process.
   1.121 +@return The file server session. */
   1.122 +inline RFs& CApaProcess::FsSession()const
   1.123 +	{ return (RFs&)iFsSession; } //lint !e1536 Exposing low access member - Kept for backward BC
   1.124 +
   1.125 +/** Returns a pointer to the main document.
   1.126 +@return A pointer to the main document. */
   1.127 +inline CApaDocument* CApaProcess::MainDocument()const
   1.128 +	{ return iMainDoc; }
   1.129 +	
   1.130 +#endif	// __APAPROC_H__