Fix crashing libcallnotify.so library
authorPali Rohár <pali.rohar@gmail.com>
Fri, 22 Jun 2012 13:01:52 +0000 (15:01 +0200)
committerPali Rohár <pali.rohar@gmail.com>
Fri, 22 Jun 2012 13:01:52 +0000 (15:01 +0200)
src/usr/lib/hildon-control-panel/libcallnotify.c

index 5dc4013..2696abe 100644 (file)
@@ -1,4 +1,5 @@
 #include <hildon-cp-plugin/hildon-cp-plugin-interface.h>
+#include <hildon/hildon.h>
 #include <gtk/gtk.h>
 #include <stdlib.h>
 #include <string.h>
@@ -17,7 +18,7 @@ osso_return_t execute(osso_context_t *osso, gpointer data, gboolean user_activat
        GtkAdjustment * adj;
        gdouble sldValue = 0.0;
        gdouble newValue = 0.0;
-       char *fileContent;
+       char fileContent[64];
        char *fileDouble;
        int i;
        gint response;
@@ -49,6 +50,7 @@ osso_return_t execute(osso_context_t *osso, gpointer data, gboolean user_activat
 
 
        slider = gtk_hscale_new_with_range(0.0, 60.0, 0.1);
+       adj = gtk_range_get_adjustment(GTK_RANGE(slider));
 
 
                FILE *inputFilePtr = fopen("/home/user/.config/CallNotify/conf.txt", "r");
@@ -61,11 +63,11 @@ osso_return_t execute(osso_context_t *osso, gpointer data, gboolean user_activat
 
 
                    if (fileContent[0]=='y')
-                       hildon_check_button_set_active (GTK_BUTTON(btnVisual), TRUE);
+                       hildon_check_button_set_active (HILDON_CHECK_BUTTON(btnVisual), TRUE);
                    if (fileContent[2]=='y')
-                       hildon_check_button_set_active (GTK_BUTTON(btnVibrate) , TRUE);
+                       hildon_check_button_set_active (HILDON_CHECK_BUTTON(btnVibrate) , TRUE);
                    if (fileContent[4]=='y')
-                       hildon_check_button_set_active (GTK_BUTTON(btnSound), TRUE);
+                       hildon_check_button_set_active (HILDON_CHECK_BUTTON(btnSound), TRUE);
 
                        (char*)strtok(fileContent, ";");
                        (char*)strtok(NULL, ";");
@@ -80,12 +82,11 @@ osso_return_t execute(osso_context_t *osso, gpointer data, gboolean user_activat
 
                    sldValue = g_strtod(fileDouble, NULL);
 
-                   adj = gtk_range_get_adjustment(GTK_RANGE(slider));
                    gtk_adjustment_set_value(adj, sldValue);
 
-               }
+                   fclose(inputFilePtr);
 
-                fclose(inputFilePtr);
+               }
 
 
        gtk_container_add(GTK_CONTAINER (GTK_DIALOG(dialog)->vbox),     btnVisual);
@@ -106,9 +107,9 @@ osso_return_t execute(osso_context_t *osso, gpointer data, gboolean user_activat
                inputFilePtr = fopen("/home/user/.config/CallNotify/conf.txt", "w");
 
 
-               a = hildon_check_button_get_active(GTK_BUTTON(btnVisual)) ? 'y' : 'n';
-               b = hildon_check_button_get_active(GTK_BUTTON(btnVibrate)) ? 'y' : 'n';
-               c = hildon_check_button_get_active(GTK_BUTTON(btnSound)) ? 'y' : 'n';
+               a = hildon_check_button_get_active(HILDON_CHECK_BUTTON(btnVisual)) ? 'y' : 'n';
+               b = hildon_check_button_get_active(HILDON_CHECK_BUTTON(btnVibrate)) ? 'y' : 'n';
+               c = hildon_check_button_get_active(HILDON_CHECK_BUTTON(btnSound)) ? 'y' : 'n';
 
                newValue = gtk_adjustment_get_value(adj);