2 * Copyright (C) 2011 Martin Willi
3 * Copyright (C) 2011 revosec AG
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 "duplicheck_plugin.h"
18 #include "duplicheck_notify.h"
19 #include "duplicheck_listener.h"
23 typedef struct private_duplicheck_plugin_t private_duplicheck_plugin_t
;
26 * Private data of duplicheck plugin
28 struct private_duplicheck_plugin_t
{
31 * Implements plugin interface
33 duplicheck_plugin_t
public;
36 * Listener doing duplicate checks
38 duplicheck_listener_t
*listener
;
41 * Notification sender facility
43 duplicheck_notify_t
*notify
;
46 METHOD(plugin_t
, get_name
, char*,
47 private_duplicheck_plugin_t
*this)
55 static bool plugin_cb(private_duplicheck_plugin_t
*this,
56 plugin_feature_t
*feature
, bool reg
, void *cb_data
)
60 charon
->bus
->add_listener(charon
->bus
, &this->listener
->listener
);
64 charon
->bus
->remove_listener(charon
->bus
, &this->listener
->listener
);
69 METHOD(plugin_t
, get_features
, int,
70 private_duplicheck_plugin_t
*this, plugin_feature_t
*features
[])
72 static plugin_feature_t f
[] = {
73 PLUGIN_CALLBACK((plugin_feature_callback_t
)plugin_cb
, NULL
),
74 PLUGIN_PROVIDE(CUSTOM
, "duplicheck"),
80 METHOD(plugin_t
, destroy
, void,
81 private_duplicheck_plugin_t
*this)
83 this->notify
->destroy(this->notify
);
84 this->listener
->destroy(this->listener
);
91 plugin_t
*duplicheck_plugin_create()
93 private_duplicheck_plugin_t
*this;
95 if (!lib
->settings
->get_bool(lib
->settings
,
96 "%s.plugins.duplicheck.enable", TRUE
, charon
->name
))
104 .get_name
= _get_name
,
105 .get_features
= _get_features
,
109 .notify
= duplicheck_notify_create(),
117 this->listener
= duplicheck_listener_create(this->notify
);
119 return &this->public.plugin
;