[maemo-commits] [maemo-commits] r9732 - in projects/haf/trunk/maemo-af-desktop: . hildon-home

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Thu Feb 8 10:48:33 EET 2007
Author: jobi
Date: 2007-02-08 10:48:32 +0200 (Thu, 08 Feb 2007)
New Revision: 9732

Modified:
   projects/haf/trunk/maemo-af-desktop/ChangeLog
   projects/haf/trunk/maemo-af-desktop/hildon-home/hildon-home-private.h
   projects/haf/trunk/maemo-af-desktop/hildon-home/hildon-home-window.c
   projects/haf/trunk/maemo-af-desktop/hildon-home/home-applet-handler.c
   projects/haf/trunk/maemo-af-desktop/hildon-home/home-applet-handler.h
Log:

2007-02-08  Johan Bilien <johan.bilien at nokia.com>

	* hildon-home/home-applet-handler.[ch]:
	- Add HildonLog class variable
	- log each initialize and deinitialize callback call
	- do not load an applet if it crashes on the last session
	in one of these callbacks.
	* hildon-home/hildon-home-window.c: Remove the log
	file once Home has loaded all its applets properly.
	Fixes: NB#51146


Modified: projects/haf/trunk/maemo-af-desktop/ChangeLog
===================================================================
--- projects/haf/trunk/maemo-af-desktop/ChangeLog	2007-02-08 08:36:03 UTC (rev 9731)
+++ projects/haf/trunk/maemo-af-desktop/ChangeLog	2007-02-08 08:48:32 UTC (rev 9732)
@@ -1,5 +1,16 @@
 2007-02-08  Johan Bilien <johan.bilien at nokia.com>
 
+	* hildon-home/home-applet-handler.[ch]:
+	- Add HildonLog class variable
+	- log each initialize and deinitialize callback call
+	- do not load an applet if it crashes on the last session
+	in one of these callbacks.
+	* hildon-home/hildon-home-window.c: Remove the log
+	file once Home has loaded all its applets properly.
+	Fixes: NB#51146
+
+2007-02-08  Johan Bilien <johan.bilien at nokia.com>
+
 	* hildon-home/hildon-home-area.c,
 	hildon-status-bar/hildon-status-bar-main.c:
 	- reverted iteration of the main loop between the load of

Modified: projects/haf/trunk/maemo-af-desktop/hildon-home/hildon-home-private.h
===================================================================
--- projects/haf/trunk/maemo-af-desktop/hildon-home/hildon-home-private.h	2007-02-08 08:36:03 UTC (rev 9731)
+++ projects/haf/trunk/maemo-af-desktop/hildon-home/hildon-home-private.h	2007-02-08 08:48:32 UTC (rev 9732)
@@ -249,7 +249,9 @@
 #define LAYOUT_MODE_NOTIFICATION_MODE_CANCEL_NO    _("home_bd_cancel_layout_no")
 #define LAYOUT_MODE_NOTIFICATION_MODE_ACCEPT_TEXT  _("home_ni_overlapping_applets")
 
+#define HH_LOG_PATH                              "/.osso/home.log"
 
+
 #define TRANSIENCY_MAXITER 50
 										
 enum { 	 

Modified: projects/haf/trunk/maemo-af-desktop/hildon-home/hildon-home-window.c
===================================================================
--- projects/haf/trunk/maemo-af-desktop/hildon-home/hildon-home-window.c	2007-02-08 08:36:03 UTC (rev 9731)
+++ projects/haf/trunk/maemo-af-desktop/hildon-home/hildon-home-window.c	2007-02-08 08:48:32 UTC (rev 9732)
@@ -863,6 +863,11 @@
                                        filename);
 
   g_free (user_filename);
+
+  /* We survived, let's remove the log file */
+  user_filename = g_strdup_printf ("%s%s", g_get_home_dir (), HH_LOG_PATH);
+  unlink (user_filename);
+  g_free (user_filename);
 }
 
 static GObject *

Modified: projects/haf/trunk/maemo-af-desktop/hildon-home/home-applet-handler.c
===================================================================
--- projects/haf/trunk/maemo-af-desktop/hildon-home/home-applet-handler.c	2007-02-08 08:36:03 UTC (rev 9731)
+++ projects/haf/trunk/maemo-af-desktop/hildon-home/home-applet-handler.c	2007-02-08 08:48:32 UTC (rev 9732)
@@ -33,6 +33,7 @@
 #include "hildon-home-plugin-interface.h"
 #include "hildon-home-interface.h"
 #include "hildon-home-applet.h"
+#include "hildon-home-private.h"
 
 /* Systems includes */
 #include <string.h>  /* for strcmp */
@@ -134,6 +135,7 @@
 {
     /* Get convenience variables */
     GObjectClass *object_class = G_OBJECT_CLASS(applet_class);
+    gchar *log_path;
     
     /* Set the global parent_class here */
     parent_class = g_type_class_peek_parent(applet_class);
@@ -143,6 +145,19 @@
    
     g_type_class_add_private(applet_class,
                              sizeof(struct _HomeAppletHandlerPrivate));
+
+    log_path = g_strdup_printf ("%s%s",
+                                g_get_home_dir (),
+                                HH_LOG_PATH);
+    applet_class->log = hildon_log_new (log_path);
+    g_free (log_path);
+    applet_class->bad_plugins = 
+        hildon_log_get_incomplete_groups (applet_class->log,
+                                          "init_start",
+                                          "init_end",
+                                          "deinit_start",
+                                          "deinit_end",
+                                          NULL);
     
 }
 
