HarmattanSyncApplications
CalendarBackend.h
1/*
2 * This file is part of buteo-sync-plugins package
3 *
4 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5 *
6 * Contact: Sateesh Kavuri <sateesh.kavuri@nokia.com>
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * version 2.1 as published by the Free Software Foundation.
11 *
12 * This library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 *
22 */
23
24#ifndef CALENDARBACKEND_H_490498898043897984389983478
25#define CALENDARBACKEND_H_490498898043897984389983478
26
27#include <QString>
28
29#include "definitions.h"
30
31//calendar related includes
32#include "extendedcalendar.h"
33#include "notebook.h"
34#include <sqlitestorage.h>
35#include <KCalendarCore/MemoryCalendar>
36#include <KCalendarCore/VCalFormat>
37#include <KCalendarCore/ICalFormat>
38
39static const QString ID_SEPARATOR("::");
42{
43
44public:
45 //error status code return by calender backend.
53
56
59
61 // \param strNotebookName Name of the notebook to use
62 bool init( const QString& aNotebookName, const QString& aUid = "" );
63
65 bool uninit();
66
68 // @param aIncidences List of incidences
69 // @return True on success, otherwise false
70 bool getAllIncidences( KCalendarCore::Incidence::List& aIncidences );
71
73 // @param aIncidences List of incidences
74 // @param aTime Timestamp
75 // @return True on success, otherwise false
76 bool getAllNew( KCalendarCore::Incidence::List& aIncidences, const QDateTime& aTime );
77
79 // @param aIncidences List of incidences
80 // @param aTime Timestamp
81 // @return True on success, otherwise false
82 bool getAllModified( KCalendarCore::Incidence::List& aIncidences, const QDateTime& aTime );
83
85 // @param aIncidences List of incidences
86 // @param aTime Timestamp
87 // @return True on success, otherwise false
88 bool getAllDeleted( KCalendarCore::Incidence::List& aIncidences, const QDateTime& aTime );
89
91 // Caller must not free the returned pointer.
92 // \param aUID Item UID
93 // \return The incidence (should not be freed by caller).
94 KCalendarCore::Incidence::Ptr getIncidence( const QString& aUID );
95
97 // \param pInci Incidence
98 QString getVCalString( KCalendarCore::Incidence::Ptr aInci );
99
101 // \param pInci Incidence
102 QString getICalString( KCalendarCore::Incidence::Ptr aInci );
103
105 // Caller has to free the returned incidence after user.
106 // \param aVString Incidence representation in VCalendar format.
107 // \return Incidence pointer
108 KCalendarCore::Incidence::Ptr getIncidenceFromVcal( const QString& aVString );
109
111 // Caller has to free the returned incidence after user.
112 // \param aIString Incidence representation in ICalendar format.
113 // \return Incidence pointer
114 KCalendarCore::Incidence::Ptr getIncidenceFromIcal( const QString& aIString );
115
117 //
118 // Duplicate checking will be done if id the of item is not empty.
119 // If an entry exists, it will be overwritten.
120 // The uid of incidence will be updated.
121 // \param aInci Incidence to be added.
122 // \param commitNow - indicates if we have to commit to the backend immediately
123 // \return true if addition is success, otherwise false
124 bool addIncidence( KCalendarCore::Incidence::Ptr aInci, bool commitNow = true );
125
129
131 //
132 // if there is no incidence with old id exists, a new incidence
133 // will be created.
134 // The uid of incidence will be updated.
135 // \param aInci Incidence to be modified
136 // \param aUID UID of item
137 // \return true if modification was success, otherwise false
138 bool modifyIncidence( KCalendarCore::Incidence::Ptr aInci, const QString& aUID, bool commitNow = true );
139
141 // \param aUID id of the incidence to be deleted
142 // \return errorCode of the operation as status.
143 ErrorStatus deleteIncidence( const QString& aUID);
144
145private:
146 bool modifyIncidence( KCalendarCore::Incidence::Ptr aIncidence, KCalendarCore::Incidence::Ptr aIncidenceData );
147
148 void filterIncidences( KCalendarCore::Incidence::List& aList );
149
150 QString iNotebookStr;
151 mKCal::ExtendedCalendar::Ptr iCalendar;
152 mKCal::ExtendedStorage::Ptr iStorage;
153
154};
155
156
157#endif //CALENDARBACKEND_H_490498898043897984389983478
Calendar implementation for synchronization.
Definition CalendarBackend.h:42
bool getAllDeleted(KCalendarCore::Incidence::List &aIncidences, const QDateTime &aTime)
returns all deleted items after the date
QString getICalString(KCalendarCore::Incidence::Ptr aInci)
returns ICalendar representation of incidence
bool modifyIncidence(KCalendarCore::Incidence::Ptr aInci, const QString &aUID, bool commitNow=true)
Modify the incidence in calendar.
bool addIncidence(KCalendarCore::Incidence::Ptr aInci, bool commitNow=true)
Add the incidence to calendar.
ErrorStatus deleteIncidence(const QString &aUID)
delete the incidence
virtual ~CalendarBackend()
destructor
bool uninit()
Uninitializes the storage.
ErrorStatus
Definition CalendarBackend.h:47
@ STATUS_OK
Definition CalendarBackend.h:51
@ STATUS_ITEM_NOT_FOUND
Definition CalendarBackend.h:50
@ STATUS_GENERIC_ERROR
Definition CalendarBackend.h:48
@ STATUS_ITEM_DUPLICATE
Definition CalendarBackend.h:49
CalendarBackend()
constructor
bool init(const QString &aNotebookName, const QString &aUid="")
Initializes the CalendarBackend.
KCalendarCore::Incidence::Ptr getIncidence(const QString &aUID)
Get incidence based on uid.
QString getVCalString(KCalendarCore::Incidence::Ptr aInci)
returns VCalendar representation of incidence
bool getAllIncidences(KCalendarCore::Incidence::List &aIncidences)
returns all incidences inside this calendar
bool getAllNew(KCalendarCore::Incidence::List &aIncidences, const QDateTime &aTime)
returns all new items after the date
bool commitChanges()
Tell Calendar to commit changes to their db.
KCalendarCore::Incidence::Ptr getIncidenceFromIcal(const QString &aIString)
get Incidence from ICalendar string
KCalendarCore::Incidence::Ptr getIncidenceFromVcal(const QString &aVString)
get Incidence from VCalendar string
bool getAllModified(KCalendarCore::Incidence::List &aIncidences, const QDateTime &aTime)
returns all modified items after the date