Hi,
I have submitted a patch for review:
https://gerrit.libreoffice.org/2598
To pull it, you can do:
git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/98/2598/1
evoab2: Follow API changes in EDS 3.8
EDS 3.8 deprecates e_book_client_new() and replaces it with various
e_book_client_connect() functions. This patch follows the change
and enables direct read access for the addressbook. That means
instead of receiving contacts via the D-Bus session bus, the
connectivity driver now directly accesses the underlaying SQLite
data base (for reading).
This patch also shuffles code in EApiInit() slightly to avoid
excessive if/else nesting.
Change-Id: If41fb92eed2ea26bbf2d3125a9ba2250f142c5a2
---
M connectivity/source/drivers/evoab2/EApi.cxx
M connectivity/source/drivers/evoab2/EApi.h
M connectivity/source/drivers/evoab2/NResultSet.cxx
3 files changed, 53 insertions(+), 12 deletions(-)
diff --git a/connectivity/source/drivers/evoab2/EApi.cxx
b/connectivity/source/drivers/evoab2/EApi.cxx
index 987510c..8b7b5cd 100644
--- a/connectivity/source/drivers/evoab2/EApi.cxx
+++ b/connectivity/source/drivers/evoab2/EApi.cxx
@@ -63,7 +63,7 @@
SYM_MAP( e_book_query_field_exists )
};
-//< 3-6 api
+//< 3.6 api
static ApiMap aOldApiMap[] =
{
SYM_MAP( e_book_get_addressbooks ),
@@ -76,7 +76,7 @@
SYM_MAP( e_source_group_peek_sources )
};
-//>= 3-6 api
+//>= 3.6 api
static ApiMap aNewApiMap[] =
{
SYM_MAP( e_source_registry_list_sources ),
@@ -87,12 +87,24 @@
SYM_MAP( e_source_get_display_name ),
SYM_MAP( e_source_get_uid ),
SYM_MAP( e_source_registry_ref_source),
- SYM_MAP( e_book_client_new ),
SYM_MAP( e_client_open_sync ),
SYM_MAP( e_client_get_source ),
SYM_MAP( e_book_client_get_contacts_sync ),
SYM_MAP( e_client_util_free_object_slist )
};
+
+//== indirect read access (3.6 only)
+static ApiMap aClientApiMap36[] =
+{
+ SYM_MAP( e_book_client_new )
+};
+
+//>= direct read access API (>= 3.8)
+static ApiMap aClientApiMap38[] =
+{
+ SYM_MAP( e_book_client_connect_direct_sync )
+};
+
#undef SYM_MAP
template<size_t N> static bool
@@ -122,22 +134,33 @@
aModule = osl_loadModule( rtl::OUString::createFromAscii
( eBookLibNames[ j ] ).pData,
SAL_LOADMODULE_DEFAULT );
- if( aModule)
+
+ if( aModule == NULL)
+ continue;
+
+ if (tryLink( aModule, eBookLibNames[ j ], aCommonApiMap))
{
- if (tryLink( aModule, eBookLibNames[ j ], aCommonApiMap))
+ if (eds_check_version( 3, 6, 0 ) != NULL)
{
- if (eds_check_version(3, 6, 0) == NULL)
+ if (tryLink( aModule, eBookLibNames[ j ], aOldApiMap))
+ return true;
+ }
+ else if (tryLink( aModule, eBookLibNames[ j ], aNewApiMap))
+ {
+ if (eds_check_version( 3, 7, 6 ) != NULL)
{
- if (tryLink( aModule, eBookLibNames[ j ], aNewApiMap))
+ if (tryLink( aModule, eBookLibNames[ j ], aClientApiMap36))
return true;
}
- else if (tryLink( aModule, eBookLibNames[ j ], aOldApiMap))
+ else
{
- return true;
+ if (tryLink( aModule, eBookLibNames[ j ], aClientApiMap38))
+ return true;
}
}
- osl_unloadModule( aModule );
}
+
+ osl_unloadModule( aModule );
}
fprintf( stderr, "Can find no compliant libebook client libraries\n" );
return false;
diff --git a/connectivity/source/drivers/evoab2/EApi.h b/connectivity/source/drivers/evoab2/EApi.h
index 8d188a9..59e2c3a 100644
--- a/connectivity/source/drivers/evoab2/EApi.h
+++ b/connectivity/source/drivers/evoab2/EApi.h
@@ -147,6 +147,7 @@
EAPI_EXTERN const gchar* (*e_source_get_uid) (ESource *source);
EAPI_EXTERN ESource* (*e_source_registry_ref_source) (ESourceRegistry *registry, const gchar *uid);
EAPI_EXTERN EBookClient* (*e_book_client_new) (ESource *source, GError **error);
+EAPI_EXTERN EBookClient* (*e_book_client_connect_direct_sync) (ESourceRegistry *registry, ESource
*source, GCancellable *cancellable, GError **error);
EAPI_EXTERN gboolean (*e_client_open_sync) (EClient *client, gboolean only_if_exists, GCancellable
*cancellable, GError **error);
EAPI_EXTERN ESource* (*e_client_get_source) (EClient *client);
EAPI_EXTERN gboolean (*e_book_client_get_contacts_sync) (EBookClient *client, const gchar *sexp,
GSList **contacts, GCancellable *cancellable, GError **error);
diff --git a/connectivity/source/drivers/evoab2/NResultSet.cxx
b/connectivity/source/drivers/evoab2/NResultSet.cxx
index 154db40..f3a5ca3 100644
--- a/connectivity/source/drivers/evoab2/NResultSet.cxx
+++ b/connectivity/source/drivers/evoab2/NResultSet.cxx
@@ -411,7 +411,7 @@
return NULL;
ESource *pSource = e_source_registry_ref_source(get_e_source_registry(), id);
- EBookClient *pBook = pSource ? e_book_client_new (pSource, NULL) : NULL;
+ EBookClient *pBook = pSource ? createClient (pSource) : NULL;
if (pBook && !e_client_open_sync (pBook, TRUE, NULL, NULL))
{
g_object_unref (G_OBJECT (pBook));
@@ -478,6 +478,21 @@
m_pContacts = g_slist_sort_with_data( m_pContacts, &CompareContacts,
const_cast< gpointer >( static_cast< gconstpointer >( &_rCompData ) ) );
+ }
+
+protected:
+ virtual EBookClient * createClient( ESource *pSource )
+ {
+ return e_book_client_new (pSource, NULL);
+ }
+};
+
+class OEvoabVersion38Helper : public OEvoabVersion36Helper
+{
+protected:
+ virtual EBookClient * createClient( ESource *pSource )
+ {
+ return e_book_client_connect_direct_sync (get_e_source_registry (), pSource, NULL, NULL);
}
};
@@ -614,7 +629,9 @@
,m_nIndex(-1)
,m_nLength(0)
{
- if (eds_check_version(3, 6, 0) == NULL)
+ if (eds_check_version( 3, 7, 6 ) == NULL)
+ m_pVersionHelper = new OEvoabVersion38Helper;
+ else if (eds_check_version( 3, 6, 0 ) == NULL)
m_pVersionHelper = new OEvoabVersion36Helper;
else
m_pVersionHelper = new OEvoabVersion35Helper;
--
To view, visit https://gerrit.libreoffice.org/2598
To unsubscribe, visit https://gerrit.libreoffice.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If41fb92eed2ea26bbf2d3125a9ba2250f142c5a2
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Mathias Hasselmann <mathias@openismus.com>
Context
- [PATCH] evoab2: Follow API changes in EDS 3.8 · Mathias Hasselmann (via Code Review)
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.