localisation/apparchitecture/inc/apaapp.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 // apaapp.h
       
    17 //
       
    18 
       
    19 #ifndef __APAAPP_H__
       
    20 #define __APAAPP_H__
       
    21 
       
    22 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    23 #if !defined(__APAID_PARTNER_H__)
       
    24 #include "apaidpartner.h"
       
    25 #endif
       
    26 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
       
    27 #include <e32std.h>
       
    28 #include <e32base.h>
       
    29 #include <apadef.h>
       
    30 #include <apaid.h>
       
    31 
       
    32 class CApaApplication;
       
    33 class CApaDocument;
       
    34 class CApaProcess;
       
    35 class CDictionaryStore;
       
    36 class CImplementationInformation;
       
    37 class CApaAppServer;
       
    38 
       
    39 
       
    40 /** Defines the basic behaviour for applications.
       
    41 
       
    42 The class defines the basic twin roles of an application class as a factory 
       
    43 that creates concrete document objects, and as a supplier of utility functions 
       
    44 not specific to any particular instance of a document. For example, returning 
       
    45 an application's caption, or accessing its .ini file.
       
    46 
       
    47 The class is derived from by the UI framework and is further derived from 
       
    48 by the UI application.
       
    49 
       
    50 @publishedAll 
       
    51 @released 
       
    52 @see CEikApplication */
       
    53 class CApaApplication : public CBase
       
    54 // base class for applications; allows creation of documents & file stores + display of app icon and name.
       
    55 	{
       
    56 public:
       
    57 	/** Completes construction of this application object.
       
    58 	
       
    59 	The function is called after an instance of a derived class has been successfully 
       
    60 	created using the ordinal 1 function of the application DLL.
       
    61 	
       
    62 	After calling this function, an application can create document objects.
       
    63 	
       
    64 	An implementation of this function is supplied by the UI framework.
       
    65 	
       
    66 	@see CEikApplication */
       
    67 	virtual void PreDocConstructL() = 0; // call once before creating document
       
    68 	
       
    69 	/** Creates a document object.
       
    70 	
       
    71 	The function is called by the application process when a new document is required. 
       
    72 	The application process adds the new document to its list of documents.
       
    73 	
       
    74 	An implementation of this function is supplied by the UI framework.
       
    75 	
       
    76 	@param aProcess A pointer to the process associated with the application.
       
    77 	@return A pointer to the newly created document.
       
    78 	@see CApaProcess::AddNewDocumentL() */
       
    79 	virtual CApaDocument* CreateDocumentL(CApaProcess* aProcess) = 0;
       
    80 	
       
    81 	/** Gets the application specific UID.
       
    82 	
       
    83 	The UID is used to differentiate between UI applications.
       
    84 	
       
    85 	An implementation of this function must be supplied by the UI application.
       
    86 	
       
    87 	@return The application specific UID. */
       
    88 	virtual TUid AppDllUid() const = 0;
       
    89 public: // utility functions
       
    90 	IMPORT_C static TInt GenerateFileName(RFs& aFs, TFileName& aRootName);
       
    91 	IMPORT_C CDictionaryStore* OpenIniFileL(RFs& aFs) const;
       
    92 	
       
    93 	/** Opens the .ini file associated with the application, constructs the dictionary 
       
    94 	store object, returns a pointer to it and puts the pointer onto the cleanupstack.
       
    95 	
       
    96 	The .ini file must be created, if it does not already exist.
       
    97 	
       
    98 	An implementation of this function is supplied by the UI framework.
       
    99 	
       
   100 	@param aFs Handle to a file server session 
       
   101 	@return A pointer to the dictionary store object that represents the application's .ini file. 
       
   102 	@see CEikApplication */
       
   103 	virtual CDictionaryStore* OpenIniFileLC(RFs& aFs) const = 0;
       
   104 public: // enquiry functions
       
   105 	IMPORT_C virtual TFileName AppFullName() const; // returns the full path and name of the app
       
   106 	/** Returns the capabilities of the application.
       
   107 	
       
   108 	Application capability information is represented by an instance of a TApaAppCapability 
       
   109 	object wrapped in a packaged modifiable buffer descriptor.
       
   110 	
       
   111 	The function is called from a number of places within the application framework.
       
   112 	
       
   113 	An implementation of this function is supplied by the UI framework.
       
   114 	
       
   115 	@param aInfo A packaged modifiable buffer descriptor (a TPckgBuf), encapsulating 
       
   116 	a TApaAppCapability object. 
       
   117 	@see CEikApplication
       
   118 	@see TApaAppCapability
       
   119 	@see TPckgBuf */
       
   120 	virtual void Capability(TDes8& aInfo) const = 0;
       
   121 public:	// accessor function
       
   122 	IMPORT_C TFileName DllName() const;
       
   123 	IMPORT_C ~CApaApplication();
       
   124 	IMPORT_C virtual void NewAppServerL(CApaAppServer*& aAppServer);
       
   125 protected:
       
   126 	IMPORT_C CApaApplication();
       
   127 public: // internal use only
       
   128 	void SetAppFileNameRef(const RBuf& aFileName);
       
   129 private:
       
   130 	IMPORT_C virtual void CApaApplication_Reserved1();
       
   131 	IMPORT_C virtual void CApaApplication_Reserved2();
       
   132 private:
       
   133 	const RBuf* iAppFileNameRef;  // not owned
       
   134 	TUid iEComDtorKey;
       
   135 //	friend class CApaProcess;
       
   136 	friend class TApaApplicationFactory; // so that it can access iDtorKey
       
   137 private:
       
   138 	TInt iCApaApplication_Reserved1;
       
   139 	};
       
   140 
       
   141 
       
   142 /** Encapsulates the functionality of creating an application, whether it be via a factory function
       
   143 or an ECOM plugin. Instances of this class can usually be created implicitly when required as
       
   144 function parameters - just specify the function pointer, ECOM plugin UID or CImplementationInformation
       
   145 reference.
       
   146 
       
   147 @publishedAll
       
   148 @released
       
   149 @see CApaProcess
       
   150 @see EikStart */
       
   151 class TApaApplicationFactory
       
   152 	{
       
   153 public:
       
   154 	typedef CApaApplication* (*TFunction)();
       
   155 public:
       
   156 	IMPORT_C TApaApplicationFactory();
       
   157 	IMPORT_C TApaApplicationFactory(TFunction aFunction);
       
   158 	IMPORT_C TApaApplicationFactory(const CImplementationInformation& aEmbeddedApplicationInformation);
       
   159 	IMPORT_C TApaApplicationFactory(TUid aEmbeddedApplicationUid);
       
   160 	CApaApplication* CreateApplicationL() const;
       
   161 	HBufC* AppFileNameL() const;
       
   162 	TUid AppFileUid() const;
       
   163 private:
       
   164 	enum TType
       
   165 		{
       
   166 		ETypeFunction,							// if iType is this, iData is a TFunction
       
   167 		ETypeEmbeddedApplicationInformation,	// if iType is this, iData is an ECOM CImplementationInformation
       
   168 		ETypeEmbeddedApplicationUid				// if iType is this, iData is an ECOM implementation TUid
       
   169 		};
       
   170 private:
       
   171 	static CApaApplication* CreateEmbeddedApplicationL(TUid aUid);
       
   172 	static HBufC* EmbeddedApplicationDisplayNameLC(TUid aUid);
       
   173 	static HBufC* FullAppFileNameL(const TDesC& aAppName);
       
   174 	static void CleanupImplementationArray(TAny* aImplementationArray);
       
   175 private:
       
   176 	TType iType;
       
   177 	TUint iData;
       
   178 	mutable CApaApplication* iApplication; // used to be iSpare1
       
   179 	TInt iSpare2;
       
   180 	};
       
   181 
       
   182 	
       
   183 #endif	// __APAAPP_H__