|
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 __DEVICE_H |
|
20 #define __DEVICE_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <object.h> |
|
24 |
|
25 /** |
|
26 * Device |
|
27 * |
|
28 * @lib jsdevice.dll |
|
29 * @since 5.0 |
|
30 */ |
|
31 |
|
32 |
|
33 namespace KJS |
|
34 { |
|
35 |
|
36 class MDeviceBinding; |
|
37 class ServiceObject; |
|
38 class DevicePrivate; |
|
39 |
|
40 class Device: public JSObject |
|
41 { |
|
42 friend class DeviceFunc; |
|
43 public: // constructor and destructor |
|
44 |
|
45 /** |
|
46 * Constructor |
|
47 * @return none |
|
48 * @since 5.0 |
|
49 **/ |
|
50 Device( ExecState* exec ); |
|
51 |
|
52 /** |
|
53 * Pre-Destructor |
|
54 * Clean up resources before garbage collection destroys us |
|
55 * @return none |
|
56 * @since 5.0 |
|
57 **/ |
|
58 void Close(); |
|
59 |
|
60 /** |
|
61 * Destructor |
|
62 * @return none |
|
63 * @since 5.0 |
|
64 **/ |
|
65 virtual ~Device(); |
|
66 |
|
67 |
|
68 public: // From JSObject |
|
69 |
|
70 /** |
|
71 * getOwnPropertySlot |
|
72 * @return bool |
|
73 * @since 5.0 |
|
74 **/ |
|
75 bool getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot); |
|
76 /** |
|
77 * getValueProperty |
|
78 * @return JSValue* |
|
79 * @since 5.0 |
|
80 **/ |
|
81 JSValue* getValueProperty(KJS::ExecState* exec, int token) const; |
|
82 |
|
83 /** |
|
84 * class info |
|
85 * @return const ClassInfo* |
|
86 * @since 5.0 |
|
87 **/ |
|
88 const ClassInfo* classInfo() const { return &info; } |
|
89 |
|
90 /** |
|
91 * whether this object is valid |
|
92 * @return boolean |
|
93 * @since 5.0 |
|
94 */ |
|
95 const bool valid() const { return m_valid; } |
|
96 |
|
97 static const ClassInfo info; |
|
98 |
|
99 /** |
|
100 * entries in lookup table |
|
101 */ |
|
102 enum |
|
103 { |
|
104 getServiceObject, |
|
105 listProviders |
|
106 }; |
|
107 |
|
108 /** |
|
109 * toString |
|
110 * @return UString |
|
111 * @since 5.0 |
|
112 **/ |
|
113 virtual UString toString( ExecState* exec ) const; |
|
114 |
|
115 /** |
|
116 * SetUid |
|
117 * @return none |
|
118 * @since 5.0 |
|
119 **/ |
|
120 void SetUid( const TUint& aValue); |
|
121 |
|
122 private: |
|
123 DevicePrivate* m_privateData; // private object to hold data |
|
124 bool m_valid; // object is valid or not |
|
125 }; |
|
126 |
|
127 class DevicePrivate |
|
128 { |
|
129 friend class Device; |
|
130 friend class DeviceFunc; |
|
131 public: |
|
132 DevicePrivate(); |
|
133 ~DevicePrivate() { Close(); } |
|
134 void Close(); |
|
135 void SetUid( const TUint& aValue); |
|
136 |
|
137 private: |
|
138 MDeviceBinding* m_deviceBinding; // Owned |
|
139 Identifier m_propName; |
|
140 RPointerArray<ServiceObject>* m_serviceObjArray; // owned |
|
141 ExecState* m_exec; // not owned |
|
142 |
|
143 }; |
|
144 |
|
145 class DeviceFunc : public JSObject |
|
146 { |
|
147 |
|
148 public: // constructor and destructor |
|
149 |
|
150 /** |
|
151 * Constructor |
|
152 * @return none |
|
153 * @since 5.0 |
|
154 **/ |
|
155 DeviceFunc( ExecState* exec, MDeviceBinding* deviceBinding, |
|
156 int token ); |
|
157 |
|
158 /** |
|
159 * Destructor |
|
160 * @return none |
|
161 * @since 5.0 |
|
162 **/ |
|
163 virtual ~DeviceFunc() {} |
|
164 |
|
165 public: // From JSObject |
|
166 |
|
167 /** |
|
168 * implementsCall |
|
169 * @return bool |
|
170 * @since 5.0 |
|
171 **/ |
|
172 bool implementsCall() const { return true; } |
|
173 |
|
174 /** |
|
175 * call |
|
176 * @return Value |
|
177 * @since 5.0 |
|
178 **/ |
|
179 JSValue* callAsFunction(ExecState *exec, JSObject *thisObj, const List &args); |
|
180 |
|
181 private: |
|
182 MDeviceBinding* m_deviceBinding; // not owned |
|
183 int m_func; // not owned |
|
184 }; |
|
185 |
|
186 } |
|
187 |
|
188 #include "Device.lut.h" |
|
189 |
|
190 #endif //__DEVICE_H |