[maemo-commits] [maemo-commits] r14170 - in projects/haf/trunk/hildon-desktop: . debian debian/config policies src
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Fri Sep 28 14:45:58 EEST 2007
- Previous message: [maemo-commits] r14169 - in projects/haf/trunk/osso-app-killer: . src
- Next message: [maemo-commits] r14171 - in projects/haf/trunk/gtk+: . gtk
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: lucasr Date: 2007-09-28 14:45:55 +0300 (Fri, 28 Sep 2007) New Revision: 14170 Added: projects/haf/trunk/hildon-desktop/policies/statusbar-policy.c Modified: projects/haf/trunk/hildon-desktop/ChangeLog projects/haf/trunk/hildon-desktop/configure.ac projects/haf/trunk/hildon-desktop/debian/config/desktop.conf projects/haf/trunk/hildon-desktop/debian/rules projects/haf/trunk/hildon-desktop/policies/Makefile.am projects/haf/trunk/hildon-desktop/src/hd-desktop.c projects/haf/trunk/hildon-desktop/src/hd-desktop.h projects/haf/trunk/hildon-desktop/src/main.c Log: 2007-09-28 Lucas Rocha <lucas.rocha at nokia.com> Added "safe mode" support which, in practice, disables all home plugins and loads default ones for task navigator and statusbar. Based on patch from Karoliina Salminen <karoliina.t.salminen at nokia.com>. * debian/rules: added --enable-safe-mode option to configure step. * debian/config/desktop.conf: added UI policy key for statusbar. * src/hd-desktop.c (hd_desktop_init, hd_desktop_load_containers): create a stamp file on startup which should be removed on a normal desktop shutdown. On startup, if the file is still there it means desktop didn't shutdown normally on previous session and the safe mode should be activated. If running in a development environment, then safe mode is disabled. * src/hd-desktop.h: added constants for the stamp file used by safe more code. * src/main.c (signal_handler): remove stamp file on SIGTERM to mark a plain shutdown. * policies/statusbar-policy.c: new statusbar UI policy which loads all default plugins in case the desktop is in safe mode. Modified: projects/haf/trunk/hildon-desktop/ChangeLog =================================================================== --- projects/haf/trunk/hildon-desktop/ChangeLog 2007-09-28 11:38:08 UTC (rev 14169) +++ projects/haf/trunk/hildon-desktop/ChangeLog 2007-09-28 11:45:55 UTC (rev 14170) @@ -1,3 +1,24 @@ +2007-09-28 Lucas Rocha <lucas.rocha at nokia.com> + + Added "safe mode" support which, in practice, disables all home plugins + and loads default ones for task navigator and statusbar. Based on + patch from Karoliina Salminen <karoliina.t.salminen at nokia.com>. + + * debian/rules: added --enable-safe-mode option to configure step. + * debian/config/desktop.conf: added UI policy key for statusbar. + * src/hd-desktop.c (hd_desktop_init, hd_desktop_load_containers): + create a stamp file on startup which should be removed on a normal + desktop shutdown. On startup, if the file is still there it means + desktop didn't shutdown normally on previous session and the safe mode + should be activated. If running in a development environment, then safe + mode is disabled. + * src/hd-desktop.h: added constants for the stamp file used by safe + more code. + * src/main.c (signal_handler): remove stamp file on SIGTERM to mark + a plain shutdown. + * policies/statusbar-policy.c: new statusbar UI policy which loads all + default plugins in case the desktop is in safe mode. + 2007-09-28 Johan Bilien <johan.bilien at nokia.com> * libhildondesktop/hildon-home-area.c: removed debug message Modified: projects/haf/trunk/hildon-desktop/configure.ac =================================================================== --- projects/haf/trunk/hildon-desktop/configure.ac 2007-09-28 11:38:08 UTC (rev 14169) +++ projects/haf/trunk/hildon-desktop/configure.ac 2007-09-28 11:45:55 UTC (rev 14170) @@ -42,6 +42,10 @@ [AC_HELP_STRING([--enable-instrumenting],[Compile with instrumentation flags (default=no)])], [hildon_use_instrumenting=yes],[hildon_use_instrumenting=no]) +AC_ARG_ENABLE(safe-mode, + [AS_HELP_STRING([--enable-safe-mode],[Enable "safe mode" support for desktop (default=no)])], + [enable_safe_mode=yes], [enable_safe_mode=no]) + if test "x${hildon_use_timestamping}" = "xyes" then CFLAGS="$CFLAGS -DHILDON_USE_TIMESTAMPING" @@ -54,6 +58,11 @@ CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wmissing-declarations -Werror -Wno-format-extra-args" fi +if test "x${enable_safe_mode}" = "xyes" +then + AC_DEFINE(HAVE_SAFE_MODE, [], [Whether safe mode support is present]) +fi + # D-BUS headers do not compile with -pedantic. Once they are fixed, #return the flag #CFLAGS="$CFLAGS -Wall -ansi -pedantic -Wmissing-prototypes -Wmissing-declarations -Werror" Modified: projects/haf/trunk/hildon-desktop/debian/config/desktop.conf =================================================================== --- projects/haf/trunk/hildon-desktop/debian/config/desktop.conf 2007-09-28 11:38:08 UTC (rev 14169) +++ projects/haf/trunk/hildon-desktop/debian/config/desktop.conf 2007-09-28 11:45:55 UTC (rev 14170) @@ -24,6 +24,7 @@ X-Size-Width=282 X-Size-Height=50 X-Orientation=top +X-UI-Policy=libstatusbarpolicy.so X-Is-Ordered=1 X-Load-New-Plugins=1 X-Config-File=statusbar.conf Modified: projects/haf/trunk/hildon-desktop/debian/rules =================================================================== --- projects/haf/trunk/hildon-desktop/debian/rules 2007-09-28 11:38:08 UTC (rev 14169) +++ projects/haf/trunk/hildon-desktop/debian/rules 2007-09-28 11:45:55 UTC (rev 14170) @@ -53,7 +53,7 @@ config.status: configure dh_testdir # Add here commands to configure the package. - CFLAGS="$(CFLAGS)" ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --sysconfdir=/etc --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info --disable-dependency-tracking + CFLAGS="$(CFLAGS)" ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --sysconfdir=/etc --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info --disable-dependency-tracking --enable-safe-mode build: build-stamp Modified: projects/haf/trunk/hildon-desktop/policies/Makefile.am =================================================================== --- projects/haf/trunk/hildon-desktop/policies/Makefile.am 2007-09-28 11:38:08 UTC (rev 14169) +++ projects/haf/trunk/hildon-desktop/policies/Makefile.am 2007-09-28 11:45:55 UTC (rev 14170) @@ -1,4 +1,4 @@ -hildonuipolicylib_LTLIBRARIES = libtasknavigatorpolicy.la +hildonuipolicylib_LTLIBRARIES = libtasknavigatorpolicy.la libstatusbarpolicy.la libtasknavigatorpolicy_la_LDFLAGS = -module -avoid-version @@ -6,13 +6,28 @@ $(LIBHILDONDESKTOP_LIBS) \ $(GTK_LIBS) -libtasknavigatorpolicy_la_CFLAGS = \ - -std=c99 -rdynamic \ - $(LIBHILDONDESKTOP_CFLAGS) \ - $(GTK_CFLAGS) \ +libtasknavigatorpolicy_la_CFLAGS = \ + -std=c99 -rdynamic \ + $(LIBHILDONDESKTOP_CFLAGS) \ + $(GTK_CFLAGS) \ -DHD_TN_ENTRY_PATH=\"$(hildonnavigatordesktopentrydir)\" libtasknavigatorpolicy_la_SOURCES = \ tasknavigator-policy.c +libstatusbarpolicy_la_LDFLAGS = -module -avoid-version + +libstatusbarpolicy_la_LIBADD = \ + $(LIBHILDONDESKTOP_LIBS) \ + $(GTK_LIBS) + +libstatusbarpolicy_la_CFLAGS = \ + -std=c99 -rdynamic \ + $(LIBHILDONDESKTOP_CFLAGS) \ + $(GTK_CFLAGS) \ + -DHD_SB_ENTRY_PATH=\"$(hildonstatusbardesktopentrydir)\" + +libstatusbarpolicy_la_SOURCES = \ + statusbar-policy.c + CLEANFILES = *~ Added: projects/haf/trunk/hildon-desktop/policies/statusbar-policy.c =================================================================== --- projects/haf/trunk/hildon-desktop/policies/statusbar-policy.c 2007-09-28 11:38:08 UTC (rev 14169) +++ projects/haf/trunk/hildon-desktop/policies/statusbar-policy.c 2007-09-28 11:45:55 UTC (rev 14170) @@ -0,0 +1,132 @@ +/* + * This file is part of python-hildondesktop + * + * Copyright (C) 2007 Nokia Corporation. + * + * Author: Lucas Rocha <lucas.rocha at nokia.com> + * Contact: Karoliina Salminen <karoliina.t.salminen at nokia.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <glib.h> +#include <glib-object.h> +#include <gtk/gtk.h> +#include <libhildondesktop/hildon-desktop-item.h> +#include <libhildondesktop/statusbar-item.h> +#include <libhildondesktop/hildon-desktop-toggle-button.h> + +#define HD_SB_BATTERY_PLUGIN "hildon-status-bar-battery.desktop" +#define HD_SB_INTERNET_PLUGIN "hildon-status-bar-internet.desktop" +#define HD_SB_SOUND_PLUGIN "sound.desktop" +#define HD_SB_DISPLAY_PLUGIN "hildon-status-bar-display.desktop" +#define HD_SB_PRESENCE_PLUGIN "presence.desktop" +#define HD_SB_CONTACT_PLUGIN "contact.desktop" +#define HD_SB_BLUETOOTH_PLUGIN "hildon-status-bar-bluetooth.desktop" +#define HD_SB_LOCATION_PLUGIN "location.desktop" +#define HD_SB_ALARM_PLUGIN "hildon-status-bar-alarm.desktop" +#define HD_SB_USB_PLUGIN "hildon-status-bar-usb.desktop" + +G_MODULE_EXPORT GList *hd_ui_policy_module_filter_plugin_list (GList *plugin_list); +G_MODULE_EXPORT gchar *hd_ui_policy_module_get_default_item (gint position); +G_MODULE_EXPORT HildonDesktopItem *hd_ui_policy_module_get_failure_item (gint position); + +GList * +hd_ui_policy_module_filter_plugin_list (GList *plugin_list) +{ + GList *f_plugin_list = NULL; + +#ifdef HAVE_SAFE_MODE + if (plugin_list == NULL) + { + g_debug ("NAO OK!"); + + f_plugin_list = g_list_append (f_plugin_list, g_strdup (HD_SB_ENTRY_PATH "/" HD_SB_BATTERY_PLUGIN)); + f_plugin_list = g_list_append (f_plugin_list, g_strdup (HD_SB_ENTRY_PATH "/" HD_SB_INTERNET_PLUGIN)); + f_plugin_list = g_list_append (f_plugin_list, g_strdup (HD_SB_ENTRY_PATH "/" HD_SB_SOUND_PLUGIN)); + f_plugin_list = g_list_append (f_plugin_list, g_strdup (HD_SB_ENTRY_PATH "/" HD_SB_DISPLAY_PLUGIN)); + f_plugin_list = g_list_append (f_plugin_list, g_strdup (HD_SB_ENTRY_PATH "/" HD_SB_PRESENCE_PLUGIN)); + f_plugin_list = g_list_append (f_plugin_list, g_strdup (HD_SB_ENTRY_PATH "/" HD_SB_CONTACT_PLUGIN)); + f_plugin_list = g_list_append (f_plugin_list, g_strdup (HD_SB_ENTRY_PATH "/" HD_SB_BLUETOOTH_PLUGIN)); + f_plugin_list = g_list_append (f_plugin_list, g_strdup (HD_SB_ENTRY_PATH "/" HD_SB_LOCATION_PLUGIN)); + f_plugin_list = g_list_append (f_plugin_list, g_strdup (HD_SB_ENTRY_PATH "/" HD_SB_ALARM_PLUGIN)); + f_plugin_list = g_list_append (f_plugin_list, g_strdup (HD_SB_ENTRY_PATH "/" HD_SB_USB_PLUGIN)); + } +#endif + + return f_plugin_list; +} + +gchar * +hd_ui_policy_module_get_default_item (gint position) +{ + gchar *plugin_id = NULL; + + switch (position) + { + case 0: + plugin_id = g_strdup (HD_SB_ENTRY_PATH "/" HD_SB_BATTERY_PLUGIN); + break; + + case 1: + plugin_id = g_strdup (HD_SB_ENTRY_PATH "/" HD_SB_INTERNET_PLUGIN); + break; + + case 2: + plugin_id = g_strdup (HD_SB_ENTRY_PATH "/" HD_SB_SOUND_PLUGIN); + break; + + case 3: + plugin_id = g_strdup (HD_SB_ENTRY_PATH "/" HD_SB_DISPLAY_PLUGIN); + break; + + case 4: + plugin_id = g_strdup (HD_SB_ENTRY_PATH "/" HD_SB_PRESENCE_PLUGIN); + break; + + case 5: + plugin_id = g_strdup (HD_SB_ENTRY_PATH "/" HD_SB_CONTACT_PLUGIN); + break; + + case 6: + plugin_id = g_strdup (HD_SB_ENTRY_PATH "/" HD_SB_BLUETOOTH_PLUGIN); + break; + + case 7: + plugin_id = g_strdup (HD_SB_ENTRY_PATH "/" HD_SB_LOCATION_PLUGIN); + break; + + case 8: + plugin_id = g_strdup (HD_SB_ENTRY_PATH "/" HD_SB_ALARM_PLUGIN); + break; + + case 9: + plugin_id = g_strdup (HD_SB_ENTRY_PATH "/" HD_SB_USB_PLUGIN); + break; + } + + return plugin_id; +} + +HildonDesktopItem * +hd_ui_policy_module_get_failure_item (gint position) +{ + return NULL; +} Modified: projects/haf/trunk/hildon-desktop/src/hd-desktop.c =================================================================== --- projects/haf/trunk/hildon-desktop/src/hd-desktop.c 2007-09-28 11:38:08 UTC (rev 14169) +++ projects/haf/trunk/hildon-desktop/src/hd-desktop.c 2007-09-28 11:45:55 UTC (rev 14170) @@ -33,6 +33,7 @@ #include <gtk/gtk.h> #include <libgnomevfs/gnome-vfs.h> #include <glib/gi18n.h> +#include <glib/gstdio.h> #ifdef HAVE_LIBOSSO #include <libosso.h> @@ -114,6 +115,9 @@ #ifdef HAVE_LIBOSSO osso_context_t *osso_context; #endif +#ifdef HAVE_SAFE_MODE + gboolean safe_mode; +#endif }; static void hd_desktop_load_containers (HDDesktop *desktop); @@ -505,7 +509,7 @@ error = NULL; } - if (is_to_load) + if (is_to_load) plugin_list = g_list_append (plugin_list, g_strdup (groups[i])); } @@ -914,18 +918,30 @@ 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); - - if (error) +#ifdef HAVE_SAFE_MODE + /* Check for safe mode */ + if (priv->safe_mode) { + /* Do not load new plugins automatically in safe mode ever */ load_new_plugins = FALSE; - g_error_free (error); - error = NULL; + } + else + { +#endif + load_new_plugins = g_key_file_get_boolean (keyfile, + groups[i], + HD_DESKTOP_CONFIG_KEY_LOAD_NEW_PLUGINS, + &error); + + if (error) + { + load_new_plugins = FALSE; + g_error_free (error); + error = NULL; + } +#ifdef HAVE_SAFE_MODE } +#endif policy_module = g_key_file_get_string (keyfile, groups[i], @@ -1299,11 +1315,31 @@ 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); - +#ifdef HAVE_SAFE_MODE + if (priv->safe_mode) + { + /* + * 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); + } + else + { +#endif + hd_plugin_manager_load (HD_PLUGIN_MANAGER (priv->pm), + plugin_list, + HILDON_DESKTOP_WINDOW (info->container)->container, + info->policy); +#ifdef HAVE_SAFE_MODE + } +#endif + gtk_widget_show (info->container); g_free (type); @@ -1694,6 +1730,41 @@ NULL); desktop->priv->dialog_queue = g_queue_new (); + +#ifdef HAVE_SAFE_MODE + const gchar *dev_mode = g_getenv ("SBOX_PRELOAD"); + + priv->safe_mode = FALSE; + + if (!dev_mode) + { + /* + * 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 and statusbar plugins will be disabled."); + + priv->safe_mode = TRUE; + } + else + { + g_debug ("LALALA"); + + /* 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); + + priv->safe_mode = FALSE; + } + } +#endif } static void Modified: projects/haf/trunk/hildon-desktop/src/hd-desktop.h =================================================================== --- projects/haf/trunk/hildon-desktop/src/hd-desktop.h 2007-09-28 11:38:08 UTC (rev 14169) +++ projects/haf/trunk/hildon-desktop/src/hd-desktop.h 2007-09-28 11:45:55 UTC (rev 14170) @@ -40,6 +40,11 @@ #define HD_IS_DESKTOP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), HD_TYPE_DESKTOP)) #define HD_DESKTOP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), HD_TYPE_DESKTOP, HDDesktopClass)) +#ifdef HAVE_SAFE_MODE +#define HILDON_DESKTOP_STAMP_DIR "/tmp/osso-appl-states/hildon-desktop/" +#define HILDON_DESKTOP_STAMP_FILE HILDON_DESKTOP_STAMP_DIR"/stamp" +#endif + struct _HDDesktop { GObject gobject; Modified: projects/haf/trunk/hildon-desktop/src/main.c =================================================================== --- projects/haf/trunk/hildon-desktop/src/main.c 2007-09-28 11:38:08 UTC (rev 14169) +++ projects/haf/trunk/hildon-desktop/src/main.c 2007-09-28 11:45:55 UTC (rev 14170) @@ -119,6 +119,20 @@ if (signal == SIGTERM) { hd_wm_memory_kill_all_watched (FALSE); + +#ifdef HAVE_SAFE_MODE + /* + * Clean up stamp file created by 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. + */ + if (g_file_test (HILDON_DESKTOP_STAMP_FILE, G_FILE_TEST_EXISTS)) + { + g_unlink (HILDON_DESKTOP_STAMP_FILE); + } +#endif + exit (0); } }
- Previous message: [maemo-commits] r14169 - in projects/haf/trunk/osso-app-killer: . src
- Next message: [maemo-commits] r14171 - in projects/haf/trunk/gtk+: . gtk
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]