2 * Copyright (C) 2010 Tobias Brunner
3 * Copyright (C) 2010 Martin Willi
4 * Hochschule fuer Technik Rapperswil
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 #include "android_plugin.h"
18 #include "android_logger.h"
19 #include "android_handler.h"
20 #include "android_creds.h"
21 #include "android_service.h"
26 typedef struct private_android_plugin_t private_android_plugin_t
;
29 * Private data of an android_plugin_t object.
31 struct private_android_plugin_t
{
34 * Public android_plugin_t interface.
36 android_plugin_t
public;
39 * Android specific logger
41 android_logger_t
*logger
;
44 * Android specific DNS handler
46 android_handler_t
*handler
;
49 * Android specific credential set
51 android_creds_t
*creds
;
54 * Service that interacts with the Android Settings frontend
56 android_service_t
*service
;
59 METHOD(plugin_t
, get_name
, char*,
60 private_android_plugin_t
*this)
65 METHOD(plugin_t
, destroy
, void,
66 private_android_plugin_t
*this)
68 hydra
->attributes
->remove_handler(hydra
->attributes
,
69 &this->handler
->handler
);
70 lib
->credmgr
->remove_set(lib
->credmgr
, &this->creds
->set
);
71 charon
->bus
->remove_listener(charon
->bus
, &this->logger
->listener
);
72 this->creds
->destroy(this->creds
);
73 this->handler
->destroy(this->handler
);
74 this->logger
->destroy(this->logger
);
75 DESTROY_IF(this->service
);
82 plugin_t
*android_plugin_create()
84 private_android_plugin_t
*this;
89 .get_name
= _get_name
,
90 .reload
= (void*)return_false
,
94 .logger
= android_logger_create(),
95 .creds
= android_creds_create(),
98 charon
->bus
->add_listener(charon
->bus
, &this->logger
->listener
);
99 lib
->credmgr
->add_set(lib
->credmgr
, &this->creds
->set
);
100 hydra
->attributes
->add_handler(hydra
->attributes
, &this->handler
->handler
);
102 this->service
= android_service_create(this->creds
);
103 this->handler
= android_handler_create(this->service
!= NULL
);
105 return &this->public.plugin
;