Skip to content
This repository has been archived by the owner on Mar 11, 2020. It is now read-only.

Commit

Permalink
Merge pull request #357 from wcwang/next
Browse files Browse the repository at this point in the history
[Calendar] Applied interface and constructor checking.
  • Loading branch information
wcwang committed Oct 23, 2013
2 parents 89afd13 + 33e9432 commit db6e377
Show file tree
Hide file tree
Showing 11 changed files with 1,614 additions and 649 deletions.
100 changes: 71 additions & 29 deletions lib/ripple/platform/tizen/2.0/CalendarAlarm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012 Intel Corporation.
* Copyright 2013 Intel Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,37 +14,79 @@
* limitations under the License.
*/

var utils = require('ripple/utils'),
TZDate = require('ripple/platform/tizen/2.0/TZDate'),
TimeDuration = require('ripple/platform/tizen/2.0/TimeDuration'),
errorcode = require('ripple/platform/tizen/2.0/errorcode'),
WebAPIError = require('ripple/platform/tizen/2.0/WebAPIError'),
_alarmMethods = ["SOUND", "DISPLAY"];

function CalendarAlarm (triggerTime, method, description) {
var absoluteDate = null,
before = null,
isValid = false,
_self = this;

if (triggerTime instanceof TZDate) {
absoluteDate = triggerTime;
} else if (triggerTime instanceof TimeDuration) {
before = triggerTime;
} else {
throw (new WebAPIError(errorcode.TYPE_MISMATCH_ERR));
var t = require('ripple/platform/tizen/2.0/typecast'),
CalendarAlarm;

CalendarAlarm = function () {
var voc, calendarAlarm = {};

// private
function construct() {
this.__defineGetter__("absoluteDate", function () {
return calendarAlarm.absoluteDate;
});
this.__defineSetter__("absoluteDate", function (val) {
try {
calendarAlarm.absoluteDate = t.TZDate(val, "?");
} catch (e) {
}
});

this.__defineGetter__("before", function () {
return calendarAlarm.before;
});
this.__defineSetter__("before", function (val) {
try {
calendarAlarm.before = t.TimeDuration(val, "?");
} catch (e) {
}
});

this.__defineGetter__("method", function () {
return calendarAlarm.method;
});
this.__defineSetter__("method", function (val) {
try {
calendarAlarm.method = t.AlarmMethod(val);
} catch (e) {
}
});

this.__defineGetter__("description", function () {
return calendarAlarm.description;
});
this.__defineSetter__("description", function (val) {
try {
calendarAlarm.description = t.DOMString(val, "?");
} catch (e) {
}
});
}

isValid = utils.arrayContains(_alarmMethods, method);
if (!isValid)
throw (new WebAPIError(errorcode.TYPE_MISMATCH_ERR));
// Constructor
function CalendarAlarm_TZDate_AlarmMethod_DOMString(absoluteDate, method,
description) {
construct.call(this);

_self.absoluteDate = absoluteDate;
_self.before = before;
_self.method = method;
_self.description = description || "";
calendarAlarm.absoluteDate = absoluteDate;
calendarAlarm.before = null;
calendarAlarm.method = method;
calendarAlarm.description = description || "";
}

function CalendarAlarm_TimeDuration_AlarmMethod_DOMString(before, method,
description) {
construct.call(this);

calendarAlarm.absoluteDate = null;
calendarAlarm.before = before;
calendarAlarm.method = method;
calendarAlarm.description = description || "";
}

return _self;
}
voc = [CalendarAlarm_TZDate_AlarmMethod_DOMString,
CalendarAlarm_TimeDuration_AlarmMethod_DOMString];
t.CalendarAlarm(arguments, this, voc);
};

module.exports = CalendarAlarm;
147 changes: 123 additions & 24 deletions lib/ripple/platform/tizen/2.0/CalendarAttendee.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012 Intel Corporation.
* Copyright 2013 Intel Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,31 +14,130 @@
* limitations under the License.
*/

module.exports = function (uri, attendeeInitDict) {
var _self = this;
var t = require('ripple/platform/tizen/2.0/typecast'),
CalendarAttendee;

CalendarAttendee = function (uri, attendeeInitDict) {
var calendarAttendee = {}, attr;

t.CalendarAttendee(arguments, this);

calendarAttendee.uri = uri;
calendarAttendee.name = undefined;
calendarAttendee.role = "REQ_PARTICIPANT";
calendarAttendee.status = "PENDING";
calendarAttendee.RSVP = false;
calendarAttendee.type = "INDIVIDUAL";
calendarAttendee.group = undefined;
calendarAttendee.delegatorURI = undefined;
calendarAttendee.delegateURI = undefined;
calendarAttendee.contactRef = null;

_self.uri = uri;
if (attendeeInitDict) {
_self.name = (attendeeInitDict.name) ? attendeeInitDict.name : "";
_self.role = (attendeeInitDict.role) ? attendeeInitDict.role : "";
_self.status = (attendeeInitDict.status) ? attendeeInitDict.status : "";
_self.RSVP = (attendeeInitDict.RSVP) ? attendeeInitDict.RSVP : "";
_self.type = (attendeeInitDict.type) ? attendeeInitDict.type : "";
_self.group = (attendeeInitDict.group) ? attendeeInitDict.group : "";
_self.delegatorURI = (attendeeInitDict.delegatorURI) ? attendeeInitDict.delegatorURI : "";
_self.delegateURI = (attendeeInitDict.delegateURI) ? attendeeInitDict.delegateURI : "";
_self.contactRef = (attendeeInitDict.contactRef) ? attendeeInitDict.contactRef : "";
} else {
_self.name = "";
_self.role = "";
_self.status = "";
_self.RSVP = "";
_self.type = "";
_self.group = "";
_self.delegatorURI = "";
_self.delegateURI = "";
_self.contactRef = "";
for (attr in attendeeInitDict) {
calendarAttendee[attr] = attendeeInitDict[attr];
}
}

return _self;
this.__defineGetter__("uri", function () {
return calendarAttendee.uri;
});
this.__defineSetter__("uri", function (val) {
try {
calendarAttendee.uri = t.DOMString(val);
} catch (e) {
}
});

this.__defineGetter__("name", function () {
return calendarAttendee.name;
});
this.__defineSetter__("name", function (val) {
try {
calendarAttendee.name = t.DOMString(val, "?");
} catch (e) {
}
});

this.__defineGetter__("role", function () {
return calendarAttendee.role;
});
this.__defineSetter__("role", function (val) {
try {
calendarAttendee.role = t.AttendeeRole(val);
} catch (e) {
}
});

this.__defineGetter__("status", function () {
return calendarAttendee.status;
});
this.__defineSetter__("status", function (val) {
try {
calendarAttendee.status = t.AttendeeStatus(val);
} catch (e) {
}
});

this.__defineGetter__("RSVP", function () {
return calendarAttendee.RSVP;
});
this.__defineSetter__("RSVP", function (val) {
try {
calendarAttendee.RSVP = t.boolean(val);
} catch (e) {
}
});

this.__defineGetter__("type", function () {
return calendarAttendee.type;
});
this.__defineSetter__("type", function (val) {
try {
calendarAttendee.type = t.AttendeeType(val);
} catch (e) {
}
});

this.__defineGetter__("group", function () {
return calendarAttendee.group;
});
this.__defineSetter__("group", function (val) {
try {
calendarAttendee.group = t.DOMString(val, "?");
} catch (e) {
}
});

this.__defineGetter__("delegatorURI", function () {
return calendarAttendee.delegatorURI;
});
this.__defineSetter__("delegatorURI", function (val) {
try {
calendarAttendee.delegatorURI = t.DOMString(val, "?");
} catch (e) {
}
});

this.__defineGetter__("delegateURI", function () {
return calendarAttendee.delegateURI;
});
this.__defineSetter__("delegateURI", function (val) {
try {
calendarAttendee.delegateURI = t.DOMString(val, "?");
} catch (e) {
}
});

this.__defineGetter__("contactRef", function () {
return calendarAttendee.contactRef;
});
this.__defineSetter__("contactRef", function (val) {
try {
calendarAttendee.contactRef = t.ContactRef(val, "?");
} catch (e) {
}
});
};

module.exports = CalendarAttendee;

0 comments on commit db6e377

Please sign in to comment.