diff options
author | (no author) <(no author)@15ad00c4-1369-45f4-8270-35d70d36bdcd> | 2008-01-29 19:32:11 +0000 |
---|---|---|
committer | (no author) <(no author)@15ad00c4-1369-45f4-8270-35d70d36bdcd> | 2008-01-29 19:32:11 +0000 |
commit | 22d290126c7beefa35f7a3c91818f6e1fd955604 (patch) | |
tree | f7d65c1754efb7b76a48b91b5e02666a5a7a68a9 | |
parent | 948defe24821f32af27cfcde0cdedae7666c5a1b (diff) |
This commit was manufactured by cvs2svn to create tagsyncevolution-0-7-deb2
'syncevolution-0-7-deb2'.
git-svn-id: https://zeitsenke.de/svn/SyncEvolution/tags/syncevolution-0-7-deb2@490 15ad00c4-1369-45f4-8270-35d70d36bdcd
-rw-r--r-- | debian/changelog | 11 | ||||
-rw-r--r-- | debian/dbus-wrapper.cpp | 39 | ||||
-rwxr-xr-x | debian/rules | 16 | ||||
-rw-r--r-- | src/EvolutionSyncClient.cpp | 8 | ||||
-rw-r--r-- | src/SQLiteSyncSource.cpp | 203 | ||||
-rw-r--r-- | src/SQLiteSyncSource.h | 142 |
6 files changed, 62 insertions, 357 deletions
diff --git a/debian/changelog b/debian/changelog index a15b87ba..e24d96da 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,14 @@ +syncevolution (1:0.7-2) unstable; urgency=low + + * compiled with --as-needed to avoid useless dependencies on libs which + are not available on ITOS 2008 + * replaced linking against a patched libdbus with a wrapper for the + libdbus function dbus_connection_send_with_reply() which replaces + the hard-coded default: this was necessary to be compatible with + ITOS 2006 till 2008 + + -- Patrick Ohly <patrick.ohly@gmx.de> Sat, 19 Jan 2008 21:09:05 +0100 + syncevolution (1:0.7-1) unstable; urgency=low * updated upstream sources diff --git a/debian/dbus-wrapper.cpp b/debian/dbus-wrapper.cpp new file mode 100644 index 00000000..86a02926 --- /dev/null +++ b/debian/dbus-wrapper.cpp @@ -0,0 +1,39 @@ + +#include <dlfcn.h> + +/** + * There are valid use cases where the (previously hard-coded) default + * timeout was too short. This function replaces _DBUS_DEFAULT_TIMEOUT_VALUE + * and - if set - interprets the content of DBUS_DEFAULT_TIMEOUT as + * number of milliseconds. + */ +static int _dbus_connection_default_timeout(void) +{ + const char *def = getenv("DBUS_DEFAULT_TIMEOUT"); + int timeout = 0; + + if (def) { + timeout = atoi(def); + } + if (timeout <= 0) { + /* the traditional _DBUS_DEFAULT_TIMEOUT_VALUE */ + timeout = 25 * 1000; + } +} + +extern "C" int +dbus_connection_send_with_reply (void *connection, + void *message, + void **pending_return, + int timeout_milliseconds) +{ + static typeof(dbus_connection_send_with_reply) *real_func; + + if (!real_func) { + real_func = (typeof(dbus_connection_send_with_reply) *)dlsym(RTLD_NEXT, "dbus_connection_send_with_reply"); + } + return real_func ? + real_func(connection, message, pending_return, + timeout_milliseconds == -1 ? _dbus_connection_default_timeout() : timeout_milliseconds) : + 0; +} diff --git a/debian/rules b/debian/rules index 9f384312..37d2a202 100755 --- a/debian/rules +++ b/debian/rules @@ -12,7 +12,7 @@ # options that can be added to DEB_BUILD_OPTIONS: # - noopt: compile with -O0 -# - maemo[=<absolute path to directory which contains patched libdbus-1.a/so>]: enable maemo hacks +# - maemo: enable maemo hacks # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 @@ -27,6 +27,9 @@ DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) CFLAGS = -Wall -g +LDFLAGS = -Wl,--as-needed +export CFLAGS +export LDFLAGS ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) CONFIGURE_FLAGS += CXXFLAGS="-g -O0" @@ -36,16 +39,19 @@ ifneq (,$(findstring maemo,$(DEB_BUILD_OPTIONS))) CONFIGURE_FLAGS += --enable-maemo --enable-shared endif -ifneq (,$(findstring maemo=,$(DEB_BUILD_OPTIONS))) - CONFIGURE_FLAGS += --with-patched-libdbus=$(subst maemo=,,$(filter maemo=%,$(DEB_BUILD_OPTIONS))) -endif - config.status: configure dh_testdir # --enable-shared added to build SyncEvolution backends as modules, # which is more flexible but not the default because it requires a # specific installation layout. ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) $(CONFIGURE_FLAGS) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info + # fix place of \$compiler_flags in -shared build line: our -Wl,--as-needed has + # no effect if it comes after the libs, which is where libtool 1.5.24 puts it + # normally + perl -pi -e 's/-shared (.*) \\\$$compiler_flags/-shared \\\$$compiler_flags $$1/' libtool + # add dbus wrapper which overrides the default timeout: only required if not yet + # in upstream source (it wasn't in the 0.7 source snapshot) + grep dbus_connection_send_with_reply src/EvolutionSyncClient.cpp >/dev/null || cat debian/dbus-wrapper.cpp >>src/EvolutionSyncClient.cpp #Architecture build: build-arch build-indep diff --git a/src/EvolutionSyncClient.cpp b/src/EvolutionSyncClient.cpp index 41279ecb..23fad4ae 100644 --- a/src/EvolutionSyncClient.cpp +++ b/src/EvolutionSyncClient.cpp @@ -623,13 +623,7 @@ void EvolutionSyncClient::fatalError(void *object, const char *error) exit(1); } -/* - * There have been segfaults inside glib in the background - * thread which ran the second event loop. Disabled it again, - * even though the synchronous EDS API calls will block then - * when EDS dies. - */ -#if 0 && defined(HAVE_GLIB) && defined(HAVE_EDS) +#if defined(HAVE_GLIB) && defined(HAVE_EDS) # define RUN_GLIB_LOOP #endif diff --git a/src/SQLiteSyncSource.cpp b/src/SQLiteSyncSource.cpp deleted file mode 100644 index 0aecaa50..00000000 --- a/src/SQLiteSyncSource.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (C) 2007 Patrick Ohly - * Copyright (C) 2007 Funambol - * - * 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 "config.h" - -#ifdef ENABLE_SQLITE - -#include "SQLiteSyncSource.h" -#include "base/util/StringBuffer.h" -#include "vocl/VConverter.h" - -#include <stdarg.h> - -void SQLiteSyncSource::throwError(const string &operation) -{ - string descr = string(getName()) + ": '" + m_id + "': " + operation + " failed"; - - if (m_db) { - const char *error = sqlite3_errmsg(m_db); - descr += ": "; - descr += error ? error : "unspecified error"; - } - - throw runtime_error(descr); -} - -sqlite3_stmt *SQLiteSyncSource::prepareSQLWrapper(const char *sql, const char **nextsql) -{ - sqlite3_stmt *stmt = NULL; - - checkSQL(sqlite3_prepare(m_db, sql, -1, &stmt, nextsql), sql); - return stmt; -} - -sqlite3_stmt *SQLiteSyncSource::prepareSQL(const char *sqlfmt, ...) -{ - StringBuffer sql; - va_list ap; - - va_start(ap, sqlfmt); - sql.vsprintf(sqlfmt, ap); - va_end(ap); - - return prepareSQLWrapper(sql.c_str()); -} - - -SQLiteSyncSource::key_t SQLiteSyncSource::findKey(const char *database, const char *keyname, const char *key) -{ - eptr<sqlite3_stmt> query(prepareSQL("SELECT ROWID FROM %s WHERE %s = '%s';", database, keyname, key)); - - int res = checkSQL(sqlite3_step(query), "getting key"); - if (res == SQLITE_ROW) { - return sqlite3_column_int64(query, 0); - } else { - return -1; - } -} - -string SQLiteSyncSource::findColumn(const char *database, const char *keyname, const char *key, const char *column, const char *def) -{ - eptr<sqlite3_stmt> query(prepareSQL("SELECT %s FROM %s WHERE %s = '%s';", column, database, keyname, key)); - - int res = checkSQL(sqlite3_step(query), "getting key"); - if (res == SQLITE_ROW) { - const unsigned char *text = sqlite3_column_text(query, 0); - - return text ? (const char *)text : def; - } else { - return def; - } -} - -string SQLiteSyncSource::getTextColumn(sqlite3_stmt *stmt, int col, const char *def) -{ - const unsigned char *text = sqlite3_column_text(stmt, col); - return text ? (const char *)text : def; -} - -SQLiteSyncSource::syncml_time_t SQLiteSyncSource::getTimeColumn(sqlite3_stmt *stmt, int col) -{ - // assumes that the database stores the result of time() directly - return sqlite3_column_int64(stmt, col); -} - -void SQLiteSyncSource::rowToVObject(sqlite3_stmt *stmt, vocl::VObject &vobj) -{ - const unsigned char *text; - const char *tablename; - int i; - - for (i = 0; m_mapping[i].colname; i++) { - if (m_mapping[i].colindex < 0 || - !m_mapping[i].propname) { - continue; - } - tablename = sqlite3_column_table_name(stmt, m_mapping[i].colindex); - if (!tablename || strcasecmp(tablename, m_mapping[i].tablename)) { - continue; - } - text = sqlite3_column_text(stmt, m_mapping[i].colindex); - if (text) { - vobj.addProperty(m_mapping[i].propname, (const char *)text); - } - } -} - -void SQLiteSyncSource::open() -{ - const string prefix("file://"); - bool create = m_id.substr(0, prefix.size()) == prefix; - string filename = create ? m_id.substr(prefix.size()) : m_id; - - if (!create && access(filename.c_str(), F_OK)) { - throw runtime_error(string(getName()) + ": no such database: '" + filename + "'"); - } - - sqlite3 *db; - int res = sqlite3_open(filename.c_str(), &db); - m_db = db; - checkSQL(res, "opening"); - - // check whether file is empty = newly created, define schema if that's the case - eptr<sqlite3_stmt> check(prepareSQLWrapper("SELECT * FROM sqlite_master;")); - switch (sqlite3_step(check)) { - case SQLITE_ROW: - // okay - break; - case SQLITE_DONE: { - // empty - const char *schema = getDefaultSchema(); - const char *nextsql = schema; - while (nextsql && *nextsql) { - const char *sql = nextsql; - eptr<sqlite3_stmt> create(prepareSQLWrapper(sql, &nextsql)); - while (true) { - int res = sqlite3_step(create); - if (res == SQLITE_DONE) { - break; - } else if (res == SQLITE_ROW) { - // continue - } else { - throwError("creating database");\ - } - } - } - break; - } - default: - throwError("checking content"); - break; - } - - // query database schema to find columns we need - const Mapping *mapping = getConstMapping(); - int i; - for (i = 0; mapping[i].colname; i++) ; - m_mapping.set(new Mapping[i + 1]); - eptr<sqlite3_stmt> query; - string tablename; - for (i = 0; mapping[i].colname; i++) { - m_mapping[i] = mapping[i]; - - // switching to a different table? - if (tablename != m_mapping[i].tablename) { - tablename = m_mapping[i].tablename; - query.set(prepareSQL("SELECT * FROM %s;", tablename.c_str())); - } - - // search for this column name - for (m_mapping[i].colindex = sqlite3_column_count(query) - 1; - m_mapping[i].colindex >= 0; - m_mapping[i].colindex--) { - const char *name = sqlite3_column_name(query, m_mapping[i].colindex); - if (name && !strcasecmp(m_mapping[i].colname, name)) { - break; - } - } - } - memset(&m_mapping[i], 0, sizeof(m_mapping[i])); -} - -void SQLiteSyncSource::close() -{ -} - -#endif /* ENABLE_SQLITE */ diff --git a/src/SQLiteSyncSource.h b/src/SQLiteSyncSource.h deleted file mode 100644 index 8d706300..00000000 --- a/src/SQLiteSyncSource.h +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (C) 2007 Patrick Ohly - * Copyright (C) 2007 Funambol - * - * 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 - */ - -#ifndef INCL_SQLITESYNCSOURCE -#define INCL_SQLITESYNCSOURCE - -#include "EvolutionSyncSource.h" - -#ifdef ENABLE_SQLITE - -#include <sqlite3.h> -#include "EvolutionSmartPtr.h" - -namespace vocl { - class VObject; -} -void inline unref(sqlite3 *db) { sqlite3_close(db); } -void inline unref(sqlite3_stmt *stmt) { sqlite3_finalize(stmt); } - -/** - * This class implements access to SQLite database files: - * - opening the database file - * - error reporting - * - creating a database file in debugging mode - */ -class SQLiteSyncSource : public EvolutionSyncSource -{ - public: - /** - * Creates a new Evolution sync source. - * - * @param name the named needed by SyncSource - * @param sc obligatory config for this source, must remain valid throughout the lifetime of the source - * @param changeId is used to track changes in the Evolution backend - * @param id identifies the backend; not specifying it makes this instance - * unusable for anything but listing backend databases - */ - SQLiteSyncSource( const string name, SyncSourceConfig *sc, const string &changeId, const string &id ) : - EvolutionSyncSource( name, sc, changeId, id), - m_db(NULL) - {} - virtual ~SQLiteSyncSource() {} - - /* implementation of EvolutionSyncSource interface */ - virtual sources getSyncBackends() { return sources(); /* we cannot list available databases */ } - virtual void open(); - virtual void close(); - - - protected: - /** throw error for a specific sqlite3 operation on m_db */ - void throwError(const string &operation); - - /** - * wrapper around sqlite3_prepare() which operates on the current - * database and throws an error if the call fails - * - * @param sqlfmt printf-style format string for query, followed by parameters for sprintf - */ - sqlite3_stmt *prepareSQL(const char *sqlfmt, ...); - - /** - * wrapper around sqlite3_prepare() which operates on the current - * database and throws an error if the call fails - * - * @param sql preformatted SQL statement(s) - * @param nextsql pointer to next statement in sql - */ - sqlite3_stmt *prepareSQLWrapper(const char *sql, const char **nextsql = NULL); - - - /** checks the result of an sqlite3 call, throws an error if faulty, otherwise returns the result */ - int checkSQL(int res, const char *operation = "SQLite call") { - if (res != SQLITE_OK && res != SQLITE_ROW && res != SQLITE_DONE) { - throwError(operation); - } - return res; - } - - /** type used for row keys */ - typedef long long key_t; - string toString(key_t key) { char buffer[32]; sprintf(buffer, "%lld", key); return buffer; } -#define SQLITE3_COLUMN_KEY sqlite3_column_int64 - - /** return row ID for a certain row */ - key_t findKey(const char *database, const char *keyname, const char *key); - - /** return a specific column for a row identified by a certain key column as text, returns default text if not found */ - string findColumn(const char *database, const char *keyname, const char *key, const char *column, const char *def); - - /** a wrapper for sqlite3_column_test() which will check for NULL and returns default text instead */ - string getTextColumn(sqlite3_stmt *stmt, int col, const char *def = ""); - - typedef unsigned long syncml_time_t; - /** transform column to same time base as used by SyncML libary (typically time()) */ - syncml_time_t getTimeColumn(sqlite3_stmt *stmt, int col); - - /** copies all columns which directly map to a property into the vobj */ - void rowToVObject(sqlite3_stmt *stmt, vocl::VObject &vobj); - - /** database schema to use when creating new databases, may be NULL */ - virtual const char *getDefaultSchema() = 0; - - /** information about the database mapping */ - struct Mapping { - const char *colname; /**< column name in SQL table */ - const char *tablename; /**< name of the SQL table which has this column */ - const char *propname; /**< optional: vcard/vcalendar property which corresponds to this */ - int colindex; /**< determined dynamically in open(): index of the column, -1 if not present */ - }; - - /** - * array with database mapping, terminated by NULL colname: - * variable fields are stored in a copy maintained by the SQLiteSyncSource class - */ - virtual const Mapping *getConstMapping() = 0; - - /** filled in by SQLiteSyncSource::open() */ - arrayptr<Mapping> m_mapping; - - /** after opening: current databse */ - eptr<sqlite3> m_db; -}; - -#endif // ENABLE_SQLITE -#endif // INCL_SQLITESYNCSOURCE |