diff options
Diffstat (limited to 'src/containers')
-rw-r--r-- | src/containers/incidence_p.h | 65 | ||||
-rw-r--r-- | src/containers/kolabconfiguration.cpp | 121 | ||||
-rw-r--r-- | src/containers/kolabconfiguration.h | 100 | ||||
-rw-r--r-- | src/containers/kolabcontact.cpp | 506 | ||||
-rw-r--r-- | src/containers/kolabcontact.h | 412 | ||||
-rw-r--r-- | src/containers/kolabcontainers.cpp | 767 | ||||
-rw-r--r-- | src/containers/kolabcontainers.h | 408 | ||||
-rw-r--r-- | src/containers/kolabevent.cpp | 326 | ||||
-rw-r--r-- | src/containers/kolabevent.h | 124 | ||||
-rw-r--r-- | src/containers/kolabevent_p.h | 42 | ||||
-rw-r--r-- | src/containers/kolabjournal.cpp | 191 | ||||
-rw-r--r-- | src/containers/kolabjournal.h | 87 | ||||
-rw-r--r-- | src/containers/kolabnote.cpp | 185 | ||||
-rw-r--r-- | src/containers/kolabnote.h | 75 | ||||
-rw-r--r-- | src/containers/kolabtodo.cpp | 327 | ||||
-rw-r--r-- | src/containers/kolabtodo.h | 122 |
16 files changed, 3858 insertions, 0 deletions
diff --git a/src/containers/incidence_p.h b/src/containers/incidence_p.h new file mode 100644 index 0000000..8602feb --- /dev/null +++ b/src/containers/incidence_p.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2011 Christian Mollekopf <mollekopf@kolabsys.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef INCIDENCE_P +#define INCIDENCE_P + +#include "kolabcontainers.h" + +namespace Kolab { + + struct PrivateIncidence + { + PrivateIncidence() + : sequence(0), + classification(ClassPublic), + thisAndFuture(false), + priority(0), + status(StatusUndefined){} + + std::string uid; + cDateTime created; + cDateTime lastModified; + int sequence; + Classification classification; + std::vector< std::string > categories; + std::vector< std::string > relatedTo; + cDateTime start; + + cDateTime recurrenceID; + bool thisAndFuture; + std::string summary; + std::string description; + std::string location; + int priority; + Status status; + RecurrenceRule rrule; + std::vector< cDateTime > recurrenceDates; + std::vector< cDateTime > exceptionDates; + ContactReference organizer; + Duration duration; + + std::vector<Attendee> attendees; + std::vector<Attachment> attachments; + std::vector<CustomProperty> customProperties; + + std::vector<Alarm> alarms; + }; + +} + +#endif diff --git a/src/containers/kolabconfiguration.cpp b/src/containers/kolabconfiguration.cpp new file mode 100644 index 0000000..2129371 --- /dev/null +++ b/src/containers/kolabconfiguration.cpp @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2012 Christian Mollekopf <mollekopf@kolabsys.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "kolabconfiguration.h" + +namespace Kolab { + +struct Configuration::Private { + Private(): type(Invalid){} + + std::vector<CategoryColor> categoryColor; + Dictionary dictionary; + ConfigurationType type; + std::string uid; + cDateTime created; + cDateTime lastModified; +}; + +Configuration::Configuration() +: d(new Configuration::Private) +{ +} + +Configuration::Configuration(const std::vector<CategoryColor> &c) +: d(new Configuration::Private) +{ + d->categoryColor = c; + d->type = TypeCategoryColor; +} + +Configuration::Configuration(const Dictionary &dict) +: d(new Configuration::Private) +{ + d->dictionary = dict; + d->type = TypeDictionary; +} + +Configuration::Configuration(const Configuration &other) +: d(new Configuration::Private) +{ + *d = *other.d; +} + +Configuration::~Configuration() +{ + +} + +void Configuration::operator=(const Configuration &other) +{ + *d = *other.d; +} + +bool Configuration::isValid() const +{ + return d->type != Invalid; +} + +void Configuration::setUid(const std::string &uid) +{ + d->uid = uid; +} + +std::string Configuration::uid() const +{ + return d->uid; +} + +void Configuration::setCreated(const cDateTime &created) +{ + d->created = created; +} + +cDateTime Configuration::created() const +{ + return d->created; +} + +void Configuration::setLastModified(const cDateTime &lastModified) +{ + d->lastModified = lastModified; +} + +cDateTime Configuration::lastModified() const +{ + return d->lastModified; +} + + +Configuration::ConfigurationType Configuration::type() const +{ + return d->type; +} + +std::vector<CategoryColor> Configuration::categoryColor() const +{ + return d->categoryColor; +} + +Dictionary Configuration::dictionary() const +{ + return d->dictionary; +} + + + +} //Namespace diff --git a/src/containers/kolabconfiguration.h b/src/containers/kolabconfiguration.h new file mode 100644 index 0000000..d29ff1e --- /dev/null +++ b/src/containers/kolabconfiguration.h @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2012 Christian Mollekopf <mollekopf@kolabsys.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef KOLABCONFIGURATION_H +#define KOLABCONFIGURATION_H +#include <string> +#include <vector> +#include <boost/scoped_ptr.hpp> +#include "kolabcontainers.h" + +namespace Kolab { + +struct Dictionary { + Dictionary(){} + Dictionary(const std::string &c): mLanguage(c){} + + bool operator==(const Dictionary &other) const { + return mLanguage == other.mLanguage && mEntries == other.mEntries; + } + + std::string language() const { return mLanguage; } + + void setEntries(const std::vector<std::string> &e){ mEntries = e; } + std::vector<std::string> entries() const { return mEntries; } +private: + std::string mLanguage; + std::vector<std::string> mEntries; +}; + +struct CategoryColor { + CategoryColor(){} + CategoryColor(const std::string &c): mCategory(c) {} + + bool operator==(const CategoryColor &other) const { + return mCategory == other.mCategory && mColor == other.mColor && mSubcategories == other.mSubcategories; + } + + std::string category() const { return mCategory; } + + void setColor(const std::string &c) { mColor = c; } + std::string color() const { return mColor; } + + void setSubcategories(const std::vector<CategoryColor> &c) { mSubcategories = c; } + std::vector<CategoryColor> subcategories() const { return mSubcategories; } +private: + std::string mCategory; + std::string mColor; + std::vector<CategoryColor> mSubcategories; +}; + +class Configuration { +public: + Configuration(); + Configuration(const std::vector<CategoryColor> &); + Configuration(const Dictionary &); + Configuration(const Configuration &); + ~Configuration(); + void operator=(const Configuration &); + + bool isValid() const; + + void setUid(const std::string &); + std::string uid() const; + + void setCreated(const cDateTime &); + cDateTime created() const; + + void setLastModified(const cDateTime &); + cDateTime lastModified() const; + + enum ConfigurationType { + Invalid, + TypeDictionary, + TypeCategoryColor + }; + ConfigurationType type() const; + std::vector<CategoryColor> categoryColor() const; + Dictionary dictionary() const; +private: + struct Private; + boost::scoped_ptr<Private> d; +}; + +} //Namespace + +#endif // KOLABCONFIGURATION_H diff --git a/src/containers/kolabcontact.cpp b/src/containers/kolabcontact.cpp new file mode 100644 index 0000000..528b13d --- /dev/null +++ b/src/containers/kolabcontact.cpp @@ -0,0 +1,506 @@ +/* + * Copyright (C) 2011 Christian Mollekopf <mollekopf@kolabsys.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include "kolabcontact.h" + +namespace Kolab { + +struct DistList::Private +{ + Private() {} + + std::string uid; + cDateTime lastModified; + std::vector< std::string > categories; + + std::string name; + std::vector<ContactReference> members; + std::vector<CustomProperty> customProperties; +}; + +DistList::DistList() +: d(new DistList::Private()) +{ + +} + +DistList::DistList(const DistList &other) +: d(new DistList::Private()) +{ + *d = *other.d; +} + +DistList::~DistList() +{ + +} + +void DistList::operator=(const Kolab::DistList &other) +{ + *d = *other.d; +} + +bool DistList::isValid() const +{ + return !d->uid.empty(); +} + +void DistList::setUid(const std::string &uid) +{ + d->uid = uid; +} + +std::string DistList::uid() const +{ + return d->uid; +} + +void DistList::setLastModified(const Kolab::cDateTime &dt) +{ + d->lastModified = dt; +} + +cDateTime DistList::lastModified() const +{ + return d->lastModified; +} + +void DistList::setName(const std::string &name) +{ + d->name = name; +} + +std::string DistList::name() const +{ + return d->name; +} + +void DistList::setMembers(const std::vector< ContactReference > &members) +{ + d->members = members; +} + +std::vector< ContactReference > DistList::members() const +{ + return d->members; +} + +void DistList::setCustomProperties(const std::vector< CustomProperty >& c) +{ + d->customProperties = c; +} + +std::vector< CustomProperty > DistList::customProperties() const +{ + return d->customProperties; +} + + + + + + +struct Contact::Private +{ + Private() + : addressPreferredIndex(-1), + gender(NotSet), + telephonesPreferredIndex(-1), + imAddressPreferredIndex(-1), + emailAddressPreferredIndex(-1) + {} + + std::string uid; + cDateTime created; + cDateTime lastModified; + std::vector< std::string > categories; + + std::string name; + NameComponents nameComponents; + std::string note; + std::string freeBusyUrl; + std::vector< std::string > titles; + std::vector<Affiliation> affiliations; + std::vector<Url> urls; + std::vector<Address> addresses; + int addressPreferredIndex; + std::vector<std::string> nickNames; + std::vector<Related> relateds; + cDateTime bDay; + cDateTime anniversary; + std::string photo; + std::string photoMimetype; + Gender gender; + std::vector<std::string> languages; + std::vector<Telephone> telephones; + int telephonesPreferredIndex; + std::vector<std::string> imAddresses; + int imAddressPreferredIndex; + std::vector<std::string> emailAddresses; + int emailAddressPreferredIndex; + std::vector<Geo> gpsPos; + std::vector<Key> keys; + Crypto crypto; + std::vector<CustomProperty> customProperties; +}; + +Contact::Contact() +: d(new Contact::Private()) +{ + +} + +Contact::Contact(const Contact &other) +: d(new Contact::Private()) +{ + *d = *other.d; +} + +Contact::~Contact() +{ + +} + +void Contact::operator=(const Kolab::Contact &other) +{ + *d = *other.d; +} + +bool Contact::isValid() const +{ + return !d->uid.empty(); +} + +void Contact::setUid(const std::string &uid) +{ + d->uid = uid; +} + +std::string Contact::uid() const +{ + return d->uid; +} + +void Contact::setLastModified(const Kolab::cDateTime &dt) +{ + d->lastModified = dt; +} + +cDateTime Contact::lastModified() const +{ + return d->lastModified; +} + +void Contact::setCategories(const std::vector< std::string > &cat) +{ + d->categories = cat; +} + +void Contact::addCategory(const std::string &cat) +{ + d->categories.push_back(cat); +} + +std::vector< std::string > Contact::categories() const +{ + return d->categories; +} + +void Contact::setName(const std::string &name) +{ + d->name = name; +} + +std::string Contact::name() const +{ + return d->name; +} + +void Contact::setNameComponents(const Kolab::NameComponents &nc) +{ + d->nameComponents = nc; +} + +NameComponents Contact::nameComponents() const +{ + return d->nameComponents; +} + +void Contact::setNote(const std::string ¬e) +{ + d->note = note; +} + +std::string Contact::note() const +{ + return d->note; +} + +void Contact::setFreeBusyUrl(const std::string &url) +{ + d->freeBusyUrl = url; +} + +std::string Contact::freeBusyUrl() const +{ + return d->freeBusyUrl; +} + +void Contact::setTitles(const std::vector< std::string >& titles) +{ + d->titles = titles; +} + +std::vector< std::string > Contact::titles() const +{ + return d->titles; +} + + +void Contact::setAffiliations(const std::vector< Affiliation > &a) +{ + d->affiliations = a; +} + +std::vector< Affiliation > Contact::affiliations() const +{ + return d->affiliations; +} + +void Contact::setUrls(const std::vector<Url> &urls) +{ + d->urls = urls; +} + +std::vector< Url > Contact::urls() const +{ + return d->urls; +} + +void Contact::setAddresses(const std::vector< Address > &ad, int preferred) +{ + d->addresses = ad; + d->addressPreferredIndex = preferred; +} + +std::vector< Address > Contact::addresses() const +{ + return d->addresses; +} + +int Contact::addressPreferredIndex() const +{ + return d->addressPreferredIndex; +} + + +void Contact::setNickNames(const std::vector< std::string > &n) +{ + d->nickNames = n; +} + +std::vector< std::string > Contact::nickNames() const +{ + return d->nickNames; +} + +void Contact::setRelateds(const std::vector< Related > &relateds) +{ + d->relateds = relateds; +} + +std::vector< Related > Contact::relateds() const +{ + return d->relateds; +} + +void Contact::setBDay(const Kolab::cDateTime &bday) +{ + d->bDay = bday; +} + +cDateTime Contact::bDay() const +{ + return d->bDay; +} + +void Contact::setAnniversary(const Kolab::cDateTime& dt) +{ + d->anniversary = dt; +} + +cDateTime Contact::anniversary() const +{ + return d->anniversary; +} + +void Contact::setPhoto(const std::string& data, const std::string& mimetype) +{ + d->photo = data; + d->photoMimetype = mimetype; +} + +std::string Contact::photo() const +{ + return d->photo; +} + +std::string Contact::photoMimetype() const +{ + return d->photoMimetype; +} + +void Contact::setGender(Contact::Gender g) +{ + d->gender = g; +} + +Contact::Gender Contact::gender() const +{ + return d->gender; +} + +void Contact::setLanguages(const std::vector< std::string >& l) +{ + d->languages = l; +} + +std::vector< std::string > Contact::languages() const +{ + return d->languages; +} + +void Contact::setTelephones(const std::vector< Telephone >& tel, int preferredIndex) +{ + d->telephonesPreferredIndex = preferredIndex; + d->telephones = tel; +} + +std::vector< Telephone > Contact::telephones() const +{ + return d->telephones; +} + +int Contact::telephonesPreferredIndex() const +{ + return d->telephonesPreferredIndex; +} + +void Contact::setIMaddresses(const std::vector< std::string > &adr, int preferredIndex) +{ + d->imAddresses = adr; + d->imAddressPreferredIndex = preferredIndex; +} + +std::vector< std::string > Contact::imAddresses() const +{ + return d->imAddresses; +} + +int Contact::imAddressPreferredIndex() const +{ + return d->imAddressPreferredIndex; +} + +void Contact::setEmailAddresses(const std::vector< std::string >& email, int preferredIndex) +{ + d->emailAddresses = email; + d->emailAddressPreferredIndex = preferredIndex; +} + +std::vector< std::string > Contact::emailAddresses() const +{ + return d->emailAddresses; +} + +int Contact::emailAddressPreferredIndex() const +{ + return d->emailAddressPreferredIndex; +} + +void Contact::setGPSpos(const std::vector< Geo >& pos) +{ + d->gpsPos = pos; +} + +std::vector< Geo > Contact::gpsPos() const +{ + return d->gpsPos; +} + +void Contact::setKeys(const std::vector<Key> &keys) +{ + d->keys = keys; +} + +std::vector<Key> Contact::keys() const +{ + return d->keys; +} + +void Contact::setCrypto(const Kolab::Crypto& c) +{ + d->crypto = c; +} + +Crypto Contact::crypto() const +{ + return d->crypto; +} + +void Contact::setCustomProperties(const std::vector< CustomProperty >& c) +{ + d->customProperties = c; +} + +std::vector< CustomProperty > Contact::customProperties() const +{ + return d->customProperties; +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +} //Namespace + diff --git a/src/containers/kolabcontact.h b/src/containers/kolabcontact.h new file mode 100644 index 0000000..86306ba --- /dev/null +++ b/src/containers/kolabcontact.h @@ -0,0 +1,412 @@ +/* + * Copyright (C) 2011 Christian Mollekopf <mollekopf@kolabsys.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef KOLABCONTACT_H +#define KOLABCONTACT_H + +#include <string> +#include <vector> +#include <boost/scoped_ptr.hpp> +#include "kolabcontainers.h" + +namespace Kolab { + +struct NameComponents { + bool operator==(const NameComponents &other) const { return mSurnames == other.mSurnames && + mGiven == other.mGiven && + mAdditional == other.mAdditional && + mPrefixes == other.mPrefixes && + mSuffixes == other.mSuffixes; + }; + void setSurnames(const std::vector<std::string> &s) { mSurnames = s; }; + std::vector<std::string> surnames() const { return mSurnames; }; + void setGiven(const std::vector<std::string> &s) { mGiven = s; }; + std::vector<std::string> given() const { return mGiven; }; + void setAdditional(const std::vector<std::string> &s) { mAdditional = s; }; + std::vector<std::string> additional() const { return mAdditional; }; + void setPrefixes(const std::vector<std::string> &s) { mPrefixes = s; }; + std::vector<std::string> prefixes() const { return mPrefixes; }; + void setSuffixes(const std::vector<std::string> &s) { mSuffixes = s; }; + std::vector<std::string> suffixes() const { return mSuffixes; }; + bool isValid() const { return !(mSurnames.empty() && mGiven.empty() && mAdditional.empty() && mPrefixes.empty() && mSuffixes.empty()); }; +private: + std::vector<std::string> mSurnames; + std::vector<std::string> mGiven; + std::vector<std::string> mAdditional; + std::vector<std::string> mPrefixes; + std::vector<std::string> mSuffixes; +}; + +struct Related { + + enum DescriptionType { + Invalid, + Text, + Uid + }; + Related(): mType(Invalid), mRelationType(NoRelation) {}; + Related(DescriptionType t, const std::string &textOrUri, int relationType = NoRelation) + : mType(t), mRelationType(relationType) + { + if (t == Text) { + mText = textOrUri; + } else { + mUri = textOrUri; + } + }; + bool operator==(const Related &other) const { return mType == other.mType && + mUri == other.mUri && + mText == other.mText && + mRelationType == other.mRelationType; + }; + DescriptionType type() const { return mType; }; + std::string uri() const { return mUri; }; + std::string text() const { return mText; }; + enum RelationType { + NoRelation = 0, + Child = 0x01, + Spouse = 0x02, + Manager = 0x04, + Assistant = 0x08, + }; + void setRelationTypes(int t) { mRelationType = t; }; + int relationTypes() const { return mRelationType; }; +private: + DescriptionType mType; + std::string mUri; + std::string mText; + int mRelationType; +}; + +struct Address { + + Address(): mTypes(0) {}; + enum Type { + Work = 0x01, + Home = 0x02 + }; + bool operator==(const Address &other) const { return mTypes == other.mTypes && + mLabel == other.mLabel && + mStreet == other.mStreet && + mLocality == other.mLocality && + mRegion == other.mRegion && + mCode == other.mCode && + mCountry == other.mCountry; + }; + void setTypes(int t) { mTypes = t; }; + int types() const { return mTypes; }; + + void setLabel(const std::string &s) { mLabel = s; }; + std::string label() const { return mLabel; } + + void setStreet(const std::string &s) { mStreet = s; }; + std::string street() const { return mStreet; }; + + void setLocality(const std::string &s) { mLocality = s; }; + std::string locality() const { return mLocality; }; + + void setRegion(const std::string &s) { mRegion = s; }; + std::string region() const { return mRegion; }; + + void setCode(const std::string &s) { mCode = s; }; + std::string code() const { return mCode; }; + + void setCountry(const std::string &s) { mCountry = s; }; + std::string country() const { return mCountry; }; +private: + int mTypes; + std::string mLabel; + std::string mStreet; + std::string mLocality; + std::string mRegion; + std::string mCode; + std::string mCountry; +}; + +struct Affiliation { + bool operator==(const Affiliation &other) const { return mOrg == other.mOrg && + mOrgUnits == other.mOrgUnits && + mLogo == other.mLogo && + mLogoMimetype == other.mLogoMimetype && + mRoles == other.mRoles && + mRelateds == other.mRelateds && + mOffices == other.mOffices; + }; + void setOrganisation(const std::string &org) { mOrg = org; }; + std::string organisation() const { return mOrg; }; + void setOrganisationalUnits(const std::vector<std::string> &units) { mOrgUnits = units; }; + std::vector<std::string> organisationalUnits() const { return mOrgUnits; }; + void setLogo(const std::string &l, const std::string mimetype) { mLogo = l; mLogoMimetype = mimetype; }; + std::string logo() const { return mLogo; }; + std::string logoMimetype() const { return mLogoMimetype; }; + + void setRoles(const std::vector<std::string> &roles) { mRoles = roles; }; + std::vector<std::string> roles() const { return mRoles; }; + void setRelateds(const std::vector<Related> &relateds) { mRelateds = relateds; }; + std::vector<Related> relateds() const { return mRelateds; }; + void setAddresses(const std::vector<Address> &offices) { mOffices = offices; }; + std::vector<Address> addresses() const { return mOffices; }; +private: + std::string mOrg; + std::vector<std::string> mOrgUnits; + std::string mLogo; + std::string mLogoMimetype; + std::vector<std::string> mRoles; + std::vector<Related> mRelateds; + std::vector<Address> mOffices; +}; + +struct Telephone { + enum Type { + Work = 0x01, + Home = 0x02, + Text = 0x04, + Voice = 0x08, + Fax = 0x10, + Cell = 0x20, + Video = 0x40, + Pager = 0x80, + Textphone = 0x100, + Car = 0x200 + }; + Telephone(): mType(0){}; + bool operator==(const Telephone &other) const { return mNumber == other.mNumber && + mType == other.mType; + }; + void setTypes(int t) { mType = t; }; + int types() const { return mType; }; + void setNumber(const std::string &n) { mNumber = n; }; + std::string number() const { return mNumber; }; +private: + std::string mNumber; + int mType; +}; + +struct Crypto { + enum CryptoTypes { + PGPinline = 0x01, + PGPmime = 0x02, + SMIME = 0x04, + SMIMEopaque = 0x08 + }; + + enum CryptoPref { + Ask, + Never, + Always, + IfPossible + }; + Crypto(): mCryptoTypes(0), mSignPref(Ask), mEncryptPref(Ask){}; + bool operator==(const Crypto &other) const { return mCryptoTypes == other.mCryptoTypes && + mSignPref == other.mSignPref && + mEncryptPref == other.mEncryptPref; }; + bool isValid() const { return mCryptoTypes; }; + + void setAllowed(int cryptoTypes) { mCryptoTypes = cryptoTypes; }; + int allowed() const { return mCryptoTypes; }; + void setSignPref(CryptoPref p) { mSignPref = p; }; + CryptoPref signPref() const { return mSignPref; }; + void setEncryptPref(CryptoPref p) { mEncryptPref = p; }; + CryptoPref encryptPref() const { return mEncryptPref; }; +private: + int mCryptoTypes; + CryptoPref mSignPref; + CryptoPref mEncryptPref; +}; + +struct Geo { + Geo(): latitude(0.0), longitude(0.0) {}; + Geo(double lat, double lon) + : latitude(lat), longitude(lon) {}; + + bool operator==(const Geo &other) const{ return (longitude == other.longitude && latitude == other.latitude);}; + double latitude; + double longitude; +}; + +struct Url { + enum UrlTypes { + NoType = 0, + Blog + }; + Url(): mType(NoType) {}; + Url(const std::string &u, int t = NoType): mUrl(u), mType(t) {}; + + bool operator==(const Url &other) const{ return (mType == other.mType && mUrl == other.mUrl);}; + + int type() const { return mType; }; + std::string url() const { return mUrl; }; +private: + std::string mUrl; + int mType; +}; + +struct Key { + enum KeyType { + Invalid, + PGP, + PKCS7_MIME + }; + Key(): keytype(Invalid) {}; + Key(const std::string &k, KeyType type) + : mKey(k), keytype(type) {}; + + bool operator==(const Key &other) const{ return (mKey == other.mKey && keytype == other.keytype);}; + + KeyType type() const { return keytype; }; + std::string key() const { return mKey; }; + +private: + std::string mKey; + KeyType keytype; +}; + + +class DistList { +public: + DistList(); + ~DistList(); + DistList(const DistList &); + void operator=(const DistList &); + + bool isValid() const; + + void setUid(const std::string &); + std::string uid() const; + + void setLastModified(const cDateTime &); + cDateTime lastModified() const; + + void setName(const std::string &); + std::string name() const; + + void setMembers(const std::vector<ContactReference> &); + std::vector<ContactReference> members() const; + + void setCustomProperties(const std::vector<CustomProperty> &); + std::vector<CustomProperty> customProperties() const; + +private: + struct Private; + boost::scoped_ptr<Private> d; +}; + +class Contact { +public: + Contact(); + ~Contact(); + Contact(const Contact &); + void operator=(const Contact &); + + bool isValid() const; + + void setUid(const std::string &); + std::string uid() const; + + void setLastModified(const cDateTime &); + cDateTime lastModified() const; + + void setCategories(const std::vector<std::string> &); + void addCategory(const std::string &); + std::vector<std::string> categories() const; + + void setName(const std::string &); + std::string name() const; + + void setNameComponents(const NameComponents &); + NameComponents nameComponents() const; + + void setNote(const std::string &); + std::string note() const; + + void setFreeBusyUrl(const std::string &); + std::string freeBusyUrl() const; + + void setTitles(const std::vector<std::string> &titles); + std::vector<std::string> titles() const; + + void setAffiliations(const std::vector<Affiliation> &); + std::vector<Affiliation> affiliations() const; + + void setUrls(const std::vector<Url> &); + std::vector<Url> urls() const; + + void setAddresses(const std::vector<Address> &, int preferred = -1); + std::vector<Address> addresses() const; + int addressPreferredIndex() const; + + void setNickNames(const std::vector< std::string > &); + std::vector< std::string > nickNames() const; + + void setRelateds(const std::vector<Related> &); + std::vector<Related> relateds() const; + + void setBDay(const cDateTime &); + cDateTime bDay() const; + + void setAnniversary(const cDateTime &); + cDateTime anniversary() const; + + void setPhoto(const std::string &data, const std::string &mimetype); + std::string photo() const; + std::string photoMimetype() const; + + enum Gender { + NotSet, + NotSpecified, + Male, + Female + }; + + void setGender(Gender); + Gender gender() const; + + void setLanguages(const std::vector<std::string> &); + std::vector<std::string> languages() const; + + void setTelephones(const std::vector<Telephone> &, int preferredIndex = -1); + std::vector<Telephone> telephones() const; + int telephonesPreferredIndex() const; + + void setIMaddresses(const std::vector<std::string> &, int preferredIndex = -1); + std::vector<std::string> imAddresses() const; + int imAddressPreferredIndex() const; + + void setEmailAddresses(const std::vector<std::string> &, int preferredIndex = -1); + std::vector<std::string> emailAddresses() const; + int emailAddressPreferredIndex() const; + + void setGPSpos(const std::vector<Geo> &); + std::vector<Geo> gpsPos() const; + + void setKeys(const std::vector<Key> &); + std::vector<Key> keys() const; + + void setCrypto(const Crypto &); + Crypto crypto() const; + + void setCustomProperties(const std::vector<CustomProperty> &); + std::vector<CustomProperty> customProperties() const; + +private: + struct Private; + boost::scoped_ptr<Private> d; +}; + +} //Namespace + +#endif // KOLABCONTACT_H diff --git a/src/containers/kolabcontainers.cpp b/src/containers/kolabcontainers.cpp new file mode 100644 index 0000000..47c76e3 --- /dev/null +++ b/src/containers/kolabcontainers.cpp @@ -0,0 +1,767 @@ +/* + * Copyright (C) 2011 Christian Mollekopf <mollekopf@kolabsys.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include "kolabcontainers.h" +#include "incidence_p.h" + +namespace Kolab { + +struct cDateTime::Private { + Private() + : year(-1), + month(-1), + day(-1), + hour(-1), + minute(-1), + second(-1), + isUtc(false){} + + int year; + int month; + int day; + int hour; + int minute; + int second; + bool isUtc; + std::string timezone; +}; + +cDateTime::cDateTime() +: d(new cDateTime::Private()) +{ + +} + +cDateTime::cDateTime(int year, int month, int day, int hour, int minute, int second, bool isUtc) +: d(new cDateTime::Private()) +{ + d->year = year; + d->month = month; + d->day = day; + d->hour = hour; + d->minute = minute; + d->second = second; + d->isUtc = isUtc; +} + +cDateTime::cDateTime(const std::string& timezone, int year, int month, int day, int hour, int minute, int second) +: d(new cDateTime::Private()) +{ + d->year = year; + d->month = month; + d->day = day; + d->hour = hour; + d->minute = minute; + d->second = second; + d->timezone = timezone; +} + +cDateTime::cDateTime(int year, int month, int day) +: d(new cDateTime::Private()) +{ + d->year = year; + d->month = month; + d->day = day; +} + +cDateTime::cDateTime(const Kolab::cDateTime &other) +: d(new cDateTime::Private()) +{ + *d = *other.d; +} + +cDateTime::~cDateTime() +{ + +} + + +void cDateTime::operator=(const Kolab::cDateTime &other) +{ + *d = *other.d; +} + +bool cDateTime::operator==(const Kolab::cDateTime &other) const +{ + if ( d->year == other.year() && + d->month == other.month() && + d->day == other.day() && + d->hour == other.hour() && + d->minute == other.minute() && + d->second== other.second() && + d->isUtc== other.isUTC() && + d->timezone== other.timezone()) { + return true; + } + return false; +} + + + +int cDateTime::year() const +{ + return d->year; +} + +int cDateTime::month() const +{ + return d->month; +} + +int cDateTime::day() const +{ + return d->day; +} + +int cDateTime::hour() const +{ + return d->hour; +} + +int cDateTime::minute() const +{ + return d->minute; +} + +int cDateTime::second() const +{ + return d->second; +} + +bool cDateTime::isDateOnly() const +{ + if ((d->hour < 0) && (d->minute < 0) && (d->second < 0)) { + return true; + } + return false; +} + +void cDateTime::setDate(int year, int month, int day) +{ + d->year = year; + d->month = month; + d->day = day; +} +void cDateTime::setTime(int hour, int minute, int second) +{ + d->hour = hour; + d->minute = minute; + d->second = second; +} +void cDateTime::setTimezone(const std::string &tz) +{ + d->timezone = tz; +} +void cDateTime::setUTC(bool utc) +{ + d->isUtc = utc; +} + +bool cDateTime::isUTC() const +{ + return d->isUtc; +} + +std::string cDateTime::timezone() const +{ + return d->timezone; +} + +bool cDateTime::isValid() const +{ + return (d->year >= 0 && d->month >= 0 && d->day >= 0); +} + +struct RecurrenceRule::Private +{ + Private() + : freq(FreqNone), + weekstart(Monday), + count(-1), + interval(1){}; + + Frequency freq; + Weekday weekstart; + cDateTime end; + int count; + int interval; + std::vector<int> bysecond; + std::vector<int> byminute; + std::vector<int> byhour; + std::vector<DayPos> byday; + std::vector<int> bymonthday; + std::vector<int> byyearday; + std::vector<int> byweekno; + std::vector<int> bymonth; +}; + +RecurrenceRule::RecurrenceRule() +: d(new RecurrenceRule::Private) +{ + +} + +RecurrenceRule::RecurrenceRule(const Kolab::RecurrenceRule &other) +: d(new RecurrenceRule::Private) +{ + *d = *other.d; +} + +void RecurrenceRule::operator=(const Kolab::RecurrenceRule &other) +{ + *d = *other.d; +} + +bool RecurrenceRule::operator==(const Kolab::RecurrenceRule &other) const +{ + if ( d->freq == other.frequency() && + d->weekstart == other.weekStart() && + d->end == other.end() && + d->count == other.count() && + d->interval == other.interval() && + d->bysecond == other.bysecond() && + d->byminute == other.byminute() && + d->byhour == other.byhour() && + d->byday == other.byday() && + d->bymonthday == other.bymonthday() && + d->byyearday == other.byyearday() && + d->byweekno == other.byweekno() && + d->bymonth == other.bymonth()) { + return true; + } + return false; +} + +RecurrenceRule::~RecurrenceRule() +{ + +} + +void RecurrenceRule::setFrequency(RecurrenceRule::Frequency freq) +{ + d->freq = freq; +} + +RecurrenceRule::Frequency RecurrenceRule::frequency() const +{ + return d->freq; +} + +void RecurrenceRule::setWeekStart(Kolab::Weekday weekstart) +{ + d->weekstart = weekstart; +} + +Kolab::Weekday RecurrenceRule::weekStart() const +{ + return d->weekstart; +} + +void RecurrenceRule::setEnd(const Kolab::cDateTime &end) +{ + d->end = end; +} + +cDateTime RecurrenceRule::end() const +{ + return d->end; +} + +void RecurrenceRule::setCount(int count) +{ + d->count = count; +} + +int RecurrenceRule::count() const +{ + return d->count; +} + +void RecurrenceRule::setInterval(int interval) +{ + d->interval = interval; +} + +int RecurrenceRule::interval() const +{ + return d->interval; +} + +void RecurrenceRule::setBysecond(const std::vector< int >&by) +{ + d->bysecond = by; +} + + +std::vector< int > RecurrenceRule::bysecond() const +{ + return d->bysecond; +} + +void RecurrenceRule::setByminute(const std::vector< int > &by) +{ + d->byminute = by; +} + +std::vector< int > RecurrenceRule::byminute() const +{ + return d->byminute; +} + +void RecurrenceRule::setByhour(const std::vector< int > &by) +{ + d->byhour = by; +} + +std::vector< int > RecurrenceRule::byhour() const +{ + return d->byhour; +} + +void RecurrenceRule::setByday(const std::vector< DayPos > &by) +{ + d->byday = by; +} + +std::vector< DayPos > RecurrenceRule::byday() const +{ + return d->byday; +} + +void RecurrenceRule::setBymonthday(const std::vector< int > &by) +{ + d->bymonthday = by; +} + +std::vector< int > RecurrenceRule::bymonthday() const +{ + return d->bymonthday; +} + +void RecurrenceRule::setByyearday(const std::vector< int > &by) +{ + d->byyearday = by; +} + +std::vector< int > RecurrenceRule::byyearday() const +{ + return d->byyearday; +} + +void RecurrenceRule::setByweekno(const std::vector< int > &by) +{ + d->byweekno = by; +} + +std::vector< int > RecurrenceRule::byweekno() const +{ + return d->byweekno; +} + +void RecurrenceRule::setBymonth(const std::vector< int > &by) +{ + d->bymonth = by; +} + +std::vector< int > RecurrenceRule::bymonth() const +{ + return d->bymonth; +} + +bool RecurrenceRule::isValid() const +{ + if (d->freq == FreqNone) { + return false; + } + return true; +} + + + +struct Attendee::Private +{ + Private() + : partStat(PartNeedsAction), + role(Required), + rsvp(false), + cutype(CutypeIndividual) + {}; + + ContactReference contact; + PartStatus partStat; + Role role; + bool rsvp; + std::vector<ContactReference> delegatedTo; + std::vector<ContactReference> delegatedFrom; + Cutype cutype; +}; + +Attendee::Attendee() +: d(new Attendee::Private) +{ + +} + +Attendee::Attendee(const ContactReference& contact) +: d(new Attendee::Private) +{ + d->contact = contact; +} + +Attendee::Attendee(const Kolab::Attendee &other) +: d(new Attendee::Private) +{ + *d = *other.d; +} + +void Attendee::operator=(const Kolab::Attendee &other) +{ + *d = *other.d; +} + +Attendee::~Attendee() +{ + +} + +bool Attendee::operator==(const Kolab::Attendee &other) const +{ + if ( d->contact == other.contact() && + d->partStat == other.partStat() && + d->role == other.role() && + d->rsvp == other.rsvp() && + d->delegatedTo == other.delegatedTo() && + d->delegatedFrom == other.delegatedFrom() && + d->cutype == other.cutype() + ) { + return true; + } + return false; +} + +bool Attendee::isValid() const +{ + return d->contact.isValid(); +}; + +void Attendee::setContact(const ContactReference &c) +{ + d->contact = c; +} + +ContactReference Attendee::contact() const +{ + return d->contact; +} + + +void Attendee::setPartStat(PartStatus partStat) +{ + d->partStat = partStat; +} + +PartStatus Attendee::partStat() const +{ + return d->partStat; +} + +void Attendee::setRole(Role role) +{ + d->role = role; +} + +Role Attendee::role() const +{ + return d->role; +} + +void Attendee::setRSVP(bool rsvp) +{ + d->rsvp = rsvp; +} + +bool Attendee::rsvp() const +{ + return d->rsvp; +} + +void Attendee::setDelegatedTo(const std::vector< ContactReference > &del) +{ + d->delegatedTo = del; +} + +std::vector< ContactReference > Attendee::delegatedTo() const +{ + return d->delegatedTo; +} + +void Attendee::setDelegatedFrom(const std::vector< ContactReference > &del) +{ + d->delegatedFrom = del; +} + +std::vector< ContactReference > Attendee::delegatedFrom() const +{ + return d->delegatedFrom; +} + +void Attendee::setCutype(Cutype type) +{ + d->cutype = type; +} + +Cutype Attendee::cutype() const +{ + return d->cutype; +} + + +struct Attachment::Private +{ + std::string uri; + std::string data; + std::string mimetype; + std::string label; +}; + +Attachment::Attachment() +: d(new Attachment::Private) +{ +} + +Attachment::Attachment(const Kolab::Attachment &other) +: d(new Attachment::Private) +{ + *d = *other.d; +} + +void Attachment::operator=(const Kolab::Attachment &other) +{ + *d = *other.d; +} + +Attachment::~Attachment() +{ +} + +bool Attachment::operator==(const Kolab::Attachment &other) const +{ + return ( d->uri == other.uri() && + d->data == other.data() && + d->label == other.label() && + d->mimetype == other.mimetype() ); +} + +void Attachment::setUri(const std::string &uri, const std::string& mimetype) +{ + d->uri = uri; + d->mimetype = mimetype; +} + +std::string Attachment::uri() const +{ + return d->uri; +} + +std::string Attachment::mimetype() const +{ + return d->mimetype; +} + +void Attachment::setLabel(const std::string &label) +{ + d->label = label; +} + +std::string Attachment::label() const +{ + return d->label; +} + +void Attachment::setData(const std::string &data, const std::string& mimetype) +{ + d->data = data; + d->mimetype = mimetype; +} + +std::string Attachment::data() const +{ + return d->data; +} + +bool Attachment::isValid() const +{ + return !d->mimetype.empty(); //TODO use isValid variable +} + + + +struct Alarm::Private +{ + Private(): relativeTo(Start), + numrepeat(0), + type(Alarm::InvalidAlarm) {}; + std::string text; + Attachment audioFile; + std::string summary; + std::vector<ContactReference> attendees; + cDateTime start; + Duration relativeDuration; + Relative relativeTo; + Duration duration; + int numrepeat; + Type type; + +}; + +Alarm::Alarm() +: d(new Alarm::Private) +{ +} + +Alarm::Alarm(const std::string &text) +: d(new Alarm::Private) +{ + d->text = text; + d->type = DisplayAlarm; +} + + +Alarm::Alarm(const Kolab::Attachment& audio) +: d(new Alarm::Private) +{ + d->audioFile = audio; + d->type = AudioAlarm; +} + +Alarm::Alarm(const std::string& summary, const std::string& description, const std::vector<ContactReference> attendees) +: d(new Alarm::Private) +{ + d->summary = summary; + d->text = description; + d->attendees = attendees; + d->type = EMailAlarm; + +} + +Alarm::Alarm(const Kolab::Alarm &other) +: d(new Alarm::Private) +{ + *d = *other.d; +} + +void Alarm::operator=(const Kolab::Alarm &other) +{ + *d = *other.d; +} + +Alarm::~Alarm() +{ +} + +bool Alarm::operator==(const Kolab::Alarm &other) const +{ + return ( d->text == other.description() && + d->text == other.description() && + d->audioFile == other.audioFile() && + d->summary == other.summary() && + d->attendees == other.attendees() && + d->start == other.start() && + d->relativeDuration == other.relativeStart() && + d->relativeTo == other.relativeTo() && + d->duration == other.duration() && + d->numrepeat == other.numrepeat() ); +} + +std::string Alarm::text() const +{ + return d->text; +} + +Attachment Alarm::audioFile() const +{ + return d->audioFile; +} + +std::string Alarm::summary() const +{ + return d->summary; +} + +std::string Alarm::description() const +{ + return d->text; +} + +std::vector<ContactReference> Alarm::attendees() const +{ + return d->attendees; +} + +void Alarm::setStart(const Kolab::cDateTime &start) +{ + d->start = start; +} + +cDateTime Alarm::start() const +{ + return d->start; +} + +void Alarm::setRelativeStart(const Kolab::Duration &duration, Relative relativeTo) +{ + d->relativeDuration = duration; + d->relativeTo = relativeTo; +} + +Duration Alarm::relativeStart() const +{ + return d->relativeDuration; +} + +Relative Alarm::relativeTo() const +{ + return d->relativeTo; +} + +void Alarm::setDuration(const Kolab::Duration &duration, int numrepeat) +{ + d->numrepeat = numrepeat; + d->duration = duration; +} + +Duration Alarm::duration() const +{ + return d->duration; +} + +int Alarm::numrepeat() const +{ + return d->numrepeat; +} + +Alarm::Type Alarm::type() const +{ + return d->type; +} + + + + + + +}//Namespace diff --git a/src/containers/kolabcontainers.h b/src/containers/kolabcontainers.h new file mode 100644 index 0000000..5f8318d --- /dev/null +++ b/src/containers/kolabcontainers.h @@ -0,0 +1,408 @@ +/* + * Copyright (C) 2011 Christian Mollekopf <mollekopf@kolabsys.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef KOLAB_CONTAINERS_H +#define KOLAB_CONTAINERS_H +#include <string> +#include <vector> +#include <boost/scoped_ptr.hpp> + +namespace Kolab { + +class cDateTime { +public: + cDateTime(); + cDateTime(int year, int month, int day, int hour, int minute, int second, bool isUtc=false); + cDateTime(const std::string &timezone, int year, int month, int day, int hour, int minute, int second); + cDateTime(int year, int month, int day); + ~cDateTime(); + cDateTime(const cDateTime &); + void operator=(const cDateTime &); + bool operator==(const cDateTime &) const; + + + void setDate(int year, int month, int day); + int year() const; + int month() const; + int day() const; + + bool isDateOnly() const; + + void setTime(int hour, int minute, int second); + int hour() const; + int minute() const; + int second() const; + + void setUTC(bool); + bool isUTC() const; + void setTimezone(const std::string &); + std::string timezone() const; + + bool isValid() const; +private: + struct Private; + boost::scoped_ptr<Private> d; +}; + +enum Classification { + ClassPublic, + ClassPrivate, + ClassConfidential +}; + +enum Status { + StatusUndefined, + StatusNeedsAction, + StatusCompleted, + StatusInProcess, + StatusCancelled, + StatusTentative, + StatusConfirmed, + StatusDraft, + StatusFinal +}; + +enum Weekday { + Monday, + Tuesday, + Wednesday, + Thursday, + Friday, + Saturday, + Sunday +}; + +struct DayPos { + DayPos(): mIsValid(false){}; + DayPos(int occurrence, Weekday weekday): mOccurrence(occurrence), mWeekday(weekday), mIsValid(true){}; + bool operator==(const DayPos &other) const { return mOccurrence == other.mOccurrence && mWeekday == other.mWeekday; }; + int occurence() const { return mOccurrence; }; + Weekday weekday() const { return mWeekday; }; + bool isValid() { return mIsValid; }; +private: + int mOccurrence; + Weekday mWeekday; + bool mIsValid; +}; + +class Attachment { +public: + Attachment(); + Attachment(const Kolab::Attachment &); + ~Attachment(); + + void operator=(const Attachment &); + bool operator==(const Attachment &) const; + + void setUri(const std::string &uri, const std::string &mimetype); + std::string uri() const; + + ///Un-encoded binary content, Implies embedded, will be encoded + void setData(const std::string &, const std::string &mimetype); + ///Decoded binary content. + std::string data() const; + //TODO add possibility to set already encoded data and uri to be embedded as performance/convenience improvement? +// ///Base64 encoded binary content, Implies embedded +// void setEncodedData(const std::string &, const std::string &mimetype); + + std::string mimetype() const; + + ///User visible label + void setLabel(const std::string &); + std::string label() const; + + bool isValid() const; +private: + struct Private; + boost::scoped_ptr<Private> d; +}; + +enum Relative { + Start, + End +}; + +struct Duration { + Duration():mWeeks(0), mDays(0), mHours(0), mMinutes(0), mSeconds(0), mNegative(false), valid(false){}; + Duration(int weeks, bool negative = false): mWeeks(weeks), mDays(0), mHours(0), mMinutes(0), mSeconds(0), mNegative(negative), valid(true){}; + Duration(int days, int hours, int minutes, int seconds, bool negative = false): mWeeks(0), mDays(days), mHours(hours), mMinutes(minutes), mSeconds(seconds), mNegative(negative), valid(true){}; + bool operator==(const Duration &other) const{ return (/*mWeeks == other.mWeeks && + mDays == other.mDays && + mHours == other.mHours && + mMinutes == other.mMinutes && + mSeconds == other.mSeconds && + mNegative == other.mNegative &&*/ + ( ((((mWeeks * 7 + mDays) * 24 + mHours) * 60 + mMinutes) * 60 + mSeconds) == + ((((other.mWeeks * 7 + other.mDays) * 24 + other.mHours) * 60 + other.mMinutes) * 60 + other.mSeconds) ) && + valid == other.valid );}; + int weeks() const { return mWeeks; }; + int days() const { return mDays; }; + int hours() const { return mHours; }; + int minutes() const { return mMinutes; }; + int seconds() const { return mSeconds; }; + + bool isNegative() const { return mNegative; }; + bool isValid() const { return valid; }; +private: + int mWeeks; + int mDays; + int mHours; + int mMinutes; + int mSeconds; + bool mNegative; + bool valid; +}; + +struct ContactReference { + enum ReferenceType { + Invalid, + EmailReference, + UidReference, + EmailAndUidReference + }; + ContactReference(): mType(Invalid) {}; + ///For xCal + ContactReference(const std::string &email, const std::string &name = std::string(), const std::string &uid = std::string()): mType(EmailAndUidReference), mEmail(email), mUid(uid), mName(name) {}; + ///For xCard + ContactReference(ReferenceType type, const std::string &emailOrUID, const std::string &name = std::string()): mType(type), mName(name) { + if (type == EmailReference) { + mEmail = emailOrUID; + } else { + mUid = emailOrUID; + } + }; + bool operator==(const ContactReference &other) const { return mEmail == other.mEmail && + mName == other.mName && + mUid == other.mUid; + }; + + bool isValid() const { return mType != Invalid; }; + + void setName(const std::string &name) { mName = name; }; + + std::string email() const { return mEmail; }; + std::string uid() const { return mUid; }; + std::string name() const { return mName; }; + + ReferenceType type() const { return mType; }; + +private: + ReferenceType mType; + std::string mEmail; + std::string mUid; + std::string mName; +}; + +class Alarm { +public: + enum Type { + InvalidAlarm, + EMailAlarm, + DisplayAlarm, + AudioAlarm + }; + + Alarm(); + Alarm(const Alarm &); + ~Alarm(); + + void operator=(const Alarm &); + bool operator==(const Alarm &other) const; + + ///EMail Alarm, @param attendees accepts only email + name and no uid + Alarm(const std::string &summary, const std::string &description, const std::vector<ContactReference> attendees); + std::string summary() const; + std::string description() const; + std::vector<ContactReference> attendees() const; + + ///Display Alarm + Alarm(const std::string &text); + std::string text() const; + + ///Audio Alarm + Alarm(const Attachment &audio); + Attachment audioFile() const; + + void setRelativeStart(const Duration &, Relative); + Duration relativeStart() const; + Relative relativeTo() const; + + void setStart(const cDateTime &); + cDateTime start() const; + + void setDuration(const Duration &, int numrepeat); + Duration duration() const; + int numrepeat() const; + + Type type() const; + +private: + struct Private; + boost::scoped_ptr<Private> d; +}; + + +class RecurrenceRule { +public: + + RecurrenceRule(); + RecurrenceRule(const RecurrenceRule &); + ~RecurrenceRule(); + + void operator=(const RecurrenceRule &); + bool operator==(const RecurrenceRule &other) const; + + enum Frequency { + FreqNone, + Yearly, + Monthly, + Weekly, + Daily, + Hourly, + Minutely, + Secondly + }; + + void setFrequency(Frequency); + Frequency frequency() const; + + void setWeekStart(Weekday); + Weekday weekStart() const; + + void setEnd(const cDateTime &); + cDateTime end() const; + + void setCount(int count); + int count() const; + + void setInterval(int); + int interval() const; + + void setBysecond(const std::vector<int> &); + std::vector<int> bysecond() const; + + void setByminute(const std::vector<int> &); + std::vector<int> byminute() const; + + void setByhour(const std::vector<int> &); + std::vector<int> byhour() const; + + void setByday(const std::vector<DayPos> &); + std::vector<DayPos> byday() const; + + void setBymonthday(const std::vector<int> &); + std::vector<int> bymonthday() const; + + void setByyearday(const std::vector<int> &); + std::vector<int> byyearday() const; + + void setByweekno(const std::vector<int> &); + std::vector<int> byweekno() const; + + void setBymonth(const std::vector<int> &); + std::vector<int> bymonth() const; + + bool isValid() const; + +private: + struct Private; + boost::scoped_ptr<Private> d; +}; + + +enum PartStatus { + PartNeedsAction, + PartAccepted, + PartDeclined, + PartTentative, + PartDelegated +}; + +enum Role { + Required, + Chair, + Optional, + NonParticipant +}; + +enum Cutype { + CutypeUnknown, + CutypeGroup, + CutypeIndividual, + CutypeResource, + CutypeRoom +}; + +class Attendee { +public: + Attendee(); + Attendee(const ContactReference &contact); + Attendee(const Attendee &); + ~Attendee(); + + void operator=(const Attendee &); + bool operator==(const Attendee &) const; + + bool isValid() const; + + void setContact(const ContactReference &); + ContactReference contact() const; + + void setPartStat(PartStatus); + PartStatus partStat() const; + + void setRole(Role); + Role role() const; + + void setRSVP(bool); + bool rsvp() const; + + void setDelegatedTo(const std::vector<ContactReference> &); + std::vector<ContactReference> delegatedTo() const; + + void setDelegatedFrom(const std::vector<ContactReference> &); + std::vector<ContactReference> delegatedFrom() const; + + void setCutype(Cutype); + Cutype cutype() const; +private: + struct Private; + boost::scoped_ptr<Private> d; +}; + +struct CustomProperty { + CustomProperty(){}; + CustomProperty(const std::string &i, const std::string &v) + : identifier(i), value(v) {}; + + bool operator==(const CustomProperty &other) const{ return (identifier == other.identifier && value == other.value);}; + std::string identifier; + std::string value; +}; + +//WARNING this function copies the vector and does not modify it +template <typename T> +std::vector<T> operator<< ( std::vector<T> v, const T &s) +{ + v.push_back(s); + return v; +} + + +} + +#endif diff --git a/src/containers/kolabevent.cpp b/src/containers/kolabevent.cpp new file mode 100644 index 0000000..f70346a --- /dev/null +++ b/src/containers/kolabevent.cpp @@ -0,0 +1,326 @@ +/* + * Copyright (C) 2011 Christian Mollekopf <mollekopf@kolabsys.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include "kolabevent.h" +#include "kolabevent_p.h" + +namespace Kolab { + +Event::Event() +: d(new Event::Private()) +{ +// std::cout << "ctor" << std::endl; +} + +Event::Event(const Event &other) +: d(new Event::Private()) +{ + *d = *other.d; +// std::cout << "cctor" << std::endl; +} + +Event::~Event() +{ +// std::cout << "dtor" << std::endl; +} + +void Event::operator=(const Kolab::Event &other) +{ + *d = *other.d; +} + +bool Event::isValid() const +{ + return !d->uid.empty(); +} + +void Event::setUid(const std::string &uid) +{ + d->uid = uid; +} + +std::string Event::uid() const +{ + return d->uid; +} + +void Event::setCreated(const Kolab::cDateTime &created) +{ + d->created = created; +} + +cDateTime Event::created() const +{ + return d->created; +} + +void Event::setLastModified(const Kolab::cDateTime &lastMod) +{ + d->lastModified = lastMod; +} + +cDateTime Event::lastModified() const +{ + return d->lastModified; +} + +void Event::setSequence(int sequence) +{ + d->sequence = sequence; +} + +int Event::sequence() const +{ + return d->sequence; +} + +void Event::setClassification(Classification class_) +{ + d->classification = class_; +} + +Classification Event::classification() const +{ + return d->classification; +} + +void Event::setCategories(const std::vector< std::string > &categories) +{ + d->categories = categories; +} + +void Event::addCategory(const std::string &cat) +{ + d->categories.push_back(cat); +} + +std::vector< std::string > Event::categories() const +{ + return d->categories; +} + +void Event::setStart(const Kolab::cDateTime &start) +{ + d->start = start; +} + +cDateTime Event::start() const +{ + return d->start; +} + +void Event::setEnd(const Kolab::cDateTime &end) +{ + d->end = end; +} + +cDateTime Event::end() const +{ + return d->end; +} + +void Event::setDuration(const Duration &duration) +{ + d->duration = duration; +} + +Duration Event::duration() const +{ + return d->duration; +} + + +void Event::setRecurrenceID(const Kolab::cDateTime &rID, bool thisandfuture) +{ + d->recurrenceID = rID; + d->thisAndFuture = thisandfuture; +} + +cDateTime Event::recurrenceID() const +{ + return d->recurrenceID; +} + +bool Event::thisAndFuture() const +{ + return d->thisAndFuture; +} + +void Event::setSummary(const std::string &summary) +{ + d->summary = summary; +} + +std::string Event::summary() const +{ + return d->summary; +} + +void Event::setDescription(const std::string &description) +{ + d->description = description; +} + +std::string Event::description() const +{ + return d->description; +} + +void Event::setPriority(int priority) +{ + d->priority = priority; +} + +int Event::priority() const +{ + return d->priority; +} + +void Event::setStatus(Status status) +{ + d->status = status; +} + +Status Event::status() const +{ + return d->status; +} + +void Event::setLocation(const std::string &location) +{ + d->location = location; +} + +std::string Event::location() const +{ + return d->location; +} + +void Event::setRecurrenceRule(const Kolab::RecurrenceRule &rrule) +{ + d->rrule = rrule; +} + +RecurrenceRule Event::recurrenceRule() const +{ + return d->rrule; +} + +void Event::setRecurrenceDates(const std::vector< cDateTime > &dates) +{ + d->recurrenceDates = dates; +} + +void Event::addRecurrenceDate(const Kolab::cDateTime &dt) +{ + d->recurrenceDates.push_back(dt); +} + +std::vector< cDateTime > Event::recurrenceDates() const +{ + return d->recurrenceDates; +} + +void Event::setExceptionDates(const std::vector< cDateTime > &dates) +{ + d->exceptionDates = dates; +} + +void Event::addExceptionDate(const Kolab::cDateTime &dt) +{ + d->exceptionDates.push_back(dt); +} + +std::vector< cDateTime > Event::exceptionDates() const +{ + return d->exceptionDates; +} + +void Event::setTransparency(bool isTransparent) +{ + d->isTransparent = isTransparent; +} + +bool Event::transparency() const +{ + return d->isTransparent; +} + +void Event::setOrganizer(const ContactReference &organizer) +{ + d->organizer = organizer; +} + +ContactReference Event::organizer() const +{ + return d->organizer; +} + +void Event::setAttendees(const std::vector< Attendee > &attendees) +{ + d->attendees = attendees; +} + +std::vector< Attendee > Event::attendees() const +{ + return d->attendees; +} + +void Event::setAttachments(const std::vector< Attachment > &attach) +{ + d->attachments = attach; +} + +std::vector< Attachment > Event::attachments() const +{ + return d->attachments; +} + +void Event::setCustomProperties(const std::vector< CustomProperty > &prop) +{ + d->customProperties = prop; +} + +std::vector< CustomProperty > Event::customProperties() const +{ + return d->customProperties; +} + +// void Event::setExceptions(const std::vector< Event > &exceptions) +// { +// d->exceptions = exceptions; +// } +// +// std::vector< Event > Event::exceptions() const +// { +// return d->exceptions; +// } + +void Event::setAlarms(const std::vector< Alarm > &alarms) +{ + d->alarms = alarms; +} + +std::vector< Alarm > Event::alarms() const +{ + return d->alarms; +} + + + + +} diff --git a/src/containers/kolabevent.h b/src/containers/kolabevent.h new file mode 100644 index 0000000..abec9a9 --- /dev/null +++ b/src/containers/kolabevent.h @@ -0,0 +1,124 @@ +/* + * Copyright (C) 2011 Christian Mollekopf <mollekopf@kolabsys.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef KOLAB_EVENT_H +#define KOLAB_EVENT_H + +#include <string> +#include <vector> +#include <boost/scoped_ptr.hpp> +#include "kolabcontainers.h" +namespace Kolab { + +class Event { +public: + Event(); + ~Event(); + Event(const Event &); + void operator=(const Event &); + + bool isValid() const; + + void setUid(const std::string &); + std::string uid() const; + + void setCreated(const cDateTime &); + cDateTime created() const; + + void setLastModified(const cDateTime &); + cDateTime lastModified() const; + + void setSequence(int); + int sequence() const; + + void setClassification(Classification); + Classification classification() const; + + void setCategories(const std::vector<std::string> &); + void addCategory(const std::string &); + std::vector<std::string> categories() const; + + void setStart(const cDateTime &); + cDateTime start() const; + + void setEnd(const cDateTime &); + cDateTime end() const; + + void setDuration(const Duration &); + Duration duration() const; + + void setTransparency(bool isTransparent); + bool transparency() const; + + void setRecurrenceRule(const RecurrenceRule &); + RecurrenceRule recurrenceRule() const; + + void setRecurrenceDates(const std::vector<cDateTime> &); + void addRecurrenceDate(const cDateTime &); + std::vector<cDateTime> recurrenceDates() const; + + void setExceptionDates(const std::vector<cDateTime> &); + void addExceptionDate(const cDateTime &); + std::vector<cDateTime> exceptionDates() const; + + void setRecurrenceID(const cDateTime &, bool thisandfuture); + cDateTime recurrenceID() const; + bool thisAndFuture() const; + + void setSummary(const std::string &); + std::string summary() const; + + void setDescription(const std::string &); + std::string description() const; + + void setPriority(int); + int priority() const; + + void setStatus(Status); + Status status() const; + + void setLocation(const std::string &); + std::string location() const; + + void setOrganizer(const ContactReference &); + ContactReference organizer() const; + + void setAttendees(const std::vector<Attendee> &); + std::vector<Attendee> attendees() const; + + void setAttachments(const std::vector<Attachment> &); + std::vector<Attachment> attachments() const; + + void setCustomProperties(const std::vector<CustomProperty> &); + std::vector<CustomProperty> customProperties() const; +/* TODO what is this? Exceptions it is + void setExceptions(const std::vector<Event> &); + std::vector<Event> exceptions() const;*/ + + void setAlarms(const std::vector<Alarm> &); + std::vector<Alarm> alarms() const; + +protected: + struct Private; + boost::scoped_ptr<Private> d; +}; + + +} + +#endif + diff --git a/src/containers/kolabevent_p.h b/src/containers/kolabevent_p.h new file mode 100644 index 0000000..66054d3 --- /dev/null +++ b/src/containers/kolabevent_p.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2011 Christian Mollekopf <mollekopf@kolabsys.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef KOLABEVENT_P +#define KOLABEVENT_P + +#include "kolabcontainers.h" +#include "incidence_p.h" + +namespace Kolab { + +class Event; + +struct Event::Private: public PrivateIncidence +{ + Private() + : PrivateIncidence(), + isTransparent(false){} + + cDateTime end; + bool isTransparent; + Duration duration; + std::vector< Event > exceptions; +}; + +} + +#endif diff --git a/src/containers/kolabjournal.cpp b/src/containers/kolabjournal.cpp new file mode 100644 index 0000000..ce37fbc --- /dev/null +++ b/src/containers/kolabjournal.cpp @@ -0,0 +1,191 @@ +/* + * Copyright (C) 2012 Christian Mollekopf <mollekopf@kolabsys.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include "kolabjournal.h" +#include "incidence_p.h" + +namespace Kolab { + +struct Journal::Private: public PrivateIncidence +{ + Private() + : PrivateIncidence() {} +}; + +Journal::Journal() +: d(new Journal::Private()) +{ +} + +Journal::Journal(const Journal &other) +: d(new Journal::Private()) +{ + *d = *other.d; +} + +Journal::~Journal() +{ +} + +void Journal::operator=(const Kolab::Journal &other) +{ + *d = *other.d; +} + +bool Journal::isValid() const +{ + return !d->uid.empty(); +} + +void Journal::setUid(const std::string &uid) +{ + d->uid = uid; +} + +std::string Journal::uid() const +{ + return d->uid; +} + +void Journal::setCreated(const Kolab::cDateTime &created) +{ + d->created = created; +} + +cDateTime Journal::created() const +{ + return d->created; +} + +void Journal::setLastModified(const Kolab::cDateTime &lastMod) +{ + d->lastModified = lastMod; +} + +cDateTime Journal::lastModified() const +{ + return d->lastModified; +} + +void Journal::setSequence(int sequence) +{ + d->sequence = sequence; +} + +int Journal::sequence() const +{ + return d->sequence; +} + +void Journal::setClassification(Classification class_) +{ + d->classification = class_; +} + +Classification Journal::classification() const +{ + return d->classification; +} + +void Journal::setCategories(const std::vector< std::string > &categories) +{ + d->categories = categories; +} + +void Journal::addCategory(const std::string &cat) +{ + d->categories.push_back(cat); +} + +std::vector< std::string > Journal::categories() const +{ + return d->categories; +} + +void Journal::setStart(const Kolab::cDateTime &start) +{ + d->start = start; +} + +cDateTime Journal::start() const +{ + return d->start; +} + +void Journal::setSummary(const std::string &summary) +{ + d->summary = summary; +} + +std::string Journal::summary() const +{ + return d->summary; +} + +void Journal::setDescription(const std::string &description) +{ + d->description = description; +} + +std::string Journal::description() const +{ + return d->description; +} + + +void Journal::setStatus(Status status) +{ + d->status = status; +} + +Status Journal::status() const +{ + return d->status; +} + +void Journal::setAttendees(const std::vector< Attendee > &attendees) +{ + d->attendees = attendees; +} + +std::vector< Attendee > Journal::attendees() const +{ + return d->attendees; +} + +void Journal::setAttachments(const std::vector< Attachment > &attach) +{ + d->attachments = attach; +} + +std::vector< Attachment > Journal::attachments() const +{ + return d->attachments; +} + +void Journal::setCustomProperties(const std::vector< CustomProperty > &prop) +{ + d->customProperties = prop; +} + +std::vector< CustomProperty > Journal::customProperties() const +{ + return d->customProperties; +} + + +}//Namespace diff --git a/src/containers/kolabjournal.h b/src/containers/kolabjournal.h new file mode 100644 index 0000000..9a904d3 --- /dev/null +++ b/src/containers/kolabjournal.h @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2012 Christian Mollekopf <mollekopf@kolabsys.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef KOLABJOURNAL_H +#define KOLABJOURNAL_H + +#include <string> +#include <vector> +#include <boost/scoped_ptr.hpp> +#include "kolabcontainers.h" +namespace Kolab { + +class Journal { +public: + Journal(); + ~Journal(); + Journal(const Journal &); + void operator=(const Journal &); + + bool isValid() const; + + void setUid(const std::string &); + std::string uid() const; + + void setCreated(const cDateTime &); + cDateTime created() const; + + void setLastModified(const cDateTime &); + cDateTime lastModified() const; + + void setSequence(int); + int sequence() const; + + void setClassification(Classification); + Classification classification() const; + + void setCategories(const std::vector<std::string> &); + void addCategory(const std::string &); + std::vector<std::string> categories() const; + + void setStart(const cDateTime &); + cDateTime start() const; + + void setSummary(const std::string &); + std::string summary() const; + + void setDescription(const std::string &); + std::string description() const; + + void setStatus(Status); + Status status() const; + + //TODO Contacts + + void setAttendees(const std::vector<Attendee> &); + std::vector<Attendee> attendees() const; + + void setAttachments(const std::vector<Attachment> &); + std::vector<Attachment> attachments() const; + + void setCustomProperties(const std::vector<CustomProperty> &); + std::vector<CustomProperty> customProperties() const; +private: + struct Private; + boost::scoped_ptr<Private> d; +}; + + + +} + +#endif + diff --git a/src/containers/kolabnote.cpp b/src/containers/kolabnote.cpp new file mode 100644 index 0000000..c7931bb --- /dev/null +++ b/src/containers/kolabnote.cpp @@ -0,0 +1,185 @@ +/* + * Copyright (C) 2012 Christian Mollekopf <mollekopf@kolabsys.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "kolabnote.h" + +namespace Kolab { + +struct Note::Private +{ + Private() + : classification(ClassPublic){} + + std::string uid; + cDateTime created; + cDateTime lastModified; + std::vector< std::string > categories; + Classification classification; + + std::string summary; + std::string description; + std::string color; + + std::vector<Attachment> attachments; + std::vector<CustomProperty> customProperties; +}; + +Note::Note() +: d(new Note::Private()) +{ +} + +Note::Note(const Note &other) +: d(new Note::Private()) +{ + *d = *other.d; +} + +Note::~Note() +{ +} + +void Note::operator=(const Kolab::Note &other) +{ + *d = *other.d; +} + +bool Note::operator==(const Kolab::Note& other) const +{ + return ( d->uid == other.uid() && + d->created == other.created() && + d->lastModified == other.lastModified() && + d->categories == other.categories() && + d->classification == other.classification() && + d->summary == other.summary() && + d->description == other.description() && + d->color == other.color() && + d->attachments == other.attachments() && + d->customProperties == other.customProperties()); +} + +bool Note::isValid() const +{ + return !d->uid.empty(); +} + +void Note::setUid(const std::string &uid) +{ + d->uid = uid; +} + +std::string Note::uid() const +{ + return d->uid; +} + +void Note::setCreated(const Kolab::cDateTime &created) +{ + d->created = created; +} + +cDateTime Note::created() const +{ + return d->created; +} + +void Note::setLastModified(const Kolab::cDateTime &lastMod) +{ + d->lastModified = lastMod; +} + +cDateTime Note::lastModified() const +{ + return d->lastModified; +} + +void Note::setClassification(Classification class_) +{ + d->classification = class_; +} + +Classification Note::classification() const +{ + return d->classification; +} + +void Note::setCategories(const std::vector< std::string > &categories) +{ + d->categories = categories; +} + +void Note::addCategory(const std::string &cat) +{ + d->categories.push_back(cat); +} + +std::vector< std::string > Note::categories() const +{ + return d->categories; +} + +void Note::setSummary(const std::string &summary) +{ + d->summary = summary; +} + +std::string Note::summary() const +{ + return d->summary; +} + +void Note::setDescription(const std::string &description) +{ + d->description = description; +} + +std::string Note::description() const +{ + return d->description; +} + +void Note::setColor(const std::string &color) +{ + d->color = color; +} + +std::string Note::color() const +{ + return d->color; +} + +void Note::setAttachments(const std::vector< Attachment > &attach) +{ + d->attachments = attach; +} + +std::vector< Attachment > Note::attachments() const +{ + return d->attachments; +} + +void Note::setCustomProperties(const std::vector< CustomProperty > &prop) +{ + d->customProperties = prop; +} + +std::vector< CustomProperty > Note::customProperties() const +{ + return d->customProperties; +} + +} //Note diff --git a/src/containers/kolabnote.h b/src/containers/kolabnote.h new file mode 100644 index 0000000..6edffb6 --- /dev/null +++ b/src/containers/kolabnote.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2012 Christian Mollekopf <mollekopf@kolabsys.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef KOLABNOTE_H +#define KOLABNOTE_H + +#include <string> +#include <vector> +#include <boost/scoped_ptr.hpp> +#include "kolabcontainers.h" +namespace Kolab { + + class Note { + public: + Note(); + ~Note(); + Note(const Note &); + void operator=(const Note &); + bool operator==(const Note &) const; + + bool isValid() const; + + void setUid(const std::string &); + std::string uid() const; + + void setCreated(const cDateTime &); + cDateTime created() const; + + void setLastModified(const cDateTime &); + cDateTime lastModified() const; + + void setClassification(Classification); + Classification classification() const; + + void setCategories(const std::vector<std::string> &); + void addCategory(const std::string &); + std::vector<std::string> categories() const; + + void setSummary(const std::string &); + std::string summary() const; + + void setDescription(const std::string &); + std::string description() const; + + void setColor(const std::string &); + std::string color() const; + + void setAttachments(const std::vector<Attachment> &); + std::vector<Attachment> attachments() const; + + void setCustomProperties(const std::vector<CustomProperty> &); + std::vector<CustomProperty> customProperties() const; + private: + struct Private; + boost::scoped_ptr<Private> d; + }; + +} + +#endif + diff --git a/src/containers/kolabtodo.cpp b/src/containers/kolabtodo.cpp new file mode 100644 index 0000000..ceefcf9 --- /dev/null +++ b/src/containers/kolabtodo.cpp @@ -0,0 +1,327 @@ +/* + * Copyright (C) 2011 Christian Mollekopf <mollekopf@kolabsys.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include "kolabtodo.h" +#include "incidence_p.h" + +namespace Kolab { + + +struct Todo::Private: public PrivateIncidence +{ + Private() + : PrivateIncidence(), + percentComplete(0){} + + cDateTime due; + int percentComplete; +}; + +Todo::Todo() +: d(new Todo::Private()) +{ + +} + +Todo::Todo(const Todo &other) +: d(new Todo::Private()) +{ + *d = *other.d; +} + +Todo::~Todo() +{ + +} + +void Todo::operator=(const Kolab::Todo &other) +{ + *d = *other.d; +} + +bool Todo::isValid() const +{ + return !d->uid.empty(); +} + +void Todo::setUid(const std::string &uid) +{ + d->uid = uid; +} + +std::string Todo::uid() const +{ + return d->uid; +} + +void Todo::setCreated(const Kolab::cDateTime &created) +{ + d->created = created; +} + +cDateTime Todo::created() const +{ + return d->created; +} + +void Todo::setLastModified(const Kolab::cDateTime &lastMod) +{ + d->lastModified = lastMod; +} + +cDateTime Todo::lastModified() const +{ + return d->lastModified; +} + +void Todo::setSequence(int sequence) +{ + d->sequence = sequence; +} + +int Todo::sequence() const +{ + return d->sequence; +} + +void Todo::setClassification(Classification class_) +{ + d->classification = class_; +} + +Classification Todo::classification() const +{ + return d->classification; +} + +void Todo::setCategories(const std::vector< std::string > &categories) +{ + d->categories = categories; +} + +void Todo::addCategory(const std::string &cat) +{ + d->categories.push_back(cat); +} + +std::vector< std::string > Todo::categories() const +{ + return d->categories; +} + +void Todo::setRelatedTo(const std::vector< std::string > &related) +{ + d->relatedTo = related; +} + +void Todo::addRelatedTo(const std::string &related) +{ + d->relatedTo.push_back(related); +} + +std::vector< std::string > Todo::relatedTo() const +{ + return d->relatedTo; +} + +void Todo::setStart(const Kolab::cDateTime &start) +{ + d->start = start; +} + +cDateTime Todo::start() const +{ + return d->start; +} + +void Todo::setDue(const Kolab::cDateTime &due) +{ + d->due = due; +} + +cDateTime Todo::due() const +{ + return d->due; +} + +void Todo::setRecurrenceID(const Kolab::cDateTime &rID, bool thisandfuture) +{ + d->recurrenceID = rID; + d->thisAndFuture = thisandfuture; +} + +cDateTime Todo::recurrenceID() const +{ + return d->recurrenceID; +} + +bool Todo::thisAndFuture() const +{ + return d->thisAndFuture; +} + +void Todo::setSummary(const std::string &summary) +{ + d->summary = summary; +} + +std::string Todo::summary() const +{ + return d->summary; +} + +void Todo::setDescription(const std::string &description) +{ + d->description = description; +} + +std::string Todo::description() const +{ + return d->description; +} + +void Todo::setPriority(int priority) +{ + d->priority = priority; +} + +int Todo::priority() const +{ + return d->priority; +} + +void Todo::setStatus(Status status) +{ + d->status = status; +} + +Status Todo::status() const +{ + return d->status; +} + +void Todo::setPercentComplete(int complete) +{ + d->percentComplete = complete; +} + +int Todo::percentComplete() const +{ + return d->percentComplete; +} + +void Todo::setLocation(const std::string &location) +{ + d->location = location; +} + +std::string Todo::location() const +{ + return d->location; +} + +void Todo::setRecurrenceRule(const Kolab::RecurrenceRule &rrule) +{ + d->rrule = rrule; +} + +RecurrenceRule Todo::recurrenceRule() const +{ + return d->rrule; +} + +void Todo::setRecurrenceDates(const std::vector< cDateTime > &dates) +{ + d->recurrenceDates = dates; +} + +void Todo::addRecurrenceDate(const Kolab::cDateTime &dt) +{ + d->recurrenceDates.push_back(dt); +} + +std::vector< cDateTime > Todo::recurrenceDates() const +{ + return d->recurrenceDates; +} + +void Todo::setExceptionDates(const std::vector< cDateTime > &dates) +{ + d->exceptionDates = dates; +} + +void Todo::addExceptionDate(const Kolab::cDateTime &dt) +{ + d->exceptionDates.push_back(dt); +} + +std::vector< cDateTime > Todo::exceptionDates() const +{ + return d->exceptionDates; +} + +void Todo::setOrganizer(const ContactReference &organizer) +{ + d->organizer = organizer; +} + +ContactReference Todo::organizer() const +{ + return d->organizer; +} + +void Todo::setAttendees(const std::vector< Attendee > &attendees) +{ + d->attendees = attendees; +} + +std::vector< Attendee > Todo::attendees() const +{ + return d->attendees; +} + +void Todo::setAttachments(const std::vector< Attachment > &attach) +{ + d->attachments = attach; +} + +std::vector< Attachment > Todo::attachments() const +{ + return d->attachments; +} + +void Todo::setCustomProperties(const std::vector< CustomProperty > &prop) +{ + d->customProperties = prop; +} + +std::vector< CustomProperty > Todo::customProperties() const +{ + return d->customProperties; +} + +void Todo::setAlarms(const std::vector< Alarm > &alarms) +{ + d->alarms = alarms; +} + +std::vector< Alarm > Todo::alarms() const +{ + return d->alarms; +} + +} diff --git a/src/containers/kolabtodo.h b/src/containers/kolabtodo.h new file mode 100644 index 0000000..ce547e3 --- /dev/null +++ b/src/containers/kolabtodo.h @@ -0,0 +1,122 @@ +/* + * Copyright (C) 2011 Christian Mollekopf <mollekopf@kolabsys.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef KOLAB_TODO_H +#define KOLAB_TODO_H + +#include <string> +#include <vector> +#include <boost/scoped_ptr.hpp> +#include "kolabcontainers.h" +namespace Kolab { + + +class Todo { +public: + Todo(); + ~Todo(); + Todo(const Todo &); + void operator=(const Todo &); + + bool isValid() const; + + void setUid(const std::string &); + std::string uid() const; + + void setCreated(const cDateTime &); + cDateTime created() const; + + void setLastModified(const cDateTime &); + cDateTime lastModified() const; + + void setSequence(int); + int sequence() const; + + void setClassification(Classification); + Classification classification() const; + + void setCategories(const std::vector<std::string> &); + void addCategory(const std::string &); + std::vector<std::string> categories() const; + + void setRelatedTo(const std::vector<std::string> &); + void addRelatedTo(const std::string &); + std::vector<std::string> relatedTo() const; + + void setStart(const cDateTime &); + cDateTime start() const; + + void setDue(const cDateTime &); + cDateTime due() const; + + void setRecurrenceRule(const RecurrenceRule &); + RecurrenceRule recurrenceRule() const; + + void setRecurrenceDates(const std::vector<cDateTime> &); + void addRecurrenceDate(const cDateTime &); + std::vector<cDateTime> recurrenceDates() const; + + void setExceptionDates(const std::vector<cDateTime> &); + void addExceptionDate(const cDateTime &); + std::vector<cDateTime> exceptionDates() const; + + void setRecurrenceID(const cDateTime &, bool thisandfuture); + cDateTime recurrenceID() const; + bool thisAndFuture() const; + + void setSummary(const std::string &); + std::string summary() const; + + void setDescription(const std::string &); + std::string description() const; + + void setPriority(int); + int priority() const; + + void setStatus(Status); + Status status() const; + + void setPercentComplete(int); + int percentComplete() const; + + void setLocation(const std::string &); + std::string location() const; + + void setOrganizer(const ContactReference &); + ContactReference organizer() const; + + void setAttendees(const std::vector<Attendee> &); + std::vector<Attendee> attendees() const; + + void setAttachments(const std::vector<Attachment> &); + std::vector<Attachment> attachments() const; + + void setCustomProperties(const std::vector<CustomProperty> &); + std::vector<CustomProperty> customProperties() const; + + void setAlarms(const std::vector<Alarm> &); + std::vector<Alarm> alarms() const; + +private: + struct Private; + boost::scoped_ptr<Private> d; +}; + +} + +#endif + |