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
This commit is contained in:
committed by
Michael Meeks
parent
c20518286c
commit
b2983b4653
@@ -63,7 +63,7 @@ static ApiMap aCommonApiMap[] =
|
||||
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 @@ static ApiMap aOldApiMap[] =
|
||||
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 @@ static ApiMap aNewApiMap[] =
|
||||
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 @@ bool EApiInit()
|
||||
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;
|
||||
|
@@ -147,6 +147,7 @@ EAPI_EXTERN const gchar* (*eds_check_version) (guint required_major, guint requi
|
||||
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);
|
||||
|
@@ -411,7 +411,7 @@ public:
|
||||
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));
|
||||
@@ -479,6 +479,21 @@ public:
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
class OEvoabVersion35Helper : public OEvoabVersionHelper
|
||||
@@ -614,7 +629,9 @@ OEvoabResultSet::OEvoabResultSet( OCommonStatement* pStmt, OEvoabConnection *pCo
|
||||
,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;
|
||||
|
Reference in New Issue
Block a user