File modem-manager-gui-0.0.17.1-fix-libebook-api-break.patch of Package modem-manager-gui
diff -rupN modem-manager-gui-0.0.17.1.old/src/addressbooks.c modem-manager-gui-0.0.17.1/src/addressbooks.c
--- modem-manager-gui-0.0.17.1.old/src/addressbooks.c 2014-08-28 15:04:24.000000000 +0400
+++ modem-manager-gui-0.0.17.1/src/addressbooks.c 2015-04-25 21:10:05.137967000 +0300
@@ -36,6 +36,8 @@
#include "vcard.h"
#include "addressbooks.h"
+#define MMGUI_ADDRESSBOOKS_GNOME_CONNECT_TIMEOUT 15
+
#define MMGUI_ADDRESSBOOKS_AKONADI_LINK_PATH "%s/.local/share/akonadi/socket-localhost"
#define MMGUI_ADDRESSBOOKS_AKONADI_SOCKET_PATH "%s/akonadiserver.socket"
#define MMGUI_ADDRESSBOOKS_AKONADI_DBUS_INTERFACE "org.freedesktop.Akonadi.Control"
@@ -78,7 +80,6 @@ struct _mmgui_addressbooks_akonadi_colle
typedef struct _mmgui_addressbooks_akonadi_collection *mmgui_addressbooks_akonadi_collection_t;
-
//KDE (Akonadi)
static gboolean mmgui_addressbooks_session_service_activate(gchar *interface, guint *status);
static gint mmgui_addressbooks_open_kde_socket(void);
@@ -871,14 +872,25 @@ static gboolean mmgui_addressbooks_get_g
addressbooks->gnomesourcename = "";
}
- if (addressbooks->e_book_client_connect_sync != NULL) {
- /*Version 3.8*/
- client = (EBookClient *)(addressbooks->e_book_client_connect_sync)(source, NULL, &error);
- if (client == NULL) {
- (addressbooks->e_book_query_unref)(query);
- g_debug("Failed to get EBookClient: %s\n", error->message);
- g_error_free(error);
- return FALSE;
+ if ((addressbooks->e_book_client_connect_sync != NULL) || (addressbooks->e_book_client_connect_sync316 != NULL)) {
+ if (addressbooks->gnomelibversion >= 16) {
+ /*Version 3.16 ...*/
+ client = (EBookClient *)(addressbooks->e_book_client_connect_sync316)(source, MMGUI_ADDRESSBOOKS_GNOME_CONNECT_TIMEOUT, NULL, &error);
+ if (client == NULL) {
+ (addressbooks->e_book_query_unref)(query);
+ g_debug("Failed to get EBookClient: %s\n", error->message);
+ g_error_free(error);
+ return FALSE;
+ }
+ } else {
+ /*Version 3.8 ... 3.16*/
+ client = (EBookClient *)(addressbooks->e_book_client_connect_sync)(source, NULL, &error);
+ if (client == NULL) {
+ (addressbooks->e_book_query_unref)(query);
+ g_debug("Failed to get EBookClient: %s\n", error->message);
+ g_error_free(error);
+ return FALSE;
+ }
}
} else {
/*Versions 3.2 ... 3.6*/
@@ -889,7 +901,7 @@ static gboolean mmgui_addressbooks_get_g
g_error_free(error);
return FALSE;
}
-
+
if (!(addressbooks->e_client_open_sync)((EClient *)client, TRUE, NULL, &error)) {
(addressbooks->e_book_query_unref)(query);
g_debug("Failed to open EBookClient: %s\n", error->message);
@@ -941,6 +953,7 @@ static gboolean mmgui_addressbooks_get_g
mmgui_addressbooks_t mmgui_addressbooks_new(mmgui_libpaths_cache_t libcache)
{
mmgui_addressbooks_t addressbooks;
+ gpointer *connectfunc;
gboolean libopened;
guint akonadistatus;
@@ -953,6 +966,7 @@ mmgui_addressbooks_t mmgui_addressbooks_
/*Open module*/
addressbooks->ebookmodule = g_module_open(mmgui_libpaths_cache_get_library_name(libcache, "libebook-1.2"), G_MODULE_BIND_LAZY);
+ addressbooks->gnomelibversion = mmgui_libpaths_cache_get_library_major_version(libcache, "libebook-1.2");
if (addressbooks->ebookmodule != NULL) {
libopened = TRUE;
@@ -974,7 +988,13 @@ mmgui_addressbooks_t mmgui_addressbooks_
addressbooks->e_book_query_to_string = NULL;
addressbooks->e_book_client_get_contacts_sync = NULL;
} else {
- if (!g_module_symbol(addressbooks->ebookmodule, "e_book_client_connect_sync", (gpointer *)&(addressbooks->e_book_client_connect_sync))) {
+ /*API was broken in version 3.16*/
+ if (addressbooks->gnomelibversion >= 16) {
+ connectfunc = (gpointer *)&(addressbooks->e_book_client_connect_sync316);
+ } else {
+ connectfunc = (gpointer *)&(addressbooks->e_book_client_connect_sync);
+ }
+ if (!g_module_symbol(addressbooks->ebookmodule, "e_book_client_connect_sync", connectfunc)) {
/*Since version 3.2 used these functions, but in 3.8 they are deprecated*/
libopened = libopened && g_module_symbol(addressbooks->ebookmodule, "e_book_client_new", (gpointer *)&(addressbooks->e_book_client_new));
libopened = libopened && g_module_symbol(addressbooks->ebookmodule, "e_client_open_sync", (gpointer *)&(addressbooks->e_client_open_sync));
diff -rupN modem-manager-gui-0.0.17.1.old/src/addressbooks.h modem-manager-gui-0.0.17.1/src/addressbooks.h
--- modem-manager-gui-0.0.17.1.old/src/addressbooks.h 2014-08-28 00:24:41.000000000 +0400
+++ modem-manager-gui-0.0.17.1/src/addressbooks.h 2015-04-25 21:00:50.449376000 +0300
@@ -247,6 +247,7 @@ typedef const gchar *(*e_source_get_disp
typedef EBookClient *(*e_book_client_new_func)(ESource *source, GError **error);
typedef gboolean (*e_client_open_sync_func)(EClient *client, gboolean only_if_exists, gpointer cancellable, GError **error);
typedef EClient *(*e_book_client_connect_sync_func)(ESource *source, gpointer cancellable, GError **error);
+typedef EClient *(*e_book_client_connect_sync316_func)(ESource *source, guint32 wait_for_connected_seconds, gpointer cancellable, GError **error);
typedef gchar *(*e_book_query_to_string_func)(EBookQuery *q);
typedef gboolean (*e_book_client_get_contacts_sync_func)(EBookClient *client, const gchar *sexp, GSList **out_contacts, gpointer cancellable, GError **error);
typedef EBook *(*e_book_new_system_addressbook_func)(GError **error);
@@ -269,6 +270,7 @@ struct _mmgui_addressbooks {
e_book_client_new_func e_book_client_new;
e_client_open_sync_func e_client_open_sync;
e_book_client_connect_sync_func e_book_client_connect_sync;
+ e_book_client_connect_sync316_func e_book_client_connect_sync316;
e_book_query_to_string_func e_book_query_to_string;
e_book_client_get_contacts_sync_func e_book_client_get_contacts_sync;
e_book_new_system_addressbook_func e_book_new_system_addressbook;
@@ -280,6 +282,7 @@ struct _mmgui_addressbooks {
e_contact_get_func e_contact_get;
//GNOME stuff
gboolean gnomesupported;
+ gint gnomelibversion;
GSList *gnomecontacts;
const gchar *gnomesourcename;
//Akonadi access data
diff -rupN modem-manager-gui-0.0.17.1.old/src/libpaths.c modem-manager-gui-0.0.17.1/src/libpaths.c
--- modem-manager-gui-0.0.17.1.old/src/libpaths.c 2014-01-05 18:23:44.000000000 +0400
+++ modem-manager-gui-0.0.17.1/src/libpaths.c 2015-04-25 20:40:08.544962000 +0300
@@ -32,6 +32,7 @@
#define MMGUI_LIBPATHS_CACHE_FILE "/etc/ld.so.cache"
#define MMGUI_LIBPATHS_CACHE_SOEXT ".so"
+#define MMGUI_LIBPATHS_CACHE_SOEXT_LEN 3
#define MMGUI_LIBPATHS_CACHE_LIB_TEMP "/usr/lib/%s.so"
#define MMGUI_LIBPATHS_CACHE_PATH_TEMP "/usr/lib/%s.so"
/*Cache file*/
@@ -39,17 +40,21 @@
#define MMGUI_LIBPATHS_LOCAL_CACHE_DIR "modem-manager-gui"
#define MMGUI_LIBPATHS_LOCAL_CACHE_FILE "libpaths.conf"
#define MMGUI_LIBPATHS_LOCAL_CACHE_PERM 0755
+#define MMGUI_LIBPATHS_LOCAL_CACHE_VER 2
/*Cache file sections*/
#define MMGUI_LIBPATHS_FILE_ROOT_SECTION "cache"
#define MMGUI_LIBPATHS_FILE_TIMESTAMP "timestamp"
+#define MMGUI_LIBPATHS_FILE_VERSION "version"
#define MMGUI_LIBPATHS_FILE_NAME "name"
#define MMGUI_LIBPATHS_FILE_PATH "path"
+#define MMGUI_LIBPATHS_FILE_MAJORVER "majorver"
struct _mmgui_libpaths_entry {
gchar *id;
gchar *libname;
gchar *libpath;
+ gint majorver;
};
typedef struct _mmgui_libpaths_entry *mmgui_libpaths_entry_t;
@@ -60,6 +65,7 @@ static gboolean mmgui_libpaths_cache_ope
const gchar *homepath;
gchar *confpath;
guint64 localtimestamp;
+ gint filever;
GError *error;
if (libcache == NULL) return FALSE;
@@ -95,11 +101,28 @@ static gboolean mmgui_libpaths_cache_ope
localtimestamp = g_key_file_get_uint64(libcache->localkeyfile, MMGUI_LIBPATHS_FILE_ROOT_SECTION, MMGUI_LIBPATHS_FILE_TIMESTAMP, &error);
if (error == NULL) {
if (localtimestamp == dbtimestamp) {
- libcache->updatelocal = FALSE;
+ /*Timestamp is up to date - check version*/
+ filever = g_key_file_get_integer(libcache->localkeyfile, MMGUI_LIBPATHS_FILE_ROOT_SECTION, MMGUI_LIBPATHS_FILE_VERSION, &error);
+ if (error == NULL) {
+ if (filever >= MMGUI_LIBPATHS_LOCAL_CACHE_VER) {
+ /*Acceptable version of file*/
+ libcache->updatelocal = FALSE;
+ } else {
+ /*Old version of file*/
+ libcache->updatelocal = TRUE;
+ }
+ } else {
+ /*Unknown version of file*/
+ libcache->updatelocal = TRUE;
+ g_debug("Local cache contain unreadable version identifier: %s", error->message);
+ g_error_free(error);
+ }
} else {
+ /*Wrong timestamp*/
libcache->updatelocal = TRUE;
}
} else {
+ /*Unknown timestamp*/
libcache->updatelocal = TRUE;
g_debug("Local cache contain unreadable timestamp: %s", error->message);
g_error_free(error);
@@ -126,6 +149,8 @@ static gboolean mmgui_libpaths_cache_clo
if (update) {
/*Save timestamp*/
g_key_file_set_int64(libcache->localkeyfile, MMGUI_LIBPATHS_FILE_ROOT_SECTION, MMGUI_LIBPATHS_FILE_TIMESTAMP, (gint64)libcache->modtime);
+ /*Save version of file*/
+ g_key_file_set_integer(libcache->localkeyfile, MMGUI_LIBPATHS_FILE_ROOT_SECTION, MMGUI_LIBPATHS_FILE_VERSION, MMGUI_LIBPATHS_LOCAL_CACHE_VER);
/*Write to file*/
error = NULL;
filedata = g_key_file_to_data(libcache->localkeyfile, &datasize, &error);
@@ -158,6 +183,8 @@ static gboolean mmgui_libpaths_cache_add
if (cachedlib->libpath != NULL) {
g_key_file_set_string(libcache->localkeyfile, cachedlib->id, MMGUI_LIBPATHS_FILE_PATH, cachedlib->libpath);
}
+ /*Library major version*/
+ g_key_file_set_integer(libcache->localkeyfile, cachedlib->id, MMGUI_LIBPATHS_FILE_MAJORVER, cachedlib->majorver);
}
}
@@ -183,8 +210,10 @@ static gboolean mmgui_libpaths_cache_get
}
} else {
cachedlib->libname = NULL;
- g_debug("Local cache does not contain library name: %s", error->message);
- g_error_free(error);
+ if (error != NULL) {
+ g_debug("Local cache does not contain library name: %s", error->message);
+ g_error_free(error);
+ }
}
/*Library path*/
error = NULL;
@@ -197,8 +226,26 @@ static gboolean mmgui_libpaths_cache_get
}
} else {
cachedlib->libpath = NULL;
- g_debug("Local cache does not contain library path: %s", error->message);
- g_error_free(error);
+ if (error != NULL) {
+ g_debug("Local cache does not contain library path: %s", error->message);
+ g_error_free(error);
+ }
+ }
+ /*Library major version*/
+ error = NULL;
+ if (g_key_file_has_key(libcache->localkeyfile, cachedlib->id, MMGUI_LIBPATHS_FILE_MAJORVER, &error)) {
+ error = NULL;
+ cachedlib->majorver = g_key_file_get_integer(libcache->localkeyfile, cachedlib->id, MMGUI_LIBPATHS_FILE_MAJORVER, &error);
+ if (error != NULL) {
+ g_debug("Local cache contain unreadable library major version: %s", error->message);
+ g_error_free(error);
+ }
+ } else {
+ cachedlib->majorver = 0;
+ if (error != NULL) {
+ g_debug("Local cache does not contain library major version: %s", error->message);
+ g_error_free(error);
+ }
}
}
}
@@ -223,6 +270,7 @@ static void mmgui_libpaths_cache_destroy
if (cachedlib->libpath != NULL) {
g_free(cachedlib->libpath);
}
+ cachedlib->majorver = 0;
g_free(cachedlib);
}
@@ -232,6 +280,12 @@ static gboolean mmgui_libpaths_cache_get
gchar *libext, *libid;
guint pathlen, sym, lnsym, lilen, lnlen;
gboolean res;
+ gchar *majorverstart, *majorverend;
+ gsize fragmentlen;
+ gint i, d;
+ guint mult;
+ gchar curdigit;
+ gchar digits[2][10] = {{'0','1','2','3','4','5','6','7','8','9'}, {0,1,2,3,4,5,6,7,8,9}};
if ((libcache == NULL) || (libpath == NULL)) return FALSE;
@@ -281,6 +335,42 @@ static gboolean mmgui_libpaths_cache_get
mmgui_libpaths_cache_add_to_local_cache_file(libcache, cachedlib);
g_debug("Library path: %s (%s)\n", cachedlib->libpath, libid);
}
+
+ cachedlib->majorver = 0;
+
+ if ((libext[MMGUI_LIBPATHS_CACHE_SOEXT_LEN] == '.') && (libext[MMGUI_LIBPATHS_CACHE_SOEXT_LEN+1] != '\0')) {
+ majorverstart = libext + MMGUI_LIBPATHS_CACHE_SOEXT_LEN + 1;
+ majorverend = strchr(majorverstart, '.');
+ if (majorverend != NULL) {
+ fragmentlen = majorverend - majorverstart;
+ } else {
+ fragmentlen = strlen(libext) - (MMGUI_LIBPATHS_CACHE_SOEXT_LEN + 1);
+ }
+
+ if (fragmentlen > 0) {
+ mult = 1;
+ for (i=fragmentlen-1; i>=0; i--) {
+ /*Seqrch for digit*/
+ curdigit = -1;
+ for (d=0; d<10; d++) {
+ if (digits[0][d] == majorverstart[i]) {
+ curdigit = digits[1][d];
+ break;
+ }
+ }
+ /*Add digit*/
+ if (curdigit != -1) {
+ cachedlib->majorver += mult * curdigit;
+ mult *= 10;
+ } else {
+ cachedlib->majorver = 0;
+ break;
+ }
+ }
+ mmgui_libpaths_cache_add_to_local_cache_file(libcache, cachedlib);
+ g_debug("Library version: %i (%s)\n", cachedlib->majorver, libid);
+ }
+ }
res = TRUE;
}
@@ -510,3 +600,20 @@ gchar *mmgui_libpaths_cache_get_library_
return libcache->safename;
}
}
+
+gint mmgui_libpaths_cache_get_library_major_version(mmgui_libpaths_cache_t libcache, gchar *libname)
+{
+ mmgui_libpaths_entry_t cachedlib;
+
+ if ((libcache == NULL) || (libname == NULL)) return 0;
+
+ cachedlib = (mmgui_libpaths_entry_t)g_hash_table_lookup(libcache->cache, libname);
+
+ if (cachedlib != NULL) {
+ /*Cached library version*/
+ return cachedlib->majorver;
+ } else {
+ /*Safe library version*/
+ return 0;
+ }
+}
diff -rupN modem-manager-gui-0.0.17.1.old/src/libpaths.h modem-manager-gui-0.0.17.1/src/libpaths.h
--- modem-manager-gui-0.0.17.1.old/src/libpaths.h 2013-06-17 23:02:10.000000000 +0400
+++ modem-manager-gui-0.0.17.1/src/libpaths.h 2015-04-25 20:40:28.911690000 +0300
@@ -41,5 +41,6 @@ mmgui_libpaths_cache_t mmgui_libpaths_ca
void mmgui_libpaths_cache_close(mmgui_libpaths_cache_t libcache);
gchar *mmgui_libpaths_cache_get_library_name(mmgui_libpaths_cache_t libcache, gchar *libname);
gchar *mmgui_libpaths_cache_get_library_path(mmgui_libpaths_cache_t libcache, gchar *libname);
+gint mmgui_libpaths_cache_get_library_major_version(mmgui_libpaths_cache_t libcache, gchar *libname);
#endif /* __LIBPATHS_H__ */