author | Eugene Ostroukhov <eugeneo@symbian.org> |
Tue, 13 Jul 2010 14:25:10 -0700 | |
changeset 442 | 980aaebb8022 |
parent 340 | 740921999de7 |
permissions | -rw-r--r-- |
310
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1 |
if (typeof(DeviceInfo) != 'object') |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
2 |
DeviceInfo = {}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
3 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
4 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
5 |
* This represents the PhoneGap API itself, and provides a global namespace for accessing |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
6 |
* information about the state of PhoneGap. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
7 |
* @class |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
8 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
9 |
PhoneGap = { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
10 |
queue: { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
11 |
ready: true, |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
12 |
commands: [], |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
13 |
timer: null |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
14 |
}, |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
15 |
_constructors: [] |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
16 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
17 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
18 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
19 |
* Boolean flag indicating if the PhoneGap API is available and initialized. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
20 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
21 |
PhoneGap.available = DeviceInfo.uuid != undefined; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
22 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
23 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
24 |
* Execute a PhoneGap command in a queued fashion, to ensure commands do not |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
25 |
* execute with any race conditions, and only run when PhoneGap is ready to |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
26 |
* recieve them. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
27 |
* @param {String} command Command to be run in PhoneGap, e.g. "ClassName.method" |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
28 |
* @param {String[]} [args] Zero or more arguments to pass to the method |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
29 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
30 |
PhoneGap.exec = function() { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
31 |
PhoneGap.queue.commands.push(arguments); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
32 |
if (PhoneGap.queue.timer == null) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
33 |
PhoneGap.queue.timer = setInterval(PhoneGap.run_command, 10); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
34 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
35 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
36 |
* Internal function used to dispatch the request to PhoneGap. This needs to be implemented per-platform to |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
37 |
* ensure that methods are called on the phone in a way appropriate for that device. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
38 |
* @private |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
39 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
40 |
PhoneGap.run_command = function() { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
41 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
42 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
43 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
44 |
* This class contains acceleration information |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
45 |
* @constructor |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
46 |
* @param {Number} x The force applied by the device in the x-axis. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
47 |
* @param {Number} y The force applied by the device in the y-axis. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
48 |
* @param {Number} z The force applied by the device in the z-axis. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
49 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
50 |
function Acceleration(x, y, z) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
51 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
52 |
* The force applied by the device in the x-axis. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
53 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
54 |
this.x = x; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
55 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
56 |
* The force applied by the device in the y-axis. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
57 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
58 |
this.y = y; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
59 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
60 |
* The force applied by the device in the z-axis. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
61 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
62 |
this.z = z; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
63 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
64 |
* The time that the acceleration was obtained. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
65 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
66 |
this.timestamp = new Date().getTime(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
67 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
68 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
69 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
70 |
* This class specifies the options for requesting acceleration data. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
71 |
* @constructor |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
72 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
73 |
function AccelerationOptions() { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
74 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
75 |
* The timeout after which if acceleration data cannot be obtained the errorCallback |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
76 |
* is called. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
77 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
78 |
this.timeout = 10000; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
79 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
80 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
81 |
* This class provides access to device accelerometer data. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
82 |
* @constructor |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
83 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
84 |
function Accelerometer() { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
85 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
86 |
* The last known acceleration. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
87 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
88 |
this.lastAcceleration = null; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
89 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
90 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
91 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
92 |
* Asynchronously aquires the current acceleration. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
93 |
* @param {Function} successCallback The function to call when the acceleration |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
94 |
* data is available |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
95 |
* @param {Function} errorCallback The function to call when there is an error |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
96 |
* getting the acceleration data. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
97 |
* @param {AccelerationOptions} options The options for getting the accelerometer data |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
98 |
* such as timeout. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
99 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
100 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
101 |
Accelerometer.prototype.getCurrentAcceleration = function(successCallback, errorCallback, options) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
102 |
// If the acceleration is available then call success |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
103 |
// If the acceleration is not available then call error |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
104 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
105 |
try { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
106 |
if (!this.serviceObj) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
107 |
this.serviceObj = this.getServiceObj(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
108 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
109 |
if (this.serviceObj == null) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
110 |
throw { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
111 |
name: "DeviceErr", |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
112 |
message: "Could not initialize service object" |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
113 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
114 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
115 |
//get the sensor channel |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
116 |
var SensorParams = { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
117 |
SearchCriterion: "AccelerometerAxis" |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
118 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
119 |
var returnvalue = this.serviceObj.ISensor.FindSensorChannel(SensorParams); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
120 |
var error = returnvalue["ErrorCode"]; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
121 |
var errmsg = returnvalue["ErrorMessage"]; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
122 |
if (!(error == 0 || error == 1012)) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
123 |
var ex = { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
124 |
name: "Unable to find Sensor Channel: " + error, |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
125 |
message: errmsg |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
126 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
127 |
throw ex; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
128 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
129 |
var channelInfoMap = returnvalue["ReturnValue"][0]; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
130 |
var criteria = { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
131 |
ChannelInfoMap: channelInfoMap, |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
132 |
ListeningType: "ChannelData" |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
133 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
134 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
135 |
if (typeof(successCallback) != 'function') |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
136 |
successCallback = function(){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
137 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
138 |
if (typeof(errorCallback) != 'function') |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
139 |
errorCallback = function(){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
140 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
141 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
142 |
this.success_callback = successCallback; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
143 |
this.error_callback = errorCallback; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
144 |
//create a closure to persist this instance of Accelerometer into the RegisterForNofication callback |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
145 |
var obj = this; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
146 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
147 |
// TODO: this call crashes WRT, but there is no other way to read the accel sensor |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
148 |
// http://discussion.forum.nokia.com/forum/showthread.php?t=182151&highlight=memory+leak |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
149 |
this.serviceObj.ISensor.RegisterForNotification(criteria, function(transId, eventCode, result){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
150 |
try { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
151 |
var criteria = { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
152 |
TransactionID: transId |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
153 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
154 |
obj.serviceObj.ISensor.Cancel(criteria); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
155 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
156 |
var accel = new Acceleration(result.ReturnValue.XAxisData, result.ReturnValue.YAxisData, result.ReturnValue.ZAxisData); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
157 |
Accelerometer.lastAcceleration = accel; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
158 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
159 |
obj.success_callback(accel); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
160 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
161 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
162 |
catch (ex) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
163 |
obj.serviceObj.ISensor.Cancel(criteria); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
164 |
obj.error_callback(ex); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
165 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
166 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
167 |
}); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
168 |
} catch (ex) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
169 |
errorCallback(ex); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
170 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
171 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
172 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
173 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
174 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
175 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
176 |
* Asynchronously aquires the acceleration repeatedly at a given interval. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
177 |
* @param {Function} successCallback The function to call each time the acceleration |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
178 |
* data is available |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
179 |
* @param {Function} errorCallback The function to call when there is an error |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
180 |
* getting the acceleration data. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
181 |
* @param {AccelerationOptions} options The options for getting the accelerometer data |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
182 |
* such as timeout. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
183 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
184 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
185 |
Accelerometer.prototype.watchAcceleration = function(successCallback, errorCallback, options) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
186 |
this.getCurrentAcceleration(successCallback, errorCallback, options); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
187 |
// TODO: add the interval id to a list so we can clear all watches |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
188 |
var frequency = (options != undefined)? options.frequency : 10000; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
189 |
return setInterval(function() { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
190 |
navigator.accelerometer.getCurrentAcceleration(successCallback, errorCallback, options); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
191 |
}, frequency); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
192 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
193 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
194 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
195 |
* Clears the specified accelerometer watch. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
196 |
* @param {String} watchId The ID of the watch returned from #watchAcceleration. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
197 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
198 |
Accelerometer.prototype.clearWatch = function(watchId) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
199 |
clearInterval(watchId); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
200 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
201 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
202 |
//gets the Acceleration Service Object from WRT |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
203 |
Accelerometer.prototype.getServiceObj = function() { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
204 |
var so; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
205 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
206 |
try { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
207 |
so = device.getServiceObject("Service.Sensor", "ISensor"); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
208 |
} catch (ex) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
209 |
throw { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
210 |
name: "DeviceError", |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
211 |
message: "Could not initialize accel service object (" + ex.name + ": " + ex.message + ")" |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
212 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
213 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
214 |
return so; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
215 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
216 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
217 |
if (typeof navigator.accelerometer == "undefined") navigator.accelerometer = new Accelerometer();/** |
321
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
218 |
* This class provides access to the device media, interfaces to both sound and video |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
219 |
* @constructor |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
220 |
*/ |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
221 |
function Audio(src, successCallback, errorCallback) { |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
222 |
this.src = src; |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
223 |
this.successCallback = successCallback; |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
224 |
this.errorCallback = errorCallback; |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
225 |
} |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
226 |
|
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
227 |
Audio.prototype.record = function() { |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
228 |
}; |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
229 |
|
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
230 |
Audio.prototype.play = function() { |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
231 |
try { |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
232 |
if (document.getElementById('gapsound')) |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
233 |
document.body.removeChild(document.getElementById('gapsound')); |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
234 |
var obj; |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
235 |
obj = document.createElement("embed"); |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
236 |
obj.setAttribute("id", "gapsound"); |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
237 |
obj.setAttribute("type", "audio/x-mpeg"); |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
238 |
obj.setAttribute("width", "0"); |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
239 |
obj.setAttribute("width", "0"); |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
240 |
obj.setAttribute("hidden", "true"); |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
241 |
obj.setAttribute("autostart", "true"); |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
242 |
obj.setAttribute("src", this.src); |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
243 |
document.body.appendChild(obj); |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
244 |
} catch (ex) { debug.log(ex.name + ": " + ex.message); } |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
245 |
}; |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
246 |
|
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
247 |
Audio.prototype.pause = function() { |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
248 |
}; |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
249 |
|
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
250 |
Audio.prototype.stop = function() { |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
251 |
document.body.removeChild(document.getElementById('gapsound')); |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
252 |
}; |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
253 |
/** |
310
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
254 |
* This class provides access to the device camera. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
255 |
* @constructor |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
256 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
257 |
function Camera() { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
258 |
this.success_callback = null; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
259 |
this.error_callback = null; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
260 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
261 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
262 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
263 |
* We use the Platform Services 2.0 API here. So we must include a portion of the |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
264 |
* PS 2.0 source code (camera API). |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
265 |
* @param {Function} successCallback |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
266 |
* @param {Function} errorCallback |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
267 |
* @param {Object} options |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
268 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
269 |
Camera.prototype.getPicture = function(successCallback, errorCallback, options){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
270 |
try { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
271 |
if (!this.serviceObj) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
272 |
this.serviceObj = com.nokia.device.load("", "com.nokia.device.camera", ""); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
273 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
274 |
if (!this.serviceObj) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
275 |
throw { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
276 |
name: "CameraError", |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
277 |
message: "could not load camera service" |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
278 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
279 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
280 |
var obj = this; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
281 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
282 |
obj.success_callback = successCallback; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
283 |
obj.error_callback = errorCallback; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
284 |
this.serviceObj.startCamera( function(transactionID, errorCode, outPut) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
285 |
//outPut should be an array of image urls (local), or an error code |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
286 |
if (errorCode == 0) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
287 |
obj.success_callback(outPut); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
288 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
289 |
else { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
290 |
obj.error_callback({ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
291 |
name: "CameraError", |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
292 |
message: errorCode |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
293 |
}); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
294 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
295 |
}); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
296 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
297 |
} catch (ex) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
298 |
errorCallback.call(ex); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
299 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
300 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
301 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
302 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
303 |
if (typeof navigator.camera == "undefined") navigator.camera = new Camera();/* |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
304 |
Copyright © 2009 Nokia. All rights reserved. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
305 |
Code licensed under the BSD License: |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
306 |
Software License Agreement (BSD License) Copyright © 2009 Nokia. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
307 |
All rights reserved. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
308 |
Redistribution and use of this software in source and binary forms, with or without modification, are permitted provided that the following conditions are met: |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
309 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
310 |
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
311 |
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
312 |
Neither the name of Nokia Corporation. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission of Nokia Corporation. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
313 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
314 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
315 |
version: 1.0 |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
316 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
317 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
318 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
319 |
// utility.js |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
320 |
// |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
321 |
// This file contains some utility functions for S60 providers |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
322 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
323 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
324 |
// Start an application and wait for it to exit |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
325 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
326 |
//TBD: Get rid of this global, use closures instead |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
327 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
328 |
DeviceError.prototype = new Error(); //inheritance occurs here |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
329 |
DeviceError.prototype.constructor = DeviceError; //If this not present then, it uses default constructor of Error |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
330 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
331 |
//constructor for DeviceError. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
332 |
function DeviceError(message,code) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
333 |
{ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
334 |
this.toString = concatenate; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
335 |
this.code = code; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
336 |
this.name = "DeviceException";//we can even overwrite default name "Error" |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
337 |
this.message=message; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
338 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
339 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
340 |
function concatenate() |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
341 |
{ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
342 |
return (this.name+":"+" "+this.message+" "+this.code); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
343 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
344 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
345 |
function splitErrorMessage(errmessage) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
346 |
{ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
347 |
if(errmessage.search(/:/)!=-1) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
348 |
{ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
349 |
if((errmessage.split(":").length)==2) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
350 |
{ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
351 |
return errmessage.split(":")[1]; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
352 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
353 |
if((errmessage.split(":").length)>2) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
354 |
{ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
355 |
return errmessage.split(":")[2]; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
356 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
357 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
358 |
return errmessage; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
359 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
360 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
361 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
362 |
var __s60_start_and_wait_cb; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
363 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
364 |
function __s60_on_app_exit(){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
365 |
widget.onshow = null; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
366 |
if(__s60_start_and_wait_cb != null){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
367 |
__s60_start_and_wait_cb(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
368 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
369 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
370 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
371 |
function __s60_on_app_start(){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
372 |
widget.onhide = null; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
373 |
widget.onshow = __s60_on_app_exit; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
374 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
375 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
376 |
// This function cannot actually force JS to wait, |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
377 |
// but it does supply a callback the apps can use |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
378 |
// to continue processing on return from the app. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
379 |
// Apps should take care not to reinvoke this and |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
380 |
// should be careful about any other processing |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
381 |
// that might happen while the app is running. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
382 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
383 |
function __s60_start_and_wait(id, args, app_exit_cb){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
384 |
__s60_start_and_wait_cb = app_exit_cb; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
385 |
widget.onhide = __s60_on_app_start; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
386 |
widget.openApplication(id, args); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
387 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
388 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
389 |
function __s60_api_not_supported(){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
390 |
throw(err_ServiceNotSupported); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
391 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
392 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
393 |
function __s60_enumerate_object(object, namespace, func, param){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
394 |
var key; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
395 |
for(key in object){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
396 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
397 |
var propname; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
398 |
if(namespace){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
399 |
propname = namespace + "." + key; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
400 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
401 |
else{ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
402 |
propname = key; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
403 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
404 |
var value = object[key]; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
405 |
if(typeof value == "object"){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
406 |
__s60_enumerate_object(value, propname, func, param); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
407 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
408 |
else { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
409 |
func(propname,value, param); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
410 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
411 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
412 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
413 |
/* |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
414 |
Copyright © 2009 Nokia. All rights reserved. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
415 |
Code licensed under the BSD License: |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
416 |
Software License Agreement (BSD License) Copyright © 2009 Nokia. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
417 |
All rights reserved. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
418 |
Redistribution and use of this software in source and binary forms, with or without modification, are permitted provided that the following conditions are met: |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
419 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
420 |
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
421 |
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
422 |
Neither the name of Nokia Corporation. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission of Nokia Corporation. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
423 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
424 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
425 |
version: 1.0 |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
426 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
427 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
428 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
429 |
var __device_debug_on__ = true; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
430 |
var err_missing_argument = 1003; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
431 |
var event_cancelled = 3; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
432 |
var err_bad_argument = 1002; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
433 |
var err_InvalidService_Argument = 1000; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
434 |
var err_ServiceNotReady = 1006; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
435 |
var err_ServiceNotSupported = 1004; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
436 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
437 |
function __device_debug(text){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
438 |
//if(__device_debug_on__) alert(text); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
439 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
440 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
441 |
function __device_handle_exception(e, text){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
442 |
__device_debug(text); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
443 |
throw(e); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
444 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
445 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
446 |
function __device_typeof(value) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
447 |
{ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
448 |
// First check to see if the value is undefined. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
449 |
if (value == undefined) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
450 |
return "undefined"; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
451 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
452 |
// Check for objects created with the "new" keyword. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
453 |
if (value instanceof Object) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
454 |
// Check whether it's a string object. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
455 |
if (value instanceof String) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
456 |
return "String"; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
457 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
458 |
// Check whether it's an array object/array literal. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
459 |
else |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
460 |
if (value instanceof Array) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
461 |
return "Array"; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
462 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
463 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
464 |
// dealing with a literal. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
465 |
if (typeof value) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
466 |
if (typeof value == "object") { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
467 |
if (typeof value == "object" && !value) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
468 |
return "null"; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
469 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
470 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
471 |
// if not null check for other types |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
472 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
473 |
// Check if it's a string literal. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
474 |
else if (typeof value == "string") { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
475 |
return "string"; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
476 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
477 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
478 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
479 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
480 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
481 |
// The top-level service object. It would be nice to use a namespace here |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
482 |
// (com.nokia.device.service), but emulating namespaces still allows name clashes. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
483 |
/* |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
484 |
var sp_device = { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
485 |
//services: null; // TBD: Make the services list a member of this object? |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
486 |
load: __device_service_load, |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
487 |
listServices: __device_service_list, |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
488 |
listInterfaces: __device_service_interfaces, |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
489 |
version: "0.1", |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
490 |
info: "device prototype" |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
491 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
492 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
493 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
494 |
if(undefined == com) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
495 |
var com={}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
496 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
497 |
if( typeof com != "object") |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
498 |
throw("com defined as non object"); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
499 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
500 |
if(undefined == com.nokia) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
501 |
com.nokia = {}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
502 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
503 |
if( typeof com.nokia != "object") |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
504 |
throw("com.nokia defined as non object"); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
505 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
506 |
if(undefined == com.nokia.device) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
507 |
com.nokia.device = { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
508 |
load: __device_service_load, |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
509 |
listServices: __device_service_list, |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
510 |
listInterfaces: __device_service_interfaces, |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
511 |
version: "0.1", |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
512 |
info: "device prototype" |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
513 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
514 |
else |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
515 |
throw("com.nokia.device already defined"); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
516 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
517 |
com.nokia.device.SORT_ASCENDING = 0; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
518 |
com.nokia.device.SORT_DESCENDING = 1; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
519 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
520 |
com.nokia.device.SORT_BY_DATE = 0; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
521 |
com.nokia.device.SORT_BY_SENDER = 1; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
522 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
523 |
com.nokia.device.STATUS_READ = 0; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
524 |
com.nokia.device.STATUS_UNREAD = 1; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
525 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
526 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
527 |
// Configure the services offered. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
528 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
529 |
var __device_services_inited = false; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
530 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
531 |
var __device_services = [ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
532 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
533 |
// For now, the only service is the base "device"" service |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
534 |
{ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
535 |
"name":"com.nokia.device", |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
536 |
"version": 0.1, |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
537 |
"interfaces": [] |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
538 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
539 |
]; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
540 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
541 |
// Initialize the configured services. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
542 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
543 |
function __device_services_init(){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
544 |
if(__device_services_inited){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
545 |
return; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
546 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
547 |
__device_services_inited = true; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
548 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
549 |
// Get the service-specific service entries. Note that these |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
550 |
// need to be individually wrapped by try/catch blocks so that the |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
551 |
// interpreter gracefully handles missing services. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
552 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
553 |
try { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
554 |
__device_services[0].interfaces.push(__device_geolocation_service_entry); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
555 |
}catch (e){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
556 |
__device_debug("Missing library implementation: " + e); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
557 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
558 |
try { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
559 |
__device_services[0].interfaces.push(__device_camera_service_entry); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
560 |
}catch (e){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
561 |
__device_debug("Missing library implementation: " + e); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
562 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
563 |
try { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
564 |
__device_services[0].interfaces.push(__device_media_service_entry); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
565 |
}catch (e){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
566 |
// __device_debug("Missing library implementation: " + e); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
567 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
568 |
try { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
569 |
__device_services[0].interfaces.push(__device_contacts_service_entry); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
570 |
}catch (e){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
571 |
// __device_debug("Missing library implementation: " + e); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
572 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
573 |
try { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
574 |
__device_services[0].interfaces.push(__device_messaging_service_entry); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
575 |
}catch (e){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
576 |
__device_debug("Missing library implementation: " + e); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
577 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
578 |
try { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
579 |
__device_services[0].interfaces.push(__device_calendar_service_entry); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
580 |
}catch (e){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
581 |
__device_debug("Missing library implementation: " + e); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
582 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
583 |
try { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
584 |
__device_services[0].interfaces.push(__device_landmarks_service_entry); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
585 |
}catch (e){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
586 |
__device_debug("Missing library implementation: " + e); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
587 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
588 |
try { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
589 |
__device_services[0].interfaces.push(__device_event_service_entry); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
590 |
}catch (e){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
591 |
__device_debug("Missing library implementation: " + e); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
592 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
593 |
try { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
594 |
__device_services[0].interfaces.push(__device_sysinfo_service_entry); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
595 |
}catch (e){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
596 |
__device_debug("Missing library implementation: " + e); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
597 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
598 |
try { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
599 |
__device_services[0].interfaces.push(__device_sensors_service_entry); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
600 |
}catch (e){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
601 |
__device_debug("Missing library implementation: " + e); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
602 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
603 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
604 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
605 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
606 |
function __device_get_implementation(i){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
607 |
//__device_debug("get_implementation: " + i); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
608 |
return new i.proto(new(i.providers[0].instance)); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
609 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
610 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
611 |
function __device_get_descriptor(i){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
612 |
//__device_debug("get_descriptor: " + i); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
613 |
return new i.descriptor(new(i.providers[0].descriptor)); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
614 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
615 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
616 |
function __device_get_interface(s, interfaceName, version){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
617 |
//__device_debug("get_interface: " + s + " " + interfaceName); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
618 |
var i = s.interfaces; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
619 |
if((interfaceName == null) || (interfaceName == '')){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
620 |
// Interface name not specified, get first interface, ignoring version |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
621 |
return __device_get_implementation(i[0]); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
622 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
623 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
624 |
// Find first match of name and version |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
625 |
for (var d in i){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
626 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
627 |
if(i[d].name == null){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
628 |
__device_update_descriptor(i[d]); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
629 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
630 |
if(i[d].name == undefined){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
631 |
continue; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
632 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
633 |
if (i[d].name == interfaceName){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
634 |
// Match version if specified |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
635 |
if ((version == null) || (version == '') || (i[d].version >= version)){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
636 |
return __device_get_implementation(i[d]); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
637 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
638 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
639 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
640 |
return null; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
641 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
642 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
643 |
// Implemention of the load method |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
644 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
645 |
function __device_service_load(serviceName, interfaceName, version){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
646 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
647 |
__device_services_init(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
648 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
649 |
// Service name is specified |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
650 |
if ((serviceName != null) && (serviceName != '') &&(serviceName != "*")){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
651 |
for(var s in __device_services){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
652 |
if (serviceName == __device_services[s].name){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
653 |
return __device_get_interface(__device_services[s], interfaceName, version); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
654 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
655 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
656 |
// Service name not specified, get first implementation |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
657 |
} else { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
658 |
//__device_debug("Trying to get interface implementations: "); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
659 |
for(var s in __device_services){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
660 |
//__device_debug("service_load: " + s + ":" + __device_services[s].name + ": " + interfaceName); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
661 |
var i = __device_get_interface(__device_services[s], interfaceName, version); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
662 |
if (i != null){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
663 |
return i; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
664 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
665 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
666 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
667 |
return null; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
668 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
669 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
670 |
// Lazily fill in the descriptor table |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
671 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
672 |
function __device_update_descriptor(i){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
673 |
var d = __device_get_descriptor(i); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
674 |
i.name = d.interfaceName; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
675 |
i.version = d.version; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
676 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
677 |
// Get an array of interface descriptors for a service |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
678 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
679 |
function __device_interface_list(s){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
680 |
var retval = new Array(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
681 |
for(var i in s.interfaces){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
682 |
if(s.interfaces[i].name == null){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
683 |
__device_update_descriptor(s.interfaces[i]); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
684 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
685 |
if(s.interfaces[i].name == undefined){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
686 |
continue; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
687 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
688 |
retval[i] = new Object(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
689 |
retval[i].name = s.interfaces[i].name; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
690 |
retval[i].version = s.interfaces[i].version; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
691 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
692 |
return retval; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
693 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
694 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
695 |
// Get a service description |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
696 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
697 |
function __device_service_descriptor(s){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
698 |
this.name = s.name; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
699 |
this.version = s.version; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
700 |
this.interfaces = __device_interface_list(s); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
701 |
this.toString = __device_service_descriptor_to_string; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
702 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
703 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
704 |
function __device_service_descriptor_to_string(){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
705 |
var is = "\nInterfaces(s): "; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
706 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
707 |
for (i in this.interfaces){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
708 |
is += "\n" + this.interfaces[i].name + " " + this.interfaces[0].version; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
709 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
710 |
return ("Service: " + this.name + is); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
711 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
712 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
713 |
// Implement the listServices method |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
714 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
715 |
function __device_service_list(serviceName, interfaceName, version){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
716 |
//__device_debug("__device_service_list: " + serviceName + " " + interfaceName); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
717 |
__device_services_init(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
718 |
var retval = new Array(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
719 |
var n = 0; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
720 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
721 |
//Treat empty service and interface names as wildcards |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
722 |
if ((serviceName == null)|| (serviceName == '')/* || (serviceName == undefined)*/){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
723 |
serviceName = ".*"; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
724 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
725 |
if ((interfaceName == null) || (interfaceName == '') /*|| (serviceName == undefined)*/){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
726 |
interfaceName = ".*"; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
727 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
728 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
729 |
if ((typeof serviceName != "string") || (typeof interfaceName != "string")) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
730 |
return retval; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
731 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
732 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
733 |
// This method does regular expression matching of service and interface |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
734 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
735 |
var sregx = new RegExp(serviceName); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
736 |
var iregx = new RegExp(interfaceName); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
737 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
738 |
for(var s in __device_services){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
739 |
//__device_debug (serviceName + "==" + __device_services[s].name + "?:" + sregx.test(__device_services[s].name)); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
740 |
if (sregx.test(__device_services[s].name)){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
741 |
// Find the first matching interface |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
742 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
743 |
for(var i in __device_services[s].interfaces){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
744 |
if(__device_services[s].interfaces[i].name == null){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
745 |
__device_update_descriptor(__device_services[s].interfaces[i]); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
746 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
747 |
if(__device_services[s].interfaces[i].name == undefined){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
748 |
continue; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
749 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
750 |
//__device_debug (interfaceName + "==" + __device_services[s].interfaces[i].name + "?:" + iregx.test(__device_services[s].interfaces[i].name)); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
751 |
if (iregx.test(__device_services[s].interfaces[i].name)){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
752 |
if ((version == null) || (version == '') || (__device_services[s].interfaces[i].version >= version)){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
753 |
// An interface matched, we're done. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
754 |
retval[n] = new __device_service_descriptor(__device_services[s]); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
755 |
break; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
756 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
757 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
758 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
759 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
760 |
++n; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
761 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
762 |
return retval; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
763 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
764 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
765 |
// Implement the listInterfaces method |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
766 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
767 |
function __device_service_interfaces(serviceName){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
768 |
__device_services_init(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
769 |
if(serviceName==null||serviceName==undefined||serviceName==''){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
770 |
throw new DeviceError("Framework: listInterfaces: serviceName is missing", err_missing_argument); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
771 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
772 |
for (var s in __device_services){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
773 |
if(__device_services[s].name == serviceName){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
774 |
return __device_interface_list(__device_services[s]); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
775 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
776 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
777 |
return null; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
778 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
779 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
780 |
function modifyObjectBaseProp(obj){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
781 |
for (pro in obj) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
782 |
if(typeof obj[pro] == "function" ) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
783 |
obj[pro] = 0; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
784 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
785 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
786 |
/* |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
787 |
Copyright © 2009 Nokia. All rights reserved. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
788 |
Code licensed under the BSD License: |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
789 |
Software License Agreement (BSD License) Copyright © 2009 Nokia. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
790 |
All rights reserved. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
791 |
Redistribution and use of this software in source and binary forms, with or without modification, are permitted provided that the following conditions are met: |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
792 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
793 |
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
794 |
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
795 |
Neither the name of Nokia Corporation. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission of Nokia Corporation. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
796 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
797 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
798 |
version: 1.0 |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
799 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
800 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
801 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
802 |
// S60 sp-based camera provider |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
803 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
804 |
function __sp_camera_descriptor(){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
805 |
//__device_debug("sp_camera_descriptor"); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
806 |
//Read-only properties |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
807 |
this.interfaceName = "com.nokia.device.camera"; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
808 |
this.version = "0.1"; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
809 |
//Class-static properties |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
810 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
811 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
812 |
// TBD make local to closure funcs |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
813 |
var __sp_camera_start_date; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
814 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
815 |
function __sp_camera_instance(){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
816 |
//__device_debug("sp_camera_instance"); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
817 |
//Descriptor |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
818 |
this.descriptor = new __sp_camera_descriptor(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
819 |
//Core methods |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
820 |
this.startCamera = __sp_startCamera; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
821 |
this.stopViewfinder = __s60_api_not_supported; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
822 |
//Extended methods |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
823 |
this.takePicture = __s60_api_not_supported; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
824 |
//Private data |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
825 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
826 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
827 |
var CAMERA_APP_ID = 0x101f857a; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
828 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
829 |
//Apps should take care that this is not reinvoked |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
830 |
//while the viewfinder is running. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
831 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
832 |
function __sp_startCamera(camera_cb){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
833 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
834 |
//If callback is null , then return missing argument error |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
835 |
if( camera_cb == null ) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
836 |
throw new DeviceError("Camera:startCamera:callback is missing", err_missing_argument); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
837 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
838 |
//If the callback is not a function, then return bad type error |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
839 |
if( typeof(camera_cb) != "function" ) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
840 |
throw new DeviceError("Camera:startCamera:callback is a non-function", err_bad_argument); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
841 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
842 |
var finished = function (){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
843 |
var invoker = function (arg1, arg2, arg3){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
844 |
//__device_debug("invoker with: " + camera_cb); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
845 |
var it = arg3.ReturnValue; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
846 |
var item; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
847 |
var items = new Array(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
848 |
while (( item = it.getNext()) != undefined){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
849 |
var d = new Date(Date.parse(item.FileDate)); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
850 |
//__device_debug(item.FileName + " " + d ); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
851 |
// Items returned in reverse date order, so stop iterating before |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
852 |
// reaching initial date. (Should be able to do this more efficiently |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
853 |
// with sp filter, but that doesn't seem to work right now.) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
854 |
if (d > __sp_camera_start_date) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
855 |
var pathname = item.FileNameAndPath.replace(/\\/g, "/"); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
856 |
var fileScheme = "file:///"; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
857 |
//Non-patched builds don't allow file scheme TBD: change this for patched builds |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
858 |
items.unshift(fileScheme + pathname); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
859 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
860 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
861 |
var dummyTransID = 0; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
862 |
var dummyStatusCode = 0; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
863 |
camera_cb(dummyTransID, dummyStatusCode, items); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
864 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
865 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
866 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
867 |
//When camera returns, get the image(s) created |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
868 |
try { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
869 |
var mso = device.getServiceObject("Service.MediaManagement", "IDataSource"); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
870 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
871 |
catch(e) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
872 |
__device_handle_exception (e, "media service not available : " + e); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
873 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
874 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
875 |
var criteria = new Object(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
876 |
modifyObjectBaseProp(criteria); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
877 |
criteria.Type = 'FileInfo'; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
878 |
criteria.Filter = new Object(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
879 |
modifyObjectBaseProp(criteria.Filter); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
880 |
criteria.Filter.FileType = 'Image'; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
881 |
//criteria.Filter.Key = 'FileDate'; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
882 |
//criteria.Filter.StartRange = null; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
883 |
//criteria.Filter.EndRange = null; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
884 |
criteria.Sort = new Object(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
885 |
modifyObjectBaseProp(criteria.Sort); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
886 |
criteria.Sort.Key = 'FileDate'; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
887 |
criteria.Sort.Order = 'Descending'; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
888 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
889 |
try { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
890 |
var rval = mso.IDataSource.GetList(criteria, invoker); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
891 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
892 |
catch (e) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
893 |
__device_handle_exception (e, "media service GetList failed: " + e); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
894 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
895 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
896 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
897 |
__sp_camera_start_date = new Date(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
898 |
__s60_start_and_wait(CAMERA_APP_ID, "", finished); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
899 |
var dummyTid = 0; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
900 |
return dummyTid; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
901 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
902 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
903 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
904 |
/* |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
905 |
Copyright © 2009 Nokia. All rights reserved. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
906 |
Code licensed under the BSD License: |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
907 |
Software License Agreement (BSD License) Copyright © 2009 Nokia. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
908 |
All rights reserved. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
909 |
Redistribution and use of this software in source and binary forms, with or without modification, are permitted provided that the following conditions are met: |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
910 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
911 |
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
912 |
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
913 |
Neither the name of Nokia Corporation. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission of Nokia Corporation. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
914 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
915 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
916 |
version: 1.0 |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
917 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
918 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
919 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
920 |
// Camera service interface |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
921 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
922 |
var __device_camera_service_entry = {"name": null, |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
923 |
"version": null, |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
924 |
"proto": __device_camera, |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
925 |
"descriptor": __device_camera_descriptor, |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
926 |
"providers": [{"descriptor": __sp_camera_descriptor, "instance": __sp_camera_instance}] |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
927 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
928 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
929 |
function __device_camera_descriptor(provider){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
930 |
this.interfaceName = provider.interfaceName; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
931 |
this.version = provider.version; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
932 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
933 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
934 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
935 |
// Private camera prototype: called from service factory |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
936 |
function __device_camera(provider){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
937 |
//Private properties |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
938 |
this.provider = provider; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
939 |
//Read-only properties |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
940 |
this.interfaceName = provider.descriptor.interfaceName; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
941 |
this.version = provider.descriptor.version; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
942 |
// this.supportedMediaTypes = provider.supportedMediaTypes; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
943 |
// this.supportedSizes = provider.supportedSizes; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
944 |
//Core methods |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
945 |
this.startCamera = __device_camera_startCamera; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
946 |
this.stopViewfinder = __device_camera_stopViewfinder; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
947 |
//Extended methods |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
948 |
this.takePicture = __device_camera_takePicture; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
949 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
950 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
951 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
952 |
//Why bother to define these methods? Because the camera |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
953 |
//object defines the contract for providers! |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
954 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
955 |
function __device_camera_startCamera(camera_cb){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
956 |
return this.provider.startCamera(camera_cb); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
957 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
958 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
959 |
function __device_camera_stopViewfinder(){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
960 |
this.provider.stopViewfinder(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
961 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
962 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
963 |
function __device_camera_takePicture(format){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
964 |
this.provider.takePicture(format); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
965 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
966 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
967 |
* This class provides access to the device contacts. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
968 |
* @constructor |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
969 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
970 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
971 |
function Contacts() { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
972 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
973 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
974 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
975 |
function Contact() { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
976 |
this.id = null; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
977 |
this.name = { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
978 |
formatted: "", |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
979 |
givenName: "", |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
980 |
familyName: "" |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
981 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
982 |
this.phones = []; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
983 |
this.emails = []; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
984 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
985 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
986 |
Contact.prototype.displayName = function() |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
987 |
{ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
988 |
// TODO: can be tuned according to prefs |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
989 |
return this.givenName + " " + this.familyName; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
990 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
991 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
992 |
/* |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
993 |
* @param {ContactsFilter} filter Object with filter properties. filter.name only for now. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
994 |
* @param {function} successCallback Callback function on success |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
995 |
* @param {function} errorCallback Callback function on failure |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
996 |
* @param {object} options Object with properties .page and .limit for paging |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
997 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
998 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
999 |
Contacts.prototype.find = function(filter, successCallback, errorCallback, options) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1000 |
try { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1001 |
this.contactsService = device.getServiceObject("Service.Contact", "IDataSource"); |
340
740921999de7
Bug 2784 - Update bundled PhoneGap libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
321
diff
changeset
|
1002 |
if (typeof options == 'object') |
740921999de7
Bug 2784 - Update bundled PhoneGap libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
321
diff
changeset
|
1003 |
this.options = options; |
740921999de7
Bug 2784 - Update bundled PhoneGap libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
321
diff
changeset
|
1004 |
else |
740921999de7
Bug 2784 - Update bundled PhoneGap libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
321
diff
changeset
|
1005 |
this.options = {}; |
310
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1006 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1007 |
var criteria = new Object(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1008 |
criteria.Type = "Contact"; |
340
740921999de7
Bug 2784 - Update bundled PhoneGap libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
321
diff
changeset
|
1009 |
if (filter && filter.name) { |
740921999de7
Bug 2784 - Update bundled PhoneGap libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
321
diff
changeset
|
1010 |
var searchTerm = ''; |
740921999de7
Bug 2784 - Update bundled PhoneGap libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
321
diff
changeset
|
1011 |
if (filter.name.givenName && filter.name.givenName.length > 0) { |
740921999de7
Bug 2784 - Update bundled PhoneGap libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
321
diff
changeset
|
1012 |
searchTerm += filter.name.givenName; |
740921999de7
Bug 2784 - Update bundled PhoneGap libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
321
diff
changeset
|
1013 |
} |
740921999de7
Bug 2784 - Update bundled PhoneGap libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
321
diff
changeset
|
1014 |
if (filter.name.familyName && filter.name.familyName.length > 0) { |
740921999de7
Bug 2784 - Update bundled PhoneGap libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
321
diff
changeset
|
1015 |
searchTerm += searchTerm.length > 0 ? ' ' + filter.name.familyName : filter.name.familyName; |
740921999de7
Bug 2784 - Update bundled PhoneGap libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
321
diff
changeset
|
1016 |
} |
740921999de7
Bug 2784 - Update bundled PhoneGap libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
321
diff
changeset
|
1017 |
if (!filter.name.familyName && !filter.name.givenName && filter.name.formatted) { |
740921999de7
Bug 2784 - Update bundled PhoneGap libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
321
diff
changeset
|
1018 |
searchTerm = filter.name.formatted; |
740921999de7
Bug 2784 - Update bundled PhoneGap libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
321
diff
changeset
|
1019 |
} |
740921999de7
Bug 2784 - Update bundled PhoneGap libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
321
diff
changeset
|
1020 |
criteria.Filter = { SearchVal: searchTerm }; |
740921999de7
Bug 2784 - Update bundled PhoneGap libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
321
diff
changeset
|
1021 |
} |
310
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1022 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1023 |
if (typeof(successCallback) != 'function') |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1024 |
successCallback = function(){}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1025 |
if (typeof(errorCallback) != 'function') |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1026 |
errorCallback = function(){}; |
340
740921999de7
Bug 2784 - Update bundled PhoneGap libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
321
diff
changeset
|
1027 |
if (isNaN(this.options.limit)) |
740921999de7
Bug 2784 - Update bundled PhoneGap libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
321
diff
changeset
|
1028 |
this.options.limit = 200; |
740921999de7
Bug 2784 - Update bundled PhoneGap libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
321
diff
changeset
|
1029 |
if (isNaN(this.options.page)) |
740921999de7
Bug 2784 - Update bundled PhoneGap libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
321
diff
changeset
|
1030 |
this.options.page = 1; |
310
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1031 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1032 |
//need a closure here to bind this method to this instance of the Contacts object |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1033 |
this.global_success = successCallback; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1034 |
var obj = this; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1035 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1036 |
//WRT: result.ReturnValue is an iterator of contacts |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1037 |
this.contactsService.IDataSource.GetList(criteria, function(transId, eventCode, result){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1038 |
obj.success_callback(result.ReturnValue); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1039 |
}); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1040 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1041 |
catch (ex) { |
340
740921999de7
Bug 2784 - Update bundled PhoneGap libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
321
diff
changeset
|
1042 |
alert(ex.name + ": " + ex.message); |
310
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1043 |
errorCallback(ex); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1044 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1045 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1046 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1047 |
Contacts.prototype.success_callback = function(contacts_iterator) { |
340
740921999de7
Bug 2784 - Update bundled PhoneGap libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
321
diff
changeset
|
1048 |
try { |
310
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1049 |
var gapContacts = new Array(); |
442
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1050 |
if (contacts_iterator) { |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1051 |
contacts_iterator.reset(); |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1052 |
var contact; |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1053 |
var i = 0; |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1054 |
var end = this.options.page * this.options.limit; |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1055 |
var start = end - this.options.limit; |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1056 |
while ((contact = contacts_iterator.getNext()) != undefined && i < end) { |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1057 |
try { |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1058 |
if (i >= start) { |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1059 |
var gapContact = new Contact(); |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1060 |
gapContact.name.givenName = Contacts.GetValue(contact, "FirstName"); |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1061 |
gapContact.name.familyName = Contacts.GetValue(contact, "LastName"); |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1062 |
gapContact.name.formatted = gapContact.name.givenName + " " + gapContact.name.familyName; |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1063 |
gapContact.emails = Contacts.getEmailsList(contact); |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1064 |
gapContact.phones = Contacts.getPhonesList(contact); |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1065 |
gapContact.address = Contacts.getAddress(contact); |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1066 |
gapContact.id = Contacts.GetValue(contact, "id"); |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1067 |
gapContacts.push(gapContact); |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1068 |
} |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1069 |
i++; |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1070 |
} catch (e) { |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1071 |
alert("ContactsError (" + e.name + ": " + e.message + ")"); |
310
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1072 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1073 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1074 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1075 |
this.contacts = gapContacts; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1076 |
this.global_success(gapContacts); |
340
740921999de7
Bug 2784 - Update bundled PhoneGap libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
321
diff
changeset
|
1077 |
} catch (ex) { alert(ex.name + ": " + ex.message); } |
310
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1078 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1079 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1080 |
Contacts.getEmailsList = function(contact) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1081 |
var emails = new Array(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1082 |
try { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1083 |
emails[0] = { type:"General", address: Contacts.GetValue(contact, "EmailGen") }; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1084 |
emails[1] = { type:"Work", address: Contacts.GetValue(contact, "EmailWork") }; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1085 |
emails[2] = { type:"Home", address: Contacts.GetValue(contact, "EmailHome") }; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1086 |
} catch (e) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1087 |
emails = []; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1088 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1089 |
return emails; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1090 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1091 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1092 |
Contacts.getPhonesList = function(contact) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1093 |
var phones = new Array(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1094 |
try { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1095 |
phones[0] = { type:"Mobile", number: Contacts.GetValue(contact, "MobilePhoneGen") }; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1096 |
phones[1] = { type:"Home", number: Contacts.GetValue(contact, "LandPhoneGen") }; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1097 |
phones[2] = { type:"Fax", number: Contacts.GetValue(contact, "FaxNumberGen") }; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1098 |
phones[3] = { type:"Work", number: Contacts.GetValue(contact, "LandPhoneWork") }; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1099 |
phones[4] = { type:"WorkMobile", number: Contacts.GetValue(contact, "MobilePhoneWork") }; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1100 |
} catch (e) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1101 |
phones = []; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1102 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1103 |
return phones; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1104 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1105 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1106 |
Contacts.getAddress = function(contact) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1107 |
var address = ""; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1108 |
try { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1109 |
address = Contacts.GetValue(contact, "AddrLabelHome") + ", " + Contacts.GetValue(contact, "AddrStreetHome") + ", " + |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1110 |
Contacts.GetValue(contact, "AddrLocalHome") + ", " + Contacts.GetValue(contact, "AddrRegionHome") + ", " + |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1111 |
Contacts.GetValue(contact, "AddrPostCodeHome") + ", " + Contacts.GetValue(contact, "AddrCountryHome"); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1112 |
} catch (e) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1113 |
address = ""; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1114 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1115 |
return address; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1116 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1117 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1118 |
Contacts.GetValue = function(contactObj, key) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1119 |
try { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1120 |
return contactObj[key]["Value"]; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1121 |
} catch (e) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1122 |
return ""; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1123 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1124 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1125 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1126 |
if (typeof navigator.contacts == "undefined") navigator.contacts = new Contacts(); |
321
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1127 |
/** |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1128 |
* This class provides access to the debugging console. |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1129 |
* @constructor |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1130 |
*/ |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1131 |
function DebugConsole() { |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1132 |
} |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1133 |
|
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1134 |
/** |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1135 |
* Print a normal log message to the console |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1136 |
* @param {Object|String} message Message or object to print to the console |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1137 |
*/ |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1138 |
DebugConsole.prototype.log = function(message) { |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1139 |
|
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1140 |
//This ends up in C:\jslog_widget.log on the device |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1141 |
console.log(message); |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1142 |
}; |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1143 |
|
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1144 |
/** |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1145 |
* Print a warning message to the console |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1146 |
* @param {Object|String} message Message or object to print to the console |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1147 |
*/ |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1148 |
DebugConsole.prototype.warn = function(message) { |
442
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1149 |
console.log(message); |
321
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1150 |
}; |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1151 |
|
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1152 |
/** |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1153 |
* Print an error message to the console |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1154 |
* @param {Object|String} message Message or object to print to the console |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1155 |
*/ |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1156 |
DebugConsole.prototype.error = function(message) { |
442
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1157 |
console.log(message); |
321
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1158 |
}; |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1159 |
|
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1160 |
if (typeof window.debug == "undefined") window.debug = new DebugConsole(); |
310
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1161 |
PhoneGap.ExtendWrtDeviceObj = function(){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1162 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1163 |
if (!window.device) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1164 |
window.device = {}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1165 |
navigator.device = window.device; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1166 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1167 |
try { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1168 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1169 |
if (window.menu) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1170 |
window.menu.hideSoftkeys(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1171 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1172 |
device.available = PhoneGap.available; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1173 |
device.platform = null; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1174 |
device.version = null; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1175 |
device.name = null; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1176 |
device.uuid = null; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1177 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1178 |
var so = device.getServiceObject("Service.SysInfo", "ISysInfo"); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1179 |
var pf = PhoneGap.GetWrtPlatformVersion(so); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1180 |
device.platform = pf.platform; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1181 |
device.version = pf.version; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1182 |
device.uuid = PhoneGap.GetWrtDeviceProperty(so, "IMEI"); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1183 |
device.name = PhoneGap.GetWrtDeviceProperty(so, "PhoneModel"); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1184 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1185 |
catch (e) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1186 |
device.available = false; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1187 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1188 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1189 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1190 |
PhoneGap.GetWrtDeviceProperty = function(serviceObj, key) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1191 |
var criteria = { "Entity": "Device", "Key": key }; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1192 |
var result = serviceObj.ISysInfo.GetInfo(criteria); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1193 |
if (result.ErrorCode == 0) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1194 |
return result.ReturnValue.StringData; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1195 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1196 |
else { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1197 |
return null; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1198 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1199 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1200 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1201 |
PhoneGap.GetWrtPlatformVersion = function(serviceObj) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1202 |
var criteria = { "Entity": "Device", "Key": "PlatformVersion" }; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1203 |
var result = serviceObj.ISysInfo.GetInfo(criteria); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1204 |
if (result.ErrorCode == 0) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1205 |
var version = {}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1206 |
version.platform = result.ReturnValue.MajorVersion; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1207 |
version.version = result.ReturnValue.MinorVersion; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1208 |
return version; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1209 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1210 |
else { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1211 |
return null; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1212 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1213 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1214 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1215 |
PhoneGap.ExtendWrtDeviceObj();/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1216 |
* This class provides access to device GPS data. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1217 |
* @constructor |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1218 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1219 |
function Geolocation() { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1220 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1221 |
* The last known GPS position. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1222 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1223 |
this.lastPosition = null; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1224 |
this.lastError = null; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1225 |
this.callbacks = { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1226 |
onLocationChanged: [], |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1227 |
onError: [] |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1228 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1229 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1230 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1231 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1232 |
* Asynchronously aquires the current position. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1233 |
* @param {Function} successCallback The function to call when the position |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1234 |
* data is available |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1235 |
* @param {Function} errorCallback The function to call when there is an error |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1236 |
* getting the position data. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1237 |
* @param {PositionOptions} options The options for getting the position data |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1238 |
* such as timeout. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1239 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1240 |
Geolocation.prototype.getCurrentPosition = function(successCallback, errorCallback, options) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1241 |
var referenceTime = 0; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1242 |
if (this.lastPosition) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1243 |
referenceTime = this.lastPosition.timestamp; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1244 |
else |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1245 |
this.start(options); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1246 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1247 |
var timeout = 20000; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1248 |
var interval = 500; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1249 |
if (typeof(options) == 'object' && options.interval) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1250 |
interval = options.interval; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1251 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1252 |
if (typeof(successCallback) != 'function') |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1253 |
successCallback = function() {}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1254 |
if (typeof(errorCallback) != 'function') |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1255 |
errorCallback = function() {}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1256 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1257 |
var dis = this; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1258 |
var delay = 0; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1259 |
var timer = setInterval(function() { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1260 |
delay += interval; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1261 |
//if we have a new position, call success and cancel the timer |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1262 |
if (dis.lastPosition && dis.lastPosition.timestamp > referenceTime) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1263 |
successCallback(dis.lastPosition); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1264 |
clearInterval(timer); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1265 |
} else if (delay >= timeout) { //else if timeout has occured then call error and cancel the timer |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1266 |
errorCallback(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1267 |
clearInterval(timer); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1268 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1269 |
//else the interval gets called again |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1270 |
}, interval); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1271 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1272 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1273 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1274 |
* Asynchronously aquires the position repeatedly at a given interval. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1275 |
* @param {Function} successCallback The function to call each time the position |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1276 |
* data is available |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1277 |
* @param {Function} errorCallback The function to call when there is an error |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1278 |
* getting the position data. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1279 |
* @param {PositionOptions} options The options for getting the position data |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1280 |
* such as timeout and the frequency of the watch. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1281 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1282 |
Geolocation.prototype.watchPosition = function(successCallback, errorCallback, options) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1283 |
// Invoke the appropriate callback with a new Position object every time the implementation |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1284 |
// determines that the position of the hosting device has changed. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1285 |
this.getCurrentPosition(successCallback, errorCallback, options); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1286 |
var frequency = 10000; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1287 |
if (typeof options == 'object' && options.frequency) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1288 |
frequency = options.frequency; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1289 |
var that = this; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1290 |
return setInterval(function() { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1291 |
that.getCurrentPosition(successCallback, errorCallback, options); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1292 |
}, frequency); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1293 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1294 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1295 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1296 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1297 |
* Clears the specified position watch. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1298 |
* @param {String} watchId The ID of the watch returned from #watchPosition. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1299 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1300 |
Geolocation.prototype.clearWatch = function(watchId) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1301 |
clearInterval(watchId); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1302 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1303 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1304 |
Geolocation.prototype.start = function(options) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1305 |
var so = device.getServiceObject("Service.Location", "ILocation"); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1306 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1307 |
//construct the criteria for our location request |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1308 |
var updateOptions = new Object(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1309 |
// Specify that location information need not be guaranteed. This helps in |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1310 |
// that the widget doesn't need to wait for that information possibly indefinitely. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1311 |
updateOptions.PartialUpdates = true; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1312 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1313 |
//default 15 seconds |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1314 |
if (typeof(options) == 'object' && options.timeout) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1315 |
//options.timeout in in ms, updateOptions.UpdateTimeout in microsecs |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1316 |
updateOptions.UpdateTimeOut = options.timeout * 1000; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1317 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1318 |
//default 1 second |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1319 |
if (typeof(options) == 'object' && options.interval) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1320 |
//options.timeout in in ms, updateOptions.UpdateTimeout in microsecs |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1321 |
updateOptions.UpdateInterval = options.interval * 1000; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1322 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1323 |
// Initialize the criteria for the GetLocation call |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1324 |
var trackCriteria = new Object(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1325 |
// could use "BasicLocationInformation" or "GenericLocationInfo" |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1326 |
trackCriteria.LocationInformationClass = "GenericLocationInfo"; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1327 |
trackCriteria.Updateoptions = updateOptions; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1328 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1329 |
var dis = this; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1330 |
so.ILocation.Trace(trackCriteria, function(transId, eventCode, result) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1331 |
var retVal = result.ReturnValue; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1332 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1333 |
if (result.ErrorCode != 0 || isNaN(retVal.Latitude)) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1334 |
return; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1335 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1336 |
// heading options: retVal.TrueCourse, retVal.MagneticHeading, retVal.Heading, retVal.MagneticCourse |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1337 |
// but retVal.Heading was the only field being returned with data on the test device (Nokia 5800) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1338 |
// WRT does not provide accuracy |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1339 |
var newCoords = new Coordinates(retVal.Latitude, retVal.Longitude, retVal.Altitude, null, retVal.Heading, retVal.HorizontalSpeed); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1340 |
var positionObj = { coords: newCoords, timestamp: (new Date()).getTime() }; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1341 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1342 |
dis.lastPosition = positionObj; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1343 |
}); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1344 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1345 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1346 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1347 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1348 |
if (typeof navigator.geolocation == "undefined") navigator.geolocation = new Geolocation(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1349 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1350 |
/** |
321
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1351 |
* This class provides access to native mapping applications on the device. |
310
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1352 |
*/ |
321
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1353 |
function Map() { |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1354 |
|
310
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1355 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1356 |
|
321
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1357 |
/** |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1358 |
* Shows a native map on the device with pins at the given positions. |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1359 |
* @param {Array} positions |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1360 |
*/ |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1361 |
Map.prototype.show = function(positions) { |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1362 |
|
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1363 |
var err = "map api is unimplemented on symbian.wrt"; |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1364 |
debug.log(err); |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1365 |
return { name: "MapError", message: err }; |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1366 |
|
310
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1367 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1368 |
|
321
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1369 |
if (typeof navigator.map == "undefined") navigator.map = new Map(); |
442
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1370 |
function Network() { |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1371 |
/** |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1372 |
* The last known Network status. |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1373 |
*/ |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1374 |
this.lastReachability = null; |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1375 |
}; |
310
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1376 |
|
442
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1377 |
Network.prototype.isReachable = function(hostName, successCallback, options) { |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1378 |
var req = new XMLHttpRequest(); |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1379 |
req.open('GET', hostName, true); |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1380 |
req.onreadystatechange = function (aEvt) { |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1381 |
if (req.readyState == 4) { |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1382 |
if(req.status == 200) |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1383 |
successCallback(NetworkStatus.REACHABLE_VIA_CARRIER_DATA_NETWORK); |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1384 |
else |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1385 |
successCallback(NetworkStatus.NOT_REACHABLE); |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1386 |
} |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1387 |
}; |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1388 |
req.send(null); |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1389 |
|
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1390 |
}; |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1391 |
|
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1392 |
/** |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1393 |
* This class contains information about any NetworkStatus. |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1394 |
* @constructor |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1395 |
*/ |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1396 |
function NetworkStatus() { |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1397 |
this.code = null; |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1398 |
this.message = ""; |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1399 |
} |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1400 |
|
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1401 |
NetworkStatus.NOT_REACHABLE = 0; |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1402 |
NetworkStatus.REACHABLE_VIA_CARRIER_DATA_NETWORK = 1; |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1403 |
NetworkStatus.REACHABLE_VIA_WIFI_NETWORK = 2; |
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1404 |
|
980aaebb8022
Bug 3192 - phonegap wizard: Contacts filter does not seem to work
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
340
diff
changeset
|
1405 |
if (typeof navigator.network == "undefined") navigator.network = new Network(); |
310
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1406 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1407 |
* This class provides access to notifications on the device. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1408 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1409 |
function Notification() { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1410 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1411 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1412 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1413 |
Notification.prototype.vibrate = function(mills) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1414 |
{ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1415 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1416 |
if (!Notification.getSysinfoObject()) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1417 |
Notification.embedSysinfoObject(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1418 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1419 |
this.sysinfo = Notification.getSysinfoObject(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1420 |
this.sysinfo.startvibra(mills, 100); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1421 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1422 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1423 |
//TODO: this is not beeping |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1424 |
Notification.prototype.beep = function(count, volume) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1425 |
{ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1426 |
if (!Notification.getSysinfoObject()) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1427 |
Notification.embedSysinfoObject(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1428 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1429 |
this.sysinfo = Notification.getSysinfoObject(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1430 |
this.sysinfo.beep(220,2000); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1431 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1432 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1433 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1434 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1435 |
* Open a native alert dialog, with a customizable title and button text. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1436 |
* @param {String} message Message to print in the body of the alert |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1437 |
* @param {String} [title="Alert"] Title of the alert dialog (default: Alert) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1438 |
* @param {String} [buttonLabel="OK"] Label of the close button (default: OK) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1439 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1440 |
Notification.prototype.alert = function(message, title, buttonLabel) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1441 |
// Default is to use a browser alert; this will use "index.html" as the title though |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1442 |
alert(message); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1443 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1444 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1445 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1446 |
* Start spinning the activity indicator on the statusbar |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1447 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1448 |
Notification.prototype.activityStart = function() { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1449 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1450 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1451 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1452 |
* Stop spinning the activity indicator on the statusbar, if it's currently spinning |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1453 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1454 |
Notification.prototype.activityStop = function() { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1455 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1456 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1457 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1458 |
* Causes the device to blink a status LED. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1459 |
* @param {Integer} count The number of blinks. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1460 |
* @param {String} colour The colour of the light. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1461 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1462 |
Notification.prototype.blink = function(count, colour) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1463 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1464 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1465 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1466 |
Notification.embedSysinfoObject = function() { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1467 |
var el = document.createElement("embed"); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1468 |
el.setAttribute("type", "application/x-systeminfo-widget"); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1469 |
el.setAttribute("hidden", "yes"); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1470 |
document.getElementsByTagName("body")[0].appendChild(el); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1471 |
return; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1472 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1473 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1474 |
Notification.getSysinfoObject = function() { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1475 |
return document.embeds[0]; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1476 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1477 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1478 |
if (typeof navigator.notification == "undefined") navigator.notification = new Notification(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1479 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1480 |
* This class provides access to the device orientation. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1481 |
* @constructor |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1482 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1483 |
function Orientation() { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1484 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1485 |
* The current orientation, or null if the orientation hasn't changed yet. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1486 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1487 |
this.currentOrientation = null; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1488 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1489 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1490 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1491 |
* Set the current orientation of the phone. This is called from the device automatically. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1492 |
* |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1493 |
* When the orientation is changed, the DOMEvent \c orientationChanged is dispatched against |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1494 |
* the document element. The event has the property \c orientation which can be used to retrieve |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1495 |
* the device's current orientation, in addition to the \c Orientation.currentOrientation class property. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1496 |
* |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1497 |
* @param {Number} orientation The orientation to be set |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1498 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1499 |
Orientation.prototype.setOrientation = function(orientation) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1500 |
if (orientation == this.currentOrientation) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1501 |
return; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1502 |
var old = this.currentOrientation; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1503 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1504 |
this.currentOrientation = orientation; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1505 |
var e = document.createEvent('Events'); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1506 |
e.initEvent('orientationChanged', 'false', 'false'); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1507 |
e.orientation = orientation; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1508 |
e.oldOrientation = old; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1509 |
document.dispatchEvent(e); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1510 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1511 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1512 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1513 |
* Asynchronously aquires the current orientation. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1514 |
* @param {Function} successCallback The function to call when the orientation |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1515 |
* is known. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1516 |
* @param {Function} errorCallback The function to call when there is an error |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1517 |
* getting the orientation. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1518 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1519 |
Orientation.prototype.getCurrentOrientation = function(successCallback, errorCallback) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1520 |
// If the orientation is available then call success |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1521 |
// If the orientation is not available then call error |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1522 |
try { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1523 |
if (!this.serviceObj) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1524 |
this.serviceObj = this.getServiceObj(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1525 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1526 |
if (this.serviceObj == null) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1527 |
errorCallback({ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1528 |
name: "DeviceErr", |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1529 |
message: "Could not initialize service object" |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1530 |
}); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1531 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1532 |
//get the sensor channel |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1533 |
var SensorParams = { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1534 |
SearchCriterion: "Orientation" |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1535 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1536 |
var returnvalue = this.serviceObj.ISensor.FindSensorChannel(SensorParams); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1537 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1538 |
var error = returnvalue["ErrorCode"]; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1539 |
var errmsg = returnvalue["ErrorMessage"]; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1540 |
if (!(error == 0 || error == 1012)) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1541 |
var ex = { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1542 |
name: "Unable to find Sensor Channel: " + error, |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1543 |
message: errmsg |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1544 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1545 |
errorCallback(ex); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1546 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1547 |
var channelInfoMap = returnvalue["ReturnValue"][0]; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1548 |
var criteria = { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1549 |
ChannelInfoMap: channelInfoMap, |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1550 |
ListeningType: "ChannelData" |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1551 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1552 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1553 |
if (typeof(successCallback) != 'function') |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1554 |
successCallback = function(){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1555 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1556 |
if (typeof(errorCallback) != 'function') |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1557 |
errorCallback = function(){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1558 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1559 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1560 |
this.success_callback = successCallback; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1561 |
this.error_callback = errorCallback; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1562 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1563 |
//create a closure to persist this instance of orientation object into the RegisterForNofication callback |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1564 |
var obj = this; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1565 |
|
321
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1566 |
// TODO: this call crashes WRT, but there is no other way to read the orientation sensor |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1567 |
// http://discussion.forum.nokia.com/forum/showthread.php?t=182151&highlight=memory+leak |
310
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1568 |
this.serviceObj.ISensor.RegisterForNotification(criteria, function(transId, eventCode, result){ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1569 |
var criteria = { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1570 |
TransactionID: transId |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1571 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1572 |
try { |
321
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1573 |
//var orientation = result.ReturnValue.DeviceOrientation; |
310
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1574 |
obj.serviceObj.ISensor.Cancel(criteria); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1575 |
|
321
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1576 |
var orientation = null; |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1577 |
switch (result.ReturnValue.DeviceOrientation) { |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1578 |
case "DisplayUpwards": orientation = DisplayOrientation.FACE_UP; break; |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1579 |
case "DisplayDownwards": orientation = DisplayOrientation.FACE_DOWN; break; |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1580 |
case "DisplayUp": orientation = DisplayOrientation.PORTRAIT; break; |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1581 |
case "DisplayDown": orientation = DisplayOrientation.REVERSE_PORTRAIT; break; |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1582 |
case "DisplayRightUp": orientation = DisplayOrientation.LANDSCAPE_RIGHT_UP; break; |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1583 |
case "DisplayLeftUp": orientation = DisplayOrientation.LANDSCAPE_LEFT_UP; break; |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1584 |
|
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1585 |
} |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1586 |
|
310
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1587 |
obj.setOrientation(orientation); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1588 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1589 |
obj.success_callback(orientation); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1590 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1591 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1592 |
catch (ex) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1593 |
obj.serviceObj.ISensor.Cancel(criteria); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1594 |
obj.error_callback(ex); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1595 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1596 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1597 |
}); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1598 |
} catch (ex) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1599 |
errorCallback({ name: "OrientationError", message: ex.name + ": " + ex.message }); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1600 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1601 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1602 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1603 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1604 |
* Asynchronously aquires the orientation repeatedly at a given interval. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1605 |
* @param {Function} successCallback The function to call each time the orientation |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1606 |
* data is available. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1607 |
* @param {Function} errorCallback The function to call when there is an error |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1608 |
* getting the orientation data. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1609 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1610 |
Orientation.prototype.watchOrientation = function(successCallback, errorCallback, options) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1611 |
// Invoke the appropriate callback with a new Position object every time the implementation |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1612 |
// determines that the position of the hosting device has changed. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1613 |
this.getCurrentOrientation(successCallback, errorCallback); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1614 |
var frequency = (options != undefined)? options.frequency : 1000; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1615 |
return setInterval(function() { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1616 |
navigator.orientation.getCurrentOrientation(successCallback, errorCallback); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1617 |
}, frequency); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1618 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1619 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1620 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1621 |
* Clears the specified orientation watch. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1622 |
* @param {String} watchId The ID of the watch returned from #watchOrientation. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1623 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1624 |
Orientation.prototype.clearWatch = function(watchId) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1625 |
clearInterval(watchId); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1626 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1627 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1628 |
//gets the Acceleration Service Object from WRT |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1629 |
Orientation.prototype.getServiceObj = function() { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1630 |
var so; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1631 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1632 |
try { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1633 |
so = device.getServiceObject("Service.Sensor", "ISensor"); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1634 |
} catch (ex) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1635 |
throw { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1636 |
name: "DeviceError", |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1637 |
message: ex.name + ": " + ex.message |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1638 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1639 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1640 |
return so; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1641 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1642 |
|
321
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1643 |
|
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1644 |
/** |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1645 |
* This class encapsulates the possible orientation values. |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1646 |
* @constructor |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1647 |
*/ |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1648 |
function DisplayOrientation() { |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1649 |
this.code = null; |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1650 |
this.message = ""; |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1651 |
} |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1652 |
|
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1653 |
DisplayOrientation.PORTRAIT = 0; |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1654 |
DisplayOrientation.REVERSE_PORTRAIT = 1; |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1655 |
DisplayOrientation.LANDSCAPE_LEFT_UP = 2; |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1656 |
DisplayOrientation.LANDSCAPE_RIGHT_UP = 3; |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1657 |
DisplayOrientation.FACE_UP = 4; |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1658 |
DisplayOrientation.FACE_DOWN = 5; |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1659 |
|
310
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1660 |
if (typeof navigator.orientation == "undefined") navigator.orientation = new Orientation(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1661 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1662 |
* This class contains position information. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1663 |
* @param {Object} lat |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1664 |
* @param {Object} lng |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1665 |
* @param {Object} acc |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1666 |
* @param {Object} alt |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1667 |
* @param {Object} altacc |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1668 |
* @param {Object} head |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1669 |
* @param {Object} vel |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1670 |
* @constructor |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1671 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1672 |
function Position(coords, timestamp) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1673 |
this.coords = coords; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1674 |
this.timestamp = new Date().getTime(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1675 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1676 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1677 |
function Coordinates(lat, lng, alt, acc, head, vel) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1678 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1679 |
* The latitude of the position. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1680 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1681 |
this.latitude = lat; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1682 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1683 |
* The longitude of the position, |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1684 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1685 |
this.longitude = lng; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1686 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1687 |
* The accuracy of the position. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1688 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1689 |
this.accuracy = acc; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1690 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1691 |
* The altitude of the position. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1692 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1693 |
this.altitude = alt; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1694 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1695 |
* The direction the device is moving at the position. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1696 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1697 |
this.heading = head; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1698 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1699 |
* The velocity with which the device is moving at the position. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1700 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1701 |
this.speed = vel; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1702 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1703 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1704 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1705 |
* This class specifies the options for requesting position data. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1706 |
* @constructor |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1707 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1708 |
function PositionOptions() { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1709 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1710 |
* Specifies the desired position accuracy. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1711 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1712 |
this.enableHighAccuracy = true; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1713 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1714 |
* The timeout after which if position data cannot be obtained the errorCallback |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1715 |
* is called. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1716 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1717 |
this.timeout = 10000; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1718 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1719 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1720 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1721 |
* This class contains information about any GSP errors. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1722 |
* @constructor |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1723 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1724 |
function PositionError() { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1725 |
this.code = null; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1726 |
this.message = ""; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1727 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1728 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1729 |
PositionError.UNKNOWN_ERROR = 0; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1730 |
PositionError.PERMISSION_DENIED = 1; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1731 |
PositionError.POSITION_UNAVAILABLE = 2; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1732 |
PositionError.TIMEOUT = 3; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1733 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1734 |
* This class provides access to the device SMS functionality. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1735 |
* @constructor |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1736 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1737 |
function Sms() { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1738 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1739 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1740 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1741 |
/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1742 |
* Sends an SMS message. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1743 |
* @param {Integer} number The phone number to send the message to. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1744 |
* @param {String} message The contents of the SMS message to send. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1745 |
* @param {Function} successCallback The function to call when the SMS message is sent. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1746 |
* @param {Function} errorCallback The function to call when there is an error sending the SMS message. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1747 |
* @param {PositionOptions} options The options for accessing the GPS location such as timeout and accuracy. |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1748 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1749 |
Sms.prototype.send = function(number, message, successCallback, errorCallback, options) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1750 |
try { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1751 |
if (!this.serviceObj) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1752 |
this.serviceObj = this.getServiceObj(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1753 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1754 |
// Setup input params using dot syntax |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1755 |
var criteria = new Object(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1756 |
criteria.MessageType = 'SMS'; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1757 |
criteria.To = number; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1758 |
criteria.BodyText = message; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1759 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1760 |
var result = this.serviceObj.IMessaging.Send(criteria); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1761 |
if (result.ErrorCode != 0 && result.ErrorCode != "0") |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1762 |
{ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1763 |
var exception = { name: "SMSError", message: result.ErrorMessage }; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1764 |
throw exception; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1765 |
} else { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1766 |
successCallback.call(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1767 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1768 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1769 |
catch(ex) |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1770 |
{ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1771 |
errorCallback.call({ name: "SmsError", message: ex.name + ": " + ex.message }); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1772 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1773 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1774 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1775 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1776 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1777 |
//gets the Sms Service Object from WRT |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1778 |
Sms.prototype.getServiceObj = function() { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1779 |
var so; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1780 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1781 |
try { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1782 |
so = device.getServiceObject("Service.Messaging", "IMessaging"); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1783 |
} catch (ex) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1784 |
throw { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1785 |
name: "SmsError", |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1786 |
message: "Failed to load sms service (" + ex.name + ": " + ex.message + ")" |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1787 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1788 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1789 |
return so; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1790 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1791 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1792 |
if (typeof navigator.sms == "undefined") navigator.sms = new Sms();/** |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1793 |
* @author ryan |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1794 |
*/ |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1795 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1796 |
function Storage() { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1797 |
this.available = true; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1798 |
this.serialized = null; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1799 |
this.items = null; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1800 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1801 |
if (!window.widget) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1802 |
this.available = false; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1803 |
return; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1804 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1805 |
var pref = window.widget.preferenceForKey(Storage.PREFERENCE_KEY); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1806 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1807 |
//storage not yet created |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1808 |
if (pref == "undefined" || pref == undefined) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1809 |
this.length = 0; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1810 |
this.serialized = "({})"; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1811 |
this.items = {}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1812 |
window.widget.setPreferenceForKey(this.serialized, Storage.PREFERENCE_KEY); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1813 |
} else { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1814 |
this.serialized = pref;'({"store_test": { "key": "store_test", "data": "asdfasdfs" },})'; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1815 |
this.items = eval(this.serialized); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1816 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1817 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1818 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1819 |
Storage.PREFERENCE_KEY = "phonegap_storage_pref_key"; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1820 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1821 |
Storage.prototype.index = function (key) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1822 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1823 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1824 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1825 |
Storage.prototype.getItem = function (key) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1826 |
try { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1827 |
return this.items[key].data; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1828 |
} catch (ex) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1829 |
return null; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1830 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1831 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1832 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1833 |
Storage.prototype.setItem = function (key, data) { |
340
740921999de7
Bug 2784 - Update bundled PhoneGap libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
321
diff
changeset
|
1834 |
|
310
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1835 |
this.items[key] = { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1836 |
"key": key, |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1837 |
"data": data |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1838 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1839 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1840 |
this.serialize(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1841 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1842 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1843 |
Storage.prototype.removeItem = function (key) { |
340
740921999de7
Bug 2784 - Update bundled PhoneGap libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
321
diff
changeset
|
1844 |
|
310
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1845 |
if (this.items[key]) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1846 |
this.items[key] = undefined; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1847 |
} |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1848 |
this.serialize(); |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1849 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1850 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1851 |
Storage.prototype.clear = function () { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1852 |
this.serialized = "({})"; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1853 |
this.items = {}; |
340
740921999de7
Bug 2784 - Update bundled PhoneGap libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
321
diff
changeset
|
1854 |
this.serialize(); |
310
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1855 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1856 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1857 |
Storage.prototype.serialize = function() { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1858 |
var json = ""; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1859 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1860 |
for (key in this.items) { |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1861 |
var item = this.items[key]; |
340
740921999de7
Bug 2784 - Update bundled PhoneGap libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
321
diff
changeset
|
1862 |
if (typeof item != "undefined") { |
740921999de7
Bug 2784 - Update bundled PhoneGap libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
321
diff
changeset
|
1863 |
json += "\"" + item.key + "\": { \"key\": \"" + item.key + "\", \"data\": \"" + item.data + "\" }, "; |
740921999de7
Bug 2784 - Update bundled PhoneGap libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
321
diff
changeset
|
1864 |
} |
310
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1865 |
} |
340
740921999de7
Bug 2784 - Update bundled PhoneGap libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
321
diff
changeset
|
1866 |
this.serialized = "({" + json + "})"; |
310
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1867 |
|
340
740921999de7
Bug 2784 - Update bundled PhoneGap libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
321
diff
changeset
|
1868 |
window.widget.setPreferenceForKey( this.serialized, Storage.PREFERENCE_KEY); |
310
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1869 |
}; |
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1870 |
|
e9484be98cfe
UI to add libraries was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1871 |
if (typeof navigator.storage == "undefined" ) navigator.storage = new Storage(); |
321
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1872 |
/** |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1873 |
* This class provides access to the telephony features of the device. |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1874 |
* @constructor |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1875 |
*/ |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1876 |
function Telephony() { |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1877 |
this.number = ""; |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1878 |
} |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1879 |
|
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1880 |
/** |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1881 |
* Calls the specifed number. |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1882 |
* @param {Integer} number The number to be called. |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1883 |
*/ |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1884 |
Telephony.prototype.send = function(number) { |
340
740921999de7
Bug 2784 - Update bundled PhoneGap libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
321
diff
changeset
|
1885 |
widget.openURL('tel:+' + number); |
321
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1886 |
}; |
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1887 |
|
b99b8311285c
PhoneGap library was updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
310
diff
changeset
|
1888 |
if (typeof navigator.telephony == "undefined") navigator.telephony = new Telephony(); |