|
1 // Copyright (c) 1998-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 // MODULE - Message Type Module |
|
15 // User Interface registry |
|
16 // |
|
17 // |
|
18 |
|
19 // Messaging includes |
|
20 #include <msvapi.h> |
|
21 #include <msvruids.h> |
|
22 #include <mtclbase.h> |
|
23 |
|
24 // Specific includes |
|
25 #include "MTUIREG.H" |
|
26 #include "MTUIPAN.H" |
|
27 |
|
28 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
29 #include "msvconsts.h" |
|
30 #endif |
|
31 |
|
32 // |
|
33 // CMtmUiRegistry // |
|
34 // |
|
35 EXPORT_C CMtmUiRegistry* CMtmUiRegistry::NewL(CMsvSession& aMsvSession,TTimeIntervalMicroSeconds32 aTimeoutMicroSeconds32) |
|
36 /** Constructs and allocates a CMtmUiRegistry object. |
|
37 |
|
38 The client should delete this object when it is no longer required. |
|
39 |
|
40 The registry keeps a reference count of the number of instances of each MTM |
|
41 in use. When that reference count falls to zero, the DLL that provides the |
|
42 MTM is unloaded. However, this is not done immediately, but only after the |
|
43 time specified in aTimeoutMicroSeconds32. This increases efficiency in cases |
|
44 where the DLL is required again shortly. |
|
45 |
|
46 @param aMsvSession The client's Message Server session |
|
47 @param aTimeoutMicroSeconds32 Time to wait before unloading MTM DLLs |
|
48 @leave KErrNoMemory A memory allocation failed |
|
49 @return A pointer to a newly allocated and initialised object */ |
|
50 { |
|
51 CMtmUiRegistry* self = new (ELeave) CMtmUiRegistry(aMsvSession,aTimeoutMicroSeconds32); |
|
52 CleanupStack::PushL(self); |
|
53 self->ConstructL(); |
|
54 CleanupStack::Pop(); |
|
55 return self; |
|
56 }; |
|
57 |
|
58 |
|
59 CMtmUiRegistry::~CMtmUiRegistry() |
|
60 /** Destructor. */ |
|
61 { |
|
62 } |
|
63 |
|
64 |
|
65 EXPORT_C CBaseMtmUi* CMtmUiRegistry::NewMtmUiL(CBaseMtm& aMtm) |
|
66 /** Creates a User Interface MTM object for the specified MTM. |
|
67 |
|
68 The client should delete the returned object when it is no longer required. |
|
69 |
|
70 @return User Interface MTM object for specified MTM |
|
71 @param aMtm Client MTM for which to get the associated UI MTM |
|
72 @leave KErrNotFound MTM type could not be found |
|
73 @leave KErrNoMemory A memory allocation failed |
|
74 @leave KErrBadLibraryEntryPoint Malformed MTM: a library entry point was not of the required type |
|
75 @leave Other DLL loading error codes if the DLL that provides the MTM cannot be loaded |
|
76 */ |
|
77 { |
|
78 CBaseMtmUi* newMtm = NULL; |
|
79 if(!IsPresent(aMtm.Type())) |
|
80 User::Leave(KErrNotFound); |
|
81 |
|
82 TInt index=MtmTypeUidToIndex(aMtm.Type()); |
|
83 CRegisteredMtmDll* registeredmtmdll=iRegisteredMtmDllArray[index]; |
|
84 RLibrary mtmdlllibrary; |
|
85 User::LeaveIfError(registeredmtmdll->GetLibrary(iFs,mtmdlllibrary)); |
|
86 |
|
87 TInt refcount=registeredmtmdll->MtmDllRefCount(); |
|
88 TRAPD(ret, newMtm = NewMtmL(mtmdlllibrary, aMtm, *registeredmtmdll)); |
|
89 |
|
90 if ((ret!=KErrNone) && (registeredmtmdll->MtmDllRefCount()==refcount)) // Library not released in mtm destructor |
|
91 registeredmtmdll->ReleaseLibrary(); |
|
92 |
|
93 User::LeaveIfError(ret); |
|
94 return newMtm; |
|
95 } |
|
96 |
|
97 CBaseMtmUi* CMtmUiRegistry::NewMtmL(const RLibrary& aLib, CBaseMtm& aMtm, CRegisteredMtmDll& aReg) const |
|
98 { |
|
99 TInt ordinal = aReg.MtmDllInfo().iEntryPointOrdinalNumber; |
|
100 TLibraryFunction libFunc = aLib.Lookup(ordinal); |
|
101 if (!libFunc) |
|
102 User::Leave(KErrBadLibraryEntryPoint); |
|
103 |
|
104 MtmUiFactoryFunctionL* pFunc = (MtmUiFactoryFunctionL*)libFunc; |
|
105 return (*pFunc)(aMtm, aReg); |
|
106 } |
|
107 |
|
108 // protected constructor |
|
109 CMtmUiRegistry::CMtmUiRegistry(CMsvSession& aMsvSession,TTimeIntervalMicroSeconds32 aTimeoutMicroSeconds32) |
|
110 : CObserverRegistry(aMsvSession, KUidMtmUiComponent, aTimeoutMicroSeconds32) |
|
111 { |
|
112 __DECLARE_NAME(_S("CMtmUiRegistry")); |
|
113 } |
|
114 |