1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_connectivity.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <rtl/ustring.hxx> 32*cdf0e10cSrcweir #include <osl/module.h> 33*cdf0e10cSrcweir #include <stdio.h> 34*cdf0e10cSrcweir #define DECLARE_FN_POINTERS 1 35*cdf0e10cSrcweir #include "EApi.h" 36*cdf0e10cSrcweir static const char *eBookLibNames[] = { 37*cdf0e10cSrcweir "libebook-1.2.so.9", // evolution-2.8 38*cdf0e10cSrcweir "libebook-1.2.so.5", // evolution-2.4 and 2.6+ 39*cdf0e10cSrcweir "libebook-1.2.so.3", // evolution-2.2 40*cdf0e10cSrcweir "libebook.so.8" // evolution-2.0 41*cdf0e10cSrcweir }; 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir typedef void (*SymbolFunc) (void); 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir #define SYM_MAP(a) { #a, (SymbolFunc *)&a } 46*cdf0e10cSrcweir static struct { 47*cdf0e10cSrcweir const char *sym_name; 48*cdf0e10cSrcweir SymbolFunc *ref_value; 49*cdf0e10cSrcweir } aApiMap[] = { 50*cdf0e10cSrcweir SYM_MAP( e_contact_field_name ), 51*cdf0e10cSrcweir SYM_MAP( e_contact_get ), 52*cdf0e10cSrcweir SYM_MAP( e_contact_get_type ), 53*cdf0e10cSrcweir SYM_MAP( e_contact_field_id ), 54*cdf0e10cSrcweir SYM_MAP( e_source_peek_name ), 55*cdf0e10cSrcweir SYM_MAP( e_source_get_property ), 56*cdf0e10cSrcweir SYM_MAP( e_source_list_peek_groups ), 57*cdf0e10cSrcweir SYM_MAP( e_source_group_peek_sources ), 58*cdf0e10cSrcweir SYM_MAP( e_book_new ), 59*cdf0e10cSrcweir SYM_MAP( e_book_open ), 60*cdf0e10cSrcweir SYM_MAP( e_book_get_uri ), 61*cdf0e10cSrcweir SYM_MAP( e_book_get_source ), 62*cdf0e10cSrcweir SYM_MAP( e_book_get_addressbooks ), 63*cdf0e10cSrcweir SYM_MAP( e_book_get_contacts ), 64*cdf0e10cSrcweir SYM_MAP( e_book_authenticate_user ), 65*cdf0e10cSrcweir SYM_MAP( e_book_query_field_test ), 66*cdf0e10cSrcweir SYM_MAP( e_book_query_and ), 67*cdf0e10cSrcweir SYM_MAP( e_book_query_or ), 68*cdf0e10cSrcweir SYM_MAP( e_book_query_not ), 69*cdf0e10cSrcweir SYM_MAP( e_book_query_ref ), 70*cdf0e10cSrcweir SYM_MAP( e_book_query_unref ), 71*cdf0e10cSrcweir SYM_MAP( e_book_query_from_string ), 72*cdf0e10cSrcweir SYM_MAP( e_book_query_to_string ), 73*cdf0e10cSrcweir SYM_MAP( e_book_query_field_exists ), 74*cdf0e10cSrcweir SYM_MAP( e_source_group_peek_base_uri) 75*cdf0e10cSrcweir }; 76*cdf0e10cSrcweir #undef SYM_MAP 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir static bool 79*cdf0e10cSrcweir tryLink( oslModule &aModule, const char *pName ) 80*cdf0e10cSrcweir { 81*cdf0e10cSrcweir for( guint i = 0; i < G_N_ELEMENTS( aApiMap ); i++ ) 82*cdf0e10cSrcweir { 83*cdf0e10cSrcweir SymbolFunc aMethod; 84*cdf0e10cSrcweir aMethod = (SymbolFunc) osl_getFunctionSymbol 85*cdf0e10cSrcweir ( aModule, rtl::OUString::createFromAscii ( aApiMap[ i ].sym_name ).pData ); 86*cdf0e10cSrcweir if( !aMethod ) 87*cdf0e10cSrcweir { 88*cdf0e10cSrcweir fprintf( stderr, "Warning: missing symbol '%s' in '%s'", 89*cdf0e10cSrcweir aApiMap[ i ].sym_name, pName ); 90*cdf0e10cSrcweir return false; 91*cdf0e10cSrcweir } 92*cdf0e10cSrcweir * aApiMap[ i ].ref_value = aMethod; 93*cdf0e10cSrcweir } 94*cdf0e10cSrcweir return true; 95*cdf0e10cSrcweir } 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir bool EApiInit() 98*cdf0e10cSrcweir { 99*cdf0e10cSrcweir oslModule aModule; 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir for( guint j = 0; j < G_N_ELEMENTS( eBookLibNames ); j++ ) 102*cdf0e10cSrcweir { 103*cdf0e10cSrcweir aModule = osl_loadModule( rtl::OUString::createFromAscii 104*cdf0e10cSrcweir ( eBookLibNames[ j ] ).pData, 105*cdf0e10cSrcweir SAL_LOADMODULE_DEFAULT ); 106*cdf0e10cSrcweir if( aModule) 107*cdf0e10cSrcweir { 108*cdf0e10cSrcweir if ( tryLink( aModule, eBookLibNames[ j ] ) ) 109*cdf0e10cSrcweir return true; 110*cdf0e10cSrcweir osl_unloadModule( aModule ); 111*cdf0e10cSrcweir } 112*cdf0e10cSrcweir } 113*cdf0e10cSrcweir fprintf( stderr, "Can find no compliant libebook client libraries\n" ); 114*cdf0e10cSrcweir return false; 115*cdf0e10cSrcweir } 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir #if 0 118*cdf0e10cSrcweir // hjs: SOLARDEF does no longer exist please lookup the required 119*cdf0e10cSrcweir // defines in a regular compile line 120*cdf0e10cSrcweir /* 121*cdf0e10cSrcweir * Test code - enable & 122*cdf0e10cSrcweir * 123*cdf0e10cSrcweir * Compile with ( after source LinuxIntelEnv.Set.sh ) 124*cdf0e10cSrcweir gcc $SOLARDEF -I $SOLARVER/$UPD/$INPATH/inc \ 125*cdf0e10cSrcweir -I. `pkg-config --cflags --libs gobject-2.0` \ 126*cdf0e10cSrcweir -L $SOLARVER/$UPD/$INPATH/lib -luno_sal -lstdc++ EApi.cxx 127*cdf0e10cSrcweir */ 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir int main( int argc, char **argv) 130*cdf0e10cSrcweir { 131*cdf0e10cSrcweir return EApiInit(); 132*cdf0e10cSrcweir } 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir #endif 135*cdf0e10cSrcweir 136