Kaydet (Commit) 0cf743b7 authored tarafından Milan Crha's avatar Milan Crha Kaydeden (comit) Caolán McNamara

sketch out how to port to e-d-s 3.6

Change-Id: I04d2a4d7d1520567dd0eb929ffb5d9fa53d35dd4
üst 13bdce91
...@@ -1075,6 +1075,15 @@ Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getColumns( ...@@ -1075,6 +1075,15 @@ Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getColumns(
return xResultSet; return xResultSet;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
static bool isSourceBackend( ESource *pSource, const char *backendname)
{
if (!pSource || e_source_has_extension (pSource, "Address Book")) // E_SOURCE_EXTENSION_ADDRESS_BOOK
return false;
gpointer extension = e_source_get_extension (pSource, "Address Book"); // E_SOURCE_EXTENSION_ADDRESS_BOOK
return extension && g_strcmp0 (e_source_backend_get_backend_name (extension), backendname) == 0;
}
Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getTables( Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getTables(
const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/,
const ::rtl::OUString& /*tableNamePattern*/, const Sequence< ::rtl::OUString >& types ) throw(SQLException, RuntimeException) const ::rtl::OUString& /*tableNamePattern*/, const Sequence< ::rtl::OUString >& types ) throw(SQLException, RuntimeException)
...@@ -1111,41 +1120,31 @@ Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getTables( ...@@ -1111,41 +1120,31 @@ Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getTables(
ODatabaseMetaDataResultSet::ORows aRows; ODatabaseMetaDataResultSet::ORows aRows;
ESourceList *pSourceList; GSList *pSources;
if( !e_book_get_addressbooks (&pSourceList, NULL) ) pSources = e_source_registry_list_sources (registry, "Address Book"); // E_SOURCE_EXTENSION_ADDRESS_BOOK
pSourceList = NULL;
GSList *g; GList *liter;
for( g = e_source_list_peek_groups( pSourceList ); g; g = g->next) for( liter = pSources; liter; liter = liter->next)
{ {
GSList *s; ESource *pSource = E_SOURCE (liter->data);
const char *p = e_source_group_peek_base_uri(E_SOURCE_GROUP(g->data)); bool can = false;
switch (m_pConnection->getSDBCAddressType()) { switch (m_pConnection->getSDBCAddressType()) {
case SDBCAddress::EVO_GWISE: case SDBCAddress::EVO_GWISE:
if ( !strncmp( "groupwise://", p, 11 )) can = isSourceBackend( pSource, "groupwise"); // not supported in evo/eds 3.6.x+, somehow
break; break;
else
continue;
case SDBCAddress::EVO_LOCAL: case SDBCAddress::EVO_LOCAL:
if ( !strncmp( "file://", p, 6 ) || can = isSourceBackend( pSource, "local");
!strncmp( "local://", p, 6 ) ) break;
break;
else
continue;
case SDBCAddress::EVO_LDAP: case SDBCAddress::EVO_LDAP:
if ( !strncmp( "ldap://", p, 6 )) can = isSourceBackend( pSource, "ldap");
break; break;
else
continue;
case SDBCAddress::Unknown: case SDBCAddress::Unknown:
break; break;
} }
for (s = e_source_group_peek_sources (E_SOURCE_GROUP (g->data)); s; s = s->next)
{
ESource *pSource = E_SOURCE (s->data);
rtl::OUString aName = rtl::OStringToOUString( e_source_peek_name( pSource ), if (can) {
rtl::OUString aName = rtl::OStringToOUString( e_source_get_display_name( pSource ),
RTL_TEXTENCODING_UTF8 ); RTL_TEXTENCODING_UTF8 );
ODatabaseMetaDataResultSet::ORow aRow(3); ODatabaseMetaDataResultSet::ORow aRow(3);
...@@ -1153,10 +1152,12 @@ Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getTables( ...@@ -1153,10 +1152,12 @@ Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getTables(
aRow.push_back(new ORowSetValueDecorator(aName)); aRow.push_back(new ORowSetValueDecorator(aName));
aRow.push_back(new ORowSetValueDecorator(aTable)); aRow.push_back(new ORowSetValueDecorator(aTable));
aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
// add also e_source_get_uid (pSource)
aRows.push_back(aRow); aRows.push_back(aRow);
} }
} }
g_slist_free_full (pSources, g_object_unref);
pResult->setRows(aRows); pResult->setRows(aRows);
return xRef; return xRef;
......
...@@ -126,9 +126,11 @@ OEvoabResultSet::~OEvoabResultSet() ...@@ -126,9 +126,11 @@ OEvoabResultSet::~OEvoabResultSet()
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
static ESource * static ESource *
findSource( const char *name ) findSource( const char *uid )
{ {
ESourceList *pSourceList = NULL; //ideally as
return e_source_registry_ref_source (registry, uid);
/*ESourceList *pSourceList = NULL;
g_return_val_if_fail (name != NULL, NULL); g_return_val_if_fail (name != NULL, NULL);
...@@ -144,51 +146,48 @@ findSource( const char *name ) ...@@ -144,51 +146,48 @@ findSource( const char *name )
return pSource; return pSource;
} }
} }
return NULL; return NULL;*/
} }
static EBook * static EBookClient *
openBook( const char *abname ) openBook( const char *abname )
{ {
ESource *pSource = findSource (abname); ESource *pSource = findSource (abname);
EBook *pBook = NULL; EBookClient *pBook = NULL;
if (pSource) if (pSource)
pBook = e_book_new (pSource, NULL); pBook = e_book_client_new (pSource, NULL);
if (pBook && !e_book_open (pBook, TRUE, NULL)) if (pBook && !e_client_open_sync (pBook, TRUE, NULL, NULL))
{ {
g_object_unref (G_OBJECT (pBook)); g_object_unref (G_OBJECT (pBook));
pBook = NULL; pBook = NULL;
} }
if (pSource)
g_object_unref (pSource);
return pBook; return pBook;
} }
static bool isLDAP( EBook *pBook ) static bool isBookBackend( EBookClient *pBook, const char *backendname)
{ {
return pBook && !strncmp( "ldap://", e_book_get_uri( pBook ), 6 ); ESource *pSource = e_client_get_source ((EClient *) pBook);
}
static bool isLocal( EBook *pBook ) if (!pSource || e_source_has_extension (pSource, "Address Book")) // E_SOURCE_EXTENSION_ADDRESS_BOOK
{ return false;
return pBook && ( !strncmp( "file://", e_book_get_uri( pBook ), 6 ) ||
!strncmp( "local:", e_book_get_uri( pBook ), 6 ) ); gpointer extension = e_source_get_extension (pSource, "Address Book"); // E_SOURCE_EXTENSION_ADDRESS_BOOK
return extension && g_strcmp0 (e_source_backend_get_backend_name (extension), backendname) == 0;
} }
static bool isAuthRequired( EBook *pBook ) static bool isLDAP( EBookClient *pBook )
{ {
return e_source_get_property( e_book_get_source( pBook ), return pBook && isBookBackend( pBook, "ldap" );
"auth" ) != NULL;
} }
static rtl::OString getUserName( EBook *pBook ) static bool isLocal( EBookClient *pBook )
{ {
rtl::OString aName; return pBook && isBookBackend( pBook, "local" );
if( isLDAP( pBook ) )
aName = e_source_get_property( e_book_get_source( pBook ), "binddn" );
else
aName = e_source_get_property( e_book_get_source( pBook ), "user" );
return aName;
} }
static ::rtl::OUString static ::rtl::OUString
...@@ -210,24 +209,17 @@ valueToBool( GValue& _rValue ) ...@@ -210,24 +209,17 @@ valueToBool( GValue& _rValue )
} }
static bool static bool
executeQuery (EBook* pBook, EBookQuery* pQuery, GList **ppList, executeQuery (EBookClient* pBook, EBookQuery* pQuery, GList **ppList,
rtl::OString &rPassword, GError **pError) rtl::OString &rPassword, GError **pError)
{ {
ESource *pSource = e_book_get_source( pBook ); bool bSuccess;
bool bSuccess = false; char *sexp;
bool bAuthSuccess = true;
*ppList = NULL; *ppList = NULL;
if( isAuthRequired( pBook ) ) sexp = e_book_query_to_string( pQuery );
{ bSuccess = e_book_client_get_contacts_sync( pBook, sexp, ppList, pError );
rtl::OString aUser( getUserName( pBook ) ); g_free (sexp);
const char *pAuth = e_source_get_property( pSource, "auth" );
bAuthSuccess = e_book_authenticate_user( pBook, aUser.getStr(), rPassword.getStr(), pAuth, pError );
}
if (bAuthSuccess)
bSuccess = e_book_get_contacts( pBook, pQuery, ppList, pError );
return bSuccess; return bSuccess;
} }
...@@ -507,7 +499,7 @@ void OEvoabResultSet::construct( const QueryData& _rData ) ...@@ -507,7 +499,7 @@ void OEvoabResultSet::construct( const QueryData& _rData )
{ {
ENSURE_OR_THROW( _rData.getQuery(), "internal error: no EBookQuery" ); ENSURE_OR_THROW( _rData.getQuery(), "internal error: no EBookQuery" );
EBook *pBook = openBook(::rtl::OUStringToOString(_rData.sTable, RTL_TEXTENCODING_UTF8).getStr()); EBookClient *pBook = openBook(::rtl::OUStringToOString(_rData.sTable, RTL_TEXTENCODING_UTF8).getStr());
if ( !pBook ) if ( !pBook )
m_pConnection->throwGenericSQLException( STR_CANNOT_OPEN_BOOK, *this ); m_pConnection->throwGenericSQLException( STR_CANNOT_OPEN_BOOK, *this );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment