CVS removal of now-long-unused libxpical.

git-svn-id: svn://10.0.0.236/trunk@174152 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
shaver%mozilla.org
2005-06-04 13:16:15 +00:00
parent 776bca62a7
commit ac31fa2294
21 changed files with 0 additions and 11274 deletions

View File

@@ -1,100 +0,0 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 2001
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = calendar
LIBRARY_NAME = xpical
EXPORT_LIBRARY = 1
IS_COMPONENT = 1
MODULE_NAME = oeICalModule
MOZILLA_INTERNAL_API = 1
REQUIRES = xpcom \
appshell \
string \
timer \
necko \
msgcompose \
addrbook \
dom \
pref \
ical \
icalss \
$(NULL)
XPIDLSRCS = oeIICal.idl
CPPSRCS = \
oeICalEventImpl.cpp \
oeICalTodoImpl.cpp \
oeICalFactory.cpp \
oeICalImpl.cpp \
oeICalContainerImpl.cpp \
oeDateTimeImpl.cpp \
$(NULL)
CSRCS = \
token.c \
md5.c \
$(NULL)
EXTRA_DSO_LIBS = mozicalss mozical
EXTRA_DSO_LDOPTS += \
$(LIBS_DIR) \
$(EXTRA_DSO_LIBS) \
$(MOZ_COMPONENT_LIBS) \
$(NULL)
ifdef MOZ_MAIL_NEWS
DEFINES += -DMOZ_MAIL_NEWS
endif
#DEFINES += -DICAL_DEBUG
#-DICAL_DEBUG_ALL
#ifdef ENABLE_TESTS
DIRS += tests
#endif
include $(topsrcdir)/config/rules.mk

View File

