|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 #ifndef CDLLIBRARY_H |
|
18 #define CDLLIBRARY_H |
|
19 |
|
20 #include <e32base.h> |
|
21 #include <CdlEngDef.h> |
|
22 #include <CdlEngine.h> |
|
23 #include <babitflags.h> |
|
24 |
|
25 class CCdlLibManager; |
|
26 class REComSession; |
|
27 |
|
28 |
|
29 GLREF_D const TUid KCdlLibraryUid; |
|
30 |
|
31 _LIT(KCdlLibsPath,"\\sys\\bin\\"); |
|
32 _LIT(KCdlLibsLoaderPath,"z:\\sys\\bin\\;\\sys\\bin\\"); |
|
33 |
|
34 /** |
|
35 * CDL's version of RLibrary. |
|
36 * This suppresses calling of entry points on DLL load and close. |
|
37 */ |
|
38 class RCdlLibrary |
|
39 { |
|
40 public: |
|
41 RCdlLibrary(); |
|
42 |
|
43 void Close(); |
|
44 TInt CdlLoad(const TDesC& aLibName, TBool aRomOnly); |
|
45 |
|
46 const TCdlArray<SCdlCustomisation>& ContentsL() const; |
|
47 const SCdlCustomisation* CustomisationL(TUid aUid, TInt aImplId) const; |
|
48 TPtrC Name() const; |
|
49 const TDesC* FullName() const; |
|
50 TBool SameShortName(const TDesC& aShortLibName); |
|
51 |
|
52 TInt& RefCount() { return iRefCount; } |
|
53 |
|
54 TBool IsLibLoadedAsRomOnly() const; |
|
55 void SetLibLoadedAsRomOnly(); |
|
56 |
|
57 public: |
|
58 static TPtrC ExtractName(const TDesC& aLibName); |
|
59 static TBool CheckIfNotRomOnly(TBool aRomOnly, const TDesC& aName); |
|
60 |
|
61 private: |
|
62 HBufC* iName; // owned, the full path name of the library |
|
63 TPtrC iShortName; // file name without extension or path, points to content of iName |
|
64 TInt iRefCount; |
|
65 TBitFlags iFlags; |
|
66 TUid iEcomDtorUid; |
|
67 TAny* iEcomImpl; |
|
68 }; |
|
69 |
|
70 |
|
71 /** |
|
72 * A reference to a CDL library. This allows the CDL library manager to reference count |
|
73 * RCdlLibrary objects, thereby preventing many instances of the same library existing. |
|
74 */ |
|
75 class RCdlLibRef |
|
76 { |
|
77 public: |
|
78 RCdlLibRef(); |
|
79 void Close(); |
|
80 RCdlLibrary* Lib() const; |
|
81 TPtrC Name() const; |
|
82 |
|
83 private: |
|
84 friend class CCdlLibManager; // only CCdlLibManager can set a reference |
|
85 void SetRef(CCdlLibManager* aLibMan, RCdlLibrary* aLib); |
|
86 |
|
87 private: |
|
88 CCdlLibManager* iLibMan; // not owned |
|
89 RCdlLibrary* iLib; // shared ownership with CCdlManager and all other references to this library |
|
90 }; |
|
91 |
|
92 |
|
93 /** |
|
94 * The CDL library manager. Maintains one RCdlLibrary for each CDL DLL that is required |
|
95 * by the engine and its clients. |
|
96 */ |
|
97 NONSHARABLE_CLASS(CCdlLibManager) : public CBase |
|
98 { |
|
99 public: |
|
100 CCdlLibManager(); |
|
101 ~CCdlLibManager(); |
|
102 void ConstructL(); |
|
103 |
|
104 TBool IsLibLoadedAsRomOnly(const TDesC& aLibName) const; |
|
105 RCdlLibRef LoadL(const TDesC& aLibName, RCdlLibrary* aLib, TBool aRomOnly); |
|
106 void Close(RCdlLibrary* aLib); |
|
107 RCdlLibrary* FindLib(const TDesC& aLibName) const; |
|
108 |
|
109 private: |
|
110 |
|
111 static TInt LazyUnload(TAny* aThis); |
|
112 void DoLazyUnload(); |
|
113 |
|
114 private: |
|
115 CArrayPtrFlat<RCdlLibrary> iLibs; // shared ownership of contained libraries with RCdlLibRef objects |
|
116 REComSession* iEcom; |
|
117 CAsyncCallBack* iLazyUnloader; |
|
118 }; |
|
119 |
|
120 |
|
121 #endif |