Implemented an alternative HTTP fetcher based on libsoup
[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, destroy, void,
38 private_soup_plugin_t *this)
39 {
40 lib->fetcher->remove_fetcher(lib->fetcher,
41 (fetcher_constructor_t)soup_fetcher_create);
42 free(this);
43 }
44
45 /*
46 * see header file
47 */
48 plugin_t *soup_plugin_create()
49 {
50 private_soup_plugin_t *this;
51
52 g_type_init();
53 if (!g_thread_get_initialized())
54 {
55 g_thread_init(NULL);
56 }
57
58 INIT(this,
59 .public = {
60 .plugin = {
61 .destroy = _destroy,
62 },
63 },
64 );
65
66 lib->fetcher->add_fetcher(lib->fetcher,
67 (fetcher_constructor_t)soup_fetcher_create, "http://");
68 lib->fetcher->add_fetcher(lib->fetcher,
69 (fetcher_constructor_t)soup_fetcher_create, "https://");
70
71 return &this->public.plugin;
72 }