@@ -1,854 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is OEone Corporation.
*
* The Initial Developer of the Original Code is
* OEone Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Mostafa Hosseini (mostafah@oeone.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
const DEFAULT_SERVER="file:///tmp/.oecalendar";
const DEFAULT_TITLE="Lunch Time";
const DEFAULT_DESCRIPTION = "Will be out for one hour";
const DEFAULT_LOCATION = "Restaurant";
const DEFAULT_CATEGORY = "Personal";
const DEFAULT_EMAIL = "mostafah@oeone.com";
const DEFAULT_PRIVATE = false;
const DEFAULT_ALLDAY = false;
const DEFAULT_ALARM = true;
const DEFAULT_ALARMUNITS = "minutes";
const DEFAULT_ALARMLENGTH = 5;
const DEFAULT_RECUR = true;
const DEFAULT_RECURINTERVAL = 7;
const DEFAULT_RECURUNITS = "days";
const DEFAULT_RECURFOREVER = true;
const DEFAULT_ATTACHMENT = DEFAULT_SERVER;
var iCalLib = null;
var gObserver = null;
var gTodoObserver = null;
function Observer()
{
}
Observer.prototype.onAddItem = function( icalevent )
{
dump( "Observer.prototype.onAddItem\n" );
}
Observer.prototype.onModifyItem = function( icalevent, oldevent )
{
dump( "Observer.prototype.onModifyItem\n" );
}
Observer.prototype.onDeleteItem = function( icalevent )
{
dump( "Observer.prototype.onDeleteItem\n" );
}
Observer.prototype.onAlarm = function( icalevent )
{
dump( "Observer.prototype.onAlarm\n" );
}
Observer.prototype.onLoad = function()
{
dump( "Observer.prototype.onLoad\n" );
}
Observer.prototype.onStartBatch = function()
{
dump( "Observer.prototype.onStartBatch\n" );
}
Observer.prototype.onEndBatch = function()
{
dump( "Observer.prototype.onEndBatch\n" );
}
function Test()
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
if( iCalLib == null ) {
var iCalLibComponent = Components.classes["@mozilla.org/ical;1"].createInstance();
iCalLib = iCalLibComponent.QueryInterface(Components.interfaces.oeIICal);
}
iCalLib.server = DEFAULT_SERVER;
iCalLib.Test();
alert( "Finished Test" );
}
function TestAll()
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
if( iCalLib == null ) {
var iCalLibComponent = Components.classes["@mozilla.org/ical;1"].createInstance();
iCalLib = iCalLibComponent.QueryInterface(Components.interfaces.oeIICal);
}
if( gObserver == null ) {
gObserver = new Observer();
iCalLib.addObserver( gObserver );
}
if( gTodoObserver == null ) {
gTodoObserver = new Observer();
iCalLib.addTodoObserver( gTodoObserver );
}
if( !TestTimeConversion() ) {
alert( "Stopped Test" );
return;
}
iCalLib.server = DEFAULT_SERVER;
var id = TestAddEvent();
if( id == 0 ) {
alert( "Stopped Test" );
return;
}
var iCalEvent = TestFetchEvent( id );
if( iCalEvent == null ) {
alert( "Stopped Test" );
return;
}
id = TestUpdateEvent( iCalEvent );
// TestSearchEvent();
TestDeleteEvent( id );
TestRecurring();
//Todo tests
var id = TestAddTodo();
var iCalTodo = TestFetchTodo( id );
id = TestUpdateTodo( iCalTodo );
TestDeleteTodo( id );
TestFilterTodo( id );
TestIcalString();
alert( "Finished Test" );
}
function TestTimeConversion() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var dateTimeComponent = Components.classes["@mozilla.org/oedatetime;1"].createInstance();
dateTime = dateTimeComponent.QueryInterface(Components.interfaces.oeIDateTime);
var date1 = new Date();
dateTime.setTime( date1 );
var date1inms = parseInt( date1.getTime()/1000 );
if( (dateTime.getTime()/1000) != date1inms ) {
alert( "TestTimeConversion(): Step1 failed" );
return false;
}
date1 = new Date( 1970, 0, 1, 0, 0, 0 );
dateTime.setTime( date1 );
date1inms = parseInt( date1.getTime()/1000 );
if( (dateTime.getTime()/1000) != date1inms ) {
alert( "TestTimeConversion(): Step2 failed" );
return false;
}
date1 = new Date( 1969, 11, 31, 23, 59, 59 );
dateTime.setTime( date1 );
date1inms = parseInt( date1.getTime()/1000 );
if( (dateTime.getTime()/1000) != date1inms ) {
alert( "TestTimeConversion(): Step3 failed" );
return false;
}
date1 = new Date( 1969, 11, 31, 19, 0, 0 );
dateTime.setTime( date1 );
date1inms = parseInt( date1.getTime()/1000 );
if( (dateTime.getTime()/1000) != date1inms ) {
alert( "TestTimeConversion(): Step4 failed" );
return false;
}
date1 = new Date( 1962, 7, 03, 0, 0, 0 );
dateTime.setTime( date1 );
date1inms = parseInt( date1.getTime()/1000 );
if( (dateTime.getTime()/1000) != date1inms ) {
alert( "TestTimeConversion(): Step5 failed" );
return false;
}
if( dateTime.hour != date1.getHours() ) {
alert( "TestTimeConversion(): Step6 failed" );
return false;
}
return true;
}
function TestAddEvent()
{
var iCalEventComponent = Components.classes["@mozilla.org/icalevent;1"].createInstance();
var iCalEvent = iCalEventComponent.QueryInterface(Components.interfaces.oeIICalEvent);
iCalEvent.title = DEFAULT_TITLE;
iCalEvent.description = DEFAULT_DESCRIPTION;
iCalEvent.location = DEFAULT_LOCATION;
iCalEvent.categories = DEFAULT_CATEGORY;
iCalEvent.privateEvent = DEFAULT_PRIVATE;
iCalEvent.allDay = DEFAULT_ALLDAY;
iCalEvent.alarm = DEFAULT_ALARM;
iCalEvent.alarmUnits = DEFAULT_ALARMUNITS;
iCalEvent.alarmLength = DEFAULT_ALARMLENGTH;
iCalEvent.alarmEmailAddress = DEFAULT_EMAIL;
iCalEvent.inviteEmailAddress = DEFAULT_EMAIL;
iCalEvent.recur = DEFAULT_RECUR;
iCalEvent.recurInterval = DEFAULT_RECURINTERVAL;
iCalEvent.recurUnits = DEFAULT_RECURUNITS;
iCalEvent.recurForever = DEFAULT_RECURFOREVER;
iCalEvent.start.year = 2001;
iCalEvent.start.month = 10; //November
iCalEvent.start.day = 1;
iCalEvent.start.hour = 12;
iCalEvent.start.minute = 24;
iCalEvent.end.year = 2001;
iCalEvent.end.month = 10; //November
iCalEvent.end.day = 1;
iCalEvent.end.hour = 13;
iCalEvent.end.minute = 24;
var snoozetime = new Date();
iCalEvent.setSnoozeTime( snoozetime );
Attachment = Components.classes["@mozilla.org/messengercompose/attachment;1"].createInstance( Components.interfaces.nsIMsgAttachment );
Attachment.url = DEFAULT_ATTACHMENT;
iCalEvent.addAttachment( Attachment );
Contact = Components.classes["@mozilla.org/addressbook/cardproperty;1"].createInstance( Components.interfaces.nsIAbCard );
Contact.primaryEmail = DEFAULT_EMAIL;
iCalEvent.addContact( Contact );
var id = iCalLib.addEvent( iCalEvent );
if( id == null ){
alert( "TestAddEvent(): Invalid Id" );
return 0;
}
if( iCalEvent.title != DEFAULT_TITLE ){
alert( "TestAddEvent(): Invalid Title" );
return 0;
}
if( iCalEvent.description != DEFAULT_DESCRIPTION ){
alert( "TestAddEvent(): Invalid Description" );
return 0;
}
if( iCalEvent.location != DEFAULT_LOCATION ){
alert( "TestAddEvent(): Invalid Location" );
return 0;
}
if( iCalEvent.categories != DEFAULT_CATEGORY ){
alert( "TestAddEvent(): Invalid Category" );
return 0;
}
if( iCalEvent.privateEvent != DEFAULT_PRIVATE ){
alert( "TestAddEvent(): Invalid PrivateEvent Setting" );
return 0;
}
if( iCalEvent.allDay != DEFAULT_ALLDAY ){
alert( "TestAddEvent(): Invalid AllDay Setting" );
return 0;
}
if( iCalEvent.alarm != DEFAULT_ALARM ){
alert( "TestAddEvent(): Invalid Alarm Setting" );
return 0;
}
if( iCalEvent.alarmUnits != DEFAULT_ALARMUNITS ){
alert( "TestAddEvent(): Invalid Alarm Units" );
return 0;
}
if( iCalEvent.alarmLength != DEFAULT_ALARMLENGTH ){
alert( "TestAddEvent(): Invalid Alarm Length" );
return 0;
}
if( iCalEvent.alarmEmailAddress != DEFAULT_EMAIL ){
alert( "TestAddEvent(): Invalid Alarm Email Address" );
return 0;
}
if( iCalEvent.inviteEmailAddress != DEFAULT_EMAIL ){
alert( "TestAddEvent(): Invalid Invite Email Address" );
return 0;
}
if( iCalEvent.recur != DEFAULT_RECUR ){
alert( "TestAddEvent(): Invalid Recur Setting" );
return 0;
}
if( iCalEvent.recurInterval != DEFAULT_RECURINTERVAL ){
alert( "TestAddEvent(): Invalid Recur Interval" );
return 0;
}
if( iCalEvent.recurUnits != DEFAULT_RECURUNITS ){
alert( "TestAddEvent(): Invalid Recur Units" );
return 0;
}
if( iCalEvent.recurForever != DEFAULT_RECURFOREVER ){
alert( "TestAddEvent(): Invalid Recur Forever" );
return 0;
}
//TODO: Check for start and end date
return id;
}
function TestFetchEvent( id )
{
var iCalEvent = iCalLib.fetchEvent( id );
if( id == null ){
alert( "TestFetchEvent(): Invalid Id" );
return null;
}
if( iCalEvent.title != DEFAULT_TITLE ){
alert( "TestFetchEvent(): Invalid Title" );
return null;
}
if( iCalEvent.description != DEFAULT_DESCRIPTION ){
alert( "TestFetchEvent(): Invalid Description" );
return null;
}
if( iCalEvent.location != DEFAULT_LOCATION ){
alert( "TestFetchEvent(): Invalid Location" );
return null;
}
if( iCalEvent.categories != DEFAULT_CATEGORY ){
alert( "TestFetchEvent(): Invalid Category" );
return null;
}
if( iCalEvent.privateEvent != DEFAULT_PRIVATE ){
alert( "TestFetchEvent(): Invalid PrivateEvent Setting" );
return null;
}
if( iCalEvent.allDay != DEFAULT_ALLDAY ){
alert( "TestFetchEvent(): Invalid AllDay Setting" );
return null;
}
if( iCalEvent.alarm != DEFAULT_ALARM ){
alert( "TestFetchEvent(): Invalid Alarm Setting" );
return null;
}
if( iCalEvent.alarmUnits != DEFAULT_ALARMUNITS ){
alert( "TestFetchEvent(): Invalid Alarm Units" );
return null;
}
if( iCalEvent.alarmLength != DEFAULT_ALARMLENGTH ){
alert( "TestFetchEvent(): Invalid Alarm Length" );
return null;
}
if( iCalEvent.alarmEmailAddress != DEFAULT_EMAIL ){
alert( "TestFetchEvent(): Invalid Alarm Email Address" );
return null;
}
if( iCalEvent.inviteEmailAddress != DEFAULT_EMAIL ){
alert( "TestFetchEvent(): Invalid Invite Email Address" );
return null;
}
if( iCalEvent.recur != DEFAULT_RECUR ){
alert( "TestFetchEvent(): Invalid Recur Setting" );
return null;
}
if( iCalEvent.recurInterval != DEFAULT_RECURINTERVAL ){
alert( "TestFetchEvent(): Invalid Recur Interval" );
return null;
}
if( iCalEvent.recurUnits != DEFAULT_RECURUNITS ){
alert( "TestFetchEvent(): Invalid Recur Units" );
return null;
}
if( iCalEvent.recurForever != DEFAULT_RECURFOREVER ){
alert( "TestFetchEvent(): Invalid Recur Forever" );
return null;
}
if( !iCalEvent.attachmentsArray.Count() ) {
alert( "TestFetchEvent(): No attachment found" );
return null;
}
attachment = iCalEvent.attachmentsArray.QueryElementAt( 0, Components.interfaces.nsIMsgAttachment );
if ( attachment.url != DEFAULT_ATTACHMENT ) {
alert( "TestFetchEvent(): Invalid attachment" );
return null;
}
//TODO: Check for start and end date
return iCalEvent;
}
function TestUpdateEvent( iCalEvent )
{
iCalEvent.title = DEFAULT_TITLE+"*NEW*";
iCalEvent.description = DEFAULT_DESCRIPTION+"*NEW*";
iCalEvent.location = DEFAULT_LOCATION+"*NEW*";
iCalEvent.categories = DEFAULT_CATEGORY+"*NEW*";
iCalEvent.privateEvent = !DEFAULT_PRIVATE;
iCalEvent.allDay = !DEFAULT_ALLDAY;
iCalEvent.alarm = !DEFAULT_ALARM;
iCalEvent.recur = !DEFAULT_RECUR;
iCalEvent.start.year = 2002;
iCalEvent.start.month = 11; //December
iCalEvent.start.day = 2;
iCalEvent.start.hour = 13;
iCalEvent.start.minute = 25;
iCalEvent.end.year = 2002;
iCalEvent.end.month = 11; //December
iCalEvent.end.day = 2;
iCalEvent.end.hour = 14;
iCalEvent.end.minute = 25;
var id = iCalLib.modifyEvent( iCalEvent );
if( id == null )
alert( "TestUpdateEvent(): Invalid Id" );
if( iCalEvent.title != DEFAULT_TITLE+"*NEW*" )
alert( "TestUpdateEvent(): Invalid Title" );
if( iCalEvent.description != DEFAULT_DESCRIPTION+"*NEW*" )
alert( "TestUpdateEvent(): Invalid Description" );
if( iCalEvent.location != DEFAULT_LOCATION+"*NEW*" )
alert( "TestUpdateEvent(): Invalid Location" );
if( iCalEvent.categories != DEFAULT_CATEGORY+"*NEW*" )
alert( "TestUpdateEvent(): Invalid Category" );
if( iCalEvent.privateEvent != !DEFAULT_PRIVATE )
alert( "TestUpdateEvent(): Invalid PrivateEvent Setting" );
if( iCalEvent.allDay != !DEFAULT_ALLDAY )
alert( "TestUpdateEvent(): Invalid AllDay Setting" );
if( iCalEvent.alarm != !DEFAULT_ALARM )
alert( "TestUpdateEvent(): Invalid Alarm Setting" );
if( iCalEvent.recur != !DEFAULT_RECUR )
alert( "TestUpdateEvent(): Invalid Recur Setting" );
//TODO check start and end dates
return id;
}
/*
function TestSearchEvent()
{
result = iCalLib.SearchBySQL( "SELECT * FROM VEVENT WHERE CATEGORIES = 'Personal'" );
alert( "Result : " + result );
}*/
function TestDeleteEvent( id )
{
iCalLib.deleteEvent( id );
var iCalEvent = iCalLib.fetchEvent( id );
if( iCalEvent != null )
alert( "Delete failed" );
}
function TestRecurring() {
var iCalEventComponent = Components.classes["@mozilla.org/icalevent;1"].createInstance();
this.iCalEvent = iCalEventComponent.QueryInterface(Components.interfaces.oeIICalEvent);
iCalEvent.allDay = true;
iCalEvent.recur = true;
iCalEvent.recurInterval = 1;
iCalEvent.recurUnits = "years";
iCalEvent.recurForever = true;
iCalEvent.start.year = 2001;
iCalEvent.start.month = 0;
iCalEvent.start.day = 1;
iCalEvent.start.hour = 0;
iCalEvent.start.minute = 0;
iCalEvent.end.year = 2001;
iCalEvent.end.month = 0;
iCalEvent.end.day = 1;
iCalEvent.end.hour = 23;
iCalEvent.end.minute = 59;
var id = iCalLib.addEvent( iCalEvent );
var displayDates = new Object();
var checkdate = new Date( 2002, 0, 1, 0, 0, 0 );
var eventList = iCalLib.getEventsForDay( checkdate );
if( !eventList.hasMoreElements() )
alert( "Yearly Recur Test Failed" );
iCalLib.deleteEvent( id );
}
function TestAddTodo()
{
var iCalTodoComponent = Components.classes["@mozilla.org/icaltodo;1"].createInstance();
var iCalTodo = iCalTodoComponent.QueryInterface(Components.interfaces.oeIICalTodo);
iCalTodo.title = DEFAULT_TITLE;
iCalTodo.description = DEFAULT_DESCRIPTION;
iCalTodo.location = DEFAULT_LOCATION;
iCalTodo.categories = DEFAULT_CATEGORY;
iCalTodo.privateEvent = DEFAULT_PRIVATE;
iCalTodo.allDay = DEFAULT_ALLDAY;
iCalTodo.alarm = DEFAULT_ALARM;
iCalTodo.alarmUnits = DEFAULT_ALARMUNITS;
iCalTodo.alarmLength = DEFAULT_ALARMLENGTH;
iCalTodo.alarmEmailAddress = DEFAULT_EMAIL;
iCalTodo.inviteEmailAddress = DEFAULT_EMAIL;
iCalTodo.recur = DEFAULT_RECUR;
iCalTodo.recurInterval = DEFAULT_RECURINTERVAL;
iCalTodo.recurUnits = DEFAULT_RECURUNITS;
iCalTodo.recurForever = DEFAULT_RECURFOREVER;
iCalTodo.start.year = 2001;
iCalTodo.start.month = 10; //November
iCalTodo.start.day = 1;
iCalTodo.start.hour = 12;
iCalTodo.start.minute = 24;
iCalTodo.due.year = 2001;
iCalTodo.due.month = 11; //December
iCalTodo.due.day = 1;
iCalTodo.due.hour = 23;
iCalTodo.due.minute = 59;
var id = iCalLib.addTodo( iCalTodo );
if( id == null )
alert( "TestAddTodo(): Invalid Id" );
if( iCalTodo.title != DEFAULT_TITLE )
alert( "TestAddTodo(): Invalid Title" );
if( iCalTodo.description != DEFAULT_DESCRIPTION )
alert( "TestAddTodo(): Invalid Description" );
if( iCalTodo.location != DEFAULT_LOCATION )
alert( "TestAddTodo(): Invalid Location" );
if( iCalTodo.categories != DEFAULT_CATEGORY )
alert( "TestAddTodo(): Invalid Category" );
if( iCalTodo.privateEvent != DEFAULT_PRIVATE )
alert( "TestAddTodo(): Invalid PrivateEvent Setting" );
if( iCalTodo.allDay != DEFAULT_ALLDAY )
alert( "TestAddTodo(): Invalid AllDay Setting" );
if( iCalTodo.alarm != DEFAULT_ALARM )
alert( "TestAddTodo(): Invalid Alarm Setting" );
if( iCalTodo.alarmUnits != DEFAULT_ALARMUNITS )
alert( "TestAddTodo(): Invalid Alarm Units" );
if( iCalTodo.alarmLength != DEFAULT_ALARMLENGTH )
alert( "TestAddTodo(): Invalid Alarm Length" );
if( iCalTodo.alarmEmailAddress != DEFAULT_EMAIL )
alert( "TestAddTodo(): Invalid Alarm Email Address" );
if( iCalTodo.inviteEmailAddress != DEFAULT_EMAIL )
alert( "TestAddTodo(): Invalid Invite Email Address" );
if( iCalTodo.recur != DEFAULT_RECUR )
alert( "TestAddTodo(): Invalid Recur Setting" );
if( iCalTodo.recurInterval != DEFAULT_RECURINTERVAL )
alert( "TestAddTodo(): Invalid Recur Interval" );
if( iCalTodo.recurUnits != DEFAULT_RECURUNITS )
alert( "TestAddTodo(): Invalid Recur Units" );
if( iCalTodo.recurForever != DEFAULT_RECURFOREVER )
alert( "TestAddTodo(): Invalid Recur Forever" );
//TODO: Check for start and end date
return id;
}
function TestFetchTodo( id )
{
var iCalEvent = iCalLib.fetchTodo( id );
if( id == null )
alert( "TestFetchTodo(): Invalid Id" );
if( iCalEvent.title != DEFAULT_TITLE )
alert( "TestFetchTodo(): Invalid Title" );
if( iCalEvent.description != DEFAULT_DESCRIPTION )
alert( "TestFetchTodo(): Invalid Description" );
if( iCalEvent.location != DEFAULT_LOCATION )
alert( "TestFetchTodo(): Invalid Location" );
if( iCalEvent.categories != DEFAULT_CATEGORY )
alert( "TestFetchTodo(): Invalid Category" );
if( iCalEvent.privateEvent != DEFAULT_PRIVATE )
alert( "TestFetchTodo(): Invalid PrivateEvent Setting" );
if( iCalEvent.allDay != DEFAULT_ALLDAY )
alert( "TestFetchTodo(): Invalid AllDay Setting" );
if( iCalEvent.alarm != DEFAULT_ALARM )
alert( "TestFetchTodo(): Invalid Alarm Setting" );
if( iCalEvent.alarmUnits != DEFAULT_ALARMUNITS )
alert( "TestFetchTodo(): Invalid Alarm Units" );
if( iCalEvent.alarmLength != DEFAULT_ALARMLENGTH )
alert( "TestFetchTodo(): Invalid Alarm Length" );
if( iCalEvent.alarmEmailAddress != DEFAULT_EMAIL )
alert( "TestFetchTodo(): Invalid Alarm Email Address" );
if( iCalEvent.inviteEmailAddress != DEFAULT_EMAIL )
alert( "TestFetchTodo(): Invalid Invite Email Address" );
if( iCalEvent.recur != DEFAULT_RECUR )
alert( "TestFetchTodo(): Invalid Recur Setting" );
if( iCalEvent.recurInterval != DEFAULT_RECURINTERVAL )
alert( "TestFetchTodo(): Invalid Recur Interval" );
if( iCalEvent.recurUnits != DEFAULT_RECURUNITS )
alert( "TestFetchTodo(): Invalid Recur Units" );
if( iCalEvent.recurForever != DEFAULT_RECURFOREVER )
alert( "TestFetchTodo(): Invalid Recur Forever" );
//TODO: Check for start and end date
return iCalEvent;
}
function TestUpdateTodo( iCalTodo )
{
iCalTodo.title = DEFAULT_TITLE+"*NEW*";
iCalTodo.description = DEFAULT_DESCRIPTION+"*NEW*";
iCalTodo.location = DEFAULT_LOCATION+"*NEW*";
iCalTodo.categories = DEFAULT_CATEGORY+"*NEW*";
iCalTodo.privateEvent = !DEFAULT_PRIVATE;
iCalTodo.allDay = !DEFAULT_ALLDAY;
iCalTodo.alarm = !DEFAULT_ALARM;
iCalTodo.recur = !DEFAULT_RECUR;
iCalTodo.start.year = 2002;
iCalTodo.start.month = 0; //January
iCalTodo.start.day = 2;
iCalTodo.start.hour = 13;
iCalTodo.start.minute = 25;
var id = iCalLib.modifyTodo( iCalTodo );
if( id == null )
alert( "TestUpdateTodo(): Invalid Id" );
if( iCalTodo.title != DEFAULT_TITLE+"*NEW*" )
alert( "TestUpdateTodo(): Invalid Title" );
if( iCalTodo.description != DEFAULT_DESCRIPTION+"*NEW*" )
alert( "TestUpdateTodo(): Invalid Description" );
if( iCalTodo.location != DEFAULT_LOCATION+"*NEW*" )
alert( "TestUpdateTodo(): Invalid Location" );
if( iCalTodo.categories != DEFAULT_CATEGORY+"*NEW*" )
alert( "TestUpdateTodo(): Invalid Category" );
if( iCalTodo.privateEvent != !DEFAULT_PRIVATE )
alert( "TestUpdateTodo(): Invalid PrivateEvent Setting" );
if( iCalTodo.allDay != !DEFAULT_ALLDAY )
alert( "TestUpdateTodo(): Invalid AllDay Setting" );
if( iCalTodo.alarm != !DEFAULT_ALARM )
alert( "TestUpdateTodo(): Invalid Alarm Setting" );
if( iCalTodo.recur != !DEFAULT_RECUR )
alert( "TestUpdateTodo(): Invalid Recur Setting" );
//TODO check start and end dates
return id;
}
function TestDeleteTodo( id )
{
iCalLib.deleteTodo( id );
var iCalEvent = iCalLib.fetchTodo( id );
if( iCalEvent != null )
alert( "Delete failed" );
}
function TestFilterTodo()
{
var iCalTodoComponent = Components.classes["@mozilla.org/icaltodo;1"].createInstance();
var iCalTodo = iCalTodoComponent.QueryInterface(Components.interfaces.oeIICalTodo);
iCalTodo.start.year = 2002;
iCalTodo.start.month = 0;
iCalTodo.start.day = 1;
iCalTodo.start.hour = 0;
iCalTodo.start.minute = 0;
iCalTodo.due.year = 2003;
iCalTodo.due.month = 0;
iCalTodo.due.day = 1;
iCalTodo.due.hour = 0;
iCalTodo.due.minute = 0;
var id = iCalLib.addTodo( iCalTodo );
var todoList = this.iCalLib.getAllTodos();
if ( !todoList.hasMoreElements() ) {
alert( "TestFilterTodo-Step1: failed" );
return;
}
var now = Date();
iCalLib.filter.completed.setTime( now );
todoList = this.iCalLib.getAllTodos();
if ( !todoList.hasMoreElements() ) {
alert( "TestFilterTodo-Step2: failed" );
return;
}
iCalTodo.completed.setTime( now );
now = Date();
iCalLib.filter.completed.setTime( now );
todoList = this.iCalLib.getAllTodos();
if ( todoList.hasMoreElements() ) {
alert( "TestFilterTodo-Step3: failed" );
return;
}
iCalTodo.completed.clear();
todoList = this.iCalLib.getAllTodos();
if ( !todoList.hasMoreElements() ) {
alert( "TestFilterTodo-Step4: failed" );
return;
}
iCalLib.deleteTodo( id );
}
function TestIcalString()
{
var iCalEventComponent = Components.classes["@mozilla.org/icalevent;1"].createInstance();
var iCalEvent = iCalEventComponent.QueryInterface(Components.interfaces.oeIICalEvent);
iCalEvent.id = 999999999;
iCalEvent.title = DEFAULT_TITLE;
iCalEvent.description = DEFAULT_DESCRIPTION;
iCalEvent.location = DEFAULT_LOCATION;
iCalEvent.categories = DEFAULT_CATEGORY;
iCalEvent.privateEvent = DEFAULT_PRIVATE;
iCalEvent.allDay = DEFAULT_ALLDAY;
iCalEvent.alarm = DEFAULT_ALARM;
iCalEvent.alarmUnits = DEFAULT_ALARMUNITS;
iCalEvent.alarmLength = DEFAULT_ALARMLENGTH;
iCalEvent.alarmEmailAddress = DEFAULT_EMAIL;
iCalEvent.inviteEmailAddress = DEFAULT_EMAIL;
iCalEvent.recur = DEFAULT_RECUR;
iCalEvent.recurInterval = DEFAULT_RECURINTERVAL;
iCalEvent.recurUnits = DEFAULT_RECURUNITS;
iCalEvent.recurForever = DEFAULT_RECURFOREVER;
iCalEvent.start.year = 2001;
iCalEvent.start.month = 10; //November
iCalEvent.start.day = 1;
iCalEvent.start.hour = 12;
iCalEvent.start.minute = 24;
iCalEvent.end.year = 2001;
iCalEvent.end.month = 10; //November
iCalEvent.end.day = 1;
iCalEvent.end.hour = 13;
iCalEvent.end.minute = 24;
var snoozetime = new Date();
iCalEvent.setSnoozeTime( snoozetime );
var sCalenderData = iCalEvent.getIcalString();
var iCalEventComponent = Components.classes["@mozilla.org/icalevent;1"].createInstance();
var iCalParseEvent = iCalEventComponent.QueryInterface(Components.interfaces.oeIICalEvent);
//alert(sCalenderData);
iCalParseEvent.parseIcalString( sCalenderData );
//alert("2" + iCalParseEvent.description);
if( iCalParseEvent.title != DEFAULT_TITLE )
alert( "Invalid Title" );
if( iCalParseEvent.description != DEFAULT_DESCRIPTION )
alert( "Invalid Description" );
if( iCalParseEvent.location != DEFAULT_LOCATION )
alert( "Invalid Location" );
if( iCalParseEvent.categories != DEFAULT_CATEGORY )
alert( "Invalid Category" );
if( iCalParseEvent.privateEvent != DEFAULT_PRIVATE )
alert( "Invalid PrivateEvent Setting" );
if( iCalParseEvent.allDay != DEFAULT_ALLDAY )
alert( "Invalid AllDay Setting" );
if( iCalParseEvent.alarm != DEFAULT_ALARM )
alert( "Invalid Alarm Setting" );
if( iCalParseEvent.alarmUnits != DEFAULT_ALARMUNITS )
alert( "Invalid Alarm Units" );
if( iCalParseEvent.alarmLength != DEFAULT_ALARMLENGTH )
alert( "Invalid Alarm Length" );
if( iCalParseEvent.alarmEmailAddress != DEFAULT_EMAIL )
alert( "Invalid Alarm Email Address" );
if( iCalParseEvent.inviteEmailAddress != DEFAULT_EMAIL )
alert( "Invalid Invite Email Address" );
if( iCalParseEvent.recur != DEFAULT_RECUR )
alert( "Invalid Recur Setting" );
if( iCalParseEvent.recurInterval != DEFAULT_RECURINTERVAL )
alert( "Invalid Recur Interval" );
if( iCalParseEvent.recurUnits != DEFAULT_RECURUNITS )
alert( "Invalid Recur Units" );
if( iCalParseEvent.recurForever != DEFAULT_RECURFOREVER )
alert( "Invalid Recur Forever" );
var iCalTodoComponent = Components.classes["@mozilla.org/icaltodo;1"].createInstance();
var iCalTodo = iCalTodoComponent.QueryInterface(Components.interfaces.oeIICalTodo);
iCalTodo.title = DEFAULT_TITLE;
iCalTodo.description = DEFAULT_DESCRIPTION;
iCalTodo.location = DEFAULT_LOCATION;
iCalTodo.categories = DEFAULT_CATEGORY;
iCalTodo.privateEvent = DEFAULT_PRIVATE;
iCalTodo.start.year = 2001;
iCalTodo.start.month = 10; //November
iCalTodo.start.day = 1;
iCalTodo.start.hour = 12;
iCalTodo.start.minute = 24;
iCalTodo.due.year = 2001;
iCalTodo.due.month = 11; //December
iCalTodo.due.day = 1;
iCalTodo.due.hour = 23;
iCalTodo.due.minute = 59;
iCalTodo.id = 999999999;
var icalstring = iCalTodo.getTodoIcalString();
iCalTodo.parseTodoIcalString( icalstring );
if( iCalTodo.id == null )
alert( "TestAddTodo(): Invalid Id" );
if( iCalTodo.title != DEFAULT_TITLE )
alert( "TestAddTodo(): Invalid Title" );
if( iCalTodo.description != DEFAULT_DESCRIPTION )
alert( "TestAddTodo(): Invalid Description" );
if( iCalTodo.location != DEFAULT_LOCATION )
alert( "TestAddTodo(): Invalid Location" );
if( iCalTodo.categories != DEFAULT_CATEGORY )
alert( "TestAddTodo(): Invalid Category" );
if( iCalTodo.privateEvent != DEFAULT_PRIVATE )
alert( "TestAddTodo(): Invalid PrivateEvent Setting" );
//TODO: Check for start and end date
return true;
}

