blob: 5c4ed2fb613e3c70dc094fd6ce1178236c0c1277 [file] [log] [blame]
agsantos520da842020-12-01 16:39:06 -05001/**
2 * Copyright (C) 2020 Savoir-faire Linux Inc.
3 *
4 * Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21#include <iostream>
22#include <string.h>
23#include <thread>
24#include <memory>
25#include <map>
26#include "plugin/jamiplugin.h"
27#include "botchathandler.h"
28
29#ifdef WIN32
30#define EXPORT_PLUGIN __declspec(dllexport)
31#else
32#define EXPORT_PLUGIN
33#endif
34
35#define AutoAnswer_VERSION_MAJOR 0
36#define AutoAnswer_VERSION_MINOR 1
37#define AutoAnswer_VERSION_PATCH 0
38
39extern "C" {
40
41void
42pluginExit(void)
43{}
44
45EXPORT_PLUGIN JAMI_PluginExitFunc
46JAMI_dynPluginInit(const JAMI_PluginAPI* api)
47{
48 std::cout << "******************" << std::endl << std::endl;
49 std::cout << "** AutoAnswer **" << std::endl;
50 std::cout << "******************" << std::endl << std::endl;
51 std::cout << " Version " << AutoAnswer_VERSION_MAJOR << "." << AutoAnswer_VERSION_MINOR << "."
52 << AutoAnswer_VERSION_PATCH << std::endl;
53
54 // If invokeService doesn't return an error
55 if (api) {
56 std::map<std::string, std::string> ppm;
57 api->invokeService(api, "getPluginPreferences", &ppm);
58 std::string dataPath;
59 api->invokeService(api, "getPluginDataPath", &dataPath);
60
61 auto fmpbotChatHandler = std::make_unique<jami::botChatHandler>(api,
62 std::move(ppm),
63 std::move(dataPath));
64 if (api->manageComponent(api, "ChatHandlerManager", fmpbotChatHandler.release())) {
65 return nullptr;
66 }
67 }
68
69 return pluginExit;
70}
71}