first revision of new manager webapp
[strongswan.git] / src / manager / manager.h
1 /**
2 * @file manager.h
3 *
4 * @brief Interface of manager_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2007 Martin Willi
10 * Hochschule fuer Technik Rapperswil
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
21 */
22
23 #ifndef MANAGER_H_
24 #define MANAGER_H_
25
26 #include "database.h"
27 #include "gateway.h"
28
29 #include <context.h>
30
31 #include <utils/iterator.h>
32
33 typedef struct manager_t manager_t;
34
35 /**
36 * @brief The manager, manages multiple gateways.
37 */
38 struct manager_t {
39
40 /**
41 * implements context_t interface
42 */
43 context_t context;
44
45 /**
46 * @brief Create an iterator over all configured gateways.
47 *
48 * enumerate() arguments: int id, char *name, int port, char *address
49 * If port is 0, address is a Unix socket address.
50 *
51 * @return enumerator
52 */
53 enumerator_t* (*create_gateway_enumerator)(manager_t *this);
54
55 /**
56 * @brief Select a gateway.
57 *
58 * If id is 0, the previously selected gateway is returned. If none has
59 * been selected yet, NULL is returned.
60 *
61 * @param id id of the gateway (from enumerate), or 0
62 * @return selected gateway, or NULL
63 */
64 gateway_t* (*select_gateway)(manager_t *this, int id);
65
66 /**
67 * @brief Try to log in.
68 *
69 * @param username username
70 * @param password cleartext password
71 * @return TRUE if login successful
72 */
73 bool (*login)(manager_t *this, char *username, char *password);
74
75 /**
76 * @brief Check if user logged in.
77 *
78 * @return TRUE if logged in
79 */
80 bool (*logged_in)(manager_t *this);
81
82 /**
83 * @brief Log out.
84 */
85 void (*logout)(manager_t *this);
86 };
87
88 /**
89 * @brief Create a manager instance.
90 */
91 manager_t *manager_create(database_t *database);
92
93 #endif /* MANAGER_H_ */