View File

@@ -1,61 +0,0 @@
<?xml version="1.0"?>
<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- The contents of this file are subject to the Mozilla Public License Version
- 1.1 (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- for the specific language governing rights and limitations under the
- License.
-
- The Original Code is OEone Calendar code, released
- October 31st, 2001.
-
- The Initial Developer of the Original Code is
- OEone Corporation.
- Portions created by the Initial Developer are Copyright (C) 2001
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
- Mostafa Hosseini (mostafah@oeone.com)
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the GPL or the LGPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<!DOCTYPE window>
<window
id="ICalendar"
title="ICalendar"
orient="vertical"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="caltst.js"/>
<hbox>
<box align="left">
<button label="Test Libical" onclick="Test();"/>
<button label="Test XPIcal" onclick="TestAll();"/>
</box>
<spacer flex="1"/>
</hbox>
</window>

View File

@@ -1,263 +0,0 @@
/*
* This code implements the MD5 message-digest algorithm.
* The algorithm is due to Ron Rivest. This code was
* written by Colin Plumb in 1993, no copyright is claimed.
* This code is in the public domain; do with it what you wish.
*
* Equivalent code is available from RSA Data Security, Inc.
* This code has been tested against that, and is equivalent,
* except that you don't need to include two pages of legalese
* with every copy.
*
* To compute the message digest of a chunk of bytes, declare an
* MD5Context structure, pass it to MD5Init, call MD5Update as
* needed on buffers full of bytes, and then call MD5Final, which
* will fill a supplied 16-byte array with the digest.
*/
/* Brutally hacked by John Walker back from ANSI C to K&R (no
prototypes) to maintain the tradition that Netfone will compile
with Sun's original "cc". */
#include <memory.h> /* for memcpy() */
#include "md5.h"
#ifdef sgi
#define HIGHFIRST
#endif
#ifdef sun
#define HIGHFIRST
#endif
#ifndef HIGHFIRST
#define byteReverse(buf, len) /* Nothing */
#else
/*
* Note: this code is harmless on little-endian machines.
*/
void byteReverse(buf, longs)
unsigned char *buf; unsigned longs;
{
uint32 t;
do {
t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
((unsigned) buf[1] << 8 | buf[0]);
*(uint32 *) buf = t;
buf += 4;
} while (--longs);
}
#endif
/*
* Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
* initialization constants.
*/
void MD5Init(ctx)
struct MD5Context *ctx;
{
ctx->buf[0] = 0x67452301;
ctx->buf[1] = 0xefcdab89;
ctx->buf[2] = 0x98badcfe;
ctx->buf[3] = 0x10325476;
ctx->bits[0] = 0;
ctx->bits[1] = 0;
}
/*
* Update context to reflect the concatenation of another buffer full
* of bytes.
*/
void MD5Update(ctx, buf, len)
struct MD5Context *ctx; unsigned char *buf; unsigned len;
{
uint32 t;
/* Update bitcount */
t = ctx->bits[0];
if ((ctx->bits[0] = t + ((uint32) len << 3)) < t)
ctx->bits[1]++; /* Carry from low to high */
ctx->bits[1] += len >> 29;
t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
/* Handle any leading odd-sized chunks */
if (t) {
unsigned char *p = (unsigned char *) ctx->in + t;
t = 64 - t;
if (len < t) {
memcpy(p, buf, len);
return;
}
memcpy(p, buf, t);
byteReverse(ctx->in, 16);
MD5Transform(ctx->buf, (uint32 *) ctx->in);
buf += t;
len -= t;
}
/* Process data in 64-byte chunks */
while (len >= 64) {
memcpy(ctx->in, buf, 64);
byteReverse(ctx->in, 16);
MD5Transform(ctx->buf, (uint32 *) ctx->in);
buf += 64;
len -= 64;
}
/* Handle any remaining bytes of data. */
memcpy(ctx->in, buf, len);
}
/*
* Final wrapup - pad to 64-byte boundary with the bit pattern
* 1 0* (64-bit count of bits processed, MSB-first)
*/
void MD5Final(digest, ctx)
unsigned char digest[16]; struct MD5Context *ctx;
{
unsigned count;
unsigned char *p;
/* Compute number of bytes mod 64 */
count = (ctx->bits[0] >> 3) & 0x3F;
/* Set the first char of padding to 0x80. This is safe since there is
always at least one byte free */
p = ctx->in + count;
*p++ = 0x80;
/* Bytes of padding needed to make 64 bytes */
count = 64 - 1 - count;
/* Pad out to 56 mod 64 */
if (count < 8) {
/* Two lots of padding: Pad the first block to 64 bytes */
memset(p, 0, count);
byteReverse(ctx->in, 16);
MD5Transform(ctx->buf, (uint32 *) ctx->in);
/* Now fill the next block with 56 bytes */
memset(ctx->in, 0, 56);
} else {
/* Pad block to 56 bytes */
memset(p, 0, count - 8);
}
byteReverse(ctx->in, 14);
/* Append length in bits and transform */
((uint32 *) ctx->in)[14] = ctx->bits[0];
((uint32 *) ctx->in)[15] = ctx->bits[1];
MD5Transform(ctx->buf, (uint32 *) ctx->in);
byteReverse((unsigned char *) ctx->buf, 4);
memcpy(digest, ctx->buf, 16);
memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
}
/* The four core functions - F1 is optimized somewhat */
/* #define F1(x, y, z) (x & y | ~x & z) */
#define F1(x, y, z) (z ^ (x & (y ^ z)))
#define F2(x, y, z) F1(z, x, y)
#define F3(x, y, z) (x ^ y ^ z)
#define F4(x, y, z) (y ^ (x | ~z))
/* This is the central step in the MD5 algorithm. */
#define MD5STEP(f, w, x, y, z, data, s) \
( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
/*
* The core of the MD5 algorithm, this alters an existing MD5 hash to
* reflect the addition of 16 longwords of new data. MD5Update blocks
* the data and converts bytes into longwords for this routine.
*/
void MD5Transform(buf, in)
uint32 buf[4]; uint32 in[16];
{
register uint32 a, b, c, d;
a = buf[0];
b = buf[1];
c = buf[2];
d = buf[3];
MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
buf[0] += a;
buf[1] += b;
buf[2] += c;
buf[3] += d;
}

View File

@@ -1,26 +0,0 @@
#ifndef MD5_H
#define MD5_H
#if defined(__alpha) || defined(__x86_64)
typedef unsigned int uint32;
#else
typedef unsigned long uint32;
#endif
struct MD5Context {
uint32 buf[4];
uint32 bits[2];
unsigned char in[64];
};
extern void MD5Init(struct MD5Context *ctx);
extern void MD5Update(struct MD5Context *ctx, unsigned char *buf, unsigned len);
extern void MD5Final(unsigned char digest[16], struct MD5Context *ctx);
extern void MD5Transform();
/*
* This is needed to make RSAREF happy on some MS-DOS compilers.
*/
typedef struct MD5Context MD5_CTX;
#endif /* !MD5_H */

View File

@@ -1,274 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is OEone Corporation.
*
* The Initial Developer of the Original Code is
* OEone Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Mostafa Hosseini (mostafah@oeone.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* This file implements a date-time XPCOM object used to pass date-time values between the frontend and the
backend. It provides access to individual date-time fields from javascript and translates that data to a
icaltimetype structure for the backend.*/
#ifndef WIN32
#include <unistd.h>
#endif
#include "oeDateTimeImpl.h"
#include "nsMemory.h"
#include "stdlib.h"
icaltimetype ConvertFromPrtime( PRTime indate );
PRTime ConvertToPrtime ( icaltimetype indate );
icaltimezone *currenttimezone = nsnull;
/* Implementation file */
NS_IMPL_ISUPPORTS1(oeDateTimeImpl, oeIDateTime)
nsresult
NS_NewDateTime( oeIDateTime** inst )
{
NS_PRECONDITION(inst != nsnull, "null ptr");
if (! inst)
return NS_ERROR_NULL_POINTER;
*inst = new oeDateTimeImpl();
if (! *inst)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*inst);
return NS_OK;
}
oeDateTimeImpl::oeDateTimeImpl()
{
/* member initializers and constructor code */
m_datetime = icaltime_null_time();
m_tzid = nsnull;
}
oeDateTimeImpl::~oeDateTimeImpl()
{
if( m_tzid )
nsMemory::Free( m_tzid );
}
/* attribute short year; */
NS_IMETHODIMP oeDateTimeImpl::GetYear(PRInt16 *retval)
{
*retval = m_datetime.year;
return NS_OK;
}
NS_IMETHODIMP oeDateTimeImpl::SetYear(PRInt16 newval)
{
m_datetime.year = newval;
return NS_OK;
}
/* attribute short month; */
NS_IMETHODIMP oeDateTimeImpl::GetMonth(PRInt16 *retval)
{
*retval = m_datetime.month - 1;
return NS_OK;
}
NS_IMETHODIMP oeDateTimeImpl::SetMonth(PRInt16 newval)
{
m_datetime.month = newval + 1;
if( m_datetime.month < 1 || m_datetime.month > 12 )
m_datetime = icaltime_normalize( m_datetime );
return NS_OK;
}
/* attribute short day; */
NS_IMETHODIMP oeDateTimeImpl::GetDay(PRInt16 *retval)
{
*retval = m_datetime.day;
return NS_OK;
}
NS_IMETHODIMP oeDateTimeImpl::SetDay(PRInt16 newval)
{
m_datetime.day = newval;
if( newval < 1 || newval > 31 )
m_datetime = icaltime_normalize( m_datetime );
return NS_OK;
}
/* attribute short hour; */
NS_IMETHODIMP oeDateTimeImpl::GetHour(PRInt16 *retval)
{
*retval = m_datetime.hour;
return NS_OK;
}
NS_IMETHODIMP oeDateTimeImpl::SetHour(PRInt16 newval)
{
m_datetime.hour = newval;
if( newval < 0 || newval > 23 )
m_datetime = icaltime_normalize( m_datetime );
return NS_OK;
}
/* attribute short minute; */
NS_IMETHODIMP oeDateTimeImpl::GetMinute(PRInt16 *retval)
{
*retval = m_datetime.minute;
return NS_OK;
}
NS_IMETHODIMP oeDateTimeImpl::SetMinute(PRInt16 newval)
{
m_datetime.minute = newval;
if( newval < 0 || newval > 59 )
m_datetime = icaltime_normalize( m_datetime );
return NS_OK;
}
NS_IMETHODIMP oeDateTimeImpl::GetTime(PRTime *retval)
{
*retval = ConvertToPrtime( m_datetime );
return NS_OK;
}
NS_IMETHODIMP oeDateTimeImpl::ToString(char **retval)
{
char tmp[20];
sprintf( tmp, "%04d/%02d/%02d %02d:%02d:%02d" , m_datetime.year, m_datetime.month, m_datetime.day, m_datetime.hour, m_datetime.minute, m_datetime.second );
*retval= (char*) nsMemory::Clone( tmp, strlen(tmp)+1);
return NS_OK;
}
NS_IMETHODIMP oeDateTimeImpl::SetTime( PRTime ms )
{
m_datetime = ConvertFromPrtime( ms );
return NS_OK;
}
NS_IMETHODIMP oeDateTimeImpl::SetTimeInTimezone( PRTime ms, const char *tzid )
{
#ifdef ICAL_DEBUG_ALL
printf( "SetTimeInTimezone( %s )\n", tzid );
#endif
if( m_tzid )
nsMemory::Free( m_tzid );
if( tzid )
m_tzid= (char*) nsMemory::Clone( tzid, strlen(tzid)+1);
else
m_tzid = nsnull;
icaltimetype newdatetime = ConvertFromPrtime( ms );
icaltimezone *from_zone = icaltimezone_get_builtin_timezone_from_tzid ( tzid );
if( from_zone )
icaltimezone_convert_time ( &newdatetime, from_zone, currenttimezone );
else {
if( m_tzid )
nsMemory::Free( m_tzid );
m_tzid = nsnull;
}
m_datetime = newdatetime;
return NS_OK;
}
NS_IMETHODIMP oeDateTimeImpl::Clear()
{
m_datetime = icaltime_null_time();
return NS_OK;
}
NS_IMETHODIMP oeDateTimeImpl::GetIsSet(PRBool *retval)
{
*retval = ! icaltime_is_null_time(m_datetime);
return NS_OK;
}
NS_IMETHODIMP oeDateTimeImpl::GetUtc(PRBool *retval)
{
*retval = m_datetime.is_utc;
return NS_OK;
}
NS_IMETHODIMP oeDateTimeImpl::SetUtc(PRBool newval)
{
m_datetime.is_utc = newval;
return NS_OK;
}
void oeDateTimeImpl::AdjustToWeekday( short weekday ) {
short currentday = icaltime_day_of_week( m_datetime );
while( currentday != weekday ) {
m_datetime.day++;
m_datetime = icaltime_normalize( m_datetime );
currentday = icaltime_day_of_week( m_datetime );
}
}
/* readonly attribute string tzid; */
NS_IMETHODIMP oeDateTimeImpl::GetTzID(char **aRetVal)
{
#ifdef ICAL_DEBUG_ALL
printf( "GetTzID() = " );
#endif
if( m_tzid ) {
*aRetVal= (char*) nsMemory::Clone( m_tzid, strlen(m_tzid)+1);
if( *aRetVal == nsnull )
return NS_ERROR_OUT_OF_MEMORY;
} else
*aRetVal= nsnull;
#ifdef ICAL_DEBUG_ALL
printf( "\"%s\"\n", *aRetVal );
#endif
return NS_OK;
}
void oeDateTimeImpl::SetTzID(const char *aNewVal)
{
#ifdef ICAL_DEBUG_ALL
printf( "SetTzID( %s )\n", aNewVal );
#endif
if( m_tzid )
nsMemory::Free( m_tzid );
if( aNewVal )
m_tzid= (char*) nsMemory::Clone( aNewVal, strlen(aNewVal)+1);
else
m_tzid = nsnull;
}
int oeDateTimeImpl::CompareDate( oeDateTimeImpl *anotherdt ) {
if( m_datetime.year == anotherdt->m_datetime.year &&
m_datetime.month == anotherdt->m_datetime.month &&
m_datetime.day == anotherdt->m_datetime.day )
return 0;
return 1;
}

View File

@@ -1,73 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is OEone Corporation.
*
* The Initial Developer of the Original Code is
* OEone Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Mostafa Hosseini (mostafah@oeone.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* Header file for oeDateTimeImpl.cpp containing its CID and CONTRACTID.*/
#ifndef __OE_DATETIMEIMPL_H__
#define __OE_DATETIMEIMPL_H__
#include "oeIICal.h"
extern "C" {
#include "ical.h"
int icaltimezone_get_vtimezone_properties (icaltimezone *zone,
icalcomponent *component);
}
extern icaltimezone *currenttimezone;
#define OE_DATETIME_CID \
{ 0x78b5b255, 0x7450, 0x47c0, { 0xba, 0x16, 0x0a, 0x6e, 0x7e, 0x80, 0x6e, 0x5d } }
#define OE_DATETIME_CONTRACTID "@mozilla.org/oedatetime;1"
class oeDateTimeImpl : public oeIDateTime
{
public:
NS_DECL_ISUPPORTS
NS_DECL_OEIDATETIME
oeDateTimeImpl();
virtual ~oeDateTimeImpl();
void AdjustToWeekday( short weekday );
int CompareDate( oeDateTimeImpl *anotherdt );
void SetTzID(const char *aNewVal);
/* additional members */
struct icaltimetype m_datetime;
private:
char *m_tzid;
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,114 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is OEone Calendar Code, released October 31st, 2001.
*
* The Initial Developer of the Original Code is
* OEone Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s): Mostafa Hosseini <mostafah@oeone.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* Header file for oeICalContainerImpl.cpp containing its CID and CONTRACTID.*/
#include "oeIICal.h"
#include "oeICalImpl.h"
#include "oeICalEventImpl.h"
#include "oeICalTodoImpl.h"
#include "nsISupportsArray.h"
#define OE_ICALCONTAINER_CID \
{ 0x10697055, 0x4199, 0x4c2a, { 0x89, 0xf4, 0x60, 0x24, 0x3a, 0x8c, 0x76, 0xca } }
#define OE_ICALCONTAINER_CONTRACTID "@mozilla.org/ical-container;1"
class oeFilterDateTime : public oeIDateTime
{
public:
NS_DECL_ISUPPORTS
NS_DECL_OEIDATETIME
oeFilterDateTime();
virtual ~oeFilterDateTime();
void SetFieldType( PRInt32 type );
class oeICalContainerFilter *m_parent;
private:
struct icaltimetype m_datetime;
PRInt32 m_icaltype;
};
class oeICalContainerFilter : public oeIICalTodo
{
public:
NS_DECL_ISUPPORTS
NS_DECL_OEIICALEVENT
NS_DECL_OEIICALTODO
oeICalContainerFilter();
virtual ~oeICalContainerFilter();
nsCOMPtr<nsISupportsArray> m_calendarArray;
void UpdateAllFilters( PRInt32 icaltype );
private:
oeFilterDateTime *m_completed;
};
class oeICalContainerImpl : public oeIICalContainer
{
public:
oeICalContainerImpl();
virtual ~oeICalContainerImpl();
/**
* This macro expands into a declaration of the nsISupports interface.
* Every XPCOM component needs to implement nsISupports, as it acts
* as the gateway to other interfaces this component implements. You
* could manually declare QueryInterface, AddRef, and Release instead
* of using this macro, but why?
*/
// nsISupports interface
NS_DECL_ISUPPORTS
/**
* This macro is defined in the nsISample.h file, and is generated
* automatically by the xpidl compiler. It expands to
* declarations of all of the methods required to implement the
* interface. xpidl will generate a NS_DECL_[INTERFACENAME] macro
* for each interface that it processes.
*
* The methods of nsISample are discussed individually below, but
* commented out (because this macro already defines them.)
*/
NS_DECL_OEIICALCONTAINER
icaltimetype GetNextEvent( icaltimetype starting );
private:
bool m_batchMode;
bool m_suppressAlarmsByDefault;
nsCOMPtr<nsISupportsArray> m_calendarArray;
nsCOMPtr<nsISupportsArray> m_observerArray;
nsCOMPtr<nsISupportsArray> m_todoobserverArray;
oeICalContainerFilter *m_filter;
};

File diff suppressed because it is too large Load Diff

View File

@@ -1,188 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is OEone Calendar Code, released October 31st, 2001.
*
* The Initial Developer of the Original Code is
* OEone Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s): Mostafa Hosseini <mostafah@oeone.com>
* ArentJan Banck <ajbanck@planet.nl>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* Header file for oeICalEventImpl.cpp containing its CID and CONTRACTID.*/
#ifndef _OEICALEVENTIMPL_H_
#define _OEICALEVENTIMPL_H_
#include "oeIICal.h"
#include "oeDateTimeImpl.h"
#include "nsISimpleEnumerator.h"
#include "nsISupportsPrimitives.h"
#include "nsSupportsPrimitives.h"
#include "nsISupportsArray.h"
#include "nsString.h"
#include "nsVoidArray.h"
extern "C" {
#include "ical.h"
}
#define OE_ICALEVENT_CID \
{ 0x31bda500, 0xee5e, 0x4a4a, { 0x9a, 0xb4, 0x7b, 0x4b, 0x3e, 0x87, 0x40, 0x05 } }
#define OE_ICALEVENT_CONTRACTID "@mozilla.org/icalevent;1"
#define ICALEVENT_VERSION "2.0"
#define ICALEVENT_PRODID "-//Mozilla.org/NONSGML Mozilla Calendar V1.0//EN"
/* event enumerator */
class
oeEventEnumerator : public nsISimpleEnumerator
{
public:
oeEventEnumerator();
virtual ~oeEventEnumerator();
// nsISupports interface
NS_DECL_ISUPPORTS
// nsISimpleEnumerator interface
NS_DECL_NSISIMPLEENUMERATOR
NS_IMETHOD AddEvent( nsISupports *event );
private:
PRUint32 mCurrentIndex;
nsCOMPtr<nsISupportsArray> mEventVector;
};
class
oeDateEnumerator : public nsISimpleEnumerator
{
public:
oeDateEnumerator();
virtual ~oeDateEnumerator();
// nsISupports interface
NS_DECL_ISUPPORTS
// nsISimpleEnumerator interface
NS_DECL_NSISIMPLEENUMERATOR
NS_IMETHOD AddDate( PRTime date );
private:
PRInt32 mCurrentIndex;
nsVoidArray mDateVector;
};
/* oeIcalEvent Header file */
class oeICalEventImpl : public oeIICalEvent
{
public:
NS_DECL_ISUPPORTS
NS_DECL_OEIICALEVENT
oeICalEventImpl();
virtual ~oeICalEventImpl();
/* additional members */
bool ParseIcalComponent( icalcomponent *vcalendar );
icalcomponent *AsIcalComponent();
icaltimetype GetNextAlarmTime( icaltimetype begin );
bool matchId( const char *id );
icaltimetype GetNextRecurrence( icaltimetype begin, bool *isbeginning );
icaltimetype GetPreviousOccurrence( icaltimetype beforethis );
icaltimetype CalculateEventTime( icaltimetype alarmtime );
void ChopAndAddEventToEnum( struct icaltimetype startdate, nsISimpleEnumerator **eventlist,
bool isallday, bool isbeginning );
void SetType( Componenttype type );
private:
Componenttype m_type;
char *m_id;
char *m_syncid;
nsCString m_title;
nsCString m_description;
nsCString m_location;
nsCString m_category;
nsCString m_url;
short m_priority;
eventMethodProperty m_method;
eventStatusProperty m_status;
bool m_isprivate;
bool m_allday;
bool m_hasalarm;
unsigned long m_alarmlength;
icalparameter_related m_alarmtriggerrelation;
char *m_alarmunits;
char *m_alarmemail;
char *m_inviteemail;
short m_recurtype;
unsigned long m_recurinterval;
unsigned long m_recurcount;
bool m_recur;
bool m_recurforever;
char *m_recurunits;
short m_recurweekdays;
short m_recurweeknumber;
icaldurationtype m_duration;
oeDateTimeImpl *m_start;
oeDateTimeImpl *m_end;
oeDateTimeImpl *m_stamp;
oeDateTimeImpl *m_recurend;
bool m_storeingmt;
icaltimetype m_lastalarmack;
icaltimetype m_lastmodified;
nsVoidArray m_exceptiondates;
nsVoidArray m_snoozetimes;
icaltimetype CalculateAlarmTime( icaltimetype date );
bool IsExcepted( PRTime date );
icaldurationtype GetLength();
nsCOMPtr<nsISupportsArray> m_attachments;
nsCOMPtr<nsISupportsArray> m_contacts;
nsCOMPtr<oeIICal> m_calendar;
};
/*******************************************************************************************/
#define OE_ICALEVENTDISPLAY_CONTRACTID "@mozilla.org/icaleventdisplay;1"
class oeICalEventDisplayImpl : public oeIICalEventDisplay
{
public:
NS_DECL_ISUPPORTS
NS_FORWARD_OEIICALEVENT(mEvent->)
NS_DECL_OEIICALEVENTDISPLAY
oeICalEventDisplayImpl( oeIICalEvent *event );
virtual ~oeICalEventDisplayImpl();
private:
icaltimetype m_displaydate;
icaltimetype m_displaydateend;
nsCOMPtr<oeIICalEvent> mEvent;
};
#endif

View File

@@ -1,84 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is OEone Calendar Code, released October 31st, 2001.
*
* The Initial Developer of the Original Code is
* OEone Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s): Mostafa Hosseini <mostafah@oeone.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* Factory implementation of various calendar objects */
#include "oeICalImpl.h"
#include "oeICalContainerImpl.h"
#include "oeICalEventImpl.h"
#include "oeDateTimeImpl.h"
#include "nsIGenericFactory.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(oeICalImpl)
NS_GENERIC_FACTORY_CONSTRUCTOR(oeICalContainerImpl)
NS_GENERIC_FACTORY_CONSTRUCTOR(oeICalEventImpl)
NS_GENERIC_FACTORY_CONSTRUCTOR(oeICalTodoImpl)
NS_GENERIC_FACTORY_CONSTRUCTOR(oeDateTimeImpl)
static const nsModuleComponentInfo pModuleInfo[] =
{
{ "ICal Service",
OE_ICAL_CID,
OE_ICAL_CONTRACTID,
oeICalImplConstructor,
},
{ "ICal Container",
OE_ICALCONTAINER_CID,
OE_ICALCONTAINER_CONTRACTID,
oeICalContainerImplConstructor,
},
{ "ICal Event",
OE_ICALEVENT_CID,
OE_ICALEVENT_CONTRACTID,
oeICalEventImplConstructor,
},
{ "ICal DateTime",
OE_DATETIME_CID,
OE_DATETIME_CONTRACTID,
oeDateTimeImplConstructor,
},
{ "ICal Todo",
OE_ICALTODO_CID,
OE_ICALTODO_CONTRACTID,
oeICalTodoImplConstructor,
}
};
NS_IMPL_NSGETMODULE( oeICalModule, pModuleInfo)

File diff suppressed because it is too large Load Diff

View File

@@ -1,199 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is OEone Calendar Code, released October 31st, 2001.
*
* The Initial Developer of the Original Code is
* OEone Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s): Mostafa Hosseini <mostafah@oeone.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* Header file for oeICalImpl.cpp containing its CID and CONTRACTID. It also includes
the implementation for an event linked-list used throughout the code */
#ifndef _OEICALIMPL_H_
#define _OEICALIMPL_H_
#include "oeIICal.h"
#include "nsITimer.h"
#include "oeICalEventImpl.h"
#include "oeICalTodoImpl.h"
#include "nsVoidArray.h"
#define OE_ICAL_CID \
{ 0x0a8c5de7, 0x0d19, 0x4b95, { 0x82, 0xf4, 0xe0, 0xaf, 0x92, 0x45, 0x32, 0x27 } }
#define OE_ICAL_CONTRACTID "@mozilla.org/ical;1"
extern "C" {
#include "ical.h"
}
class TodoList {
public:
oeIICalTodo* todo;
TodoList* next;
TodoList() {
todo = nsnull;
next = nsnull;
}
~TodoList() {
if( todo )
todo->Release();
if( next )
delete next;
}
void Add( oeIICalTodo* e) {
if( !todo ) {
todo = e;
} else {
if( !next ) {
next = new TodoList();
}
next->Add( e );
}
}
oeIICalTodo* GetTodoById( const char *id ) {
if( !todo )
return nsnull;
if( ((oeICalTodoImpl *)todo)->matchId( id ) )
return todo;
if( next )
return next->GetTodoById( id );
return nsnull;
}
void Remove( const char *id ) {
if( !todo )
return;
if( ((oeICalTodoImpl *)todo)->matchId( id ) ) {
todo->Release();
if( next ) {
todo = next->todo;
TodoList *tmp = next;
next = next->next;
tmp->next = nsnull;
tmp->todo = nsnull;
delete tmp;
} else {
todo = nsnull;
}
} else {
if( next )
next->Remove( id );
}
}
};
class oeICalFilter : public oeIICalTodo
{
public:
NS_DECL_ISUPPORTS
NS_DECL_OEIICALEVENT
NS_DECL_OEIICALTODO
oeICalFilter();
virtual ~oeICalFilter();
oeDateTimeImpl *m_completed;
private:
/* char *m_id;
char *m_syncid;
char *m_title;
char *m_description;
char *m_location;
char *m_category;
bool m_isprivate;
bool m_allday;
bool m_hasalarm;
unsigned long m_alarmlength;
char *m_alarmunits;
char *m_alarmemail;
char *m_inviteemail;
short m_recurtype;
unsigned long m_recurinterval;
bool m_recur;
bool m_recurforever;
char *m_recurunits;
short m_recurweekdays;
short m_recurweeknumber;
oeDateTimeImpl *m_start;
oeDateTimeImpl *m_end;
oeDateTimeImpl *m_recurend;
icaltimetype m_lastalarmack;
int m_percent;
oeDateTimeImpl *m_due;*/
};
class oeICalImpl : public oeIICal
{
public:
oeICalImpl();
virtual ~oeICalImpl();
/**
* This macro expands into a declaration of the nsISupports interface.
* Every XPCOM component needs to implement nsISupports, as it acts
* as the gateway to other interfaces this component implements. You
* could manually declare QueryInterface, AddRef, and Release instead
* of using this macro, but why?
*/
// nsISupports interface
NS_DECL_ISUPPORTS
/**
* This macro is defined in the nsISample.h file, and is generated
* automatically by the xpidl compiler. It expands to
* declarations of all of the methods required to implement the
* interface. xpidl will generate a NS_DECL_[INTERFACENAME] macro
* for each interface that it processes.
*
* The methods of nsISample are discussed individually below, but
* commented out (because this macro already defines them.)
*/
NS_DECL_OEIICAL
void SetupAlarmManager();
icaltimetype GetNextEvent( icaltimetype starting );
nsVoidArray *GetEventList();
private:
nsCOMPtr<nsISupportsArray> m_observerlist;
nsCOMPtr<nsISupportsArray> m_todoobserverlist;
bool m_batchMode;
bool m_suppressAlarms;
nsVoidArray m_eventlist;
TodoList m_todolist;
nsITimer *m_alarmtimer;
nsCString m_serveraddr;
oeICalFilter *m_filter;
bool SatisfiesFilter( oeIICalTodo *comp );
void ChopAndAddEventToEnum( struct icaltimetype startdate,
nsISimpleEnumerator **eventlist, oeICalEventImpl* event, bool isallday, bool isbeginning );
void CancelAlarmTimer();
};
#endif

View File

@@ -1,376 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Calendar Code.
*
* The Initial Developer of the Original Code is
* Chris Charabaruk <ccharabaruk@meldstar.com>.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s): Chris Charabaruk <ccharabaruk@meldstar.com>
* Mostafa Hosseini <mostafah@oeone.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* This file implements an XPCOM object which represents a calendar task(todo) object. It is a derivation
of the event object which adds fields exclusive to tasks.
*/
#ifndef WIN32
#include <unistd.h>
#endif
#include "oeICalEventImpl.h"
#include "oeICalTodoImpl.h"
#include "nsMemory.h"
#include "nsCOMPtr.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIServiceManager.h"
#define strcasecmp strcmp
#define RECUR_NONE 0
#define RECUR_DAILY 1
#define RECUR_WEEKLY 2
#define RECUR_MONTHLY_MDAY 3
#define RECUR_MONTHLY_WDAY 4
#define RECUR_YEARLY 5
/* Implementation file */
NS_IMPL_ISUPPORTS2(oeICalTodoImpl, oeIICalTodo, oeIICalEvent)
icaltimetype ConvertFromPrtime( PRTime indate );
PRTime ConvertToPrtime ( icaltimetype indate );
nsresult
NS_NewICalTodo( oeIICalTodo** inst )
{
NS_PRECONDITION(inst != nsnull, "null ptr");
if (! inst)
return NS_ERROR_NULL_POINTER;
*inst = new oeICalTodoImpl();
if (! *inst)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*inst);
return NS_OK;
}
oeICalTodoImpl::oeICalTodoImpl()
{
#ifdef ICAL_DEBUG
printf( "oeICalTodoImpl::oeICalTodoImpl()\n" );
#endif
mEvent = new oeICalEventImpl();
NS_ADDREF( mEvent );
mEvent->SetType( XPICAL_VTODO_COMPONENT );
/* member initializers and constructor code */
nsresult rv;
if( NS_FAILED( rv = NS_NewDateTime((oeIDateTime**) &m_completed ))) {
m_completed = nsnull;
}
m_percent = 0;
//Some defaults are different for todos, apply them
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
if ( NS_SUCCEEDED(rv) && prefBranch ) {
nsXPIDLCString tmpstr;
PRInt32 tmpint;
rv = prefBranch->GetIntPref("calendar.alarms.onfortodos", &tmpint);
if (NS_SUCCEEDED(rv))
SetAlarm( tmpint );
rv = prefBranch->GetIntPref("calendar.alarms.todoalarmlen", &tmpint);
if (NS_SUCCEEDED(rv))
SetAlarmLength( tmpint );
rv = prefBranch->GetCharPref("calendar.alarms.todoalarmunit", getter_Copies(tmpstr));
if (NS_SUCCEEDED(rv))
SetAlarmUnits( PromiseFlatCString( tmpstr ).get() );
}
}
oeICalTodoImpl::~oeICalTodoImpl()
{
#ifdef ICAL_DEBUG_ALL
printf( "oeICalTodoImpl::~oeICalTodoImpl()\n");
#endif
/* destructor code */
if( m_completed )
m_completed->Release();
mEvent->Release();
}
bool oeICalTodoImpl::matchId( const char *id ) {
return mEvent->matchId( id );
}
/* readonly attribute oeIDateTime due; */
NS_IMETHODIMP oeICalTodoImpl::GetDue(oeIDateTime * *due)
{
return mEvent->GetEnd( due );
}
/* areadonly attribute oeIDateTime completed; */
NS_IMETHODIMP oeICalTodoImpl::GetCompleted(oeIDateTime * *completed)
{
*completed = m_completed;
NS_ADDREF(*completed);
return NS_OK;
}
/* attribute short percent; */
NS_IMETHODIMP oeICalTodoImpl::GetPercent(PRInt16 *aRetVal)
{
#ifdef ICAL_DEBUG_ALL
printf( "GetPercent() = " );
#endif
*aRetVal = m_percent;
#ifdef ICAL_DEBUG_ALL
printf( "%d\n", *aRetVal );
#endif
return NS_OK;
}
NS_IMETHODIMP oeICalTodoImpl::SetPercent(PRInt16 aNewVal)
{
#ifdef ICAL_DEBUG_ALL
printf( "SetPercent( %d )\n", aNewVal );
#endif
m_percent = aNewVal;
return NS_OK;
}
NS_IMETHODIMP oeICalTodoImpl::Clone( oeIICalTodo **ev )
{
#ifdef ICAL_DEBUG_ALL
printf( "oeICalTodoImpl::Clone()\n" );
#endif
nsresult rv;
oeICalTodoImpl *icaltodo =nsnull;
if( NS_FAILED( rv = NS_NewICalTodo( (oeIICalTodo**) &icaltodo ) ) ) {
return rv;
}
icalcomponent *vcalendar = AsIcalComponent();
if ( !vcalendar ) {
#ifdef ICAL_DEBUG
printf( "oeICalTodoImpl::Clone() failed!\n" );
#endif
icaltodo->Release();
return NS_OK;
}
icalcomponent *vtodo = icalcomponent_get_first_component( vcalendar, ICAL_VTODO_COMPONENT );
if( !(icaltodo->ParseIcalComponent( vtodo )) ) {
#ifdef ICAL_DEBUG
printf( "oeICalTodoImpl::Clone() failed.\n" );
#endif
icaltodo->Release();
return NS_OK;
}
*ev = icaltodo;
return NS_OK;
}
NS_IMETHODIMP oeICalTodoImpl::GetTodoIcalString(nsACString& aRetVal)
{
#ifdef ICAL_DEBUG_ALL
printf( "oeICalTodoImpl::GetTodoIcalString() = " );
#endif
icalcomponent *vcalendar = AsIcalComponent();
if ( !vcalendar ) {
#ifdef ICAL_DEBUG
printf( "oeICalTodoImpl::GetTodoIcalString() failed!\n" );
#endif
return NS_OK;
}
char *str = icalcomponent_as_ical_string( vcalendar );
if( str ) {
aRetVal = str;
} else
aRetVal.Truncate();
icalcomponent_free( vcalendar );
#ifdef ICAL_DEBUG_ALL
printf( "\"%s\"\n", PromiseFlatCString( aRetVal ).get() );
#endif
return NS_OK;
}
NS_IMETHODIMP oeICalTodoImpl::ParseTodoIcalString(const nsACString& aNewVal, PRBool *aRetVal)
{
#ifdef ICAL_DEBUG_ALL
printf( "oeICalTodoImpl::ParseTodoIcalString( %s )\n", PromiseFlatCString( aNewVal ).get() );
#endif
*aRetVal = false;
icalcomponent *comp = icalparser_parse_string( PromiseFlatCString( aNewVal ).get() );
if( comp ) {
if( ParseIcalComponent( comp ) )
*aRetVal = true;
icalcomponent_free( comp );
}
return NS_OK;
}
bool oeICalTodoImpl::ParseIcalComponent( icalcomponent *comp )
{
#ifdef ICAL_DEBUG_ALL
printf( "ParseIcalComponent()\n" );
#endif
icalcomponent *vtodo=nsnull;
icalcomponent_kind kind = icalcomponent_isa( comp );
if( kind == ICAL_VCALENDAR_COMPONENT )
vtodo = icalcomponent_get_first_component( comp , ICAL_VTODO_COMPONENT );
else if( kind == ICAL_VTODO_COMPONENT )
vtodo = comp;
if ( !vtodo ) {
#ifdef ICAL_DEBUG
printf( "oeICalTodoImpl::ParseIcalComponent() failed: vtodo is NULL!\n" );
#endif
return false;
}
//First parse all basic properties
((oeICalEventImpl *)mEvent)->ParseIcalComponent( vtodo );
//then go on with the extra properties
//percent
icalproperty *prop = icalcomponent_get_first_property( vtodo, ICAL_PERCENTCOMPLETE_PROPERTY );
if ( prop != 0) {
m_percent = icalproperty_get_percentcomplete( prop );
} else {
m_percent = 0;
}
//completed
prop = icalcomponent_get_first_property( vtodo, ICAL_COMPLETED_PROPERTY );
if (prop != 0) {
icaltimetype completed;
completed = icalproperty_get_completed( prop );
m_completed->m_datetime = completed;
} else {
m_completed->m_datetime = icaltime_null_time();
}
return true;
}
icalcomponent* oeICalTodoImpl::AsIcalComponent()
{
#ifdef ICAL_DEBUG_ALL
printf( "AsIcalComponent()\n" );
#endif
icalcomponent *newcalendar;
newcalendar = icalcomponent_new_vcalendar();
if ( !newcalendar ) {
#ifdef ICAL_DEBUG
printf( "oeICalTodoImpl::AsIcalComponent() failed: Cannot create VCALENDAR!\n" );
#endif
return nsnull;
}
icalcomponent *basevcal = ((oeICalEventImpl *)mEvent)->AsIcalComponent();
if ( !basevcal ) {
#ifdef ICAL_DEBUG
printf( "oeICalTodoImpl::AsIcalComponent() failed: Cannot create ical component from mEvent!\n" );
#endif
icalcomponent_free( newcalendar );
return nsnull;
}
//version
icalproperty *prop = icalproperty_new_version( ICALEVENT_VERSION );
icalcomponent_add_property( newcalendar, prop );
//prodid
prop = icalproperty_new_prodid( ICALEVENT_PRODID );
icalcomponent_add_property( newcalendar, prop );
icalcomponent *vtodo = icalcomponent_new_vtodo();
icalcomponent *vevent = icalcomponent_get_first_component( basevcal, ICAL_VEVENT_COMPONENT );
for( prop = icalcomponent_get_first_property( vevent, ICAL_ANY_PROPERTY );
prop != 0 ;
prop = icalcomponent_get_next_property( vevent, ICAL_ANY_PROPERTY ) ) {
icalproperty *newprop;
icalproperty_kind propkind = icalproperty_isa( prop );
if( propkind == ICAL_X_PROPERTY ) {
newprop = icalproperty_new_x( icalproperty_get_value_as_string( prop ) );
icalproperty_set_x_name( newprop, icalproperty_get_x_name( prop ));
icalparameter *oldpar = icalproperty_get_first_parameter( prop, ICAL_MEMBER_PARAMETER );
icalparameter *newpar = icalparameter_new_member( icalparameter_get_member( oldpar ) );
icalproperty_add_parameter( newprop, newpar );
} else if( propkind == ICAL_DTEND_PROPERTY ) {
//Change DTEND to DUE
newprop = icalproperty_new_due( icalproperty_get_dtend( prop ) );
icalparameter *oldpar = icalproperty_get_first_parameter( prop, ICAL_TZID_PARAMETER );
if( oldpar ) {
icalparameter *newpar = icalparameter_new_tzid( icalparameter_get_tzid( oldpar ) );
icalproperty_add_parameter( newprop, newpar );
}
} else {
newprop = icalproperty_new_clone( prop );
}
icalcomponent_add_property( vtodo, newprop );
}
icalcomponent *nestedcomp;
for( nestedcomp = icalcomponent_get_first_component( vevent, ICAL_ANY_COMPONENT );
nestedcomp != 0 ;
nestedcomp = icalcomponent_get_next_component( vevent, ICAL_ANY_COMPONENT ) ) {
icalcomponent_add_component( vtodo, icalcomponent_new_clone(nestedcomp) );
}
icalcomponent_free( basevcal );
//percent
if( m_percent != 0) {
prop = icalproperty_new_percentcomplete( m_percent );
icalcomponent_add_property( vtodo, prop );
}
//completed
if( m_completed && !icaltime_is_null_time( m_completed->m_datetime ) ) {
prop = icalproperty_new_completed( m_completed->m_datetime );
icalcomponent_add_property( vtodo, prop );
}
//add event to newcalendar
icalcomponent_add_component( newcalendar, vtodo );
return newcalendar;
}
oeICalEventImpl *oeICalTodoImpl::GetBaseEvent() {
return mEvent;
}
/* End of implementation class template. */

