1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #include <rtl/ustring.hxx>
20 #include <osl/module.hxx>
21 #define DECLARE_FN_POINTERS 1
23 static const char *eBookLibNames
[] = {
24 "libebook-1.2.so.20", // evolution-data-server 3.33.2+
25 "libebook-1.2.so.19", // evolution-data-server 3.24+
28 "libebook-1.2.so.14", // bumped again (evolution-3.6)
29 "libebook-1.2.so.13", // bumped again (evolution-3.4)
30 "libebook-1.2.so.12", // bumped again
31 "libebook-1.2.so.10", // bumped again
32 "libebook-1.2.so.9", // evolution-2.8
33 "libebook-1.2.so.5", // evolution-2.4 and 2.6+
34 "libebook-1.2.so.3", // evolution-2.2
35 "libebook.so.8" // evolution-2.0
38 typedef void (*SymbolFunc
) ();
40 #define SYM_MAP(a) { #a, reinterpret_cast<SymbolFunc *>(&a) }
47 SymbolFunc
*ref_value
;
52 const ApiMap aCommonApiMap
[] =
54 SYM_MAP( eds_check_version
),
55 SYM_MAP( e_contact_field_name
),
56 SYM_MAP( e_contact_get
),
57 SYM_MAP( e_contact_get_type
),
58 SYM_MAP( e_contact_field_id
),
59 SYM_MAP( e_book_new
),
60 SYM_MAP( e_book_open
),
61 SYM_MAP( e_book_get_source
),
62 SYM_MAP( e_book_get_contacts
),
63 SYM_MAP( e_book_query_field_test
),
64 SYM_MAP( e_book_query_and
),
65 SYM_MAP( e_book_query_or
),
66 SYM_MAP( e_book_query_not
),
67 SYM_MAP( e_book_query_ref
),
68 SYM_MAP( e_book_query_unref
),
69 SYM_MAP( e_book_query_from_string
),
70 SYM_MAP( e_book_query_to_string
),
71 SYM_MAP( e_book_query_field_exists
)
75 const ApiMap aOldApiMap
[] =
77 SYM_MAP( e_book_get_addressbooks
),
78 SYM_MAP( e_book_get_uri
),
79 SYM_MAP( e_book_authenticate_user
),
80 SYM_MAP( e_source_group_peek_base_uri
),
81 SYM_MAP( e_source_peek_name
),
82 SYM_MAP( e_source_get_property
),
83 SYM_MAP( e_source_list_peek_groups
),
84 SYM_MAP( e_source_group_peek_sources
)
88 const ApiMap aNewApiMap
[] =
90 SYM_MAP( e_source_registry_list_sources
),
91 SYM_MAP( e_source_registry_new_sync
),
92 SYM_MAP( e_source_has_extension
),
93 SYM_MAP( e_source_get_extension
),
94 SYM_MAP( e_source_backend_get_backend_name
),
95 SYM_MAP( e_source_get_display_name
),
96 SYM_MAP( e_source_get_uid
),
97 SYM_MAP( e_source_registry_ref_source
),
98 SYM_MAP( e_client_open_sync
),
99 SYM_MAP( e_client_get_source
),
100 SYM_MAP( e_book_client_get_contacts_sync
),
101 SYM_MAP( e_client_util_free_object_slist
)
104 //== indirect read access (3.6 only)
105 const ApiMap aClientApiMap36
[] =
107 SYM_MAP( e_book_client_new
)
110 //>= direct read access API (>= 3.8)
111 const ApiMap aClientApiMap38
[] =
113 SYM_MAP( e_book_client_connect_direct_sync
)
118 template<size_t N
> static bool
119 tryLink( osl::Module
&rModule
, const char *pName
, const ApiMap (&pMap
)[N
])
121 for (size_t i
= 0; i
< N
; ++i
)
123 SymbolFunc aMethod
= reinterpret_cast<SymbolFunc
>(
124 rModule
.getFunctionSymbol(OUString::createFromAscii(pMap
[i
].sym_name
)));
127 fprintf( stderr
, "Warning: missing symbol '%s' in '%s'\n",
128 pMap
[ i
].sym_name
, pName
);
131 *pMap
[ i
].ref_value
= aMethod
;
138 for( guint j
= 0; j
< G_N_ELEMENTS( eBookLibNames
); j
++ )
140 osl::Module
aModule(OUString::createFromAscii(eBookLibNames
[j
]), SAL_LOADMODULE_DEFAULT
);
145 if (tryLink( aModule
, eBookLibNames
[ j
], aCommonApiMap
))
147 if (eds_check_version( 3, 6, 0 ) != nullptr)
149 if (tryLink( aModule
, eBookLibNames
[ j
], aOldApiMap
))
155 else if (tryLink( aModule
, eBookLibNames
[ j
], aNewApiMap
))
157 if (eds_check_version( 3, 7, 6 ) != nullptr)
159 if (tryLink( aModule
, eBookLibNames
[ j
], aClientApiMap36
))
167 if (tryLink( aModule
, eBookLibNames
[ j
], aClientApiMap38
))
176 fprintf( stderr
, "Can find no compliant libebook client libraries\n" );
180 ESourceRegistry
*get_e_source_registry()
182 static ESourceRegistry
*theInstance
= e_source_registry_new_sync(nullptr, nullptr);
186 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */