Migrated manager_t to INIT/METHOD macros.

This commit is contained in:
Tobias Brunner
2011-10-04 10:56:16 +02:00
parent 2b7f89b1fa
commit 758aa810ce
+26 -35
View File
@@ -47,18 +47,14 @@ struct private_manager_t {
gateway_t *gateway; gateway_t *gateway;
}; };
/** METHOD(manager_t, create_gateway_enumerator, enumerator_t*,
* Implementation of manager_t.create_gateway_enumerator. private_manager_t *this)
*/
static enumerator_t* create_gateway_enumerator(private_manager_t *this)
{ {
return this->store->create_gateway_enumerator(this->store, this->user); return this->store->create_gateway_enumerator(this->store, this->user);
} }
/** METHOD(manager_t, select_gateway, gateway_t*,
* Implementation of manager_t.select_gateway. private_manager_t *this, int select_id)
*/
static gateway_t* select_gateway(private_manager_t *this, int select_id)
{ {
if (select_id != 0) if (select_id != 0)
{ {
@@ -95,18 +91,14 @@ static gateway_t* select_gateway(private_manager_t *this, int select_id)
return this->gateway; return this->gateway;
} }
/** METHOD(manager_t, logged_in, bool,
* Implementation of manager_t.logged_in. private_manager_t *this)
*/
static bool logged_in(private_manager_t *this)
{ {
return this->user != 0; return this->user != 0;
} }
/** METHOD(manager_t, login, bool,
* Implementation of manager_t.login. private_manager_t *this, char *username, char *password)
*/
static bool login(private_manager_t *this, char *username, char *password)
{ {
if (!this->user) if (!this->user)
{ {
@@ -115,10 +107,8 @@ static bool login(private_manager_t *this, char *username, char *password)
return this->user != 0; return this->user != 0;
} }
/** METHOD(manager_t, logout, void,
* Implementation of manager_t.logout. private_manager_t *this)
*/
static void logout(private_manager_t *this)
{ {
if (this->gateway) if (this->gateway)
{ {
@@ -128,10 +118,8 @@ static void logout(private_manager_t *this)
this->user = 0; this->user = 0;
} }
/** METHOD(context_t, destroy, void,
* Implementation of manager_t.destroy private_manager_t *this)
*/
static void destroy(private_manager_t *this)
{ {
if (this->gateway) this->gateway->destroy(this->gateway); if (this->gateway) this->gateway->destroy(this->gateway);
free(this); free(this);
@@ -142,18 +130,21 @@ static void destroy(private_manager_t *this)
*/ */
manager_t *manager_create(storage_t *storage) manager_t *manager_create(storage_t *storage)
{ {
private_manager_t *this = malloc_thing(private_manager_t); private_manager_t *this;
this->public.login = (bool(*)(manager_t*, char *username, char *password))login; INIT(this,
this->public.logged_in = (bool(*)(manager_t*))logged_in; .public = {
this->public.logout = (void(*)(manager_t*))logout; .login = _login,
this->public.create_gateway_enumerator = (enumerator_t*(*)(manager_t*))create_gateway_enumerator; .logged_in = _logged_in,
this->public.select_gateway = (gateway_t*(*)(manager_t*, int id))select_gateway; .logout = _logout,
this->public.context.destroy = (void(*)(context_t*))destroy; .create_gateway_enumerator = _create_gateway_enumerator,
.select_gateway = _select_gateway,
this->user = 0; .context = {
this->store = storage; .destroy = _destroy,
this->gateway = NULL; },
},
.store = storage,
);
return &this->public; return &this->public;
} }