View File

@@ -1,79 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Calendar Code.
*
* The Initial Developer of the Original Code is
* Chris Charabaruk <ccharabaruk@meldstar.com>.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s): Chris Charabaruk <ccharabaruk@meldstar.com>
* Mostafa Hosseini <mostafah@oeone.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* Header file for oeICalTodoImpl.cpp containing its CID and CONTRACTID.*/
#ifndef _OEICALTODOIMPL_H_
#define _OEICALTODOIMPL_H_
#include "oeIICal.h"
#include "oeDateTimeImpl.h"
#include "nsISimpleEnumerator.h"
#include "nsISupportsPrimitives.h"
#include "nsSupportsPrimitives.h"
extern "C" {
#include "ical.h"
}
#define OE_ICALTODO_CID { 0x0c06905a, 0x1dd2, 0x11b2, { 0xba, 0x61, 0xc9, 0x5d, 0x84, 0x0b, 0x01, 0xef } }
#define OE_ICALTODO_CONTRACTID "@mozilla.org/icaltodo;1"
/* oeICalTodo Header file */
class oeICalTodoImpl : public oeIICalTodo
{
public:
NS_DECL_ISUPPORTS
NS_FORWARD_OEIICALEVENT(mEvent->)
NS_DECL_OEIICALTODO
oeICalTodoImpl();
virtual ~oeICalTodoImpl();
/* additional members */
bool ParseIcalComponent( icalcomponent *vcalendar );
icalcomponent *AsIcalComponent();
NS_IMETHOD Clone(oeIICalTodo **_retval);
bool matchId( const char *id );
oeICalEventImpl *GetBaseEvent();
private:
int m_percent;
oeDateTimeImpl *m_completed;
oeICalEventImpl *mEvent;
};
#endif

