mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-20 20:50:19 +00:00
refactor: route exit saves through FE persistence wrapper; keep text mode simple
This commit is contained in:
@@ -44,11 +44,20 @@ typedef struct
|
|||||||
char *icon; /* filename */
|
char *icon; /* filename */
|
||||||
} menu_entry;
|
} menu_entry;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
gboolean success;
|
||||||
|
gboolean partial_failure;
|
||||||
|
gboolean config_failed;
|
||||||
|
gboolean theme_failed;
|
||||||
|
} fe_preferences_save_result;
|
||||||
|
|
||||||
int fe_args (int argc, char *argv[]);
|
int fe_args (int argc, char *argv[]);
|
||||||
void fe_init (void);
|
void fe_init (void);
|
||||||
void fe_main (void);
|
void fe_main (void);
|
||||||
void fe_cleanup (void);
|
void fe_cleanup (void);
|
||||||
void fe_exit (void);
|
void fe_exit (void);
|
||||||
|
fe_preferences_save_result fe_preferences_persistence_save_all (void);
|
||||||
int fe_timeout_add (int interval, void *callback, void *userdata);
|
int fe_timeout_add (int interval, void *callback, void *userdata);
|
||||||
int fe_timeout_add_seconds (int interval, void *callback, void *userdata);
|
int fe_timeout_add_seconds (int interval, void *callback, void *userdata);
|
||||||
void fe_timeout_remove (int tag);
|
void fe_timeout_remove (int tag);
|
||||||
|
|||||||
@@ -1104,8 +1104,18 @@ zoitechat_exit (void)
|
|||||||
plugin_kill_all ();
|
plugin_kill_all ();
|
||||||
fe_cleanup ();
|
fe_cleanup ();
|
||||||
|
|
||||||
if (!save_config ())
|
{
|
||||||
g_printerr ("Could not save zoitechat.conf.\n");
|
fe_preferences_save_result save_result;
|
||||||
|
|
||||||
|
save_result = fe_preferences_persistence_save_all ();
|
||||||
|
if (!save_result.success)
|
||||||
|
{
|
||||||
|
if (save_result.partial_failure || (!save_result.config_failed && save_result.theme_failed))
|
||||||
|
g_printerr ("Could not fully save preferences. zoitechat.conf was written, but colors.conf failed.\n");
|
||||||
|
else
|
||||||
|
g_printerr ("Could not save zoitechat.conf.\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
if (prefs.save_pevents)
|
if (prefs.save_pevents)
|
||||||
{
|
{
|
||||||
pevent_save (NULL);
|
pevent_save (NULL);
|
||||||
|
|||||||
@@ -59,6 +59,7 @@
|
|||||||
#include "plugin-notification.h"
|
#include "plugin-notification.h"
|
||||||
#include "theme/theme-manager.h"
|
#include "theme/theme-manager.h"
|
||||||
#include "theme/theme-application.h"
|
#include "theme/theme-application.h"
|
||||||
|
#include "preferences-persistence.h"
|
||||||
|
|
||||||
#ifdef USE_LIBCANBERRA
|
#ifdef USE_LIBCANBERRA
|
||||||
#include <canberra.h>
|
#include <canberra.h>
|
||||||
@@ -585,6 +586,21 @@ fe_cleanup (void)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fe_preferences_save_result
|
||||||
|
fe_preferences_persistence_save_all (void)
|
||||||
|
{
|
||||||
|
PreferencesPersistenceResult save_result;
|
||||||
|
fe_preferences_save_result result;
|
||||||
|
|
||||||
|
save_result = preferences_persistence_save_all ();
|
||||||
|
result.success = save_result.success;
|
||||||
|
result.partial_failure = save_result.partial_failure;
|
||||||
|
result.config_failed = save_result.config_failed;
|
||||||
|
result.theme_failed = save_result.theme_failed;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
fe_exit (void)
|
fe_exit (void)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -581,6 +581,19 @@ fe_exit (void)
|
|||||||
g_main_loop_quit(main_loop);
|
g_main_loop_quit(main_loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fe_preferences_save_result
|
||||||
|
fe_preferences_persistence_save_all (void)
|
||||||
|
{
|
||||||
|
fe_preferences_save_result result;
|
||||||
|
|
||||||
|
result.success = save_config () != 0;
|
||||||
|
result.partial_failure = FALSE;
|
||||||
|
result.config_failed = !result.success;
|
||||||
|
result.theme_failed = FALSE;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
fe_new_server (struct server *serv)
|
fe_new_server (struct server *serv)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user