|
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="Calendar Service API example"/><meta name="DC.Relation" scheme="URI" content="GUID-92BD4759-43FA-482F-A12B-3F5607D4AA35"/><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-CABB28B8-D2B1-496B-BD7E-34FF496E60B4"/><meta name="DC.Format" content="XHTML"/><meta name="DC.Identifier" content="GUID-7C0890BC-7931-417B-B4AC-6E77E65A10F3"/><title>Calendar 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-7C0890BC-7931-417B-B4AC-6E77E65A10F3">Calendar 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-AE9A928B-F938-49B5-BC9E-72CB42046571.html#GUID-AE9A928B-F938-49B5-BC9E-72CB42046571">Calendar 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-258E89D2-D435-4988-838C-D116733586E7"><?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>CalendarSample</string> |
|
24 <key>Identifier</key> |
|
25 <string>com.nokia.widget.sapi.calendar.sample</string> |
|
26 <key>Version</key> |
|
27 <string>1.0</string> |
|
28 <key>MainHTML</key> |
|
29 <string>calendar-sample.html</string> |
|
30 </dict> |
|
31 </plist></pre> |
|
32 </div> |
|
33 <div><h3>calendar-sample.html</h3> |
|
34 <pre class="codeblock" id="GUID-476FB58D-71F4-480B-8564-BA26ED2281FF"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
|
35 <html> |
|
36 <head> |
|
37 <script type="text/javascript" src="js/common.js"></script> |
|
38 <script type="text/javascript" src="js/calendar-sample.js"></script> |
|
39 </head> |
|
40 <body id='docBody' bgcolor="#ddeeff" onload="setup()" style=width:100%;height:100%;> |
|
41 <form name="frm"> |
|
42 <h3>Calendar API Sample Widget</h3> |
|
43 <input type="button" onclick="addCalendar('img1')" value="AddCalendar"><img id="img1" src="pic/blank.png" width="25" height="25" align="center"><br> |
|
44 <input type="button" onclick="addMeeting('img2')" value="AddMeeting"><img id="img2" src="pic/blank.png" width="25" height="25" align="center"><br> |
|
45 <input type="button" onclick="getCalendar('img3')" value="GetCalendar"><img id="img3" src="pic/blank.png" width="25" height="25" align="center"><br> |
|
46 <input type="button" onclick="getMeeting('img4')" value="GetMeeting"><img id="img4" src="pic/blank.png" width="25" height="25" align="center"><br> |
|
47 <input type="button" onclick="delCalendar('img5')" value="DeleteCalendar"><img id="img5" src="pic/blank.png" width="25" height="25" align="center"><br> |
|
48 <input type="button" onclick="delAllEntry('img6')" value="DeleteAllEntriesInDefaultCalendar"><img id="img6" src="pic/blank.png" width="25" height="25" align="center"><br> |
|
49 <input type="button" onclick="delAllEntryAsync('img7')" value="DeleteAllEntriesInDefaultCalendarAsync"><img id="img7" src="pic/blank.png" width="25" height="25" align="center"><br> |
|
50 <input type="button" onclick="importEntry('img8')" value="ImportCalendar"><img id="img8" src="pic/blank.png" width="25" height="25" align="center"><br> |
|
51 <input type="button" onclick="exportEntry('img9')" value="ExportCalendar"><img id="img9" src="pic/blank.png" width="25" height="25" align="center"><br> |
|
52 <input type="button" onclick="importEntryAsync('img10')" value="ImportAsync"><img id="img10" src="pic/blank.png" width="25" height="25" align="center"><br> |
|
53 <input type="button" onclick="exportEntryAsync('img11')" value="ExportAsync"><img id="img11" src="pic/blank.png" width="25" height="25" align="center"><br> |
|
54 <input type="button" onclick="requestNotification('img12')" value="RequestNotification"><img id="img12" src="pic/blank.png" width="25" height="25" align="center"><br> |
|
55 <input type="button" onclick="cancelImportEntryAsync('img13')" value="CancelImportAsync"><img id="img13" src="pic/blank.png" width="25" height="25" align="center"><br> |
|
56 <input type="button" onclick="cancelExportEntryAsync('img14')" value="CancelExportAsync"><img id="img14" src="pic/blank.png" width="25" height="25" align="center"><br> |
|
57 <input type="button" onclick="cancelRequestNotification('img15')" value="CancelRequestNotification"><img id="img15" src="pic/blank.png" width="25" height="25" align="center"><br> |
|
58 <hr> |
|
59 <div class='calendarsample' id='calendarsample' bgcolor="#ddeeff" style=width:100%;height:100%;overflow:auto></div> |
|
60 </form> |
|
61 </body> |
|
62 </html></pre> |
|
63 </div> |
|
64 <div><h3>common.js</h3> |
|
65 <pre class="codeblock" id="GUID-7DD317AE-A467-4492-BA83-D9ED206473CA">// common.js |
|
66 // |
|
67 // This file contains some utility functions |
|
68 |
|
69 // Check the error code and show the information to users |
|
70 function checkError(message, resultList, divId, imgId) |
|
71 { |
|
72 var errCode = resultList.ErrorCode; |
|
73 var msg = ""; |
|
74 |
|
75 if (errCode) { |
|
76 msg = message + "<BR>" + "Failed Error: " + errCode + "<BR>"; |
|
77 if(resultList.ErrorMessage != undefined) |
|
78 msg += "Error Message: " + resultList.ErrorMessage; |
|
79 showIMG(imgId,"no"); |
|
80 } else { |
|
81 showIMG(imgId,"yes"); |
|
82 } |
|
83 |
|
84 //print error message |
|
85 if(divId != null && divId != undefined) |
|
86 document.getElementById(divId).innerHTML = msg; |
|
87 console.info(msg); |
|
88 |
|
89 return errCode; |
|
90 } |
|
91 |
|
92 // Build the message by reading a iteratorable list in a recursive manner |
|
93 function showIterableList(iterator) |
|
94 { |
|
95 var msg = ""; |
|
96 try |
|
97 { |
|
98 iterator.reset(); |
|
99 var item; |
|
100 while (( item = iterator.getNext()) != undefined ){ |
|
101 msg += showObject( item ); |
|
102 } |
|
103 } |
|
104 catch(e) |
|
105 { |
|
106 alert('<showIterableList> ' + e); |
|
107 } |
|
108 return msg; |
|
109 } |
|
110 |
|
111 // Build the message by reading a JS object in a recursive manner |
|
112 function showObject( obj ) |
|
113 { |
|
114 var txt = ""; |
|
115 try { |
|
116 if ( typeof obj != 'object' ) |
|
117 return "" + obj + '<BR/>'; |
|
118 else { |
|
119 for(var key in obj) { |
|
120 txt += key + ":"; |
|
121 txt += showObject( obj[key] ); |
|
122 txt += '<BR/>'; |
|
123 } |
|
124 txt += '<BR/>'; |
|
125 } |
|
126 } |
|
127 catch (e) |
|
128 { |
|
129 alert("showObject: " + e); |
|
130 } |
|
131 return txt; |
|
132 } |
|
133 |
|
134 // Show the image to indicate the test result |
|
135 function showIMG(imgId, isOK) |
|
136 { |
|
137 if(imgId == null || imgId == undefined) |
|
138 return; |
|
139 |
|
140 if(isOK == "yes") |
|
141 document.getElementById(imgId).src = "pic/yes.png"; |
|
142 else if(isOK == "no") |
|
143 document.getElementById(imgId).src = "pic/no.png"; |
|
144 else |
|
145 document.getElementById(imgId).src = "pic/blank.png"; |
|
146 } |
|
147 |
|
148 // Show elements in object by using 'alert' |
|
149 function testObject(obj) |
|
150 { |
|
151 var msg = ""; |
|
152 for(var key in obj) { |
|
153 msg = msg + ":" + key + "=" + obj[key]; |
|
154 } |
|
155 alert(msg); |
|
156 } |
|
157 |
|
158 // Test whether the input is numeric |
|
159 function IsNumeric(sText) |
|
160 { |
|
161 var ValidChars = "0123456789."; |
|
162 var IsNumber=true; |
|
163 var Char; |
|
164 |
|
165 for (i = 0; i < sText.length && IsNumber == true; i++) |
|
166 { |
|
167 Char = sText.charAt(i); |
|
168 if (ValidChars.indexOf(Char) == -1) |
|
169 { |
|
170 IsNumber = false; |
|
171 } |
|
172 } |
|
173 return IsNumber; |
|
174 }</pre> |
|
175 </div> |
|
176 <div><h3>calendar-sample.js</h3> |
|
177 <pre class="codeblock" id="GUID-E22C2F7D-3052-4361-92D7-E1ACA632B0D5">// calendar-sample.js |
|
178 // |
|
179 // In this sample Calendar and Meeting event will be added, deleted, and listed |
|
180 // from default database; Meeting event will be imported and exported; The |
|
181 // notification will be send when the calendar changes; Also, async operation will |
|
182 // be canceled. |
|
183 // |
|
184 |
|
185 //SAPI Error Codes |
|
186 // 0 - Success |
|
187 // 1000 - InvalidServiceArgument |
|
188 // 1001 - UnknownArgumentName |
|
189 // 1002 - BadArgumentType |
|
190 // 1003 - MissingArgument |
|
191 // 1004 - ServiceNotSupported |
|
192 // 1005 - ServiceInUse |
|
193 // 1006 - ServiceNotReady |
|
194 // 1007 - NoMemory |
|
195 // 1008 - HardwareNotAvailable |
|
196 // 1009 - ServerBusy |
|
197 // 1010 - EntryExists |
|
198 // 1011 - AccessDenied |
|
199 // 1012 - NotFound |
|
200 // 1013 - UnknownFormat |
|
201 // 1014 - GeneralError |
|
202 // 1015 - CancelSuccess |
|
203 // 1016 - ServiceTimedOut |
|
204 // 1017 - PathNotFound |
|
205 |
|
206 // Declare the service object |
|
207 var so; |
|
208 |
|
209 // imgid for callback1 function |
|
210 var imgid_callback1; |
|
211 |
|
212 // imgid for callback2 function |
|
213 var imgid_callback2; |
|
214 |
|
215 // imgid for callback3 function |
|
216 var imgid_callback3; |
|
217 |
|
218 // id of the div used to display information |
|
219 const DIV_ID = 'calendarsample'; |
|
220 |
|
221 // Called from onload() |
|
222 function setup() |
|
223 { |
|
224 try { |
|
225 so = device.getServiceObject("Service.Calendar", "IDataSource"); |
|
226 console.info("setup: so: %s", so); |
|
227 } |
|
228 catch (e) { |
|
229 alert('<setup> ' +e); |
|
230 } |
|
231 } |
|
232 |
|
233 //Add a calendar |
|
234 function addCalendar(imgId) |
|
235 { |
|
236 var calName = prompt("Please enter the calendar name","C:myCalendar"); |
|
237 if(calName == "" || calName == null) |
|
238 return; |
|
239 |
|
240 var item = new Object(); |
|
241 item.CalendarName = calName; |
|
242 |
|
243 var criteria = new Object(); |
|
244 criteria.Type = "Calendar"; |
|
245 criteria.Item = item; |
|
246 |
|
247 try { |
|
248 var result = so.IDataSource.Add(criteria); |
|
249 checkError("IDataSource::addCalendar",result,DIV_ID,imgId); |
|
250 } |
|
251 catch (e) { |
|
252 showIMG(imgId,"no"); |
|
253 alert ("addCalendar: " + e); |
|
254 } |
|
255 } |
|
256 |
|
257 //Add a meeting |
|
258 function addMeeting(imgId) |
|
259 { |
|
260 var startDate = new Date("January 6, 2008 19:05:00"); |
|
261 var endDate = new Date("January 7, 2008 20:05:00"); |
|
262 |
|
263 var item = new Object(); |
|
264 item.Type = "Meeting"; |
|
265 item.StartTime = startDate; |
|
266 item.EndTime = endDate; |
|
267 |
|
268 var criteria = new Object(); |
|
269 criteria.Type = "CalendarEntry"; |
|
270 criteria.Item = item; |
|
271 |
|
272 try { |
|
273 var result = so.IDataSource.Add(criteria); |
|
274 checkError("IDataSource::addMeeting",result,DIV_ID,imgId); |
|
275 } |
|
276 catch (e) { |
|
277 showIMG(imgId,"no"); |
|
278 alert ("addCalendar: " + e); |
|
279 } |
|
280 } |
|
281 |
|
282 //Get Calendar |
|
283 function getCalendar(imgId) |
|
284 { |
|
285 // This is an optional parameter. If "DefaultCalendar" is set to true, |
|
286 // GetList returns the list with one element (default calendar) else it |
|
287 // returns a list of all calendars. |
|
288 var filter = new Object(); |
|
289 filter.DefaultCalendar = false; |
|
290 |
|
291 var criteria = new Object(); |
|
292 criteria.Type = "Calendar"; |
|
293 criteria.Filter = filter; |
|
294 |
|
295 try { |
|
296 imgid_callback1 = imgId; |
|
297 var result = so.IDataSource.GetList(criteria); |
|
298 if(!checkError("IDataSource::getCalendar",result,DIV_ID,imgId)) { |
|
299 document.getElementById(DIV_ID).innerHTML = showIterableList(result.ReturnValue); |
|
300 } |
|
301 } |
|
302 catch (e) { |
|
303 showIMG(imgId,"no"); |
|
304 alert ("getCalendar: " + e); |
|
305 } |
|
306 } |
|
307 |
|
308 // Get Meeting |
|
309 function getMeeting(imgId) |
|
310 { |
|
311 var filter = new Object(); |
|
312 filter.Type = "Meeting"; |
|
313 |
|
314 var criteria = new Object(); |
|
315 criteria.Type = "CalendarEntry"; |
|
316 criteria.Filter = filter; |
|
317 |
|
318 try { |
|
319 var result = so.IDataSource.GetList(criteria); |
|
320 if(!checkError("IDataSource::getMeeting",result,DIV_ID,imgId)) { |
|
321 var msg = ""; |
|
322 var meetingObj; |
|
323 var meetingIt = result.ReturnValue; |
|
324 while ((meetingObj = meetingIt.getNext()) != undefined) |
|
325 { |
|
326 msg = msg + "Type: " + meetingObj['Type'] + "<br>"; |
|
327 msg = msg + "Summary: " + meetingObj['Summary'] + "<br>"; |
|
328 msg = msg + "StartTime: " + meetingObj['StartTime'] + "<br>"; |
|
329 msg = msg + "EndTime: " + meetingObj['EndTime'] + "<br>"; |
|
330 msg = msg + "Id: " + meetingObj['Id'] + "<br>"; |
|
331 msg = msg + "LocalId: " + meetingObj['LocalId'] +"<br><br>"; |
|
332 } |
|
333 meetingIt.reset(); |
|
334 document.getElementById(DIV_ID).innerHTML = msg; |
|
335 } |
|
336 } |
|
337 catch (e) { |
|
338 showIMG(imgId,"no"); |
|
339 alert ("getCalendar: " + e); |
|
340 } |
|
341 } |
|
342 |
|
343 //Delete Calendar |
|
344 function delCalendar(imgId) |
|
345 { |
|
346 var calName = prompt("Please enter the calendar name", "C:myCalendar"); |
|
347 if(calName == "" || calName == null) |
|
348 return; |
|
349 |
|
350 var delData = new Object(); |
|
351 delData.CalendarName = calName; |
|
352 |
|
353 var criteria = new Object(); |
|
354 criteria.Type = "Calendar"; |
|
355 criteria.Data = delData; |
|
356 |
|
357 try { |
|
358 var result = so.IDataSource.Delete(criteria); |
|
359 checkError("IDataSource::delCalendar",result,DIV_ID,imgId); |
|
360 } |
|
361 catch (e) { |
|
362 showIMG(imgId,"no"); |
|
363 alert ("delCalendar: " + e); |
|
364 } |
|
365 } |
|
366 |
|
367 //Delete All Entries in Default Calendar |
|
368 function delAllEntry(imgId) |
|
369 { |
|
370 var delData = new Object(); |
|
371 delData.DeleteAll = true; |
|
372 |
|
373 var criteria = new Object(); |
|
374 criteria.Type = "CalendarEntry"; |
|
375 criteria.Data = delData; |
|
376 |
|
377 try { |
|
378 var result = so.IDataSource.Delete(criteria); |
|
379 checkError("IDataSource::delAllEntry",result,DIV_ID,imgId); |
|
380 } |
|
381 catch (e) { |
|
382 showIMG(imgId,"no"); |
|
383 alert ("delAllEntry: " + e); |
|
384 } |
|
385 } |
|
386 |
|
387 //Delete All Entries in Default Calendar Async |
|
388 function delAllEntryAsync(imgId) |
|
389 { |
|
390 var delData = new Object(); |
|
391 delData.DeleteAll = true; |
|
392 |
|
393 var criteria = new Object(); |
|
394 criteria.Type = "CalendarEntry"; |
|
395 criteria.Data = delData; |
|
396 |
|
397 try { |
|
398 imgid_callback4 = imgId; |
|
399 var result = so.IDataSource.Delete(criteria, callback4); |
|
400 if(!checkError("IDataSource::delAllEntryAsync",result,DIV_ID,imgId)); |
|
401 showIMG(imgId, ""); |
|
402 } |
|
403 catch (e) { |
|
404 showIMG(imgId,"no"); |
|
405 alert ("delAllEntryAsync: " + e); |
|
406 } |
|
407 } |
|
408 |
|
409 // Import Entry |
|
410 function importEntry(imgId) { |
|
411 |
|
412 var fileName = "c:\\data\\calendarFile"; |
|
413 |
|
414 var impData = new Object(); |
|
415 impData.Format = "VCal"; |
|
416 impData.FileName = fileName; |
|
417 |
|
418 var criteria = new Object(); |
|
419 criteria.Type = "CalendarEntry"; |
|
420 criteria.Data = impData; |
|
421 |
|
422 try { |
|
423 var result = so.IDataSource.Import(criteria); |
|
424 checkError("IDataSource::Import",result,DIV_ID,imgId); |
|
425 } |
|
426 catch (e) { |
|
427 showIMG(imgId,"no"); |
|
428 alert ("importEntry: " + e); |
|
429 } |
|
430 } |
|
431 |
|
432 // Export Entry |
|
433 function exportEntry(imgId) { |
|
434 |
|
435 var fileName = "c:\\data\\calendarFile"; |
|
436 |
|
437 var exData = new Object(); |
|
438 exData.Format = "VCal"; |
|
439 exData.FileName = fileName; |
|
440 |
|
441 var criteria = new Object(); |
|
442 criteria.Type = "CalendarEntry"; |
|
443 criteria.Data = exData; |
|
444 |
|
445 try { |
|
446 var result = so.IDataSource.Export(criteria); |
|
447 checkError("IDataSource::Export",result,DIV_ID,imgId); |
|
448 } |
|
449 catch (e) { |
|
450 showIMG(imgId,"no"); |
|
451 alert ("exportEntry: " + e); |
|
452 } |
|
453 } |
|
454 |
|
455 // Import Entry Async |
|
456 function importEntryAsync(imgId) { |
|
457 |
|
458 var fileName = "c:\\data\\calendarFile"; |
|
459 |
|
460 var impData = new Object(); |
|
461 impData.Format = "VCal"; |
|
462 impData.FileName = fileName; |
|
463 |
|
464 var criteria = new Object(); |
|
465 criteria.Type = "CalendarEntry"; |
|
466 criteria.Data = impData; |
|
467 |
|
468 try { |
|
469 imgid_callback1 = imgId; |
|
470 var result = so.IDataSource.Import(criteria, callback1); |
|
471 if(!checkError("IDataSource::ImportAsync",result,DIV_ID,imgId)) |
|
472 showIMG(imgId, ""); |
|
473 } |
|
474 catch (e) { |
|
475 showIMG(imgId,"no"); |
|
476 alert ("importEntryAsync: " + e); |
|
477 } |
|
478 } |
|
479 |
|
480 // Export Entry Async |
|
481 function exportEntryAsync(imgId) { |
|
482 |
|
483 var fileName = "c:\\data\\calendarFile"; |
|
484 |
|
485 var exData = new Object(); |
|
486 exData.Format = "VCal"; |
|
487 exData.FileName = fileName; |
|
488 |
|
489 var criteria = new Object(); |
|
490 criteria.Type = "CalendarEntry"; |
|
491 criteria.Data = exData; |
|
492 |
|
493 try { |
|
494 imgid_callback2 = imgId; |
|
495 var result = so.IDataSource.Export(criteria, callback2); |
|
496 if(!checkError("IDataSource::ExportAsync",result,DIV_ID,imgId)) |
|
497 showIMG(imgId, ""); |
|
498 } |
|
499 catch (e) { |
|
500 showIMG(imgId,"no"); |
|
501 alert ("exportEntryAsync: " + e); |
|
502 } |
|
503 } |
|
504 |
|
505 // Cancel Import Entry Async |
|
506 function cancelImportEntryAsync(imgId) { |
|
507 |
|
508 var fileName = "c:\\data\\calendarFile"; |
|
509 |
|
510 var impData = new Object(); |
|
511 impData.Format = "VCal"; |
|
512 impData.FileName = fileName; |
|
513 |
|
514 var criteria = new Object(); |
|
515 criteria.Type = "CalendarEntry"; |
|
516 criteria.Data = impData; |
|
517 |
|
518 try { |
|
519 imgid_callback1 = imgId; |
|
520 var result = so.IDataSource.Import(criteria, callback1); |
|
521 if(!checkError("IDataSource::CancelImportAsync",result,DIV_ID,imgId)) { |
|
522 showIMG(imgId, ""); |
|
523 var criteria2 = new Object(); |
|
524 criteria2.TransactionID = result.TransactionID; |
|
525 var cresult = so.IDataSource.Cancel(criteria2); |
|
526 checkError("IDataSource::CancelImportAsync",cresult,DIV_ID,imgId); |
|
527 } |
|
528 } |
|
529 catch (e) { |
|
530 showIMG(imgId,"no"); |
|
531 alert ("cancelImportEntryAsync: " + e); |
|
532 } |
|
533 } |
|
534 |
|
535 // Cancel Export Entry Async |
|
536 function cancelExportEntryAsync(imgId) { |
|
537 |
|
538 var fileName = "c:\\data\\calendarFile"; |
|
539 |
|
540 var exData = new Object(); |
|
541 exData.Format = "VCal"; |
|
542 exData.FileName = fileName; |
|
543 |
|
544 var criteria = new Object(); |
|
545 criteria.Type = "CalendarEntry"; |
|
546 criteria.Data = exData; |
|
547 |
|
548 try { |
|
549 imgid_callback2 = imgId; |
|
550 var result = so.IDataSource.Export(criteria, callback2); |
|
551 if(!checkError("IDataSource::CancelExportAsync",result,DIV_ID,imgId)){ |
|
552 showIMG(imgId, ""); |
|
553 var criteria2 = new Object(); |
|
554 criteria2.TransactionID = result.TransactionID; |
|
555 var cresult = so.IDataSource.Cancel(criteria2); |
|
556 checkError("IDataSource::CancelExportAsync",cresult,DIV_ID,imgId); |
|
557 } |
|
558 } |
|
559 catch (e) { |
|
560 showIMG(imgId,"no"); |
|
561 alert ("cancelExportEntryAsync: " + e); |
|
562 } |
|
563 } |
|
564 |
|
565 // Request Notification |
|
566 function requestNotification(imgId) { |
|
567 |
|
568 var criteria = new Object(); |
|
569 criteria.Type = "CalendarEntry"; |
|
570 |
|
571 try { |
|
572 imgid_callback3 = imgId; |
|
573 var result = so.IDataSource.RequestNotification(criteria, callback3); |
|
574 checkError("IDataSource::requestNotification",result,DIV_ID,imgId); |
|
575 } |
|
576 catch (e) { |
|
577 showIMG(imgId,"no"); |
|
578 alert ("requestNotification: " + e); |
|
579 } |
|
580 } |
|
581 |
|
582 // Cancel Request Notification |
|
583 function cancelRequestNotification(imgId) { |
|
584 |
|
585 var criteria = new Object(); |
|
586 criteria.Type = "CalendarEntry"; |
|
587 |
|
588 try { |
|
589 imgid_callback3 = imgId; |
|
590 var result = so.IDataSource.RequestNotification(criteria, callback3); |
|
591 if(!checkError("IDataSource::CancelRequestNotification",result,DIV_ID,imgId)){ |
|
592 showIMG(imgId, ""); |
|
593 var criteria2 = new Object(); |
|
594 criteria2.TransactionID = result.TransactionID; |
|
595 var cresult = so.IDataSource.Cancel(criteria2); |
|
596 checkError("IDataSource::CancelRequestNotification",cresult,DIV_ID,imgId); |
|
597 } |
|
598 } |
|
599 catch (e) { |
|
600 showIMG(imgId,"no"); |
|
601 alert ("CancelRequestNotification: " + e); |
|
602 } |
|
603 } |
|
604 |
|
605 // This is the asynchronous callback handler |
|
606 function callback1(transId, eventCode, result) |
|
607 { |
|
608 console.info("callback1: transId: %d eventCode: %d result.ErrorCode: %d", transId, eventCode, result.ErrorCode); |
|
609 checkError("IDataSource::ImportAsync",result,DIV_ID,imgid_callback1); |
|
610 } |
|
611 |
|
612 // This is the asynchronous callback handler |
|
613 function callback2(transId, eventCode, result) |
|
614 { |
|
615 console.info("callback2: transId: %d eventCode: %d result.ErrorCode: %d", transId, eventCode, result.ErrorCode); |
|
616 checkError("IDataSource::ExportAsync",result,DIV_ID,imgid_callback2); |
|
617 } |
|
618 |
|
619 // This is the asynchronous callback handler |
|
620 function callback3(transId, eventCode, result) |
|
621 { |
|
622 console.info("callback3: transId: %d eventCode: %d result.ErrorCode: %d", transId, eventCode, result.ErrorCode); |
|
623 if(!checkError("IDataSource::Notification",result,DIV_ID,imgid_callback3)) { |
|
624 document.getElementById(DIV_ID).innerHTML = showIterableList(result.ReturnValue); |
|
625 } |
|
626 } |
|
627 |
|
628 // This is the asynchronous callback handler |
|
629 function callback4(transId, eventCode, result) |
|
630 { |
|
631 console.info("callback4: transId: %d eventCode: %d result.ErrorCode: %d", transId, eventCode, result.ErrorCode); |
|
632 if(!checkError("IDataSource::delAllEntryAsync",result,DIV_ID,imgid_callback4)) { |
|
633 document.getElementById(DIV_ID).innerHTML = showIterableList(result.ReturnValue); |
|
634 } |
|
635 }</pre> |
|
636 </div> |
|
637 </div></div></div><div class="footer"><hr/><div class="copy">© Nokia 2009.</div></div></body></html> |