[maemo-commits] [maemo-commits] r13369 - projects/haf/branches/hildon-desktop/karoliina-safe-mode/src
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Thu Aug 23 11:45:09 EEST 2007
- Previous message: [maemo-commits] r13368 - projects/haf/trunk/hildon-application-framework/debian
- Next message: [maemo-commits] r13370 - in projects/haf/trunk/gtk+: . docs/reference docs/reference/gtk/tmpl gtk
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: karoliina Date: 2007-08-23 11:45:06 +0300 (Thu, 23 Aug 2007) New Revision: 13369 Added: projects/haf/branches/hildon-desktop/karoliina-safe-mode/src/hd-plugin-blacklist.c projects/haf/branches/hildon-desktop/karoliina-safe-mode/src/hd-plugin-blacklist.h projects/haf/branches/hildon-desktop/karoliina-safe-mode/src/hd-stamps.h Modified: projects/haf/branches/hildon-desktop/karoliina-safe-mode/src/Makefile.am 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 Log: Committed some changes. This version compiles but is not working as expected. Modified: projects/haf/branches/hildon-desktop/karoliina-safe-mode/src/Makefile.am =================================================================== --- projects/haf/branches/hildon-desktop/karoliina-safe-mode/src/Makefile.am 2007-08-23 07:04:58 UTC (rev 13368) +++ projects/haf/branches/hildon-desktop/karoliina-safe-mode/src/Makefile.am 2007-08-23 08:45:06 UTC (rev 13369) @@ -121,6 +121,8 @@ hd-panel-window-dialog.c \ hd-panel-window-dialog.h \ hd-config.h \ + hd-plugin-blacklist.c \ + hd-plugin-blacklist.h \ main.c pluginlib_LTLIBRARIES = libhd-applications-menu-settings.la Modified: projects/haf/branches/hildon-desktop/karoliina-safe-mode/src/hd-desktop.c =================================================================== --- projects/haf/branches/hildon-desktop/karoliina-safe-mode/src/hd-desktop.c 2007-08-23 07:04:58 UTC (rev 13368) +++ projects/haf/branches/hildon-desktop/karoliina-safe-mode/src/hd-desktop.c 2007-08-23 08:45:06 UTC (rev 13369) @@ -59,6 +59,8 @@ #include "hd-panel-window.h" #include "hd-panel-window-dialog.h" +#include "hd-plugin-blacklist.h" + #define HD_DESKTOP_GET_PRIVATE(object) \ (G_TYPE_INSTANCE_GET_PRIVATE ((object), HD_TYPE_DESKTOP, HDDesktopPrivate)) @@ -82,10 +84,9 @@ * 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" +#include "hd-stamps.h" + typedef struct { GtkWidget *parent; @@ -432,7 +433,7 @@ return; } } - + buffer = g_key_file_to_data (keyfile, (gsize *) &buffer_size, &error); if (error) @@ -1279,10 +1280,22 @@ /* * Safe mode is not active, so load all plugins according to the plugin list */ + printf("Printing plugin list. Safe mode inactive\n----------------------------------------\n"); + + g_list_foreach (plugin_list, (GFunc) printf , NULL); + + + + printf("\n--------------------------------------------\nLoading now plugins\n"); + + + /* Black list functionality must be in the plugin-manager, otherwise it will not work, because + this is already a list and plugin manager handles what it loads and does not */ hd_plugin_manager_load (HD_PLUGIN_MANAGER (priv->pm), plugin_list, HILDON_DESKTOP_WINDOW (info->container)->container, info->policy); + } else { @@ -1697,6 +1710,9 @@ /* Hildon Desktop enters safe mode */ g_warning ("hildon-desktop did not exit properly on the previous " "session. All home plugins will be disabled."); + + printf ("hildon-desktop did not exit properly on the previous " + "session. All home plugins will be disabled.\n"); priv->safe_mode = TRUE; } Added: projects/haf/branches/hildon-desktop/karoliina-safe-mode/src/hd-plugin-blacklist.c =================================================================== --- projects/haf/branches/hildon-desktop/karoliina-safe-mode/src/hd-plugin-blacklist.c 2007-08-23 07:04:58 UTC (rev 13368) +++ projects/haf/branches/hildon-desktop/karoliina-safe-mode/src/hd-plugin-blacklist.c 2007-08-23 08:45:06 UTC (rev 13369) @@ -0,0 +1,139 @@ +/* + * This file is part of hildon-desktop + * + * Copyright (C) 2007 Nokia Corporation. + * + * Author: Karoliina Salminen <karoliina.t.salminen 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 <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <glib.h> +#include <glib-object.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 + + +#include "hd-plugin-blacklist.h" + +gchar* +hd_plugin_blacklist_transaction_read (gchar *key_file_name, const gchar *group_name, const gchar *key) +{ + GKeyFile *keyfile; + GError *error = NULL; + gchar *value = NULL; + + g_return_val_if_fail (key_file_name != NULL, NULL); + + printf("hd_plugin_blacklist_transaction_read\n"); + + keyfile = g_key_file_new (); + + g_key_file_load_from_file (keyfile, + key_file_name, + G_KEY_FILE_NONE, + &error); + + if (error) + { + g_warning ("Error loading blacklist configuration file %s: %s", key_file_name, error->message); + g_error_free (error); + + return NULL; + } + + value = g_key_file_get_string (keyfile, group_name, key, &error); + + if (error) + { + g_error_free (error); + error = NULL; + g_key_file_free (keyfile); + return NULL; + } + + g_key_file_free (keyfile); + + return value; +} + +void +hd_plugin_blacklist_transaction_write (gchar *key_file_name, const gchar *group_name, const gchar *key, const gchar *value) +{ + GKeyFile *keyfile; + GError *error = NULL; + gchar *buffer; + gint buffer_size; + + g_return_if_fail (key_file_name != NULL); + + printf("hd_plugin_blacklist_transaction_write\n"); + + keyfile = g_key_file_new (); + + /* Load old keyfile */ + + g_key_file_load_from_file (keyfile, + key_file_name, + G_KEY_FILE_NONE, + &error); + + /* Now set the key in there */ + printf("g_key_file_set_string begin\n"); + g_key_file_set_string (keyfile, group_name, key, value); + printf("g_key_file_set_string end\n"); + buffer = g_key_file_to_data (keyfile, (gsize *) &buffer_size, &error); + + printf("Buffer created. Buffer = %s \n",buffer); + /* + if (error) + { + g_warning ("Error saving desktop blacklist configuration file: %s", error->message); + g_error_free (error); + + return; + }*/ + printf("write buffer\n"); + printf("Creat\n"); + //g_creat (key_file_name, O_CREAT); + printf("Creat done\n"); + printf("Write to file \n"); + if(g_file_set_contents (key_file_name, buffer, buffer_size, &error)){ + printf("Something occurred\n"); + } + printf("buffer written\n"); + if (error) + { + g_warning ("Error saving desktop blacklist configuration file: %s", error->message); + g_error_free (error); + } + + g_free (buffer); + g_key_file_free (keyfile); +} + Added: projects/haf/branches/hildon-desktop/karoliina-safe-mode/src/hd-plugin-blacklist.h =================================================================== --- projects/haf/branches/hildon-desktop/karoliina-safe-mode/src/hd-plugin-blacklist.h 2007-08-23 07:04:58 UTC (rev 13368) +++ projects/haf/branches/hildon-desktop/karoliina-safe-mode/src/hd-plugin-blacklist.h 2007-08-23 08:45:06 UTC (rev 13369) @@ -0,0 +1,35 @@ +/* + * This file is part of hildon-desktop + * + * Copyright (C) 2007 Nokia Corporation. + * + * Author: Karoliina Salminen <karoliina.t.salminen 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 + * + */ + + +#ifndef __hd_plugin_blacklist__h__ +#define __hd_plugin_blacklist__h__ + +gchar* +hd_plugin_blacklist_transaction_read (gchar *key_file_name, const gchar *group_name, const gchar *key); + +void +hd_plugin_blacklist_transaction_write (gchar *key_file_name, const gchar *group_name, const gchar *key, const gchar *value); + +#endif Modified: projects/haf/branches/hildon-desktop/karoliina-safe-mode/src/hd-plugin-manager.c =================================================================== --- projects/haf/branches/hildon-desktop/karoliina-safe-mode/src/hd-plugin-manager.c 2007-08-23 07:04:58 UTC (rev 13368) +++ projects/haf/branches/hildon-desktop/karoliina-safe-mode/src/hd-plugin-manager.c 2007-08-23 08:45:06 UTC (rev 13369) @@ -26,10 +26,14 @@ #include <config.h> #endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + #include <gtk/gtk.h> #include <glib.h> #include <glib-object.h> - #include <libhildondesktop/hildon-desktop-container.h> #include "hd-plugin-manager.h" @@ -37,6 +41,9 @@ #include "hd-plugin-loader.h" #include "hd-plugin-loader-factory.h" +#include "hd-stamps.h" +#include "hd-plugin-blacklist.h" + #define HD_PLUGIN_MANAGER_GET_PRIVATE(object) \ (G_TYPE_INSTANCE_GET_PRIVATE ((object), HD_TYPE_PLUGIN_MANAGER, HDPluginManagerPrivate)) @@ -228,14 +235,66 @@ for (iter = f_plugin_list; iter; iter = g_list_next (iter)) { - if (!hd_plugin_manager_load_plugin (pm, - (const gchar *) iter->data, - container) && policy != NULL) + /* Add attempt to blacklist */ + + gchar *status=NULL; + + status = hd_plugin_blacklist_transaction_read (HILDON_DESKTOP_BLACKLIST, iter->data, "blacklist-status"); + if(status == NULL) { - hd_plugin_manager_handle_plugin_failure (pm, container, policy, position); + + hd_plugin_blacklist_transaction_write (HILDON_DESKTOP_BLACKLIST, iter->data, "blacklist-status", "init"); + + if (!hd_plugin_manager_load_plugin (pm, + (const gchar *) iter->data, + container) && policy != NULL) + { + hd_plugin_manager_handle_plugin_failure (pm, container, policy, position); + } + + position++; + + + hd_plugin_blacklist_transaction_write (HILDON_DESKTOP_BLACKLIST, iter->data, "blacklist-status", "done"); + + } + else + { + if((strcmp(status,"init"))) + { /* if not status init (=not crashed) */ - position++; + + hd_plugin_blacklist_transaction_write (HILDON_DESKTOP_BLACKLIST, iter->data, "blacklist-status", "init"); + + if (!hd_plugin_manager_load_plugin (pm, + (const gchar *) iter->data, + container) && policy != NULL) + { + hd_plugin_manager_handle_plugin_failure (pm, container, policy, position); + + hd_plugin_blacklist_transaction_write (HILDON_DESKTOP_BLACKLIST, iter->data, "blacklist-status", "fail"); + + } + + position++; + + hd_plugin_blacklist_transaction_write (HILDON_DESKTOP_BLACKLIST, iter->data, "blacklist-status", "done"); + + + } + else /* Actually crashed , init status found */ + { + + + } + + } + + g_free(status); + + + } g_list_foreach (f_plugin_list, (GFunc) g_free, NULL); Added: projects/haf/branches/hildon-desktop/karoliina-safe-mode/src/hd-stamps.h =================================================================== --- projects/haf/branches/hildon-desktop/karoliina-safe-mode/src/hd-stamps.h 2007-08-23 07:04:58 UTC (rev 13368) +++ projects/haf/branches/hildon-desktop/karoliina-safe-mode/src/hd-stamps.h 2007-08-23 08:45:06 UTC (rev 13369) @@ -0,0 +1,33 @@ +/* + * This file is part of hildon-desktop + * + * Copyright (C) 2007 Nokia Corporation. + * + * Author: Karoliina Salminen <karoliina.t.salminen 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 + * + */ + +#ifndef __hd_stamps__h__ +#define __hd_stamps__h__ + +#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" +#define HILDON_DESKTOP_BLACKLIST HILDON_DESKTOP_STAMP_DIR"/blacklist.conf" + +#endif
- Previous message: [maemo-commits] r13368 - projects/haf/trunk/hildon-application-framework/debian
- Next message: [maemo-commits] r13370 - in projects/haf/trunk/gtk+: . docs/reference docs/reference/gtk/tmpl gtk
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]