2005-11-05 23:04:33 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2005 Patrick Ohly
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "EvolutionSyncSource.h"
|
|
|
|
#include "EvolutionSmartPtr.h"
|
|
|
|
|
|
|
|
#include <libebook/e-book.h>
|
|
|
|
#include <libebook/e-vcard.h>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements access to Evolution address books.
|
|
|
|
*/
|
|
|
|
class EvolutionContactSource : public EvolutionSyncSource
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Creates a new Evolution address book source.
|
2005-11-26 22:16:03 +01:00
|
|
|
*
|
2005-11-05 23:04:33 +01:00
|
|
|
* @param changeId is used to track changes in the Evolution backend;
|
|
|
|
* not specifying it implies that always all items are returned
|
|
|
|
* @param id identifies the backend; not specifying it makes this instance
|
|
|
|
* unusable for anything but listing backend databases
|
|
|
|
*/
|
|
|
|
EvolutionContactSource( const string &name,
|
|
|
|
const string &changeId = string(""),
|
|
|
|
const string &id = string(""),
|
2005-11-26 22:16:03 +01:00
|
|
|
EVCardFormat vcardFormat = EVC_FORMAT_VCARD_30 );
|
2005-11-05 23:04:33 +01:00
|
|
|
virtual ~EvolutionContactSource();
|
|
|
|
|
|
|
|
//
|
|
|
|
// implementation of EvolutionSyncSource
|
|
|
|
//
|
|
|
|
virtual sources getSyncBackends();
|
|
|
|
virtual void open();
|
|
|
|
virtual void close();
|
2005-11-25 21:53:04 +01:00
|
|
|
virtual SyncItem *createItem( const string &uid, SyncState state );
|
2005-11-05 23:04:33 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// implementation of SyncSource
|
|
|
|
//
|
|
|
|
virtual int addItem(SyncItem& item);
|
|
|
|
virtual int updateItem(SyncItem& item);
|
|
|
|
virtual int deleteItem(SyncItem& item);
|
2005-11-26 22:16:03 +01:00
|
|
|
virtual int beginSync();
|
|
|
|
virtual int endSync();
|
|
|
|
|
2005-11-05 23:04:33 +01:00
|
|
|
private:
|
|
|
|
/** valid after open(): the address book that this source references */
|
|
|
|
gptr<EBook, GObject> m_addressbook;
|
|
|
|
|
|
|
|
/** the format of vcards that new items are expected to have */
|
|
|
|
const EVCardFormat m_vcardFormat;
|
|
|
|
|
|
|
|
/** the mime type which corresponds to m_vcardFormat */
|
|
|
|
const char *getMimeType();
|
2005-11-26 22:16:03 +01:00
|
|
|
|
|
|
|
/** internal implementation of endSync() which will throw an exception in case of failure */
|
|
|
|
void endSyncThrow();
|
2005-12-03 15:35:11 +01:00
|
|
|
|
|
|
|
/** log a one-line info about a contact */
|
|
|
|
void logItem( const string &uid, const string &info );
|
|
|
|
void logItem( SyncItem &item, const string &info );
|
|
|
|
|
2005-11-05 23:04:33 +01:00
|
|
|
};
|