1 /* |
|
2 * Copyright (c) 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 the License "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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef SYSTEMINFOPLUGIN_H |
|
20 #define SYSTEMINFOPLUGIN_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <cecombrowserplugininterface.h> |
|
24 #include <npscript.h> |
|
25 |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class CPowerObserver; |
|
29 class CNetworkObserver; |
|
30 class CSystemInfoMisc; |
|
31 class MProfileEngine; |
|
32 |
|
33 // CLASS DECLARATION |
|
34 |
|
35 /****************************************** |
|
36 This class is specific to ECom Style Plugin. This is used for passing |
|
37 plugin specific initialization information to and from browser. |
|
38 *******************************************/ |
|
39 IMPORT_C NPError InitializeFuncs( NPPluginFuncs* aPpf ); |
|
40 |
|
41 // CONSTANTS |
|
42 const TInt KFirstSystemInfoImplementationValue = 0x10282854; |
|
43 |
|
44 /** |
|
45 * CSystemInfoPluginEcomMain |
|
46 * Used for passing plugin specific initialization information to and from browser. |
|
47 * @lib npSystemInfoPlugin.lib |
|
48 * @since S60 v3.2 |
|
49 */ |
|
50 NONSHARABLE_CLASS(CSystemInfoPluginEcomMain) : public CEcomBrowserPluginInterface |
|
51 { |
|
52 public: // Functions from base classes |
|
53 |
|
54 /** |
|
55 * Two-phased constructor. |
|
56 */ |
|
57 static CSystemInfoPluginEcomMain* NewL( TAny* aInitParam ); |
|
58 |
|
59 /** |
|
60 * Destructor |
|
61 */ |
|
62 virtual ~CSystemInfoPluginEcomMain(); |
|
63 |
|
64 /** |
|
65 * Passed from the browser to the plugin and delcares what |
|
66 * functions the browser makes available |
|
67 */ |
|
68 NPNetscapeFuncs* Funcs() const { return iNpf; } |
|
69 |
|
70 private: |
|
71 |
|
72 // Default constructor |
|
73 CSystemInfoPluginEcomMain( NPNetscapeFuncs* aNpf ); |
|
74 |
|
75 // By default Symbian 2nd phase constructor is private. |
|
76 void ConstructL( NPPluginFuncs* aPluginFuncs ); |
|
77 |
|
78 // Netscape Function Pointer |
|
79 NPNetscapeFuncs* iNpf; |
|
80 }; |
|
81 |
|
82 /** |
|
83 * CSystemInfoPlugin class |
|
84 * Interfaces to Browser, used to pass information between browser and plugin |
|
85 * @lib npSystemInfoPlugin.lib |
|
86 * @since S60 v3.2 |
|
87 */ |
|
88 NONSHARABLE_CLASS(CSystemInfoPlugin) : public CBase |
|
89 { |
|
90 public: |
|
91 static CSystemInfoPlugin* NewL(); |
|
92 |
|
93 virtual ~CSystemInfoPlugin(); |
|
94 |
|
95 public: |
|
96 void Deallocate (); |
|
97 bool HasMethod( NPIdentifier name ); |
|
98 bool Invoke( NPIdentifier name, |
|
99 NPVariant *args, |
|
100 uint32_t argCount, |
|
101 NPVariant *result ); |
|
102 bool HasProperty( NPIdentifier name ); |
|
103 bool GetProperty( NPIdentifier name, NPVariant *variant ); |
|
104 bool SetPropertyL( NPIdentifier name, NPVariant *variant ); |
|
105 |
|
106 public: |
|
107 void SetInstance( NPP instance ) { iInstanceHandle = instance; } |
|
108 bool InvokeCallback ( TDesC8& name, const NPVariant *args, uint32_t argCount ); |
|
109 |
|
110 private: |
|
111 CSystemInfoPlugin(); |
|
112 void ConstructL(); |
|
113 |
|
114 void VariantToInt( NPVariant& v, TInt& i ); |
|
115 void DesToNpvariant(TPtr8& string, NPVariant*& variant); |
|
116 |
|
117 private: |
|
118 NPP iInstanceHandle; |
|
119 NPIdentifier* iSystemInfoPluginIdentifiers; |
|
120 TUid iUid; |
|
121 MProfileEngine* iProfileEngine; |
|
122 |
|
123 // sysinfo feature class instances |
|
124 CPowerObserver* iPowerObserver; // owned |
|
125 CNetworkObserver* iNetworkObserver; // owned |
|
126 CSystemInfoMisc* iSystemInfoMisc; // owned |
|
127 }; |
|
128 |
|
129 /** |
|
130 ******************************************************************************** |
|
131 Plugin API methods. Source located in CSystemInfoApi.cpp |
|
132 ********************************************************************************* |
|
133 */ |
|
134 |
|
135 /** |
|
136 * Create a plugin. |
|
137 */ |
|
138 |
|
139 NPError SystemInfoNewp( NPMIMEType pluginType, NPP instance, uint16 mode, |
|
140 CDesCArray* argn, CDesCArray* argv, NPSavedData* saved ); |
|
141 |
|
142 /** |
|
143 * Wrapper the errors |
|
144 */ |
|
145 void SystemInfoConstructL( NPP aInstance, CDesCArray* argn, CDesCArray* argv ); |
|
146 |
|
147 /** |
|
148 * Destroy a plugin. |
|
149 */ |
|
150 NPError SystemInfoDestroy( NPP instance, NPSavedData** save ); |
|
151 |
|
152 /** |
|
153 * Generic hook to retrieve values/attributes from the plugin. |
|
154 */ |
|
155 NPError SystemInfoGetvalue( NPP instance, NPPVariable variable, void *ret_value ); |
|
156 |
|
157 |
|
158 /** |
|
159 ******************************************************************************** |
|
160 System Info Plugin API methods. Source located in CSystemInfoApi.cpp |
|
161 ********************************************************************************* |
|
162 */ |
|
163 typedef struct |
|
164 { |
|
165 NPObject object; |
|
166 CSystemInfoPlugin *plugin; |
|
167 } SystemInfoPluginObject; |
|
168 |
|
169 /** |
|
170 * systemInfoPluginAllocate |
|
171 */ |
|
172 NPObject* systemInfoPluginAllocate( NPP /*npp*/, NPClass* /*aClass*/ ); |
|
173 |
|
174 /** |
|
175 * systemInfoPluginDeallocate |
|
176 */ |
|
177 void systemInfoPluginDeallocate( SystemInfoPluginObject* obj ); |
|
178 |
|
179 /** |
|
180 * systemInfoPluginInvalidate |
|
181 */ |
|
182 void systemInfoPluginInvalidate( NPObject* /*obj*/ ); |
|
183 |
|
184 /** |
|
185 * systemInfoPluginHasMethod |
|
186 */ |
|
187 bool systemInfoPluginHasMethod( SystemInfoPluginObject* obj, |
|
188 NPIdentifier name ); |
|
189 |
|
190 /** |
|
191 * systemInfoPluginInvokeFunction |
|
192 */ |
|
193 bool systemInfoPluginInvokeFunction( SystemInfoPluginObject* obj, |
|
194 NPIdentifier name, |
|
195 NPVariant* args, |
|
196 uint32_t argCount, |
|
197 NPVariant* result ); |
|
198 |
|
199 /** |
|
200 * systemInfoPluginHasProperty |
|
201 */ |
|
202 bool systemInfoPluginHasProperty( SystemInfoPluginObject* obj, |
|
203 NPIdentifier name ); |
|
204 |
|
205 /** |
|
206 * systemInfoPluginGetProperty |
|
207 */ |
|
208 bool systemInfoPluginGetProperty ( SystemInfoPluginObject* obj, |
|
209 NPIdentifier name, |
|
210 NPVariant* variant); |
|
211 |
|
212 /** |
|
213 * systemInfoPluginSetProperty |
|
214 */ |
|
215 bool systemInfoPluginSetProperty( SystemInfoPluginObject* obj, |
|
216 NPIdentifier name, |
|
217 NPVariant* variant); |
|
218 |
|
219 /** |
|
220 * _systemInfoPluginClass |
|
221 */ |
|
222 static NPClass _systemInfoPluginClass = |
|
223 { |
|
224 0, // structVersion |
|
225 (NPAllocateFunctionPtr) systemInfoPluginAllocate, |
|
226 (NPDeallocateFunctionPtr) systemInfoPluginDeallocate, |
|
227 (NPInvalidateFunctionPtr) systemInfoPluginInvalidate, |
|
228 (NPHasMethodFunctionPtr) systemInfoPluginHasMethod, |
|
229 (NPInvokeFunctionPtr) systemInfoPluginInvokeFunction, |
|
230 (NPInvokeDefaultFunctionPtr) 0, |
|
231 (NPHasPropertyFunctionPtr) systemInfoPluginHasProperty, |
|
232 (NPGetPropertyFunctionPtr) systemInfoPluginGetProperty, |
|
233 (NPSetPropertyFunctionPtr) systemInfoPluginSetProperty, |
|
234 (NPRemovePropertyFunctionPtr) 0, |
|
235 (NPEnumerationFunctionPtr) 0 |
|
236 }; |
|
237 |
|
238 /** |
|
239 * static instance of the function pointer table |
|
240 */ |
|
241 static NPClass* systemInfoPluginClass = &_systemInfoPluginClass; |
|
242 |
|
243 #endif // SYSTEMINFOPLUGIN_H |
|
244 |
|
245 // End of File |
|