22c8762e0f1da4473dc263d81c7be0e1aa3abab8
[strongswan.git] / src / libstrongswan / plugins / soup / soup_plugin.c
1 /*
2 * Copyright (C) 2010 Martin Willi
3 * Copyright (C) 2010 revosec AG
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 #include "soup_plugin.h"
17 #include "soup_fetcher.h"
18
19 #include <glib.h>
20 #include <glib-object.h>
21
22 #include <library.h>
23
24 typedef struct private_soup_plugin_t private_soup_plugin_t;
25
26 /**
27 * private data of soup_plugin
28 */
29 struct private_soup_plugin_t {
30
31 /**
32 * public functions
33 */
34 soup_plugin_t public;
35 };
36
37 METHOD(plugin_t, get_name, char*,
38 private_soup_plugin_t *this)
39 {
40 return "soup";
41 }
42
43 METHOD(plugin_t, destroy, void,
44 private_soup_plugin_t *this)
45 {
46 lib->fetcher->remove_fetcher(lib->fetcher,
47 (fetcher_constructor_t)soup_fetcher_create);
48 free(this);
49 }
50
51 /*
52 * see header file
53 */
54 plugin_t *soup_plugin_create()
55 {
56 private_soup_plugin_t *this;
57
58 g_type_init();
59 if (!g_thread_get_initialized())
60 {
61 g_thread_init(NULL);
62 }
63
64 INIT(this,
65 .public = {
66 .plugin = {
67 .get_name = _get_name,
68 .reload = (void*)return_false,
69 .destroy = _destroy,
70 },
71 },
72 );
73
74 lib->fetcher->add_fetcher(lib->fetcher,
75 (fetcher_constructor_t)soup_fetcher_create, "http://");
76 lib->fetcher->add_fetcher(lib->fetcher,
77 (fetcher_constructor_t)soup_fetcher_create, "https://");
78
79 return &this->public.plugin;
80 }