View File

@@ -1,362 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is OEone Calendar Code, released October 31st, 2001.
*
* The Initial Developer of the Original Code is
* OEone Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s): Mostafa Hosseini <mostafah@oeone.com>
* Chris Charabaruk <ccharabaruk@meldstar.com>
* ArentJan Banck <ajbanck@planet.nl>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* The Interface Description of all calendar objects listing various fields and methods of each */
#include "nsISupports.idl"
#include "nsISupportsArray.idl"
interface nsIAbCard;
interface nsIMsgAttachment;
interface nsISimpleEnumerator;
/**
* The uuid is a unique number identifying the interface normally
* called IID. It can be generated as follows:
*
* Windows: guidgen.exe
* Unix: uuidgen which comes with e2fsprogs package
* Mac: ???
* All platform: Using irc, connect to irc.mozilla.org and type in
* /join #mozilla
* /msg mozbot uuid
*
*/
typedef long eventMethodProperty;
typedef long eventStatusProperty;
typedef long Componenttype;
interface oeIICal;
[scriptable, uuid(db180127-cc56-40c6-a8ef-7e329e1c4142)]
interface oeIDateTime : nsISupports
{
attribute short year;
attribute short month;
attribute short day;
attribute short hour;
attribute short minute;
attribute boolean utc;
readonly attribute string tzID;
readonly attribute boolean isSet;
PRTime getTime();
void setTime( in PRTime ms );
void setTimeInTimezone( in PRTime ms, in string tzID );
string toString();
void clear();
};
[scriptable, uuid(89c5cd5a-af2d-45e6-83c7-2f2420a13626)]
interface oeIICalEvent : nsISupports
{
const eventMethodProperty ICAL_METHOD_X = 10011;
const eventMethodProperty ICAL_METHOD_PUBLISH = 10012;
const eventMethodProperty ICAL_METHOD_REQUEST = 10013;
const eventStatusProperty ICAL_STATUS_X = 10028;
const eventStatusProperty ICAL_STATUS_TENTATIVE = 10029;
const eventStatusProperty ICAL_STATUS_CONFIRMED = 10030;
const eventStatusProperty ICAL_STATUS_COMPLETED = 10031;
const eventStatusProperty ICAL_STATUS_NEEDSACTION = 10032;
const eventStatusProperty ICAL_STATUS_CANCELLED = 10033;
const eventStatusProperty ICAL_STATUS_INPROCESS = 10034;
const eventStatusProperty ICAL_STATUS_DRAFT = 10035;
const eventStatusProperty ICAL_STATUS_FINAL = 10036;
const eventStatusProperty ICAL_STATUS_NONE = 10037;
const Componenttype XPICAL_VEVENT_COMPONENT = 4;
const Componenttype XPICAL_VTODO_COMPONENT = 5;
readonly attribute oeIDateTime start;
readonly attribute oeIDateTime end;
readonly attribute oeIDateTime stamp;
attribute oeIICal parent;
readonly attribute Componenttype type;
readonly attribute PRTime lastModified;
attribute string id;
attribute AUTF8String title;
attribute AUTF8String description;
attribute AUTF8String location;
attribute AUTF8String categories;
attribute boolean privateEvent;
attribute string syncId;
attribute boolean allDay;
attribute boolean alarm;
attribute string alarmUnits;
attribute unsigned long alarmLength;
attribute string alarmEmailAddress;
attribute string inviteEmailAddress;
attribute unsigned long recurInterval;
attribute unsigned long recurCount;
readonly attribute oeIDateTime recurEnd;
attribute boolean recur;
attribute string recurUnits;
attribute boolean recurForever;
attribute short recurWeekdays;
attribute short recurWeekNumber;
attribute PRTime lastAlarmAck;
attribute AUTF8String url;
attribute short priority;
attribute eventMethodProperty method;
attribute eventStatusProperty status;
void setDuration( in boolean is_negative, in unsigned short weeks, in unsigned short days, in unsigned short hours,
in unsigned short minutes, in unsigned short seconds );
void getDuration( out boolean is_negative, out unsigned short weeks, out unsigned short days, out unsigned short hours,
out unsigned short minutes, out unsigned short seconds );
boolean getNextRecurrence( in PRTime begin, out PRTime result);
boolean getPreviousOccurrence( in PRTime beforethis, out PRTime result);
AUTF8String getIcalString();
boolean parseIcalString(in AUTF8String icalstr);
void addException( in PRTime exdate );
nsISimpleEnumerator getExceptions();
void removeAllExceptions();
void setSnoozeTime( in PRTime exdate );
oeIICalEvent clone();
//attachments
readonly attribute nsISupportsArray attachmentsArray;
void addAttachment(in nsIMsgAttachment attachment);
void removeAttachment(in nsIMsgAttachment attachment);
void removeAttachments();
//contacts
readonly attribute nsISupportsArray contactsArray;
void addContact(in nsIAbCard contact);
void removeContact(in nsIAbCard contact);
void removeContacts();
void reportError( in short severity, in unsigned long errorid, in string errorstring );
void setParameter( in string name, in string value );
string getParameter( in string name );
void updateLastModified();
};
[scriptable, uuid(f95df40e-0d5f-49ec-9ba8-4b88d3eb53e0)]
interface oeIICalEventDisplay : oeIICalEvent
{
readonly attribute oeIICalEvent event;
attribute PRTime displayDate;
attribute PRTime displayEndDate;
};
[scriptable, uuid(d44987b4-1dd1-11b2-9783-8a78ed685caf)]
interface oeIICalTodo : oeIICalEvent
{
readonly attribute oeIDateTime due;
readonly attribute oeIDateTime completed;
attribute short percent;
AUTF8String getTodoIcalString();
boolean parseTodoIcalString(in AUTF8String icalstr);
};
[scriptable, uuid(b8584baa-1507-40d4-b542-5a2758e1c86d)]
interface oeIICalObserver : nsISupports
{
void onStartBatch();
void onEndBatch();
void onLoad();
void onAddItem( in oeIICalEvent e);
void onModifyItem( in oeIICalEvent e, in oeIICalEvent olde );
void onDeleteItem( in oeIICalEvent e);
void onAlarm( in oeIICalEventDisplay e);
void onError( in short severity, in unsigned long errorid, in string errorstring );
};
[scriptable, uuid(7a4fd625-69a8-4008-932e-cccc227b402c)]
interface oeIICalTodoObserver : nsISupports
{
void onStartBatch();
void onEndBatch();
void onLoad();
void onAddItem( in oeIICalTodo e);
void onModifyItem( in oeIICalTodo e, in oeIICalTodo olde );
void onDeleteItem( in oeIICalTodo e);
void onAlarm( in oeIICalEventDisplay e);
void onError( in short severity, in unsigned long errorid, in string errorstring );
};
[scriptable, uuid(981ab93d-ad51-45bb-a4a2-e158c2cfdeb4)]
interface oeIICal : nsISupports
{
void Test();
attribute boolean batchMode;
readonly attribute oeIICalTodo filter;
attribute AUTF8String server;
attribute boolean suppressAlarms;
void addObserver( in oeIICalObserver observer );
void removeObserver( in oeIICalObserver observer );
void addTodoObserver( in oeIICalTodoObserver observer );
void removeTodoObserver( in oeIICalTodoObserver observer );
string addEvent( in oeIICalEvent icalevent );
string modifyEvent( in oeIICalEvent icalevent );
void deleteEvent( in string id );
oeIICalEvent fetchEvent( in string id );
// nsISimpleEnumerator searchBySQL( in string sqlstr );
/**
*
* GetAllEvents
*
* DESCRIPTION: Returns a list of all the events in this calendar in an enumerator.
* The events are sorted based on the order of their next occurence if they recur in
* the future or their last occurence in the past otherwise.
* Here's a presentation of the sort criteria using the time axis:
* -----(Last occurence of Event1)---(Last occurence of Event2)----(Now)----(Next occurence of Event3)---->
* (Note that Event1 and Event2 will not recur in the future.)
*/
nsISimpleEnumerator getAllEvents();
/**
* For all the getEvents* and get*EventForRange methods:
* Get events for a certain range. items are oeIICalEventDisplay
*/
nsISimpleEnumerator getEventsForMonth( in PRTime date );
nsISimpleEnumerator getEventsForWeek( in PRTime date );
nsISimpleEnumerator getEventsForDay( in PRTime date );
nsISimpleEnumerator getEventsForRange( in PRTime begindate, in PRTime enddate );
nsISimpleEnumerator getNextNEvents( in PRTime begindate, in long count );
nsISimpleEnumerator getFirstEventsForRange( in PRTime begindate, in PRTime enddate );
string addTodo( in oeIICalTodo icaltodo );
string modifyTodo( in oeIICalTodo icaltodo );
void deleteTodo( in string id );
oeIICalTodo fetchTodo( in string id );
nsISimpleEnumerator getAllTodos();
void resetFilter();
void reportError( in short severity, in unsigned long errorid, in string errorstring );
};
[scriptable, uuid(c89ec938-f690-4f62-a4b3-11e962ba2314)]
interface oeIICalContainer : nsISupports
{
attribute boolean batchMode;
attribute boolean suppressAlarmsByDefault;
readonly attribute oeIICalTodo filter;
/**
* Add a calendar to the container.
* @param server
* a string indicating the server url
* @param type
* a string idicating which type of calendar to add.
* an object with contractid of @mozilla.org/ical;1?type=<type>
* will be created and added. The object should implement
* oeIICal.
* When empty, @mozilla.org/ical;1 will be used
*/
void addCalendar( in AUTF8String server, in string type );
void removeCalendar( in AUTF8String server );
oeIICal getCalendar( in AUTF8String server );
void addCalendars( in unsigned long serverCount, [array, size_is(serverCount)] in wstring servers );
void addObserver( in oeIICalObserver observer );
void removeObserver( in oeIICalObserver observer );
void addTodoObserver( in oeIICalTodoObserver observer );
void removeTodoObserver( in oeIICalTodoObserver observer );
string addEvent( in oeIICalEvent icalevent, in AUTF8String server );
string modifyEvent( in oeIICalEvent icalevent );
void deleteEvent( in string id );
oeIICalEvent fetchEvent( in string id );
nsISimpleEnumerator getAllEvents();
/**
* For all the getEvents* and get*EventForRange methods:
* Get events for a certain range. items are oeIICalEventDisplay
*/
nsISimpleEnumerator getEventsForMonth( in PRTime date );
/**
* Get the events starting at the beginning of |date|
* until 7 days later
*/
nsISimpleEnumerator getEventsForWeek( in PRTime date );
nsISimpleEnumerator getEventsForDay( in PRTime date );
nsISimpleEnumerator getEventsForRange( in PRTime begindate, in PRTime enddate );
nsISimpleEnumerator getNextNEvents( in PRTime begindate, in long count );
/**
* Get the first occurence of the events in the given time range
*/
nsISimpleEnumerator getFirstEventsForRange( in PRTime begindate, in PRTime enddate );
string addTodo( in oeIICalTodo icaltodo, in AUTF8String server );
string modifyTodo( in oeIICalTodo icaltodo );
void deleteTodo( in string id );
oeIICalTodo fetchTodo( in string id );
nsISimpleEnumerator getAllTodos();
void resetFilter();
void reportError( in short severity, in unsigned long errorid, in string errorstring );
};
[scriptable, uuid(0d42d962-e5fd-428b-b622-867928c9b669)]
interface oeIICalError : nsISupports
{
//severity codes
const long CAL_DEBUG = 0;
const long CAL_WARN = 1;
const long CAL_PROBLEM = 2;
const long CAL_CRITICAL = 3;
//error codes
const long UID_NOT_FOUND = 1001;
};
%{ C++
extern nsresult
NS_NewICal(oeIICal** inst);
extern nsresult
NS_NewICalEvent(oeIICalEvent** inst);
extern nsresult
NS_NewICalTodo(oeIICalTodo** inst);
extern nsresult
NS_NewDateTime(oeIDateTime** inst);
extern nsresult
NS_NewICalEventDisplay( oeIICalEvent* event, oeIICalEventDisplay** inst );
#define GENERATE_CAL_FAILURE(x) \
(NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_CALENDAR,x))
#define NS_ERROR_CAL_UID_NOT_FOUND \
GENERATE_CAL_FAILURE(oeIICalError::UID_NOT_FOUND)
%}

