CApaProcess Class Reference

class CApaProcess : public CBase

Maintains a list of documents and all of the potentially shared resources used by documents.

This includes the application DLLs. The class also supplies utility functions that provide the basic structure for persisted document files.

The class deals with the loading of application DLLs and manages the creation and destruction of application (CApaApplication) objects and document (CApaDocument) objects.

The class is derived from by the UI framework and further derivation by the UI application is not necessary unless it needs to add extra utility functions for the use of applications.

CApaApplication CApaDocument

Inherits from

Public Member Functions
~CApaProcess()
IMPORT_C CApaDocument *AddNewDocumentL(TApaApplicationFactory)
IMPORT_C voidDestroyDocument(CApaDocument *)
RFs &FsSession()
IMPORT_C TPtrCMainDocFileName()
CApaDocument *MainDocument()
IMPORT_C CApaProcess *NewL(const RFs &)
IMPORT_C CApaDocument *OpenNewDocumentL(CFileStore *&, CStreamDictionary *&, const TDesC &, TUint)
IMPORT_C TApaAppIdentifierReadAppIdentifierL(const CStreamStore &, const CStreamDictionary &)
IMPORT_C CStreamDictionary *ReadRootStreamLC(RFs &, CFileStore *&, const TDesC &, TUint)
IMPORT_C CStreamDictionary *ReadRootStreamLC(CFileStore *&, const RFile &)
IMPORT_C voidResetL()
IMPORT_C voidSetMainDocFileName(const TDesC &)
IMPORT_C voidSetMainDocFileNameL(const TDesC &)
IMPORT_C voidSetMainDocument(CApaDocument *)
IMPORT_C voidWriteAppIdentifierL(CStreamStore &, CStreamDictionary &, const TApaAppIdentifier &)
IMPORT_C voidWriteRootStreamL(CPersistentStore &, CStreamDictionary &, const CApaApplication &)
IMPORT_C voidWriteRootStreamL(CPersistentStore &, CStreamDictionary &, const TApaAppIdentifier &)
Protected Member Functions
CApaProcess()
CApaProcess(const RFs &)
IMPORT_C voidCApaProcess_Reserved1()
IMPORT_C voidCApaProcess_Reserved2()
IMPORT_C voidConstructL()
IMPORT_C voidConstructL(TProcessId)
Private Member Functions
RApaApplication *AddAppL(TApaApplicationFactory)
CApaDocument *CreateDocL(CApaApplication *)
voidDeleteAllDocs()
voidDoReadRootStreamL(CStreamDictionary &, const CFileStore &)
RApaApplication *FindAppInListL(const TDesC &, TUid)
TInt IdleRemoveApplications(TAny *)
voidMarkApplicationForAsyncRemoval(const CApaApplication *)
voidRemoveApp(RApaApplication *)
voidRemoveMarkedApplications()
Inherited Functions
CBase::CBase()
CBase::Delete(CBase *)
CBase::Extension_(TUint,TAny *&,TAny *)
CBase::operator new(TUint)
CBase::operator new(TUint,TAny *)
CBase::operator new(TUint,TLeave)
CBase::operator new(TUint,TLeave,TUint)
CBase::operator new(TUint,TUint)
CBase::~CBase()
Private Attributes
CArrayPtrFlat< RApaApplication > *iAppList
CIdle *iAsyncAppRemover
TInt iCApaProcess_Reserved1
CArrayPtrFlat< CApaDocument > *iDocList
RFs iFsSession
CApaDocument *iMainDoc
HBufC *iMainDocFileName
CApaParentProcessMonitor *iMonitor

Constructor & Destructor Documentation

CApaProcess()

IMPORT_CCApaProcess()[protected]

Constructor for CApaProcess

CApaProcess(const RFs &)

IMPORT_CCApaProcess(const RFs &aFs)[protected]

Constructs the application process object with the specified file session handle.

Derived classes must define and implement a constructor through which the file session handle can be specified. A typical implementation calls this constructor through a constructor initialization list.

