manager can query and list IKE_SA status (no layout yet)
[strongswan.git] / src / manager / controller / static_controller.c
1 /**
2 * @file static_controller.c
3 *
4 * @brief Implementation of static_controller_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 #include "static_controller.h"
24 #include "../manager.h"
25 #include "../gateway.h"
26
27 #include <template.h>
28
29 #include <library.h>
30
31
32 typedef struct private_static_controller_t private_static_controller_t;
33
34 /**
35 * private data of the task manager
36 */
37 struct private_static_controller_t {
38
39 /**
40 * public functions
41 */
42 static_controller_t public;
43
44 /**
45 * manager instance
46 */
47 manager_t *manager;
48
49 };
50
51 /**
52 * serve style.css
53 */
54 static void style(private_static_controller_t *this,
55 request_t *request, response_t *response)
56 {
57 template_t *t = template_create("templates/static/style.css");
58 response->set_content_type(response, "text/css");
59 t->render(t, response);
60 t->destroy(t);
61 }
62
63 /**
64 * Implementation of controller_t.get_name
65 */
66 static char* get_name(private_static_controller_t *this)
67 {
68 return "static";
69 }
70
71 /**
72 * Implementation of controller_t.get_handler
73 */
74 static controller_handler_t get_handler(private_static_controller_t *this, char *name)
75 {
76 if (streq(name, "style.css")) return (controller_handler_t)style;
77 return NULL;
78 }
79
80 /**
81 * Implementation of controller_t.destroy
82 */
83 static void destroy(private_static_controller_t *this)
84 {
85 free(this);
86 }
87
88 /*
89 * see header file
90 */
91 controller_t *static_controller_create(context_t *context, void *param)
92 {
93 private_static_controller_t *this = malloc_thing(private_static_controller_t);
94
95 this->public.controller.get_name = (char*(*)(controller_t*))get_name;
96 this->public.controller.get_handler = (controller_handler_t(*)(controller_t*,char*))get_handler;
97 this->public.controller.destroy = (void(*)(controller_t*))destroy;
98
99 this->manager = (manager_t*)context;
100
101 return &this->public.controller;
102 }
103