diff options
Diffstat (limited to 'src/setup/gnunet-setup-datacache-config.c')
-rw-r--r-- | src/setup/gnunet-setup-datacache-config.c | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/src/setup/gnunet-setup-datacache-config.c b/src/setup/gnunet-setup-datacache-config.c new file mode 100644 index 00000000..585a786f --- /dev/null +++ b/src/setup/gnunet-setup-datacache-config.c | |||
@@ -0,0 +1,137 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2010 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 2, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file src/gnunet-setup-datacache-config.c | ||
23 | * @brief test datacache configuration | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | #include "gnunet-setup.h" | ||
27 | #include <gnunet/gnunet_datacache_plugin.h> | ||
28 | |||
29 | /** | ||
30 | * Stub implementation of the 'DeleteNotifyCallback' callback. | ||
31 | */ | ||
32 | static void | ||
33 | dnc_dummy (void *cls, | ||
34 | const GNUNET_HashCode *key, | ||
35 | size_t size) | ||
36 | { | ||
37 | /* do nothing */ | ||
38 | } | ||
39 | |||
40 | |||
41 | /** | ||
42 | * Test if the configuration works for the given plugin. | ||
43 | * | ||
44 | * @param name name of the plugin to check | ||
45 | * @return GNUNET_OK on success, GNUNET_SYSERR if the config is wrong | ||
46 | */ | ||
47 | static int | ||
48 | test_config (const char *name) | ||
49 | { | ||
50 | struct GNUNET_DATACACHE_PluginEnvironment env = | ||
51 | { | ||
52 | cfg, | ||
53 | "dhtcache", | ||
54 | NULL, &dnc_dummy, | ||
55 | 1024LL | ||
56 | }; | ||
57 | void *ret; | ||
58 | |||
59 | ret = GNUNET_PLUGIN_load (name, &env); | ||
60 | if (NULL == ret) | ||
61 | return GNUNET_SYSERR; | ||
62 | GNUNET_PLUGIN_unload (name, ret); | ||
63 | return GNUNET_OK; | ||
64 | } | ||
65 | |||
66 | |||
67 | static void | ||
68 | show (const char *name) | ||
69 | { | ||
70 | gtk_widget_show (GTK_WIDGET (gtk_builder_get_object (builder, | ||
71 | name))); | ||
72 | } | ||
73 | |||
74 | |||
75 | static void | ||
76 | hide (const char *name) | ||
77 | { | ||
78 | gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (builder, | ||
79 | name))); | ||
80 | } | ||
81 | |||
82 | |||
83 | void | ||
84 | GNUNET_setup_datacache_mysql_invalidate_cb () | ||
85 | { | ||
86 | hide ("GNUNET_setup_datacache_mysql_tab_ok_image"); | ||
87 | hide ("GNUNET_setup_datacache_mysql_tab_error_image"); | ||
88 | } | ||
89 | |||
90 | |||
91 | void | ||
92 | GNUNET_setup_datacache_postgres_invalidate_cb () | ||
93 | { | ||
94 | hide ("GNUNET_setup_datacache_postgres_tab_ok_image"); | ||
95 | hide ("GNUNET_setup_datacache_postgres_tab_error_image"); | ||
96 | } | ||
97 | |||
98 | |||
99 | void | ||
100 | GNUNET_setup_datacache_mysql_tab_test_button_clicked_cb (GtkWidget *widget, | ||
101 | gpointer user_data) | ||
102 | { | ||
103 | if (GNUNET_OK == | ||
104 | test_config ("libgnunet_plugin_datacache_mysql")) | ||
105 | { | ||
106 | show ("GNUNET_setup_datacache_mysql_tab_ok_image"); | ||
107 | hide ("GNUNET_setup_datacache_mysql_tab_error_image"); | ||
108 | } | ||
109 | else | ||
110 | { | ||
111 | hide ("GNUNET_setup_datacache_mysql_tab_ok_image"); | ||
112 | show ("GNUNET_setup_datacache_mysql_tab_error_image"); | ||
113 | } | ||
114 | } | ||
115 | |||
116 | |||
117 | void | ||
118 | GNUNET_setup_datacache_postgres_tab_test_button_clicked_cb (GtkWidget *widget, | ||
119 | gpointer user_data) | ||
120 | { | ||
121 | if (GNUNET_OK == | ||
122 | test_config ("libgnunet_plugin_datacache_postgres")) | ||
123 | { | ||
124 | show ("GNUNET_setup_datacache_postgres_tab_ok_image"); | ||
125 | hide ("GNUNET_setup_datacache_postgres_tab_error_image"); | ||
126 | } | ||
127 | else | ||
128 | { | ||
129 | hide ("GNUNET_setup_datacache_postgres_tab_ok_image"); | ||
130 | show ("GNUNET_setup_datacache_postgres_tab_error_image"); | ||
131 | } | ||
132 | } | ||
133 | |||
134 | |||
135 | |||
136 | /* end of gnunet-setup-datacache-config.c */ | ||
137 | |||