22 #include <eikenv.h> |
22 #include <eikenv.h> |
23 #include <bautils.h> |
23 #include <bautils.h> |
24 #include "secui.h" |
24 #include "secui.h" |
25 #include <data_caging_path_literals.hrh> |
25 #include <data_caging_path_literals.hrh> |
26 |
26 |
27 _LIT(KDirAndFile,"z:SecUi.rsc"); |
|
28 |
|
29 |
|
30 // ================= MEMBER FUNCTIONS ======================= |
27 // ================= MEMBER FUNCTIONS ======================= |
31 // |
28 // |
32 // ---------------------------------------------------------- |
29 // ---------------------------------------------------------- |
33 // TSecUi::InitializeLibL() |
30 // TSecUi::InitializeLibL() |
34 // Initializes SecUi resource file |
31 // Initializes SecUi resource file |
36 // |
33 // |
37 EXPORT_C void TSecUi::InitializeLibL() |
34 EXPORT_C void TSecUi::InitializeLibL() |
38 { |
35 { |
39 if (Dll::Tls()!=NULL) |
36 if (Dll::Tls()!=NULL) |
40 {//Secui has been initialized already; increase client count. |
37 {//Secui has been initialized already; increase client count. |
41 #if defined(_DEBUG) |
38 RDEBUG("Secui has been initialized already", 0); |
42 RDebug::Print(_L("(SECUI): InitializeLibL: Secui has been initialized already")); |
|
43 #endif |
|
44 TSecUi* instance=(TSecUi*) Dll::Tls(); |
39 TSecUi* instance=(TSecUi*) Dll::Tls(); |
45 instance->IncreaseClientCount(); |
40 instance->IncreaseClientCount(); |
|
41 instance->iDialogOpened++; |
|
42 RDEBUG("instance->iDialogOpened", instance->iDialogOpened); |
46 return; |
43 return; |
47 } |
44 } |
48 #if defined(_DEBUG) |
45 RDEBUG("First initialization", 0); |
49 RDebug::Print(_L("(SECUI): InitializeLibL: First initialization")); |
|
50 #endif |
|
51 TSecUi* self = new (ELeave) TSecUi(); |
46 TSecUi* self = new (ELeave) TSecUi(); |
52 CleanupStack::PushL(self); |
47 CleanupStack::PushL(self); |
53 self->ConstructL(); |
48 self->ConstructL(); |
54 self->IncreaseClientCount(); |
49 self->IncreaseClientCount(); |
|
50 self->iDialogOpened=0; |
55 Dll::SetTls(self); |
51 Dll::SetTls(self); |
56 CleanupStack::Pop(); |
52 CleanupStack::Pop(); |
57 } |
53 } |
58 // |
54 // |
59 // ---------------------------------------------------------- |
55 // ---------------------------------------------------------- |
61 // Uninitializes SecUi resource file |
57 // Uninitializes SecUi resource file |
62 // ---------------------------------------------------------- |
58 // ---------------------------------------------------------- |
63 // |
59 // |
64 EXPORT_C void TSecUi::UnInitializeLib() |
60 EXPORT_C void TSecUi::UnInitializeLib() |
65 { |
61 { |
|
62 RDEBUG("0", 0); |
66 if (Dll::Tls()==NULL) |
63 if (Dll::Tls()==NULL) |
|
64 { |
|
65 RDEBUG("!!!!!!!!!! Dll::Tls not yet initialized: 0", 0); |
67 return; |
66 return; |
68 #if defined(_DEBUG) |
67 } |
69 RDebug::Print(_L("(SECUI): UnInitializeLibL")); |
68 RDEBUG("0", 0); |
70 #endif |
|
71 TSecUi* instance=(TSecUi*) Dll::Tls(); |
69 TSecUi* instance=(TSecUi*) Dll::Tls(); |
72 instance->DecreaseClientCount(); |
70 instance->DecreaseClientCount(); |
73 //only delete the lib is there are no clients using it |
71 //only delete the lib is there are no clients using it |
74 if(instance->CanBeFreed()) |
72 if(instance->CanBeFreed()) |
75 { |
73 { |
76 #if defined(_DEBUG) |
74 RDEBUG("Last uninitialize", 0); |
77 RDebug::Print(_L("(SECUI): UnInitializeLibL: Last uninitialize")); |
|
78 #endif |
|
79 delete instance; |
75 delete instance; |
80 Dll::SetTls(NULL); |
76 Dll::SetTls(NULL); |
81 } |
77 } |
82 } |
78 } |
83 |
79 |
87 // C++ default constructor |
83 // C++ default constructor |
88 // ---------------------------------------------------------- |
84 // ---------------------------------------------------------- |
89 // |
85 // |
90 TSecUi::TSecUi() |
86 TSecUi::TSecUi() |
91 { |
87 { |
92 |
|
93 } |
88 } |
94 // |
89 // |
95 // ---------------------------------------------------------- |
90 // ---------------------------------------------------------- |
96 // TSecUi::TSecUi() |
91 // TSecUi::TSecUi() |
97 // Destructor |
92 // Destructor |
98 // ---------------------------------------------------------- |
93 // ---------------------------------------------------------- |
99 // |
94 // |
100 TSecUi::~TSecUi() |
95 TSecUi::~TSecUi() |
101 { |
96 { |
102 if (iResourceFileOffset >= 0) |
|
103 { |
|
104 CEikonEnv::Static()->DeleteResourceFile(iResourceFileOffset); |
|
105 } |
|
106 } |
97 } |
107 // |
98 // |
108 // ---------------------------------------------------------- |
99 // ---------------------------------------------------------- |
109 // TSecUi::ConstructL() |
100 // TSecUi::ConstructL() |
110 // Symbian OS default constructor |
101 // Symbian OS default constructor |
111 // ---------------------------------------------------------- |
102 // ---------------------------------------------------------- |
112 // |
103 // |
113 void TSecUi::ConstructL() |
104 void TSecUi::ConstructL() |
114 { |
105 { |
115 iResourceFileOffset = CCoeEnv::Static()->AddResourceFileL(ResourceFileName()); |
106 RDEBUG("iClientCount", iClientCount); |
116 iClientCount = 0; |
107 iClientCount = 0; |
117 } |
|
118 // |
|
119 // ---------------------------------------------------------- |
|
120 // TSecUi::ResourceFileName |
|
121 // Returns the resource file name of SecurityUI dll. |
|
122 // ---------------------------------------------------------- |
|
123 // |
|
124 TFileName TSecUi::ResourceFileName() |
|
125 { |
|
126 |
|
127 TParse parse; |
|
128 parse.Set(KDirAndFile, &KDC_RESOURCE_FILES_DIR, NULL); |
|
129 TFileName resourceFileName(parse.FullName()); |
|
130 BaflUtils::NearestLanguageFile(CCoeEnv::Static()->FsSession(), resourceFileName); |
|
131 return resourceFileName; |
|
132 |
|
133 } |
108 } |
134 |
109 |
135 // ----------------------------------------------------------------------------- |
110 // ----------------------------------------------------------------------------- |
136 // TSecUi::CanBeFreed() |
111 // TSecUi::CanBeFreed() |
137 // ----------------------------------------------------------------------------- |
112 // ----------------------------------------------------------------------------- |
138 // |
113 // |
139 TBool TSecUi::CanBeFreed() |
114 TBool TSecUi::CanBeFreed() |
140 { |
115 { |
|
116 RDEBUG("iClientCount", iClientCount); |
141 if (iClientCount <= 0) |
117 if (iClientCount <= 0) |
142 { |
118 { |
143 #if defined(_DEBUG) |
|
144 RDebug::Print(_L("(SECUI): No clients; Can be freed: clients(%d) "), iClientCount); |
|
145 #endif |
|
146 return ETrue; |
119 return ETrue; |
147 } |
120 } |
148 else |
121 else |
149 { |
122 { |
150 #if defined(_DEBUG) |
|
151 RDebug::Print(_L("(SECUI): Can NOT be freed: clients(%d) "), iClientCount); |
|
152 #endif |
|
153 return EFalse; |
123 return EFalse; |
154 } |
124 } |
155 } |
125 } |
156 |
126 |
157 // ----------------------------------------------------------------------------- |
127 // ----------------------------------------------------------------------------- |
159 // ----------------------------------------------------------------------------- |
129 // ----------------------------------------------------------------------------- |
160 // |
130 // |
161 void TSecUi::IncreaseClientCount() |
131 void TSecUi::IncreaseClientCount() |
162 { |
132 { |
163 ++iClientCount; |
133 ++iClientCount; |
164 #if defined(_DEBUG) |
134 RDEBUG("iClientCount", iClientCount); |
165 RDebug::Print(_L("(SECUI): IncreaseClientCount, clients now(%d) "), iClientCount); |
|
166 #endif |
|
167 } |
135 } |
168 |
136 |
169 // ----------------------------------------------------------------------------- |
137 // ----------------------------------------------------------------------------- |
170 // TSecUi::DecreaseClientCount() |
138 // TSecUi::DecreaseClientCount() |
171 // ----------------------------------------------------------------------------- |
139 // ----------------------------------------------------------------------------- |
172 // |
140 // |
173 |
141 |
174 void TSecUi::DecreaseClientCount() |
142 void TSecUi::DecreaseClientCount() |
175 { |
143 { |
176 --iClientCount; |
144 --iClientCount; |
177 #if defined(_DEBUG) |
145 RDEBUG("iClientCount", iClientCount); |
178 RDebug::Print(_L("(SECUI): DecreaseClientCount, clients now(%d) "), iClientCount); |
|
179 #endif |
|
180 } |
146 } |
181 |
147 |
182 |
148 |
183 // End of file |
149 // End of file |
184 |
150 |