This constructor is used by the UI framework.

Parameters

const RFs & aFsHandle to a file server session

~CApaProcess()

IMPORT_C~CApaProcess()

Frees resources prior to destruction.

Documents must be saved before the application process is deleted, otherwise data may be lost.

In debug mode, the destructor raises an APPARC 6 panic if documents still exist, and an APPARC 5 panic if applications still exist.

Member Functions Documentation

AddAppL(TApaApplicationFactory)

RApaApplication *AddAppL(TApaApplicationFactoryaApplicationFactory)[private]

Parameters

TApaApplicationFactory aApplicationFactory

AddNewDocumentL(TApaApplicationFactory)

IMPORT_C CApaDocument *AddNewDocumentL(TApaApplicationFactoryaApplicationFactory)

Creates and adds a new document using the specified application factory.

The document may be a main document or an embedded document.

Any document created with this function must be destroyed using DestroyDocument().

CApaProcess::DestroyDocument() CApaApplication

Parameters

TApaApplicationFactory aApplicationFactoryShould be created implicitly by passing a pointer to a factory function, an ECOM plugin UID, or a CImplementationInformation reference.

CApaProcess_Reserved1()

IMPORT_C voidCApaProcess_Reserved1()[protected, virtual]

Reserved for future use

CApaProcess_Reserved2()

IMPORT_C voidCApaProcess_Reserved2()[protected, virtual]

Reserved for future use

ConstructL()

IMPORT_C voidConstructL()[protected]

Completes construction of the application process object.

Implementers of derived classes must call this function as part of the second stage construction of an object. Typically, derived classes implement their own NewL() function and call ConstructL() as part of that implementation.

ConstructL(TProcessId)

IMPORT_C voidConstructL(TProcessIdaParentProcessId)[protected]

Completes construction of the application process object, passing in a Parent Process Identifier.

Implementers of derived classes must call this function as part of the second stage construction of an object. Typically, derived classes implement their own NewL() function and call ConstructL() as part of that implementation.

Parameters

TProcessId aParentProcessIdId of the parent process. This process will terminate when the parent does.

CreateDocL(CApaApplication *)

CApaDocument *CreateDocL(CApaApplication *aApp)[private]

Parameters

CApaApplication * aApp

DeleteAllDocs()

voidDeleteAllDocs()[private]

DestroyDocument(CApaDocument *)

IMPORT_C voidDestroyDocument(CApaDocument *aDoc)

Destroys the specified document.

All references to the document are removed, and associated resources are freed. Specifically, the function deletes any associated application and unloads the application DLL, provided that no other documents of that application type are still open.

All document objects created through CApaProcess must be deleted using this function.

CApaApplication CApaProcess

Parameters

CApaDocument * aDocA pointer to the document to be destroyed.

DoReadRootStreamL(CStreamDictionary &, const CFileStore &)

voidDoReadRootStreamL(CStreamDictionary &aStreamDictionary,
const CFileStore &aStore
)[private, static]

Parameters

CStreamDictionary & aStreamDictionary
const CFileStore & aStore

FindAppInListL(const TDesC &, TUid)

RApaApplication *FindAppInListL(const TDesC &aAppFileName,
TUidaUid
)const [private]

Parameters

const TDesC & aAppFileName
TUid aUid

FsSession()

RFs &FsSession()const [inline]

Returns a handle to the file server session used by this application process.

IdleRemoveApplications(TAny *)

TInt IdleRemoveApplications(TAny *aApaProcess)[private, static]

Parameters

TAny * aApaProcess

MainDocFileName()

IMPORT_C TPtrCMainDocFileName()const

Returns the filename of the main document.

MainDocument()

CApaDocument *MainDocument()const [inline]

Returns a pointer to the main document.

MarkApplicationForAsyncRemoval(const CApaApplication *)

voidMarkApplicationForAsyncRemoval(const CApaApplication *aApp)[private]

Parameters

const CApaApplication * aApp

