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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // The main startup of the AppArc server
24 #include <f32file.h> // class RFs
28 class CApaApplication;
30 class RApaApplication;
33 class CPersistentStore;
34 class CStreamDictionary;
35 class TApaApplicationFactory;
38 class CApaParentProcessMonitor;
40 /** Maintains a list of documents and all of the potentially shared resources used
43 This includes the application DLLs. The class also supplies utility functions
44 that provide the basic structure for persisted document files.
46 The class deals with the loading of application DLLs and manages the creation
47 and destruction of application (CApaApplication) objects and document (CApaDocument)
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.
58 class CApaProcess : public CBase
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.
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);
79 IMPORT_C TPtrC MainDocFileName() const;
80 inline RFs& FsSession() const;
81 inline CApaDocument* MainDocument() const;
83 IMPORT_C ~CApaProcess();
85 IMPORT_C CApaProcess();
86 IMPORT_C CApaProcess(const RFs& aFs);
87 IMPORT_C void ConstructL();
88 IMPORT_C void ConstructL(TProcessId aParentProcessId);
90 IMPORT_C virtual void CApaProcess_Reserved1();
91 IMPORT_C virtual void CApaProcess_Reserved2();
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);
99 void MarkApplicationForAsyncRemoval(const CApaApplication* aApp);
100 static TInt IdleRemoveApplications(TAny* aApaProcess);
101 void RemoveMarkedApplications();
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;
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
122 /** Returns a pointer to the main document.
123 @return A pointer to the main document. */
124 inline CApaDocument* CApaProcess::MainDocument()const
127 #endif // __APAPROC_H__