tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / connectivity / source / drivers / evoab2 / EApi.cxx
blob9ec8e0d44e32c088810486c50576566b657a40f0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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
22 #include "EApi.h"
23 static const char *eBookLibNames[] = {
24 "libebook-1.2.so.21", // evolution-data-server 3.45.2+
25 "libebook-1.2.so.20", // evolution-data-server 3.33.2+
26 "libebook-1.2.so.19", // evolution-data-server 3.24+
27 "libebook-1.2.so.16"
30 typedef void (*SymbolFunc) ();
32 namespace {
34 struct ApiMap
36 const char *sym_name;
37 SymbolFunc *ref_value;
42 const ApiMap aCommonApiMap[] =
44 { "eds_check_version", reinterpret_cast<SymbolFunc *>(&eds_check_version) },
45 { "e_contact_field_name", reinterpret_cast<SymbolFunc *>(&e_contact_field_name) },
46 { "e_contact_get", reinterpret_cast<SymbolFunc *>(&e_contact_get) },
47 { "e_contact_get_type", reinterpret_cast<SymbolFunc *>(&e_contact_get_type) },
48 { "e_contact_field_id", reinterpret_cast<SymbolFunc *>(&e_contact_field_id) },
49 { "e_book_new", reinterpret_cast<SymbolFunc *>(&e_book_new) },
50 { "e_book_open", reinterpret_cast<SymbolFunc *>(&e_book_open) },
51 { "e_book_get_source", reinterpret_cast<SymbolFunc *>(&e_book_get_source) },
52 { "e_book_get_contacts", reinterpret_cast<SymbolFunc *>(&e_book_get_contacts) },
53 { "e_book_query_field_test", reinterpret_cast<SymbolFunc *>(&e_book_query_field_test) },
54 { "e_book_query_and", reinterpret_cast<SymbolFunc *>(&e_book_query_and) },
55 { "e_book_query_or", reinterpret_cast<SymbolFunc *>(&e_book_query_or) },
56 { "e_book_query_not", reinterpret_cast<SymbolFunc *>(&e_book_query_not) },
57 { "e_book_query_ref", reinterpret_cast<SymbolFunc *>(&e_book_query_ref) },
58 { "e_book_query_unref", reinterpret_cast<SymbolFunc *>(&e_book_query_unref) },
59 { "e_book_query_from_string", reinterpret_cast<SymbolFunc *>(&e_book_query_from_string) },
60 { "e_book_query_to_string", reinterpret_cast<SymbolFunc *>(&e_book_query_to_string) },
61 { "e_book_query_field_exists", reinterpret_cast<SymbolFunc *>(&e_book_query_field_exists) }
64 const ApiMap aNewApiMap[] =
66 { "e_source_registry_list_sources", reinterpret_cast<SymbolFunc *>(&e_source_registry_list_sources) },
67 { "e_source_registry_new_sync", reinterpret_cast<SymbolFunc *>(&e_source_registry_new_sync) },
68 { "e_source_has_extension", reinterpret_cast<SymbolFunc *>(&e_source_has_extension) },
69 { "e_source_get_extension", reinterpret_cast<SymbolFunc *>(&e_source_get_extension) },
70 { "e_source_backend_get_backend_name", reinterpret_cast<SymbolFunc *>(&e_source_backend_get_backend_name) },
71 { "e_source_get_display_name", reinterpret_cast<SymbolFunc *>(&e_source_get_display_name) },
72 { "e_source_get_uid", reinterpret_cast<SymbolFunc *>(&e_source_get_uid) },
73 { "e_source_registry_ref_source", reinterpret_cast<SymbolFunc *>(&e_source_registry_ref_source) },
74 { "e_client_open_sync", reinterpret_cast<SymbolFunc *>(&e_client_open_sync) },
75 { "e_client_get_source", reinterpret_cast<SymbolFunc *>(&e_client_get_source) },
76 { "e_book_client_get_contacts_sync", reinterpret_cast<SymbolFunc *>(&e_book_client_get_contacts_sync) },
77 { "e_client_util_free_object_slist", reinterpret_cast<SymbolFunc *>(&e_client_util_free_object_slist) }
80 //>= direct read access API (>= 3.8)
81 const ApiMap aClientApiMap38[] =
83 { "e_book_client_connect_direct_sync", reinterpret_cast<SymbolFunc *>(&e_book_client_connect_direct_sync) }
86 template<size_t N> static bool
87 tryLink( osl::Module &rModule, const char *pName, const ApiMap (&pMap)[N])
89 for (size_t i = 0; i < N; ++i)
91 SymbolFunc aMethod = reinterpret_cast<SymbolFunc>(
92 rModule.getFunctionSymbol(OUString::createFromAscii(pMap[i].sym_name)));
93 if( !aMethod )
95 fprintf( stderr, "Warning: missing symbol '%s' in '%s'\n",
96 pMap[ i ].sym_name, pName );
97 return false;
99 *pMap[ i ].ref_value = aMethod;
101 return true;
104 bool EApiInit()
106 for( guint j = 0; j < G_N_ELEMENTS( eBookLibNames ); j++ )
108 osl::Module aModule(OUString::createFromAscii(eBookLibNames[j]), SAL_LOADMODULE_DEFAULT);
110 if (!aModule.is())
111 continue;
113 if (tryLink( aModule, eBookLibNames[ j ], aCommonApiMap))
115 if (tryLink( aModule, eBookLibNames[ j ], aNewApiMap))
117 if (tryLink( aModule, eBookLibNames[ j ], aClientApiMap38))
119 aModule.release();
120 return true;
125 fprintf( stderr, "Can find no compliant libebook client libraries\n" );
126 return false;
129 ESourceRegistry *get_e_source_registry()
131 static ESourceRegistry *theInstance = e_source_registry_new_sync(nullptr, nullptr);
132 return theInstance;
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */