2 * Copyright (C) 2008 Martin Willi
3 * Hochschule fuer Technik Rapperswil
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>.
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
16 #include "medsrv_plugin.h"
18 #include "medsrv_creds.h"
19 #include "medsrv_config.h"
23 typedef struct private_medsrv_plugin_t private_medsrv_plugin_t
;
26 * private data of medsrv plugin
28 struct private_medsrv_plugin_t
{
31 * implements plugin interface
33 medsrv_plugin_t
public;
36 * database connection instance
41 * medsrv credential set instance
43 medsrv_creds_t
*creds
;
46 * medsrv config database
48 medsrv_config_t
*config
;
51 METHOD(plugin_t
, get_name
, char*,
52 private_medsrv_plugin_t
*this)
57 METHOD(plugin_t
, destroy
, void,
58 private_medsrv_plugin_t
*this)
60 charon
->backends
->remove_backend(charon
->backends
, &this->config
->backend
);
61 lib
->credmgr
->remove_set(lib
->credmgr
, &this->creds
->set
);
62 this->config
->destroy(this->config
);
63 this->creds
->destroy(this->creds
);
64 this->db
->destroy(this->db
);
71 plugin_t
*medsrv_plugin_create()
74 private_medsrv_plugin_t
*this;
79 .get_name
= _get_name
,
80 .reload
= (void*)return_false
,
86 uri
= lib
->settings
->get_str(lib
->settings
,
87 "medsrv.database", NULL
);
90 DBG1(DBG_CFG
, "mediation database URI not defined, skipped");
95 this->db
= lib
->db
->create(lib
->db
, uri
);
98 DBG1(DBG_CFG
, "opening mediation server database failed");
103 this->creds
= medsrv_creds_create(this->db
);
104 this->config
= medsrv_config_create(this->db
);
106 lib
->credmgr
->add_set(lib
->credmgr
, &this->creds
->set
);
107 charon
->backends
->add_backend(charon
->backends
, &this->config
->backend
);
109 return &this->public.plugin
;