Index: src/cpp/windows/base/stringUtils.cpp =================================================================== --- src/cpp/windows/base/stringUtils.cpp (revision 344) +++ src/cpp/windows/base/stringUtils.cpp (working copy) @@ -357,5 +357,16 @@ return data; } +int countElementTag(const std::wstring& xml, const std::wstring& tag) { + wstring content = L""; + wstring::size_type count = 0, pos = 0, previous = 0; + wstring::size_type start = 0, end = 0; + + while (getElementContent(xml,tag,content,pos,start,end) != 1) { + pos += end; + count ++; + } + return count; +} Index: src/cpp/windows/vocl/WinContact.cpp =================================================================== --- src/cpp/windows/vocl/WinContact.cpp (revision 344) +++ src/cpp/windows/vocl/WinContact.cpp (working copy) @@ -293,6 +293,11 @@ delete vp; vp = NULL; } + if (getProperty(L"InternetFreeBusyAddress", element)) { + vp = new VProperty(L"FBURL", element.c_str()); + vo->addProperty(vp); + delete vp; vp = NULL; + } // ----- ORG ----- // Add only if at least 1 property is supported, but include @@ -786,6 +791,9 @@ setProperty(L"WebPage", element); } } + else if (!wcscmp(name, L"FBURL")) { + setProperty(L"InternetFreeBusyAddress", element); + } // // ---- ADR fields ---- Index: src/cpp/windows/vocl/WinEvent.cpp =================================================================== --- src/cpp/windows/vocl/WinEvent.cpp (revision 344) +++ src/cpp/windows/vocl/WinEvent.cpp (working copy) @@ -547,6 +547,13 @@ if(element = getVObjectPropertyValue(vo, L"X-MICROSOFT-CDO-REPLYTIME")) { setProperty(L"ReplyTime", element); } + if (element = getVObjectPropertyValue(vo, L"ATTENDEE")) { + WinRecipient *recip = new WinRecipient(element); + if (vo->containsProperty(L"STATUS")) { + recip->setAttendeeStatus(vo->getProperty(L"STATUS")->getValue()); // why is getValue() deprecated? + } + addRecipient(recip); + } // AALARM @@ -699,9 +706,11 @@ recipientList* WinEvent::getRecipients() { return &recipients; } +void WinEvent::addRecipient(const WinRecipient *recip) { + recipients.push_back(*recip); +} - const TIME_ZONE_INFORMATION* WinEvent::getTimezone() { if (useTimezone) { Index: src/cpp/windows/vocl/WinEventSIF.cpp =================================================================== --- src/cpp/windows/vocl/WinEventSIF.cpp (revision 344) +++ src/cpp/windows/vocl/WinEventSIF.cpp (working copy) @@ -39,12 +39,9 @@ #include "base/stringUtils.h" #include "vocl/sifUtils.h" #include "base/globalsdef.h" +#include "base/util/XMLProcessor.h" +USE_FUNAMBOL_NAMESPACE -USE_NAMESPACE - -using namespace std; - - // Constructor WinEventSIF::WinEventSIF() { sifFields = NULL; @@ -52,12 +49,12 @@ } // Constructor: fills propertyMap parsing the passed SIF string -WinEventSIF::WinEventSIF(const wstring dataString, const wchar_t** fields, const wchar_t** recFields) { +WinEventSIF::WinEventSIF(const wstring dataString, const wchar_t** fields, const wchar_t** recFields, const wchar_t** attFields) { sif = L""; sifFields = fields; recPatternSIF.setSifFields(recFields); - + attendeeSIFFields = attFields; parse(dataString); } @@ -141,6 +138,15 @@ // // TODO: format recipients // + if (recipientList.size() > 0) { + sif += L""; + sifRecipientList::iterator it; + for(it=recipientList.begin(); it != recipientList.end();it++) { + WinRecipientSIF recipient = *it; + sif += recipient.toString(); + } + sif += L""; + } sif += L""; @@ -204,10 +210,25 @@ } } - // - // TODO: parse recipients and fill recipients list - // - + // Handle attendees + int numOfAttendees = countElementTag(data,L"Attendee"); + int start=0,end=0,lengthOfData=0; + const wstring attOpenTag = L""; + const wstring attCloseTag = L""; + wstring attData; + for(int i=0;i #include "base/globalsdef.h" USE_NAMESPACE using namespace std; - -// Constructor +/** Default constructor */ WinRecipient::WinRecipient() { - attendee = L""; + attendee = L""; + setProperty(L"AttendeeName",L""); + setProperty(L"AttendeeEmail",L""); + setProperty(L"AttendeeStatus",L"0"); + setProperty(L"AttendeeType",L"0"); + attendeeEmail = L""; + attendeeName = L""; + attendeeStatus = 0; + attendeeType = 0; } - -// Constructor: fills propertyMap parsing the ATTENDEE -WinRecipient::WinRecipient(const wstring data) { - attendee = L""; - parse(data); +WinRecipient::WinRecipient(const wstring dataString) { + WinRecipient(); + parse(dataString); } - -// Destructor +/** Destructor */ WinRecipient::~WinRecipient() { } - - - -// Parse a ATTENDEE string and fills the propertyMap. -int WinRecipient::parse(const wstring data) { - // TODO - return 0; +/** toString() */ +wstring& WinRecipient::toString() { + attendee = L""; + VProperty *vp = new VProperty(TEXT("ATTENDEE"), (WCHAR *)attendeeEmail.c_str()); + // The vcal and sif/outlook definitions of attendee type don't really match up + vp->addParameter(TEXT("ROLE"),TEXT("ATTENDEE")); + switch (attendeeStatus) { + case PARTSTAT_DECLINED_OL_RESPONSE: // declined + vp->addParameter(TEXT("STATUS"),PARTSTAT_DECLINED_STR); + break; + case PARTSTAT_CONFIRMED_OL_RESPONSE: + vp->addParameter(TEXT("STATUS"),PARTSTAT_CONFIRMED_STR); + break; + case PARTSTAT_NEEDSACTION_OL_RESPONSE: + vp->addParameter(TEXT("STATUS"),PARTSTAT_NEEDSACTION_STR); + break; + case PARTSTAT_TENTATIVE_OL_RESPONSE: + vp->addParameter(TEXT("STATUS"), PARTSTAT_TENTATIVE_STR); + break; + case PARTSTAT_DELEGATED_OL_RESPONSE: + vp->addParameter(TEXT("STATUS"), PARTSTAT_DELEGATED_STR); + break; + default: + vp->addParameter(TEXT("STATUS"), TEXT("SENT")); + break; + } + WCHAR *retString = vp->toString(TEXT("2.1")); + attendee.append(retString); + return attendee; } +/** parse() */ +int WinRecipient::parse(const wstring dataString) { + wstring name; + string::size_type has_email = dataString.find_last_of('<'); + if (has_email) { + string::size_type lengthOfEmail = dataString.length()-2-has_email; + wstring email(dataString, has_email+1, lengthOfEmail); + this->setAttendeeEmail(email); + name = dataString.substr(0, has_email-1); + } else { + name = dataString; + } + this->setAttendeeName(name); + return 0; +} +WinRecipient* WinRecipient::clone() { + WinRecipient *clone = new WinRecipient(); + clone->setAttendeeName(attendeeName); + clone->setAttendeeEmail(attendeeEmail); + clone->setAttendeeStatus(attendeeStatus); + clone->setAttendeeType(attendeeType); + return clone; +} -// Format and return a ATTENDEE string from the propertyMap. -wstring& WinRecipient::toString() { - // TODO - return attendee; +wstring& WinRecipient::getAttendeeName() { + return attendeeName; } - +void WinRecipient::setAttendeeName(const wstring attName) { + setProperty(L"AttendeeName",attName); + attendeeName = attName; +} +wstring& WinRecipient::getAttendeeEmail() { + return attendeeEmail; +} +void WinRecipient::setAttendeeEmail(const wstring attEmail) { + setProperty(L"AttendeeEmail",attEmail); + attendeeEmail = attEmail; +} +int WinRecipient::getAttendeeStatus() { + return attendeeStatus; +} +void WinRecipient::setAttendeeStatus(const int attStatus) { + attendeeStatus = attStatus; + wstring as; + wchar_t buf[2]; + _itow(attStatus,buf,10); + as.append(buf); + setProperty(L"AttendeeStatus", as); +} +void WinRecipient::setAttendeeStatus(const wstring vcalStatus) { + if (vcalStatus.compare(PARTSTAT_CONFIRMED_STR) == 0) { + this->setAttendeeStatus(PARTSTAT_CONFIRMED_OL_RESPONSE); + } else if (vcalStatus.compare(PARTSTAT_TENTATIVE_STR) == 0) { + this->setAttendeeStatus(PARTSTAT_TENTATIVE_OL_RESPONSE); + } else if (vcalStatus.compare(PARTSTAT_DELEGATED_STR) == 0) { + this->setAttendeeStatus(PARTSTAT_DELEGATED_OL_RESPONSE); + } else if (vcalStatus.compare(PARTSTAT_DECLINED_STR) == 0) { + this->setAttendeeStatus(PARTSTAT_DECLINED_OL_RESPONSE); + } +} +int WinRecipient::getAttendeeType() { + return attendeeType; +} +void WinRecipient::setAttendeeType(const int attType) { + attendeeType = attType; + wstring at; + wchar_t buf[2]; + _itow(attType,buf,10); + at.append(buf); + setProperty(L"AttendeeType",at); +} Index: src/cpp/windows/vocl/WinRecipientSIF.cpp =================================================================== --- src/cpp/windows/vocl/WinRecipientSIF.cpp (revision 0) +++ src/cpp/windows/vocl/WinRecipientSIF.cpp (revision 0) @@ -0,0 +1,115 @@ +/* + * 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 + * 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 + * 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 + * 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 + * 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 + * feasible for technical reasons, the Appropriate Legal Notices must display + * the words "Powered by Funambol". + */ + +#include "base/util/utils.h" +#include "base/stringUtils.h" +#include "vocl/WinRecipientSIF.h" +#include "vocl/constants.h" +#include +#include "base/globalsdef.h" +#include "vocl/sifUtils.h" +USE_NAMESPACE + +using namespace std; + +/** Default constructor */ +WinRecipientSIF::WinRecipientSIF() { + sifdata = L""; + sifFields = NULL; +} +WinRecipientSIF::WinRecipientSIF(const std::wstring dataString, const wchar_t **fields) { + sifFields = fields; + parse(dataString); +} +/** toString() */ +wstring& WinRecipientSIF::toString() { + wstring propertyValue; + sifdata = attendeeOpen; + sifdata = sifdata.append(L"\r\n"); + + // + // Add all recurrence properties + // + map::iterator it = propertyMap.begin(); + while (it != propertyMap.end()) { + propertyValue = it->second; + addPropertyToSIF(sifdata, it->first, propertyValue); + it ++; + } + sifdata = sifdata.append(attendeeClose); + return sifdata; +} +/** parse() */ +int WinRecipientSIF::parse(const wstring dataString) { + sifdata = dataString; + // Get the data inside + int lengthOfTotalData = sifdata.length()-attendeeOpen.length()-attendeeClose.length(); + sifdata = sifdata.substr(attendeeOpen.length(), + lengthOfTotalData); + if (!sifFields) { + LOG.error("%s", ERR_SIFFIELDS_NULL); + return 1; + } + propertyMap.clear(); + wstring propertyValue; + + for (int i=0; sifFields[i]; i++) { + // Set only properties found! + if (!getElementContent(dataString, sifFields[i], propertyValue, 0)) { + + replaceAll(L"<", L"<", propertyValue); + replaceAll(L">", L">", propertyValue); + replaceAll(L"&", L"&", propertyValue); + + setProperty(sifFields[i], propertyValue); + } + } + getProperty(L"AttendeeName",attendeeName); + getProperty(L"AttendeeEmail",attendeeEmail); + // attendee status, attendee type? + return 0; +} +void WinRecipientSIF::setSifFields(const wchar_t** fields) { + sifFields = fields; +} +WinRecipientSIF* WinRecipientSIF::clone() { + WinRecipientSIF* clone = new WinRecipientSIF(); + clone->setSifFields(sifFields); + clone->parse(sifdata); + return clone; +} +/** Destructor */ +WinRecipientSIF::~WinRecipientSIF() { +} Index: src/include/windows/base/stringUtils.h =================================================================== --- src/include/windows/base/stringUtils.h (revision 344) +++ src/include/windows/base/stringUtils.h (working copy) @@ -56,7 +56,7 @@ char* encryptData (const char* data, const char* password = NULL); char* decryptData (const char* b64Data, const char* password = NULL); - +int countElementTag(const std::wstring& xml, const std::wstring& tag); /** @} */ /** @endcond */ #endif \ No newline at end of file Index: src/include/windows/vocl/WinEvent.h =================================================================== --- src/include/windows/vocl/WinEvent.h (revision 344) +++ src/include/windows/vocl/WinEvent.h (working copy) @@ -178,6 +178,8 @@ /// Returns a pointer to the list (internally owned) of recipients. recipientList* getRecipients(); + /// Adds Recipient to list + void addRecipient(const WinRecipient *recip); /** * Returns a pointer to the timezone information for this event, NULL if Index: src/include/windows/vocl/WineventSIF.h =================================================================== --- src/include/windows/vocl/WineventSIF.h (revision 344) +++ src/include/windows/vocl/WineventSIF.h (working copy) @@ -44,12 +44,14 @@ #include "vocl/WinItem.h" #include "vocl/WinEvent.h" #include "vocl/WinRecurrenceSIF.h" +#include "vocl/WinRecipientSIF.h" #include "base/globalsdef.h" BEGIN_NAMESPACE using namespace std; +typedef list sifRecipientList; /** * Rapresents an event object for Windows Clients, for SIF format. @@ -69,6 +71,12 @@ /// The recurrence pattern object for SIF data, containing recurring properties. WinRecurrenceSIF recPatternSIF; + /// NULL terminated array of SIF fields names for attendees + const wchar_t** attendeeSIFFields; + + /// SIF recipient list + sifRecipientList recipientList; + /// Parse appointment exceptions from SIF string, and fill exception lists. void parseExceptions(const wstring& sifString); @@ -110,7 +118,7 @@ * @param fields the NULL terminated array of SIF fields * @param fields the NULL terminated array of SIF fields for recurrence pattern */ - WinEventSIF(const wstring dataString, const wchar_t** fields, const wchar_t** recFields); + WinEventSIF(const wstring dataString, const wchar_t** fields, const wchar_t** recFields, const wchar_t** attFields); /// Destructor ~WinEventSIF(); @@ -164,6 +172,9 @@ * @return the converted value if necessary */ wstring adaptFromSIFSpecs(const wstring& propName, const wstring& propValue); + + void WinEventSIF::addRecipient(const WinRecipientSIF *recipient); + sifRecipientList* WinEventSIF::getRecipients(); }; Index: src/include/windows/vocl/WinItem.h =================================================================== --- src/include/windows/vocl/WinItem.h (revision 344) +++ src/include/windows/vocl/WinItem.h (working copy) @@ -67,6 +67,31 @@ #define INFO_ITEM_VOBJ_VERSION_NOTFOUND "Warning! VObject version not specified (\"%ls\" expected)" #include "base/globalsdef.h" +// STATUS field stuff +#define PARTSTAT_ACCEPTED_STR L"ACCEPTED" +#define PARTSTAT_ACCEPTED_OL_RESPONSE 3 //olResponseAccepted + +#define PARTSTAT_CONFIRMED_STR L"CONFIRMED" +#define PARTSTAT_CONFIRMED_OL_RESPONSE 3 // olResponseccepted +#define PARTSTAT_DECLINED_STR L"DECLINED" +#define PARTSTAT_DECLINED_OL_RESPONSE 4 //olResponseDeclined + +#define PARTSTAT_TENTATIVE_STR L"TENTATIVE" +#define PARTSTAT_TENTATIVE_OL_RESPONSE 2 //olResponseTentative + +#define PARTSTAT_DELEGATED_STR L"DELEGATED" +#define PARTSTAT_DELEGATED_OL_RESPONSE 1 // olResponseOrganized? + +#define PARTSTAT_COMPLETED_STR L"COMPLETED" +#define PARTSTAT_COMPLETED_OL_TASK 2 //olTaskComplete + +#define PARTSTAT_INPROCESS_STR L"IN-PROCESS" +#define PARTSTAT_INPROCESS_OL_TASK 3 /* olTaskInProgress (1) is proper, but set to 5 because this property shouldn't exist */ + +#define PARTSTAT_NEEDSACTION_STR L"NEEDS-ACTION" +#define PARTSTAT_NEEDSACTION_OL_TASK 3 // olTaskWaiting +#define PARTSTAT_NEEDSACTION_OL_RESPONSE 5 // olResponseNotResponded + BEGIN_NAMESPACE Index: src/include/windows/vocl/WinRecipient.h =================================================================== --- src/include/windows/vocl/WinRecipient.h (revision 344) +++ src/include/windows/vocl/WinRecipient.h (working copy) @@ -33,52 +33,52 @@ * the words "Powered by Funambol". */ -#ifndef INCL_WINRECIPIENT -#define INCL_WINRECIPIENT - /** @cond API */ /** @addtogroup win_adapter */ /** @{ */ +#ifndef INCL_WINRECIPIENT +#define INCL_WINRECIPIENT + +#include "base/timeUtils.h" #include "vocl/WinItem.h" #include "base/globalsdef.h" +BEGIN_FUNAMBOL_NAMESPACE -BEGIN_NAMESPACE - - /** - * Rapresents a recipient object (attendee) for Windows Clients. - * The object can be filled passing a vCalendar ATTENDEE string, or filling - * directly the map. Calling 'toString()' a vCalendar ATTENDEE is formatted and returned. + * Represents an attendee to an event + * @author Mathew McBride */ class WinRecipient : public WinItem { - private: - - wstring attendee; - + wstring attendee; +protected: + wstring attendeeName; + wstring attendeeEmail; + int attendeeStatus; + int attendeeType; public: - - /// Default Constructor - WinRecipient(); - - /// Constructor: fills propertyMap parsing the vCalendar ATTENDEE string - WinRecipient(const wstring data); - - /// Destructor - ~WinRecipient(); - - - /// Parse a vCalendar ATTENDEE string and fills the propertyMap. - int parse(const wstring data); - - /// Format and return a vCalendar ATTENDEE string from the propertyMap. - wstring& toString(); + /** default constructor */ + WinRecipient(); + /** constructor with rule argument */ + WinRecipient(const wstring dataString); + /** destructor */ + virtual ~WinRecipient(); + /** toString */ + wstring& toString(); + int parse(const wstring dataString); + WinRecipient* clone(); + /* get and set methods */ + wstring& getAttendeeName(); + void setAttendeeName(const wstring attName); + wstring& getAttendeeEmail(); + void setAttendeeEmail(const wstring attEmail); + int getAttendeeStatus(); + void setAttendeeStatus(const wstring vcalStatus); + void setAttendeeStatus(const int attStatus); + int getAttendeeType(); + void setAttendeeType(const int attType); }; +END_FUNAMBOL_NAMESPACE - -END_NAMESPACE - -/** @} */ -/** @endcond */ -#endif +#endif Index: src/include/windows/vocl/WinRecipientSIF.h =================================================================== --- src/include/windows/vocl/WinRecipientSIF.h (revision 0) +++ src/include/windows/vocl/WinRecipientSIF.h (revision 0) @@ -0,0 +1,77 @@ +/* + * 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 + * 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 + * 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 + * 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 + * 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 + * feasible for technical reasons, the Appropriate Legal Notices must display + * the words "Powered by Funambol". + */ + +/** @cond API */ +/** @addtogroup win_adapter */ +/** @{ */ + +#ifndef INCL_WINRECIPIENT_SIF +#define INCL_WINRECIPIENT_SIF + +#include "vocl/WinRecipient.h" +#include "base/timeUtils.h" +#include "vocl/WinItem.h" +#include "base/globalsdef.h" + +const wstring attendeeOpen = L""; +const wstring attendeeClose = L""; + +BEGIN_FUNAMBOL_NAMESPACE + +/** + * Represents an attendee to an event (SIF flavour) + * @author Mathew McBride + */ +class WinRecipientSIF : public WinRecipient { +private: + wstring sifdata; + const wchar_t** sifFields; +public: + /** Default constructor */ + WinRecipientSIF(); + /** Constructor with SIF data and sifFields */ + WinRecipientSIF(const wstring dataString, const wchar_t** fields); + /** Destructor */ + ~WinRecipientSIF(); + + /** Parse a SIF string */ + int parse(const wstring dataString); + /// Sets the internal pointer sifFields with the passed array. + void setSifFields(const wchar_t** fields); + wstring& toString(); + WinRecipientSIF* clone(); +}; +END_FUNAMBOL_NAMESPACE +#endif Index: src/include/windows/vocl/WinRecurrence.h =================================================================== --- src/include/windows/vocl/WinRecurrence.h (revision 344) +++ src/include/windows/vocl/WinRecurrence.h (working copy) @@ -44,9 +44,8 @@ #include "vocl/WinItem.h" #include "base/globalsdef.h" -BEGIN_NAMESPACE +BEGIN_FUNAMBOL_NAMESPACE - /** * Rapresents a recurrence pattern object for Windows Clients. * The object can be filled passing a vCalendar RRULE string, or filling @@ -113,7 +112,7 @@ }; -END_NAMESPACE +END_FUNAMBOL_NAMESPACE /** @} */ /** @endcond */