/*
- * Funambol is a mobile platform developed by Funambol, Inc.
+ * Funambol is a mobile platform developed by Funambol, Inc.
* Copyright (C) 2003 - 2007 Funambol, Inc.
- *
+ *
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by
- * the Free Software Foundation with the addition of the following permission
+ * the Free Software Foundation with the addition of the following permission
* added to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED
- * WORK IN WHICH THE COPYRIGHT IS OWNED BY FUNAMBOL, FUNAMBOL DISCLAIMS THE
+ * WORK IN WHICH THE COPYRIGHT IS OWNED BY FUNAMBOL, FUNAMBOL DISCLAIMS THE
* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
- * You should have received a copy of the GNU Affero General Public License
+ *
+ * You should have received a copy of the GNU Affero General Public License
* along with this program; if not, see http://www.gnu.org/licenses or write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA.
- *
- * You can contact Funambol, Inc. headquarters at 643 Bair Island Road, Suite
+ *
+ * You can contact Funambol, Inc. headquarters at 643 Bair Island Road, Suite
* 305, Redwood City, CA 94063, USA, or at email address info@funambol.com.
- *
+ *
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
- *
+ *
* In accordance with Section 7(b) of the GNU Affero General Public License
* version 3, these Appropriate Legal Notices must retain the display of the
- * "Powered by Funambol" logo. If the display of the logo is not reasonably
+ * "Powered by Funambol" logo. If the display of the logo is not reasonably
* feasible for technical reasons, the Appropriate Legal Notices must display
* the words "Powered by Funambol".
*/
#include "vocl/WinRecurrence.h"
#include "vocl/constants.h"
#include <oleauto.h>
+#include "base/globalsdef.h"
+
+USE_NAMESPACE
using namespace std;
// Constructor
WinRecurrence::WinRecurrence() {
rrule = L"";
+ startDate = 0;
+ useTimezone = false;
}
// Constructor: fills propertyMap parsing the passed RRULE
-WinRecurrence::WinRecurrence(const wstring dataString, const DATE startDate) {
+WinRecurrence::WinRecurrence(const wstring dataString, const DATE date) {
rrule = L"";
- parse(dataString, startDate);
+ startDate = date;
+ useTimezone = false;
+ parse(dataString);
}
// Destructor
int dayofmonth = 0;
int instance = 1;
int monthofyear = 0;
- BOOL noEnd = FALSE;
+ bool noEnd = false;
wstring pStart = L"";
// Read all values from propertyMap.
getProperty(L"DayOfMonth", tmp); dayofmonth = _wtoi(tmp.c_str());
getProperty(L"Instance", tmp); instance = _wtoi(tmp.c_str());
getProperty(L"MonthOfYear", tmp); monthofyear = _wtoi(tmp.c_str());
- getProperty(L"NoEndDate", tmp); noEnd = _wtoi(tmp.c_str());
+ getProperty(L"NoEndDate", tmp); noEnd = (tmp != TEXT("0"));
getProperty(L"PatternStartDate", pStart);
// Note: "PatternEndDate" is no more sent: using only "Occurrences"
}
break;
}
-
+
// Monthly = 2
case winRecursMonthly: {
if(dayofmonth > 0) {
break;
}
}
-
+
// MonthNth = 3
case winRecursMonthNth: {
if(instance>0 && dayofweek>0) {
}
break;
}
-
+
// YearNth = 6
case winRecursYearNth: {
if(dayofweek>0 && instance>0) {
// Parse a RRULE string and fills the propertyMap.
-int WinRecurrence::parse(const wstring dataString, const DATE startDate) {
+int WinRecurrence::parse(const wstring dataString) {
int ret = 0;
WCHAR* str = wstrdup(dataString.c_str());
int weekOfMonth = -1;
int monthOfYear = -1;
+ if (!token) {
+ goto error;
+ }
+
//
// First token will be: "D|W|MP|MD|YM|YD<interval>"
setIntProperty(L"RecurrenceType", recType);
setIntProperty(L"Interval", interval);
occurences = _wtoi(token+1);
- if(occurences == 0) setIntProperty(L"NoEndDate", TRUE);
+ if(occurences == 0) setIntProperty(L"NoEndDate", 1);
else setIntProperty(L"Occurrences", occurences);
token ++;
}
setIntProperty(L"RecurrenceType", recType);
setIntProperty(L"Interval", interval);
occurences = _wtoi(token+1);
- if(occurences == 0) setIntProperty(L"NoEndDate", TRUE);
+ if(occurences == 0) setIntProperty(L"NoEndDate", 1);
else setIntProperty(L"Occurrences", occurences);
if(wcscmp(days, L"")) setIntProperty(L"DayOfWeekMask", stringToDaysOfWeek(days));
- else setIntProperty(L"DayOfWeekMask", getWeekDayFromDate(startDate));
+ else setIntProperty(L"DayOfWeekMask", getWeekDayFromDate(startDate));
token++;
}
else if(token[8] == TEXT('T')) {
setProperty(L"PatternEndDate", token);
setIntProperty(L"Interval", interval);
if(wcscmp(days, L"")) setIntProperty(L"DayOfWeekMask", stringToDaysOfWeek(days));
- else setIntProperty(L"DayOfWeekMask", getWeekDayFromDate(startDate));
+ else setIntProperty(L"DayOfWeekMask", getWeekDayFromDate(startDate));
}
else if(isWeekDay(token)) {
wcscat(days, token);
setIntProperty(L"DayOfMonth", dayOfMonth);
setIntProperty(L"Interval", interval);
occurences = _wtoi(token+1);
- if(occurences == 0) setIntProperty(L"NoEndDate", TRUE);
+ if(occurences == 0) setIntProperty(L"NoEndDate", 1);
else setIntProperty(L"Occurrences", occurences);
token++;
}
setIntProperty(L"Instance", weekOfMonth);
setIntProperty(L"DayOfWeekMask", stringToDaysOfWeek(days));
occurences = _wtoi(token+1);
- if(occurences == 0) setIntProperty(L"NoEndDate", TRUE);
+ if(occurences == 0) setIntProperty(L"NoEndDate", 1);
else setIntProperty(L"Occurrences", occurences);
token++;
}
setIntProperty(L"MonthOfYear",monthOfYear);
setIntProperty(L"DayOfMonth", dayOfMonth);
occurences = _wtoi(token+1);
- if(occurences == 0) setIntProperty(L"NoEndDate", TRUE);
+ if(occurences == 0) setIntProperty(L"NoEndDate", 1);
else setIntProperty(L"Occurrences", occurences);
token++;
}
if (mOfYear) delete [] mOfYear;
return ret;
}
-
-
-
-
-
-
-const int WinRecurrence::getIntProperty(const wstring propertyName) {
- int ret = 0;
- wstring tmp;
- if (getProperty(propertyName, tmp)) {
- ret = _wtoi(tmp.c_str());
- }
- return ret;
-}
-
-
-void WinRecurrence::setIntProperty(const wstring propertyName, const int propertyValue) {
- WCHAR tmp[10];
- wsprintf(tmp, TEXT("%d"), propertyValue);
- setProperty(propertyName, tmp);
-}
-