NewL(const RFs &)

IMPORT_C CApaProcess *NewL(const RFs &aFs)[static]

Creates and returns a pointer to a new application process.

This function is not used by UI applications.

Parameters

const RFs & aFsHandle to a file server session.

OpenNewDocumentL(CFileStore *&, CStreamDictionary *&, const TDesC &, TUint)

IMPORT_C CApaDocument *OpenNewDocumentL(CFileStore *&aStore,
CStreamDictionary *&aStreamDic,
const TDesC &aDocFullFileName,
TUintaFileMode
)

Opens the specified file and restores the content as a document.

The created document can be merged into or embedded in another document.

Any document created with this function must be destroyed using DestroyDocument().

TFileMode CApaProcess::DestroyDocument()

Parameters

CFileStore *& aStoreOn return, this contains a pointer to the store object created during the restore.
CStreamDictionary *& aStreamDicOn return, this contains a pointer to the stream dictionary object created during the restore.
const TDesC & aDocFullFileNameThe name of the file containing the document.
TUint aFileModeThe mode in which to open the file.

ReadAppIdentifierL(const CStreamStore &, const CStreamDictionary &)

IMPORT_C TApaAppIdentifierReadAppIdentifierL(const CStreamStore &aStore,
const CStreamDictionary &aStreamDic
)[static]

Reads the application identifier from its stream in the specified store and returns it.

The location of the stream is found in the specified stream dictionary.

Parameters

const CStreamStore & aStoreThe store from which the application identifier should be read.
const CStreamDictionary & aStreamDicThe stream dictionary containing the stream ID of the application identifier stream. The stream dictionary can be found in the root stream of the store.

ReadRootStreamLC(RFs &, CFileStore *&, const TDesC &, TUint)

IMPORT_C CStreamDictionary *ReadRootStreamLC(RFs &aFs,
CFileStore *&aStore,
const TDesC &aDocFullFileName,
TUintaFileMode
)[static]

Reads the stream dictionary contained as the root stream in the specified document file.

The function constructs, and returns a pointer to the stream dictionary object and puts the pointer to the stream dictionary object onto the cleanup stack. It also returns a pointer to the created file store object through an argument reference.

The file must be a valid document file; otherwise the function leaves with one of the system-wide error codes.

TFileMode

Parameters

RFs & aFsHandle to a file server session.
CFileStore *& aStoreOn return, a pointer to the newly created file store object.
const TDesC & aDocFullFileNameThe full path name of the document file.
TUint aFileModeThe mode in which to open the file.

ReadRootStreamLC(CFileStore *&, const RFile &)

IMPORT_C CStreamDictionary *ReadRootStreamLC(CFileStore *&aStore,
const RFile &aFile
)[static]

Parameters

CFileStore *& aStore
const RFile & aFile

RemoveApp(RApaApplication *)

voidRemoveApp(RApaApplication *aApp)[private]

Parameters

RApaApplication * aApp

RemoveMarkedApplications()

voidRemoveMarkedApplications()[private]

ResetL()

IMPORT_C voidResetL()

Resets the the application process to its initial state.

Specifically, it saves the main document, deletes the main and all embedded documents from memory, resets the main document filename and deletes all applications except the main application.

The function can leave if saving the main document fails.

SetMainDocFileName(const TDesC &)

IMPORT_C voidSetMainDocFileName(const TDesC &aMainDocFileName)

Sets the filename of the main document.

panic
APPARC 7 If the length of aMainDocFileName is greater than KMaxFileName or the length of the last filename set by SetMainDocFileNameL if greater
KMaxFileName

Parameters

const TDesC & aMainDocFileNameThe filename to be set.

SetMainDocFileNameL(const TDesC &)

IMPORT_C voidSetMainDocFileNameL(const TDesC &aMainDocFileName)

Sets the filename of the main document.

Parameters

const TDesC & aMainDocFileNameThe filename to be set. There is no restriction on the length of this descriptor.

