42
|
1 |
/**
|
|
2 |
* Logging.js
|
|
3 |
*
|
|
4 |
* Nokia Web Runtime Service API emulation
|
|
5 |
* WRT v1.1
|
|
6 |
*
|
|
7 |
* Copyright 2009 Nokia Corporation. All rights reserved.
|
|
8 |
*/
|
|
9 |
|
|
10 |
|
|
11 |
(function(){
|
|
12 |
|
|
13 |
var provider = 'Service.Logging',
|
|
14 |
Interface = 'IDataSource';
|
|
15 |
|
|
16 |
/**
|
|
17 |
* Landmark service
|
|
18 |
*/
|
|
19 |
var LoggingService = function(){
|
|
20 |
this.Add = __Add;
|
|
21 |
this.GetList = __GetList;
|
|
22 |
this.Delete = __Delete;
|
|
23 |
this.RequestNotification = __RequestNotification;
|
|
24 |
this.Cancel = __Cancel;
|
|
25 |
|
|
26 |
}
|
|
27 |
|
|
28 |
device.implementation.extend(provider, Interface, new LoggingService() );
|
|
29 |
|
|
30 |
|
|
31 |
/******************************************************/
|
|
32 |
/******************************************************/
|
|
33 |
/******************************************************/
|
|
34 |
|
|
35 |
var context = device.implementation.context,
|
|
36 |
_t = context._t,
|
|
37 |
method = '',
|
|
38 |
result = false,
|
|
39 |
DBase = null;
|
|
40 |
|
|
41 |
var transactionIds = new Array();
|
|
42 |
var tTransactionId = -1;
|
|
43 |
var isTraceInProgress = false;
|
|
44 |
var criteriaReq;
|
|
45 |
var callbackReq;
|
|
46 |
|
|
47 |
/**
|
|
48 |
* Logging: Add
|
|
49 |
* @param {Object} criteria
|
|
50 |
* @param (function) callback
|
|
51 |
*/
|
|
52 |
function __Add(criteria, callback, flag){
|
|
53 |
method = "Add";
|
|
54 |
// Async call
|
|
55 |
flag = flag || false;
|
|
56 |
|
|
57 |
if (!flag) {
|
|
58 |
var result = ValidateAdd(criteria, callback);
|
|
59 |
if (result.ErrorCode != 0)
|
|
60 |
return result;
|
|
61 |
}
|
|
62 |
|
|
63 |
|
|
64 |
if(typeof callback == 'function')
|
|
65 |
{
|
|
66 |
return context.callAsync(this, arguments.callee, criteria, callback);
|
|
67 |
}
|
|
68 |
DBase = context.getData(provider);
|
|
69 |
var returnValue = DBase[criteria.Type];
|
|
70 |
criteria.Item.id = GenerateRandomNumber()+'';
|
|
71 |
criteria.Item["EventTime"] = GetCurrDate();
|
|
72 |
returnValue.push(criteria.Item);
|
|
73 |
return context.Result(criteria.Item.id,0);
|
|
74 |
}
|
|
75 |
|
|
76 |
/**
|
|
77 |
* Logging: GetList
|
|
78 |
* @param {Object} criteria
|
|
79 |
* @param (function) callback
|
|
80 |
*/
|
|
81 |
function __GetList(criteria, callback, flag){
|
|
82 |
method = "GetList";
|
|
83 |
// Async call
|
|
84 |
flag = flag || false;
|
|
85 |
|
|
86 |
if (!flag) {
|
|
87 |
var result = ValidateGetList(criteria, callback);
|
|
88 |
if (result.ErrorCode != 0)
|
|
89 |
return result;
|
|
90 |
}
|
|
91 |
|
|
92 |
|
|
93 |
if(typeof callback == 'function')
|
|
94 |
{
|
|
95 |
return context.callAsync(this, arguments.callee, criteria, callback);
|
|
96 |
}
|
|
97 |
if(criteria.Filter){
|
|
98 |
context.notify(_t('%s:: GetList : filter not implemented in preview').arg(provider));
|
|
99 |
}
|
|
100 |
|
|
101 |
DBase = context.getData(provider);
|
|
102 |
var returnValue;
|
|
103 |
// @todo: apply filter criteria
|
|
104 |
returnValue = context.Iterator( DBase[criteria.Type] || [] );
|
|
105 |
|
|
106 |
return context.Result(returnValue,0);
|
|
107 |
}
|
|
108 |
|
|
109 |
/**
|
|
110 |
* Logging: Delete
|
|
111 |
* @param {Object} criteria
|
|
112 |
* @param (function) callback
|
|
113 |
*/
|
|
114 |
function __Delete(criteria, callback, flag){
|
|
115 |
method = "Delete";
|
|
116 |
// Async call
|
|
117 |
flag = flag || false;
|
|
118 |
if (!flag) {
|
|
119 |
if (!criteria || !criteria.Type)
|
|
120 |
return error(device.implementation.ERR_MISSING_ARGUMENT, msg.msgTypeMissing);
|
|
121 |
|
|
122 |
if (typeof criteria.Type != 'string')
|
|
123 |
return error(device.implementation.ERR_BAD_ARGUMENT_TYPE, msg.msgTypeInvalid);
|
|
124 |
|
|
125 |
if (criteria.Type != 'Log')
|
|
126 |
return error(device.implementation.ERR_INVALID_SERVICE_ARGUMENT, msg.msgTypeInvalid);
|
|
127 |
|
|
128 |
if (!criteria.Data)
|
|
129 |
return error(device.implementation.ERR_MISSING_ARGUMENT, msg.msgDataMissing);
|
|
130 |
|
|
131 |
if(typeof criteria.Data != 'object')
|
|
132 |
return error(device.implementation.ERR_INVALID_SERVICE_ARGUMENT, msg.msgDataInvalid);
|
|
133 |
|
|
134 |
if(typeof criteria.Data.id == 'undefined')
|
|
135 |
return error(device.implementation.ERR_MISSING_ARGUMENT, msg.msgid);
|
|
136 |
|
|
137 |
if (typeof criteria.Data.id != "string")
|
|
138 |
return error(device.implementation.ERR_BAD_ARGUMENT_TYPE, msg.msgidInvalid);
|
|
139 |
|
|
140 |
if(criteria.Data.id == '')
|
|
141 |
return error(device.implementation.ERR_INVALID_SERVICE_ARGUMENT, msg.msgidInvalid);
|
|
142 |
}
|
|
143 |
DBase = context.getData(provider);
|
|
144 |
var returnValue,found = false;
|
|
145 |
returnValue = DBase[criteria.Type];
|
|
146 |
for(var i=0; i<returnValue.length; i++){
|
|
147 |
if(returnValue[i].id == criteria.Data.id)
|
|
148 |
{
|
|
149 |
found = true;
|
|
150 |
returnValue.splice(i,1);
|
|
151 |
}
|
|
152 |
}
|
|
153 |
if(!found)
|
|
154 |
return error(device.implementation.ERR_NOT_FOUND, msg.msgidInvalid);
|
|
155 |
|
|
156 |
return context.Result(undefined,0);
|
|
157 |
}
|
|
158 |
|
|
159 |
/**
|
|
160 |
* Logging: RequestNotification
|
|
161 |
* @param {Object} criteria
|
|
162 |
* @param (function) callback
|
|
163 |
*/
|
|
164 |
function __RequestNotification(criteria, callback, flag){
|
|
165 |
method = "RequestNotification";
|
|
166 |
|
|
167 |
// Async call
|
|
168 |
flag = flag || false;
|
|
169 |
if (!flag) {
|
|
170 |
if (!criteria || !criteria.Type)
|
|
171 |
return error(device.implementation.ERR_MISSING_ARGUMENT, msg.msgTypeMissing);
|
|
172 |
|
|
173 |
if (typeof criteria.Type != 'string')
|
|
174 |
return error(device.implementation.ERR_BAD_ARGUMENT_TYPE, msg.msgTypeInvalid);
|
|
175 |
|
|
176 |
if (criteria.Type != 'Log')
|
|
177 |
return error(device.implementation.ERR_INVALID_SERVICE_ARGUMENT, msg.msgTypeInvalid);
|
|
178 |
|
|
179 |
if (!criteria.Filter)
|
|
180 |
return error(device.implementation.ERR_MISSING_ARGUMENT, msg.msgFilterMissing);
|
|
181 |
|
|
182 |
if(typeof criteria.Filter != 'object')
|
|
183 |
return error(device.implementation.ERR_INVALID_SERVICE_ARGUMENT, msg.msgFilterInvalid);
|
|
184 |
|
|
185 |
if(typeof criteria.Filter.DelayTime == 'undefined')
|
|
186 |
return error(device.implementation.ERR_MISSING_ARGUMENT, msg.msgDelayTimeMissing);
|
|
187 |
|
|
188 |
if(typeof criteria.Filter.DelayTime != 'number')
|
|
189 |
return error(device.implementation.ERR_BAD_ARGUMENT_TYPE, msg.msgDelayTimeInvalid);
|
|
190 |
if(criteria.Filter.DelayTime <= 0)
|
|
191 |
return error(device.implementation.ERR_INVALID_SERVICE_ARGUMENT, msg.msgDelayTimeInvalid);
|
|
192 |
|
|
193 |
if(criteria.Filter.DelayTime < 1000000 )
|
|
194 |
{
|
|
195 |
criteria.Filter.DelayTime = 1000000;
|
|
196 |
context.notify(_t('%s:: RequestNotification : Using DelayTime = 1000000').arg(provider));
|
|
197 |
}
|
|
198 |
}
|
|
199 |
if(typeof callback != 'function')
|
|
200 |
return error(device.implementation.ERR_INVALID_SERVICE_ARGUMENT, msg.msgMissingCallback);
|
|
201 |
|
|
202 |
criteriaReq = criteria;
|
|
203 |
callbackReq = callback;
|
|
204 |
isTraceInProgress = true;
|
|
205 |
|
|
206 |
return notificationCall(criteria,callback);
|
|
207 |
}
|
|
208 |
|
|
209 |
/**
|
|
210 |
* Logging: Cancel
|
|
211 |
* @param {Object} criteria
|
|
212 |
* @param (function) callback
|
|
213 |
*/
|
|
214 |
function __Cancel(criteria){
|
|
215 |
method = "Cancel";
|
|
216 |
if (!criteria || typeof criteria.TransactionID == 'undefined')
|
|
217 |
return error(device.implementation.ERR_MISSING_ARGUMENT, msg.msgTransactionIdMissing);
|
|
218 |
|
|
219 |
if (typeof criteria.TransactionID != 'number')
|
|
220 |
return error(device.implementation.ERR_INVALID_SERVICE_ARGUMENT, msg.msgTransactionIdInvalid);
|
|
221 |
|
|
222 |
clearTimeout(criteria.TransactionID);
|
|
223 |
if (criteria.TransactionID == tTransactionId) {
|
|
224 |
isTraceInProgress = false;
|
|
225 |
tTransactionId = -1;
|
|
226 |
}
|
|
227 |
return context.ErrorResult(device.implementation.ERR_SUCCESS);
|
|
228 |
|
|
229 |
}
|
|
230 |
|
|
231 |
|
|
232 |
/**
|
|
233 |
* Location: error
|
|
234 |
* @param {number,string} ErrorCode and ErrorString
|
|
235 |
* Replaces Error String with method name
|
|
236 |
*/
|
|
237 |
function error(code, msg /*, args...*/){
|
|
238 |
|
|
239 |
var args = ['Logging',method].concat([].slice.call(arguments,2));
|
|
240 |
msg = msg ? _t().arg.apply(msg,args) : undefined;
|
|
241 |
return context.ErrorResult(code, msg);
|
|
242 |
}
|
|
243 |
|
|
244 |
/**
|
|
245 |
* Logging: notificationCall
|
|
246 |
* @param {}
|
|
247 |
* This function Calls callback function after given delay
|
|
248 |
*/
|
|
249 |
function notificationCall(){
|
|
250 |
var tid = setTimeout(function(){
|
|
251 |
if(!isTraceInProgress)
|
|
252 |
return;
|
|
253 |
|
|
254 |
DBase = context.getData(provider);
|
|
255 |
var returnValue;
|
|
256 |
returnValue = context.Iterator( DBase[criteriaReq.Type] || [] );
|
|
257 |
|
|
258 |
var result,
|
|
259 |
eventCode = {completed:2, error:4, progress:9},
|
|
260 |
code = eventCode.completed;
|
|
261 |
|
|
262 |
callbackReq(tTransactionId,code,context.Result(returnValue,0));
|
|
263 |
//notificationCall();
|
|
264 |
}, criteriaReq.Filter.DelayTime/1000);
|
|
265 |
if(tTransactionId == -1)
|
|
266 |
tTransactionId = tid;
|
|
267 |
return context.AsyncResult(tTransactionId);
|
|
268 |
}
|
|
269 |
|
|
270 |
/**
|
|
271 |
* Helper functions
|
|
272 |
*/
|
|
273 |
|
|
274 |
/**
|
|
275 |
* GenerateRandomNumber
|
|
276 |
* @param {}array of log data for getting unique ID
|
|
277 |
*
|
|
278 |
*/
|
|
279 |
function GenerateRandomNumber(arr)
|
|
280 |
{
|
|
281 |
var randomnumber = Math.floor(Math.random() * 10001);
|
|
282 |
randomnumber +=200;
|
|
283 |
return randomnumber;
|
|
284 |
}
|
|
285 |
|
|
286 |
/**
|
|
287 |
* GetCurrDate
|
|
288 |
* @param {}Gets date in internet format
|
|
289 |
*
|
|
290 |
*/
|
|
291 |
function GetCurrDate()
|
|
292 |
{
|
|
293 |
var d_names = new Array("Sunday", "Monday", "Tuesday",
|
|
294 |
"Wednesday", "Thursday", "Friday", "Saturday");
|
|
295 |
|
|
296 |
var m_names = new Array("January", "February", "March",
|
|
297 |
"April", "May", "June", "July", "August", "September",
|
|
298 |
"October", "November", "December");
|
|
299 |
|
|
300 |
var ampm = "am";
|
|
301 |
|
|
302 |
var d = new Date();
|
|
303 |
var curr_day = d.getDay();
|
|
304 |
var curr_date = d.getDate();
|
|
305 |
if(curr_date <10)
|
|
306 |
curr_date = "0"+curr_date;
|
|
307 |
var curr_month = d.getMonth();
|
|
308 |
var curr_year = d.getFullYear();
|
|
309 |
var curr_hour = d.getHours();
|
|
310 |
if(curr_hour > 11)
|
|
311 |
{
|
|
312 |
ampm = "pm";
|
|
313 |
}
|
|
314 |
else if(curr_hour <10)
|
|
315 |
{
|
|
316 |
curr_hour = "0"+curr_hour;
|
|
317 |
}
|
|
318 |
var curr_min = d.getMinutes();
|
|
319 |
if(curr_min <10)
|
|
320 |
curr_min = "0"+curr_min;
|
|
321 |
|
|
322 |
var curr_sec = d.getSeconds();
|
|
323 |
if(curr_sec <10)
|
|
324 |
curr_sec = "0"+curr_sec;
|
|
325 |
|
|
326 |
var strDate = d_names[curr_day]+', '+curr_date+' '+m_names[curr_month]+', '+curr_year+' '+curr_hour+':'+curr_min+':'+curr_sec+' '+ampm;
|
|
327 |
return strDate;
|
|
328 |
}
|
|
329 |
|
|
330 |
/**
|
|
331 |
* ValidateAdd
|
|
332 |
* @param {object,function}
|
|
333 |
* Validates ADD arguments
|
|
334 |
*/
|
|
335 |
function ValidateAdd(criteria,callback)
|
|
336 |
{
|
|
337 |
var type;
|
|
338 |
if(!criteria || !criteria.Type)
|
|
339 |
return error(device.implementation.ERR_MISSING_ARGUMENT,msg.msgTypeMissing);
|
|
340 |
|
|
341 |
if (typeof criteria.Type != 'string')
|
|
342 |
return error(device.implementation.ERR_BAD_ARGUMENT_TYPE, msg.msgTypeInvalid);
|
|
343 |
|
|
344 |
if(criteria.Type != 'Log')
|
|
345 |
return error(device.implementation.ERR_INVALID_SERVICE_ARGUMENT,msg.msgTypeInvalid);
|
|
346 |
|
|
347 |
if (!criteria.Item)
|
|
348 |
return error(device.implementation.ERR_MISSING_ARGUMENT, msg.msgItemMissing);
|
|
349 |
|
|
350 |
if(typeof criteria.Item != 'object')
|
|
351 |
return error(device.implementation.ERR_INVALID_SERVICE_ARGUMENT, msg.msgItemInvalid);
|
|
352 |
|
|
353 |
|
|
354 |
if(typeof criteria.Item.EventType == "undefined")
|
|
355 |
return error(device.implementation.ERR_MISSING_ARGUMENT,msg.msgEventTypeMissing);
|
|
356 |
|
|
357 |
if(typeof criteria.Item.EventType != "number" )
|
|
358 |
return error(device.implementation.ERR_BAD_ARGUMENT_TYPE,msg.msgEventTypeInvalid);
|
|
359 |
|
|
360 |
if(typeof criteria.Item.EventType == "number" && !(criteria.Item.EventType >=0 && criteria.Item.EventType <=4))
|
|
361 |
return error(device.implementation.ERR_INVALID_SERVICE_ARGUMENT,msg.msgEventTypeInvalid);
|
|
362 |
|
|
363 |
type = typeof criteria.Item.RemoteParty;
|
|
364 |
if(type != 'undefined' && type != "string")
|
|
365 |
return error(device.implementation.ERR_BAD_ARGUMENT_TYPE,msg.msgRemotePartyInvalid);
|
|
366 |
|
|
367 |
type = typeof criteria.Item.Direction;
|
|
368 |
if (type != 'undefined') {
|
|
369 |
if (type != "number")
|
|
370 |
return error(device.implementation.ERR_BAD_ARGUMENT_TYPE, msg.msgDirectionInvalid);
|
|
371 |
|
|
372 |
if (type == "number" && (criteria.Item.Direction < 0 || criteria.Item.Direction > 6))
|
|
373 |
return error(device.implementation.ERR_INVALID_SERVICE_ARGUMENT, msg.msgDirectionInvalid);
|
|
374 |
}
|
|
375 |
|
|
376 |
type = typeof criteria.Item.EventDuration;
|
|
377 |
if(type != 'undefined' && type != "number")
|
|
378 |
return error(device.implementation.ERR_BAD_ARGUMENT_TYPE,msg.msgEventDurationInvalid);
|
|
379 |
|
|
380 |
type = typeof criteria.Item.DeliveryStatus;
|
|
381 |
if (type != 'undefined') {
|
|
382 |
if (type != "number")
|
|
383 |
return error(device.implementation.ERR_BAD_ARGUMENT_TYPE, msg.msgDeliveryStatusInvalid);
|
|
384 |
|
|
385 |
if (type == "number" && (criteria.Item.DeliveryStatus < 0 || criteria.Item.DeliveryStatus > 6))
|
|
386 |
return error(device.implementation.ERR_INVALID_SERVICE_ARGUMENT, msg.msgDeliveryStatusInvalid);
|
|
387 |
}
|
|
388 |
|
|
389 |
type = typeof criteria.Item.Subject;
|
|
390 |
if(type != 'undefined' && type != "string")
|
|
391 |
return error(device.implementation.ERR_BAD_ARGUMENT_TYPE,msg.msgSubjectInvalid);
|
|
392 |
|
|
393 |
type = typeof criteria.Item.PhoneNumber;
|
|
394 |
if(type != 'undefined' && type != "string")
|
|
395 |
return error(device.implementation.ERR_BAD_ARGUMENT_TYPE,msg.msgPhoneNumberInvalid);
|
|
396 |
|
|
397 |
type = typeof criteria.Item.Link;
|
|
398 |
if(type != 'undefined' && type != "number")
|
|
399 |
return error(device.implementation.ERR_BAD_ARGUMENT_TYPE,msg.msgLinkInvalid);
|
|
400 |
|
|
401 |
type = typeof criteria.Item.LogFlags;
|
|
402 |
if(type != 'undefined' && (type != "number" || (criteria.Item.LogFlags != 1 && criteria.Item.LogFlags != 0)))
|
|
403 |
return error(device.implementation.ERR_BAD_ARGUMENT_TYPE,msg.msgLogFlagsInvalid);
|
|
404 |
|
|
405 |
return context.ErrorResult(device.implementation.ERR_SUCCESS, "");
|
|
406 |
}
|
|
407 |
|
|
408 |
/**
|
|
409 |
* ValidateGetList
|
|
410 |
* @param {object,function}
|
|
411 |
* Validates GetList function
|
|
412 |
*/
|
|
413 |
function ValidateGetList(criteria,callback)
|
|
414 |
{
|
|
415 |
var type;
|
|
416 |
if(!criteria || !criteria.Type)
|
|
417 |
return error(device.implementation.ERR_MISSING_ARGUMENT,msg.msgTypeMissing);
|
|
418 |
|
|
419 |
if (typeof criteria.Type != 'string')
|
|
420 |
return error(device.implementation.ERR_BAD_ARGUMENT_TYPE, msg.msgTypeInvalid);
|
|
421 |
|
|
422 |
if(criteria.Type != 'Log')
|
|
423 |
return error(device.implementation.ERR_INVALID_SERVICE_ARGUMENT,msg.msgTypeInvalid);
|
|
424 |
|
|
425 |
type = typeof criteria.Filter;
|
|
426 |
if(type != 'undefined' && type != "object")
|
|
427 |
return error(device.implementation.ERR_BAD_ARGUMENT_TYPE,msg.msgFilterInvalid);
|
|
428 |
|
|
429 |
if(type == 'undefined')
|
|
430 |
return context.ErrorResult(device.implementation.ERR_SUCCESS, "");
|
|
431 |
|
|
432 |
type = typeof criteria.Filter.id;
|
|
433 |
if(type != 'undefined' && type != "string")
|
|
434 |
return error(device.implementation.ERR_BAD_ARGUMENT_TYPE,msg.msgid);
|
|
435 |
|
|
436 |
if(type != 'undefined')
|
|
437 |
return context.ErrorResult(device.implementation.ERR_SUCCESS, ""); // if id is given all other filters will be ignored
|
|
438 |
|
|
439 |
type = typeof criteria.Filter.EventType;
|
|
440 |
if (type != 'undefined') {
|
|
441 |
if (type != "number")
|
|
442 |
return error(device.implementation.ERR_BAD_ARGUMENT_TYPE, msg.msgEventTypeInvalid);
|
|
443 |
|
|
444 |
if (type != "number" || !(criteria.Filter.EventType >= 0 && criteria.Filter.EventType <= 4))
|
|
445 |
return error(device.implementation.ERR_INVALID_SERVICE_ARGUMENT, msg.msgEventTypeInvalid);
|
|
446 |
}
|
|
447 |
type = typeof criteria.Filter.RecentList;
|
|
448 |
if (type != 'undefined') {
|
|
449 |
if (type != "number")
|
|
450 |
return error(device.implementation.ERR_BAD_ARGUMENT_TYPE, msg.msgRecentListInvalid);
|
|
451 |
if (type == "number" && (criteria.Filter.RecentList < -1 || criteria.Filter.RecentList > 3))
|
|
452 |
return error(device.implementation.ERR_INVALID_SERVICE_ARGUMENT, msg.msgRecentListInvalid);
|
|
453 |
}
|
|
454 |
|
|
455 |
type = typeof criteria.Filter.RemoteParty;
|
|
456 |
if(type != 'undefined' && type != "string")
|
|
457 |
return error(device.implementation.ERR_BAD_ARGUMENT_TYPE,msg.msgRemotePartyInvalid);
|
|
458 |
|
|
459 |
type = typeof criteria.Filter.Direction;
|
|
460 |
if (type != 'undefined') {
|
|
461 |
if (type != "number")
|
|
462 |
return error(device.implementation.ERR_BAD_ARGUMENT_TYPE, msg.msgDirectionInvalid);
|
|
463 |
if (type == "number" && (criteria.Filter.Direction < 0 || criteria.Filter.Direction > 6))
|
|
464 |
return error(device.implementation.ERR_INVALID_SERVICE_ARGUMENT, msg.msgDirectionInvalid);
|
|
465 |
}
|
|
466 |
|
|
467 |
type = typeof criteria.Filter.DeliveryStatus;
|
|
468 |
if (type != 'undefined') {
|
|
469 |
if (type != "number")
|
|
470 |
return error(device.implementation.ERR_BAD_ARGUMENT_TYPE, msg.msgDeliveryStatusInvalid);
|
|
471 |
if (type == "number" && (criteria.Filter.DeliveryStatus < 0 || criteria.Filter.DeliveryStatus > 6))
|
|
472 |
return error(device.implementation.ERR_INVALID_SERVICE_ARGUMENT, msg.msgDeliveryStatusInvalid);
|
|
473 |
}
|
|
474 |
|
|
475 |
type = typeof criteria.Filter.EndTime;
|
|
476 |
if(type != 'undefined' && (type != "object" || typeof criteria.Filter.EndTime.getTime != "function"))
|
|
477 |
return error(device.implementation.ERR_BAD_ARGUMENT_TYPE,msg.msgEndTimeInvalid);
|
|
478 |
|
|
479 |
type = typeof criteria.Filter.PhoneNumber;
|
|
480 |
if(type != 'undefined' && type != "string")
|
|
481 |
return error(device.implementation.ERR_BAD_ARGUMENT_TYPE,msg.msgPhoneNumberInvalid);
|
|
482 |
|
|
483 |
|
|
484 |
type = typeof criteria.Filter.LogFlags;
|
|
485 |
if (type != 'undefined') {
|
|
486 |
if (type != "number")
|
|
487 |
return error(device.implementation.ERR_BAD_ARGUMENT_TYPE, msg.msgLogFlagsInvalid);
|
|
488 |
if (type == "number" && (criteria.Filter.LogFlags != 1 && criteria.Filter.LogFlags != 0))
|
|
489 |
return error(device.implementation.ERR_INVALID_SERVICE_ARGUMENT, msg.msgLogFlagsInvalid);
|
|
490 |
}
|
|
491 |
return context.ErrorResult(device.implementation.ERR_SUCCESS, "");
|
|
492 |
}
|
|
493 |
|
|
494 |
|
|
495 |
/**
|
|
496 |
* error messages
|
|
497 |
* order of %s args: Service name, method name, parameter name
|
|
498 |
*/
|
|
499 |
var msg = {
|
|
500 |
msgTypeInvalid : '%s:%s:TypeInvalid',
|
|
501 |
msgTypeMissing : '%s:%s:Type Missing',
|
|
502 |
msgFilterInvalid : '%s:%s:FilterInvalid',
|
|
503 |
msgidInvalid : '%s:%s:idInvalid',
|
|
504 |
msgRecentListInvalid : '%s:%s:RecentListInvalid',
|
|
505 |
msgPhoneNumberInvalid : '%s:%s:PhoneNumberInvalid',
|
|
506 |
msgDirectionInvalid : '%s:%s:DirectionInvalid',
|
|
507 |
msgDeliveryStatusInvalid : '%s:%s:DeliveryStatusInvalid',
|
|
508 |
msgLogFlagsInvalid : '%s:%s:LogFlagsInvalid',
|
|
509 |
msgEndTimeInvalid : '%s:%s:EndTimeInvalid',
|
|
510 |
msgRemotePartyInvalid : '%s:%s:RemotePartyInvalid',
|
|
511 |
msgEventTypeInvalid : '%s:%s:EventTypeInvalid',
|
|
512 |
msgItemInvalid : '%s:%s:ItemInvalid',
|
|
513 |
msgItemMissing : '%s:%s:ItemMissing',
|
|
514 |
msgEventTypeInvalid : '%s:%s:EventTypeInvalid',
|
|
515 |
msgEventTypeMissing : '%s:%s:EventType Missing',
|
|
516 |
msgEventDurationInvalid : '%s:%s:EventDurationInvalid',
|
|
517 |
msgSubjectInvalid : '%s:%s:SubjectInvalid',
|
|
518 |
msgEventDataInvalid : '%s:%s:EventDataInvalid',
|
|
519 |
msgLinkInvalid : '%s:%s:LinkInvalid',
|
|
520 |
msgDataInvalid : '%s:%s:DataInvalid',
|
|
521 |
msgDataMissing : '%s:%s:Data Missing',
|
|
522 |
msgid : '%s:%s:id',
|
|
523 |
msgFilterInvalid : '%s:%s:FilterInvalid',
|
|
524 |
msgFilterMissing : '%s:%s:Filter Missing',
|
|
525 |
msgDelayTimeInvalid : '%s:%s:DelayTimeInvalid',
|
|
526 |
msgDelayTimerMissing : '%s:%s:DelayTimerMissing',
|
|
527 |
msgTransactionIdInvalid : '%s:%s:TransactionIdInvalid',
|
|
528 |
msgTransactionIdMissing : '%s:%s:TransactionID Missing',
|
|
529 |
msgMissingCallback : '%s:%s:Missing Callback',
|
|
530 |
msgNoMsg : '%s:%s:'
|
|
531 |
};
|
|
532 |
|
|
533 |
|
|
534 |
}) ()
|
|
535 |
|