|
1 |
|
2 <!DOCTYPE html |
|
3 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
4 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><meta name="copyright" content="(C) Copyright 2009"/><meta name="DC.rights.owner" content="(C) Copyright 2009"/><meta name="DC.Type" content="mobileconcept"/><meta name="DC.Title" content="Logging Service API example"/><meta name="DC.Relation" scheme="URI" content="GUID-6C3D58CA-CA4F-432B-898B-4020064E3CE6"/><meta name="DC.Relation" scheme="URI" content="GUID-7C69DDA4-16F1-4A8F-BDB2-4CB0015B4E81"/><meta name="DC.Relation" scheme="URI" content="GUID-65AAF569-D347-462B-B59A-9D7CA184AB9C"/><meta name="DC.Relation" scheme="URI" content="GUID-F003B7DD-E450-49AD-B447-C5132FE47D3C"/><meta name="DC.Format" content="XHTML"/><meta name="DC.Identifier" content="GUID-9C85B403-6CFC-4E17-A2B2-AD1AD2F7794D"/><title>Logging Service API example </title><script type="text/javascript"> |
|
5 function initPage() {} |
|
6 </script><link href="../PRODUCT_PLUGIN/book.css" rel="stylesheet" type="text/css"/><link href="css/s60/style.css" rel="stylesheet" type="text/css" media="all"/></head><body onload="initPage();"><div class="body"><div class="contentLeft prTxt"><h1 class="pageHeading" id="GUID-9C85B403-6CFC-4E17-A2B2-AD1AD2F7794D">Logging Service API example</h1><div> |
|
7 <p/> |
|
8 <p>This section presents the full source code of a working sample widget |
|
9 for the <a href="GUID-CF55DBA3-2D4C-4FD0-8A06-862E6128F4E7.html#GUID-CF55DBA3-2D4C-4FD0-8A06-862E6128F4E7">Logging service</a>. |
|
10 You can download the <code>wgz</code> package for this widget from |
|
11 section <a href="GUID-775005BC-2FF8-45A9-BBA6-6CED6B5780A2.html#GUID-775005BC-2FF8-45A9-BBA6-6CED6B5780A2">Example widgets</a>.</p> |
|
12 <p>For general information about creating widgets, see section <a href="GUID-0E3095DB-03FF-4240-83F2-6D876AD2083A.html#GUID-0E3095DB-03FF-4240-83F2-6D876AD2083A">Widget component files</a>.</p> |
|
13 <p>For widget development and debugging purposes, this example writes its |
|
14 output to <code>c:\data\jslog_widget.log</code> using <code>console.info</code>. |
|
15 For instructions on how to enable logging in the Web browser for S60, see |
|
16 section <a href="GUID-B584CA90-543B-4AED-B134-A3A616259DB9.html#GUID-B584CA90-543B-4AED-B134-A3A616259DB9">JavaScript console</a>.</p> |
|
17 <div><h3>Info.plist</h3> |
|
18 <pre class="codeblock" id="GUID-FBF62C65-8270-49CA-912E-8B28A7893D3C"><?xml version="1.0" encoding="UTF-8"?> |
|
19 <!DOCTYPE plist PUBLIC "-//Nokia//DTD PLIST 1.0//EN" "http://www.nokia.com/NOKIA_COM_1/DTDs/plist-1.0.dtd"> |
|
20 <plist version="1.0"> |
|
21 <dict> |
|
22 <key>DisplayName</key> |
|
23 <string>LoggingSample</string> |
|
24 <key>Identifier</key> |
|
25 <string>com.nokia.widget.sapi.logging.sample</string> |
|
26 <key>Version</key> |
|
27 <string>1.0</string> |
|
28 <key>MainHTML</key> |
|
29 <string>logging-sample.html</string> |
|
30 <key>AllowNetworkAccess</key> |
|
31 <true/> |
|
32 </dict> |
|
33 </plist> |
|
34 </pre> |
|
35 </div> |
|
36 <div><h3>Logging-sample.html</h3> |
|
37 <pre class="codeblock" id="GUID-6A2FBAA5-54EC-47CF-8637-89A9345B0614"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
|
38 <html> |
|
39 <head> |
|
40 <script type="text/javascript" src="js/common.js"></script> |
|
41 <script type="text/javascript" src="js/logging-sample.js"></script> |
|
42 </head> |
|
43 <body id='docBody' bgcolor="#ddeeff" onload="setup()" style=width:100%;height:100%;> |
|
44 |
|
45 <form name="frm"> |
|
46 <h3>Logging API Sample Widget</h3> |
|
47 |
|
48 <input type="button" onclick="addLog('img1')" value="AddLog"><img id="img1" src="pic/blank.png" width="25" height="25" align="center"><br> |
|
49 <input type="button" onclick="delLog('img2')" value="DeleteLog"><img id="img2" src="pic/blank.png" width="25" height="25" align="center"><br> |
|
50 <input type="button" onclick="getLogList('img3')" value="GetLogList"><img id="img3" src="pic/blank.png" width="25" height="25" align="center"><br> |
|
51 <input type="button" onclick="addLogAsync('img4')" value="AddLogAsync"><img id="img4" src="pic/blank.png" width="25" height="25" align="center"><br> |
|
52 <input type="button" onclick="delLogAsync('img5')" value="DeleteLogAsync"><img id="img5" src="pic/blank.png" width="25" height="25" align="center"><br> |
|
53 <input type="button" onclick="getLogListAsync('img6')" value="GetLogListAsync"><img id="img6" src="pic/blank.png" width="25" height="25" align="center"><br> |
|
54 <input type="button" onclick="requestNotification('img7')" value="RequestNotification"><img id="img7" src="pic/blank.png" width="25" height="25" align="center"><br> |
|
55 <input type="button" onclick="cancelAddLogAsync('img8')" value="CancelAddLogAsync"><img id="img8" src="pic/blank.png" width="25" height="25" align="center"><br> |
|
56 <input type="button" onclick="cancelDelLogAsync('img9')" value="CancelDeleteLogAsync"><img id="img9" src="pic/blank.png" width="25" height="25" align="center"><br> |
|
57 <input type="button" onclick="cancelGetLogListAsync('img10')" value="CancelGetLogListAsync"><img id="img10" src="pic/blank.png" width="25" height="25" align="center"><br> |
|
58 <input type="button" onclick="cancelRequestNotification('img11')" value="CancelRequestNotification"><img id="img11" src="pic/blank.png" width="25" height="25" align="center"><br> |
|
59 |
|
60 <hr> |
|
61 <div class='loggingsample' id='loggingsample' bgcolor="#ddeeff" style=width:100%;height:100%;overflow:auto> |
|
62 </div> |
|
63 </form> |
|
64 </body> |
|
65 </html> |
|
66 </pre> |
|
67 </div> |
|
68 <div><h3>common.js</h3> |
|
69 <pre class="codeblock" id="GUID-A4CCD027-781C-4761-A76E-21CDA239B7CB">errCode = resultList.ErrorCode; |
|
70 var msg = ""; |
|
71 |
|
72 if (errCode) { |
|
73 msg = message + "<BR>" + "Failed Error: " + errCode + "<BR>"; |
|
74 if(resultList.ErrorMessage != undefined) |
|
75 msg += "Error Message: " + resultList.ErrorMessage; |
|
76 showIMG(imgId,"no"); |
|
77 } else { |
|
78 showIMG(imgId,"yes"); |
|
79 } |
|
80 |
|
81 //print error message |
|
82 if(divId != null && divId != undefined) |
|
83 document.getElementById(divId).innerHTML = msg; |
|
84 console.info(msg); |
|
85 |
|
86 return errCode; |
|
87 } |
|
88 |
|
89 // Build the message by reading an iterable list in a recursive manner |
|
90 function showIterableList(iterator) |
|
91 { |
|
92 var msg = ""; |
|
93 try |
|
94 { |
|
95 iterator.reset(); |
|
96 var item; |
|
97 while (( item = iterator.getNext()) != undefined ){ |
|
98 msg += showObject( item ); |
|
99 } |
|
100 } |
|
101 catch(e) |
|
102 { |
|
103 alert('<showIterableList> ' + e); |
|
104 } |
|
105 return msg; |
|
106 } |
|
107 |
|
108 // Build the message by reading a JS object in a recursive manner |
|
109 function showObject( obj ) |
|
110 { |
|
111 var txt = ""; |
|
112 try { |
|
113 if ( typeof obj != 'object' ) |
|
114 return "" + obj + '<BR/>'; |
|
115 else { |
|
116 for(var key in obj) { |
|
117 txt += key + ":"; |
|
118 txt += showObject( obj[key] ); |
|
119 txt += '<BR/>'; |
|
120 } |
|
121 txt += '<BR/>'; |
|
122 } |
|
123 } |
|
124 catch (e) |
|
125 { |
|
126 alert("showObject: " + e); |
|
127 } |
|
128 return txt; |
|
129 } |
|
130 |
|
131 // Show the image to indicate the test result |
|
132 function showIMG(imgId, isOK) |
|
133 { |
|
134 if(imgId == null || imgId == undefined) |
|
135 return; |
|
136 |
|
137 if(isOK == "yes") |
|
138 document.getElementById(imgId).src = "pic/yes.png"; |
|
139 else if(isOK == "no") |
|
140 document.getElementById(imgId).src = "pic/no.png"; |
|
141 else |
|
142 document.getElementById(imgId).src = "pic/blank.png"; |
|
143 } |
|
144 |
|
145 // Show elements in object by using 'alert' |
|
146 function testObject(obj) |
|
147 { |
|
148 var msg = ""; |
|
149 for(var key in obj) { |
|
150 msg = msg + ":" + key + "=" + obj[key]; |
|
151 } |
|
152 alert(msg); |
|
153 } |
|
154 |
|
155 // Test whether the input is numeric |
|
156 function IsNumeric(sText) |
|
157 { |
|
158 var ValidChars = "0123456789."; |
|
159 var IsNumber=true; |
|
160 var Char; |
|
161 |
|
162 for (i = 0; i < sText.length && IsNumber == true; i++) |
|
163 { |
|
164 Char = sText.charAt(i); |
|
165 if (ValidChars.indexOf(Char) == -1) |
|
166 { |
|
167 IsNumber = false; |
|
168 } |
|
169 } |
|
170 return IsNumber; |
|
171 } |
|
172 </pre> |
|
173 </div> |
|
174 <div><h3>Logging-sample.js</h3> |
|
175 <pre class="codeblock" id="GUID-7DDB5A09-0A19-4685-8D11-52F387BDFF22">// logging-sample.js |
|
176 // |
|
177 // In this sample a log event will be added, deleted, and listed. The notification will |
|
178 // be sent when the log changes. Also, an async operation will be cancelled. |
|
179 // |
|
180 |
|
181 //SAPI Error Codes |
|
182 // 0 - Success |
|
183 // 1000 - InvalidServiceArgument |
|
184 // 1001 - UnknownArgumentName |
|
185 // 1002 - BadArgumentType |
|
186 // 1003 - MissingArgument |
|
187 // 1004 - ServiceNotSupported |
|
188 // 1005 - ServiceInUse |
|
189 // 1006 - ServiceNotReady |
|
190 // 1007 - NoMemory |
|
191 // 1008 - HardwareNotAvailable |
|
192 // 1009 - ServerBusy |
|
193 // 1010 - EntryExists |
|
194 // 1011 - AccessDenied |
|
195 // 1012 - NotFound |
|
196 // 1013 - UnknownFormat |
|
197 // 1014 - GeneralError |
|
198 // 1015 - CancelSuccess |
|
199 // 1016 - ServiceTimedOut |
|
200 // 1017 - PathNotFound |
|
201 |
|
202 // Declare the service object |
|
203 var so; |
|
204 |
|
205 // imgid for callback1 function |
|
206 var imgid_callback1; |
|
207 |
|
208 // imgid for callback2 function |
|
209 var imgid_callback2; |
|
210 |
|
211 // imgid for callback3 function |
|
212 var imgid_callback3; |
|
213 |
|
214 // imgid for callback4 function |
|
215 var imgid_callback4; |
|
216 |
|
217 // id of the div used to display information |
|
218 const DIV_ID = 'loggingsample'; |
|
219 |
|
220 // Called from onload() |
|
221 function setup() |
|
222 { |
|
223 try { |
|
224 so = device.getServiceObject('Service.Logging', 'IDataSource'); |
|
225 console.info("setup: so: %s", so); |
|
226 } |
|
227 catch (e) { |
|
228 alert('<setup> ' +e); |
|
229 } |
|
230 } |
|
231 |
|
232 // Add Log |
|
233 function addLog(imgId) { |
|
234 |
|
235 var itemMap = new Object(); |
|
236 itemMap.EventType = 3; // ShortMessage event |
|
237 itemMap.RemoteParty = '16172333568'; |
|
238 itemMap.PhoneNumber = '17819933882'; |
|
239 itemMap.Direction = 1; // outgoing |
|
240 itemMap.Subject = 'Test txt msg'; |
|
241 itemMap.Description = 'Hi, this is a text message to you'; |
|
242 itemMap.DeliveryStatus = 1; // Sent |
|
243 |
|
244 var criteria = new Object(); |
|
245 criteria.Type = 'Log'; |
|
246 criteria.Item = itemMap; |
|
247 |
|
248 try { |
|
249 var result = so.IDataSource.Add(criteria); |
|
250 checkError("IDataSource::Add",result,DIV_ID,imgId); |
|
251 } |
|
252 catch (e) { |
|
253 showIMG(imgId,"no"); |
|
254 alert("addLog: " + e); |
|
255 } |
|
256 } |
|
257 |
|
258 // Delete Log |
|
259 function delLog(imgId) { |
|
260 |
|
261 // get "id" by using RequestNotification() |
|
262 var logId = prompt("Please enter the target log id", ""); |
|
263 if (logId == "" || logId == null) |
|
264 return; |
|
265 |
|
266 var itemData = new Object(); |
|
267 itemData.id = logId; |
|
268 |
|
269 var criteria = new Object(); |
|
270 criteria.Type = 'Log'; |
|
271 criteria.Data = itemData; |
|
272 |
|
273 try { |
|
274 var result = so.IDataSource.Delete(criteria); |
|
275 checkError("IDataSource::Delete",result,DIV_ID,imgId); |
|
276 } |
|
277 catch (e) { |
|
278 showIMG(imgId,"no"); |
|
279 alert ("delLog: " + e); |
|
280 } |
|
281 } |
|
282 |
|
283 // Get the List of Log |
|
284 function getLogList(imgId) { |
|
285 |
|
286 var filterMap = new Object(); |
|
287 filterMap.EventType = 3;// shortMessage event |
|
288 |
|
289 var criteria = new Object(); |
|
290 criteria.Type = 'Log'; |
|
291 criteria.Filter = filterMap; |
|
292 |
|
293 try { |
|
294 var result = so.IDataSource.GetList(criteria); |
|
295 if(!checkError("IDataSource::getLogList",result,DIV_ID,imgId)) { |
|
296 var msg = ""; |
|
297 var obj; |
|
298 var it = result.ReturnValue; |
|
299 while ((obj = it.getNext()) != undefined) { |
|
300 msg = msg + "id: " + obj['id']+ "<br>"; |
|
301 msg = msg + "EventType: " + obj['EventType'] + "<br>"; |
|
302 msg = msg + "RemoteParty: " + obj['RemoteParty'] + "<br>"; |
|
303 msg = msg + "PhoneNumber: " + obj['PhoneNumber'] + "<br>"; |
|
304 msg = msg + "Subject: " + obj['Subject'] + "<br>"; |
|
305 msg = msg + "Description: " + obj['Description'] + "<br>"; |
|
306 msg = msg + "DeliveryStatus: " + obj['DeliveryStatus'] + "<br><br>"; |
|
307 } |
|
308 it.reset(); |
|
309 document.getElementById(DIV_ID).innerHTML = msg; |
|
310 } |
|
311 } |
|
312 catch (e) { |
|
313 showIMG(imgId,"no"); |
|
314 alert ("getLogList: " + e); |
|
315 } |
|
316 } |
|
317 |
|
318 // Add Log Async |
|
319 function addLogAsync(imgId) { |
|
320 |
|
321 var itemMap = new Object(); |
|
322 itemMap.EventType = 3; // ShortMessage event |
|
323 itemMap.RemoteParty = '16172333568'; |
|
324 itemMap.PhoneNumber = '17819933882'; |
|
325 itemMap.Direction = 1; // outgoing |
|
326 itemMap.Subject = 'Test txt msg'; |
|
327 itemMap.Description = 'Hi, this is a text message to you'; |
|
328 itemMap.DeliveryStatus = 1; // Sent |
|
329 |
|
330 var criteria = new Object(); |
|
331 criteria.Type = 'Log'; |
|
332 criteria.Item = itemMap; |
|
333 |
|
334 // Set image id for callback1 function |
|
335 imgid_callback1 = imgId; |
|
336 |
|
337 try { |
|
338 var result = so.IDataSource.Add(criteria, callback1); |
|
339 if(!checkError("IDataSource::addLogAsync",result,DIV_ID,imgId)) { |
|
340 showIMG(imgId,""); |
|
341 } |
|
342 } |
|
343 catch (e) { |
|
344 showIMG(imgId,"no"); |
|
345 alert ("addLogAsync: " + e); |
|
346 } |
|
347 } |
|
348 |
|
349 // Delete Log Async |
|
350 function delLogAsync(imgId) { |
|
351 |
|
352 // get "id" by using RequestNotification() |
|
353 var logId = prompt("Please enter the target log id", ""); |
|
354 if (logId == "" || logId == null) |
|
355 return; |
|
356 |
|
357 var itemData = new Object(); |
|
358 itemData.id = logId; |
|
359 |
|
360 var criteria = new Object(); |
|
361 criteria.Type = 'Log'; |
|
362 criteria.Data = itemData; |
|
363 |
|
364 // Set image id for callback2 function |
|
365 imgid_callback2 = imgId; |
|
366 |
|
367 try { |
|
368 var result = so.IDataSource.Delete(criteria, callback2); |
|
369 if(!checkError("IDataSource::delLogAsync",result,DIV_ID,imgId)) { |
|
370 showIMG(imgId,""); |
|
371 } |
|
372 } |
|
373 catch (e) { |
|
374 showIMG(imgId,"no"); |
|
375 alert ("delLogAsync: " + e); |
|
376 } |
|
377 } |
|
378 |
|
379 // Get Log List Async |
|
380 function getLogListAsync(imgId) { |
|
381 |
|
382 var filterMap = new Object(); |
|
383 filterMap.EventType = 3; |
|
384 |
|
385 var criteria = new Object(); |
|
386 criteria.Type = 'Log'; |
|
387 criteria.Filter = filterMap; |
|
388 |
|
389 // Set image id for callback3 function |
|
390 imgid_callback3 = imgId; |
|
391 |
|
392 try { |
|
393 var result = so.IDataSource.GetList(criteria, callback3); |
|
394 if(!checkError("IDataSource::getLogListAsync",result,DIV_ID,imgId)) { |
|
395 showIMG(imgId,""); |
|
396 } |
|
397 } |
|
398 catch (e) { |
|
399 showIMG(imgId,"no"); |
|
400 alert ("getLogListAsync: " + e); |
|
401 } |
|
402 } |
|
403 |
|
404 // Cancel Add Log Async |
|
405 function cancelAddLogAsync(imgId) { |
|
406 |
|
407 var itemMap = new Object(); |
|
408 itemMap.EventType = 3; // ShortMessage event |
|
409 itemMap.RemoteParty = '16172333568'; |
|
410 itemMap.PhoneNumber = '17819933882'; |
|
411 itemMap.Direction = 1; // outgoing |
|
412 itemMap.Subject = 'Test txt msg'; |
|
413 itemMap.Description = 'Hi, this is a text message to you'; |
|
414 itemMap.DeliveryStatus = 1; // Sent |
|
415 |
|
416 var criteria = new Object(); |
|
417 criteria.Type = 'Log'; |
|
418 criteria.Item = itemMap; |
|
419 |
|
420 // Set image id for callback1 function |
|
421 imgid_callback1 = imgId; |
|
422 |
|
423 try { |
|
424 var result = so.IDataSource.Add(criteria, callback1); |
|
425 if(!checkError("IDataSource::cancelAddLogAsync",result,DIV_ID,imgId)) { |
|
426 showIMG(imgId,""); |
|
427 var criteria2 = new Object(); |
|
428 criteria2.TransactionID = result.TransactionID; |
|
429 var result2 = so.IDataSource.Cancel(criteria2); |
|
430 checkError("IDataSource::cancelAddLogAsync",result2,DIV_ID,imgId); |
|
431 } |
|
432 } |
|
433 catch (e) { |
|
434 showIMG(imgId,"no"); |
|
435 alert ("cancelAddLogAsync: " + e); |
|
436 } |
|
437 } |
|
438 |
|
439 // Cancel Delete Log Async |
|
440 function cancelDelLogAsync(imgId) { |
|
441 |
|
442 // get "id" by using RequestNotification() |
|
443 var logId = prompt("Please enter the target log id", ""); |
|
444 if (logId == "" || logId == null) |
|
445 return; |
|
446 |
|
447 var itemData = new Object(); |
|
448 itemData.id = logId; |
|
449 |
|
450 var criteria = new Object(); |
|
451 criteria.Type = 'Log'; |
|
452 criteria.Data = itemData; |
|
453 |
|
454 // Set image id for callback2 function |
|
455 imgid_callback2 = imgId; |
|
456 |
|
457 try { |
|
458 var result = so.IDataSource.Delete(criteria, callback2); |
|
459 if(!checkError("IDataSource::cancelDelLogAsync",result,DIV_ID,imgId)) { |
|
460 showIMG(imgId,""); |
|
461 var criteria2 = new Object(); |
|
462 criteria2.TransactionID = result.TransactionID; |
|
463 var result2 = so.IDataSource.Cancel(criteria2); |
|
464 checkError("IDataSource::cancelDelLogAsync",result2,DIV_ID,imgId); |
|
465 } |
|
466 } |
|
467 catch (e) { |
|
468 showIMG(imgId,"no"); |
|
469 alert ("cancelDelLogAsync: " + e); |
|
470 } |
|
471 } |
|
472 |
|
473 // Cancel Get Log List Async |
|
474 function cancelGetLogListAsync(imgId) { |
|
475 |
|
476 var filterMap = new Object(); |
|
477 filterMap.EventType = 3;// shortMessage event |
|
478 |
|
479 var criteria = new Object(); |
|
480 criteria.Type = 'Log'; |
|
481 criteria.Filter = filterMap; |
|
482 |
|
483 // Set image id for callback3 function |
|
484 imgid_callback3 = imgId; |
|
485 |
|
486 try { |
|
487 var result = so.IDataSource.GetList(criteria, callback3); |
|
488 if(!checkError("IDataSource::cancelGetLogListAsync",result,DIV_ID,imgId)) { |
|
489 showIMG(imgId,""); |
|
490 var criteria2 = new Object(); |
|
491 criteria2.TransactionID = result.TransactionID; |
|
492 var result2 = so.IDataSource.Cancel(criteria2); |
|
493 checkError("IDataSource::cancelGetLogListAsync",result2,DIV_ID,imgId); |
|
494 } |
|
495 } |
|
496 catch (e) { |
|
497 showIMG(imgId,"no"); |
|
498 alert ("cancelGetLogListAsync: " + e); |
|
499 } |
|
500 } |
|
501 |
|
502 // Request Notification |
|
503 function requestNotification(imgId) { |
|
504 |
|
505 var filter = new Object(); |
|
506 // The Minimum time, in Microseconds, |
|
507 // that elapses before the notification request can complete. |
|
508 filter.DelayTime = 2000000; |
|
509 |
|
510 var criteria = new Object(); |
|
511 criteria.Type = 'Log'; |
|
512 criteria.Filter = filter; |
|
513 |
|
514 // Set image id for callback4 function |
|
515 imgid_callback4 = imgId; |
|
516 |
|
517 try { |
|
518 var result = so.IDataSource.RequestNotification(criteria,callback4); |
|
519 checkError("IDataSource::requestNotification",result,DIV_ID,imgId); |
|
520 } |
|
521 catch (e) { |
|
522 showIMG(imgId,"no"); |
|
523 alert ("requestNotification: " + e); |
|
524 } |
|
525 } |
|
526 |
|
527 // Cancel Request Notification |
|
528 function cancelRequestNotification(imgId) { |
|
529 |
|
530 var filter = new Object(); |
|
531 // The Minimum time, in Microseconds, |
|
532 // that elapses before the notification request can complete. |
|
533 filter.DelayTime = 2000000; |
|
534 |
|
535 var criteria = new Object(); |
|
536 criteria.Type = 'Log'; |
|
537 criteria.Filter = filter; |
|
538 |
|
539 // Set image id for callback4 function |
|
540 imgid_callback4 = imgId; |
|
541 |
|
542 try { |
|
543 var result = so.IDataSource.RequestNotification(criteria,callback4); |
|
544 if(!checkError("IDataSource::cancelRequestNotification",result,DIV_ID,imgId)) { |
|
545 showIMG(imgId,""); |
|
546 var criteria2 = new Object(); |
|
547 criteria2.TransactionID = result.TransactionID; |
|
548 var result2 = so.IDataSource.Cancel(criteria2); |
|
549 checkError("IDataSource::cancelRequestNotification",result2,DIV_ID,imgId); |
|
550 } |
|
551 } |
|
552 catch (e) { |
|
553 showIMG(imgId,"no"); |
|
554 alert ("cancelRequestNotification: " + e); |
|
555 } |
|
556 } |
|
557 |
|
558 // This is the asynchronous callback handler |
|
559 function callback1(transId, eventCode, result) |
|
560 { |
|
561 console.info("addLogAsync: transId: %d eventCode: %d result.ErrorCode: %d", transId, eventCode, result.ErrorCode); |
|
562 checkError("IDataSource::addLogAsync",result,DIV_ID,imgid_callback1); |
|
563 } |
|
564 |
|
565 // This is the asynchronous callback handler |
|
566 function callback2(transId, eventCode, result) |
|
567 { |
|
568 console.info("delLogAsync: transId: %d eventCode: %d result.ErrorCode: %d", transId, eventCode, result.ErrorCode); |
|
569 checkError("IDataSource::delLogAsync",result,DIV_ID,imgid_callback2); |
|
570 } |
|
571 |
|
572 // This is the asynchronous callback handler |
|
573 function callback3(transId, eventCode, result) |
|
574 { |
|
575 console.info("getLogListAsync: transId: %d eventCode: %d result.ErrorCode: %d", transId, eventCode, result.ErrorCode); |
|
576 if(!checkError("IDataSource::getLogListAsync",result,DIV_ID,imgid_callback3)) { |
|
577 var msg = ""; |
|
578 var obj; |
|
579 var meetingIt = result.ReturnValue; |
|
580 while ((obj = meetingIt.getNext()) != undefined) { |
|
581 msg = msg + "id: " + obj['id']+ "<br>"; |
|
582 msg = msg + "EventType: " + obj['EventType'] + "<br>"; |
|
583 msg = msg + "RemoteParty: " + obj['RemoteParty'] + "<br>"; |
|
584 msg = msg + "PhoneNumber: " + obj['PhoneNumber'] + "<br>"; |
|
585 msg = msg + "Subject: " + obj['Subject'] + "<br>"; |
|
586 msg = msg + "Description: " + obj['Description'] + "<br>"; |
|
587 msg = msg + "DeliveryStatus: " + obj['DeliveryStatus'] +"<br><br>"; |
|
588 } |
|
589 meetingIt.reset(); |
|
590 document.getElementById(DIV_ID).innerHTML = msg; |
|
591 } |
|
592 } |
|
593 |
|
594 // This is the asynchronous callback handler |
|
595 function callback4(transId, eventCode, result) |
|
596 { |
|
597 console.info("getLogListAsync: transId: %d eventCode: %d result.ErrorCode: %d", transId, eventCode, result.ErrorCode); |
|
598 if(!checkError("IDataSource::RequestNotificationAsync",result,DIV_ID,imgid_callback4)) { |
|
599 document.getElementById(DIV_ID).innerHTML = showObject("Event Log has been updated!"); |
|
600 } |
|
601 } |
|
602 </pre> |
|
603 </div> |
|
604 </div></div></div><div class="footer"><hr/><div class="copy">© Nokia 2009.</div></div></body></html> |