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
|
|
|
|
*/
|
2005-10-08 14:03:24 +02:00
|
|
|
|
2006-04-06 19:02:43 +02:00
|
|
|
#include <config.h>
|
|
|
|
|
2005-11-05 23:04:33 +01:00
|
|
|
#include <base/Log.h>
|
2005-11-25 21:53:04 +01:00
|
|
|
#include <posix/base/posixlog.h>
|
2005-11-05 23:04:33 +01:00
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
using namespace std;
|
|
|
|
|
2006-03-19 22:37:30 +01:00
|
|
|
#include <libgen.h>
|
|
|
|
|
2005-11-05 23:04:33 +01:00
|
|
|
#include "EvolutionContactSource.h"
|
2006-04-09 13:48:11 +02:00
|
|
|
#include "EvolutionCalendarSource.h"
|
2005-11-26 22:16:03 +01:00
|
|
|
#include "EvolutionSyncClient.h"
|
2005-11-05 23:04:33 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* list all known data sources of a certain type
|
|
|
|
*/
|
|
|
|
static void listSources( EvolutionSyncSource &syncSource, const string &header )
|
|
|
|
{
|
|
|
|
cout << header << ":\n";
|
|
|
|
EvolutionSyncSource::sources sources = syncSource.getSyncBackends();
|
|
|
|
|
|
|
|
for( EvolutionSyncSource::sources::const_iterator it = sources.begin();
|
|
|
|
it != sources.end();
|
|
|
|
it++ ) {
|
2006-06-27 18:26:28 +02:00
|
|
|
cout << it->m_name << " (" << it->m_uri << ")\n";
|
2005-11-05 23:04:33 +01:00
|
|
|
}
|
|
|
|
}
|
2005-10-08 14:03:24 +02:00
|
|
|
|
|
|
|
int main( int argc, char **argv )
|
|
|
|
{
|
2005-11-05 23:04:33 +01:00
|
|
|
setLogFile("-");
|
|
|
|
LOG.reset();
|
2006-03-19 22:37:30 +01:00
|
|
|
LOG.setLevel(LOG_LEVEL_INFO);
|
2005-11-05 23:04:33 +01:00
|
|
|
resetError();
|
|
|
|
|
2006-03-19 22:37:30 +01:00
|
|
|
// Expand PATH to cover the directory we were started from?
|
|
|
|
// This might be needed to find normalize_vcard.
|
|
|
|
char *exe = strdup(argv[0]);
|
|
|
|
if (strchr(exe, '/') ) {
|
|
|
|
char *dir = dirname(exe);
|
|
|
|
string path;
|
|
|
|
char *oldpath = getenv("PATH");
|
|
|
|
if (oldpath) {
|
|
|
|
path += oldpath;
|
|
|
|
path += ":";
|
|
|
|
}
|
|
|
|
path += dir;
|
|
|
|
setenv("PATH", path.c_str(), 1);
|
|
|
|
}
|
|
|
|
free(exe);
|
|
|
|
|
2005-11-05 23:04:33 +01:00
|
|
|
try {
|
2006-04-09 13:48:11 +02:00
|
|
|
if ( argc == 1 ) {
|
2006-07-23 12:27:21 +02:00
|
|
|
#ifdef ENABLE_EBOOK
|
2005-11-05 23:04:33 +01:00
|
|
|
EvolutionContactSource contactSource( string( "list" ) );
|
|
|
|
listSources( contactSource, "address books" );
|
2006-06-12 22:59:27 +02:00
|
|
|
cout << "\n";
|
2006-07-23 12:27:21 +02:00
|
|
|
#endif
|
2005-11-05 23:04:33 +01:00
|
|
|
|
2006-07-23 12:27:21 +02:00
|
|
|
#ifdef ENABLE_ECAL
|
2006-04-09 13:48:11 +02:00
|
|
|
EvolutionCalendarSource eventSource(E_CAL_SOURCE_TYPE_EVENT,
|
|
|
|
string("list"));
|
|
|
|
listSources(eventSource, "calendars");
|
2006-06-12 22:59:27 +02:00
|
|
|
cout << "\n";
|
2006-04-09 13:48:11 +02:00
|
|
|
|
|
|
|
EvolutionCalendarSource todoSource(E_CAL_SOURCE_TYPE_TODO,
|
|
|
|
string("list"));
|
2006-06-27 18:26:28 +02:00
|
|
|
listSources(todoSource, "tasks");
|
2006-07-23 12:27:21 +02:00
|
|
|
#endif
|
2006-04-09 13:48:11 +02:00
|
|
|
|
2006-03-19 22:37:30 +01:00
|
|
|
fprintf( stderr, "\nusage: %s <server>\n", argv[0] );
|
2005-11-26 22:16:03 +01:00
|
|
|
} else {
|
2006-04-09 13:48:11 +02:00
|
|
|
set<string> sources;
|
|
|
|
|
|
|
|
for (int source = 2; source < argc; source++ ) {
|
|
|
|
sources.insert(argv[source]);
|
|
|
|
}
|
|
|
|
|
|
|
|
EvolutionSyncClient client(argv[1], sources);
|
2006-03-19 22:37:30 +01:00
|
|
|
client.sync(SYNC_NONE, true);
|
2005-11-05 23:04:33 +01:00
|
|
|
}
|
2005-11-26 22:16:03 +01:00
|
|
|
return 0;
|
2006-06-06 00:27:21 +02:00
|
|
|
} catch ( const std::exception &ex ) {
|
2006-05-26 14:49:19 +02:00
|
|
|
LOG.error( ex.what() );
|
2005-11-05 23:04:33 +01:00
|
|
|
} catch (...) {
|
|
|
|
LOG.error( "unknown error" );
|
|
|
|
}
|
|
|
|
|
2005-11-26 22:16:03 +01:00
|
|
|
return 1;
|
2005-10-08 14:03:24 +02:00
|
|
|
}
|