Changeset 1620
- Timestamp:
- 01/20/07 13:29:38 (23 months ago)
- Location:
- plugins/kdepim/src
- Files:
-
- 10 modified
-
KNotesIface.h (modified) (2 diffs)
-
kaddrbook.cpp (modified) (13 diffs)
-
kaddrbook.h (modified) (3 diffs)
-
kcal.cpp (modified) (9 diffs)
-
kcal.h (modified) (3 diffs)
-
kdepim_impl.cpp (modified) (3 diffs)
-
kdepim_sync.cpp (modified) (6 diffs)
-
knotes.cpp (modified) (3 diffs)
-
knotes.h (modified) (3 diffs)
-
osyncbase.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
plugins/kdepim/src/KNotesIface.h
r455 r1620 1 1 /******************************************************************* 2 2 KNotesIface.h -- This file defines the DCOP interface for KNotes. 3 3 4 4 Copyright (C) 2000 by Adriaan de Groot 5 5 2001-2003 by Michael Brade <brade@kde.org> 6 6 7 7 This program is free software; you can redistribute it and/or 8 8 modify it under the terms of the GNU General Public License 9 9 as published by the Free Software Foundation; either version 2 10 10 of the License, or (at your option) any later version. 11 11 12 12 This program is distributed in the hope that it will be useful, 13 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 15 GNU General Public License for more details. 16 16 17 17 You should have received a copy of the GNU General Public License 18 18 along with this program; if not, write to the Free Software … … 31 31 class KNotesIface : virtual public DCOPObject 32 32 { 33 K_DCOP34 k_dcop:35 /**36 * Create a new note.37 * @param name the name (title) of the new note, if it is empty,38 * KNotes will choose an appropriate name39 * @param text the body of the new note40 * @return the new notes' id41 */42 virtual QString newNote( const QString& name = QString::null,43 const QString& text = QString::null ) = 0;33 K_DCOP 34 k_dcop: 35 /** 36 * Create a new note. 37 * @param name the name (title) of the new note, if it is empty, 38 * KNotes will choose an appropriate name 39 * @param text the body of the new note 40 * @return the new notes' id 41 */ 42 virtual QString newNote( const QString& name = QString::null, 43 const QString& text = QString::null ) = 0; 44 44 45 /**46 * Create a new note and inserts the current text in the clipboard47 * as text.48 *49 * @param name the name (title) of the new note, if it is empty,50 * KNotes will choose an appropriate name51 * @return the new notes' id52 */53 virtual QString newNoteFromClipboard( const QString& name = QString::null ) = 0;45 /** 46 * Create a new note and inserts the current text in the clipboard 47 * as text. 48 * 49 * @param name the name (title) of the new note, if it is empty, 50 * KNotes will choose an appropriate name 51 * @return the new notes' id 52 */ 53 virtual QString newNoteFromClipboard( const QString& name = QString::null ) = 0; 54 54 55 /**56 * Show a note as if it had been selected from the "notes" menu.57 * @param noteId the id of the note to show58 */59 virtual ASYNC showNote( const QString& noteId ) const = 0;55 /** 56 * Show a note as if it had been selected from the "notes" menu. 57 * @param noteId the id of the note to show 58 */ 59 virtual ASYNC showNote( const QString& noteId ) const = 0; 60 60 61 /**62 * Hide a note.63 * @param noteId the id of the note to hide64 */65 virtual ASYNC hideNote( const QString& noteId ) const = 0;61 /** 62 * Hide a note. 63 * @param noteId the id of the note to hide 64 */ 65 virtual ASYNC hideNote( const QString& noteId ) const = 0; 66 66 67 /**68 * Deletes a note forever.69 * @param noteId the id of the note to kill70 */71 virtual ASYNC killNote( const QString& noteId ) = 0;67 /** 68 * Deletes a note forever. 69 * @param noteId the id of the note to kill 70 */ 71 virtual ASYNC killNote( const QString& noteId ) = 0; 72 72 73 /**74 * Deletes a note forever.75 * @param noteId the id of the note to kill76 * @param force do not request confirmation77 */78 virtual ASYNC killNote( const QString& noteId, bool force ) = 0;73 /** 74 * Deletes a note forever. 75 * @param noteId the id of the note to kill 76 * @param force do not request confirmation 77 */ 78 virtual ASYNC killNote( const QString& noteId, bool force ) = 0; 79 79 80 /**81 * Get all the notes including their ids.82 * @return a QMap that maps the id of a note to its name83 */84 virtual QMap<QString,QString> notes() const = 0;80 /** 81 * Get all the notes including their ids. 82 * @return a QMap that maps the id of a note to its name 83 */ 84 virtual QMap<QString,QString> notes() const = 0; 85 85 86 /**87 * Changes the title/name of a note.88 * @param noteId the id of the note to be modified89 * @param newName the new title90 */91 virtual ASYNC setName( const QString& noteId, const QString& newName ) = 0;86 /** 87 * Changes the title/name of a note. 88 * @param noteId the id of the note to be modified 89 * @param newName the new title 90 */ 91 virtual ASYNC setName( const QString& noteId, const QString& newName ) = 0; 92 92 93 /**94 * Sets the text of a note. This will delete the old text!95 * @param noteId the id of the note96 * @param newText the new text for the note97 */98 virtual ASYNC setText( const QString& noteId, const QString& newText ) = 0;93 /** 94 * Sets the text of a note. This will delete the old text! 95 * @param noteId the id of the note 96 * @param newText the new text for the note 97 */ 98 virtual ASYNC setText( const QString& noteId, const QString& newText ) = 0; 99 99 100 /**101 * Returns the title/name of a note.102 * @param noteId the id of the note in question103 * @return the name as a QString104 */105 virtual QString name( const QString& noteId ) const = 0;100 /** 101 * Returns the title/name of a note. 102 * @param noteId the id of the note in question 103 * @return the name as a QString 104 */ 105 virtual QString name( const QString& noteId ) const = 0; 106 106 107 /**108 * Returns the text of a note.109 * @param noteId the id of the note in question110 * @return the body as a QString111 */112 virtual QString text( const QString& noteId ) const = 0;107 /** 108 * Returns the text of a note. 109 * @param noteId the id of the note in question 110 * @return the body as a QString 111 */ 112 virtual QString text( const QString& noteId ) const = 0; 113 113 114 /**115 * This tells KNotes that a specific app has synchronized with all the notes.116 * @param app the app that has synced with KNotes117 */118 virtual ASYNC sync( const QString& app ) = 0;114 /** 115 * This tells KNotes that a specific app has synchronized with all the notes. 116 * @param app the app that has synced with KNotes 117 */ 118 virtual ASYNC sync( const QString& app ) = 0; 119 119 120 /**121 * Test if a note was created new after the last sync.122 * @param app the app that wants to get the status since the last sync123 * @param noteId the id of the note124 * @return true if the note is new, false if not or if the note does125 * not exist126 */127 virtual bool isNew( const QString& app, const QString& noteId ) const = 0;120 /** 121 * Test if a note was created new after the last sync. 122 * @param app the app that wants to get the status since the last sync 123 * @param noteId the id of the note 124 * @return true if the note is new, false if not or if the note does 125 * not exist 126 */ 127 virtual bool isNew( const QString& app, const QString& noteId ) const = 0; 128 128 129 /**130 * Test if a note was modified since the last sync.131 * @param app the app that wants to get the status since the last sync132 * @param noteId the id of the note133 * @return true if modified (note that this will return true if the note is134 * new as well!) and false if the note is not modified or doesn't exist135 */136 virtual bool isModified( const QString& app, const QString& noteId ) const = 0;129 /** 130 * Test if a note was modified since the last sync. 131 * @param app the app that wants to get the status since the last sync 132 * @param noteId the id of the note 133 * @return true if modified (note that this will return true if the note is 134 * new as well!) and false if the note is not modified or doesn't exist 135 */ 136 virtual bool isModified( const QString& app, const QString& noteId ) const = 0; 137 137 }; 138 138 -
plugins/kdepim/src/kaddrbook.cpp
r1617 r1620 1 /*********************************************************************** 1 /*********************************************************************** 2 2 KAddressbook support for OpenSync kdepim-sync plugin 3 3 Copyright (C) 2004 Conectiva S. A. 4 4 Copyright (C) 2005 Armin Bauer 5 5 6 6 This program is free software; you can redistribute it and/or modify 7 7 it under the terms of the GNU General Public License version 2 as 8 8 published by the Free Software Foundation; 9 9 10 10 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 11 11 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, … … 16 16 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 17 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 18 19 19 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 20 20 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS … … 31 31 #include <qdeepcopy.h> 32 32 33 KContactDataSource::KContactDataSource(OSyncMember *member, OSyncHashTable *hashtable) 34 : hashtable(hashtable), member(member) 33 KContactDataSource::KContactDataSource(OSyncMember *member, OSyncHashTable *hashtable) : hashtable(hashtable), member(member) 35 34 { 36 35 connected = false; … … 44 43 QString KContactDataSource::calc_hash(KABC::Addressee &e) 45 44 { 46 //Get the revision date of the KDE addressbook entry. 47 //Regard entries with invalid revision dates as having just been changed. 48 QDateTime revdate = e.revision(); 49 osync_debug("kde", 3, "Getting hash: %s", revdate.toString().data()); 50 if (!revdate.isValid()) 51 { 52 revdate = QDateTime::currentDateTime(); 53 e.setRevision(revdate); 54 } 55 56 return revdate.toString(); 45 //Get the revision date of the KDE addressbook entry. 46 //Regard entries with invalid revision dates as having just been changed. 47 QDateTime revdate = e.revision(); 48 osync_debug("kde", 3, "Getting hash: %s", revdate.toString().data()); 49 if (!revdate.isValid()) { 50 revdate = QDateTime::currentDateTime(); 51 e.setRevision(revdate); 52 } 53 54 return revdate.toString(); 57 55 } 58 56 … … 60 58 { 61 59 osync_trace(TRACE_ENTRY, "%s(%p)", __func__, ctx); 62 60 63 61 DCOPClient *dcopc = KApplication::kApplication()->dcopClient(); 64 62 if (!dcopc) { … … 80 78 //get a handle to the standard KDE addressbook 81 79 addressbookptr = KABC::StdAddressBook::self(); 82 80 83 81 //Detection mechanismn if this is the first sync 84 82 if (!osync_anchor_compare(member, "synced", "true")) { … … 119 117 { 120 118 osync_trace(TRACE_ENTRY, "%s(%p)", __func__, ctx); 121 119 122 120 if (osync_member_get_slow_sync(member, "contact")) { 123 121 osync_trace(TRACE_INTERNAL, "Got slow-sync"); 124 122 osync_hashtable_set_slow_sync(hashtable, "contact"); 125 123 } 126 124 127 125 // We must reload the KDE addressbook in order to retrieve the latest changes. 128 126 if (!addressbookptr->load()) { … … 135 133 for (KABC::AddressBook::Iterator it=addressbookptr->begin(); it!=addressbookptr->end(); it++ ) { 136 134 QString uid = it->uid(); 137 135 138 136 OSyncChange *chg = osync_change_new(); 139 137 140 138 osync_change_set_member(chg, member); 141 139 osync_change_set_uid(chg, uid.local8Bit()); 142 140 143 141 QString hash = calc_hash(*it); 144 142 145 143 // Convert the VCARD data into a string 146 144 // only vcard3.0 exports Categories … … 150 148 151 149 osync_trace(TRACE_SENSITIVE,"\n%s", data); 152 150 153 151 osync_change_set_data(chg, data, strlen(data) + 1, TRUE); 154 152 155 153 // object type and format 156 154 osync_change_set_objtype_string(chg, "contact"); 157 155 osync_change_set_objformat_string(chg, "vcard30"); 158 156 159 157 // Use the hash table to check if the object 160 158 // needs to be reported … … 165 163 } 166 164 } 167 165 168 166 // Use the hashtable to report deletions 169 167 osync_hashtable_report_deleted(hashtable, ctx, "contact"); 170 168 171 osync_trace(TRACE_EXIT, "%s", __func__);169 osync_trace(TRACE_EXIT, "%s", __func__); 172 170 return true; 173 171 } … … 184 182 osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, ctx, chg); 185 183 KABC::VCardConverter converter; 186 184 187 185 // convert VCARD string from obj->comp into an Addresse object. 188 186 char *data = osync_change_get_data(chg); 189 187 size_t data_size = osync_change_get_datasize(chg); 190 188 QString uid = osync_change_get_uid(chg); 191 189 192 190 OSyncChangeType chtype = osync_change_get_changetype(chg); 193 191 switch(chtype) { 194 192 case CHANGE_MODIFIED: { 195 193 KABC::Addressee addressee = converter.parseVCard(QString::fromUtf8(data, data_size)); 196 194 197 195 // ensure it has the correct UID and revision 198 196 addressee.setUid(uid); 199 197 addressee.setRevision(QDateTime::currentDateTime()); 200 198 201 199 // replace the current addressbook entry (if any) with the new one 202 200 203 201 addressbookptr->insertAddressee(addressee); 204 202 205 203 QString hash = calc_hash(addressee); 206 204 osync_change_set_hash(chg, hash); 207 osync_debug("kde", 3, "KDE ADDRESSBOOK ENTRY UPDATED (UID=%s)", (const char *)uid.local8Bit()); 205 osync_debug("kde", 3, "KDE ADDRESSBOOK ENTRY UPDATED (UID=%s)", (const char *)uid.local8Bit()); 208 206 break; 209 207 } 210 208 case CHANGE_ADDED: { 211 209 KABC::Addressee addressee = converter.parseVCard(QString::fromUtf8(data, data_size)); 212 210 213 211 // ensure it has the correct revision 214 212 addressee.setRevision(QDateTime::currentDateTime()); 215 213 216 214 // add the new address to the addressbook 217 215 addressbookptr->insertAddressee(addressee); 218 216 219 217 osync_change_set_uid(chg, addressee.uid().local8Bit()); 220 218 221 219 QString hash = calc_hash(addressee); 222 220 osync_change_set_hash(chg, hash); … … 230 228 return FALSE; 231 229 } 232 230 233 231 //find addressbook entry with matching UID and delete it 234 232 KABC::Addressee addressee = addressbookptr->findByUid(uid); 235 233 if(!addressee.isEmpty()) 236 234 addressbookptr->removeAddressee(addressee); 237 235 238 236 osync_debug("kde", 3, "KDE ADDRESSBOOK ENTRY DELETED (UID=%s)", (const char*)uid.local8Bit()); 239 237 240 238 break; 241 239 } 242 default: 240 default: { 243 241 osync_context_report_error(ctx, OSYNC_ERROR_NOT_SUPPORTED, "Operation not supported"); 244 242 osync_trace(TRACE_EXIT_ERROR, "%s: Operation not supported", __func__); 245 243 return FALSE; 246 } 247 244 } 245 } 246 248 247 osync_trace(TRACE_EXIT, "%s", __func__); 249 248 return TRUE; … … 261 260 bool KContactDataSource::vcard_commit_change(OSyncContext *ctx, OSyncChange *chg) 262 261 { 263 if ( !__vcard_access(ctx, chg) )264 return false;265 266 osync_hashtable_update_hash(hashtable, chg);267 osync_context_report_success(ctx);268 return true;269 } 262 if ( !__vcard_access(ctx, chg) ) 263 return false; 264 265 osync_hashtable_update_hash(hashtable, chg); 266 osync_context_report_success(ctx); 267 return true; 268 } -
plugins/kdepim/src/kaddrbook.h
r672 r1620 1 /*********************************************************************** 1 /*********************************************************************** 2 2 MultiSync Plugin for KDE 3.x 3 3 Copyright (C) 2004 Stewart Heitmann <sheitmann@users.sourceforge.net> 4 4 5 5 This program is free software; you can redistribute it and/or modify 6 6 it under the terms of the GNU General Public License version 2 as 7 7 published by the Free Software Foundation; 8 8 9 9 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 10 10 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, … … 15 15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 17 18 18 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 19 19 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS … … 30 30 #include "osyncbase.h" 31 31 32 class KContactDataSource { 33 private: 32 class KContactDataSource 33 { 34 private: 34 35 KABC::AddressBook* addressbookptr; 35 36 36 OSyncHashTable *hashtable;37 OSyncMember *member;37 OSyncHashTable *hashtable; 38 OSyncMember *member; 38 39 39 bool __vcard_access(OSyncContext *ctx, OSyncChange *chg);40 bool __vcard_access(OSyncContext *ctx, OSyncChange *chg); 40 41 41 public:42 KContactDataSource(OSyncMember *member, OSyncHashTable *hashtable);42 public: 43 KContactDataSource(OSyncMember *member, OSyncHashTable *hashtable); 43 44 44 45 QString calc_hash(KABC::Addressee &e); 45 bool connect(OSyncContext *ctx);46 bool disconnect(OSyncContext *ctx);47 bool contact_get_changeinfo(OSyncContext *ctx);48 bool vcard_access(OSyncContext *ctx, OSyncChange *chg);49 bool vcard_commit_change(OSyncContext *ctx, OSyncChange *chg);46 bool connect(OSyncContext *ctx); 47 bool disconnect(OSyncContext *ctx); 48 bool contact_get_changeinfo(OSyncContext *ctx); 49 bool vcard_access(OSyncContext *ctx, OSyncChange *chg); 50 bool vcard_commit_change(OSyncContext *ctx, OSyncChange *chg); 50 51 bool connected; 51 52 }; -
plugins/kdepim/src/kcal.cpp
r1617 r1620 1 /*********************************************************************** 1 /*********************************************************************** 2 2 KCalendar support for OpenSync kdepim-sync plugin 3 3 Copyright (C) 2004 Conectiva S. A. 4 4 5 5 This program is free software; you can redistribute it and/or modify 6 6 it under the terms of the GNU General Public License version 2 as 7 7 published by the Free Software Foundation; 8 8 9 9 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 10 10 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, … … 15 15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 17 18 18 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 19 19 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS … … 30 30 31 31 KCalDataSource::KCalDataSource(OSyncMember *member, OSyncHashTable *hashtable) 32 : hashtable(hashtable), member(member)32 : hashtable(hashtable), member(member) 33 33 { 34 34 connected = false; … … 55 55 } 56 56 57 calendar = new KCal::CalendarResources(QString::fromLatin1( "UTC" ));58 if (!calendar) {59 osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "Can't open KDE calendar");60 return false;61 }57 calendar = new KCal::CalendarResources(QString::fromLatin1( "UTC" )); 58 if (!calendar) { 59 osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "Can't open KDE calendar"); 60 return false; 61 } 62 62 #if KDE_IS_VERSION(3,3,0) 63 /* On KDE 3.2, there was no readConfig() and load(): the data64 * was loaded automatically on the CalendarResources() constructor65 */66 calendar->readConfig();67 calendar->load();63 /* On KDE 3.2, there was no readConfig() and load(): the data 64 * was loaded automatically on the CalendarResources() constructor 65 */ 66 calendar->readConfig(); 67 calendar->load(); 68 68 #endif 69 osync_debug("kcal", 3, "Calendar: %d events", calendar->events().size());70 69 osync_debug("kcal", 3, "Calendar: %d events", calendar->events().size()); 70 71 71 connected = true; 72 72 return true; … … 75 75 bool KCalDataSource::disconnect(OSyncContext *) 76 76 { 77 78
