var reqV = null; \r
var settingsCalEntryId = null;\r
var settingsCache = null;\r
-var notificationRequest1;\r
-var notificationRequest2;\r
+var notificationRequests = new Array();\r
var calendarList = [];\r
\r
// vars for daylight saving time\r
{\r
var criteria = new Object();\r
criteria.Type = "CalendarEntry";\r
-\r
- try {\r
- notificationRequest1 = calendarService.IDataSource.RequestNotification(criteria, callback);\r
- if (notificationRequest1.ErrorCode)\r
- error('requestNotification failed with error code ' + notificationRequest1.ErrorCode);\r
- } catch (e) {\r
- error("requestNotification: " + e + ', line ' + e.line);\r
+ criteria.Filter = new Object();\r
+ for(var i=0; i < calendarList.length; i++) {\r
+ criteria.Filter.CalendarName = calendarList[i];\r
+ try {\r
+ var notificationRequest = calendarService.IDataSource.RequestNotification(criteria, callback);\r
+ if (notificationRequest.ErrorCode)\r
+ error('requestNotification failed with error code ' + notificationRequest.ErrorCode);\r
+ notificationRequests.push(notificationRequest);\r
+ } catch (e) {\r
+ error("requestNotification: " + e + ', line ' + e.line);\r
+ }\r
}\r
\r
var criteria2 = new Object();\r
criteria2.Filter = new Object();\r
criteria2.Filter.LocalIdList = new Array();\r
criteria2.Filter.LocalIdList[0] = settingsCalEntryId;\r
-\r
try {\r
- notificationRequest2 = calendarService.IDataSource.RequestNotification(criteria2, settingsCallback);\r
- if (notificationRequest2.ErrorCode)\r
- error('requestNotification failed with error code ' + notificationRequest2.ErrorCode);\r
+ var notificationRequest = calendarService.IDataSource.RequestNotification(criteria2, settingsCallback);\r
+ if (notificationRequest.ErrorCode)\r
+ error('requestNotification failed with error code ' + notificationRequest.ErrorCode);\r
+ notificationRequests.push(notificationRequest);\r
} catch (e) {\r
error("requestNotification: " + e + ', line ' + e.line);\r
}\r
}\r
\r
+function cancelNotification()\r
+{\r
+ for(var i=0; i < notificationRequests.length; i++) {\r
+ try {\r
+ var result = calendarService.IDataSource.Cancel(notificationRequests[i]);\r
+ if (result.ErrorCode)\r
+ error('requestNotification failed with error code ' + result.ErrorCode);\r
+ } catch (e) {\r
+ error("requestNotification: " + e + ', line ' + e.line);\r
+ }\r
+ }\r
+}\r
+\r
function callback(transId, eventCode, result)\r
{\r
console.info("callback(): panelNum: %d transId: %d eventCode: %d result.ErrorCode: %d", panelNum, transId, eventCode, result.ErrorCode);\r
function updateData()\r
{\r
console.info('updateData()');\r
+\r
+ // check if we got additional or less calendars since our last update\r
+ var newCalendarList = listCalendars();\r
+ if (newCalendarList.length != calendarList.length) {\r
+ calendarList = newCalendarList;\r
+ cancelNotification();\r
+ requestNotification();\r
+ }\r
+ \r
try {\r
// meetings have time\r
// note: anniveraries have a start time of 12:00am. So since we want to include them, we have to query the whole day and check if events have passed later\r