|
1 /* |
|
2 * Copyright (c) 2005-2007 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: Psln Active Idle settings plugin. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "gsactiveidleplugin.h" |
|
20 #include "gsactiveidleplugincontainer.h" |
|
21 |
|
22 #include <pslnfwplugininterface.h> |
|
23 #include <pslnfwpluginhandler.h> |
|
24 #include <pslnactiveidlepluginrsc.rsg> |
|
25 #include "pslnactiveidlepluginuids.h" |
|
26 |
|
27 #include <coeaui.h> |
|
28 #include <gulicon.h> |
|
29 #include <bautils.h> |
|
30 #include <eikfrlbd.h> |
|
31 #include <stringloader.h> |
|
32 #include <aknviewappui.h> |
|
33 |
|
34 #include <gsfwviewuids.h> |
|
35 #include <gsprivatepluginproviderids.h> |
|
36 |
|
37 // GS Active Idle Plugin impl. UID |
|
38 const TUid KGSActiveIdlePluginUid = { KGSActiveIdlePluginImplementationUID }; |
|
39 |
|
40 // Psln Active Idle Plugin impl. UID |
|
41 const TUid KPslnAIPluginUid = { KPslnActiveIdlePluginImplementationUID }; |
|
42 |
|
43 _LIT(KGSActiveIdlePluginResourceFileName, "z:pslnactiveidlepluginrsc.rsc"); |
|
44 |
|
45 |
|
46 // ---------------------------------------------------------------------------- |
|
47 // CGSActiveIdlePlugin::CGSActiveIdlePlugin() |
|
48 // |
|
49 // Constructor |
|
50 // ---------------------------------------------------------------------------- |
|
51 // |
|
52 CGSActiveIdlePlugin::CGSActiveIdlePlugin() : iResourceLoader(*iCoeEnv), iPrevViewId() |
|
53 { |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // CGSActiveIdlePlugin::NewL() |
|
58 // |
|
59 // Symbian OS default constructor |
|
60 // --------------------------------------------------------------------------- |
|
61 CGSActiveIdlePlugin* CGSActiveIdlePlugin::NewL(TAny* /*aInitParams*/) |
|
62 { |
|
63 CGSActiveIdlePlugin* self = new (ELeave) CGSActiveIdlePlugin(); |
|
64 |
|
65 CleanupStack::PushL(self); |
|
66 self->ConstructL(); |
|
67 CleanupStack::Pop(self); |
|
68 |
|
69 return self; |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------------------------- |
|
73 // CGSActiveIdlePlugin::ConstructL() |
|
74 // |
|
75 // Symbian OS two-phased constructor |
|
76 // --------------------------------------------------------------------------- |
|
77 void CGSActiveIdlePlugin::ConstructL() |
|
78 { |
|
79 #ifdef _MY_DEBUG |
|
80 RDebug::Print(_L("XAI: CGSActiveIdlePlugin::ConstructL")); |
|
81 #endif |
|
82 |
|
83 // Find the resource file. |
|
84 TParse parse; |
|
85 parse.Set(KGSActiveIdlePluginResourceFileName, &KDC_RESOURCE_FILES_DIR, NULL); |
|
86 TFileName fileName(parse.FullName()); |
|
87 |
|
88 // Open resource file. |
|
89 iResourceLoader.OpenL(fileName); |
|
90 |
|
91 BaseConstructL(); |
|
92 |
|
93 // Psln first finds and loads all plugins that implement Psln plugin interface. |
|
94 iPluginLoader = CPslnFWPluginHandler::NewL(AppUi()); |
|
95 CPslnFWPluginInterface* plugin = iPluginLoader->LoadPluginL(KPslnAIPluginUid); |
|
96 if (plugin) |
|
97 { |
|
98 // Add Psln Active Idle plugin to appui views. Plugin is deleted |
|
99 // when appui is destroyed. |
|
100 if (plugin->Id() == KPslnAIPluginUid) |
|
101 { |
|
102 CAknView* view = static_cast<CAknView*>(plugin); |
|
103 AppUi()->AddViewL(view); |
|
104 } |
|
105 } |
|
106 } |
|
107 |
|
108 // ---------------------------------------------------------------------------- |
|
109 // CGSActiveIdlePlugin::~CGSActiveIdlePlugin |
|
110 // |
|
111 // Destructor |
|
112 // ---------------------------------------------------------------------------- |
|
113 CGSActiveIdlePlugin::~CGSActiveIdlePlugin() |
|
114 { |
|
115 if (iContainer) |
|
116 { |
|
117 AppUi()->RemoveFromStack(iContainer); |
|
118 delete iContainer; |
|
119 iContainer = NULL; |
|
120 } |
|
121 |
|
122 iResourceLoader.Close(); |
|
123 |
|
124 delete iPluginLoader; |
|
125 } |
|
126 |
|
127 // --------------------------------------------------------------------------- |
|
128 // TUid CGSActiveIdlePlugin::Id() |
|
129 // |
|
130 // Returns view's ID. |
|
131 // --------------------------------------------------------------------------- |
|
132 TUid CGSActiveIdlePlugin::Id() const |
|
133 { |
|
134 return KGSActiveIdlePluginUid; |
|
135 } |
|
136 |
|
137 // ---------------------------------------------------------------------------- |
|
138 // CGSActiveIdlePlugin::GetCaption |
|
139 // |
|
140 // Return application/view caption. 256 |
|
141 // ---------------------------------------------------------------------------- |
|
142 // |
|
143 void CGSActiveIdlePlugin::GetCaptionL(TDes& aCaption) const |
|
144 { |
|
145 iCoeEnv->ReadResourceL(aCaption, R_PSLN_GS_LIST_VIEW_CAPTION); |
|
146 } |
|
147 |
|
148 // ---------------------------------------------------------------------------- |
|
149 // CGSActiveIdlePlugin::PluginProviderCategory |
|
150 // |
|
151 // A means to identify the location of this plug-in in the framework. |
|
152 // ---------------------------------------------------------------------------- |
|
153 // |
|
154 TInt CGSActiveIdlePlugin::PluginProviderCategory() const |
|
155 { |
|
156 // To identify internal plug-ins. |
|
157 return KGSPluginProviderInternal; |
|
158 } |
|
159 |
|
160 // ---------------------------------------------------------------------------- |
|
161 // CGSActiveIdlePlugin::Visible |
|
162 // |
|
163 // Provides the visibility status of self to framework. |
|
164 // ---------------------------------------------------------------------------- |
|
165 // |
|
166 TBool CGSActiveIdlePlugin::Visible() const |
|
167 { |
|
168 #ifdef _MY_DEBUG |
|
169 RDebug::Print(_L("XAI: CGSActiveIdlePlugin::Visible")); |
|
170 #endif |
|
171 |
|
172 return ETrue; |
|
173 } |
|
174 |
|
175 // --------------------------------------------------------------------------- |
|
176 // CGSActiveIdlePlugin::HandleCommandL(TInt aCommand) |
|
177 // |
|
178 // Handles commands directed to this class. |
|
179 // --------------------------------------------------------------------------- |
|
180 void CGSActiveIdlePlugin::HandleCommandL(TInt aCommand) |
|
181 { |
|
182 // shouldn't get any commands to handle, but forward them to appui anyway... |
|
183 AppUi()->HandleCommandL(aCommand); |
|
184 } |
|
185 |
|
186 // ---------------------------------------------------------------------------- |
|
187 // CGSActiveIdlePlugin::DoActivateL |
|
188 // |
|
189 // First method called by the Avkon framwork to invoke a view. |
|
190 // ---------------------------------------------------------------------------- |
|
191 // |
|
192 void CGSActiveIdlePlugin::DoActivateL( |
|
193 const TVwsViewId& aPrevViewId, |
|
194 TUid /*aCustomMessageId*/, |
|
195 const TDesC8& /*aCustomMessage*/) |
|
196 { |
|
197 #ifdef _MY_DEBUG |
|
198 RDebug::Print(_L("XAI: CGSActiveIdlePlugin::DoActivateL")); |
|
199 #endif |
|
200 |
|
201 if (!iContainer) |
|
202 { |
|
203 iContainer = new (ELeave) CGSActiveIdlePluginContainer(); |
|
204 iContainer->SetMopParent(this); |
|
205 iContainer->ConstructL(ClientRect()); |
|
206 } |
|
207 |
|
208 AppUi()->AddToStackL(*this, iContainer); |
|
209 |
|
210 if (iPrevViewId.iViewUid.iUid == 0) |
|
211 { |
|
212 iPrevViewId = aPrevViewId; |
|
213 } |
|
214 |
|
215 iContainer->MakeVisible(ETrue); |
|
216 AppUi()->ActivateLocalViewL(KPslnAIPluginUid); |
|
217 } |
|
218 |
|
219 // ---------------------------------------------------------------------------- |
|
220 // CGSActiveIdlePlugin::DoDeactivate |
|
221 // |
|
222 // Called by the Avkon view framework when closing. |
|
223 // ---------------------------------------------------------------------------- |
|
224 // |
|
225 void CGSActiveIdlePlugin::DoDeactivate() |
|
226 { |
|
227 AppUi()->RemoveFromStack(iContainer); |
|
228 iContainer->MakeVisible(EFalse); |
|
229 iPrevViewId.iViewUid.iUid = 0; |
|
230 } |
|
231 |
|
232 // End of File. |