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