[maemo-commits] [maemo-commits] r13321 - in projects/haf/branches/hildon-desktop: . karoliina-safe-mode karoliina-safe-mode/libhildondesktop karoliina-safe-mode/src
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Tue Aug 21 16:46:19 EEST 2007
- Previous message: [maemo-commits] r13320 - projects/haf/branches
- Next message: [maemo-commits] r13322 - in projects/haf/trunk/hildon-theme-layout-4: . rc
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: karoliina Date: 2007-08-21 16:46:16 +0300 (Tue, 21 Aug 2007) New Revision: 13321 Added: projects/haf/branches/hildon-desktop/karoliina-safe-mode/ Modified: projects/haf/branches/hildon-desktop/karoliina-safe-mode/ChangeLog projects/haf/branches/hildon-desktop/karoliina-safe-mode/libhildondesktop/hildon-desktop-window.c projects/haf/branches/hildon-desktop/karoliina-safe-mode/src/hd-desktop.c projects/haf/branches/hildon-desktop/karoliina-safe-mode/src/hd-plugin-manager.c projects/haf/branches/hildon-desktop/karoliina-safe-mode/src/hd-switcher-menu.c projects/haf/branches/hildon-desktop/karoliina-safe-mode/src/main.c Log: Created branch for plugin safe mode development. Copied: projects/haf/branches/hildon-desktop/karoliina-safe-mode (from rev 13317, projects/haf/trunk/hildon-desktop) Modified: projects/haf/branches/hildon-desktop/karoliina-safe-mode/ChangeLog =================================================================== --- projects/haf/trunk/hildon-desktop/ChangeLog 2007-08-21 11:47:59 UTC (rev 13317) +++ projects/haf/branches/hildon-desktop/karoliina-safe-mode/ChangeLog 2007-08-21 13:46:16 UTC (rev 13321) @@ -165,6 +165,20 @@ 2007-08-14 Lucas Rocha <lucas.rocha at nokia.com> + Patch from Karoliina Salminen <karoliina.t.salminen at nokia.com>. + + * src/hd-desktop.c: added stamp file creation & required includes. + * src/main.c: added stamp file removal after gtk_main (called through + g_object_unref) to allow clean up in case of a clean exit (with + no crash). + +2007-08-14 Lucas Rocha <lucas.rocha at nokia.com> + + * src/hd-applications-menu.c: small fix on category menu + items focus. Fixes NB#60571. + +2007-08-14 Lucas Rocha <lucas.rocha at nokia.com> + * configure.ac: 0.0.30 2007-08-14 Lucas Rocha <lucas.rocha at nokia.com> Modified: projects/haf/branches/hildon-desktop/karoliina-safe-mode/libhildondesktop/hildon-desktop-window.c =================================================================== --- projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-window.c 2007-08-21 11:47:59 UTC (rev 13317) +++ projects/haf/branches/hildon-desktop/karoliina-safe-mode/libhildondesktop/hildon-desktop-window.c 2007-08-21 13:46:16 UTC (rev 13321) @@ -66,12 +66,6 @@ priv = HILDON_DESKTOP_WINDOW_GET_PRIVATE (desktop_window); - if (desktop_window->container) - { - g_object_unref (desktop_window->container); - desktop_window = NULL; - } - G_OBJECT_CLASS (hildon_desktop_window_parent_class)->finalize (object); } Modified: projects/haf/branches/hildon-desktop/karoliina-safe-mode/src/hd-desktop.c =================================================================== --- projects/haf/trunk/hildon-desktop/src/hd-desktop.c 2007-08-21 11:47:59 UTC (rev 13317) +++ projects/haf/branches/hildon-desktop/karoliina-safe-mode/src/hd-desktop.c 2007-08-21 13:46:16 UTC (rev 13321) @@ -33,7 +33,12 @@ #include <gtk/gtk.h> #include <libgnomevfs/gnome-vfs.h> #include <glib/gi18n.h> +#include <glib/gstdio.h> +#include <sys/types.h> // Required for file io (creat etc.) +#include <sys/stat.h> // required for file io +#include <fcntl.h> // required for file io + #ifdef HAVE_LIBOSSO #include <libosso.h> #endif @@ -71,6 +76,16 @@ #define HD_DESKTOP_PING_TIMEOUT_BUTTON_OK_STRING _L10N( "qgn_bd_apkil_ok" ) #define HD_DESKTOP_PING_TIMEOUT_BUTTON_CANCEL_STRING _L10N( "qgn_bd_apkil_cancel" ) +/* + * Stamp file directory defines. This is needed by crash recovery system + * for detecting that Hildon Desktop has crashed, potentially because of some + * ill-behaving plugin. The stamp file will be cleaned up in device boot (because + * it is created on under /tmp/ and in hd-desktop finalize. + */ +#define STAMP_DIR "/tmp/osso-appl-states/" +#define HILDON_DESKTOP_STAMP_DIR "/tmp/osso-appl-states/hildon-desktop/" +#define HILDON_DESKTOP_STAMP_FILE HILDON_DESKTOP_STAMP_DIR"/stamp" + typedef struct { GtkWidget *parent; @@ -109,6 +124,13 @@ GQueue *dialog_queue; GObject *pm; GtkTreeModel *nm; + /* + * Safe mode flag for hd-desktop for knowing if non-policied + * plugins should be disabled. + * TRUE = safe mode active, plugins disabled + * FALSE = safe mode inactive, normal opration, plugins enabled + */ + gboolean safe_mode; #ifdef HAVE_LIBOSSO osso_context_t *osso_context; #endif @@ -479,8 +501,10 @@ error = NULL; } - if (is_to_load) + if (is_to_load) { plugin_list = g_list_append (plugin_list, groups[i]); + } + } g_free (groups); @@ -856,12 +880,21 @@ g_error_free (error); error = NULL; } - - load_new_plugins = g_key_file_get_boolean (keyfile, - groups[i], - HD_DESKTOP_CONFIG_KEY_LOAD_NEW_PLUGINS, - &error); + /* Check for safe mode */ + if (priv->safe_mode == FALSE) + { + load_new_plugins = g_key_file_get_boolean (keyfile, + groups[i], + HD_DESKTOP_CONFIG_KEY_LOAD_NEW_PLUGINS, + &error); + } + else + { + /* Do not load new plugins automatically in safe mode ever */ + load_new_plugins = FALSE; + } + if (error) { load_new_plugins = FALSE; @@ -1241,10 +1274,29 @@ plugin_list = hd_desktop_plugin_list_from_conf (container_config); - hd_plugin_manager_load (HD_PLUGIN_MANAGER (priv->pm), - plugin_list, - HILDON_DESKTOP_WINDOW (info->container)->container, - info->policy); + if (priv->safe_mode == FALSE) + { + /* + * Safe mode is not active, so load all plugins according to the plugin list + */ + hd_plugin_manager_load (HD_PLUGIN_MANAGER (priv->pm), + plugin_list, + HILDON_DESKTOP_WINDOW (info->container)->container, + info->policy); + } + else + { + /* + * Load only plugins according to policy by giving hd_plugin_manager_load + * NULL (==empty list) instead of GList plugin_list. This supposes that + * the default plugins within the policy are well behaving and do not cause + * crash-loop which this mechanism was made to prevent to happen. + */ + hd_plugin_manager_load (HD_PLUGIN_MANAGER (priv->pm), + NULL, + HILDON_DESKTOP_WINDOW (info->container)->container, + info->policy); + } gtk_widget_show (info->container); @@ -1634,6 +1686,33 @@ NULL); desktop->priv->dialog_queue = g_queue_new (); + + /* Check for safe mode. The stamp file is created here and + * Removed in main after gtk_main by g_object_unref in a call to finalize + * function of this gobject in case of clean non-crash exit + * Added by Karoliina <karoliina.t.salminen at nokia.com> 31.7.2007 + */ + if (g_file_test (HILDON_DESKTOP_STAMP_FILE, G_FILE_TEST_EXISTS)) + { + /* Hildon Desktop enters safe mode */ + g_warning ("hildon-desktop did not exit properly on the previous " + "session. All home plugins will be disabled."); + + priv->safe_mode = TRUE; + } + else + { + /* Hildon Desktop enters normal mode and creates the stamp to track crashes */ + g_mkdir_with_parents (HILDON_DESKTOP_STAMP_DIR, 0755); + + g_file_set_contents (HILDON_DESKTOP_STAMP_FILE, "1", 1, NULL); + + if (g_file_test (HILDON_DESKTOP_STAMP_FILE, G_FILE_TEST_EXISTS)) + g_debug ("LALALALALALAALALALALALALOLOLOLILILILILILILILI"); + + priv->safe_mode = FALSE; + } + } static void @@ -1646,6 +1725,14 @@ priv = HD_DESKTOP (object)->priv; + g_debug ("DESTROYYYYYYYY"); + g_debug ("DESTROYYYYYYYY"); + g_debug ("DESTROYYYYYYYY"); + g_debug ("DESTROYYYYYYYY"); + g_debug ("DESTROYYYYYYYY"); + g_debug ("DESTROYYYYYYYY"); + g_debug ("DESTROYYYYYYYY"); + if (priv->config_file != NULL) { g_free (priv->config_file); @@ -1657,7 +1744,7 @@ g_hash_table_destroy (priv->containers); priv->containers = NULL; } - + if (priv->pm != NULL) { g_object_unref (priv->pm); @@ -1669,7 +1756,7 @@ g_object_unref (priv->nm); priv->nm = NULL; } - + if (priv->system_conf_monitor != NULL) { gnome_vfs_monitor_cancel (priv->system_conf_monitor); @@ -1694,6 +1781,18 @@ priv->dialog_queue = NULL; } + /* + * Clean up stamp file created by hd_destop::hd_desktop_init + * On next startup the stamp file is created again and hildon-desktop remains + * in normal operation mode without entering into safe mode where some plugins + * are disabled. + */ + /* Test if file to be removed exists on the first place */ + if (g_file_test (HILDON_DESKTOP_STAMP_FILE, G_FILE_TEST_EXISTS)) + { + g_unlink (HILDON_DESKTOP_STAMP_FILE); + } + G_OBJECT_CLASS (hd_desktop_parent_class)->finalize (object); } @@ -1719,7 +1818,7 @@ hd_desktop_run (HDDesktop *desktop) { gchar *user_conf_dir; - + hd_desktop_load_containers (desktop); user_conf_dir = g_build_filename (g_get_home_dir (), @@ -1738,3 +1837,4 @@ g_free (user_conf_dir); } + Modified: projects/haf/branches/hildon-desktop/karoliina-safe-mode/src/hd-plugin-manager.c =================================================================== --- projects/haf/trunk/hildon-desktop/src/hd-plugin-manager.c 2007-08-21 11:47:59 UTC (rev 13317) +++ projects/haf/branches/hildon-desktop/karoliina-safe-mode/src/hd-plugin-manager.c 2007-08-21 13:46:16 UTC (rev 13321) @@ -138,12 +138,14 @@ priv = HD_PLUGIN_MANAGER (object)->priv; +#if 0 if (priv->factory) { g_object_unref (priv->factory); priv->factory = NULL; } - +#endif + G_OBJECT_CLASS (hd_plugin_manager_parent_class)->finalize (object); } Modified: projects/haf/branches/hildon-desktop/karoliina-safe-mode/src/hd-switcher-menu.c =================================================================== --- projects/haf/trunk/hildon-desktop/src/hd-switcher-menu.c 2007-08-21 11:47:59 UTC (rev 13317) +++ projects/haf/branches/hildon-desktop/karoliina-safe-mode/src/hd-switcher-menu.c 2007-08-21 13:46:16 UTC (rev 13321) @@ -798,7 +798,7 @@ ngroup); } - g_free (groups); + g_strfreev (groups); g_key_file_free (keyfile); } Modified: projects/haf/branches/hildon-desktop/karoliina-safe-mode/src/main.c =================================================================== --- projects/haf/trunk/hildon-desktop/src/main.c 2007-08-21 11:47:59 UTC (rev 13317) +++ projects/haf/branches/hildon-desktop/karoliina-safe-mode/src/main.c 2007-08-21 13:46:16 UTC (rev 13321) @@ -27,6 +27,8 @@ #endif #include <locale.h> +#include <unistd.h> +#include <signal.h> #include <glib/gi18n.h> #include <gtk/gtk.h> @@ -37,6 +39,13 @@ #define OSSO_USER_DIR ".osso" #define HILDON_DESKTOP_GTKRC "current-gtk-theme.maemo_af_desktop" +static void +handle_sigkill (int signal) +{ + gtk_main_quit (); +} + + int main (int argc, char **argv) { GObject *desktop; @@ -81,7 +90,19 @@ hd_desktop_run (HD_DESKTOP (desktop)); + signal (SIGTERM, handle_sigkill); + gtk_main (); + g_debug ("TERMINEIIIIII"); + g_debug ("TERMINEIIIIII"); + g_debug ("TERMINEIIIIII"); + g_debug ("TERMINEIIIIII"); + g_debug ("TERMINEIIIIII"); + g_debug ("TERMINEIIIIII"); + g_debug ("TERMINEIIIIII"); + + g_object_unref (desktop); + return 0; }
- Previous message: [maemo-commits] r13320 - projects/haf/branches
- Next message: [maemo-commits] r13322 - in projects/haf/trunk/hildon-theme-layout-4: . rc
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]