adapted to Sync4j C++ client API 3.x
git-svn-id: https://zeitsenke.de/svn/SyncEvolution/trunk@5 15ad00c4-1369-45f4-8270-35d70d36bdcd
This commit is contained in:
parent
29ae19e174
commit
3a81621f3e
8 changed files with 48 additions and 34 deletions
3
INSTALL
3
INSTALL
|
@ -1,7 +1,8 @@
|
||||||
Basic Installation
|
Basic Installation
|
||||||
==================
|
==================
|
||||||
|
|
||||||
These are generic installation instructions.
|
These are generic installation instructions. Specific installation
|
||||||
|
instructions for Sync4jEvolution are in the README file.
|
||||||
|
|
||||||
The `configure' shell script attempts to guess correct values for
|
The `configure' shell script attempts to guess correct values for
|
||||||
various system-dependent variables used during compilation. It uses
|
various system-dependent variables used during compilation. It uses
|
||||||
|
|
14
README
14
README
|
@ -138,3 +138,17 @@ If the Evolution data source requires authentication, the
|
||||||
"evolutionuser" and "evolutionpassword" are used as credentials. In
|
"evolutionuser" and "evolutionpassword" are used as credentials. In
|
||||||
this case the directory that contains the source's config.txt should
|
this case the directory that contains the source's config.txt should
|
||||||
only be accessible by the user.
|
only be accessible by the user.
|
||||||
|
|
||||||
|
Compiling from Source
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
To compile the code the 3.x version of the Sync4j C++
|
||||||
|
client library is needed. Also needed are the Evolution
|
||||||
|
development files. The code was tested with Evolution
|
||||||
|
2.0.4 and it is unclear which other versions it is
|
||||||
|
compatible with.
|
||||||
|
|
||||||
|
The build system is the normal autotools system.
|
||||||
|
See INSTALL for general instructions how to use that
|
||||||
|
and "./configure --help" for Sync4jEvolution specific
|
||||||
|
options.
|
||||||
|
|
2
configure
vendored
2
configure
vendored
|
@ -1921,7 +1921,7 @@ INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s"
|
||||||
# Check whether --with-sync4j or --without-sync4j was given.
|
# Check whether --with-sync4j or --without-sync4j was given.
|
||||||
if test "${with_sync4j+set}" = set; then
|
if test "${with_sync4j+set}" = set; then
|
||||||
withval="$with_sync4j"
|
withval="$with_sync4j"
|
||||||
SYNC4J_CFLAGS="-I$withval/include/sync4j"; SYNC4J_LIBS="-L$withval/lib"
|
SYNC4J_CFLAGS="-I$withval/include/sync4j/common -I$withval/include/sync4j"; SYNC4J_LIBS="-L$withval/lib"
|
||||||
fi;
|
fi;
|
||||||
SYNC4J_LIBS="${SYNC4J_LIBS} -lsync4j"
|
SYNC4J_LIBS="${SYNC4J_LIBS} -lsync4j"
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ AM_CONFIG_HEADER(config.h)
|
||||||
AC_ARG_WITH(sync4j,
|
AC_ARG_WITH(sync4j,
|
||||||
AS_HELP_STRING([--with-sync4j=<base directory>],
|
AS_HELP_STRING([--with-sync4j=<base directory>],
|
||||||
[specifies location of Sync4j client library]),
|
[specifies location of Sync4j client library]),
|
||||||
[SYNC4J_CFLAGS="-I$withval/include/sync4j"; SYNC4J_LIBS="-L$withval/lib"])
|
[SYNC4J_CFLAGS="-I$withval/include/sync4j/common -I$withval/include/sync4j"; SYNC4J_LIBS="-L$withval/lib"])
|
||||||
SYNC4J_LIBS="${SYNC4J_LIBS} -lsync4j"
|
SYNC4J_LIBS="${SYNC4J_LIBS} -lsync4j"
|
||||||
AC_SUBST(SYNC4J_CFLAGS)
|
AC_SUBST(SYNC4J_CFLAGS)
|
||||||
AC_SUBST(SYNC4J_LIBS)
|
AC_SUBST(SYNC4J_LIBS)
|
||||||
|
|
|
@ -139,7 +139,7 @@ void EvolutionContactSource::close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SyncItem *EvolutionContactSource::createItem( const string &uid )
|
SyncItem *EvolutionContactSource::createItem( const string &uid, SyncState state )
|
||||||
{
|
{
|
||||||
// this function must never throw an exception
|
// this function must never throw an exception
|
||||||
// because it is called inside the Sync4j C++ API library
|
// because it is called inside the Sync4j C++ API library
|
||||||
|
@ -162,8 +162,10 @@ SyncItem *EvolutionContactSource::createItem( const string &uid )
|
||||||
}
|
}
|
||||||
|
|
||||||
auto_ptr<SyncItem> item( new SyncItem( uid.c_str() ) );
|
auto_ptr<SyncItem> item( new SyncItem( uid.c_str() ) );
|
||||||
item->setData( vcardstr, strlen( vcardstr ) + 1 );
|
item->setData( vcardstr, strlen( vcardstr ) );
|
||||||
item->setDataType( getMimeType() );
|
item->setDataType( getMimeType() );
|
||||||
|
item->setModificationTime( 0 );
|
||||||
|
item->setState( state );
|
||||||
|
|
||||||
return item.release();
|
return item.release();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
@ -173,14 +175,11 @@ SyncItem *EvolutionContactSource::createItem( const string &uid )
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EvolutionContactSource::setSyncItemStatus(char *key, int status)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int EvolutionContactSource::addItem(SyncItem& item)
|
int EvolutionContactSource::addItem(SyncItem& item)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
gptr<EContact, GObject> contact( e_contact_new_from_vcard( (const char *)item.getData() ) );
|
string data = getData(item);
|
||||||
|
gptr<EContact, GObject> contact(e_contact_new_from_vcard(data.c_str()));
|
||||||
if( contact ) {
|
if( contact ) {
|
||||||
GError *gerror = NULL;
|
GError *gerror = NULL;
|
||||||
e_contact_set(contact, E_CONTACT_UID, NULL);
|
e_contact_set(contact, E_CONTACT_UID, NULL);
|
||||||
|
@ -190,7 +189,7 @@ int EvolutionContactSource::addItem(SyncItem& item)
|
||||||
throwError( "storing new contact", gerror );
|
throwError( "storing new contact", gerror );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throwError( string( "parsing vcard" ) + (const char *)item.getData(),
|
throwError( string( "parsing vcard" ) + data,
|
||||||
NULL );
|
NULL );
|
||||||
}
|
}
|
||||||
} catch ( ... ) {
|
} catch ( ... ) {
|
||||||
|
@ -202,20 +201,21 @@ int EvolutionContactSource::addItem(SyncItem& item)
|
||||||
int EvolutionContactSource::updateItem(SyncItem& item)
|
int EvolutionContactSource::updateItem(SyncItem& item)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
gptr<EContact, GObject> contact( e_contact_new_from_vcard( (const char *)item.getData() ) );
|
string data = getData(item);
|
||||||
|
gptr<EContact, GObject> contact(e_contact_new_from_vcard(data.c_str()));
|
||||||
if( contact ) {
|
if( contact ) {
|
||||||
GError *gerror = NULL;
|
GError *gerror = NULL;
|
||||||
e_contact_set( contact, E_CONTACT_UID, item.getKey( NULL ) );
|
e_contact_set( contact, E_CONTACT_UID, item.getKey() );
|
||||||
if ( e_book_commit_contact(m_addressbook, contact, &gerror) ) {
|
if ( e_book_commit_contact(m_addressbook, contact, &gerror) ) {
|
||||||
const char *uid = (const char *)e_contact_get_const(contact, E_CONTACT_UID);
|
const char *uid = (const char *)e_contact_get_const(contact, E_CONTACT_UID);
|
||||||
if (uid) {
|
if (uid) {
|
||||||
item.setKey( uid );
|
item.setKey( uid );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throwError( string( "updating contact" ) + item.getKey( NULL ), gerror );
|
throwError( string( "updating contact" ) + item.getKey(), gerror );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throwError( string( "parsing vcard" ) + (const char *)item.getData(),
|
throwError( string( "parsing vcard" ) + data,
|
||||||
NULL );
|
NULL );
|
||||||
}
|
}
|
||||||
} catch ( ... ) {
|
} catch ( ... ) {
|
||||||
|
@ -228,8 +228,8 @@ int EvolutionContactSource::deleteItem(SyncItem& item)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
GError *gerror = NULL;
|
GError *gerror = NULL;
|
||||||
if (!e_book_remove_contact( m_addressbook, item.getKey( NULL ), &gerror ) ) {
|
if (!e_book_remove_contact( m_addressbook, item.getKey(), &gerror ) ) {
|
||||||
throwError( string( "deleting contact" ) + item.getKey( NULL ),
|
throwError( string( "deleting contact" ) + item.getKey(),
|
||||||
gerror );
|
gerror );
|
||||||
}
|
}
|
||||||
} catch( ... ) {
|
} catch( ... ) {
|
||||||
|
|
|
@ -48,12 +48,11 @@ class EvolutionContactSource : public EvolutionSyncSource
|
||||||
virtual sources getSyncBackends();
|
virtual sources getSyncBackends();
|
||||||
virtual void open();
|
virtual void open();
|
||||||
virtual void close();
|
virtual void close();
|
||||||
virtual SyncItem *createItem( const string &uid );
|
virtual SyncItem *createItem( const string &uid, SyncState state );
|
||||||
|
|
||||||
//
|
//
|
||||||
// implementation of SyncSource
|
// implementation of SyncSource
|
||||||
//
|
//
|
||||||
virtual void setSyncItemStatus(char *key, int status);
|
|
||||||
virtual int addItem(SyncItem& item);
|
virtual int addItem(SyncItem& item);
|
||||||
virtual int updateItem(SyncItem& item);
|
virtual int updateItem(SyncItem& item);
|
||||||
virtual int deleteItem(SyncItem& item);
|
virtual int deleteItem(SyncItem& item);
|
||||||
|
|
|
@ -182,8 +182,8 @@ void TestEvolution::testContactSimpleInsert()
|
||||||
SyncItem item;
|
SyncItem item;
|
||||||
item.setData( vcard, strlen(vcard) + 1 );
|
item.setData( vcard, strlen(vcard) + 1 );
|
||||||
EVOLUTION_ASSERT_NO_THROW( source, source.addItem( item ) );
|
EVOLUTION_ASSERT_NO_THROW( source, source.addItem( item ) );
|
||||||
CPPUNIT_ASSERT( item.getKey( NULL ) != NULL );
|
CPPUNIT_ASSERT( item.getKey() != NULL );
|
||||||
CPPUNIT_ASSERT( strlen( item.getKey( NULL ) ) > 0 );
|
CPPUNIT_ASSERT( strlen( item.getKey() ) > 0 );
|
||||||
|
|
||||||
EVOLUTION_ASSERT_NO_THROW( source, source.close() );
|
EVOLUTION_ASSERT_NO_THROW( source, source.close() );
|
||||||
EVOLUTION_ASSERT_NO_THROW( source, source.open() );
|
EVOLUTION_ASSERT_NO_THROW( source, source.open() );
|
||||||
|
@ -194,9 +194,9 @@ void TestEvolution::testContactSimpleInsert()
|
||||||
SyncItem *sameItem;
|
SyncItem *sameItem;
|
||||||
EVOLUTION_ASSERT_NO_THROW(
|
EVOLUTION_ASSERT_NO_THROW(
|
||||||
source,
|
source,
|
||||||
sameItem = source.createItem( item.getKey( NULL ) ) );
|
sameItem = source.createItem( item.getKey(), item.getState() ) );
|
||||||
CPPUNIT_ASSERT( sameItem != NULL );
|
CPPUNIT_ASSERT( sameItem != NULL );
|
||||||
CPPUNIT_ASSERT( !strcmp( sameItem->getKey( NULL ), item.getKey( NULL ) ) );
|
CPPUNIT_ASSERT( !strcmp( sameItem->getKey(), item.getKey() ) );
|
||||||
delete sameItem;
|
delete sameItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,8 +294,8 @@ void TestEvolution::contactUpdate()
|
||||||
CPPUNIT_ASSERT( countDeletedItems( source ) == 0 );
|
CPPUNIT_ASSERT( countDeletedItems( source ) == 0 );
|
||||||
SyncItem *modifiedItem;
|
SyncItem *modifiedItem;
|
||||||
EVOLUTION_ASSERT_NO_THROW( source, modifiedItem = source.getFirstItem() );
|
EVOLUTION_ASSERT_NO_THROW( source, modifiedItem = source.getFirstItem() );
|
||||||
CPPUNIT_ASSERT( strlen( item->getKey( NULL ) ) );
|
CPPUNIT_ASSERT( strlen( item->getKey() ) );
|
||||||
CPPUNIT_ASSERT( !strcmp( item->getKey( NULL ), modifiedItem->getKey( NULL ) ) );
|
CPPUNIT_ASSERT( !strcmp( item->getKey(), modifiedItem->getKey() ) );
|
||||||
|
|
||||||
delete item;
|
delete item;
|
||||||
delete modifiedItem;
|
delete modifiedItem;
|
||||||
|
@ -341,9 +341,9 @@ void TestEvolution::testContactChanges()
|
||||||
CPPUNIT_ASSERT( countDeletedItems( source ) == 1 );
|
CPPUNIT_ASSERT( countDeletedItems( source ) == 1 );
|
||||||
SyncItem *deletedItem;
|
SyncItem *deletedItem;
|
||||||
EVOLUTION_ASSERT_NO_THROW( source, deletedItem = source.getFirstDeletedItem() );
|
EVOLUTION_ASSERT_NO_THROW( source, deletedItem = source.getFirstDeletedItem() );
|
||||||
CPPUNIT_ASSERT( strlen( item->getKey( NULL ) ) );
|
CPPUNIT_ASSERT( strlen( item->getKey() ) );
|
||||||
CPPUNIT_ASSERT( strlen( deletedItem->getKey( NULL ) ) );
|
CPPUNIT_ASSERT( strlen( deletedItem->getKey() ) );
|
||||||
CPPUNIT_ASSERT( !strcmp( item->getKey( NULL ), deletedItem->getKey( NULL ) ) );
|
CPPUNIT_ASSERT( !strcmp( item->getKey(), deletedItem->getKey() ) );
|
||||||
EVOLUTION_ASSERT_NO_THROW( source, source.close() );
|
EVOLUTION_ASSERT_NO_THROW( source, source.close() );
|
||||||
|
|
||||||
delete item;
|
delete item;
|
||||||
|
@ -359,9 +359,9 @@ void TestEvolution::testContactChanges()
|
||||||
EVOLUTION_ASSERT_NO_THROW( source, item = source.getFirstItem() );
|
EVOLUTION_ASSERT_NO_THROW( source, item = source.getFirstItem() );
|
||||||
SyncItem *newItem;
|
SyncItem *newItem;
|
||||||
EVOLUTION_ASSERT_NO_THROW( source, newItem = source.getFirstNewItem() );
|
EVOLUTION_ASSERT_NO_THROW( source, newItem = source.getFirstNewItem() );
|
||||||
CPPUNIT_ASSERT( strlen( item->getKey( NULL ) ) );
|
CPPUNIT_ASSERT( strlen( item->getKey() ) );
|
||||||
CPPUNIT_ASSERT( strlen( newItem->getKey( NULL ) ) );
|
CPPUNIT_ASSERT( strlen( newItem->getKey() ) );
|
||||||
CPPUNIT_ASSERT( !strcmp( item->getKey( NULL ), newItem->getKey( NULL ) ) );
|
CPPUNIT_ASSERT( !strcmp( item->getKey(), newItem->getKey() ) );
|
||||||
EVOLUTION_ASSERT_NO_THROW( source, source.close() );
|
EVOLUTION_ASSERT_NO_THROW( source, source.close() );
|
||||||
|
|
||||||
delete newItem;
|
delete newItem;
|
||||||
|
@ -375,7 +375,7 @@ void TestEvolution::testContactChanges()
|
||||||
CPPUNIT_ASSERT( countDeletedItems( source ) == 0 );
|
CPPUNIT_ASSERT( countDeletedItems( source ) == 0 );
|
||||||
SyncItem *updatedItem;
|
SyncItem *updatedItem;
|
||||||
EVOLUTION_ASSERT_NO_THROW( source, updatedItem = source.getFirstUpdatedItem() );
|
EVOLUTION_ASSERT_NO_THROW( source, updatedItem = source.getFirstUpdatedItem() );
|
||||||
CPPUNIT_ASSERT( !strcmp( item->getKey( NULL ), updatedItem->getKey( NULL ) ) );
|
CPPUNIT_ASSERT( !strcmp( item->getKey(), updatedItem->getKey() ) );
|
||||||
|
|
||||||
delete item;
|
delete item;
|
||||||
delete updatedItem;
|
delete updatedItem;
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <base/Log.h>
|
#include <base/Log.h>
|
||||||
#include <base/autotools/Log.h>
|
#include <posix/base/posixlog.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
Loading…
Reference in a new issue