2 * irreco - Ir Remote Control
3 * Copyright (C) 2007,2008 Arto Karppinen (arto.karppinen@iki.fi),
4 * Joni Kokko (t5kojo01@students.oamk.fi),
5 * Sami Mäki (t5masa02@students.oamk.fi),
6 * Harri Vattulainen (t5vaha01@students.oamk.fi)
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 #include "irreco_webdb_cache.h"
24 #include "irreco_webdb_client.h"
29 * PURPOCE OF FILE. TODO TODO TODO
30 * Caches XML-RPC calls, enables error handling and retries failed calls.
33 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
35 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
37 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
38 /* Construction & Destruction */
39 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
42 * Create new IrrecoWebdb Object
44 IrrecoWebdbCache
*irreco_webdb_cache_new()
46 IrrecoWebdbCache
*self
;
49 self
= g_slice_new0(IrrecoWebdbCache
);
50 self
->private = irreco_webdb_client_new();
51 self
->error_msg
= g_string_new("");
52 self
->loop
= irreco_retry_loop_new(IRRECO_SECONDS_TO_USEC(0.3),
53 IRRECO_SECONDS_TO_USEC(3));
54 self
->conf_hash
= g_hash_table_new_full(g_int_hash
, g_int_equal
, NULL
,
55 (GDestroyNotify
) irreco_webdb_conf_free
);
57 self
->themes
= irreco_string_table_new (
58 (GDestroyNotify
) irreco_webdb_theme_free
, NULL
);
60 IRRECO_RETURN_PTR(self
);
64 * Free resources of IrrecoWebdbCache Object.
66 void irreco_webdb_cache_free(IrrecoWebdbCache
*self
)
69 g_string_free(self
->error_msg
, TRUE
);
70 self
->error_msg
= NULL
;
71 irreco_retry_loop_free(self
->loop
);
73 irreco_webdb_client_free(self
->private);
75 g_slice_free(IrrecoWebdbCache
, self
);
76 g_hash_table_destroy(self
->conf_hash
);
77 self
->conf_hash
= NULL
;
78 irreco_string_table_free (self
->themes
);
84 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
85 /* Private Functions */
86 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
89 * A simple test on Irreco WebDB to test if WebDB returns correct and
90 * meaningfull results.
92 * This function generates two numbers and asks WebDB to sum them. If the sum
93 * if correct, then our connection to the WebDB seems to be working.
95 * @return TRUE on success, FALSE otherwise.
97 static gboolean
irreco_webdb_cache_test(IrrecoWebdbCache
*self
)
99 IrrecoWebdbClient
*client
;
106 if (self
->test_ok
) IRRECO_RETURN_BOOL(self
->test_ok
);
109 client
= (IrrecoWebdbClient
*) self
->private;
111 IRRECO_RETRY_LOOP_START(self
->loop
)
112 num_a
= g_rand_int_range(rand
, 1, 1000);
113 num_b
= g_rand_int_range(rand
, 1, 1000);
114 self
->test_ok
= irreco_webdb_client_sum(
115 client
, num_a
, num_b
, &sum
);
118 if (sum
== num_a
+ num_b
) {
121 g_string_printf(self
->error_msg
,
122 "Got invalid result from "
123 "sum method. %i + %i = %i. "
127 IRRECO_PRINTF("%s\n", self
->error_msg
->str
);
128 self
->test_ok
= FALSE
;
131 irreco_webdb_client_get_error_msg(
132 client
, self
->error_msg
);
134 IRRECO_RETRY_LOOP_END(self
->loop
)
137 IRRECO_RETURN_BOOL(self
->test_ok
);
141 * Shows error message in case categories list is empty.
143 * @return TRUE if categories is not empty, FALSE otherwise.
145 static gboolean
irreco_webdb_cache_verify_category(IrrecoWebdbCache
*self
)
148 if (self
->categories
== NULL
) {
149 g_string_printf(self
->error_msg
, "list of categories is NULL");
150 IRRECO_PRINTF("%s\n", self
->error_msg
->str
);
151 IRRECO_RETURN_BOOL(FALSE
)
153 IRRECO_RETURN_BOOL(TRUE
)
157 * Shows error message in case manufacturers list is empty.
159 * @return TRUE if manufacturers list contains data, FALSE otherwise.
162 irreco_webdb_cache_verify_manufacturer(IrrecoWebdbCache
*self
,
163 const gchar
*category
,
164 IrrecoStringTable
**manufactures
)
167 if (!irreco_string_table_get(self
->categories
, category
,
168 (gpointer
*) manufactures
)) {
169 g_string_printf(self
->error_msg
,
170 "list of manufacturers is NULL");
171 IRRECO_PRINTF("%s\n", self
->error_msg
->str
);
172 IRRECO_RETURN_BOOL(FALSE
)
174 IRRECO_RETURN_BOOL(TRUE
)
179 * Shows error message in case models list is empty.
181 * @return TRUE if models list contains data, FALSE otherwise.
183 static gboolean
irreco_webdb_cache_verify_model(IrrecoWebdbCache
*self
,
184 IrrecoStringTable
*manuf_list
,
185 const gchar
*manufacturer
,
186 IrrecoStringTable
**models
)
189 if (!irreco_string_table_get(manuf_list
, manufacturer
,
190 (gpointer
*) models
)) {
191 g_string_printf(self
->error_msg
, "list of models is NULL");
192 IRRECO_PRINTF("%s\n", self
->error_msg
->str
);
193 IRRECO_RETURN_BOOL(FALSE
)
195 IRRECO_RETURN_BOOL(TRUE
)
199 * Shows error message in case configurations list is empty.
201 * @return TRUE if configurations list contains data, FALSE otherwise.
203 static gboolean
irreco_webdb_cache_verify_config(IrrecoWebdbCache
*self
,
204 IrrecoStringTable
*models
,
206 IrrecoStringTable
**configs
)
209 if (!irreco_string_table_get(models
, model
, (gpointer
*) configs
)) {
210 g_string_printf(self
->error_msg
,
211 "list of configurations is NULL");
212 IRRECO_PRINTF("%s\n", self
->error_msg
->str
);
213 IRRECO_RETURN_BOOL(FALSE
)
215 IRRECO_RETURN_BOOL(TRUE
)
218 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
220 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
222 * Adds new user (name, email, password) to database.
224 * @return TRUE if user is added succesfully, FALSE otherwise.
226 gboolean
irreco_webdb_cache_add_user(IrrecoWebdbCache
*self
,
231 IrrecoWebdbClient
*client
;
235 client
= (IrrecoWebdbClient
*) self
->private;
237 IRRECO_RETRY_LOOP_START(self
->loop
)
238 /* test connection to webdb */
239 if (irreco_webdb_cache_test(self
) == FALSE
){
240 g_string_printf(self
->error_msg
,
241 "Failed cache self test.");
242 IRRECO_PRINTF("%s\n", self
->error_msg
->str
);
243 IRRECO_RETURN_BOOL(FALSE
);
246 if(irreco_webdb_client_add_user(client
, name
, email
, passwd
)) {
247 IRRECO_RETURN_BOOL(TRUE
);
249 /* irreco_webdb_client_add_user failed, get err msg */
250 irreco_webdb_client_get_error_msg(client
,
252 IRRECO_RETURN_BOOL(FALSE
);
254 IRRECO_RETRY_LOOP_END(self
->loop
)
256 IRRECO_RETURN_BOOL(FALSE
);
260 * Adds new configuration to database.
262 * @return TRUE if configuration is uploaded succesfully, FALSE otherwise.
264 gboolean
irreco_webdb_cache_upload_configuration(IrrecoWebdbCache
*self
,
265 const gchar
*backend
,
266 const gchar
*category
,
267 const gchar
*file_hash
,
268 const gchar
*file_name
,
269 const gchar
*manufacturer
,
271 const gchar
*password
,
275 IrrecoWebdbClient
*client
;
279 client
= (IrrecoWebdbClient
*) self
->private;
281 IRRECO_RETRY_LOOP_START(self
->loop
)
282 /* test connection to webdb */
283 if (irreco_webdb_cache_test(self
) == FALSE
){
284 g_string_printf(self
->error_msg
,
285 "Failed cache self test.");
286 IRRECO_PRINTF("%s\n", self
->error_msg
->str
);
287 IRRECO_RETURN_BOOL(FALSE
);
290 if(irreco_webdb_client_upload_configuration(client
, backend
,
291 category
, file_hash
, file_name
,
292 manufacturer
, model
, password
, user
,
295 IRRECO_RETURN_BOOL(TRUE
);
297 /* irreco_webdb_client_upload_configuration failed,
299 irreco_webdb_client_get_error_msg(client
,
301 IRRECO_RETURN_BOOL(FALSE
);
303 IRRECO_RETRY_LOOP_END(self
->loop
)
305 IRRECO_RETURN_BOOL(FALSE
);
309 * Extracts error message from IrrecoWebdbCache object.
311 * @return error message as string.
313 const gchar
*irreco_webdb_cache_get_error(IrrecoWebdbCache
*self
)
316 IRRECO_RETURN_STR(self
->error_msg
->str
);
320 * Fetches categories from DB
322 * @return TRUE if categories are fetched succesfully, FALSE otherwise.
324 gboolean
irreco_webdb_cache_get_categories(IrrecoWebdbCache
*self
,
325 IrrecoStringTable
**categories
)
329 if (self
->categories
== NULL
) {
330 gboolean success
= FALSE
;
331 IrrecoWebdbClient
*client
= (IrrecoWebdbClient
*) self
->private;
333 IRRECO_RETRY_LOOP_START(self
->loop
)
334 if (irreco_webdb_cache_test(self
) == FALSE
) break;
335 success
= irreco_webdb_client_get_categories(
336 client
, &self
->categories
);
340 irreco_webdb_client_get_error_msg(
341 client
, self
->error_msg
);
342 IRRECO_RETRY_LOOP_END(self
->loop
)
344 if (success
== FALSE
) IRRECO_RETURN_BOOL(FALSE
);
346 irreco_string_table_sort_abc (self
->categories
);
349 *categories
= self
->categories
;
350 IRRECO_RETURN_BOOL(TRUE
)
354 * Fetches all categories from DB.
356 * @param all_categories must be freed if return value is TRUE.
357 * @return TRUE if categories are fetched succesfully, FALSE otherwise.
359 gboolean
irreco_webdb_cache_get_all_categories(IrrecoWebdbCache
*self
,
360 IrrecoStringTable
**all_categories
)
362 gboolean success
= FALSE
;
363 IrrecoWebdbClient
*client
= (IrrecoWebdbClient
*) self
->private;
367 IRRECO_RETRY_LOOP_START(self
->loop
)
368 if (irreco_webdb_cache_test(self
) == FALSE
) break;
369 success
= irreco_webdb_client_get_all_categories(
370 client
, all_categories
);
374 irreco_webdb_client_get_error_msg(
375 client
, self
->error_msg
);
376 IRRECO_RETRY_LOOP_END(self
->loop
)
378 if (success
== FALSE
) IRRECO_RETURN_BOOL(FALSE
);
380 irreco_string_table_sort_abc(*all_categories
);
382 IRRECO_RETURN_BOOL(TRUE
)
386 * Fetches manufacturers from DB.
388 * @param category contains category in which type manufacturers are returned.
389 * @return TRUE if manufacturers are fetched succesfully, FALSE otherwise.
391 gboolean
irreco_webdb_cache_get_manufacturers(IrrecoWebdbCache
*self
,
392 const gchar
*category
,
393 IrrecoStringTable
**manufacturers
)
395 IrrecoStringTable
*manufacturer_list
;
398 if (!irreco_webdb_cache_verify_category(self
) ||
399 !irreco_webdb_cache_verify_manufacturer(self
, category
,
400 &manufacturer_list
)) {
401 IRRECO_RETURN_BOOL(FALSE
)
404 if(manufacturer_list
== NULL
) {
405 gboolean success
= FALSE
;
406 IrrecoWebdbClient
*client
= (IrrecoWebdbClient
*) self
->private;
408 IRRECO_RETRY_LOOP_START(self
->loop
)
409 if (irreco_webdb_cache_test(self
) == FALSE
) break;
410 success
= irreco_webdb_client_get_manufacturers(
411 client
, category
, &manufacturer_list
);
414 irreco_webdb_client_get_error_msg(
415 client
, self
->error_msg
);
416 IRRECO_RETRY_LOOP_END(self
->loop
)
418 if (success
== FALSE
) IRRECO_RETURN_BOOL(FALSE
);
420 irreco_string_table_sort_abc (manufacturer_list
);
421 irreco_string_table_change_data(self
->categories
, category
,
425 irreco_string_table_get(self
->categories
, category
,
426 (gpointer
*) manufacturers
);
427 IRRECO_RETURN_BOOL(TRUE
)
431 * Fetches all manufacturers from DB.
433 * @param all_manufacturers must be released if function returns TRUE.
434 * @return TRUE if manufacturers are fetched succesfully, FALSE otherwise.
436 gboolean
irreco_webdb_cache_get_all_manufacturers(IrrecoWebdbCache
*self
,
437 IrrecoStringTable
**all_manufacturers
)
439 gboolean success
= FALSE
;
440 IrrecoWebdbClient
*client
= (IrrecoWebdbClient
*) self
->private;
444 IRRECO_RETRY_LOOP_START(self
->loop
)
445 if (irreco_webdb_cache_test(self
) == FALSE
) break;
446 success
= irreco_webdb_client_get_all_manufacturers(
447 client
, all_manufacturers
);
451 irreco_webdb_client_get_error_msg(
452 client
, self
->error_msg
);
453 IRRECO_RETRY_LOOP_END(self
->loop
)
455 if (success
== FALSE
) IRRECO_RETURN_BOOL(FALSE
);
457 irreco_string_table_sort_abc(*all_manufacturers
);
459 IRRECO_RETURN_BOOL(TRUE
)
463 * Fetches models belonging given category and manufacturer.
465 * @param models must be freed if function returns TRUE.
466 * @return TRUE if models are fetched succesfully, FALSE otherwise.
468 gboolean
irreco_webdb_cache_get_models(IrrecoWebdbCache
*self
,
469 const gchar
*category
,
470 const gchar
*manufacturer
,
471 IrrecoStringTable
**models
)
473 IrrecoStringTable
*model_list
;
474 IrrecoStringTable
*manufacturer_list
;
477 if (!irreco_webdb_cache_verify_category(self
) ||
478 !irreco_webdb_cache_verify_manufacturer(self
, category
,
479 &manufacturer_list
) ||
480 !irreco_webdb_cache_verify_model(self
, manufacturer_list
,
481 manufacturer
, &model_list
)) {
482 IRRECO_RETURN_BOOL(FALSE
)
485 if(model_list
== NULL
) {
486 gboolean success
= FALSE
;
487 IrrecoWebdbClient
*client
= (IrrecoWebdbClient
*) self
->private;
489 IRRECO_RETRY_LOOP_START(self
->loop
)
490 if (irreco_webdb_cache_test(self
) == FALSE
) break;
491 success
= irreco_webdb_client_get_models(
492 client
, category
, manufacturer
, &model_list
);
495 irreco_webdb_client_get_error_msg(
496 client
, self
->error_msg
);
497 IRRECO_RETRY_LOOP_END(self
->loop
)
499 if (success
== FALSE
) IRRECO_RETURN_BOOL(FALSE
);
501 irreco_string_table_sort_abc (model_list
);
502 irreco_string_table_change_data(manufacturer_list
, manufacturer
,
506 irreco_string_table_get(manufacturer_list
, manufacturer
,
507 (gpointer
*) models
);
508 IRRECO_RETURN_BOOL(TRUE
)
512 * Fetches configs belonging given category, manufacturer and model.
514 * @return TRUE if configs are fetched succesfully, FALSE otherwise.
516 gboolean
irreco_webdb_cache_get_configs(IrrecoWebdbCache
*self
,
517 const gchar
*category
,
518 const gchar
*manufacturer
,
520 IrrecoStringTable
**configs
)
522 IrrecoStringTable
* config_list
;
523 IrrecoStringTable
* model_list
;
524 IrrecoStringTable
* manufacturer_list
;
527 if (!irreco_webdb_cache_verify_category(self
) ||
528 !irreco_webdb_cache_verify_manufacturer(self
, category
,
529 &manufacturer_list
) ||
530 !irreco_webdb_cache_verify_model(self
, manufacturer_list
,
531 manufacturer
, &model_list
) ||
532 !irreco_webdb_cache_verify_config(self
, model_list
, model
,
534 IRRECO_RETURN_BOOL(FALSE
)
537 if(config_list
== NULL
) {
538 gboolean success
= FALSE
;
539 IrrecoWebdbClient
*client
= (IrrecoWebdbClient
*) self
->private;
541 IRRECO_RETRY_LOOP_START(self
->loop
)
542 if (irreco_webdb_cache_test(self
) == FALSE
) break;
543 success
= irreco_webdb_client_get_configs(client
,
544 category
, manufacturer
, model
, &config_list
);
547 irreco_webdb_client_get_error_msg(
548 client
, self
->error_msg
);
549 IRRECO_RETRY_LOOP_END(self
->loop
)
551 if (success
== FALSE
) IRRECO_RETURN_BOOL(FALSE
);
553 irreco_string_table_change_data(model_list
, model
, config_list
);
556 irreco_string_table_get(model_list
, model
, (gpointer
*) configs
);
557 IRRECO_RETURN_BOOL(TRUE
)
561 * Fetches configuration by given ID.
563 * @return TRUE if configuration is fetched succesfully, FALSE otherwise.
565 gboolean
irreco_webdb_cache_get_configuration(IrrecoWebdbCache
*self
,
567 IrrecoWebdbConf
**config
)
569 IrrecoWebdbConf
* configuration
;
572 if (g_hash_table_lookup(self
->conf_hash
, (gconstpointer
) &id
) == NULL
) {
573 gboolean success
= FALSE
;
574 IrrecoWebdbClient
*client
= (IrrecoWebdbClient
*) self
->private;
576 IRRECO_RETRY_LOOP_START(self
->loop
)
577 if (irreco_webdb_cache_test(self
) == FALSE
) break;
578 success
= irreco_webdb_client_get_configuration(
579 client
, id
, &configuration
);
582 irreco_webdb_client_get_error_msg(client
,
584 IRRECO_RETRY_LOOP_END(self
->loop
)
586 if (success
== FALSE
) IRRECO_RETURN_BOOL(FALSE
);
588 g_hash_table_insert(self
->conf_hash
,
589 (gpointer
) &configuration
->id
,
590 (gpointer
) configuration
);
593 *config
= g_hash_table_lookup(self
->conf_hash
, (gconstpointer
) &id
);
595 IRRECO_RETURN_BOOL(TRUE
)
599 * Fetches file by given hash and name.
601 * @return TRUE if configuration is fetched succesfully, FALSE otherwise.
603 gboolean
irreco_webdb_cache_get_file(IrrecoWebdbCache
*self
,
604 const gchar
*file_hash
,
605 const gchar
*file_name
,
609 gboolean success
= FALSE
;
610 IrrecoWebdbClient
*client
;
613 client
= (IrrecoWebdbClient
*) self
->private;
615 IRRECO_RETRY_LOOP_START(self
->loop
)
616 if (irreco_webdb_cache_test(self
) == FALSE
) break;
617 success
= irreco_webdb_client_get_file(
618 client
, file_hash
, file_name
, &file
);
621 irreco_webdb_client_get_error_msg(client
, self
->error_msg
);
622 IRRECO_RETRY_LOOP_END(self
->loop
)
624 if (success
== FALSE
) IRRECO_RETURN_BOOL(FALSE
);
628 IRRECO_RETURN_BOOL(TRUE
)
632 * Check if user with given name is already at DB.
634 *.@param user_exists will contain info wether user name was at DB.
635 * @return TRUE if test is done succesfully, FALSE otherwise.
637 gboolean
irreco_webdb_cache_get_user_exists(IrrecoWebdbCache
*self
,
639 gboolean
*user_exists
)
641 IrrecoWebdbClient
*client
;
642 gboolean success
= FALSE
;
645 client
= (IrrecoWebdbClient
*) self
->private;
646 IRRECO_RETRY_LOOP_START(self
->loop
)
647 /* test connection to webdb */
648 if (irreco_webdb_cache_test(self
) == FALSE
) break;
650 success
= irreco_webdb_client_get_user_exists(client
,
656 /* irreco_webdb_client_get_user_exists failed, get err msg */
657 irreco_webdb_client_get_error_msg(client
, self
->error_msg
);
658 IRRECO_RETRY_LOOP_END(self
->loop
)
660 if (success
== FALSE
) IRRECO_RETURN_BOOL(FALSE
);
662 IRRECO_RETURN_BOOL(TRUE
)
668 * @return TRUE if login is succesful, FALSE otherwise.
670 gboolean
irreco_webdb_cache_login(IrrecoWebdbCache
*self
,
672 const gchar
*password
)
674 IrrecoWebdbClient
*client
;
678 client
= (IrrecoWebdbClient
*) self
->private;
680 IRRECO_RETRY_LOOP_START(self
->loop
)
681 /* test connection to webdb */
682 if (irreco_webdb_cache_test(self
) == FALSE
){
683 g_string_printf(self
->error_msg
,
684 "Failed cache self test.");
685 IRRECO_PRINTF("%s\n", self
->error_msg
->str
);
686 IRRECO_RETURN_BOOL(FALSE
);
689 if(irreco_webdb_client_login(client
, user
, password
)) {
691 IRRECO_RETURN_BOOL(TRUE
);
693 /* irreco_webdb_client_login failed,
695 irreco_webdb_client_get_error_msg(client
,
697 IRRECO_RETURN_BOOL(FALSE
);
699 IRRECO_RETRY_LOOP_END(self
->loop
)
701 IRRECO_RETURN_BOOL(FALSE
);
704 gboolean
irreco_webdb_cache_get_themes(IrrecoWebdbCache
*self
,
705 IrrecoStringTable
**theme
)
707 gboolean success
= FALSE
;
708 IrrecoWebdbClient
*client
= (IrrecoWebdbClient
*) self
->private;
711 IRRECO_RETRY_LOOP_START(self
->loop
)
712 if (irreco_webdb_cache_test(self
) == FALSE
) break;
713 success
= irreco_webdb_client_get_themes(client
, theme
);
716 irreco_webdb_client_get_error_msg(client
, self
->error_msg
);
717 IRRECO_RETRY_LOOP_END(self
->loop
)
719 IRRECO_RETURN_BOOL(success
)
722 gboolean
irreco_webdb_cache_get_theme_by_id(IrrecoWebdbCache
*self
,
724 IrrecoWebdbTheme
**theme
)
726 IrrecoWebdbTheme
*get_theme
;
729 if (g_hash_table_lookup(self
->conf_hash
, (gconstpointer
) &theme_id
) == NULL
) {
730 gboolean success
= FALSE
;
731 IrrecoWebdbClient
*client
= (IrrecoWebdbClient
*) self
->private;
733 IRRECO_RETRY_LOOP_START(self
->loop
)
734 if (irreco_webdb_cache_test(self
) == FALSE
) break;
735 success
= irreco_webdb_client_get_theme_by_id(
736 client
, theme_id
, &get_theme
);
739 irreco_webdb_client_get_error_msg(client
,
741 IRRECO_RETRY_LOOP_END(self
->loop
)
743 if (success
== FALSE
) IRRECO_RETURN_BOOL(FALSE
);
745 g_hash_table_insert(self
->conf_hash
,
746 (gpointer
) &get_theme
->id
,
747 (gpointer
) get_theme
);
750 *theme
= g_hash_table_lookup(self
->conf_hash
, (gconstpointer
) &theme_id
);
752 IRRECO_RETURN_BOOL(TRUE
)
756 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
757 /* Events and Callbacks */
758 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/