| 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 <[email protected]> |
| 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 |
#ifndef NOTESBACKEND_H |
| 24 |
#define NOTESBACKEND_H |
| 25 |
|
| 26 |
#include <KCalendarCore/Incidence> |
| 27 |
#include <extendedcalendar.h> |
| 28 |
#include <extendedstorage.h> |
| 29 |
|
| 30 |
class QDateTime; |
| 31 |
|
| 32 |
namespace Buteo { |
| 33 |
class StorageItem; |
| 34 |
} |
| 35 |
|
| 36 |
/*! \brief Notes Calendar backend proxy |
| 37 |
* |
| 38 |
*/ |
| 39 |
class NotesBackend |
| 40 |
{ |
| 41 |
public: |
| 42 |
|
| 43 |
/*! \brief Constructor |
| 44 |
* |
| 45 |
*/ |
| 46 |
NotesBackend(); |
| 47 |
|
| 48 |
/*! \brief Destructor |
| 49 |
* |
| 50 |
*/ |
| 51 |
virtual ~NotesBackend(); |
| 52 |
|
| 53 |
/*! \brief Initializes backend |
| 54 |
* |
| 55 |
* @return True on success, otherwise false |
| 56 |
*/ |
| 57 |
bool init( const QString& aNotebookName, const QString& aUid, const QString &aMimeType ); |
| 58 |
|
| 59 |
/*! \brief Uninitializes backend |
| 60 |
* |
| 61 |
* @return True on success, otherwise false |
| 62 |
*/ |
| 63 |
bool uninit(); |
| 64 |
|
| 65 |
/*! \brief retrieves all Notes from the backend |
| 66 |
* |
| 67 |
* @param aItems Output Parameter - List of Buteo::StorageItems retrieved from Backend. |
| 68 |
* @return True on success, otherwise false |
| 69 |
*/ |
| 70 |
bool getAllNotes( QList<Buteo::StorageItem*>& aItems ); |
| 71 |
|
| 72 |
/*! \brief gets are note ids from the backend |
| 73 |
* |
| 74 |
* @param aIds - list of notes ids |
| 75 |
* @return True on success, otherwise false |
| 76 |
*/ |
| 77 |
bool getAllNoteIds( QList<QString>& aIds ); |
| 78 |
|
| 79 |
/*! \brief get all new notes from a timestamp |
| 80 |
* |
| 81 |
* @param aNewItems List of new items.(output parameter) |
| 82 |
* @param aTime - time from which to retrieve the notes |
| 83 |
* @return True on success, otherwise false |
| 84 |
*/ |
| 85 |
bool getNewNotes( QList<Buteo::StorageItem*>& aNewItems, const QDateTime& aTime ); |
| 86 |
|
| 87 |
/*! \brief get all new note ids from a timestamp |
| 88 |
* |
| 89 |
* @param aNewIds List of new ids (output parameter) |
| 90 |
* @param aTime - time from which to retrieve the notes |
| 91 |
* @return True on success, otherwise false |
| 92 |
*/ |
| 93 |
bool getNewNoteIds( QList<QString>& aNewIds, const QDateTime& aTime ); |
| 94 |
|
| 95 |
/*! \brief get all modified notes from the backend |
| 96 |
* |
| 97 |
* @param aModifiedItems - list of modified items (output parameter) |
| 98 |
* @param aTime - timestamp from which the modified notes are needed. |
| 99 |
* @return True on success, otherwise false |
| 100 |
*/ |
| 101 |
bool getModifiedNotes( QList<Buteo::StorageItem*>& aModifiedItems, const QDateTime& aTime ); |
| 102 |
|
| 103 |
/*! \brief get all modified notes ids from the backend |
| 104 |
* |
| 105 |
* @param aModifiedIds - list of modified ids (output parameter) |
| 106 |
* @param aTime - timestamp from which the modified notes ids are needed. |
| 107 |
* @return True on success, otherwise false |
| 108 |
*/ |
| 109 |
bool getModifiedNoteIds( QList<QString>& aModifiedIds, const QDateTime& aTime ); |
| 110 |
|
| 111 |
/*! \brief gets all deleted note ids |
| 112 |
* |
| 113 |
* @param aDeletedIds - deleted ids. |
| 114 |
* @param aTime - timestamp from which the deleted ids are needed. |
| 115 |
* @return True on success, otherwise false |
| 116 |
*/ |
| 117 |
bool getDeletedNoteIds( QList<QString>& aDeletedIds, const QDateTime& aTime ); |
| 118 |
|
| 119 |
/*! \brief fetch a new StorageItem |
| 120 |
* |
| 121 |
* @return pointer to the newly created StorageItem |
| 122 |
*/ |
| 123 |
Buteo::StorageItem* newItem(); |
| 124 |
|
| 125 |
/*! \brief get an item |
| 126 |
* |
| 127 |
* @param aItemId - id of the item to get |
| 128 |
* @return pointer to the StorageItem |
| 129 |
*/ |
| 130 |
Buteo::StorageItem* getItem( const QString& aItemId ); |
| 131 |
|
| 132 |
/*! \brief Uninitializes backend |
| 133 |
* |
| 134 |
* @param aItem - item to add |
| 135 |
* @param aCommitNow - if true persist db changes, if false do this later |
| 136 |
* @return True on success, otherwise false |
| 137 |
*/ |
| 138 |
bool addNote( Buteo::StorageItem& aItem, bool commitNow ); |
| 139 |
|
| 140 |
/*! \brief Uninitializes backend |
| 141 |
* |
| 142 |
* @param aItem - item to modify |
| 143 |
* @param aCommitNow - if true persist db changes, if false do this later |
| 144 |
* @return True on success, otherwise false |
| 145 |
*/ |
| 146 |
bool modifyNote( Buteo::StorageItem& aItem, bool commitNow ); |
| 147 |
|
| 148 |
/*! \brief Uninitializes backend |
| 149 |
* |
| 150 |
* @param aId - id of item to delete |
| 151 |
* @param aCommitNow - if true persist db changes, if false do this later |
| 152 |
* @return True on success, otherwise false |
| 153 |
*/ |
| 154 |
bool deleteNote( const QString& aId, bool commitNow ); |
| 155 |
|
| 156 |
/*! \brief Persist notes db |
| 157 |
* |
| 158 |
* @return True on success, otherwise false |
| 159 |
*/ |
| 160 |
bool commitChanges(); |
| 161 |
|
| 162 |
protected: |
| 163 |
|
| 164 |
private: |
| 165 |
|
| 166 |
void retrieveNoteItems( KCalendarCore::Incidence::List& aIncidences, QList<Buteo::StorageItem*>& aItems ); |
| 167 |
|
| 168 |
void retrieveNoteIds( KCalendarCore::Incidence::List& aIncidences, QList<QString>& aIds ); |
| 169 |
|
| 170 |
void filterIncidences( KCalendarCore::Incidence::List& aIncidences ); |
| 171 |
|
| 172 |
|
| 173 |
QString iNotebookName; |
| 174 |
QString iMimeType; |
| 175 |
|
| 176 |
mKCal::ExtendedCalendar::Ptr iCalendar; |
| 177 |
mKCal::ExtendedStorage::Ptr iStorage; |
| 178 |
|
| 179 |
}; |
| 180 |
|
| 181 |
#endif // NOTESBACKEND_H |