From 603c087447542e7a37dc166a0a3bf13c91821130 Mon Sep 17 00:00:00 2001 From: Joni Kokko Date: Wed, 21 Jan 2009 16:36:47 +0200 Subject: [PATCH] Created system which uploads all configurations of remote to database --- irreco/src/core/irreco_remote_upload_dlg.c | 63 +++++++++++++++++++++++++++--- 1 file changed, 58 insertions(+), 5 deletions(-) diff --git a/irreco/src/core/irreco_remote_upload_dlg.c b/irreco/src/core/irreco_remote_upload_dlg.c index 5e7eb3cf..02c8ed90 100644 --- a/irreco/src/core/irreco_remote_upload_dlg.c +++ b/irreco/src/core/irreco_remote_upload_dlg.c @@ -20,6 +20,7 @@ #include "irreco_remote_upload_dlg.h" #include "irreco_login_dlg.h" #include "irreco_theme_upload_dlg.h" +#include "irreco_webdb_upload_dlg.h" #include "irreco_webdb_cache.h" /** Loader states. */ @@ -378,6 +379,7 @@ gboolean irreco_remote_upload_dlg_send(IrrecoRemoteUploadDlg *self) manufacturer, model, layout->filename->str, file_data, self->user_name, self->password); + if (self->remote_id != 0) { rvalue = TRUE; } @@ -396,12 +398,63 @@ gboolean irreco_remote_upload_dlg_send(IrrecoRemoteUploadDlg *self) IRRECO_RETURN_BOOL(TRUE); } - case LOADER_STATE_CONFIGURATIONS: + case LOADER_STATE_CONFIGURATIONS: { + IrrecoStringTable *devices = NULL; IRRECO_DEBUG("LOADER_STATE_CONFIGURATIONS\n"); + + if (!irreco_layout_get_backends(self->irreco_data, + layout->name->str, + &devices)) { + goto end_configurations; + } + IRRECO_STRING_TABLE_FOREACH(devices, name, + IrrecoBackendInstance *, instance) { + IrrecoBackendFileContainer *file = NULL; + gint id; + if (!irreco_backend_instance_export_conf(instance, name, + &file)) { + self->loader_state = LOADER_STATE_END; + IRRECO_DEBUG("exporting error"); + goto end_configurations; + } + id = irreco_webdb_cache_get_config_id(webdb_cache, + file->hash->str, + file->name->str); + + if (id == 0) { + irreco_show_webdb_upload_dlg(self->irreco_data, + GTK_WINDOW(self), + file, name); + + id = irreco_webdb_cache_get_config_id( + webdb_cache, + file->hash->str, + file->name->str); + + } + + /* Append configuration to remote */ + + if (id != 0) { + irreco_webdb_cache_add_configuration_to_remote( + webdb_cache, self->remote_id, id, + self->user_name, self->password); + } + + if (file != NULL) { + irreco_backend_file_container_free(file); + file = NULL; + } + } + IRRECO_STRING_TABLE_FOREACH_END + self->loader_state = LOADER_STATE_THEMES; + + end_configurations: + if (devices != NULL) irreco_string_table_free(devices); IRRECO_RETURN_BOOL(TRUE); + } case LOADER_STATE_THEMES: { - gboolean rvalue = TRUE; IrrecoStringTable *themes = NULL; IRRECO_DEBUG("LOADER_STATE_THEMES\n"); @@ -429,7 +482,7 @@ gboolean irreco_remote_upload_dlg_send(IrrecoRemoteUploadDlg *self) if (!irreco_theme_upload_dlg_run(GTK_WINDOW(self), self->irreco_data, theme)) { - rvalue = FALSE; + goto end_themes; } id = irreco_webdb_cache_get_theme_id_by_name_and_date( @@ -449,11 +502,11 @@ gboolean irreco_remote_upload_dlg_send(IrrecoRemoteUploadDlg *self) } IRRECO_STRING_TABLE_FOREACH_END - /* Set remote downloadable according to the rvalue */ + /* Set remote downloadable to TRUE */ irreco_webdb_cache_set_remote_downloadable(webdb_cache, self->remote_id, - rvalue, + TRUE, self->user_name, self->password); -- 2.11.4.GIT