SetMainDocument(CApaDocument *)

IMPORT_C voidSetMainDocument(CApaDocument *aDocument)

Parameters

CApaDocument * aDocumentA pointer to the document to be set as the main document of the application process. This must be a an object created by the AddNewDocumentL() or OpenNewDocumentL() functions

WriteAppIdentifierL(CStreamStore &, CStreamDictionary &, const TApaAppIdentifier &)

IMPORT_C voidWriteAppIdentifierL(CStreamStore &aStore,
CStreamDictionary &aStreamDic,
const TApaAppIdentifier &aAppId
)[static]

Writes the application identifier to a new stream in the specified store and records the location of this stream in the specified stream dictionary.

Parameters

CStreamStore & aStoreThe store to which the application identifier should be written.
CStreamDictionary & aStreamDicThe stream dictionary.
const TApaAppIdentifier & aAppIdThe application identifier to be externalised to a stream.

WriteRootStreamL(CPersistentStore &, CStreamDictionary &, const CApaApplication &)

IMPORT_C voidWriteRootStreamL(CPersistentStore &aStore,
CStreamDictionary &aStreamDic,
const CApaApplication &aApp
)[static]

Writes the application identifier (derived from the application object CApaApplication) followed by the stream dictionary to the store and makes the stream dictionary the root stream of the store.

Typically, the function is called by the application when it implements a file create or file save type operation. It is called after all model and UI data has been persisted. The IDs of the streams containing the model and UI data should have been lodged in the stream dictionary.

In effect, the function finishes off the file save or file create type operation, leaving the file containing the store in a valid state with the standard interface.

Parameters

CPersistentStore & aStoreThe store to which the root stream is to be written. Before calling this function, a reference to the store must be saved by putting a pointer onto the cleanup stack or by making it member data of a class. This ensures that it is not orphaned in the event of this function leaving.
CStreamDictionary & aStreamDicThe stream dictionary containing the locations and associated UIDs of other streams in the store.
const CApaApplication & aAppThe application used to create the main document in the file being written. The application identifier to be written is constructed from this application object.

WriteRootStreamL(CPersistentStore &, CStreamDictionary &, const TApaAppIdentifier &)

IMPORT_C voidWriteRootStreamL(CPersistentStore &aStore,
CStreamDictionary &aStreamDic,
const TApaAppIdentifier &aAppId
)[static]

Writes the application identifier followed by the stream dictionary to the store and makes the stream dictionary the root stream of the store.

Typically, the function is called by the application when it implements a file create or file save type operation. It is called after all model and UI data has been persisted. The IDs of the streams containing the model and UI data should have been lodged in the stream dictionary.

In effect, the function finishes off the file save or file create type operation, leaving the file containing the store in a valid state with the standard interface.

Parameters

CPersistentStore & aStoreThe store to which the root stream is to be written. Before calling this function, a reference to the store must be saved by putting a pointer onto the cleanup stack or by making it member data of a class. This ensures that it is not orphaned in the event of this function leaving.
CStreamDictionary & aStreamDicThe stream dictionary containing the locations and associated UIDs of other streams in the store.
const TApaAppIdentifier & aAppIdThe application identifier to be written into the application identifier stream.

Member Data Documentation

CArrayPtrFlat< RApaApplication > * iAppList

CArrayPtrFlat< RApaApplication > *iAppList[private]

CIdle * iAsyncAppRemover

CIdle *iAsyncAppRemover[private]

TInt iCApaProcess_Reserved1

TInt iCApaProcess_Reserved1[private]

CArrayPtrFlat< CApaDocument > * iDocList

CArrayPtrFlat< CApaDocument > *iDocList[private]

RFs iFsSession

RFs iFsSession[private]

CApaDocument * iMainDoc

CApaDocument *iMainDoc[private]

HBufC * iMainDocFileName

HBufC *iMainDocFileName[private]

CApaParentProcessMonitor * iMonitor

CApaParentProcessMonitor *iMonitor[private]