@@ -263,6 +278,8 @@
     GtkWidget *applet;
     HomeAppletHandlerPrivate *priv;
     HomeAppletHandler *handler;
+    HildonLog *log;
+    GList     *bad_plugins;
     gint applet_x = APPLET_INVALID_COORDINATE;
     gint applet_y = APPLET_INVALID_COORDINATE;
     gint applet_minwidth = APPLET_NONCHANGABLE_DIMENSION;
@@ -277,6 +294,7 @@
 
     g_return_val_if_fail (desktoppath, NULL);
 
+
     if (!htable)
       htable = g_hash_table_new (g_str_hash, g_str_equal);
 
@@ -409,13 +427,28 @@
 
 
     g_key_file_free (kfile);
-        
-    librarypath =
-            g_strconcat(HOME_APPLET_HANDLER_LIBRARY_DIR, libraryfile, NULL);
     
     handler = g_object_new (HOME_TYPE_APPLET_HANDLER, NULL);
     priv = HOME_APPLET_HANDLER_GET_PRIVATE(handler);
+    log = HOME_APPLET_HANDLER_GET_CLASS(handler)->log;
+    bad_plugins = HOME_APPLET_HANDLER_GET_CLASS(handler)->bad_plugins;
 
+    if (g_list_find_custom (bad_plugins, desktoppath, (GCompareFunc)strcmp))
+    {
+        g_warning ("Not loading %s as it did not complete initialization on "
+                   "previous startup",
+                   desktoppath);
+
+        /* The plugin was found to crash during initialization last time */
+        g_object_unref (handler);
+        g_free (libraryfile);
+        return NULL;
+    }
+
+    hildon_log_add_group (log, desktoppath);
+        
+    librarypath =
+            g_strconcat(HOME_APPLET_HANDLER_LIBRARY_DIR, libraryfile, NULL);
     priv->dlhandle = dlopen(librarypath, RTLD_NOW);
     g_free(librarypath);
     
@@ -443,7 +476,9 @@
             return NULL;
         }
 
+        hildon_log_add_message (log, "init_start", "1");
         priv->applet_data = priv->initialize(state_data, state_size, &applet);
+        hildon_log_add_message (log, "init_end", "1");
         priv->widget = applet;
 	
         handler->libraryfile = libraryfile;
@@ -543,14 +578,18 @@
 void home_applet_handler_deinitialize(HomeAppletHandler *handler)
 {
     HomeAppletHandlerPrivate *priv;
+    HildonLog *log;
 
     g_return_if_fail (handler);
 
     priv = HOME_APPLET_HANDLER_GET_PRIVATE(handler);
+    log = HOME_APPLET_HANDLER_GET_CLASS(handler)->log;
     
     if (priv->applet_data)
     {
+        hildon_log_add_message(log, "deinit_start", "1");
         priv->deinitialize(priv->applet_data);
+        hildon_log_add_message(log, "deinit_end", "1");
         /* The applet should have freed the data so we just clear the pointer */
         priv->applet_data = NULL;
     }

Modified: projects/haf/trunk/maemo-af-desktop/hildon-home/home-applet-handler.h
===================================================================
--- projects/haf/trunk/maemo-af-desktop/hildon-home/home-applet-handler.h	2007-02-08 08:36:03 UTC (rev 9731)
+++ projects/haf/trunk/maemo-af-desktop/hildon-home/home-applet-handler.h	2007-02-08 08:48:32 UTC (rev 9732)
@@ -34,11 +34,13 @@
 #include <glib.h>
 #include <glib-object.h>
 #include <gtk/gtkmenu.h>
-#include <gtk/gtktoolbar.h>
+#include <gtk/gtkeventbox.h>
+#include <gtk/gtkwindow.h>
 #include <gdk/gdkx.h> 
 #include <libosso.h>
-#include <gtk/gtk.h>
 
+#include "libdesktop/hildon-log.h"
+
 G_BEGIN_DECLS
 
 
@@ -55,6 +57,8 @@
     HOME_TYPE_APPLET_HANDLER))
 #define IS_HOME_APPLET_HANDLER_CLASS(klass) \
     (GTK_CHECK_CLASS_TYPE ((klass), HOME_TYPE_APPLET_HANDLER))
+#define HOME_APPLET_HANDLER_GET_CLASS(applet) \
+    (G_TYPE_INSTANCE_GET_CLASS ((applet),  HOME_TYPE_APPLET_HANDLER, HomeAppletHandlerClass))
 
 /* Type definitions for the applet API */
 typedef void *(*AppletInitializeFn)(void *state_data, 
@@ -97,6 +101,9 @@
 
 struct _HomeAppletHandlerClass {
     GObjectClass parent_class;
+
+    HildonLog   *log;
+    GList       *bad_plugins;
 };
 
 


More information about the maemo-commits mailing list