diff options
23 files changed, 4 insertions, 1421 deletions
@@ -59,9 +59,6 @@ Makefile.in # src/backends /src/backends/backends.am -# src/backends/buteo -/src/backends/buteo/autotroll.mk - # src/backends/webdav /src/backends/webdav/syncevo-webdav-lookup diff --git a/AUTOTOOLS-TESTING b/AUTOTOOLS-TESTING index 49fb6532..0697bfa8 100644 --- a/AUTOTOOLS-TESTING +++ b/AUTOTOOLS-TESTING @@ -6,8 +6,6 @@ Untested: --enable-kcalextended --enable-qtcontacts (see TODO) --enable-kwallet - --enable-buteo-tests - --enable-buteo --enable-maemocal ... probably more. - make -j and make -jX where X>2, because gcc is being killed by oom-killer). diff --git a/AUTOTOOLS-TODO b/AUTOTOOLS-TODO index 29d01ee4..819c0bec 100644 --- a/AUTOTOOLS-TODO +++ b/AUTOTOOLS-TODO @@ -83,10 +83,6 @@ NITPICKS: and test-client always relinked. -- Check if /etc/sync and /lib/sync really have to be created, even if they are - going to be empty after install (this is probably some buteo stuff). - - - Maybe do not create /share/man/man1 directory if we do not put there anything. @@ -366,30 +366,3 @@ crash scenarios the final error messages may get lost. To debug such cases, disable redirection by setting the environment variable SYNCEVOLUTION_DEBUG (value doesn't matter) and capture the output normally. - -Testing Buteo ---------- - -SyncEvolution enables Buteo testing based client-test. Configure with ---enable-integration-tests and --enable-buteo-tests and then run -"src/client-test" to test Buteo with the above described environment -variables. The only difference is that you have to set a new one -"CLIENT_TEST_BUTEO=1". Buteo testing supports testing two kinds of -data: qt_contact and kcal_event. - -Here are step-by-step instructions to get started with Buteo testing, -also using ScheduleWorld as example: -- CLIENT_TEST_SERVER=scheduleworld \ - CLIENT_TEST_EVOLUTION_PREFIX=file:///tmp/testing/ \ - ./client-test -h - => creates ~/.config/syncevolution/scheduleworld_[12]/ configs - which use data bases under /tmp/testing, then - prints all available tests -- create Buteo sync profile file ~/.sync/profiles/sync/scheduleworld.xml - and edit and enter account data for ScheduleWorld. -- chmod -R 666 /etc/sync - => change the access mode of the directory /etc/sync -- CLIENT_TEST_SERVER=scheduleworld \ - CLIENT_TEST_EVOLUTION_PREFIX=file:///tmp/testing/ \ - ./client-test Client::Sync::qt_contact - => runs all tests for qt_contact diff --git a/configure.ac b/configure.ac index 79035f72..873638a5 100644 --- a/configure.ac +++ b/configure.ac @@ -129,17 +129,6 @@ AC_ARG_ENABLE(integration-tests, [enables tests outside of the library (can be used together with normal builds of the library)]), enable_integration_tests="$enableval", enable_integration_tests="no") -AC_ARG_ENABLE(buteo-tests, - AS_HELP_STRING([--enable-buteo-tests], - [enables tests for Buteo sync framework. Not enabled when neither '--enable-unit-tests' nor '--enable-integration-tests' is specified]), - [ if test "$enable_unit_tests" = "yes" || test "$enable_integration_tests" = "yes" ; then - enable_buteo_tests="$enableval" - else - enable_buteo_tests="no" - fi], enable_buteo_tests="no") -PKG_CHECK_MODULES(BUTEOSYNCPROFILE, [syncprofile], HAVE_SYNCPROFILE=yes, HAVE_SYNCPROFILE=no) -PKG_CHECK_MODULES(BUTEOSYNCCOMMON, [synccommon], HAVE_SYNCCOMMON=yes, HAVE_SYNCCOMMON=no) - AC_ARG_ENABLE(static-cxx, AS_HELP_STRING([--enable-static-cxx], [build executables which contain libstdc++ instead of requiring suitable libstdc++.so to run]), @@ -188,17 +177,8 @@ fi if test "x$enable_integration_tests" = 'xyes'; then AC_DEFINE(ENABLE_INTEGRATION_TESTS, 1, [enable integration tests inside the final library]) fi -if test "$enable_buteo_tests" = "yes"; then - AC_DEFINE(ENABLE_BUTEO_TESTS, 1, [enable buteo tests]) - need_qt_modules="$need_qt_modules dbus xml" - AC_PATH_PROG(SQLITE3, sqlite3) - if test -z "$SQLITE3"; then - AC_MSG_ERROR([sqlite3 not found, is required for buteo testing]) - fi -fi AM_CONDITIONAL([ENABLE_UNIT_TESTS], [test "$enable_unit_tests" = "yes"]) AM_CONDITIONAL([ENABLE_TESTING], [test "$enable_unit_tests" = "yes" || test "$enable_integration_tests" = "yes" ]) -AM_CONDITIONAL([ENABLE_BUTEO_TESTS], [test "$enable_buteo_tests" = "yes"]) if test $enable_static_cxx = "yes"; then LIBS="$LIBS -L." @@ -545,10 +525,6 @@ AC_SUBST(DBUS_GLIB_LIBS) AC_SUBST(LIBNOTIFY_CFLAGS) AC_SUBST(LIBNOTIFY_LIBS) AC_SUBST(LIBEXECDIR) -AC_SUBST(BUTEOSYNCPROFILE_LIBS) -AC_SUBST(BUTEOSYNCPROFILE_CFLAGS) -AC_SUBST(BUTEOSYNCCOMMON_LIBS) -AC_SUBST(BUTEOSYNCCOMMON_CFLAGS) DBUS_SERVICES_DIR="${datadir}/dbus-1/services" AC_SUBST(DBUS_SERVICES_DIR) diff --git a/src/backends/buteo/ButeoBridge.cpp b/src/backends/buteo/ButeoBridge.cpp deleted file mode 100644 index 952a56c6..00000000 --- a/src/backends/buteo/ButeoBridge.cpp +++ /dev/null @@ -1,277 +0,0 @@ -/* - * Copyright (C) 2010 Intel Corporation - */ - -#include "ButeoBridge.h" -#ifdef ENABLE_UNIT_TESTS -#include "test.h" -#endif -#include <syncevo/util.h> -#include <syncevo/Cmdline.h> -#include <syncevo/Logging.h> - -#include <QDebug> - -#include <stddef.h> -#include <sys/socket.h> -#include <sys/types.h> -#include <sys/wait.h> -#include <iostream> - -#include <libsyncprofile/SyncResults.h> -#include <syncevo/SyncSource.h> - -SE_BEGIN_CXX - -// this ensures that backends are initialized once inside the -// Buteo bridge -static std::string backends = SyncSource::backendsInfo(); - -ButeoBridge::ButeoBridge(const QString &pluginName, - const Buteo::SyncProfile &profile, - Buteo::PluginCbInterface *cbInterface) : - ClientPlugin(pluginName, profile, cbInterface) -{ -} - -bool ButeoBridge::startSync() -{ - std::string username = iProfile.key("Username", "no username set").toUtf8().data(); - std::string password = iProfile.key("Password", "no password set").toUtf8().data(); - - std::string explanation("internal error"); - try { - if (m_config.empty()) { - SE_THROW("init() not called"); - } - - std::vector<const char *> sources; - int count = 0; - sources.resize(4, NULL); - QList<const Buteo::Profile *> storages = iProfile.storageProfiles(); - BOOST_FOREACH(const Buteo::Profile *profile, storages) { - if (profile->isEnabled()) { - // translate between names in profile and names in SyncEvolution - if (profile->name() == "hcontacts") { - sources[count++] = "addressbook"; - } else if (profile->name() == "hcalendar") { - sources[count++] = "calendar"; - } - } - } - - // The Yahoo CardDAV and CalDAV config only works with full - // domain (needed for DNS SRV lookup). Add it if not present. - // If the resulting username is invalid, we'll get a - // credentials error, as desired. - if (m_config == "yahoo" && - username.find('@') == username.npos) { - username += "@yahoo.com"; - } - - // run sync with just the enabled sources - Cmdline sync(std::cout, std::cerr, - "buteo-sync", - "--run", - "--sync-property", StringPrintf("username=%s", username.c_str()).c_str(), - "--sync-property", StringPrintf("password=%s", password.c_str()).c_str(), - "--sync-property", "preventSlowSync=0", - m_config.c_str(), - sources[0], sources[1], sources[2], sources[3], - NULL); - bool res = sync.parse() && sync.run(); - - // analyze result - const SyncReport &report = sync.getReport(); - SyncMLStatus status = report.getStatus(); - std::string explanation = Status2String(status); - switch (status) { - case STATUS_OK: - case STATUS_HTTP_OK: - if (res) { - emit success(getProfileName(), "done"); - } else { - emit error(getProfileName(), "internal error", Buteo::SyncResults::INTERNAL_ERROR); - } - break; - case STATUS_UNAUTHORIZED: - case STATUS_FORBIDDEN: - emit error(getProfileName(), explanation.c_str(), Buteo::SyncResults::AUTHENTICATION_FAILURE); - break; - case STATUS_TRANSPORT_FAILURE: - emit error(getProfileName(), explanation.c_str(), Buteo::SyncResults::CONNECTION_ERROR); - break; - default: - emit error(getProfileName(), explanation.c_str(), Buteo::SyncResults::INTERNAL_ERROR); - break; - } - - // Client/Configuration errors 4xx - // INTERNAL_ERROR = 401, - // AUTHENTICATION_FAILURE, - // DATABASE_FAILURE, - - // Server/Network errors 5xx - // SUSPENDED = 501, - // ABORTED, - // CONNECTION_ERROR, - // INVALID_SYNCML_MESSAGE, - // UNSUPPORTED_SYNC_TYPE, - // UNSUPPORTED_STORAGE_TYPE, - //Upto here - - //Context Error Code - // LOW_BATTERY_POWER = 601, - // POWER_SAVING_MODE, - // OFFLINE_MODE, - // BACKUP_IN_PROGRESS, - // LOW_MEMORY - return true; - } catch (...) { - Exception::handle(explanation); - } - emit error(getProfileName(), explanation.c_str(), Buteo::SyncResults::INTERNAL_ERROR); - return false; -} - -bool ButeoBridge::init() -{ - try { - if (getenv("SYNCEVOLUTION_DEBUG")) { - LoggerBase::instance().setLevel(Logger::DEBUG); - } - - // determine parameters for configuration - std::string url; - std::vector<const char *> sources; - sources.resize(4, NULL); - QString profile = getProfileName(); - if (profile == "google-calendar") { - m_config = "google-calendar"; - url = "syncURL=https://www.google.com/calendar/dav/%u/user/?SyncEvolution=Google"; - sources[0] = "calendar"; - } else if (profile == "yahoo") { - m_config = "yahoo"; - url = "syncURL="; // depend on DNS SRV to find right host - // for CalDAV/CardDAV (which currently - // are different!) - sources[0] = "calendar"; - sources[1] = "addressbook"; - } else if (profile == "google-contacts") { - // configure SyncML - m_config = "google"; - Cmdline sync(std::cout, std::cerr, - "buteo-sync", - "--template", "Google", - "--sync-property", "printChanges=0", - "--sync-property", "dumpData=0", - m_config.c_str(), - NULL); - bool res = sync.parse() && sync.run(); - if (!res) { - SE_THROW("client configuration failed"); - } else { - return true; - } - } else { - return false; - } - - // configure local sync of calendar with CalDAV and/or CardDAV - std::string config = StringPrintf("target-config@%s", m_config.c_str()); - if (!SyncConfig(config).exists()) { - Cmdline target(std::cout, std::cerr, - "buteo-sync", - "--template", "SyncEvolution", - "--sync-property", url.c_str(), - "--sync-property", "printChanges=0", - "--sync-property", "dumpData=0", - "--source-property", "calendar/type=CalDAV", - "--source-property", "addressbook/type=CardDAV", - config.c_str(), - sources[0], sources[1], sources[2], sources[3], - NULL); - bool res = target.parse() && target.run(); - if (!res) { - SE_THROW("client configuration failed"); - } - } - if (!SyncConfig(m_config).exists()) { - Cmdline server(std::cout, std::cerr, - "buteo-sync", - "--template", "SyncEvolution", - "--sync-property", "peerIsClient=1", - "--sync-property", "printChanges=0", - "--sync-property", "dumpData=0", - "--sync-property", StringPrintf("syncURL=local://@%s", m_config.c_str()).c_str(), - m_config.c_str(), - sources[0], sources[1], sources[2], sources[3], - NULL); - bool res = server.parse() && server.run(); - if (!res) { - SE_THROW("server configuration failed"); - } - } - return true; - } catch (...) { - Exception::handle(); - } - return false; -} - -bool ButeoBridge::uninit() -{ - // nothing to do - return true; -} - -void ButeoBridge::connectivityStateChanged(Sync::ConnectivityType type, - bool state) -{ -} - -extern "C" ButeoBridge *createPlugin(const QString &pluginName, - const Buteo::SyncProfile &profile, - Buteo::PluginCbInterface *cbInterface) -{ - return new ButeoBridge(pluginName, profile, cbInterface); -} - -extern "C" void destroyPlugin(ButeoBridge *client) -{ - delete client; -} - -#ifdef ENABLE_UNIT_TESTS - -/** - * The library containing this test is not normally - * linked into client-test. To use the test, compile - * client-test manually without -Wl,-as-needed - * and add libsyncevo-buteo.so. - */ -class ButeoTest : public CppUnit::TestFixture { - CPPUNIT_TEST_SUITE(ButeoTest); - CPPUNIT_TEST(init); - CPPUNIT_TEST_SUITE_END(); - - std::string m_testDir; - -public: - ButeoTest() : - m_testDir("ButeoTest") - {} - - void init() { - ScopedEnvChange xdg("XDG_CONFIG_HOME", m_testDir); - Buteo::SyncProfile profile("google-calendar"); - ButeoBridge client("google-calendar", profile, NULL); - CPPUNIT_ASSERT(client.init()); - } -}; - -SYNCEVOLUTION_TEST_SUITE_REGISTRATION(ButeoTest); - -#endif // ENABLE_UNIT_TESTS - -SE_END_CXX diff --git a/src/backends/buteo/ButeoBridge.h b/src/backends/buteo/ButeoBridge.h deleted file mode 100644 index 4cfe6519..00000000 --- a/src/backends/buteo/ButeoBridge.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2010 Intel Corporation - */ - -#ifndef INCL_SYNCEVO_BUTEOBRIDGE -#define INCL_SYNCEVO_BUTEOBRIDGE - -#include <config.h> - -#include <libsyncpluginmgr/ClientPlugin.h> - -#include <syncevo/declarations.h> -namespace SyncEvo { - -class ButeoBridge : public Buteo::ClientPlugin -{ - Q_OBJECT; - - public: - ButeoBridge(const QString &pluginName, - const Buteo::SyncProfile &profile, - Buteo::PluginCbInterface *cbInterface); - - // implementation of ClientPlugin interface - virtual bool startSync(); - virtual bool init(); - virtual bool uninit(); - -public slots: - virtual void connectivityStateChanged(Sync::ConnectivityType type, - bool state); - - private: - /** config name to be used by sync, set in init() */ - std::string m_config; -}; - -extern "C" ButeoBridge *createPlugin(const QString &pluginName, - const Buteo::SyncProfile &profile, - Buteo::PluginCbInterface *cbInterface); -extern "C" void destroyPlugin(ButeoBridge *client); - -} // namespace SyncEvo - -#endif // INCL_SYNCEVO_BUTEOBRIDGE diff --git a/src/backends/buteo/README b/src/backends/buteo/README deleted file mode 100644 index 2ae4c6bd..00000000 --- a/src/backends/buteo/README +++ /dev/null @@ -1,18 +0,0 @@ -This pseudo-backend directory does not build a normal SyncEvolution -backend. Instead it just uses the autotools extension mechanism to -hook some source code into the SyncEvolution build and creates the -/usr/lib/sync/libsyncevo-buteo.so sync client plugin for Buteo. - - -It expose SyncEvolution's sync engine to Buteo. This must work without -prior manual configuration of SyncEvolution. - -The approach will be something like this: -* create and install libsyncevo-buteo.so sync client plugin -* define "Google Calendar" service using it -* configure it in sync UI -* during sync, create or update "google@default" local sync - config, with "target-config@google" for remote CalDAV access - -Because of the limited applicability of the plugin, hard-coding -specific services is okay. diff --git a/src/backends/buteo/buteo.am b/src/backends/buteo/buteo.am deleted file mode 100644 index 88c6967a..00000000 --- a/src/backends/buteo/buteo.am +++ /dev/null @@ -1,33 +0,0 @@ -# "test" only works when compiling as part of SyncEvolution -dist_noinst_DATA += \ - src/backends/buteo/configure-sub.in \ - src/backends/buteo/README - - -if ENABLE_BUTEO -include $(top_srcdir)/src/backends/buteo/profiles/profiles.am - -# directory required by Buteo for plugins -src_backends_buteo_syncdir = $(libdir)/sync -src_backends_buteo_sync_LTLIBRARIES = src/backends/buteo/libsyncevo-buteo-client.la - -src_backends_buteo_built_sources = src/backends/buteo/ButeoBridge.moc.cpp - -BUILT_SOURCES += $(src_backends_buteo_built_sources) - -src_backends_buteo_libsyncevo_buteo_client_la_SOURCES = \ - src/backends/buteo/ButeoBridge.h \ - src/backends/buteo/ButeoBridge.cpp -nodist_src_backends_buteo_libsyncevo_buteo_client_la_SOURCES = \ - $(src_backends_buteo_built_sources) - -src_backends_buteo_libsyncevo_buteo_client_la_LIBADD = $(BUTEO_LIBS) $(QT_LIBS) $(SYNCEVOLUTION_LIBS) -src_backends_buteo_libsyncevo_buteo_client_la_LDFLAGS = -module -avoid-version $(QT_LDFLAGS) -src_backends_buteo_libsyncevo_buteo_client_la_CPPFLAGS = $(SYNCEVOLUTION_CFLAGS) -I$(top_srcdir)/test $(BACKEND_CPPFLAGS) $(QT_CPPFLAGS) -src_backends_buteo_libsyncevo_buteo_client_la_DEPENDENCIES = $(SYNCEVOLUTION_LIBS) - -# Allow Qt to set some compile flags, but not the ones normally set via configure. -# In particular -W is not compatible with the SyncEvolution header files (we have -# unused parameters in some inline functions). -src_backends_buteo_libsyncevo_buteo_client_la_CXXFLAGS = $(SYNCEVOLUTION_CXXFLAGS) $(BUTEO_CFLAGS) $(filter-out -O2 -g -W -Wall, $(QT_CXXFLAGS)) $(SYNCEVO_WFLAGS) -endif diff --git a/src/backends/buteo/configure-sub.in b/src/backends/buteo/configure-sub.in deleted file mode 100644 index 8f96c7c2..00000000 --- a/src/backends/buteo/configure-sub.in +++ /dev/null @@ -1,20 +0,0 @@ -dnl -*- mode: Autoconf; -*- -dnl Invoke autogen.sh to produce a configure script. - -# BACKEND_CPPFLAGS="$BACKEND_CPPFLAGS ..." - -AC_ARG_ENABLE(buteo, - AS_HELP_STRING([--enable-buteo], - [enable Buteo client plugin]), - [enable_buteo="$enableval"], - [enable_buteo="no"] - ) - -if test "$enable_buteo" = "yes"; then - AC_DEFINE(ENABLE_BUTEO, 1, [Buteo available]) - # AC_WITH_QT() will be called in configure-post if need_qt_modules is not empty, - # setting QT_* flags. - need_qt_modules="$need_qt_modules +core" - PKG_CHECK_MODULES(BUTEO, [synccommon syncpluginmgr syncprofile]) -fi -AM_CONDITIONAL([ENABLE_BUTEO], [test "$enable_buteo" = "yes"]) diff --git a/src/backends/buteo/profiles/client/syncevo-buteo.xml b/src/backends/buteo/profiles/client/syncevo-buteo.xml deleted file mode 100644 index 36565a1d..00000000 --- a/src/backends/buteo/profiles/client/syncevo-buteo.xml +++ /dev/null @@ -1,3 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<profile name="syncevo-buteo" type="client"/> diff --git a/src/backends/buteo/profiles/profiles.am b/src/backends/buteo/profiles/profiles.am deleted file mode 100644 index 6eca237b..00000000 --- a/src/backends/buteo/profiles/profiles.am +++ /dev/null @@ -1,21 +0,0 @@ -# TODO: preferably generate this list instead -# $(sysconfdir)/sync is directory required by Buteo for config files -# client -src_backends_buteo_profiles_clientdir = $(sysconfdir)/sync/profiles/client -dist_src_backends_buteo_profiles_client_DATA = \ - src/backends/buteo/profiles/client/syncevo-buteo.xml -# $(wildcard src/backends/buteo/profiles/client/*.xml) -# service -src_backends_buteo_profiles_servicedir = $(sysconfdir)/sync/profiles/service -dist_src_backends_buteo_profiles_service_DATA = \ - src/backends/buteo/profiles/service/google-calendar.xml \ - src/backends/buteo/profiles/service/google-contacts.xml \ - src/backends/buteo/profiles/service/yahoo.xml -# $(wildcard src/backends/buteo/profiles/service/*.xml) -# sync -src_backends_buteo_profiles_syncdir = $(sysconfdir)/sync/profiles/sync -dist_src_backends_buteo_profiles_sync_DATA = \ - src/backends/buteo/profiles/sync/google-calendar.xml \ - src/backends/buteo/profiles/sync/google-contacts.xml \ - src/backends/buteo/profiles/sync/yahoo.xml -# $(wildcard src/backends/buteo/profiles/sync/*.xml) diff --git a/src/backends/buteo/profiles/service/google-calendar.xml b/src/backends/buteo/profiles/service/google-calendar.xml deleted file mode 100644 index 672dddd0..00000000 --- a/src/backends/buteo/profiles/service/google-calendar.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<profile name="google-calendar" type="service"> - <key name="destinationtype" value="online"/> - <profile name="syncevo-buteo" type="client"/> - <profile name="hcalendar" type="storage"> - <key name="Calendar Format" value="vcalendar"/> - <key name="Notebook Name" value="Personal"/> - </profile> -</profile> diff --git a/src/backends/buteo/profiles/service/google-contacts.xml b/src/backends/buteo/profiles/service/google-contacts.xml deleted file mode 100644 index 2a89bf41..00000000 --- a/src/backends/buteo/profiles/service/google-contacts.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<profile name="google-contacts" type="service"> - <key name="destinationtype" value="online"/> - <profile name="syncevo-buteo" type="client"/> - <profile name="hcontacts" type="storage"> - <key name="Local URI" value="./contacts"/> - <key name="Target URI" value="contacts"/> - </profile> -</profile> diff --git a/src/backends/buteo/profiles/service/yahoo.xml b/src/backends/buteo/profiles/service/yahoo.xml deleted file mode 100644 index 7f86a568..00000000 --- a/src/backends/buteo/profiles/service/yahoo.xml +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<profile name="yahoo" type="service"> - <key name="destinationtype" value="online"/> - <profile name="syncevo-buteo" type="client"/> - <profile name="hcalendar" type="storage"> - <key name="Calendar Format" value="vcalendar"/> - <key name="Notebook Name" value="Personal"/> - </profile> - <profile name="hcontacts" type="storage"> - <key name="Local URI" value="./contacts"/> - <key name="Target URI" value="card"/> - </profile> -</profile> diff --git a/src/backends/buteo/profiles/sync/google-calendar.xml b/src/backends/buteo/profiles/sync/google-calendar.xml deleted file mode 100644 index df75b376..00000000 --- a/src/backends/buteo/profiles/sync/google-calendar.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<profile name="google-calendar" type="sync"> - <key name="enabled" value="true"/> - <key name="displayname" value="Google"/> - <profile type="service" name="google-calendar"/> - <profile name="hcalendar" type="storage"> - <key name="enabled" value="true"/> - </profile> -</profile> diff --git a/src/backends/buteo/profiles/sync/google-contacts.xml b/src/backends/buteo/profiles/sync/google-contacts.xml deleted file mode 100644 index 96f36963..00000000 --- a/src/backends/buteo/profiles/sync/google-contacts.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<profile name="google-contacts" type="sync"> - <key name="enabled" value="true"/> - <key name="displayname" value="Google"/> - <profile type="service" name="google-contacts"/> - <profile name="hcontacts" type="storage"> - <key name="enabled" value="true"/> - </profile> -</profile> diff --git a/src/backends/buteo/profiles/sync/yahoo.xml b/src/backends/buteo/profiles/sync/yahoo.xml deleted file mode 100644 index fc229f46..00000000 --- a/src/backends/buteo/profiles/sync/yahoo.xml +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<profile name="yahoo" type="sync"> - <key name="enabled" value="true"/> - <key name="displayname" value="Yahoo!"/> - <profile type="service" name="yahoo"/> - <profile name="hcalendar" type="storage"> - <key name="enabled" value="true"/> - </profile> - <profile name="hcontacts" type="storage"> - <!-- SyncEvolution supports it. But the server has severe issues, - therefore it is disabled at the moment. Set to "true" for - testing purposes, and don't use it with real data that you - care about... --> - <key name="enabled" value="false"/> - </profile> -</profile> diff --git a/src/client-test-app.cpp b/src/client-test-app.cpp index 98654577..81feb494 100644 --- a/src/client-test-app.cpp +++ b/src/client-test-app.cpp @@ -44,10 +44,6 @@ #include <syncevo/declarations.h> -#ifdef ENABLE_BUTEO_TESTS -#include "client-test-buteo.h" -#endif - SE_BEGIN_CXX /* @@ -320,12 +316,6 @@ public: return false; } -#ifdef ENABLE_BUTEO_TESTS - virtual void setup() { - QtContactsSwitcher::prepare(*this); - } -#endif - virtual SyncMLStatus doSync(const int *sources, const std::string &logbase, const SyncOptions &options) @@ -341,31 +331,11 @@ public: rm_r("Client_Sync_Current"); symlink(current.c_str(), "Client_Sync_Current"); - // check whether using buteo to do sync - const char *buteo = getenv("CLIENT_TEST_BUTEO"); - bool useButeo = false; - if (buteo && - (boost::equals(buteo, "1") || boost::iequals(buteo, "t"))) { - useButeo = true; - } - string server = getenv("CLIENT_TEST_SERVER") ? getenv("CLIENT_TEST_SERVER") : "funambol"; server += "_"; server += m_clientID; - if (useButeo) { -#ifdef ENABLE_BUTEO_TESTS - ButeoTest buteo(*this, server, logbase, options); - buteo.prepareSources(sources, m_syncSource2Config); - SyncReport report; - SyncMLStatus status = buteo.doSync(&report); - options.m_checkReport.check(status, report); - return status; -#else - throw runtime_error("This client-test was built without enabling buteo testing."); -#endif - } class ClientTest : public CmdlineSyncClient { public: ClientTest(const string &server, diff --git a/src/client-test-buteo.cpp b/src/client-test-buteo.cpp deleted file mode 100644 index 8e6f2f4f..00000000 --- a/src/client-test-buteo.cpp +++ /dev/null @@ -1,653 +0,0 @@ -/* - * Copyright (C) 2010 Intel Corporation - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) version 3. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - -#include "syncevo/util.h" -#include "client-test-buteo.h" -#include <libsyncprofile/SyncResults.h> -#include <libsyncprofile/ProfileEngineDefs.h> -#include <libsyncprofile/Profile.h> -#include <libsyncprofile/SyncProfile.h> -#include <syncmlcommon/SyncMLCommon.h> -#include <QDomDocument> -#include <QtDBus> - -// 3 databases used by tracker to store contacts -// empty string is used as separator -const string trackerdb_old[5] = {"meta.db", - "contents.db", - "fulltext.db", // 3 databases used by tracker - "", // separator - "hcontacts.db" // database to record deleted contact items -}; -const string trackerdb_new[5] = {"meta.db", - "meta.db-shm", - "meta.db-wal", // 3 databases used by tracker - "", // separator - "hcontacts.db" // database to record deleted contact items - }; -string QtContactsSwitcher::m_databases[5] = {}; -string QtContactsSwitcher::m_dirs[2] = {"/.cache/tracker/", - "/.sync/sync-app/"}; - -using namespace Buteo; -using namespace SyncEvo; - -// execute a command. If 'check' is true, throw an exception when -// execution encounters error(s) -static void execCmd(const std::string &cmd, bool check = true) -{ - int result = Execute(cmd, ExecuteFlags(EXECUTE_NO_STDERR | EXECUTE_NO_STDOUT)); - if (result < 0 && check) { - throw runtime_error("failed to excute command: " + cmd); - } -} - -bool ButeoTest::m_inited = false; -QString ButeoTest::m_deviceIds[2]; -map<string, string> ButeoTest::m_source2storage; - -ButeoTest::ButeoTest(ClientTest &client, - const string &server, - const string &logbase, - const SyncEvo::SyncOptions &options) : - m_client(client), m_server(server), m_logbase(logbase), m_options(options) -{ - init(); -} - -void ButeoTest::init() -{ - if (!m_inited) { - m_inited = true; - // generate device ids - for(int i = 0; i < sizeof(m_deviceIds)/sizeof(m_deviceIds[0]); i++) { - QString id; - UUID uuid; - QTextStream(&id) << "sc-pim-" << uuid.c_str(); - m_deviceIds[i] = id; - } - - // insert source -> storage mappings - m_source2storage.insert(std::make_pair("qt_vcard30", "hcontacts")); - m_source2storage.insert(std::make_pair("kcal_ical20", "hcalendar")); - m_source2storage.insert(std::make_pair("kcal_itodo20", "htodo")); - m_source2storage.insert(std::make_pair("kcal_text", "hnotes")); - - //init qcoreapplication to use qt - static const char *argv[] = { "SyncEvolution" }; - static int argc = 1; - new QCoreApplication(argc, (char **)argv); - } -} - -void ButeoTest::prepareSources(const int *sources, - const vector<string> &source2Config) -{ - for(int i = 0; sources[i] >= 0; i++) { - string source = source2Config[sources[i]]; - map<string, string>::iterator it = m_source2storage.find(source); - if (it != m_source2storage.end()) { - m_configedSources.insert(it->second); - } else { - throw runtime_error("unsupported source '" + source + "'"); - } - } -} - -SyncMLStatus ButeoTest::doSync(SyncReport *report) -{ - SyncMLStatus status = STATUS_OK; - - // kill msyncd - killAllMsyncd(); - //set sync options - setupOptions(); - // restore qtcontacts if needed - if (inclContacts()) { - QtContactsSwitcher::restoreStorage(m_client); - } - - //start msyncd - int pid = startMsyncd(); - //kill 'sh' process which is the parent of 'msyncd' - stringstream cmd; - cmd << "kill -9 " << pid; - //run sync - if (!run()) { - execCmd(cmd.str(), false); - killAllMsyncd(); - return STATUS_FATAL; - } - - execCmd(cmd.str(), false); - killAllMsyncd(); - // save qtcontacts if needed - if (inclContacts()) { - QtContactsSwitcher::backupStorage(m_client); - } - //get sync results - genSyncResults(m_syncResults, report); - return report->getStatus(); -} - -void ButeoTest::setupOptions() -{ - // 1. set deviceid, max-message-size options to /etc/sync/meego-sync-conf.xml - QString meegoSyncmlConf = "/etc/sync/meego-syncml-conf.xml"; - QFile syncmlFile(meegoSyncmlConf); - if (!syncmlFile.open(QIODevice::ReadOnly)) { - throw runtime_error("can't open syncml config"); - } - // don't invoke buteo-syncml API for it doesn't support flushing - QString syncmlContent(syncmlFile.readAll()); - syncmlFile.close(); - int id = 0; - if (!boost::ends_with(m_server, "_1")) { - id = 1; - } - - //specify the db path which saves anchors related info, then we can wipe - //out it if want to slow sync. - replaceElement(syncmlContent, "dbpath", QString((m_server + ".db").c_str())); - replaceElement(syncmlContent, "local-device-name", m_deviceIds[id]); - - QString msgSize; - QTextStream(&msgSize) << m_options.m_maxMsgSize; - replaceElement(syncmlContent, "max-message-size", msgSize); - - writeToFile(meegoSyncmlConf, syncmlContent); - - // 2. set storage 'Notebook Name' for calendar, todo and notes - // for contacts, we have to set corresponding tracker db - string storageDir = getHome() + "/.sync/profiles/storage/"; - BOOST_FOREACH(const string &source, m_configedSources) { - if (boost::iequals(source, "hcalendar") || - boost::iequals(source, "htodo") || - boost::iequals(source, "hnotes")) { - string filePath = storageDir + source + ".xml"; - QDomDocument doc(m_server.c_str()); - buildDomFromFile(doc, filePath.c_str()); - QString notebookName; - QTextStream(¬ebookName) << "client_test_" << id; - Profile profile(doc.documentElement()); - profile.setKey("Notebook Name", notebookName); - writeToFile(filePath.c_str(), profile.toString()); - } - } - - // 3. set wbxml option, sync mode, enabled selected sources and disable other sources - QDomDocument doc(m_server.c_str()); - //copy profile - string profileDir = getHome() + "/.sync/profiles/sync/"; - string profilePath = profileDir + m_server + ".xml"; - size_t pos = m_server.rfind('_'); - if (pos != m_server.npos) { - string prefix = m_server.substr(0, pos); - stringstream cmd; - cmd << "cp " << profileDir - << prefix << ".xml " - << profilePath; - execCmd(cmd.str()); - } - buildDomFromFile(doc, profilePath.c_str()); - SyncProfile syncProfile(doc.documentElement()); - syncProfile.setName(m_server.c_str()); - QList<Profile *> storages = syncProfile.storageProfilesNonConst(); - QListIterator<Profile *> it(storages); - while (it.hasNext()) { - Profile * profile = it.next(); - set<string>::iterator configedIt = m_configedSources.find(profile->name().toStdString()); - if (configedIt != m_configedSources.end()) { - profile->setKey(KEY_ENABLED, "true"); - } else { - profile->setKey(KEY_ENABLED, "false"); - } - } - - // set syncml client - Profile * syncml = syncProfile.subProfile("syncml", "client"); - if (syncml) { - // set whether using wbxml - syncml->setBoolKey(PROF_USE_WBXML, m_options.m_isWBXML); - // set sync mode - QString syncMode; - switch(m_options.m_syncMode) { - case SYNC_NONE: - break; - case SYNC_TWO_WAY: - syncMode = VALUE_TWO_WAY; - break; - case SYNC_ONE_WAY_FROM_CLIENT: - // work around here since buteo doesn't support refresh mode now - syncMode = VALUE_TO_REMOTE; - break; - case SYNC_REFRESH_FROM_CLIENT: - // don't support, no workaround here - throw runtime_error("Buteo doesn't support refresh mode"); - case SYNC_ONE_WAY_FROM_SERVER: - syncMode = VALUE_FROM_REMOTE; - break; - case SYNC_REFRESH_FROM_SERVER: { - //workaround here since buteo doesn't support refresh-from-server - //wipe out anchors and remove tracker database - //so we will do refresh-from-server by slow sync - stringstream cmd1; - cmd1 << "rm -f " << m_server << ".db"; - execCmd(cmd1.str(), false); - if (inclContacts()) { - execCmd("tracker-control -r", false); - stringstream cmd2; - cmd2 << "rm -f " - << getHome() << "/.cache/tracker/*.db " - << getHome() << "/.cache/tracker/*.db_" - << m_client.getClientB() ? "1" : "2"; - execCmd(cmd2.str(), false); - } - syncMode = VALUE_TWO_WAY; - break; - } - case SYNC_SLOW: { - //workaround here since buteo doesn't support explicite slow-sync - //wipe out anchors so we will do slow sync - stringstream cmd; - cmd << "rm -f " << m_server << ".db"; - execCmd(cmd.str(), false); - syncMode = VALUE_TWO_WAY; - break; - } - default: - break; - } - syncml->setKey(KEY_SYNC_DIRECTION, syncMode); - } - writeToFile(profilePath.c_str(), syncProfile.toString()); -} - -void ButeoTest::killAllMsyncd() -{ - execCmd("killall -9 msyncd", false); -} - -int ButeoTest::startMsyncd() -{ - int pid = fork(); - if (pid == 0) { - //child - stringstream cmd; - cmd << "msyncd >" << m_logbase << ".log 2>&1"; - if (execlp("sh", "sh", "-c", cmd.str().c_str(), (char *)0) < 0 ) { - exit(1); - } - } else if (pid < 0) { - throw runtime_error("can't fork process"); - } - // wait for msyncd get prepared - execCmd("sleep 2", false); - return pid; -} - -bool ButeoTest::run() -{ - static const QString msyncdService = "com.meego.msyncd"; - static const QString msyncdObject = "/synchronizer"; - static const QString msyncdInterface = "com.meego.msyncd"; - - QDBusConnection conn = QDBusConnection::sessionBus(); - std::auto_ptr<QDBusInterface> interface(new QDBusInterface(msyncdService, msyncdObject, msyncdInterface, conn)); - if (!interface->isValid()) { - QString error = interface->lastError().message(); - return false; - } - - // add watcher for watching unregistering service - std::auto_ptr<QDBusServiceWatcher> dbusWatcher(new QDBusServiceWatcher(msyncdService, conn, QDBusServiceWatcher::WatchForUnregistration)); - dbusWatcher->connect(dbusWatcher.get(), SIGNAL(serviceUnregistered(QString)), - this, SLOT(serviceUnregistered(QString))); - - //connect signals - interface->connect(interface.get(), SIGNAL(syncStatus(QString, int, QString, int)), - this, SLOT(syncStatus(QString, int, QString, int))); - interface->connect(interface.get(), SIGNAL(resultsAvailable(QString, QString)), - this, SLOT(resultsAvailable(QString, QString))); - - // start sync - QDBusReply<bool> reply = interface->call(QString("startSync"), m_server.c_str()); - if (reply.isValid() && !reply.value()) { - return false; - } - - // wait sync completed - return QCoreApplication::exec() == 0; -} - -void ButeoTest::genSyncResults(const QString &text, SyncReport *report) -{ - QDomDocument domResults; - if (domResults.setContent(text, true)) { - SyncResults syncResults(domResults.documentElement()); - switch(syncResults.majorCode()) { - case SyncResults::SYNC_RESULT_SUCCESS: - report->setStatus(STATUS_OK); - break; - case SyncResults::SYNC_RESULT_FAILED: - report->setStatus(STATUS_FATAL); - break; - case SyncResults::SYNC_RESULT_CANCELLED: - report->setStatus(STATUS_FATAL); - break; - }; - QList<TargetResults> targetResults = syncResults.targetResults(); - QListIterator<TargetResults> it(targetResults); - while (it.hasNext()) { - // get item sync info - TargetResults target = it.next(); - SyncSourceReport targetReport; - // temporary set this mode due to no this information in report - targetReport.recordFinalSyncMode(m_options.m_syncMode); - ItemCounts itemCounts = target.localItems(); - targetReport.setItemStat(SyncSourceReport::ITEM_LOCAL, - SyncSourceReport::ITEM_ADDED, - SyncSourceReport::ITEM_TOTAL, - itemCounts.added); - targetReport.setItemStat(SyncSourceReport::ITEM_LOCAL, - SyncSourceReport::ITEM_UPDATED, - SyncSourceReport::ITEM_TOTAL, - itemCounts.modified); - targetReport.setItemStat(SyncSourceReport::ITEM_LOCAL, - SyncSourceReport::ITEM_REMOVED, - SyncSourceReport::ITEM_TOTAL, - itemCounts.deleted); - - // get item info for remote - itemCounts = target.remoteItems(); - targetReport.setItemStat(SyncSourceReport::ITEM_REMOTE, - SyncSourceReport::ITEM_ADDED, - SyncSourceReport::ITEM_TOTAL, - itemCounts.added); - targetReport.setItemStat(SyncSourceReport::ITEM_REMOTE, - SyncSourceReport::ITEM_UPDATED, - SyncSourceReport::ITEM_TOTAL, - itemCounts.modified); - targetReport.setItemStat(SyncSourceReport::ITEM_REMOTE, - SyncSourceReport::ITEM_REMOVED, - SyncSourceReport::ITEM_TOTAL, - itemCounts.deleted); - // set to sync report - report->addSyncSourceReport(target.targetName().toStdString(), targetReport); - } - } else { - report->setStatus(STATUS_FATAL); - } -} - -void ButeoTest::syncStatus(QString profile, int status, QString message, int moreDetails) -{ - if (profile == m_server.c_str()) { - switch(status) { - case 0: // QUEUED - case 1: // STARTED - case 2: // PROGRESS - break; - case 3: // ERROR - case 5: // ABORTED - QCoreApplication::exit(1); - break; - case 4: // DONE - QCoreApplication::exit(0); - break; - default: - ; - } - } -} - -void ButeoTest::resultsAvailable(QString profile, QString syncResults) -{ - if (profile == m_server.c_str()) { - m_syncResults = syncResults; - } -} - -void ButeoTest::serviceUnregistered(QString service) -{ - QCoreApplication::exit(1); -} - -bool ButeoTest::inclContacts() -{ - set<string>::iterator sit = m_configedSources.find("hcontacts"); - if (sit != m_configedSources.end()) { - return true; - } - return false; -} - -void ButeoTest::writeToFile(const QString &filePath, const QString &content) -{ - // clear tempoary file firstly - stringstream rmCmd; - rmCmd << "rm -f " << filePath.toStdString() << "_tmp"; - execCmd(rmCmd.str(), false); - - // open temporary file and serialize dom to the file - QFile file(filePath + "_tmp"); - if (!file.open(QIODevice::WriteOnly)) { - stringstream msg; - msg << "can't open file '" << filePath.toStdString() << "' with 'write' mode"; - throw runtime_error(msg.str()); - } - if (file.write(content.toUtf8()) == -1) { - file.close(); - stringstream msg; - msg << "can't write file '" << filePath.toStdString() << "'"; - throw runtime_error(msg.str()); - } - file.close(); - - // move temp file to destination file - stringstream mvCmd; - mvCmd << "mv " << filePath.toStdString() << "_tmp " - << filePath.toStdString(); - execCmd(mvCmd.str()); -} - -void ButeoTest::replaceElement(QString &xml, const QString &elem, const QString &value) -{ - // TODO: use DOM to parse xml - // currently this could work - QString startTag = "<" + elem +">"; - QString endTag = "</" + elem +">"; - - int start = xml.indexOf(startTag); - if ( start == -1) { - return; - } - int end = xml.indexOf(endTag, start); - int pos = start + startTag.size(); - - xml.replace(pos, end - pos, value); -} - -void ButeoTest::buildDomFromFile(QDomDocument &doc, const QString &filePath) -{ - // open it - QFile file(filePath); - if (!file.open(QIODevice::ReadOnly)) { - stringstream msg; - msg << "can't open profile file '" << filePath.toStdString() << "'"; - throw runtime_error(msg.str()); - } - - // parse it - if (!doc.setContent(&file)) { - file.close(); - stringstream msg; - msg << "can't parse profile file '" << filePath.toStdString() << "'"; - throw runtime_error(msg.str()); - } - file.close(); -} - -static bool isButeo() -{ - static bool checked = false; - static bool useButeo = false; - - if (!checked) { - const char *buteo = getenv("CLIENT_TEST_BUTEO"); - if (buteo && - (boost::equals(buteo, "1") || boost::iequals(buteo, "t"))) { - useButeo = true; - } - checked = true; - } - - return useButeo; -} - -string QtContactsSwitcher::getId(ClientTest &client) { - if (client.getClientB()) { - return "1"; - } - return "2"; -} - -void QtContactsSwitcher::prepare(ClientTest &client) { - // check if version of tracker is equal or greater than 0.9.26 - // set tracker databases according it's version - FILE *fp; - int version; - char cmd[] = "tracker-control -V | awk 'NR==2 {print $2}' | awk '{split($0,A,\".\"); X=256*256*A[1]+256*A[2]+A[3];print X;}'"; - char buffer[10]; - fp = popen(cmd,"r"); - fgets(buffer,sizeof(buffer),fp); - sscanf(buffer,"%d", &version); - pclose(fp); - if (version >= 2330) { - QtContactsSwitcher::setDatabases(trackerdb_new); - } else { - QtContactsSwitcher::setDatabases(trackerdb_old); - } - - int index = 0; - for (int i = 0; i < sizeof(m_databases)/sizeof(m_databases[0]); i++) { - if (m_databases[i].empty()) { - index++; - continue; - } - - stringstream cmd; - cmd << "rm -f " << getDatabasePath(index) << m_databases[i] - << "_"; - execCmd(cmd.str() + "1", false); - execCmd(cmd.str() + "2", false); - } - execCmd("tracker-control -r", false); -} - -void QtContactsSwitcher::restoreStorage(ClientTest &client) -{ - // if CLIENT_TEST_BUTEO is not enabled, skip it for LocalTests may also use it - if (!isButeo()) { - return; - } - - string id = getId(client); - terminate(); - copyDatabases(client, false); - start(); -} - -void QtContactsSwitcher::backupStorage(ClientTest &client) -{ - // if CLIENT_TEST_BUTEO is not enabled, skip it for LocalTests may also use it - if (!isButeo()) { - return; - } - - string id = getId(client); - terminate(); - copyDatabases(client); - start(); -} - -void QtContactsSwitcher::setDatabases(const string databases[]) -{ - for (int i = 0; i < sizeof(m_databases)/sizeof(m_databases[0]); i++) { - m_databases[i] = databases[i]; - } -} -string QtContactsSwitcher::getDatabasePath(int index) -{ - string m_path = getHome() + m_dirs[index]; - return m_path; -} - -void QtContactsSwitcher::copyDatabases(ClientTest &client, bool fromDefault) -{ - static string m_cmds[] = {"", - "", - "", - "", - "\"delete from deleteditems;\""}; - - string id = getId(client); - - int index = 0; - for (int i = 0; i < sizeof(m_databases)/sizeof(m_databases[0]); i++) { - if (m_databases[i].empty()) { - index++; - continue; - } - string src = getDatabasePath(index) + m_databases[i]; - string dest = src + "_" + id; - if (!fromDefault) { - // in this case, we copy *_1/2.db to default db - // if *_1/2.db doesn't exist, we copy default with initial commands - if (access(dest.c_str(), F_OK) < 0) { - if (access(src.c_str(), F_OK) >= 0) { - if (!m_cmds[i].empty()) { - stringstream temp; - temp << "sqlite3 " << src << " " << m_cmds[i]; - execCmd(temp.str(), false); - } - } - } else { - string tmp = src; - src = dest; - dest = tmp; - } - } - stringstream cmd; - cmd << "cp -f " << src << " " << dest; - execCmd(cmd.str(), false); - } -} - -void QtContactsSwitcher::terminate() -{ - execCmd("tracker-control -t"); -} - -void QtContactsSwitcher::start() -{ - // sleep one second to let tracker daemon get prepared - execCmd("tracker-control -s"); - execCmd("sleep 2"); -} diff --git a/src/client-test-buteo.h b/src/client-test-buteo.h deleted file mode 100644 index 11f79de2..00000000 --- a/src/client-test-buteo.h +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (C) 2010 Intel Corporation - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) version 3. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - */ -#ifndef INCL_SYNC_BUTEOTEST -#define INCL_SYNC_BUTEOTEST - -#include <syncevo/util.h> -#include <syncevo/declarations.h> -#include <QString> -#include <QObject> -#include <QtDBus> -#include <QDomDocument> -#include "ClientTest.h" - -using namespace SyncEvo; - -/** - * ButeoTest is used to invoke buteo to do client test with the help - * of client test framework. The basic idea is to implement doSync and - * replace with invocation of buteo's dbus server - 'msyncd'. - * The main steps are: - * 1) pre-run: This may include set up sync options for local client - * and target server, prepare local databases - * 2) run: run sync by sending dbus calls to 'msyncd' and wait until - * it finishes - * 3) post-run: collect sync result and statistics - */ -class ButeoTest : public QObject { - Q_OBJECT -public: - ButeoTest(ClientTest &client, - const string &server, - const string &logbase, - const SyncEvo::SyncOptions &options); - - // prepare sync sources - void prepareSources(const int *sources, const vector<string> &source2Config); - - // do actually sync - SyncEvo::SyncMLStatus doSync(SyncEvo::SyncReport *report); - -private slots: - void syncStatus(QString, int, QString, int); - void resultsAvailable(QString, QString); - void serviceUnregistered(QString); - -private: - - /** initialize - */ - static void init(); - - /** - * 1. set deviceid, max-message-size options to /etc/sync/meego-sync-conf.xml - * 2. set wbxml option, sync mode, enabled selected sources and disable other sources - */ - void setupOptions(); - - // kill all msyncd - void killAllMsyncd(); - - // start msyncd - int startMsyncd(); - - // do actually running - bool run(); - - // get sync results from buteo and set them to sync report - void genSyncResults(const QString &text, SyncEvo::SyncReport *report); - - // whether configured sources include contacts - bool inclContacts(); - - // truncate file and write content to file - static void writeToFile(const QString &filePath, const QString &content ); - - //replace the element value with a new value - static void replaceElement(QString &xml, const QString &elem, const QString &value); - - // build a dom tree from file - static void buildDomFromFile(QDomDocument &doc, const QString &filePath); - - ClientTest &m_client; - string m_server; - string m_logbase; - SyncEvo::SyncOptions m_options; - std::set<string> m_configedSources; - QString m_syncResults; - - //device ids - static QString m_deviceIds[2]; - //mappings for syncevolution source and buteo storage - static map<string, string> m_source2storage; - //flag for initialization - static bool m_inited; -}; - - -/** - * Qtcontacts use tracker to store data. However, it can't specify - * the place where to store them. Since we have to separate client A - * and B's data, restore and backup their databases - */ -class QtContactsSwitcher { -public: - /** do preparation */ - static void prepare(ClientTest &client); - - static string getId(ClientTest &client); - - /** - * prepare storage: - * 1. terminate tracker - * 2. copy tracker databases from backup to its default place - * according to id - * 3. restart tracker - */ - static void restoreStorage(ClientTest &client); - - /** - * backup storage: - * 1. terminate tracker - * 2. copy tracker databases from default place to backup - * 3. restart tracker - */ - static void backupStorage(ClientTest &client); - - static void setDatabases(const string databases[]); -private: - // get the file path of databases - static std::string getDatabasePath(int index = 0); - - //terminate tracker daemons - static void terminate(); - - //start tracker daemons - static void start(); - - //copy databases between default place and backup place - static void copyDatabases(ClientTest &client, bool fromDefault = true); - - //databases used by tracker - static std::string m_databases[5]; - static std::string m_dirs[2]; -}; -#endif @@ -227,15 +227,6 @@ src_client_test_SOURCES = \ $(CORE_SOURCES) nodist_src_client_test_SOURCES = test/test.cpp -if ENABLE_BUTEO_TESTS -src_client_test_buteo_moc_files = src/client-test-buteo.moc.cpp -src_client_test_SOURCES += \ - src/client-test-buteo.h \ - src/client-test-buteo.cpp -nodist_src_client_test_SOURCES += $(src_client_test_buteo_moc_files) -BUILT_SOURCES += $(src_client_test_buteo_moc_files) -endif - # list of test file base files # # Generated files (testcases/eds_event.ics.funambol.tem) are derived from @@ -268,10 +259,10 @@ TEST_FILES_PATCHED = $(wildcard src/testcases/*.tem) # add files created via patches CLIENT_LIB_TEST_FILES += $(TEST_FILES_GENERATED) -src_client_test_CPPFLAGS = -DHAVE_CONFIG_H -DENABLE_INTEGRATION_TESTS -DENABLE_UNIT_TESTS $(src_cppflags) $(BUTEOSYNCPROFILE_CFLAGS) $(BUTEOSYNCCOMMON_CFLAGS) $(QT_CPPFLAGS) -src_client_test_CXXFLAGS = @CPPUNIT_CXXFLAGS@ $(PCRECPP_CFLAGS) $(SYNCEVOLUTION_CXXFLAGS) $(CORE_CXXFLAGS) $(BUTEOSYNCPROFILE_CFLAGS) $(BUTEOSYNCCOMMON_CFLAGS) $(filter-out -O2 -g -W -Wall, $(QT_CXXFLAGS)) $(SYNCEVO_WFLAGS) -src_client_test_LDFLAGS = @CPPUNIT_LDFLAGS@ `nm src/syncevo/.libs/libsyncevolution.a | grep funambolAutoRegisterRegistry | sed -e 's/.* /-Wl,-u/'` $(PCRECPP_LIBS) $(CORE_LD_FLAGS) $(BUTEOSYNCPROFILE_LIBS) $(BUTEOSYNCCOMMON_LIBS) $(QT_LDFLAGS) -src_client_test_LDADD = $(CORE_LDADD) $(SYNTHESIS_ENGINE) $(BUTEOSYNCPROFILE_LIBS) $(BUTEOSYNCCOMMON_LIBS) $(QT_LIBS) +src_client_test_CPPFLAGS = -DHAVE_CONFIG_H -DENABLE_INTEGRATION_TESTS -DENABLE_UNIT_TESTS $(src_cppflags) $(QT_CPPFLAGS) +src_client_test_CXXFLAGS = @CPPUNIT_CXXFLAGS@ $(PCRECPP_CFLAGS) $(SYNCEVOLUTION_CXXFLAGS) $(CORE_CXXFLAGS) $(filter-out -O2 -g -W -Wall, $(QT_CXXFLAGS)) $(SYNCEVO_WFLAGS) +src_client_test_LDFLAGS = @CPPUNIT_LDFLAGS@ `nm src/syncevo/.libs/libsyncevolution.a | grep funambolAutoRegisterRegistry | sed -e 's/.* /-Wl,-u/'` $(PCRECPP_LIBS) $(CORE_LD_FLAGS) $(QT_LDFLAGS) +src_client_test_LDADD = $(CORE_LDADD) $(SYNTHESIS_ENGINE) $(QT_LIBS) # These dependencies are intentionally a bit too broad: # they ensure that all files are in place to *run* client-test. @@ -347,8 +338,6 @@ $(filter-out %.tem, $(filter src/testcases/%, $(subst $(top_srcdir)/test/,src/,$ # runs the binary with out-dated auxiliary files. src_client_test_DEPENDENCIES = $(EXTRA_LTLIBRARIES) $(CORE_DEP) $(CLIENT_LIB_TEST_FILES) testcase2patch src/synccompare src/synclog2html src/templates -CLEANFILES += $(src_client_test_buteo_moc_files) - # Copy template directory into current working directory, if not there # yet. -ef flag checks whether device and inode numbers of both files # are equal. If such check passes then it does mean that it is either diff --git a/test/ClientTest.cpp b/test/ClientTest.cpp index 88726107..5dd2466b 100644 --- a/test/ClientTest.cpp +++ b/test/ClientTest.cpp @@ -72,10 +72,6 @@ #include <syncevo/declarations.h> -#ifdef ENABLE_BUTEO_TESTS -#include "client-test-buteo.h" -#endif - namespace CppUnit { /** @@ -416,20 +412,10 @@ static void removeItem(TestingSyncSource *source, const std::string &luid) static void restoreStorage(const ClientTest::Config &config, ClientTest &client) { -#ifdef ENABLE_BUTEO_TESTS - if (boost::iequals(config.sourceName,"qt_contact")) { - QtContactsSwitcher::restoreStorage(client); - } -#endif } static void backupStorage(const ClientTest::Config &config, ClientTest &client) { -#ifdef ENABLE_BUTEO_TESTS - if (boost::iequals(config.sourceName,"qt_contact")) { - QtContactsSwitcher::backupStorage(client); - } -#endif } /** adds the supported tests to the instance itself */ |