View File

@@ -1,58 +0,0 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MOZILLA_INTERNAL_API = 1
REQUIRES = xpcom \
calendar \
string \
$(NULL)
PROGRAM = TestIcal$(BIN_SUFFIX)
CPPSRCS = TestIcal.cpp
LIBS = $(MOZ_COMPONENT_LIBS)
include $(topsrcdir)/config/rules.mk

View File

@@ -1,86 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is OEone Calendar Code, released October 31st, 2001.
*
* The Initial Developer of the Original Code is
* OEone Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s): Mostafa Hosseini <mostafah@oeone.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <oeIICal.h>
#include <nsIServiceManager.h>
#include "nsString.h"
#include "nsIComponentRegistrar.h"
#include "stdio.h"
#define OE_ICAL_CONTRACTID "@mozilla.org/ical;1"
int
main(PRInt32 argc, char *argv[])
{
nsresult rv;
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
registrar->AutoRegister(nsnull);
// Create an instance of our component
nsCOMPtr<oeIICal> mysample = do_CreateInstance(OE_ICAL_CONTRACTID, &rv);
if (NS_FAILED(rv))
{
printf("ERROR: Cannot create instance of component " OE_ICAL_CONTRACTID " [%x].\n"
"Debugging hint:\n"
"\tsetenv NSPR_LOG_MODULES nsComponentManager:5\n"
"\tsetenv NSPR_LOG_FILE xpcom.log\n"
"\t./TestICal\n"
"\t<check the contents for xpcom.log for possible cause of error>.\n",
rv);
return -2;
}
mysample->SetServer( NS_LITERAL_CSTRING("/tmp/.oecalendar") );
rv = mysample->Test();
if ( NS_FAILED(rv) )
{
printf("ERROR: Calling oeIICal::Test()\n");
return 0;
}
printf("Test finished\n");
// Shutdown XPCOM
NS_ShutdownXPCOM(nsnull);
return 0;
}

View File

@@ -1,360 +0,0 @@
/*
** Copyright (C) 1998-1999 Greg Stein. All Rights Reserved.
**
** By using this file, you agree to the terms and conditions set forth in
** the LICENSE.html file which can be found at the top level of the mod_dav
** distribution or at http://www.webdav.org/mod_dav/license-1.html.
**
** Contact information:
** Greg Stein, PO Box 3151, Redmond, WA, 98073
** gstein@lyra.org, http://www.webdav.org/mod_dav/
*/
/*
** DAV opaquelocktoken scheme implementation
**
** Written 5/99 by Keith Wannamaker, wannamak@us.ibm.com
** Adapted from ISO/DCE RPC spec and a former Internet Draft
** by Leach and Salz:
** http://www.ics.uci.edu/pub/ietf/webdav/uuid-guid/draft-leach-uuids-guids-01
**
** Portions of the code are covered by the following license:
**
** Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc.
** Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. &
** Digital Equipment Corporation, Maynard, Mass.
** Copyright (c) 1998 Microsoft.
** To anyone who acknowledges that this file is provided "AS IS"
** without any express or implied warranty: permission to use, copy,
** modify, and distribute this file for any purpose is hereby
** granted without fee, provided that the above copyright notices and
** this notice appears in all source code copies, and that none of
** the names of Open Software Foundation, Inc., Hewlett-Packard
** Company, or Digital Equipment Corporation be used in advertising
** or publicity pertaining to distribution of the software without
** specific, written prior permission. Neither Open Software
** Foundation, Inc., Hewlett-Packard Company, Microsoft, nor Digital Equipment
** Corporation makes any representations about the suitability of
** this software for any purpose.
*/
/*This file was stolen from webtools/mozbot/uuidgen/token.c */
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <ctype.h>
#include "md5.h"
#include "token.h"
#ifdef WIN32
#include <windows.h>
#else
#include <sys/types.h>
#include <sys/time.h>
#include <unistd.h>
#ifdef XP_BEOS
#include <be/net/netdb.h>
#endif
#endif
/* set the following to the number of 100ns ticks of the actual resolution of
your system's clock */
#define UUIDS_PER_TICK 1024
/* Set this to what your compiler uses for 64 bit data type */
#ifdef WIN32
#define unsigned64_t unsigned __int64
#define I64(C) C
#else
#define unsigned64_t unsigned long long
#define I64(C) C##LL
#endif
typedef unsigned64_t uuid_time_t;
static void format_uuid_v1(uuid_t * uuid, unsigned16 clockseq, uuid_time_t timestamp, uuid_node_t node);
static void get_current_time(uuid_time_t * timestamp);
static unsigned16 true_random(void);
static void get_pseudo_node_identifier(uuid_node_t *node);
static void get_system_time(uuid_time_t *uuid_time);
static void get_random_info(unsigned char seed[16]);
/* dav_create_opaquelocktoken - generates a UUID version 1 token.
* Clock_sequence and node_address set to pseudo-random
* numbers during init.
*
* Should postpend pid to account for non-seralized creation?
*/
int create_token(uuid_state *st, uuid_t *u)
{
uuid_time_t timestamp;
get_current_time(&timestamp);
format_uuid_v1(u, st->cs, timestamp, st->node);
return 1;
}
/*
* dav_create_uuid_state - seed UUID state with pseudorandom data
*/
void create_uuid_state(uuid_state *st)
{
st->cs = true_random();
get_pseudo_node_identifier(&st->node);
}
/*
* dav_format_opaquelocktoken - generates a text representation
* of an opaquelocktoken
*/
void format_token(char *target, const uuid_t *u)
{
sprintf(target, "%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
u->time_low, u->time_mid, u->time_hi_and_version,
u->clock_seq_hi_and_reserved, u->clock_seq_low,
u->node[0], u->node[1], u->node[2],
u->node[3], u->node[4], u->node[5]);
}
/* convert a pair of hex digits to an integer value [0,255] */
static int dav_parse_hexpair(const char *s)
{
int result;
int temp;
result = s[0] - '0';
if (result > 48)
result = (result - 39) << 4;
else if (result > 16)
result = (result - 7) << 4;
else
result = result << 4;
temp = s[1] - '0';
if (temp > 48)
result |= temp - 39;
else if (temp > 16)
result |= temp - 7;
else
result |= temp;
return result;
}
/* dav_parse_locktoken: Parses string produced from
* dav_format_opaquelocktoken back into a uuid_t
* structure. On failure, return DAV_IF_ERROR_PARSE,
* else DAV_IF_ERROR_NONE.
*/
int parse_token(const char *char_token, uuid_t *bin_token)
{
int i;
for (i = 0; i < 36; ++i) {
char c = char_token[i];
if (!isxdigit(c) &&
!(c == '-' && (i == 8 || i == 13 || i == 18 || i == 23)))
return -1;
}
if (char_token[36] != '\0')
return -1;
bin_token->time_low =
(dav_parse_hexpair(&char_token[0]) << 24) |
(dav_parse_hexpair(&char_token[2]) << 16) |
(dav_parse_hexpair(&char_token[4]) << 8) |
dav_parse_hexpair(&char_token[6]);
bin_token->time_mid =
(dav_parse_hexpair(&char_token[9]) << 8) |
dav_parse_hexpair(&char_token[11]);
bin_token->time_hi_and_version =
(dav_parse_hexpair(&char_token[14]) << 8) |
dav_parse_hexpair(&char_token[16]);
bin_token->clock_seq_hi_and_reserved = dav_parse_hexpair(&char_token[19]);
bin_token->clock_seq_low = dav_parse_hexpair(&char_token[21]);
for (i = 6; i--;)
bin_token->node[i] = dav_parse_hexpair(&char_token[i*2+24]);
return -1;
}
/* dav_compare_opaquelocktoken:
* < 0 : a < b
* == 0 : a = b
* > 0 : a > b
*/
int compare_token(const uuid_t a, const uuid_t b)
{
return memcmp(&a, &b, sizeof(uuid_t));
}
/* format_uuid_v1 -- make a UUID from the timestamp, clockseq, and node ID */
static void format_uuid_v1(uuid_t * uuid, unsigned16 clock_seq,
uuid_time_t timestamp, uuid_node_t node)
{
/* Construct a version 1 uuid with the information we've gathered
* plus a few constants. */
uuid->time_low = (unsigned long)(timestamp & 0xFFFFFFFF);
uuid->time_mid = (unsigned short)((timestamp >> 32) & 0xFFFF);
uuid->time_hi_and_version = (unsigned short)((timestamp >> 48) & 0x0FFF);
uuid->time_hi_and_version |= (1 << 12);
uuid->clock_seq_low = clock_seq & 0xFF;
uuid->clock_seq_hi_and_reserved = (clock_seq & 0x3F00) >> 8;
uuid->clock_seq_hi_and_reserved |= 0x80;
memcpy(&uuid->node, &node, sizeof uuid->node);
}
/* get-current_time -- get time as 60 bit 100ns ticks since whenever.
Compensate for the fact that real clock resolution is less than 100ns. */
static void get_current_time(uuid_time_t * timestamp)
{
uuid_time_t time_now;
static uuid_time_t time_last;
static unsigned16 uuids_this_tick;
static int inited = 0;
if (!inited) {
get_system_time(&time_now);
uuids_this_tick = UUIDS_PER_TICK;
inited = 1;
};
while (1) {
get_system_time(&time_now);
/* if clock reading changed since last UUID generated... */
if (time_last != time_now) {
/* reset count of uuids gen'd with this clock reading */
uuids_this_tick = 0;
break;
};
if (uuids_this_tick < UUIDS_PER_TICK) {
uuids_this_tick++;
break;
}; /* going too fast for our clock; spin */
}; /* add the count of uuids to low order bits of the clock reading */
*timestamp = time_now + uuids_this_tick;
}
/* true_random -- generate a crypto-quality random number.
This sample doesn't do that. */
static unsigned16 true_random(void)
{
uuid_time_t time_now;
get_system_time(&time_now);
time_now = time_now/UUIDS_PER_TICK;
srand((unsigned int)(((time_now >> 32) ^ time_now)&0xffffffff));
return rand();
}
/* This sample implementation generates a random node ID *
* in lieu of a system dependent call to get IEEE node ID. */
static void get_pseudo_node_identifier(uuid_node_t *node)
{
unsigned char seed[16];
get_random_info(seed);
seed[0] |= 0x80;
memcpy(node, seed, sizeof(*node));
}
/* system dependent call to get the current system time.
Returned as 100ns ticks since Oct 15, 1582, but resolution may be
less than 100ns. */
#ifdef WIN32
static void get_system_time(uuid_time_t *uuid_time)
{
ULARGE_INTEGER time;
GetSystemTimeAsFileTime((FILETIME *)&time);
/* NT keeps time in FILETIME format which is 100ns ticks since
Jan 1, 1601. UUIDs use time in 100ns ticks since Oct 15, 1582.
The difference is 17 Days in Oct + 30 (Nov) + 31 (Dec)
+ 18 years and 5 leap days. */
time.QuadPart +=
(unsigned __int64) (1000*1000*10)
* (unsigned __int64) (60 * 60 * 24)
* (unsigned __int64) (17+30+31+365*18+5);
*uuid_time = time.QuadPart;
}
static void get_random_info(unsigned char seed[16])
{
MD5_CTX c;
struct {
MEMORYSTATUS m;
SYSTEM_INFO s;
FILETIME t;
LARGE_INTEGER pc;
DWORD tc;
DWORD l;
char hostname[MAX_COMPUTERNAME_LENGTH + 1];
} r;
MD5Init(&c); /* memory usage stats */
GlobalMemoryStatus(&r.m); /* random system stats */
GetSystemInfo(&r.s); /* 100ns resolution (nominally) time of day */
GetSystemTimeAsFileTime(&r.t); /* high resolution performance counter */
QueryPerformanceCounter(&r.pc); /* milliseconds since last boot */
r.tc = GetTickCount();
r.l = MAX_COMPUTERNAME_LENGTH + 1;
GetComputerName(r.hostname, &r.l );
MD5Update(&c, (const unsigned char *) &r, sizeof(r));
MD5Final(seed, &c);
}
#else /* WIN32 */
static void get_system_time(uuid_time_t *uuid_time)
{
struct timeval tp;
gettimeofday(&tp, (struct timezone *)0);
/* Offset between UUID formatted times and Unix formatted times.
UUID UTC base time is October 15, 1582.
Unix base time is January 1, 1970. */
*uuid_time = (tp.tv_sec * 10000000) + (tp.tv_usec * 10) +
I64(0x01B21DD213814000);
}
static void get_random_info(unsigned char seed[16])
{
MD5_CTX c;
/* Leech & Salz use Linux-specific struct sysinfo;
* replace with pid/tid for portability (in the spirit of mod_unique_id) */
struct {
/* Add thread id here, if applicable, when we get to pthread or apr */
pid_t pid;
struct timeval t;
char hostname[257];
} r;
MD5Init(&c);
r.pid = getpid();
gettimeofday(&r.t, (struct timezone *)0);
gethostname(r.hostname, 256);
MD5Update(&c, (unsigned char *)&r, sizeof(r));
MD5Final(seed, &c);
}
#endif /* WIN32 */

View File

@@ -1,82 +0,0 @@
/*
** Copyright (C) 1998-1999 Greg Stein. All Rights Reserved.
**
** By using this file, you agree to the terms and conditions set forth in
** the LICENSE.html file which can be found at the top level of the mod_dav
** distribution or at http://www.webdav.org/mod_dav/license-1.html.
**
** Contact information:
** Greg Stein, PO Box 3151, Redmond, WA, 98073
** gstein@lyra.org, http://www.webdav.org/mod_dav/
*/
/*
** DAV opaquelocktoken scheme implementation
**
** Written 5/99 by Keith Wannamaker, wannamak@us.ibm.com
** Adapted from ISO/DCE RPC spec and a former Internet Draft
** by Leach and Salz:
** http://www.ics.uci.edu/pub/ietf/webdav/uuid-guid/draft-leach-uuids-guids-01
**
** Portions of the code are covered by the following license:
**
** Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc.
** Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. &
** Digital Equipment Corporation, Maynard, Mass.
** Copyright (c) 1998 Microsoft.
** To anyone who acknowledges that this file is provided "AS IS"
** without any express or implied warranty: permission to use, copy,
** modify, and distribute this file for any purpose is hereby
** granted without fee, provided that the above copyright notices and
** this notice appears in all source code copies, and that none of
** the names of Open Software Foundation, Inc., Hewlett-Packard
** Company, or Digital Equipment Corporation be used in advertising
** or publicity pertaining to distribution of the software without
** specific, written prior permission. Neither Open Software
** Foundation, Inc., Hewlett-Packard Company, Microsoft, nor Digital Equipment
** Corporation makes any representations about the suitability of
** this software for any purpose.
*/
/*This file was stolen from webtools/mozbot/uuidgen/token.h */
#ifndef _TOKEN_H_
#define _TOKEN_H_
typedef unsigned long unsigned32;
typedef unsigned short unsigned16;
typedef unsigned char unsigned8;
typedef struct {
char nodeID[6];
} uuid_node_t;
#undef uuid_t
typedef struct _uuid_t
{
unsigned32 time_low;
unsigned16 time_mid;
unsigned16 time_hi_and_version;
unsigned8 clock_seq_hi_and_reserved;
unsigned8 clock_seq_low;
unsigned8 node[6];
} uuid_t;
/* data type for UUID generator persistent state */
typedef struct {
uuid_node_t node; /* saved node ID */
unsigned16 cs; /* saved clock sequence */
} uuid_state;
extern const uuid_t null_locktoken;
/* in dav_opaquelock.c */
int create_token(uuid_state *st, uuid_t *u);
void create_uuid_state(uuid_state *st);
void format_token(char *target, const uuid_t *u);
int compare_token(const uuid_t a, const uuid_t b);
int parse_token(const char *char_token, uuid_t *bin_token);
#endif /* _TOKEN_H_ */