1*b1cdbd2cSJim Jagielski /**************************************************************
2*b1cdbd2cSJim Jagielski *
3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one
4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file
5*b1cdbd2cSJim Jagielski * distributed with this work for additional information
6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file
7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the
8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance
9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at
10*b1cdbd2cSJim Jagielski *
11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0
12*b1cdbd2cSJim Jagielski *
13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing,
14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an
15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the
17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations
18*b1cdbd2cSJim Jagielski * under the License.
19*b1cdbd2cSJim Jagielski *
20*b1cdbd2cSJim Jagielski *************************************************************/
21*b1cdbd2cSJim Jagielski
22*b1cdbd2cSJim Jagielski
23*b1cdbd2cSJim Jagielski
24*b1cdbd2cSJim Jagielski // MARKER(update_precomp.py): autogen include statement, do not remove
25*b1cdbd2cSJim Jagielski #include "precompiled_connectivity.hxx"
26*b1cdbd2cSJim Jagielski
27*b1cdbd2cSJim Jagielski #include <rtl/ustring.hxx>
28*b1cdbd2cSJim Jagielski #include <osl/module.h>
29*b1cdbd2cSJim Jagielski #include <stdio.h>
30*b1cdbd2cSJim Jagielski #define DECLARE_FN_POINTERS 1
31*b1cdbd2cSJim Jagielski #include "EApi.h"
32*b1cdbd2cSJim Jagielski static const char *eBookLibNames[] = {
33*b1cdbd2cSJim Jagielski "libebook-1.2.so.9", // evolution-2.8
34*b1cdbd2cSJim Jagielski "libebook-1.2.so.5", // evolution-2.4 and 2.6+
35*b1cdbd2cSJim Jagielski "libebook-1.2.so.3", // evolution-2.2
36*b1cdbd2cSJim Jagielski "libebook.so.8" // evolution-2.0
37*b1cdbd2cSJim Jagielski };
38*b1cdbd2cSJim Jagielski
39*b1cdbd2cSJim Jagielski typedef void (*SymbolFunc) (void);
40*b1cdbd2cSJim Jagielski
41*b1cdbd2cSJim Jagielski #define SYM_MAP(a) { #a, (SymbolFunc *)&a }
42*b1cdbd2cSJim Jagielski static struct {
43*b1cdbd2cSJim Jagielski const char *sym_name;
44*b1cdbd2cSJim Jagielski SymbolFunc *ref_value;
45*b1cdbd2cSJim Jagielski } aApiMap[] = {
46*b1cdbd2cSJim Jagielski SYM_MAP( e_contact_field_name ),
47*b1cdbd2cSJim Jagielski SYM_MAP( e_contact_get ),
48*b1cdbd2cSJim Jagielski SYM_MAP( e_contact_get_type ),
49*b1cdbd2cSJim Jagielski SYM_MAP( e_contact_field_id ),
50*b1cdbd2cSJim Jagielski SYM_MAP( e_source_peek_name ),
51*b1cdbd2cSJim Jagielski SYM_MAP( e_source_get_property ),
52*b1cdbd2cSJim Jagielski SYM_MAP( e_source_list_peek_groups ),
53*b1cdbd2cSJim Jagielski SYM_MAP( e_source_group_peek_sources ),
54*b1cdbd2cSJim Jagielski SYM_MAP( e_book_new ),
55*b1cdbd2cSJim Jagielski SYM_MAP( e_book_open ),
56*b1cdbd2cSJim Jagielski SYM_MAP( e_book_get_uri ),
57*b1cdbd2cSJim Jagielski SYM_MAP( e_book_get_source ),
58*b1cdbd2cSJim Jagielski SYM_MAP( e_book_get_addressbooks ),
59*b1cdbd2cSJim Jagielski SYM_MAP( e_book_get_contacts ),
60*b1cdbd2cSJim Jagielski SYM_MAP( e_book_authenticate_user ),
61*b1cdbd2cSJim Jagielski SYM_MAP( e_book_query_field_test ),
62*b1cdbd2cSJim Jagielski SYM_MAP( e_book_query_and ),
63*b1cdbd2cSJim Jagielski SYM_MAP( e_book_query_or ),
64*b1cdbd2cSJim Jagielski SYM_MAP( e_book_query_not ),
65*b1cdbd2cSJim Jagielski SYM_MAP( e_book_query_ref ),
66*b1cdbd2cSJim Jagielski SYM_MAP( e_book_query_unref ),
67*b1cdbd2cSJim Jagielski SYM_MAP( e_book_query_from_string ),
68*b1cdbd2cSJim Jagielski SYM_MAP( e_book_query_to_string ),
69*b1cdbd2cSJim Jagielski SYM_MAP( e_book_query_field_exists ),
70*b1cdbd2cSJim Jagielski SYM_MAP( e_source_group_peek_base_uri)
71*b1cdbd2cSJim Jagielski };
72*b1cdbd2cSJim Jagielski #undef SYM_MAP
73*b1cdbd2cSJim Jagielski
74*b1cdbd2cSJim Jagielski static bool
tryLink(oslModule & aModule,const char * pName)75*b1cdbd2cSJim Jagielski tryLink( oslModule &aModule, const char *pName )
76*b1cdbd2cSJim Jagielski {
77*b1cdbd2cSJim Jagielski for( guint i = 0; i < G_N_ELEMENTS( aApiMap ); i++ )
78*b1cdbd2cSJim Jagielski {
79*b1cdbd2cSJim Jagielski SymbolFunc aMethod;
80*b1cdbd2cSJim Jagielski aMethod = (SymbolFunc) osl_getFunctionSymbol
81*b1cdbd2cSJim Jagielski ( aModule, rtl::OUString::createFromAscii ( aApiMap[ i ].sym_name ).pData );
82*b1cdbd2cSJim Jagielski if( !aMethod )
83*b1cdbd2cSJim Jagielski {
84*b1cdbd2cSJim Jagielski fprintf( stderr, "Warning: missing symbol '%s' in '%s'",
85*b1cdbd2cSJim Jagielski aApiMap[ i ].sym_name, pName );
86*b1cdbd2cSJim Jagielski return false;
87*b1cdbd2cSJim Jagielski }
88*b1cdbd2cSJim Jagielski * aApiMap[ i ].ref_value = aMethod;
89*b1cdbd2cSJim Jagielski }
90*b1cdbd2cSJim Jagielski return true;
91*b1cdbd2cSJim Jagielski }
92*b1cdbd2cSJim Jagielski
EApiInit()93*b1cdbd2cSJim Jagielski bool EApiInit()
94*b1cdbd2cSJim Jagielski {
95*b1cdbd2cSJim Jagielski oslModule aModule;
96*b1cdbd2cSJim Jagielski
97*b1cdbd2cSJim Jagielski for( guint j = 0; j < G_N_ELEMENTS( eBookLibNames ); j++ )
98*b1cdbd2cSJim Jagielski {
99*b1cdbd2cSJim Jagielski aModule = osl_loadModule( rtl::OUString::createFromAscii
100*b1cdbd2cSJim Jagielski ( eBookLibNames[ j ] ).pData,
101*b1cdbd2cSJim Jagielski SAL_LOADMODULE_DEFAULT );
102*b1cdbd2cSJim Jagielski if( aModule)
103*b1cdbd2cSJim Jagielski {
104*b1cdbd2cSJim Jagielski if ( tryLink( aModule, eBookLibNames[ j ] ) )
105*b1cdbd2cSJim Jagielski return true;
106*b1cdbd2cSJim Jagielski osl_unloadModule( aModule );
107*b1cdbd2cSJim Jagielski }
108*b1cdbd2cSJim Jagielski }
109*b1cdbd2cSJim Jagielski fprintf( stderr, "Can find no compliant libebook client libraries\n" );
110*b1cdbd2cSJim Jagielski return false;
111*b1cdbd2cSJim Jagielski }
112*b1cdbd2cSJim Jagielski
113*b1cdbd2cSJim Jagielski #if 0
114*b1cdbd2cSJim Jagielski // hjs: SOLARDEF does no longer exist please lookup the required
115*b1cdbd2cSJim Jagielski // defines in a regular compile line
116*b1cdbd2cSJim Jagielski /*
117*b1cdbd2cSJim Jagielski * Test code - enable &
118*b1cdbd2cSJim Jagielski *
119*b1cdbd2cSJim Jagielski * Compile with ( after source LinuxIntelEnv.Set.sh )
120*b1cdbd2cSJim Jagielski gcc $SOLARDEF -I $SOLARVER/$UPD/$INPATH/inc \
121*b1cdbd2cSJim Jagielski -I. `pkg-config --cflags --libs gobject-2.0` \
122*b1cdbd2cSJim Jagielski -L $SOLARVER/$UPD/$INPATH/lib -luno_sal -lstdc++ EApi.cxx
123*b1cdbd2cSJim Jagielski */
124*b1cdbd2cSJim Jagielski
125*b1cdbd2cSJim Jagielski int main( int argc, char **argv)
126*b1cdbd2cSJim Jagielski {
127*b1cdbd2cSJim Jagielski return EApiInit();
128*b1cdbd2cSJim Jagielski }
129*b1cdbd2cSJim Jagielski
130*b1cdbd2cSJim Jagielski #endif
131*b1cdbd2cSJim Jagielski
132