#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
osso_return_t execute(osso_context_t *osso, gpointer data, gboolean user_activated)
{
char *fileDouble;
int i;
gint response;
+ FILE *inputFilePtr;
/* Create dialog with OK and Cancel buttons. Leave the separator out,
* as we do not have any content. */
NULL);
/* ... add something to the dialog ... */
- //btnVisual = gtk_check_button_new_with_label();
btnVisual = (GtkWidget*)hildon_check_button_new(HILDON_SIZE_FULLSCREEN_WIDTH | HILDON_SIZE_FINGER_HEIGHT);
gtk_button_set_label (GTK_BUTTON (btnVisual), "Visual Notification");
adj = gtk_range_get_adjustment(GTK_RANGE(slider));
- FILE *inputFilePtr = fopen("/home/user/.config/CallNotify/conf.txt", "r");
+ inputFilePtr = fopen("/home/user/.config/CallNotify/conf.txt", "r");
- if (inputFilePtr != NULL)
- {
+ if (inputFilePtr != NULL)
+ {
+ fgets(fileContent, 12,inputFilePtr);
- fgets(fileContent, 12,inputFilePtr);
+ if (fileContent[0]=='y')
+ hildon_check_button_set_active (HILDON_CHECK_BUTTON(btnVisual), TRUE);
+ if (fileContent[2]=='y')
+ hildon_check_button_set_active (HILDON_CHECK_BUTTON(btnVibrate) , TRUE);
+ if (fileContent[4]=='y')
+ hildon_check_button_set_active (HILDON_CHECK_BUTTON(btnSound), TRUE);
- if (fileContent[0]=='y')
- hildon_check_button_set_active (HILDON_CHECK_BUTTON(btnVisual), TRUE);
- if (fileContent[2]=='y')
- hildon_check_button_set_active (HILDON_CHECK_BUTTON(btnVibrate) , TRUE);
- if (fileContent[4]=='y')
- hildon_check_button_set_active (HILDON_CHECK_BUTTON(btnSound), TRUE);
+ (char*)strtok(fileContent, ";");
+ (char*)strtok(NULL, ";");
+ (char*)strtok(NULL, ";");
- (char*)strtok(fileContent, ";");
- (char*)strtok(NULL, ";");
- (char*)strtok(NULL, ";");
+ fileDouble = strtok(NULL, ";");
- fileDouble = strtok(NULL, ";");
+ if (fileDouble)
+ {
// replace , with .
for (i=0; i<strlen(fileDouble); i++)
if (fileDouble[i]==',')
fileDouble[i] = '.';
- sldValue = g_strtod(fileDouble, NULL);
+ sldValue = g_strtod(fileDouble, NULL);
- gtk_adjustment_set_value(adj, sldValue);
+ }
- fclose(inputFilePtr);
+ fclose(inputFilePtr);
- }
+ }
+ gtk_adjustment_set_value(adj, sldValue);
gtk_container_add(GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), btnVisual);
gtk_container_add(GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), btnVibrate);
if (response == GTK_RESPONSE_OK)
{
/* ... do something with the dialog stuff ... */
- //FILE *f_write =
inputFilePtr = fopen("/home/user/.config/CallNotify/conf.txt", "w");
+ if (inputFilePtr == NULL)
+ {
+ mkdir("/home/user/.config/CallNotify", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
+ inputFilePtr = fopen("/home/user/.config/CallNotify/conf.txt", "w");
+ }
- 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);
-
+ if (inputFilePtr != NULL)
+ {
+ 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';
- fprintf(inputFilePtr, "%c;%c;%c;%.1f\n",a,b,c,newValue);
+ newValue = gtk_adjustment_get_value(adj);
- fclose(inputFilePtr);
+ fprintf(inputFilePtr, "%c;%c;%c;%.1f\n",a,b,c,newValue);
+ fclose(inputFilePtr);
+ }
}