added configurable hacks for Maemo (--enable-maemo):

- set the (non-standard!) DBUS_DEFAULT_TIMEOUT; see dbus-timeout.patch
- wrap e_book_from_string() to fix invalid parameter
- don't use UTF-8 encoding in Perl script


git-svn-id: https://zeitsenke.de/svn/SyncEvolution/trunk@327 15ad00c4-1369-45f4-8270-35d70d36bdcd
This commit is contained in:
Patrick Ohly 2007-03-24 15:47:22 +00:00
parent 943a04bdab
commit e959f943f1
4 changed files with 107 additions and 1 deletions

View File

@ -42,6 +42,17 @@ AC_ARG_ENABLE(static-cxx,
[build executables which contain libstdc++ instead of requiring suitable libstdc++.so to run]),
enable_static_cxx="$enableval", enable_static_cxx="no")
# Maemo hacks:
# - set the (non-standard!) DBUS_DEFAULT_TIMEOUT
# - wrap e_book_from_string() to fix invalid parameter
# - don't use UTF-8 encoding in Perl script
AC_ARG_ENABLE(maemo,
AS_HELP_STRING([--enable-maemo],
[enables some hacks which work around problems with the Maemo 2.0 until at least 3.0 EDS-Dbus]),
[AC_DEFINE(ENABLE_MAEMO, 1, [enable Maemo hacks])
MODIFY_SYNCCOMPARE='-e "s/use encoding/#use encoding/;" -e s/:utf8//'])
AC_SUBST(MODIFY_SYNCCOMPARE)
AC_CHECK_HEADERS(signal.h)
# cppunit needed?

58
dbus-timeout.patch Normal file
View File

@ -0,0 +1,58 @@
diff -c dbus-0.61/dbus.orig/dbus-connection.c dbus-0.61/dbus/dbus-connection.c
*** dbus-0.61/dbus.orig/dbus-connection.c 2007-03-03 16:13:20.000000000 +0100
--- dbus-0.61/dbus/dbus-connection.c 2007-03-03 16:14:11.000000000 +0100
***************
*** 4758,4761 ****
--- 4758,4784 ----
return res;
}
+
+ /**
+ * 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.
+ */
+ 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;
+ }
+
+ return timeout;
+ }
+
/** @} */
diff -c dbus-0.61/dbus.orig/dbus-connection-internal.h dbus-0.61/dbus/dbus-connection-internal.h
*** dbus-0.61/dbus.orig/dbus-connection-internal.h 2007-03-03 16:13:20.000000000 +0100
--- dbus-0.61/dbus/dbus-connection-internal.h 2007-03-03 16:14:11.000000000 +0100
***************
*** 44,51 ****
} DBusIterationFlags;
/** default timeout value when waiting for a message reply, 25 seconds */
! #define _DBUS_DEFAULT_TIMEOUT_VALUE (25 * 1000)
void _dbus_connection_lock (DBusConnection *connection);
void _dbus_connection_unlock (DBusConnection *connection);
DBusConnection * _dbus_connection_ref_unlocked (DBusConnection *connection);
--- 44,52 ----
} DBusIterationFlags;
/** default timeout value when waiting for a message reply, 25 seconds */
! #define _DBUS_DEFAULT_TIMEOUT_VALUE _dbus_connection_default_timeout()
+ int _dbus_connection_default_timeout (void);
void _dbus_connection_lock (DBusConnection *connection);
void _dbus_connection_unlock (DBusConnection *connection);
DBusConnection * _dbus_connection_ref_unlocked (DBusConnection *connection);
Common subdirectories: dbus-0.61/dbus.orig/.deps and dbus-0.61/dbus/.deps
Common subdirectories: dbus-0.61/dbus.orig/.libs and dbus-0.61/dbus/.libs

View File

@ -18,7 +18,7 @@ MAINTAINERCLEANFILES = Makefile.in
CLEANFILES = libstdc++.a
synccompare : normalize_vcard.pl
cp $< $@
perl -p -e '' @MODIFY_SYNCCOMPARE@ $< >$@
chmod u+x $@
VOCL_SOURCES = \

View File

@ -33,6 +33,31 @@ using namespace std;
#include "EvolutionSyncSource.h"
#include "EvolutionSyncClient.h"
#if defined(ENABLE_MAEMO) && defined (ENABLE_EBOOK)
#include <dlfcn.h>
extern "C" EContact *e_contact_new_from_vcard(const char *vcard)
{
static typeof(e_contact_new_from_vcard) *impl;
if (!impl) {
impl = (typeof(impl))dlsym(RTLD_NEXT, "e_contact_new_from_vcard");
}
// Old versions of EDS-DBus parse_changes_array() call
// e_contact_new_from_vcard() with a pointer which starts
// with a line break; Evolution is not happy with that and
// refuses to parse it. This code forwards until it finds
// the first non-whitespace, presumably the BEGIN:VCARD.
while (*vcard && isspace(*vcard)) {
vcard++;
}
return impl ? impl(vcard) : NULL;
}
#endif
/**
* list all known data sources of a certain type
*/
@ -50,6 +75,18 @@ static void listSources( EvolutionSyncSource &syncSource, const string &header )
int main( int argc, char **argv )
{
#ifdef ENABLE_MAEMO
// EDS-DBus uses potentially long-running calls which may fail due
// to the default 25s timeout. Some of these can be replaced by
// their async version, but e_book_async_get_changes() still
// triggered it.
//
// The workaround for this is to link the binary against a libdbus
// which has the dbus-timeout.patch and thus let's users and
// the application increase the default timeout.
setenv("DBUS_DEFAULT_TIMEOUT", "600000", 0);
#endif
#ifdef HAVE_GLIB
// this is required on Maemo and does not harm either on a normal
// desktop system with Evolution