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 (kasmra@xob.kapsi.fi),
6 * Harri Vattulainen (t5vaha01@students.oamk.fi),
7 * Pekka Gehör (pegu6@msn.com)
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 #include "irreco_webdb_cache.h"
25 #include "irreco_webdb_client.h"
28 * @addtogroup IrrecoWebdbCache
29 * @ingroup IrrecoWebdb
31 * Caches XML-RPC calls, enables error handling and retries failed calls.
38 * Source file of @ref IrrecoWebdbCache.
43 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
45 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
47 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
48 /* Construction & Destruction */
49 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
52 * @name Construction & Destruction
57 * Create new IrrecoWebdb Object
59 IrrecoWebdbCache
*irreco_webdb_cache_new()
61 IrrecoWebdbCache
*self
;
64 self
= g_slice_new0(IrrecoWebdbCache
);
65 self
->private = irreco_webdb_client_new();
66 self
->remote_categories
= NULL
;
67 self
->error_msg
= g_string_new("");
68 self
->loop
= irreco_retry_loop_new(IRRECO_SECONDS_TO_USEC(0.3),
69 IRRECO_SECONDS_TO_USEC(3));
70 self
->conf_hash
= g_hash_table_new_full(g_int_hash
, g_int_equal
, NULL
,
71 (GDestroyNotify
) irreco_webdb_conf_free
);
73 self
->theme_id_hash
= g_hash_table_new_full(g_int_hash
, g_int_equal
, NULL
,
74 (GDestroyNotify
) irreco_webdb_theme_free
);
76 self
->remote_id_hash
= g_hash_table_new_full(g_int_hash
, g_int_equal
,
77 NULL
, (GDestroyNotify
) irreco_webdb_remote_free
);
79 IRRECO_RETURN_PTR(self
);
83 * Free resources of IrrecoWebdbCache Object.
85 void irreco_webdb_cache_free(IrrecoWebdbCache
*self
)
88 g_string_free(self
->error_msg
, TRUE
);
89 self
->error_msg
= NULL
;
90 irreco_retry_loop_free(self
->loop
);
92 if (self
->remote_categories
!= NULL
) {
93 irreco_string_table_free(self
->remote_categories
);
94 self
->remote_categories
= NULL
;
96 irreco_webdb_client_free(self
->private);
98 g_slice_free(IrrecoWebdbCache
, self
);
99 if (self
->conf_hash
!= NULL
) {
100 g_hash_table_destroy(self
->conf_hash
);
101 self
->conf_hash
= NULL
;
103 if (self
->theme_id_hash
!= NULL
) {
104 g_hash_table_destroy(self
->theme_id_hash
);
105 self
->theme_id_hash
= NULL
;
107 if (self
->remote_id_hash
!= NULL
) {
108 g_hash_table_destroy(self
->remote_id_hash
);
109 self
->remote_id_hash
= NULL
;
116 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
117 /* Private Functions */
118 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
121 * @name Private Functions
126 * A simple test on Irreco WebDB to test if WebDB returns correct and
127 * meaningfull results.
129 * This function generates two numbers and asks WebDB to sum them. If the sum
130 * if correct, then our connection to the WebDB seems to be working.
132 * @return TRUE on success, FALSE otherwise.
134 static gboolean
irreco_webdb_cache_test(IrrecoWebdbCache
*self
)
136 IrrecoWebdbClient
*client
;
143 if (self
->test_ok
) IRRECO_RETURN_BOOL(self
->test_ok
);
146 client
= (IrrecoWebdbClient
*) self
->private;
148 IRRECO_RETRY_LOOP_START(self
->loop
)
149 num_a
= g_rand_int_range(rand
, 1, 1000);
150 num_b
= g_rand_int_range(rand
, 1, 1000);
151 self
->test_ok
= irreco_webdb_client_sum(
152 client
, num_a
, num_b
, &sum
);
155 if (sum
== num_a
+ num_b
) {
158 g_string_printf(self
->error_msg
,
159 "Got invalid result from "
160 "sum method. %i + %i = %i. "
162 num_a
, num_b
, (gint
) sum
,
164 IRRECO_PRINTF("%s\n", self
->error_msg
->str
);
165 self
->test_ok
= FALSE
;
168 irreco_webdb_client_get_error_msg(
169 client
, self
->error_msg
);
171 IRRECO_RETRY_LOOP_END(self
->loop
)
174 IRRECO_RETURN_BOOL(self
->test_ok
);
178 * Shows error message in case categories list is empty.
180 * @return TRUE if categories is not empty, FALSE otherwise.
182 static gboolean
irreco_webdb_cache_verify_category(IrrecoWebdbCache
*self
)
185 if (self
->categories
== NULL
) {
186 g_string_printf(self
->error_msg
, "list of categories is NULL");
187 IRRECO_PRINTF("%s\n", self
->error_msg
->str
);
188 IRRECO_RETURN_BOOL(FALSE
)
190 IRRECO_RETURN_BOOL(TRUE
)
194 * Shows error message in case manufacturers list is empty.
196 * @return TRUE if manufacturers list contains data, FALSE otherwise.
199 irreco_webdb_cache_verify_manufacturer(IrrecoWebdbCache
*self
,
200 const gchar
*category
,
201 IrrecoStringTable
**manufactures
)
204 if (!irreco_string_table_get(self
->categories
, category
,
205 (gpointer
*) manufactures
)) {
206 g_string_printf(self
->error_msg
,
207 "list of manufacturers is NULL");
208 IRRECO_PRINTF("%s\n", self
->error_msg
->str
);
209 IRRECO_RETURN_BOOL(FALSE
)
211 IRRECO_RETURN_BOOL(TRUE
)
216 * Shows error message in case models list is empty.
218 * @return TRUE if models list contains data, FALSE otherwise.
220 static gboolean
irreco_webdb_cache_verify_model(IrrecoWebdbCache
*self
,
221 IrrecoStringTable
*manuf_list
,
222 const gchar
*manufacturer
,
223 IrrecoStringTable
**models
)
226 if (!irreco_string_table_get(manuf_list
, manufacturer
,
227 (gpointer
*) models
)) {
228 g_string_printf(self
->error_msg
, "list of models is NULL");
229 IRRECO_PRINTF("%s\n", self
->error_msg
->str
);
230 IRRECO_RETURN_BOOL(FALSE
)
232 IRRECO_RETURN_BOOL(TRUE
)
236 * Shows error message in case configurations list is empty.
238 * @return TRUE if configurations list contains data, FALSE otherwise.
240 static gboolean
irreco_webdb_cache_verify_config(IrrecoWebdbCache
*self
,
241 IrrecoStringTable
*models
,
243 IrrecoStringTable
**configs
)
246 if (!irreco_string_table_get(models
, model
, (gpointer
*) configs
)) {
247 g_string_printf(self
->error_msg
,
248 "list of configurations is NULL");
249 IRRECO_PRINTF("%s\n", self
->error_msg
->str
);
250 IRRECO_RETURN_BOOL(FALSE
)
252 IRRECO_RETURN_BOOL(TRUE
)
257 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
259 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
262 * @name Public Functions
268 * Adds new user (name, email, password) to database.
270 * @return TRUE if user is added succesfully, FALSE otherwise.
272 gboolean
irreco_webdb_cache_add_user(IrrecoWebdbCache
*self
,
277 IrrecoWebdbClient
*client
;
281 client
= (IrrecoWebdbClient
*) self
->private;
283 IRRECO_RETRY_LOOP_START(self
->loop
)
284 /* test connection to webdb */
285 if (irreco_webdb_cache_test(self
) == FALSE
){
286 g_string_printf(self
->error_msg
,
287 "Failed cache self test.");
288 IRRECO_PRINTF("%s\n", self
->error_msg
->str
);
289 IRRECO_RETURN_BOOL(FALSE
);
292 if(irreco_webdb_client_add_user(client
, name
, email
, passwd
)) {
293 IRRECO_RETURN_BOOL(TRUE
);
295 /* irreco_webdb_client_add_user failed, get err msg */
296 irreco_webdb_client_get_error_msg(client
,
298 IRRECO_RETURN_BOOL(FALSE
);
300 IRRECO_RETRY_LOOP_END(self
->loop
)
302 IRRECO_RETURN_BOOL(FALSE
);
306 * Adds new configuration to database.
308 * @return TRUE if configuration is uploaded succesfully, FALSE otherwise.
310 gboolean
irreco_webdb_cache_upload_configuration(IrrecoWebdbCache
*self
,
311 const gchar
*backend
,
312 const gchar
*category
,
313 const gchar
*file_hash
,
314 const gchar
*file_name
,
315 const gchar
*manufacturer
,
317 const gchar
*password
,
321 IrrecoWebdbClient
*client
;
325 client
= (IrrecoWebdbClient
*) self
->private;
327 IRRECO_RETRY_LOOP_START(self
->loop
)
328 /* test connection to webdb */
329 if (irreco_webdb_cache_test(self
) == FALSE
){
330 g_string_printf(self
->error_msg
,
331 "Failed cache self test.");
332 IRRECO_PRINTF("%s\n", self
->error_msg
->str
);
333 IRRECO_RETURN_BOOL(FALSE
);
336 if(irreco_webdb_client_upload_configuration(client
, backend
,
337 category
, file_hash
, file_name
,
338 manufacturer
, model
, password
, user
,
341 IRRECO_RETURN_BOOL(TRUE
);
343 /* irreco_webdb_client_upload_configuration failed,
345 irreco_webdb_client_get_error_msg(client
,
347 IRRECO_RETURN_BOOL(FALSE
);
349 IRRECO_RETRY_LOOP_END(self
->loop
)
351 IRRECO_RETURN_BOOL(FALSE
);
355 * Extracts error message from IrrecoWebdbCache object.
357 * @return error message as string.
359 const gchar
*irreco_webdb_cache_get_error(IrrecoWebdbCache
*self
)
362 IRRECO_RETURN_STR(self
->error_msg
->str
);
366 * Fetches categories from DB
368 * @return TRUE if categories are fetched succesfully, FALSE otherwise.
370 gboolean
irreco_webdb_cache_get_categories(IrrecoWebdbCache
*self
,
371 IrrecoStringTable
**categories
)
375 if (self
->categories
== NULL
) {
376 gboolean success
= FALSE
;
377 IrrecoWebdbClient
*client
= (IrrecoWebdbClient
*) self
->private;
379 IRRECO_RETRY_LOOP_START(self
->loop
)
380 if (irreco_webdb_cache_test(self
) == FALSE
) break;
381 success
= irreco_webdb_client_get_categories(
382 client
, &self
->categories
);
386 irreco_webdb_client_get_error_msg(
387 client
, self
->error_msg
);
388 IRRECO_RETRY_LOOP_END(self
->loop
)
390 if (success
== FALSE
) IRRECO_RETURN_BOOL(FALSE
);
392 irreco_string_table_sort_abc (self
->categories
);
395 *categories
= self
->categories
;
396 IRRECO_RETURN_BOOL(TRUE
)
400 * Fetches all categories from DB.
402 * @param all_categories must be freed if return value is TRUE.
403 * @return TRUE if categories are fetched succesfully, FALSE otherwise.
405 gboolean
irreco_webdb_cache_get_all_categories(IrrecoWebdbCache
*self
,
406 IrrecoStringTable
**all_categories
)
408 gboolean success
= FALSE
;
409 IrrecoWebdbClient
*client
= (IrrecoWebdbClient
*) self
->private;
413 IRRECO_RETRY_LOOP_START(self
->loop
)
414 if (irreco_webdb_cache_test(self
) == FALSE
) break;
415 success
= irreco_webdb_client_get_all_categories(
416 client
, all_categories
);
420 irreco_webdb_client_get_error_msg(
421 client
, self
->error_msg
);
422 IRRECO_RETRY_LOOP_END(self
->loop
)
424 if (success
== FALSE
) IRRECO_RETURN_BOOL(FALSE
);
426 irreco_string_table_sort_abc(*all_categories
);
428 IRRECO_RETURN_BOOL(TRUE
)
432 * Fetches manufacturers from DB.
434 * @param category contains category in which type manufacturers are returned.
435 * @return TRUE if manufacturers are fetched succesfully, FALSE otherwise.
437 gboolean
irreco_webdb_cache_get_manufacturers(IrrecoWebdbCache
*self
,
438 const gchar
*category
,
439 IrrecoStringTable
**manufacturers
)
441 IrrecoStringTable
*manufacturer_list
;
444 if (!irreco_webdb_cache_verify_category(self
) ||
445 !irreco_webdb_cache_verify_manufacturer(self
, category
,
446 &manufacturer_list
)) {
447 IRRECO_RETURN_BOOL(FALSE
)
450 if(manufacturer_list
== NULL
) {
451 gboolean success
= FALSE
;
452 IrrecoWebdbClient
*client
= (IrrecoWebdbClient
*) self
->private;
454 IRRECO_RETRY_LOOP_START(self
->loop
)
455 if (irreco_webdb_cache_test(self
) == FALSE
) break;
456 success
= irreco_webdb_client_get_manufacturers(
457 client
, category
, &manufacturer_list
);
460 irreco_webdb_client_get_error_msg(
461 client
, self
->error_msg
);
462 IRRECO_RETRY_LOOP_END(self
->loop
)
464 if (success
== FALSE
) IRRECO_RETURN_BOOL(FALSE
);
466 irreco_string_table_sort_abc (manufacturer_list
);
467 irreco_string_table_change_data(self
->categories
, category
,
471 irreco_string_table_get(self
->categories
, category
,
472 (gpointer
*) manufacturers
);
473 IRRECO_RETURN_BOOL(TRUE
)
477 * Fetches all manufacturers from DB.
479 * @param all_manufacturers must be released if function returns TRUE.
480 * @return TRUE if manufacturers are fetched succesfully, FALSE otherwise.
482 gboolean
irreco_webdb_cache_get_all_manufacturers(IrrecoWebdbCache
*self
,
483 IrrecoStringTable
**all_manufacturers
)
485 gboolean success
= FALSE
;
486 IrrecoWebdbClient
*client
= (IrrecoWebdbClient
*) self
->private;
490 IRRECO_RETRY_LOOP_START(self
->loop
)
491 if (irreco_webdb_cache_test(self
) == FALSE
) break;
492 success
= irreco_webdb_client_get_all_manufacturers(
493 client
, all_manufacturers
);
497 irreco_webdb_client_get_error_msg(
498 client
, self
->error_msg
);
499 IRRECO_RETRY_LOOP_END(self
->loop
)
501 if (success
== FALSE
) IRRECO_RETURN_BOOL(FALSE
);
503 irreco_string_table_sort_abc(*all_manufacturers
);
505 IRRECO_RETURN_BOOL(TRUE
)
509 * Fetches models belonging given category and manufacturer.
511 * @param models must be freed if function returns TRUE.
512 * @return TRUE if models are fetched succesfully, FALSE otherwise.
514 gboolean
irreco_webdb_cache_get_models(IrrecoWebdbCache
*self
,
515 const gchar
*category
,
516 const gchar
*manufacturer
,
517 IrrecoStringTable
**models
)
519 IrrecoStringTable
*model_list
;
520 IrrecoStringTable
*manufacturer_list
;
523 if (!irreco_webdb_cache_verify_category(self
) ||
524 !irreco_webdb_cache_verify_manufacturer(self
, category
,
525 &manufacturer_list
) ||
526 !irreco_webdb_cache_verify_model(self
, manufacturer_list
,
527 manufacturer
, &model_list
)) {
528 IRRECO_RETURN_BOOL(FALSE
)
531 if(model_list
== NULL
) {
532 gboolean success
= FALSE
;
533 IrrecoWebdbClient
*client
= (IrrecoWebdbClient
*) self
->private;
535 IRRECO_RETRY_LOOP_START(self
->loop
)
536 if (irreco_webdb_cache_test(self
) == FALSE
) break;
537 success
= irreco_webdb_client_get_models(
538 client
, category
, manufacturer
, &model_list
);
541 irreco_webdb_client_get_error_msg(
542 client
, self
->error_msg
);
543 IRRECO_RETRY_LOOP_END(self
->loop
)
545 if (success
== FALSE
) IRRECO_RETURN_BOOL(FALSE
);
547 irreco_string_table_sort_abc (model_list
);
548 irreco_string_table_change_data(manufacturer_list
, manufacturer
,
552 irreco_string_table_get(manufacturer_list
, manufacturer
,
553 (gpointer
*) models
);
554 IRRECO_RETURN_BOOL(TRUE
)
558 * Fetches configs belonging given category, manufacturer and model.
560 * @return TRUE if configs are fetched succesfully, FALSE otherwise.
562 gboolean
irreco_webdb_cache_get_configs(IrrecoWebdbCache
*self
,
563 const gchar
*category
,
564 const gchar
*manufacturer
,
566 IrrecoStringTable
**configs
)
568 IrrecoStringTable
* config_list
;
569 IrrecoStringTable
* model_list
;
570 IrrecoStringTable
* manufacturer_list
;
573 if (!irreco_webdb_cache_verify_category(self
) ||
574 !irreco_webdb_cache_verify_manufacturer(self
, category
,
575 &manufacturer_list
) ||
576 !irreco_webdb_cache_verify_model(self
, manufacturer_list
,
577 manufacturer
, &model_list
) ||
578 !irreco_webdb_cache_verify_config(self
, model_list
, model
,
580 IRRECO_RETURN_BOOL(FALSE
)
583 if(config_list
== NULL
) {
584 gboolean success
= FALSE
;
585 IrrecoWebdbClient
*client
= (IrrecoWebdbClient
*) self
->private;
587 IRRECO_RETRY_LOOP_START(self
->loop
)
588 if (irreco_webdb_cache_test(self
) == FALSE
) break;
589 success
= irreco_webdb_client_get_configs(client
,
590 manufacturer
, model
, &config_list
);
593 irreco_webdb_client_get_error_msg(
594 client
, self
->error_msg
);
595 IRRECO_RETRY_LOOP_END(self
->loop
)
597 if (success
== FALSE
) IRRECO_RETURN_BOOL(FALSE
);
599 irreco_string_table_change_data(model_list
, model
, config_list
);
602 irreco_string_table_get(model_list
, model
, (gpointer
*) configs
);
603 IRRECO_RETURN_BOOL(TRUE
)
607 * Fetches configuration by given ID.
609 * @return TRUE if configuration is fetched succesfully, FALSE otherwise.
611 gboolean
irreco_webdb_cache_get_configuration(IrrecoWebdbCache
*self
,
613 IrrecoWebdbConf
**config
)
615 IrrecoWebdbConf
* configuration
;
618 configuration
= irreco_webdb_conf_new();
620 if (g_hash_table_lookup(self
->conf_hash
, (gconstpointer
) &id
) == NULL
) {
621 gboolean success
= FALSE
;
622 IrrecoWebdbClient
*client
= (IrrecoWebdbClient
*) self
->private;
624 IRRECO_RETRY_LOOP_START(self
->loop
)
625 if (irreco_webdb_cache_test(self
) == FALSE
) break;
626 success
= irreco_webdb_client_get_configuration(
627 client
, id
, &configuration
);
630 irreco_webdb_client_get_error_msg(client
,
632 IRRECO_RETRY_LOOP_END(self
->loop
)
634 if (success
== FALSE
) IRRECO_RETURN_BOOL(FALSE
);
636 g_hash_table_insert(self
->conf_hash
,
637 (gpointer
) &configuration
->id
,
638 (gpointer
) configuration
);
641 *config
= g_hash_table_lookup(self
->conf_hash
, (gconstpointer
) &id
);
643 IRRECO_RETURN_BOOL(TRUE
)
646 gint
irreco_webdb_cache_get_config_id(IrrecoWebdbCache
*self
,
647 const gchar
*file_hash
,
648 const gchar
*file_name
)
652 irreco_webdb_client_get_config_id_by_file_hash_and_file_name(
653 self
->private, file_hash
, file_name
));
657 * Fetches file by given hash and name.
659 * @return TRUE if configuration is fetched succesfully, FALSE otherwise.
661 gboolean
irreco_webdb_cache_get_file(IrrecoWebdbCache
*self
,
662 const gchar
*file_hash
,
663 const gchar
*file_name
,
667 gboolean success
= FALSE
;
668 IrrecoWebdbClient
*client
;
671 client
= (IrrecoWebdbClient
*) self
->private;
673 IRRECO_RETRY_LOOP_START(self
->loop
)
674 if (irreco_webdb_cache_test(self
) == FALSE
) break;
675 success
= irreco_webdb_client_get_file(
676 client
, file_hash
, file_name
, &file
);
679 irreco_webdb_client_get_error_msg(client
, self
->error_msg
);
680 IRRECO_RETRY_LOOP_END(self
->loop
)
682 if (success
== FALSE
) IRRECO_RETURN_BOOL(FALSE
);
686 IRRECO_RETURN_BOOL(TRUE
)
690 * Check if user with given name is already at DB.
692 *.@param user_exists will contain info wether user name was at DB.
693 * @return TRUE if test is done succesfully, FALSE otherwise.
695 gboolean
irreco_webdb_cache_get_user_exists(IrrecoWebdbCache
*self
,
697 gboolean
*user_exists
)
699 IrrecoWebdbClient
*client
;
700 gboolean success
= FALSE
;
703 client
= (IrrecoWebdbClient
*) self
->private;
704 IRRECO_RETRY_LOOP_START(self
->loop
)
705 /* test connection to webdb */
706 if (irreco_webdb_cache_test(self
) == FALSE
) break;
708 success
= irreco_webdb_client_get_user_exists(client
,
714 /* irreco_webdb_client_get_user_exists failed, get err msg */
715 irreco_webdb_client_get_error_msg(client
, self
->error_msg
);
716 IRRECO_RETRY_LOOP_END(self
->loop
)
718 if (success
== FALSE
) IRRECO_RETURN_BOOL(FALSE
);
720 IRRECO_RETURN_BOOL(TRUE
)
724 * Get maximum image size accepted by database
726 gint
irreco_webdb_cache_get_max_image_size(IrrecoWebdbCache
*self
)
728 IrrecoWebdbClient
*client
;
730 client
= (IrrecoWebdbClient
*) self
->private;
731 IRRECO_RETURN_INT(irreco_webdb_client_get_max_image_size(client
));
737 gint
irreco_webdb_cache_create_theme(IrrecoWebdbCache
*self
,
739 const gchar
*comment
,
740 const gchar
*preview_button
,
743 const gchar
*password
)
745 IrrecoWebdbClient
*client
;
747 client
= (IrrecoWebdbClient
*) self
->private;
748 IRRECO_RETURN_INT(irreco_webdb_client_create_theme(
759 * Set theme downloadable
761 gboolean
irreco_webdb_cache_set_theme_downloadable(IrrecoWebdbCache
*self
,
763 gboolean downloadable
,
765 const gchar
*password
)
767 IrrecoWebdbClient
*client
;
769 client
= (IrrecoWebdbClient
*) self
->private;
770 IRRECO_RETURN_BOOL(irreco_webdb_client_set_theme_downloadable(
781 * @return TRUE if login is succesful, FALSE otherwise.
783 gboolean
irreco_webdb_cache_login(IrrecoWebdbCache
*self
,
785 const gchar
*password
)
787 IrrecoWebdbClient
*client
;
791 client
= (IrrecoWebdbClient
*) self
->private;
793 IRRECO_RETRY_LOOP_START(self
->loop
)
794 /* test connection to webdb */
795 if (irreco_webdb_cache_test(self
) == FALSE
){
796 g_string_printf(self
->error_msg
,
797 "Failed cache self test.");
798 IRRECO_PRINTF("%s\n", self
->error_msg
->str
);
799 IRRECO_RETURN_BOOL(FALSE
);
802 if(irreco_webdb_client_login(client
, user
, password
)) {
804 IRRECO_RETURN_BOOL(TRUE
);
806 /* irreco_webdb_client_login failed,
808 irreco_webdb_client_get_error_msg(client
,
810 IRRECO_RETURN_BOOL(FALSE
);
812 IRRECO_RETRY_LOOP_END(self
->loop
)
814 IRRECO_RETURN_BOOL(FALSE
);
817 gboolean
irreco_webdb_cache_get_themes(IrrecoWebdbCache
*self
,
818 IrrecoStringTable
**theme
)
820 gboolean success
= FALSE
;
821 IrrecoWebdbClient
*client
= (IrrecoWebdbClient
*) self
->private;
824 IRRECO_RETRY_LOOP_START(self
->loop
)
825 if (irreco_webdb_cache_test(self
) == FALSE
) break;
826 success
= irreco_webdb_client_get_themes(client
, theme
);
829 irreco_webdb_client_get_error_msg(client
, self
->error_msg
);
830 IRRECO_RETRY_LOOP_END(self
->loop
)
832 IRRECO_RETURN_BOOL(success
)
835 gboolean
irreco_webdb_cache_get_theme_by_id(IrrecoWebdbCache
*self
,
837 IrrecoWebdbTheme
**theme
)
839 IrrecoWebdbTheme
*get_theme
;
843 if (g_hash_table_lookup(self
->theme_id_hash
,
844 (gconstpointer
) &theme_id
) == NULL
) {
845 gboolean success
= FALSE
;
846 IrrecoWebdbClient
*client
= (IrrecoWebdbClient
*) self
->private;
848 IRRECO_RETRY_LOOP_START(self
->loop
)
849 if (irreco_webdb_cache_test(self
) == FALSE
) break;
850 success
= irreco_webdb_client_get_theme_by_id(
851 client
, theme_id
, &get_theme
);
854 irreco_webdb_client_get_error_msg(client
,
856 IRRECO_RETRY_LOOP_END(self
->loop
)
858 if (success
== FALSE
) IRRECO_RETURN_BOOL(FALSE
);
860 g_hash_table_insert(self
->theme_id_hash
,
861 (gpointer
) &get_theme
->id
,
862 (gpointer
) get_theme
);
865 *theme
= g_hash_table_lookup(self
->theme_id_hash
, (gconstpointer
) &theme_id
);
867 IRRECO_RETURN_BOOL(TRUE
)
870 gint
irreco_webdb_cache_get_theme_id_by_name_and_date(IrrecoWebdbCache
*self
,
875 IRRECO_RETURN_INT(irreco_webdb_client_get_theme_id_by_name_and_date(
876 self
->private, name
, date
));
880 gboolean
irreco_webdb_cache_get_preview_button(IrrecoWebdbCache
*self
,
882 IrrecoWebdbTheme
**theme
)
884 gboolean success
= TRUE
;
885 IrrecoWebdbClient
*client
= (IrrecoWebdbClient
*) self
->private;
888 *theme
= g_hash_table_lookup(self
->theme_id_hash
,
889 (gconstpointer
) &theme_id
);
890 if (*theme
== NULL
) {
891 success
= irreco_webdb_cache_get_theme_by_id(self
, theme_id
,
893 if (success
== FALSE
) {
894 irreco_webdb_client_get_error_msg(client
, self
->error_msg
);
899 if ((*theme
)->preview_button
== NULL
)
901 IRRECO_RETRY_LOOP_START(self
->loop
)
903 if (irreco_webdb_cache_test(self
) == FALSE
) break;
905 success
= irreco_webdb_client_get_preview_button(client
,
906 theme_id
, &(*theme
)->preview_button
);
910 irreco_webdb_client_get_error_msg(client
, self
->error_msg
);
911 IRRECO_RETRY_LOOP_END(self
->loop
)
916 IRRECO_RETURN_BOOL(success
)
922 gint
irreco_webdb_cache_add_bg_to_theme(IrrecoWebdbCache
*self
,
924 const gchar
*image_hash
,
925 const gchar
*image_name
,
931 const gchar
*password
)
933 IrrecoWebdbClient
*client
;
935 client
= (IrrecoWebdbClient
*) self
->private;
936 IRRECO_RETURN_INT(irreco_webdb_client_add_bg_to_theme(
949 gboolean
irreco_webdb_cache_get_backgrounds(IrrecoWebdbCache
*self
,
951 IrrecoStringTable
**bg_list
){
952 IrrecoWebdbClient
*client
;
953 gboolean success
= TRUE
;
956 client
= (IrrecoWebdbClient
*) self
->private;
957 IRRECO_RETRY_LOOP_START(self
->loop
)
958 if (irreco_webdb_cache_test(self
) == FALSE
) break;
959 success
= irreco_webdb_client_get_backgrounds(client
,
963 irreco_webdb_client_get_error_msg(client
, self
->error_msg
);
964 IRRECO_RETRY_LOOP_END(self
->loop
)
966 IRRECO_RETURN_BOOL(success
)
969 gboolean
irreco_webdb_cache_get_bg_by_id(IrrecoWebdbCache
*self
,
971 const char *theme_bg_dir
)
973 IrrecoWebdbClient
*client
= (IrrecoWebdbClient
*) self
->private;
974 gboolean success
= TRUE
;
977 IRRECO_RETRY_LOOP_START(self
->loop
)
978 if (irreco_webdb_cache_test(self
) == FALSE
) break;
979 success
= irreco_webdb_client_get_bg_by_id(client
,
983 irreco_webdb_client_get_error_msg(client
, self
->error_msg
);
984 IRRECO_RETRY_LOOP_END(self
->loop
)
985 IRRECO_RETURN_BOOL(success
)
989 * Add button to theme
991 gint
irreco_webdb_cache_add_button_to_theme(IrrecoWebdbCache
*self
,
994 const gchar
*text_format_up
,
995 const gchar
*text_format_down
,
999 const gchar
*image_up_hash
,
1000 const gchar
*image_up_name
,
1001 const guchar
*image_up
,
1003 const gchar
*image_down_hash
,
1004 const gchar
*image_down_name
,
1005 const guchar
*image_down
,
1006 gint image_down_len
,
1007 const gchar
*folder
,
1010 const gchar
*password
)
1012 IrrecoWebdbClient
*client
;
1014 client
= (IrrecoWebdbClient
*) self
->private;
1015 IRRECO_RETURN_INT(irreco_webdb_client_add_button_to_theme(
1038 gboolean
irreco_webdb_cache_get_buttons(IrrecoWebdbCache
*self
,
1040 IrrecoStringTable
**button_list
)
1042 IrrecoWebdbClient
*client
= (IrrecoWebdbClient
*) self
->private;
1043 gboolean success
= TRUE
;
1046 IRRECO_RETRY_LOOP_START(self
->loop
)
1047 if (irreco_webdb_cache_test(self
) == FALSE
) break;
1048 success
= irreco_webdb_client_get_buttons(client
,
1052 irreco_webdb_client_get_error_msg(client
, self
->error_msg
);
1053 IRRECO_RETRY_LOOP_END(self
->loop
)
1054 IRRECO_RETURN_BOOL(success
)
1057 gboolean
irreco_webdb_cache_get_button_by_id(IrrecoWebdbCache
*self
,
1059 const char *theme_button_dir
)
1061 IrrecoWebdbClient
*client
= (IrrecoWebdbClient
*) self
->private;
1062 gboolean success
= TRUE
;
1065 IRRECO_RETRY_LOOP_START(self
->loop
)
1066 if (irreco_webdb_cache_test(self
) == FALSE
) break;
1067 success
= irreco_webdb_client_get_button_by_id(client
,
1071 irreco_webdb_client_get_error_msg(client
, self
->error_msg
);
1072 IRRECO_RETRY_LOOP_END(self
->loop
)
1074 IRRECO_RETURN_BOOL(success
)
1078 gint
irreco_webdb_cache_create_new_remote(IrrecoWebdbCache
*self
,
1079 const gchar
*comment
,
1080 const gchar
*category
,
1081 const gchar
*manufacturer
,
1083 const gchar
*file_name
,
1084 const gchar
*file_data
,
1086 const gchar
*password
)
1089 if (irreco_webdb_cache_test(self
) == FALSE
) IRRECO_RETURN_INT(0);
1090 IRRECO_RETURN_INT(irreco_webdb_client_create_new_remote(self
->private,
1091 comment
, category
, manufacturer
, model
, file_name
,
1092 file_data
, user
, password
));
1095 gboolean
irreco_webdb_cache_set_remote_downloadable(IrrecoWebdbCache
*self
,
1097 gboolean downloadable
,
1099 const gchar
*password
)
1104 IRRECO_RETRY_LOOP_START(self
->loop
)
1105 if (irreco_webdb_cache_test(self
) == FALSE
) break;
1106 success
= irreco_webdb_client_set_remote_downloadable(
1107 self
->private, id
, downloadable
, user
, password
);
1109 irreco_webdb_client_get_error_msg(self
->private,
1111 IRRECO_RETRY_LOOP_END(self
->loop
)
1112 IRRECO_RETURN_BOOL(success
);
1115 gboolean
irreco_webdb_cache_add_configuration_to_remote(IrrecoWebdbCache
*self
,
1117 gint configuration_id
,
1119 const gchar
*password
)
1124 IRRECO_RETRY_LOOP_START(self
->loop
)
1125 if (irreco_webdb_cache_test(self
) == FALSE
) break;
1126 success
= irreco_webdb_client_add_configuration_to_remote(
1127 self
->private, remote_id
,
1128 configuration_id
, user
,
1131 irreco_webdb_client_get_error_msg(self
->private,
1133 IRRECO_RETRY_LOOP_END(self
->loop
)
1134 IRRECO_RETURN_BOOL(success
);
1137 gboolean
irreco_webdb_cache_add_theme_to_remote(IrrecoWebdbCache
*self
,
1141 const gchar
*password
)
1146 IRRECO_RETRY_LOOP_START(self
->loop
)
1147 if (irreco_webdb_cache_test(self
) == FALSE
) break;
1148 success
= irreco_webdb_client_add_theme_to_remote(
1149 self
->private, remote_id
,
1150 theme_id
, user
, password
);
1152 irreco_webdb_client_get_error_msg(self
->private,
1154 IRRECO_RETRY_LOOP_END(self
->loop
)
1155 IRRECO_RETURN_BOOL(success
);
1159 * Fetches remote categories from DB
1161 * @param categories points to internally allocated storage in the cache
1162 * and must not be freed
1163 * @return TRUE if categories are fetched succesfully, FALSE otherwise.
1165 gboolean
irreco_webdb_cache_get_remote_categories(IrrecoWebdbCache
*self
,
1166 IrrecoStringTable
**categories
)
1170 if (self
->remote_categories
== NULL
) {
1171 gboolean success
= FALSE
;
1173 IRRECO_RETRY_LOOP_START(self
->loop
)
1174 if (irreco_webdb_cache_test(self
) == FALSE
) break;
1175 success
= irreco_webdb_client_get_remote_categories(
1176 self
->private, &self
->remote_categories
);
1180 irreco_webdb_client_get_error_msg(self
->private,
1182 IRRECO_RETRY_LOOP_END(self
->loop
)
1184 if (success
== FALSE
) IRRECO_RETURN_BOOL(FALSE
);
1186 irreco_string_table_sort_abc(self
->remote_categories
);
1189 *categories
= self
->remote_categories
;
1190 IRRECO_RETURN_BOOL(TRUE
)
1194 * Fetches remote manufacturers from DB.
1196 * @param category contains category in which type manufacturers are returned.
1197 * @param manufacturers points to internally allocated storage in the cache
1198 * and must not be freed
1199 * @return TRUE if manufacturers are fetched succesfully, FALSE otherwise.
1201 gboolean
irreco_webdb_cache_get_remote_manufacturers(IrrecoWebdbCache
*self
,
1202 const gchar
*category
,
1203 IrrecoStringTable
**manufacturers
)
1205 IrrecoStringTable
*categories
;
1206 IrrecoStringTable
*manufacturer_list
;
1209 if (!irreco_webdb_cache_get_remote_categories(self
, &categories
)) {
1210 IRRECO_RETURN_BOOL(FALSE
)
1213 if (!irreco_string_table_exists(categories
, category
)) {
1214 g_string_printf(self
->error_msg
, "%s",
1215 "Can't find category");
1216 IRRECO_RETURN_BOOL(FALSE
)
1219 irreco_string_table_get(categories
, category
,
1220 (gpointer
*) &manufacturer_list
);
1222 if (manufacturer_list
== NULL
) {
1223 gboolean success
= FALSE
;
1224 IRRECO_RETRY_LOOP_START(self
->loop
)
1225 if (irreco_webdb_cache_test(self
) == FALSE
) break;
1226 success
= irreco_webdb_client_get_remote_manufacturers(
1227 self
->private, category
, &manufacturer_list
);
1230 irreco_webdb_client_get_error_msg(self
->private,
1232 IRRECO_RETRY_LOOP_END(self
->loop
)
1234 if (success
== FALSE
) IRRECO_RETURN_BOOL(FALSE
);
1236 irreco_string_table_sort_abc (manufacturer_list
);
1237 irreco_string_table_change_data(categories
, category
,
1241 irreco_string_table_get(categories
, category
,
1242 (gpointer
*) manufacturers
);
1244 IRRECO_RETURN_BOOL(TRUE
)
1248 * Fetches remote models belonging given category and manufacturer.
1250 * @param models points to internally allocated storage in the cache
1251 * and must not be freed
1252 * @return TRUE if models are fetched succesfully, FALSE otherwise.
1254 gboolean
irreco_webdb_cache_get_remote_models(IrrecoWebdbCache
*self
,
1255 const gchar
*category
,
1256 const gchar
*manufacturer
,
1257 IrrecoStringTable
**models
)
1259 IrrecoStringTable
*manufacturer_list
;
1260 IrrecoStringTable
*model_list
;
1263 if (!irreco_webdb_cache_get_remote_manufacturers(self
, category
,
1264 &manufacturer_list
)) {
1265 IRRECO_RETURN_BOOL(FALSE
)
1268 if (!irreco_string_table_exists(manufacturer_list
, manufacturer
)) {
1269 g_string_printf(self
->error_msg
, "%s",
1270 "Can't find manufacturer");
1271 IRRECO_RETURN_BOOL(FALSE
)
1274 irreco_string_table_get(manufacturer_list
, manufacturer
,
1275 (gpointer
*) &model_list
);
1277 if(model_list
== NULL
) {
1278 gboolean success
= FALSE
;
1280 IRRECO_RETRY_LOOP_START(self
->loop
)
1281 if (irreco_webdb_cache_test(self
) == FALSE
) break;
1282 success
= irreco_webdb_client_get_remote_models(
1283 self
->private, category
, manufacturer
,
1287 irreco_webdb_client_get_error_msg(self
->private,
1289 IRRECO_RETRY_LOOP_END(self
->loop
)
1291 if (success
== FALSE
) IRRECO_RETURN_BOOL(FALSE
);
1293 irreco_string_table_sort_abc (model_list
);
1294 irreco_string_table_change_data(manufacturer_list
, manufacturer
,
1298 irreco_string_table_get(manufacturer_list
, manufacturer
,
1299 (gpointer
*) models
);
1300 IRRECO_RETURN_BOOL(TRUE
)
1304 * Fetches creators belonging given category, manufacturer and model.
1306 * @param creators points to internally allocated storage in the cache
1307 * and must not be freed
1308 * @return TRUE if configs are fetched succesfully, FALSE otherwise.
1310 gboolean
irreco_webdb_cache_get_remote_creators(IrrecoWebdbCache
*self
,
1311 const gchar
*category
,
1312 const gchar
*manufacturer
,
1314 IrrecoStringTable
**creators
)
1316 IrrecoStringTable
* model_list
;
1317 IrrecoStringTable
* creator_list
;
1320 if (!irreco_webdb_cache_get_remote_models(self
, category
, manufacturer
,
1322 IRRECO_RETURN_BOOL(FALSE
)
1325 if (!irreco_string_table_exists(model_list
, model
)) {
1326 g_string_printf(self
->error_msg
, "%s",
1327 "Can't find model");
1328 IRRECO_RETURN_BOOL(FALSE
)
1331 irreco_string_table_get(model_list
, model
, (gpointer
*) &creator_list
);
1333 if(creator_list
== NULL
) {
1334 gboolean success
= FALSE
;
1336 IRRECO_RETRY_LOOP_START(self
->loop
)
1337 if (irreco_webdb_cache_test(self
) == FALSE
) break;
1338 success
= irreco_webdb_client_get_remote_creators(
1339 self
->private, category
, manufacturer
,
1340 model
, &creator_list
);
1343 irreco_webdb_client_get_error_msg(self
->private,
1345 IRRECO_RETRY_LOOP_END(self
->loop
)
1347 if (success
== FALSE
) IRRECO_RETURN_BOOL(FALSE
);
1349 irreco_string_table_change_data(model_list
, model
,
1353 irreco_string_table_get(model_list
, model
, (gpointer
*) creators
);
1354 IRRECO_RETURN_BOOL(TRUE
)
1358 * Fetches creators belonging given category, manufacturer and model.
1360 * @param creators points to internally allocated storage in the cache
1361 * and must not be freed
1362 * @return TRUE if configs are fetched succesfully, FALSE otherwise.
1364 gboolean
irreco_webdb_cache_get_remotes(IrrecoWebdbCache
*self
,
1365 const gchar
*category
,
1366 const gchar
*manufacturer
,
1368 const gchar
*creator
,
1369 GList
**remote_list
)
1371 IrrecoStringTable
* creator_list
;
1374 if (!irreco_webdb_cache_get_remote_creators(self
, category
,
1375 manufacturer
, model
,
1377 IRRECO_RETURN_BOOL(FALSE
)
1380 if (!irreco_string_table_exists(creator_list
, creator
)) {
1381 g_string_printf(self
->error_msg
, "%s",
1382 "Can't find creator");
1383 IRRECO_RETURN_BOOL(FALSE
)
1386 irreco_string_table_get(creator_list
, creator
,
1387 (gpointer
*) remote_list
);
1389 if(*remote_list
== NULL
) {
1390 gboolean success
= FALSE
;
1392 IRRECO_RETRY_LOOP_START(self
->loop
)
1393 if (irreco_webdb_cache_test(self
) == FALSE
) break;
1394 success
= irreco_webdb_client_get_remotes(self
->private,
1395 category
, manufacturer
, model
,
1396 creator
, remote_list
);
1399 irreco_webdb_client_get_error_msg(self
->private,
1401 IRRECO_RETRY_LOOP_END(self
->loop
)
1403 if (success
== FALSE
) IRRECO_RETURN_BOOL(FALSE
);
1405 irreco_string_table_change_data(creator_list
, creator
,
1409 irreco_string_table_get(creator_list
, creator
,
1410 (gpointer
*) remote_list
);
1411 IRRECO_RETURN_BOOL(TRUE
)
1415 * Fetches remote by given ID.
1417 * @param remote points to internally allocated storage in the cache
1418 * and must not be freed
1419 * @return TRUE if remote is fetched succesfully, FALSE otherwise.
1421 gboolean
irreco_webdb_cache_get_remote_by_id(IrrecoWebdbCache
*self
,
1423 IrrecoWebdbRemote
**remote
)
1427 if (g_hash_table_lookup(self
->remote_id_hash
,
1428 (gconstpointer
) &id
) == NULL
) {
1429 gboolean success
= FALSE
;
1431 IRRECO_RETRY_LOOP_START(self
->loop
)
1432 if (irreco_webdb_cache_test(self
) == FALSE
) break;
1433 success
= irreco_webdb_client_get_remote_by_id(
1434 self
->private, id
, remote
);
1437 irreco_webdb_client_get_error_msg(self
->private,
1439 IRRECO_RETRY_LOOP_END(self
->loop
)
1441 if (success
== FALSE
) IRRECO_RETURN_BOOL(FALSE
);
1443 g_hash_table_insert(self
->remote_id_hash
,
1444 (gpointer
) &((*remote
)->id
),
1445 (gpointer
) *remote
);
1448 *remote
= g_hash_table_lookup(self
->remote_id_hash
,
1449 (gconstpointer
) &id
);
1451 IRRECO_RETURN_BOOL(TRUE
)
1455 * Fetches configurations belonging given remote_id.
1457 * @param configs points to internally allocated storage in the cache
1458 * and must not be freed
1459 * @return TRUE if remote is fetched succesfully, FALSE otherwise.
1461 gboolean
irreco_webdb_cache_get_configurations_of_remote(IrrecoWebdbCache
*self
,
1465 IrrecoWebdbRemote
*remote
;
1466 GList
*configuration_list
= NULL
;
1467 gboolean success
= FALSE
;
1470 if (!irreco_webdb_cache_get_remote_by_id(self
, remote_id
, &remote
)) {
1471 IRRECO_RETURN_BOOL(FALSE
)
1475 if (remote
->configurations
!= NULL
) {
1479 IRRECO_RETRY_LOOP_START(self
->loop
)
1480 if (irreco_webdb_cache_test(self
) == FALSE
) break;
1481 success
= irreco_webdb_client_get_configurations_of_remote(
1482 self
->private, remote_id
,
1483 &configuration_list
);
1486 irreco_webdb_client_get_error_msg(self
->private,
1488 IRRECO_RETRY_LOOP_END(self
->loop
)
1490 if (success
== FALSE
) IRRECO_RETURN_BOOL(FALSE
);
1492 configuration_list
= g_list_first(configuration_list
);
1493 while(configuration_list
) {
1494 irreco_webdb_remote_add_configuration_id(remote
,
1495 GPOINTER_TO_INT(configuration_list
->data
));
1496 configuration_list
= configuration_list
->next
;
1498 g_list_free(configuration_list
);
1501 *configs
= remote
->configurations
;
1503 IRRECO_RETURN_BOOL(TRUE
)
1507 * Fetches themes belonging given remote_id.
1509 * @param themes points to internally allocated storage in the cache
1510 * and must not be freed
1511 * @return TRUE if remote is fetched succesfully, FALSE otherwise.
1513 gboolean
irreco_webdb_cache_get_themes_of_remote(IrrecoWebdbCache
*self
,
1517 IrrecoWebdbRemote
*remote
;
1518 GList
*theme_list
= NULL
;
1519 gboolean success
= FALSE
;
1522 if (!irreco_webdb_cache_get_remote_by_id(self
, remote_id
, &remote
)) {
1523 IRRECO_RETURN_BOOL(FALSE
)
1526 if (remote
->themes
!= NULL
) {
1530 IRRECO_RETRY_LOOP_START(self
->loop
)
1531 if (irreco_webdb_cache_test(self
) == FALSE
) break;
1532 success
= irreco_webdb_client_get_themes_of_remote(
1533 self
->private, remote_id
,
1537 irreco_webdb_client_get_error_msg(self
->private,
1539 IRRECO_RETRY_LOOP_END(self
->loop
)
1541 if (success
== FALSE
) IRRECO_RETURN_BOOL(FALSE
);
1543 theme_list
= g_list_first(theme_list
);
1545 irreco_webdb_remote_add_theme_id(remote
, GPOINTER_TO_INT(
1547 theme_list
= theme_list
->next
;
1549 g_list_free(theme_list
);
1552 *themes
= remote
->themes
;
1554 IRRECO_RETURN_BOOL(TRUE
)
1558 * Fetches remote data by given ID.
1560 * @return TRUE if data is fetched succesfully, FALSE otherwise.
1562 gboolean
irreco_webdb_cache_get_remote_data(IrrecoWebdbCache
*self
,
1569 IRRECO_RETRY_LOOP_START(self
->loop
)
1570 if (irreco_webdb_cache_test(self
) == FALSE
) break;
1571 success
= irreco_webdb_client_get_remote_data(self
->private,
1575 irreco_webdb_client_get_error_msg(self
->private,
1577 IRRECO_RETRY_LOOP_END(self
->loop
)
1578 IRRECO_RETURN_BOOL(success
);
1581 gboolean
irreco_webdb_cache_get_lirc_dirs(IrrecoWebdbCache
*self
,
1582 IrrecoStringTable
**dir_list
)
1584 gboolean success
= FALSE
;
1585 IrrecoWebdbClient
*client
= (IrrecoWebdbClient
*) self
->private;
1589 IRRECO_RETRY_LOOP_START(self
->loop
)
1590 if (irreco_webdb_cache_test(self
) == FALSE
) break;
1591 success
= irreco_webdb_client_get_lirc_dirs(client
,
1594 irreco_webdb_client_get_error_msg(client
,
1596 IRRECO_RETRY_LOOP_END(self
->loop
)
1598 if(success
== FALSE
) IRRECO_RETURN_BOOL(FALSE
);
1600 IRRECO_RETURN_BOOL(success
);
1603 gboolean
irreco_webdb_cache_get_lirc_manufacturers(IrrecoWebdbCache
*self
,
1605 IrrecoStringTable
**manufacturer_list
)
1607 gboolean success
= FALSE
;
1608 IrrecoWebdbClient
*client
= (IrrecoWebdbClient
*) self
->private;
1612 IRRECO_RETRY_LOOP_START(self
->loop
)
1613 if (irreco_webdb_cache_test(self
) == FALSE
) break;
1614 success
= irreco_webdb_client_get_lirc_manufacturers(
1619 irreco_webdb_client_get_error_msg(client
,
1621 IRRECO_RETRY_LOOP_END(self
->loop
)
1623 if(success
== FALSE
) IRRECO_RETURN_BOOL(FALSE
);
1625 IRRECO_RETURN_BOOL(success
);
1628 gboolean
irreco_webdb_cache_get_lirc_models(IrrecoWebdbCache
*self
,
1629 const gchar
*manufacturer
,
1630 IrrecoStringTable
**model_list
)
1632 gboolean success
= FALSE
;
1633 IrrecoWebdbClient
*client
= (IrrecoWebdbClient
*) self
->private;
1637 IRRECO_RETRY_LOOP_START(self
->loop
)
1638 if (irreco_webdb_cache_test(self
) == FALSE
) break;
1639 success
= irreco_webdb_client_get_lirc_models(
1644 irreco_webdb_client_get_error_msg(client
,
1646 IRRECO_RETRY_LOOP_END(self
->loop
)
1648 if(success
== FALSE
) IRRECO_RETURN_BOOL(FALSE
);
1650 IRRECO_RETURN_BOOL(success
);
1653 gboolean
irreco_webdb_cache_get_lirc_file(IrrecoWebdbCache
*self
,
1655 IrrecoStringTable
**file
)
1657 gboolean success
= FALSE
;
1658 IrrecoWebdbClient
*client
= (IrrecoWebdbClient
*) self
->private;
1662 IRRECO_RETRY_LOOP_START(self
->loop
)
1663 if (irreco_webdb_cache_test(self
) == FALSE
) break;
1664 success
= irreco_webdb_client_get_lirc_file(
1669 irreco_webdb_client_get_error_msg(client
,
1671 IRRECO_RETRY_LOOP_END(self
->loop
)
1673 if(success
== FALSE
) IRRECO_RETURN_BOOL(FALSE
);
1675 IRRECO_RETURN_BOOL(success
);
1680 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
1681 /* Events and Callbacks */
1682 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/