|
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 // |
|
15 |
|
16 #include "COEFEP.H" |
|
17 #include <coedef.h> // enum ERepositoryKeyMask_FepId etc |
|
18 #include <e32std.h> |
|
19 #include <e32base.h> |
|
20 #include <coemain.h> |
|
21 #include "coedatastorage.h" |
|
22 #include "coepanic.h" |
|
23 #include <centralrepository.h> |
|
24 #include "coedefkeys.h" |
|
25 |
|
26 // |
|
27 // class CCoeFepLoader |
|
28 // |
|
29 |
|
30 CCoeFepLoader* CCoeFepLoader::NewL(CCoeEnv& aCoeEnv, CCoeFepLoader*& aOwner) |
|
31 { |
|
32 return new(ELeave) CCoeFepLoader(aCoeEnv, aOwner); |
|
33 } |
|
34 |
|
35 CCoeFepLoader::~CCoeFepLoader() |
|
36 { |
|
37 Cancel(); |
|
38 iOwner=NULL; |
|
39 } |
|
40 |
|
41 CCoeFepLoader::CCoeFepLoader(CCoeEnv& aCoeEnv, CCoeFepLoader*& aOwner) |
|
42 :CActive(EActivePriorityFepLoader), |
|
43 iCoeEnv(aCoeEnv), |
|
44 iOwner(aOwner), |
|
45 iFirstRunL(ETrue) |
|
46 { |
|
47 CActiveScheduler::Add(this); |
|
48 TRequestStatus* status=&iStatus; |
|
49 User::RequestComplete(status, KErrNone); |
|
50 SetActive(); |
|
51 } |
|
52 |
|
53 void CCoeFepLoader::DoCancel() |
|
54 { |
|
55 } |
|
56 |
|
57 void CCoeFepLoader::RunL() |
|
58 { |
|
59 iCoeEnv.EnsureCorrectFepIsLoadedL(); |
|
60 |
|
61 if (iFirstRunL) |
|
62 { |
|
63 iFirstRunL=EFalse; |
|
64 #if defined(USE_IH_RAISE_EVENT) |
|
65 const TInt appStartupInstrumentationEventIdBase=iCoeEnv.AppStartupInstrumentationEventIdBase(); |
|
66 if (appStartupInstrumentationEventIdBase!=0) |
|
67 { |
|
68 IH_DECLARE( lInstrumentationHandler ); |
|
69 IH_CREATE( lInstrumentationHandler ); |
|
70 IH_RAISE_EVENT( lInstrumentationHandler, appStartupInstrumentationEventIdBase+MTestInstrumentation::TIDOffsetEndApplicationReadyForInput ); |
|
71 IH_DELETE( lInstrumentationHandler ); |
|
72 } |
|
73 #endif |
|
74 } |
|
75 delete this; |
|
76 } |
|
77 |
|
78 TInt CCoeFepLoader::RunError(TInt aError) |
|
79 { |
|
80 delete this; |
|
81 return aError; |
|
82 } |
|
83 |
|
84 |
|
85 // |
|
86 // class CCoeFepTracker |
|
87 // |
|
88 |
|
89 CCoeFepTracker* CCoeFepTracker::NewL(CCoeEnv& aCoeEnv) |
|
90 { // static |
|
91 CRepository& repository(CCoeDataStorage::GetL(aCoeEnv).FepFrameworkRepositoryL()); |
|
92 CCoeFepTracker* fepTracker = new(ELeave) CCoeFepTracker(aCoeEnv,repository); |
|
93 CleanupStack::PushL(fepTracker); |
|
94 fepTracker->ConstructL(); |
|
95 CleanupStack::Pop(fepTracker); |
|
96 return fepTracker; |
|
97 } |
|
98 |
|
99 CCoeFepTracker::~CCoeFepTracker() |
|
100 { |
|
101 Cancel(); |
|
102 } |
|
103 |
|
104 CCoeFepTracker::CCoeFepTracker(CCoeEnv& aCoeEnv, CRepository& aRepository) |
|
105 : CActive(EActivePriorityWsEvents), iCoeEnv(aCoeEnv), iRepository(aRepository) |
|
106 { |
|
107 CActiveScheduler::Add(this); |
|
108 } |
|
109 |
|
110 void CCoeFepTracker::ConstructL() |
|
111 { |
|
112 Queue(); |
|
113 } |
|
114 |
|
115 void CCoeFepTracker::Queue() |
|
116 { |
|
117 #if defined(_DEBUG) |
|
118 const TInt error= |
|
119 #endif |
|
120 iRepository.NotifyRequest(ERepositoryKeyMask_FepId, ERepositoryKeyMask_FepId, iStatus); |
|
121 __ASSERT_DEBUG(error==KErrNone, Panic(ECoePanicUnexpectedError)); |
|
122 SetActive(); |
|
123 } |
|
124 |
|
125 void CCoeFepTracker::DoCancel() |
|
126 { |
|
127 iRepository.NotifyCancel(ERepositoryKeyMask_FepId, ERepositoryKeyMask_FepId); |
|
128 } |
|
129 |
|
130 void CCoeFepTracker::RunL() |
|
131 { |
|
132 const TInt error = iStatus.Int(); |
|
133 Queue(); |
|
134 User::LeaveIfError(error); |
|
135 iCoeEnv.EnsureCorrectFepIsLoadedL(); |
|
136 } |
|
137 |
|
138 // |
|
139 // class FepName |
|
140 // |
|
141 |
|
142 TUid FepName::UidFromNameL(const TDesC& aName) |
|
143 { |
|
144 _LIT(KLitSecureFepNameMatch,"::*"); |
|
145 const TInt pos = aName.Match(KLitSecureFepNameMatch); |
|
146 if(pos != 0) |
|
147 { |
|
148 return TUid::Null(); |
|
149 } |
|
150 // The specified FEP uses ECom, and aName is actually the UID in hex prefixed with "::". |
|
151 TPtrC uidVal(aName.Mid(KLitSecureFepNameMatch().Length() - 1)); |
|
152 if((uidVal.Length() > 2) && (uidVal[1] == 'x')) |
|
153 { |
|
154 // Has "0x" prefix. |
|
155 uidVal.Set(uidVal.Mid(2)); |
|
156 } |
|
157 TUint32 uid = 0; |
|
158 TLex lexer(uidVal); |
|
159 User::LeaveIfError(lexer.Val(uid, EHex)); |
|
160 return TUid::Uid(TInt(uid)); |
|
161 } |
|
162 |
|
163 void FepName::NameFromUid(TDes& aName, const TUid& aUid) |
|
164 /** |
|
165 Generates a common FEP name representation for a secure FEP. |
|
166 |
|
167 @param aName On return, the common name representation. |
|
168 @param aUid The UID of the secure FEP implementation. |
|
169 */ |
|
170 { |
|
171 _LIT(KLitSecureFepNameFormat,"::%08X"); |
|
172 aName.Format(KLitSecureFepNameFormat, aUid.iUid); |
|
173 } |
|
174 |
|
175 |