|
1 // Copyright (c) 1999-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 // A revised version of the CRegisteredParserDll class. This no longer uses a |
|
15 // reference to a CParserRegistrationData object. Instead a UidType is passed in |
|
16 // the constructor, or through a set method. The class is used to find the file |
|
17 // which contains a parser, to load and maintain a reference count of the number of |
|
18 // objects using the dll, so that it can be unloaded when no longer required. |
|
19 // It will also unload the dll when a new parser is required. |
|
20 // |
|
21 // |
|
22 |
|
23 #include "REGPSDLL.H" |
|
24 #include <f32file.h> |
|
25 #include <s32strm.h> |
|
26 #include <e32uid.h> |
|
27 #include <biouids.h> |
|
28 #include <msvreg.h> |
|
29 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
30 #include <biomessageuids.h> |
|
31 #endif |
|
32 |
|
33 EXPORT_C CRegisteredParserDll* CRegisteredParserDll::NewL(TDesC& aParserName) |
|
34 /** Allocates and creates a new BIO parser counter. |
|
35 |
|
36 @param aParserName Name of the BIO parser to handle |
|
37 @return New BIO parser counter */ |
|
38 { |
|
39 CRegisteredParserDll* self = new (ELeave) CRegisteredParserDll(aParserName); |
|
40 CleanupStack::PushL(self); |
|
41 self->ConstructL(); |
|
42 CleanupStack::Pop(self); |
|
43 return self; |
|
44 } |
|
45 |
|
46 void CRegisteredParserDll::ConstructL() |
|
47 { |
|
48 CTimer::ConstructL(); |
|
49 CActiveScheduler::Add(this); |
|
50 } |
|
51 |
|
52 |
|
53 CRegisteredParserDll::CRegisteredParserDll(const TDesC& aParserName) |
|
54 : CTimer(EPriorityLow), iParserName(aParserName) |
|
55 { |
|
56 } |
|
57 |
|
58 EXPORT_C CRegisteredParserDll::~CRegisteredParserDll() |
|
59 /** Destructor. */ |
|
60 { |
|
61 __ASSERT_DEBUG(iDllRefCount==0,User::Panic(_L("Dll in use"), KBIOMessageParserDllStillInUse)); |
|
62 Cancel(); |
|
63 iParserDllLibrary.Close(); |
|
64 } |
|
65 |
|
66 void CRegisteredParserDll::RunL() |
|
67 { |
|
68 iParserDllLibrary.Close(); |
|
69 } |
|
70 |
|
71 EXPORT_C TInt CRegisteredParserDll::GetLibrary(RFs& aFs,RLibrary& aDllLibrary) |
|
72 /** Gets a handle to the parser DLL, and increments the reference count. |
|
73 |
|
74 @param aFs File server handle |
|
75 @param aDllLibrary On return, the parser DLL |
|
76 @return Incremented reference count if successful; otherwise, a system wide |
|
77 error code */ |
|
78 { |
|
79 TInt ret=KErrNone; |
|
80 if (iDllRefCount==0) |
|
81 TRAP(ret,LoadLibraryL(aFs)); |
|
82 if (ret==KErrNone) |
|
83 { |
|
84 aDllLibrary = iParserDllLibrary; |
|
85 iDllRefCount++; |
|
86 } |
|
87 else |
|
88 iParserDllLibrary.Close(); |
|
89 return ret; |
|
90 } |
|
91 |
|
92 void CRegisteredParserDll::LoadLibraryL(RFs& /*aFs*/) |
|
93 { |
|
94 // load parser using name - messaging api v2 style |
|
95 Cancel(); |
|
96 if (iParserDllLibrary.Handle()==0) |
|
97 { |
|
98 User::LeaveIfError(iParserDllLibrary.Load(iParserName)); |
|
99 } |
|
100 } |
|
101 |
|
102 EXPORT_C void CRegisteredParserDll::ReleaseLibrary() |
|
103 /** Releases the parser DLL, and decrements the reference count. */ |
|
104 { |
|
105 iDllRefCount--; |
|
106 if(iDllRefCount==0) |
|
107 { |
|
108 After(KReleaseLibraryTimeout); |
|
109 } |
|
110 } |
|
111 |
|
112 TInt CRegisteredParserDll::FindFullName(RFs& /*aFs*/,TDes& /*aFullName*/) |
|
113 { |
|
114 User::Invariant(); |
|
115 return KErrNotSupported; // Only here to avoid warnings |
|
116 } |