conf.c File Reference

#include "config.h"
#include <glib.h>
#include <gconf/gconf-client.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <liberipc/eripc.h>
#include "log.h"
#include "conf.h"
#include "connections.h"
#include "locales.h"
#include "i18n.h"
#include "ipc.h"
#include "wacom.h"
Include dependency graph for conf.c:

Go to the source code of this file.

Defines

#define UNUSED(x)   (void)(x)
#define KEYS_SYSTEM   KEYS_EREADER "/sys"
#define KEY_GLOBAL_LOCALE   KEYS_SYSTEM "/global/locale"
#define KEY_GLOBAL_TZ_OFFSET   KEYS_SYSTEM "/global/timezone_offset"
#define KEY_GLOBAL_LIST_LOCALES   KEYS_SYSTEM "/global/list_locales"
#define KEY_GLOBAL_LIST_LANGUAGES   KEYS_SYSTEM "/global/list_languages"
#define KEY_GLOBAL_FIRST_BOOT   KEYS_SYSTEM "/global/is_first_boot"
#define KEY_DISPLAY_ROTATION   KEYS_SYSTEM "/display/rotation"
#define KEY_SENSOR_USE_SOUND   KEYS_SYSTEM "/sensor/use_sound"
#define KEY_SENSOR_USE_LIGHT   KEYS_SYSTEM "/sensor/use_light"
#define KEY_SENSOR_USE_LOCK_LEFT   KEYS_SYSTEM "/sensor/use_lock_left"
#define KEY_SENSOR_USE_LOCK_RIGHT   KEYS_SYSTEM "/sensor/use_lock_right"
#define KEY_SENSOR_USE_LOCK_MIDDLE   KEYS_SYSTEM "/sensor/use_lock_middle"
#define KEY_POWER_IDLE_MODE   KEYS_SYSTEM "/power/idle_mode"
#define KEY_POWER_MIN_STANDBY   KEYS_SYSTEM "/power/min_standby"
#define KEY_POWER_USE_STYLUS   KEYS_SYSTEM "/power/use_stylus"
#define KEY_POWER_STANDBY_IF_PLUGGED   KEYS_SYSTEM "/power/standby_if_plugged"
#define KEY_FLIGHTMODE_MODE   KEYS_SYSTEM "/flightmode/flightmode_mode"
#define KEY_PAGETURN_INVERTED   KEYS_SYSTEM "/flipbar/pageturn_inverted"
#define KEY_INDEX_WITH_METADATA   KEYS_SYSTEM "/index/add_with_metadata"
#define KEY_UP_DOWN_FOCUS_BEHAVIOR   "/desktop/poky/interface/gtk-up-down-focus-behavior"
#define MINIMUM_STANDBY_MIN   1

Functions

static void event_gconf_value_changed (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
static void set_startup_defaults (void)
static void update_installed_locales (void)
void conf_set_services (void)
 Initialize configuration.
gboolean conf_get_first_boot (void)
 Run specials when this is the first boot of the device.
void conf_set_first_boot (gboolean first_boot)
void conf_disabled_sensor_lock (void)
 Read sensor lock settings from registry and set statusbar icon accordingly.
gboolean conf_set_flightmode (gboolean is_enabled)
 Run specials when this is the first boot of the device.
gboolean conf_is_multi_language ()
static gboolean set_locale (const gchar *locale)

Variables

static GConfClient * g_gconfclient = NULL
static gboolean g_number_of_langages = FALSE

Define Documentation

#define KEY_DISPLAY_ROTATION   KEYS_SYSTEM "/display/rotation"

Definition at line 70 of file conf.c.

Referenced by event_gconf_value_changed(), and set_startup_defaults().

#define KEY_FLIGHTMODE_MODE   KEYS_SYSTEM "/flightmode/flightmode_mode"

Definition at line 80 of file conf.c.

Referenced by conf_set_flightmode(), event_gconf_value_changed(), and set_startup_defaults().

#define KEY_GLOBAL_FIRST_BOOT   KEYS_SYSTEM "/global/is_first_boot"

Definition at line 69 of file conf.c.

Referenced by conf_get_first_boot(), conf_set_first_boot(), and event_gconf_value_changed().

#define KEY_GLOBAL_LIST_LANGUAGES   KEYS_SYSTEM "/global/list_languages"

Definition at line 68 of file conf.c.

Referenced by update_installed_locales().

#define KEY_GLOBAL_LIST_LOCALES   KEYS_SYSTEM "/global/list_locales"

Definition at line 67 of file conf.c.

Referenced by update_installed_locales().

#define KEY_GLOBAL_LOCALE   KEYS_SYSTEM "/global/locale"
#define KEY_GLOBAL_TZ_OFFSET   KEYS_SYSTEM "/global/timezone_offset"

Definition at line 66 of file conf.c.

#define KEY_INDEX_WITH_METADATA   KEYS_SYSTEM "/index/add_with_metadata"

Definition at line 82 of file conf.c.

Referenced by event_gconf_value_changed(), and set_startup_defaults().

#define KEY_PAGETURN_INVERTED   KEYS_SYSTEM "/flipbar/pageturn_inverted"

Definition at line 81 of file conf.c.

Referenced by event_gconf_value_changed(), and set_startup_defaults().

#define KEY_POWER_IDLE_MODE   KEYS_SYSTEM "/power/idle_mode"

Definition at line 76 of file conf.c.

Referenced by event_gconf_value_changed(), and set_startup_defaults().

#define KEY_POWER_MIN_STANDBY   KEYS_SYSTEM "/power/min_standby"

Definition at line 77 of file conf.c.

Referenced by event_gconf_value_changed(), and set_startup_defaults().

#define KEY_POWER_STANDBY_IF_PLUGGED   KEYS_SYSTEM "/power/standby_if_plugged"

Definition at line 79 of file conf.c.

Referenced by event_gconf_value_changed(), and set_startup_defaults().

#define KEY_POWER_USE_STYLUS   KEYS_SYSTEM "/power/use_stylus"

Definition at line 78 of file conf.c.

Referenced by event_gconf_value_changed(), and set_startup_defaults().

#define KEY_SENSOR_USE_LIGHT   KEYS_SYSTEM "/sensor/use_light"

Definition at line 72 of file conf.c.

Referenced by event_gconf_value_changed(), and set_startup_defaults().

#define KEY_SENSOR_USE_LOCK_LEFT   KEYS_SYSTEM "/sensor/use_lock_left"
#define KEY_SENSOR_USE_LOCK_MIDDLE   KEYS_SYSTEM "/sensor/use_lock_middle"
#define KEY_SENSOR_USE_LOCK_RIGHT   KEYS_SYSTEM "/sensor/use_lock_right"
#define KEY_SENSOR_USE_SOUND   KEYS_SYSTEM "/sensor/use_sound"

Definition at line 71 of file conf.c.

Referenced by event_gconf_value_changed(), and set_startup_defaults().

#define KEY_UP_DOWN_FOCUS_BEHAVIOR   "/desktop/poky/interface/gtk-up-down-focus-behavior"

Definition at line 84 of file conf.c.

Referenced by set_startup_defaults().

#define KEYS_SYSTEM   KEYS_EREADER "/sys"

Definition at line 64 of file conf.c.

Referenced by conf_set_services().

#define MINIMUM_STANDBY_MIN   1

Definition at line 86 of file conf.c.

Referenced by event_gconf_value_changed(), and set_startup_defaults().

#define UNUSED (  )     (void)(x)

Copyright (C) 2008 iRex Technologies B.V. All rights reserved.

Definition at line 52 of file conf.c.


Function Documentation

void conf_disabled_sensor_lock ( void   ) 

Read sensor lock settings from registry and set statusbar icon accordingly.

---------------------------------------------------------------------------

Name : conf_disabled_sensor_lock

Parameters:
-- 
Returns:
--

--------------------------------------------------------------------------

Definition at line 178 of file conf.c.

References g_gconfclient, ipc_menu_set_item_state(), KEY_SENSOR_USE_LOCK_LEFT, KEY_SENSOR_USE_LOCK_MIDDLE, KEY_SENSOR_USE_LOCK_RIGHT, and LOGPRINTF.

Referenced by event_gconf_value_changed(), and on_phase_1_complete().

00179 {
00180     LOGPRINTF("entry");
00181     
00182     gboolean locked;
00183     GError   *error = NULL;
00184 
00185     locked = gconf_client_get_bool(g_gconfclient, KEY_SENSOR_USE_LOCK_LEFT, &error);
00186     if (!error && !locked)
00187     {
00188         locked = gconf_client_get_bool(g_gconfclient, KEY_SENSOR_USE_LOCK_RIGHT, &error);
00189         if (!error && !locked)
00190         {
00191             locked = gconf_client_get_bool(g_gconfclient, KEY_SENSOR_USE_LOCK_MIDDLE, &error);
00192         }
00193     }
00194     
00195     if (error) 
00196     {
00197         g_error_free(error);
00198     }
00199     else if (locked)
00200     {
00201         ipc_menu_set_item_state("lock", "general", "normal");
00202     }
00203     else
00204     {
00205         ipc_menu_set_item_state("lock", "general", "disabled");
00206     }
00207 }

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean conf_get_first_boot ( void   ) 

Run specials when this is the first boot of the device.

---------------------------------------------------------------------------

Name : conf_get_first_boot

Parameters:
-- 
Returns:
--

--------------------------------------------------------------------------

Definition at line 144 of file conf.c.

References g_gconfclient, KEY_GLOBAL_FIRST_BOOT, LOGPRINTF, and WARNPRINTF.

Referenced by start_phase_2(), and sys_standby().

00145 {
00146     LOGPRINTF("entry");
00147 
00148     gboolean     first_boot = FALSE;
00149     GError       *error     = NULL;
00150     
00151     first_boot = gconf_client_get_bool(g_gconfclient, KEY_GLOBAL_FIRST_BOOT, &error);
00152     if (error)
00153     {
00154         WARNPRINTF("error fetching GConf key %s: %s", KEY_GLOBAL_FIRST_BOOT, error->message);
00155         g_error_free(error);
00156     }   
00157     LOGPRINTF("return: %d", first_boot);
00158     
00159     return first_boot;
00160 }

Here is the caller graph for this function:

gboolean conf_is_multi_language ( void   ) 

Definition at line 228 of file conf.c.

References g_number_of_langages.

Referenced by start_phase_2().

00229 {
00230     return (g_number_of_langages > 1);
00231 }

Here is the caller graph for this function:

void conf_set_first_boot ( gboolean  first_boot  ) 

Definition at line 163 of file conf.c.

References g_gconfclient, KEY_GLOBAL_FIRST_BOOT, LOGPRINTF, and WARNPRINTF.

Referenced by sys_starting_finished().

00164 {
00165     LOGPRINTF("entry");
00166 
00167     GError       *error     = NULL;
00168     
00169     gconf_client_set_bool(g_gconfclient, KEY_GLOBAL_FIRST_BOOT, first_boot, &error);
00170     if (error)
00171     {
00172         WARNPRINTF("error writing GConf key %s: %s", KEY_GLOBAL_FIRST_BOOT, error->message);
00173         g_error_free(error);
00174     }   
00175 }

Here is the caller graph for this function:

gboolean conf_set_flightmode ( gboolean  is_enabled  ) 

Run specials when this is the first boot of the device.

---------------------------------------------------------------------------

Name : conf_set_flightmode

Parameters:
[in] is_enabled - TRUE flightmode enabled, no connectivity allowed FALSE flightmode disabled, connectivity allowed
Returns:
TRUE =ok, FALSE = error

--------------------------------------------------------------------------

Definition at line 210 of file conf.c.

References g_gconfclient, KEY_FLIGHTMODE_MODE, LOGPRINTF, and WARNPRINTF.

Referenced by conn_on_statusitem_activated().

00211 {
00212     gboolean ret = TRUE;  // return value, TRUE = ok
00213     GError   *error = NULL;
00214 
00215     LOGPRINTF("entry");
00216 
00217     ret = gconf_client_set_bool(g_gconfclient, KEY_FLIGHTMODE_MODE, is_enabled, &error);
00218     if (error)
00219     {
00220         WARNPRINTF("error saving GConf key %s: %s", KEY_FLIGHTMODE_MODE, error->message);
00221         g_error_free(error);
00222     }
00223 
00224     return ret;
00225 }

Here is the caller graph for this function:

void conf_set_services ( void   ) 

Initialize configuration.

---------------------------------------------------------------------------

Name : conf_set_services

Parameters:
-- 
Returns:
--

--------------------------------------------------------------------------

Definition at line 112 of file conf.c.

References ERRORPRINTF, event_gconf_value_changed(), g_gconfclient, KEYS_SYSTEM, LOGPRINTF, set_startup_defaults(), and update_installed_locales().

Referenced by main().

00113 {
00114     LOGPRINTF("entry");
00115 
00116     g_type_init();
00117     g_gconfclient = gconf_client_get_default();
00118     if (g_gconfclient==NULL) 
00119     {
00120         ERRORPRINTF("Failed to connect to GConf");
00121         exit(1);
00122     }   
00123     
00124     gconf_client_add_dir(g_gconfclient,
00125                          KEYS_SYSTEM,
00126                          GCONF_CLIENT_PRELOAD_NONE,
00127                          NULL);
00128 
00129     gconf_client_notify_add(g_gconfclient,
00130                             KEYS_SYSTEM,
00131                             event_gconf_value_changed,
00132                             NULL,
00133                             NULL,
00134                             NULL);
00135     
00136     // check locales/languages available on system
00137     update_installed_locales();
00138     
00139     // initialize system settings from startup configuration
00140     set_startup_defaults();
00141 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void event_gconf_value_changed ( GConfClient *  client,
guint  cnxn_id,
GConfEntry *  entry,
gpointer  user_data 
) [static]

Definition at line 281 of file conf.c.

References conf_disabled_sensor_lock(), conn_set_flightmode(), g_gconfclient, KEY_DISPLAY_ROTATION, KEY_FLIGHTMODE_MODE, KEY_GLOBAL_FIRST_BOOT, KEY_GLOBAL_LOCALE, KEY_INDEX_WITH_METADATA, KEY_PAGETURN_INVERTED, KEY_POWER_IDLE_MODE, KEY_POWER_MIN_STANDBY, KEY_POWER_STANDBY_IF_PLUGGED, KEY_POWER_USE_STYLUS, KEY_SENSOR_USE_LIGHT, KEY_SENSOR_USE_LOCK_LEFT, KEY_SENSOR_USE_LOCK_MIDDLE, KEY_SENSOR_USE_LOCK_RIGHT, KEY_SENSOR_USE_SOUND, LOGPRINTF, MINIMUM_STANDBY_MIN, rotation, set_locale(), sys_set_idle_mode(), sys_set_index_with_metadata(), sys_set_pageturn_inverted(), sys_set_rotate_direction(), sys_set_sensor_feedback(), sys_set_sensor_lock_config(), sys_set_standby_mode(), sys_set_standby_time(), UNUSED, update_installed_locales(), wacom_disable(), wacom_enable(), and WARNPRINTF.

Referenced by conf_set_services().

00285 {
00286     UNUSED(cnxn_id);
00287     UNUSED(user_data);
00288 
00289     LOGPRINTF("entry");
00290 
00291     const gchar* key = gconf_entry_get_key(entry);
00292     if (key == NULL)
00293     {
00294         WARNPRINTF("Failed to get key name");
00295         return;
00296     }
00297     
00298     const GConfValue* value = gconf_entry_get_value(entry);
00299     if (value == NULL)
00300     {
00301         // value not set, possibly empty folder
00302         return;
00303     }
00304 
00305     LOGPRINTF("key [%s] type [%d] value [%s]", key, value->type, gconf_value_to_string(value));
00306     
00307     if (strcmp(key, KEY_GLOBAL_LOCALE) == 0)
00308     {
00309         if (value->type == GCONF_VALUE_STRING)
00310         {   
00311             const char *locale = gconf_value_get_string(value);
00312             if (locale != NULL)
00313             {
00314                 if (!set_locale(locale))
00315                 {
00316                     WARNPRINTF("Locale not found");
00317                 }
00318             }
00319         }
00320         else
00321         {
00322             WARNPRINTF("Cannot parse value of key %s", key);
00323         }
00324     }
00325     else if (strcmp(key, KEY_INDEX_WITH_METADATA) == 0)
00326     {
00327         if (value->type == GCONF_VALUE_BOOL)
00328         {
00329             sys_set_index_with_metadata(gconf_value_get_bool(value));
00330         }
00331         else
00332         {
00333             WARNPRINTF("Cannot parse value of key %s", key);
00334         }
00335     }
00336     else if (strcmp(key, KEY_PAGETURN_INVERTED) == 0)
00337     {
00338         if (value->type == GCONF_VALUE_BOOL)
00339         {
00340             sys_set_pageturn_inverted(gconf_value_get_bool(value));
00341         }
00342         else
00343         {
00344             WARNPRINTF("Cannot parse value of key %s", key);
00345         }
00346     }
00347     else if (strcmp(key, KEY_DISPLAY_ROTATION) == 0)
00348     {
00349         if (value->type == GCONF_VALUE_STRING)
00350         {   
00351             const char *rotation = gconf_value_get_string(value);
00352             if (rotation != NULL)
00353             {
00354                 sys_set_rotate_direction(rotation);
00355             }
00356         }
00357         else
00358         {
00359             WARNPRINTF("Cannot parse value of key %s", key);
00360         }
00361     }
00362     else if (strcmp(key, KEY_SENSOR_USE_SOUND) == 0)
00363     {
00364         if (value->type == GCONF_VALUE_BOOL)
00365         {   
00366             gboolean use_light     = gconf_client_get_bool(g_gconfclient, KEY_SENSOR_USE_LIGHT, NULL);
00367             gboolean use_sound     = gconf_value_get_bool(value);
00368 
00369             sys_set_sensor_feedback(use_light, use_sound);
00370         }
00371         else
00372         {
00373             WARNPRINTF("Cannot parse value of key %s", key);
00374         }
00375     }
00376     else if (strcmp(key, KEY_SENSOR_USE_LIGHT) == 0)
00377     {
00378         if (value->type == GCONF_VALUE_BOOL)
00379         {   
00380             gboolean use_sound     = gconf_client_get_bool(g_gconfclient, KEY_SENSOR_USE_SOUND, NULL);
00381             gboolean use_light     = gconf_value_get_bool(value);
00382             
00383             sys_set_sensor_feedback(use_light, use_sound);
00384         }
00385         else
00386         {
00387             WARNPRINTF("Cannot parse value of key %s", key);
00388         }
00389     }
00390     else if (strcmp(key, KEY_SENSOR_USE_LOCK_LEFT) == 0)
00391     {
00392         if (value->type == GCONF_VALUE_BOOL)
00393         {   
00394             gboolean use_lock_left = gconf_value_get_bool(value);
00395             gboolean use_lock_right = gconf_client_get_bool(g_gconfclient, KEY_SENSOR_USE_LOCK_RIGHT, NULL);
00396             gboolean use_lock_middle = gconf_client_get_bool(g_gconfclient, KEY_SENSOR_USE_LOCK_MIDDLE, NULL);
00397             
00398             conf_disabled_sensor_lock();
00399             
00400             sys_set_sensor_lock_config(use_lock_left, use_lock_right, use_lock_middle);
00401         }
00402         else
00403         {
00404             WARNPRINTF("Cannot parse value of key %s", key);
00405         }
00406     }
00407     else if (strcmp(key, KEY_SENSOR_USE_LOCK_RIGHT) == 0)
00408     {
00409         if (value->type == GCONF_VALUE_BOOL)
00410         {   
00411             gboolean use_lock_left = gconf_client_get_bool(g_gconfclient, KEY_SENSOR_USE_LOCK_LEFT, NULL);
00412             gboolean use_lock_right = gconf_value_get_bool(value);
00413             gboolean use_lock_middle = gconf_client_get_bool(g_gconfclient, KEY_SENSOR_USE_LOCK_MIDDLE, NULL);
00414             
00415             conf_disabled_sensor_lock();
00416             
00417             sys_set_sensor_lock_config(use_lock_left, use_lock_right, use_lock_middle);
00418         }
00419         else
00420         {
00421             WARNPRINTF("Cannot parse value of key %s", key);
00422         }
00423     }
00424     else if (strcmp(key, KEY_SENSOR_USE_LOCK_MIDDLE) == 0)
00425     {
00426         if (value->type == GCONF_VALUE_BOOL)
00427         {   
00428             gboolean use_lock_left = gconf_client_get_bool(g_gconfclient, KEY_SENSOR_USE_LOCK_LEFT, NULL);
00429             gboolean use_lock_right = gconf_client_get_bool(g_gconfclient, KEY_SENSOR_USE_LOCK_RIGHT, NULL);
00430             gboolean use_lock_middle = gconf_value_get_bool(value);
00431             
00432             conf_disabled_sensor_lock();
00433             
00434             sys_set_sensor_lock_config(use_lock_left, use_lock_right, use_lock_middle);
00435         }
00436         else
00437         {
00438             WARNPRINTF("Cannot parse value of key %s", key);
00439         }
00440     }
00441 /*    
00442     else if (strcmp(key, KEY_GLOBAL_TZ_OFFSET) == 0)
00443     {
00444         if (value->type == GCONF_VALUE_INT)
00445         {   
00446             sys_set_timezone_offset(gconf_value_get_int(value));
00447         }
00448         else
00449         {
00450             WARNPRINTF("Cannot parse value of key %s", key);
00451         }
00452     }
00453 */
00454     else if (strcmp(key, KEY_POWER_USE_STYLUS) == 0)
00455     {
00456         if (value->type == GCONF_VALUE_BOOL)
00457         {   
00458             if (gconf_value_get_bool(value))
00459             {
00460                 wacom_enable();
00461             }
00462             else
00463             {
00464                 wacom_disable();
00465             }
00466         }
00467         else
00468         {
00469             WARNPRINTF("Cannot parse value of key %s", key);
00470         }
00471     }
00472     else if (strcmp(key, KEY_POWER_IDLE_MODE) == 0)
00473     {
00474         if (value->type == GCONF_VALUE_BOOL)
00475         {   
00476             sys_set_idle_mode(gconf_value_get_bool(value));
00477         }
00478         else
00479         {
00480             WARNPRINTF("Cannot parse value of key %s", key);
00481         }
00482     }
00483     else if (strcmp(key, KEY_POWER_MIN_STANDBY) == 0)
00484     {
00485         if (value->type == GCONF_VALUE_INT)
00486         {   
00487             gint standby = gconf_value_get_int(value);
00488             if (standby > 0)
00489             {
00490                 if (standby < MINIMUM_STANDBY_MIN)
00491                 {
00492                     standby = MINIMUM_STANDBY_MIN;
00493                 }
00494                 sys_set_standby_time(standby * 60);
00495             }
00496             else if (standby == -1)
00497             {
00498                 sys_set_standby_time(0);
00499             }
00500         }
00501         else
00502         {
00503             WARNPRINTF("Cannot parse value of key %s", key);
00504         }
00505     }
00506     else if (strcmp(key, KEY_POWER_STANDBY_IF_PLUGGED) == 0)
00507     {
00508         if (value->type == GCONF_VALUE_BOOL)
00509         {   
00510             sys_set_standby_mode(gconf_value_get_bool(value));
00511         }
00512         else
00513         {
00514             WARNPRINTF("Cannot parse value of key %s", key);
00515         }
00516     }
00517     else if (strcmp(key, KEY_FLIGHTMODE_MODE) == 0)
00518     {
00519         if (value->type == GCONF_VALUE_BOOL)
00520         {   
00521             conn_set_flightmode(gconf_value_get_bool(value));
00522         }
00523         else
00524         {
00525             WARNPRINTF("Cannot parse value of key %s", key);
00526         }
00527     }
00528     else if (strcmp(key, KEY_GLOBAL_FIRST_BOOT) == 0)
00529     {
00530         if (value->type == GCONF_VALUE_BOOL)
00531         {   
00532             if (gconf_value_get_bool(value))
00533             {
00534                 // device is reset to factory defaults;
00535                 // check locales/languages available on system
00536                 update_installed_locales();
00537             }
00538         }
00539     }    
00540     
00541 /*
00542     LOGPRINTF("GConf key changed");
00543     g_print("Key: %s\t", key);
00544 
00545     if (value) 
00546     {
00547         switch (value->type) 
00548         {
00549         case GCONF_VALUE_STRING: 
00550             g_print(" STRING\t`%s`", gconf_value_get_string(value));
00551             break;
00552         
00553         case GCONF_VALUE_INT:
00554             g_print(" INT\t %d", gconf_value_get_int(value));
00555             break;      
00556         
00557         case GCONF_VALUE_FLOAT:
00558             g_print(" FLOAT\t %f", gconf_value_get_float(value));
00559             break;            
00560         
00561         case GCONF_VALUE_BOOL:
00562             g_print(" BOOL\t %s", (gconf_value_get_bool(value) ? "true" : "false"));
00563             break;            
00564         
00565         case GCONF_VALUE_SCHEMA:
00566             g_print(" SCHEMA");
00567             break;            
00568         
00569         case GCONF_VALUE_LIST:
00570             g_print(" LIST");
00571             break;            
00572         
00573         case GCONF_VALUE_PAIR:
00574             g_print(" PAIR");
00575             break;            
00576         
00577         case GCONF_VALUE_INVALID:
00578         default:
00579             g_print(" has invalid type");
00580             break;
00581         }
00582     }
00583     else
00584     {
00585       g_print(" has invalid type");
00586     } 
00587     g_print("\n");
00588 */
00589 }

Here is the call graph for this function:

Here is the caller graph for this function:

static gboolean set_locale ( const gchar *  locale  )  [static]

Definition at line 238 of file conf.c.

References ipc_send_changed_locale(), locales_list_codes(), locales_list_create(), locales_list_free(), LOGPRINTF, and WARNPRINTF.

Referenced by event_gconf_value_changed(), and set_startup_defaults().

00239 {
00240     gboolean retval = FALSE;
00241     GSList *locale_list;
00242     GSList *code_list;
00243     GSList *found;
00244     locale_list = locales_list_create();
00245     code_list = locales_list_codes(locale_list);
00246     
00247     found = g_slist_find_custom(code_list, locale, (GCompareFunc)strcmp);
00248     if (!found) 
00249     {
00250         WARNPRINTF("Locale [%s] not found, try en_US", locale);
00251         found = g_slist_find_custom(code_list, "en_US", (GCompareFunc)strcmp);
00252     }
00253     if (!found) 
00254     {
00255         WARNPRINTF("Locale en_US not found, try en_GB");
00256         found = g_slist_find_custom(code_list, "en_GB", (GCompareFunc)strcmp);
00257     }
00258     
00259     if (found)
00260     {
00261         LOGPRINTF("Found and set locale [%s]", (gchar *) found->data);
00262         
00263         // set locale in environment 
00264         g_setenv("LANG", found->data, TRUE);
00265         setlocale(LC_ALL, "");
00266         
00267         // report to applications
00268         ipc_send_changed_locale(found->data);
00269         
00270         retval = TRUE;
00271     }
00272     
00273     // free memory
00274     locales_list_free(locale_list);
00275     g_slist_free(code_list);
00276     
00277     return retval;
00278 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void set_startup_defaults ( void   )  [static]

Definition at line 592 of file conf.c.

References conn_set_flightmode(), g_gconfclient, KEY_DISPLAY_ROTATION, KEY_FLIGHTMODE_MODE, KEY_GLOBAL_LOCALE, KEY_INDEX_WITH_METADATA, KEY_PAGETURN_INVERTED, KEY_POWER_IDLE_MODE, KEY_POWER_MIN_STANDBY, KEY_POWER_STANDBY_IF_PLUGGED, KEY_POWER_USE_STYLUS, KEY_SENSOR_USE_LIGHT, KEY_SENSOR_USE_LOCK_LEFT, KEY_SENSOR_USE_LOCK_MIDDLE, KEY_SENSOR_USE_LOCK_RIGHT, KEY_SENSOR_USE_SOUND, KEY_UP_DOWN_FOCUS_BEHAVIOR, LOGPRINTF, MINIMUM_STANDBY_MIN, rotation, set_locale(), sys_set_idle_mode(), sys_set_index_with_metadata(), sys_set_pageturn_inverted(), sys_set_rotate_direction(), sys_set_sensor_feedback(), sys_set_sensor_lock_config(), sys_set_standby_mode(), sys_set_standby_time(), wacom_disable(), wacom_enable(), and WARNPRINTF.

Referenced by conf_set_services().

00593 {
00594     LOGPRINTF("entry");
00595 
00596     GError *error = NULL;
00597     
00598     // set alternate navigation of GTK+ for DR800 with up/down buttons only
00599 #if MACHINE_IS_DR800SG || MACHINE_IS_DR800S || MACHINE_IS_DR800SW
00600     gconf_client_set_int(g_gconfclient, KEY_UP_DOWN_FOCUS_BEHAVIOR, 1, &error);
00601 #elif MACHINE_IS_DR1000S || MACHINE_IS_DR1000SW
00602     gconf_client_set_int(g_gconfclient, KEY_UP_DOWN_FOCUS_BEHAVIOR, 0, &error);
00603 #endif    
00604     if (error)
00605     {
00606         WARNPRINTF("error writing GConf key %s: %s", KEY_UP_DOWN_FOCUS_BEHAVIOR, error->message);
00607         g_error_free(error);
00608         error = NULL;
00609     }
00610     
00611     char *locale = gconf_client_get_string(g_gconfclient, KEY_GLOBAL_LOCALE, &error);
00612     if (error)
00613     {
00614         WARNPRINTF("error fetching GConf key %s: %s", KEY_GLOBAL_LOCALE, error->message);
00615         g_error_free(error);
00616         error = NULL;
00617     }
00618     else
00619     {
00620         if (!set_locale(locale))
00621         {
00622             WARNPRINTF("Locale not found");
00623         }
00624     }
00625   
00626 /*    
00627     gint tz_offset = gconf_client_get_int(g_gconfclient, KEY_GLOBAL_TZ_OFFSET, &error);
00628     if (error)
00629     {
00630         WARNPRINTF("error fetching GConf key %s: %s", KEY_GLOBAL_TZ_OFFSET, error->message);
00631         g_error_free(error);
00632         error = NULL;
00633     }
00634     else
00635     {
00636         sys_set_timezone_offset(tz_offset);
00637     }
00638 */
00639 
00640     gboolean index_with_metadata = gconf_client_get_bool(g_gconfclient, KEY_INDEX_WITH_METADATA, &error);
00641     if (error)
00642     {
00643         WARNPRINTF("error fetching GConf key %s: %s", KEY_INDEX_WITH_METADATA, error->message);
00644         g_error_free(error);
00645         error = NULL;
00646     }
00647     else
00648     {
00649         sys_set_index_with_metadata(index_with_metadata);
00650     }
00651 
00652     char *rotation = gconf_client_get_string(g_gconfclient, KEY_DISPLAY_ROTATION, &error);
00653     if (error)
00654     {
00655         WARNPRINTF("error fetching GConf key %s: %s", KEY_DISPLAY_ROTATION, error->message);
00656         g_error_free(error);
00657         error = NULL;
00658     }
00659     if (rotation != NULL )
00660     {
00661         sys_set_rotate_direction(rotation);
00662     }
00663     
00664     gboolean is_pageturn_inverted = gconf_client_get_bool(g_gconfclient, KEY_PAGETURN_INVERTED, &error);
00665     if (error)
00666     {
00667         WARNPRINTF("error fetching GConf key %s: %s", KEY_PAGETURN_INVERTED, error->message);
00668         g_error_free(error);
00669         error = NULL;
00670     }
00671     else
00672     {
00673         sys_set_pageturn_inverted(is_pageturn_inverted);
00674     }
00675 
00676     gboolean use_light = gconf_client_get_bool(g_gconfclient, KEY_SENSOR_USE_LIGHT, &error);
00677     if (error)
00678     {
00679         WARNPRINTF("error fetching GConf key %s: %s", KEY_SENSOR_USE_LIGHT, error->message);
00680         g_error_free(error);
00681         error = NULL;
00682     }
00683     else
00684     {
00685         gboolean use_sound = gconf_client_get_bool(g_gconfclient, KEY_SENSOR_USE_SOUND, &error);
00686         if (error)
00687         {
00688             WARNPRINTF("error fetching GConf key %s: %s", KEY_SENSOR_USE_SOUND, error->message);
00689             g_error_free(error);
00690             error = NULL;
00691         }
00692         else
00693         {
00694             sys_set_sensor_feedback(use_light, use_sound);    
00695         }
00696     }
00697     
00698     gboolean use_lock_left = gconf_client_get_bool(g_gconfclient, KEY_SENSOR_USE_LOCK_LEFT, &error);
00699     if (error)
00700     {
00701         WARNPRINTF("error fetching GConf key %s: %s", KEY_SENSOR_USE_LOCK_LEFT, error->message);
00702         g_error_free(error);
00703         error = NULL;
00704     }
00705     else
00706     {
00707         gboolean use_lock_right  = gconf_client_get_bool(g_gconfclient, KEY_SENSOR_USE_LOCK_RIGHT, &error);
00708         if (error)
00709         {
00710             WARNPRINTF("error fetching GConf key %s: %s", KEY_SENSOR_USE_LOCK_RIGHT, error->message);
00711             g_error_free(error);
00712             error = NULL;
00713         }
00714         else
00715         {
00716             gboolean use_lock_middle = gconf_client_get_bool(g_gconfclient, KEY_SENSOR_USE_LOCK_MIDDLE, &error);
00717             if (error)
00718             {
00719                 WARNPRINTF("error fetching GConf key %s: %s", KEY_SENSOR_USE_LOCK_MIDDLE, error->message);
00720                 g_error_free(error);
00721                 error = NULL;
00722             }
00723             else
00724             {
00725                 sys_set_sensor_lock_config(use_lock_left, use_lock_right, use_lock_middle);    
00726             }
00727         }
00728     }
00729 
00730     gboolean use_stylus = gconf_client_get_bool(g_gconfclient, KEY_POWER_USE_STYLUS, &error);
00731     if (error)
00732     {
00733         WARNPRINTF("error fetching GConf key %s: %s", KEY_POWER_USE_STYLUS, error->message);
00734         g_error_free(error);
00735         error = NULL;
00736     }
00737     else
00738     {
00739         if (use_stylus)
00740         {
00741             wacom_enable();
00742         }
00743         else
00744         {
00745             wacom_disable();
00746         }
00747     }
00748  
00749     gboolean idle_mode = gconf_client_get_bool(g_gconfclient, KEY_POWER_IDLE_MODE, &error);
00750     if (error)
00751     {
00752         WARNPRINTF("error fetching GConf key %s: %s", KEY_POWER_IDLE_MODE, error->message);
00753         g_error_free(error);
00754         error = NULL;
00755     }
00756     else
00757     {
00758         sys_set_idle_mode(idle_mode);
00759     }
00760 
00761     gint standby = gconf_client_get_int(g_gconfclient, KEY_POWER_MIN_STANDBY, &error);
00762     if (error)
00763     {
00764         WARNPRINTF("error fetching GConf key %s: %s", KEY_POWER_MIN_STANDBY, error->message);
00765         g_error_free(error);
00766         error = NULL;
00767     }
00768     else
00769     {
00770         if (standby > 0)
00771         {
00772             if (standby < MINIMUM_STANDBY_MIN)
00773             {
00774                 standby = MINIMUM_STANDBY_MIN;
00775             }
00776             sys_set_standby_time(standby * 60);
00777         }
00778         else if (standby == -1)
00779         {
00780             sys_set_standby_time(0);
00781         }
00782     }
00783     
00784     gboolean standby_if_plugged = gconf_client_get_bool(g_gconfclient, KEY_POWER_STANDBY_IF_PLUGGED, &error);
00785     if (error)
00786     {
00787         WARNPRINTF("error fetching GConf key %s: %s", KEY_POWER_STANDBY_IF_PLUGGED, error->message);
00788         g_error_free(error);
00789         error = NULL;
00790     }
00791     else
00792     {
00793         sys_set_standby_mode(standby_if_plugged);
00794     }
00795     
00796     gboolean is_flightmode_enabled = gconf_client_get_bool(g_gconfclient, KEY_FLIGHTMODE_MODE, &error);
00797     if (error)
00798     {
00799         WARNPRINTF("error fetching GConf key %s: %s", KEY_FLIGHTMODE_MODE, error->message);
00800         g_error_free(error);
00801         error = NULL;
00802     }
00803     else
00804     {
00805         conn_set_flightmode(is_flightmode_enabled);
00806     }
00807 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void update_installed_locales ( void   )  [static]

Definition at line 810 of file conf.c.

References g_gconfclient, g_number_of_langages, KEY_GLOBAL_LIST_LANGUAGES, KEY_GLOBAL_LIST_LOCALES, KEY_GLOBAL_LOCALE, locales_list_codes(), locales_list_create(), locales_list_free(), locales_list_languages(), LOGPRINTF, and WARNPRINTF.

Referenced by conf_set_services(), and event_gconf_value_changed().

00811 {
00812     GSList *locale_list;
00813     GSList *code_list;
00814     GSList *lang_list;
00815     
00816     // get list of installed locales on system
00817     locale_list = locales_list_create();
00818 
00819     // create lists of only codes and languages
00820     code_list = locales_list_codes(locale_list);
00821     lang_list = locales_list_languages(locale_list);
00822 
00823     // update gconf entries
00824     gconf_client_set_list(g_gconfclient, KEY_GLOBAL_LIST_LOCALES, GCONF_VALUE_STRING, code_list, NULL);
00825     gconf_client_set_list(g_gconfclient, KEY_GLOBAL_LIST_LANGUAGES, GCONF_VALUE_STRING, lang_list, NULL);
00826 
00827     if (g_slist_length(code_list) != g_slist_length(lang_list))
00828     {
00829         WARNPRINTF("Locale code and language lists are not of equal length");
00830     }
00831     
00832     g_number_of_langages = g_slist_length(code_list);
00833         
00834     if (g_number_of_langages == 1)
00835     {
00836         // auto set locale to the only available langage
00837         //
00838         char *new_locale = code_list->data;
00839         char *old_locale = gconf_client_get_string(g_gconfclient, KEY_GLOBAL_LOCALE, NULL);
00840         if ( ((old_locale == NULL) || (strcmp(old_locale, new_locale) != 0)) )
00841         {
00842             LOGPRINTF("Auto set locale to %s (was: %s)", new_locale, old_locale);
00843             gconf_client_set_string(g_gconfclient, KEY_GLOBAL_LOCALE, new_locale, NULL);
00844         }
00845         else
00846         {
00847             LOGPRINTF("Locale already set to %s", new_locale);
00848         }
00849     }
00850 
00851     // free memory
00852     locales_list_free(locale_list);
00853     g_slist_free(code_list);
00854     g_slist_free(lang_list);
00855 }

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

GConfClient* g_gconfclient = NULL [static]
gboolean g_number_of_langages = FALSE [static]

Definition at line 94 of file conf.c.

Referenced by conf_is_multi_language(), and update_installed_locales().

Generated by  doxygen 1.6.2-20100208