system.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  state_device { STATE_DEVICE_UNKNOWN = 0, STATE_DEVICE_STARTING, STATE_DEVICE_STARTED, STATE_DEVICE_STOPPING }
enum  state_card {
  STATE_CARD_UNKNOWN = 0, STATE_CARD_INACCESSIBLE, STATE_CARD_EJECTED, STATE_CARD_UNMOUNTING,
  STATE_CARD_UNMOUNTED, STATE_CARD_INDEXING, STATE_CARD_MOUNTED
}
enum  state_charge {
  STATE_CHARGE_UNKNOWN = 0, STATE_CHARGE_LOW, STATE_CHARGE_CHARGING, STATE_CHARGE_DISCHARGING,
  STATE_CHARGE_FULL
}
enum  state_stylus { STATE_STYLUS_UNKNOWN = 0, STATE_STYLUS_IDLE, STATE_STYLUS_SCRIBBLING }
enum  state_power {
  STATE_POWER_UNKNOWN = 0, STATE_POWER_OFF, STATE_POWER_RUN, STATE_POWER_IDLE,
  STATE_POWER_STANDBY
}
enum  led_color {
  COLOR_OFF = 0, COLOR_BLUE, COLOR_GREEN, COLOR_CYAN,
  COLOR_RED, COLOR_MAGENTA, COLOR_YELLOW, COLOR_WHITE
}
enum  rotate_direction { ROTATE_UNKOWN = 0, ROTATE_CLOCKWISE, ROTATE_ANTICLOCKWISE }
enum  display_orientation { ORIENTATION_PORTRAIT = 0, ORIENTATION_LANDSCAPE_CLOCKWISE, ORIENTATION_LANDSCAPE_ANTICLOCKWISE }
enum  busy_dialog { BUSY_DIALOG_NONE = 0, BUSY_DIALOG_DELAYED, BUSY_DIALOG_DIRECT }

Functions

void sys_set_services (void)
 Initialize the system services. Find micro driver and set up battery level polling.
gboolean sys_get_battery (int *level, enum state_charge *state, int *timeleft)
 Return battery level and charge information.
void sys_get_device_capabilities (gboolean *has_stylus, gboolean *has_wifi, gboolean *has_bluetooth, gboolean *has_3g)
 Return device capabilities.
gboolean sys_set_busy (gboolean is_busy)
 Set the busy state for eg LED indication.
gboolean sys_set_beeper_config (gboolean use_sound)
 Enable/disable audible feedback by applications.
gboolean sys_set_beeper (gint duration_ms, const char *tone)
 Enable/disable audible feedback.
gboolean sys_set_pageturn_inverted (gboolean is_inverted)
 Setup direction to use for the flipbar.
gboolean sys_set_rotate_direction (const char *direction)
 Setup direction to use for rotation. To actually rotate the screen, call sys_set_orientation().
gboolean sys_set_orientation (const char *orientation)
 Change the orientation of the screen. The rotation direction is set by sys_set_rotate_direction().
gboolean sys_set_sensor_feedback (gboolean use_light, gboolean use_sound)
 Enable/disable audible and visual feedback by applications.
gboolean sys_set_sensor_lock_config (gboolean lock_left, gboolean lock_right, gboolean lock_middle)
 Setup which sensor(s) to block when locked. To actually lock the sensors, call sys_set_sensor_lock().
gboolean sys_set_sensor_lock (const char *lock_mode)
 Block the sensor input.
gboolean sys_set_rgb_led (enum led_color color, gint flash_ms)
 Set the main RGB led.
gboolean sys_set_timezone_offset (gint tz_offset_sec)
 Set the offset from UTC time.
void sys_eject_card (gboolean silent)
 Unmount all volumes etc before the SD care can be safely ejected.
void sys_update_battery (const char *battery)
 Update the battery level and state.
void sys_update_hardware (const char *hardware)
 Update the hardware state.
gboolean sys_usb_connect (void)
 Establish USB connection by exporting file system.
void sys_set_card (enum state_card new_state)
void sys_set_idle_mode (gboolean idle_enabled)
void sys_set_standby_time (guint time_sec)
void sys_set_standby_mode (gboolean standby_if_plugged)
void sys_reset_idle_time (void)
void sys_usb_no_connect (void)
void sys_standby (void)
void sys_restart (void)
gboolean sys_request_popup (const char *state)
gboolean sys_set_power (const char *device, gint mode)
gboolean sys_get_power (const char *device, gint *mode)
guint sys_get_orientation (void)
gboolean sys_get_pageturn_inverted (void)
gfloat sys_get_display_vcom (void)
void sys_install_drz (void)
enum state_device sys_get_device_state (void)
enum state_power sys_get_power_state (void)
enum state_card sys_get_card (void)
void sys_set_device_state (enum state_device)
gboolean sys_has_stylus (void)
gboolean sys_has_network (void)
gboolean sys_is_emulator (void)
void sys_update_rgb_led (void)
gboolean sys_spawn_async (const char *command)
gboolean sys_spawn_async_with_callback (const char *command, GChildWatchFunc callback, gpointer data)
gboolean sys_spawn_sync (const char *command)
gboolean sys_is_dr800 (void)
gboolean sys_get_enable_index_splash (void)
void sys_set_enable_index_splash (gboolean value)
gboolean sys_set_index_with_metadata (gboolean value)
gint sys_battery_level (void)
void sys_starting_finished (void)

Enumeration Type Documentation

Enumerator:
BUSY_DIALOG_NONE 
BUSY_DIALOG_DELAYED 
BUSY_DIALOG_DIRECT 

Definition at line 114 of file system.h.

00115 {
00116     BUSY_DIALOG_NONE = 0,
00117     BUSY_DIALOG_DELAYED,
00118     BUSY_DIALOG_DIRECT
00119 };

Enumerator:
ORIENTATION_PORTRAIT 
ORIENTATION_LANDSCAPE_CLOCKWISE 
ORIENTATION_LANDSCAPE_ANTICLOCKWISE 

Definition at line 107 of file system.h.

enum led_color
Enumerator:
COLOR_OFF 
COLOR_BLUE 
COLOR_GREEN 
COLOR_CYAN 
COLOR_RED 
COLOR_MAGENTA 
COLOR_YELLOW 
COLOR_WHITE 

Definition at line 88 of file system.h.

00089 {
00090     COLOR_OFF = 0,  //0
00091     COLOR_BLUE,     //1
00092     COLOR_GREEN,    //2
00093     COLOR_CYAN,     //3
00094     COLOR_RED,      //4
00095     COLOR_MAGENTA,  //5
00096     COLOR_YELLOW,   //6
00097     COLOR_WHITE     //7   
00098 };

Enumerator:
ROTATE_UNKOWN 
ROTATE_CLOCKWISE 
ROTATE_ANTICLOCKWISE 

Definition at line 100 of file system.h.

00101 {
00102     ROTATE_UNKOWN = 0,
00103     ROTATE_CLOCKWISE,
00104     ROTATE_ANTICLOCKWISE
00105 };

enum state_card
Enumerator:
STATE_CARD_UNKNOWN 
STATE_CARD_INACCESSIBLE 
STATE_CARD_EJECTED 
STATE_CARD_UNMOUNTING 
STATE_CARD_UNMOUNTED 
STATE_CARD_INDEXING 
STATE_CARD_MOUNTED 

Definition at line 52 of file system.h.

Enumerator:
STATE_CHARGE_UNKNOWN 
STATE_CHARGE_LOW 
STATE_CHARGE_CHARGING 
STATE_CHARGE_DISCHARGING 
STATE_CHARGE_FULL 

Definition at line 63 of file system.h.

File Name : system.h

Description: System handling functions Copyright (C) 2008 iRex Technologies B.V. All rights reserved.

Enumerator:
STATE_DEVICE_UNKNOWN 
STATE_DEVICE_STARTING 
STATE_DEVICE_STARTED 
STATE_DEVICE_STOPPING 

Definition at line 44 of file system.h.

Enumerator:
STATE_POWER_UNKNOWN 
STATE_POWER_OFF 
STATE_POWER_RUN 
STATE_POWER_IDLE 
STATE_POWER_STANDBY 

Definition at line 79 of file system.h.

00080 {
00081     STATE_POWER_UNKNOWN = 0,
00082     STATE_POWER_OFF,
00083     STATE_POWER_RUN,
00084     STATE_POWER_IDLE,
00085     STATE_POWER_STANDBY
00086 };

Enumerator:
STATE_STYLUS_UNKNOWN 
STATE_STYLUS_IDLE 
STATE_STYLUS_SCRIBBLING 

Definition at line 72 of file system.h.

00073 {
00074     STATE_STYLUS_UNKNOWN = 0,
00075     STATE_STYLUS_IDLE,
00076     STATE_STYLUS_SCRIBBLING
00077 };


Function Documentation

gint sys_battery_level ( void   ) 

Definition at line 886 of file system.c.

References sys_get_battery().

Referenced by conn_connect().

00887 {
00888     int level;
00889     enum state_charge state;
00890 
00891     sys_get_battery(&level, &state, NULL);
00892 
00893     return level;
00894 }

Here is the call graph for this function:

Here is the caller graph for this function:

void sys_eject_card ( gboolean  silent  ) 

Unmount all volumes etc before the SD care can be safely ejected.

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

Name : sys_eject_card

Parameters:
silent [Input] TRUE to suppress dialogs, FALSE otherwise
Returns:
--

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

Definition at line 702 of file system.c.

References do_unmount(), LOGPRINTF, and on_eject_continue().

Referenced by cb_menu_item_activated(), and cb_sys_card_unmount().

00703 {
00704     LOGPRINTF("entry");
00705     do_unmount(!silent, NULL, on_eject_continue, (gpointer) silent);
00706 }

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean sys_get_battery ( int *  level,
enum state_charge state,
int *  timeleft 
)

Return battery level and charge information.

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

Name : sys_get_battery

Parameters:
[out] level Set to current battery charge in percent
[out] state Charge state
[out] timeleft Minutes to emtpy (discharging/low) or -1 (charging/full)
Returns:
TRUE for success, FALSE for failure

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

Definition at line 897 of file system.c.

References get_battery_state(), LOGPRINTF, read_ionkbd, STATE_CHARGE_DISCHARGING, sys_is_emulator(), and WARNPRINTF.

Referenced by cb_sys_get_battery_state(), do_idle(), sys_battery_level(), and sys_set_services().

00898 {
00899     LOGPRINTF("entry");
00900 
00901     gboolean result = FALSE;
00902     gint cur_level = 0;
00903     gint charging  = 0;
00904     gint rc        = 0;
00905     
00906     if (sys_is_emulator())
00907     {
00908         *level = 100;
00909         *state = STATE_CHARGE_DISCHARGING;
00910         return TRUE;
00911     }
00912 
00913     rc = read_ionkbd("battery", "%d %d", &cur_level, &charging);
00914     
00915     if ((rc > 0) && (cur_level != 0xFF))
00916     {
00917         *level    = cur_level;
00918         *state    = get_battery_state(cur_level, charging);
00919         
00920         LOGPRINTF("battery level %d, charging %d", cur_level, charging);
00921         result = TRUE;
00922     }
00923     else
00924     {
00925         WARNPRINTF("Failed to read battery information");
00926     }
00927 
00928     return result;
00929 }

Here is the call graph for this function:

Here is the caller graph for this function:

enum state_card sys_get_card ( void   ) 

Definition at line 1366 of file system.c.

References card_state.

Referenced by cb_sys_get_card_mountpoint(), hal_device_removed(), on_process_exit(), and post_process_startup().

01367 {
01368     return card_state;    
01369 }

Here is the caller graph for this function:

void sys_get_device_capabilities ( gboolean *  has_stylus,
gboolean *  has_wifi,
gboolean *  has_bluetooth,
gboolean *  has_3g 
)

Return device capabilities.

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

Name : sys_get_device_capabilities

Parameters:
has_stylus 
has_wifi 
has_bluetooth 
has_3g 
Returns:
--

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

Definition at line 1163 of file system.c.

References data, LOGPRINTF, read_sysset, and sys_is_emulator().

Referenced by cb_sys_get_device_capabilities(), sys_has_network(), and sys_has_stylus().

01164 {
01165     LOGPRINTF("entry");
01166 
01167     gboolean found_stylus    = FALSE;
01168     gboolean found_wifi      = FALSE;
01169     gboolean found_bluetooth = FALSE;
01170     gboolean found_3g        = FALSE;
01171     char data[64];
01172     
01173     bzero(data, sizeof(data));
01174     read_sysset("wacom/serial", "%s", &data);
01175     if ((data[0] != '\0') && (data[0] != '\xFF')) 
01176     {
01177         LOGPRINTF("data %s", data);
01178         if ((strlen(data) > 0) && (strtoul(data,NULL,16) != 0))
01179         {
01180             found_stylus = TRUE;
01181         }
01182     }
01183 
01184     bzero(data, sizeof(data));
01185     read_sysset("wifi/address", "%s", &data);
01186     if ((data[0] != '\0') && (data[0] != '\xFF')) 
01187     {
01188         if (strlen(data) > 0)
01189         {
01190             found_wifi = TRUE;
01191         }
01192     }
01193 
01194     bzero(data, sizeof(data));
01195     read_sysset("bluetooth/address", "%s", &data);
01196     if ((data[0] != '\0') && (data[0] != '\xFF')) 
01197     {
01198         if (strlen(data) > 0)
01199         {
01200             found_bluetooth = TRUE;
01201         }
01202     }
01203 
01204     bzero(data, sizeof(data));
01205     read_sysset("3g/imei", "%s", &data);
01206     if ((data[0] != '\0') && (data[0] != '\xFF')) 
01207     {
01208         if (strlen(data) > 0)
01209         {
01210             found_3g = TRUE;
01211         }
01212     }
01213     
01214     bzero(data, sizeof(data));
01215     read_sysset("3g/meid", "%s", &data);
01216     if ((data[0] != '\0') && (data[0] != '\xFF')) 
01217     {
01218         if (strlen(data) > 0)
01219         {
01220             found_3g = TRUE;
01221         }
01222     }
01223     
01224     if (sys_is_emulator())
01225     {
01226         found_stylus = TRUE;
01227         found_3g     = TRUE;
01228     }
01229 
01230     LOGPRINTF("capabilities from sysset: wacom %d, wifi %d, bluetooth %d, 3g %d", found_stylus, found_wifi, found_bluetooth, found_3g);
01231         
01232     *has_stylus    = found_stylus;
01233     *has_wifi      = found_wifi;
01234     *has_bluetooth = found_bluetooth;
01235     *has_3g        = found_3g;
01236 }

Here is the call graph for this function:

Here is the caller graph for this function:

enum state_device sys_get_device_state ( void   ) 

Definition at line 1497 of file system.c.

References device_state, and LOGPRINTF.

Referenced by check_respawn(), check_start_next(), and process_activate_ctb().

01498 {
01499 #if (LOGGING_ON)
01500         const gchar *state_str[] = { "UKNOWN", "STARTING", "STARTED", "STOPPING" };
01501         LOGPRINTF("device_state [%s]", state_str[device_state]);
01502 #endif        
01503     return device_state;
01504 }

Here is the caller graph for this function:

gfloat sys_get_display_vcom ( void   ) 

Definition at line 946 of file system.c.

References LOGPRINTF, and read_sysset.

Referenced by display_update().

00947 {
00948     LOGPRINTF("entry");
00949     gfloat vcom;
00950 
00951     read_sysset("display/vcom", "%f", &vcom);
00952 
00953     return vcom;
00954 }

Here is the caller graph for this function:

gboolean sys_get_enable_index_splash ( void   ) 

Definition at line 1570 of file system.c.

References g_index_splash_enabled.

01571 {
01572     return g_index_splash_enabled;
01573 }

guint sys_get_orientation ( void   ) 

Definition at line 1437 of file system.c.

References g_orientation.

Referenced by cb_sys_get_orientation(), and parse_gtk_message().

01438 {
01439     return g_orientation;
01440 }

Here is the caller graph for this function:

gboolean sys_get_pageturn_inverted ( void   ) 

Definition at line 1443 of file system.c.

References g_pageturn_inverted.

Referenced by cb_sys_get_pageturn_inverted().

01444 {
01445     return g_pageturn_inverted; 
01446 }

Here is the caller graph for this function:

gboolean sys_get_power ( const char *  device,
gint *  mode 
)

Definition at line 1426 of file system.c.

References LOGPRINTF, and read_power.

01427 {
01428     LOGPRINTF("entry");
01429     
01430     gboolean retval = FALSE;
01431     retval = read_power(device, "%d", &mode);
01432     
01433     return retval;
01434 }

enum state_power sys_get_power_state ( void   ) 

Definition at line 1507 of file system.c.

References power_state.

Referenced by gtk_messages().

01508 {
01509 #if (LOGGING_ON)
01510 //        const gchar *state_str[] = { "UKNOWN",  "OFF", "RUN", "IDLE", "STANDBY" };
01511 //        LOGPRINTF("power_state [%s]", state_str[power_state]);
01512 #endif        
01513     return power_state;
01514 }

Here is the caller graph for this function:

gboolean sys_has_network ( void   ) 

Definition at line 1114 of file system.c.

References sys_get_device_capabilities().

Referenced by cb_open_url().

01115 {
01116     gboolean ignore          = FALSE;
01117     gboolean found_wifi      = FALSE;
01118     gboolean found_bluetooth = FALSE;
01119     gboolean found_3g        = FALSE;
01120     
01121     sys_get_device_capabilities(&ignore, &found_wifi, &found_bluetooth, &found_3g);
01122     
01123     return (found_wifi || found_bluetooth || found_3g);
01124 }

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean sys_has_stylus ( void   ) 

Definition at line 1127 of file system.c.

References sys_get_device_capabilities().

Referenced by start_phase_2().

01128 {
01129     gboolean found_stylus    = FALSE;
01130     gboolean ignore          = FALSE;
01131     
01132     sys_get_device_capabilities(&found_stylus, &ignore, &ignore, &ignore);
01133     
01134     return (found_stylus);
01135 }

Here is the call graph for this function:

Here is the caller graph for this function:

void sys_install_drz ( void   ) 

Definition at line 1456 of file system.c.

References DRZ_PATH, DRZINSTALL_TOOL, on_install_drz_ready(), and sys_spawn_async_with_callback().

Referenced by check_and_install_drz(), and on_confirm_install_drz().

01457 {
01458     // NOTE installation of AdobeID account requires network connections (IPC) so
01459     //      this must be called asynchronous
01460     gchar *command = g_strdup_printf(DRZINSTALL_TOOL" -s %s", DRZ_PATH);
01461     sys_spawn_async_with_callback(command, on_install_drz_ready, NULL);
01462     g_free(command);
01463     return;
01464 }

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean sys_is_dr800 ( void   ) 

Definition at line 1138 of file system.c.

References read_ionkbd.

01139 {
01140     int type = 0;
01141     int rc = read_ionkbd("device_type", "%d", &type);
01142     if ((rc > 0) && ((type == 3) || (type == 4) || (type == 5)))
01143     {
01144         return TRUE;
01145     }
01146     
01147     return FALSE;
01148 }

gboolean sys_is_emulator ( void   ) 

Definition at line 1151 of file system.c.

Referenced by conn_connect(), conn_disconnect(), on_phase_1_complete(), start_phase_2(), sys_get_battery(), sys_get_device_capabilities(), sys_set_idle_mode(), sys_set_services(), and volume_is_mounted().

01152 {
01153     char hostname[100] = {0};
01154     int rc = gethostname(hostname, sizeof(hostname));
01155     if ((rc == 0) && (strcmp(hostname, "qemuarm") == 0))
01156     {
01157         return TRUE;
01158     }
01159     return FALSE;
01160 }

Here is the caller graph for this function:

gboolean sys_request_popup ( const char *  state  ) 

Definition at line 1382 of file system.c.

References g_popup_enabled, and ipc_show_popup().

Referenced by cb_menu_request_popup(), on_phase_2_complete(), and start_phase_2().

01383 {
01384     g_return_val_if_fail(state!=NULL, FALSE);
01385     
01386     if (strcmp(state, "localblock") == 0)
01387     {
01388         g_popup_enabled = FALSE;
01389     }
01390     else if (strcmp(state, "block") == 0)
01391     {
01392         g_popup_enabled = FALSE;
01393         ipc_show_popup(state);
01394     }
01395     else if (strcmp(state, "localunblock") == 0)
01396     {
01397         g_popup_enabled = TRUE;
01398     }
01399     else if (strcmp(state, "unblock") == 0)
01400     {
01401         g_popup_enabled = TRUE;
01402         ipc_show_popup(state);
01403     }
01404     else if (g_popup_enabled)
01405     {
01406         ipc_show_popup(state);
01407     }
01408     return TRUE;
01409 }

Here is the call graph for this function:

Here is the caller graph for this function:

void sys_reset_idle_time ( void   ) 

Definition at line 363 of file system.c.

References set_idle_time().

Referenced by display_update(), do_idle(), hal_device_property_modified(), ipc_show_splash(), sys_set_idle_mode(), sys_update_hardware(), udi_mount_volume(), update(), and volume_is_mounted().

00364 {
00365     set_idle_time(0);
00366 }

Here is the call graph for this function:

Here is the caller graph for this function:

void sys_restart ( void   ) 

Definition at line 745 of file system.c.

References busy_add_foreground(), BUSY_DIALOG_NONE, device_state, do_unmount(), LOGPRINTF, on_restart_continue(), and STATE_DEVICE_STOPPING.

Referenced by on_confirm_install_update(), and sys_check_and_install_firmware().

00746 {
00747     LOGPRINTF("entry");
00748     
00749     device_state = STATE_DEVICE_STOPPING;
00750     busy_add_foreground(0, BUSY_DIALOG_NONE, NULL);
00751     do_unmount(TRUE, "restart", on_restart_continue, NULL);
00752 }

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean sys_set_beeper ( gint  duration_ms,
const char *  tone 
)

Enable/disable audible feedback.

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

Name : sys_set_beeper_config

Parameters:
duration_ms Length of tone in ms (use intervals of 10ms)
tone Beep tone "high" or "low"
Returns:
TRUE for success, FALSE for failure

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

Definition at line 378 of file system.c.

References buffer, g_sound_enabled, LOGPRINTF, WARNPRINTF, and write_ionkbd.

Referenced by cb_sys_beep().

00379 {
00380     LOGPRINTF("entry");
00381     
00382     gboolean retval = FALSE;
00383     char *buffer    = NULL;
00384     gint beep_pitch = -1;
00385     
00386     if (!g_sound_enabled)
00387     {
00388         return FALSE;
00389     }
00390     
00391     if (g_ascii_strcasecmp(tone, "high") == 0)
00392     {
00393         beep_pitch = 1;
00394     }
00395     else if (g_ascii_strcasecmp(tone, "low") == 0)
00396     {
00397         beep_pitch = 0;
00398     }
00399     else
00400     {
00401         WARNPRINTF("Unknown tone: %s", tone);
00402     }
00403 
00404     if (beep_pitch != -1)
00405     {
00406         // Bits 0..6 are length of time to play tone (in units of 10ms)
00407         // Bit 7 sets high/low tone
00408         buffer = g_strdup_printf("%d", ((duration_ms / 10) & 0xEF) | ((beep_pitch & 0x01) << 7));
00409         retval = write_ionkbd("beeper", buffer);
00410         g_free(buffer);
00411     }
00412    
00413     return retval;
00414 }

Here is the caller graph for this function:

gboolean sys_set_beeper_config ( gboolean  use_sound  ) 

Enable/disable audible feedback by applications.

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

Name : sys_set_beeper_config

Parameters:
use_sound TRUE for beeps, FALSE to mute
Returns:
TRUE for success, FALSE for failure

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

Definition at line 369 of file system.c.

References g_sound_enabled, and LOGPRINTF.

00370 {
00371     LOGPRINTF("entry");
00372     
00373     g_sound_enabled = use_sound;
00374     return TRUE;
00375 }

gboolean sys_set_busy ( gboolean  is_busy  ) 

Set the busy state for eg LED indication.

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

Name : sys_set_busy

Parameters:
is_busy TRUE for busy, FALSE otherwise
Returns:
TRUE for success, FALSE for failure

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

void sys_set_card ( enum state_card  new_state  ) 

Definition at line 1302 of file system.c.

References ADOBE_SYNC, busy_add_foreground(), BUSY_DIALOG_NONE, card_state, ERCONFTOOL_DELETE, ERCONFTOOL_IMPORT, g_card_device, g_index_splash_enabled, g_index_with_metadata, hal_get_mountpoint_device(), ipc_send_volume_mounted(), ipc_show_splash(), LOGPRINTF, MDB_INDEXER, MOUNTPOINT_CARD, on_card_indexed(), STATE_CARD_EJECTED, STATE_CARD_INACCESSIBLE, STATE_CARD_INDEXING, STATE_CARD_MOUNTED, STATE_CARD_UNMOUNTED, STATE_USB_DISCONNECTED, STATE_USB_UNMOUNTED, sys_spawn_async(), sys_spawn_async_with_callback(), sys_spawn_sync(), usb_set_state(), and usb_state.

Referenced by hal_device_property_modified(), hal_device_removed(), on_card_indexed(), and volume_is_mounted().

01303 {
01304 #if (LOGGING_ON)
01305     const gchar *state_str[] = { "UKNOWN", "INACCESSIBLE", "EJECTED", "UNMOUNTING", "UNMOUNTED", "INDEXING", "MOUNTED" };
01306     LOGPRINTF("prepare card_state %s > %s", state_str[card_state], state_str[new_state]);
01307 #endif        
01308     
01309     switch (new_state)
01310     {
01311     case STATE_CARD_EJECTED:
01312         ipc_show_splash("nosd");
01313 
01314         // delete private settings from registry
01315         sys_spawn_async(ERCONFTOOL_DELETE);
01316     
01317         if (   (usb_state != STATE_USB_DISCONNECTED)
01318             && (usb_state != STATE_USB_UNMOUNTED) )
01319         {
01320             // set new state before unmounting USB
01321             LOGPRINTF("change card_state %s > %s", state_str[card_state], state_str[new_state]);
01322             card_state = new_state;
01323             usb_set_state(STATE_USB_UNMOUNTED);
01324         }
01325         break;
01326         
01327     case STATE_CARD_INDEXING:
01328     {
01329         busy_add_foreground(0, BUSY_DIALOG_NONE, NULL);
01330         if (g_index_splash_enabled)
01331         {
01332             ipc_show_splash("indexing");
01333         }
01334         sys_spawn_sync(ERCONFTOOL_IMPORT);
01335         
01336         // synchronize with Adobe Digital Editions
01337         sys_spawn_sync(ADOBE_SYNC);
01338         
01339         gchar *command = g_strdup_printf("%s %s %s", 
01340                                          MDB_INDEXER,
01341                                          MOUNTPOINT_CARD,
01342                                          g_index_with_metadata ? "" : "--quick");
01343         sys_spawn_async_with_callback(command, on_card_indexed, (gpointer) FALSE);
01344         g_free(command);
01345         // busy is reset by "on_card_indexed" callback
01346     }
01347     break;
01348 
01349     case STATE_CARD_MOUNTED:
01350         ipc_send_volume_mounted(MOUNTPOINT_CARD);
01351         g_card_device = hal_get_mountpoint_device();
01352         break;
01353     
01354     case STATE_CARD_INACCESSIBLE:
01355     case STATE_CARD_UNMOUNTED:
01356     default:
01357         break;
01358     }
01359 
01360     LOGPRINTF("change card_state %s > %s", state_str[card_state], state_str[new_state]);
01361     
01362     card_state = new_state;
01363 }

Here is the call graph for this function:

Here is the caller graph for this function:

void sys_set_device_state ( enum  state_device  ) 

Definition at line 1517 of file system.c.

References device_state, and LOGPRINTF.

Referenced by on_phase_2_complete().

01518 {
01519     LOGPRINTF("entry, new state: %d", new_state);
01520 
01521     device_state = new_state;
01522 }

Here is the caller graph for this function:

void sys_set_enable_index_splash ( gboolean  value  ) 

Definition at line 1576 of file system.c.

References g_index_splash_enabled.

Referenced by cb_sys_card_mount().

01577 {
01578     g_index_splash_enabled = value; 
01579 }

Here is the caller graph for this function:

void sys_set_idle_mode ( gboolean  idle_enabled  ) 

Definition at line 317 of file system.c.

References g_idle_enabled, g_idle_time_source, g_version_micro, sys_is_emulator(), and sys_reset_idle_time().

Referenced by event_gconf_value_changed(), and set_startup_defaults().

00318 {
00319 #if MACHINE_IS_DR1000S || MACHINE_IS_DR1000SW    
00320     if (g_version_micro < 0.34f)
00321     {
00322         g_idle_enabled = FALSE;
00323     }
00324     else
00325 #endif    
00326     if (sys_is_emulator())
00327     {
00328         g_idle_enabled = FALSE;
00329     }
00330     else
00331     {
00332         g_idle_enabled = idle_enabled;
00333     }
00334     
00335     if (g_idle_enabled)
00336     {
00337         // start idle timer
00338         sys_reset_idle_time();
00339     }
00340     else
00341     {
00342         if (g_idle_time_source)
00343         {
00344             g_source_remove(g_idle_time_source);
00345             g_idle_time_source = 0;
00346         }
00347     }
00348 }

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean sys_set_index_with_metadata ( gboolean  value  ) 

Definition at line 441 of file system.c.

References g_index_with_metadata, and LOGPRINTF.

Referenced by event_gconf_value_changed(), and set_startup_defaults().

00442 {
00443     LOGPRINTF("entry");
00444 
00445     g_index_with_metadata = with_metadata;
00446     
00447     return TRUE;
00448 }

Here is the caller graph for this function:

gboolean sys_set_orientation ( const char *  orientation  ) 

Change the orientation of the screen. The rotation direction is set by sys_set_rotate_direction().

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

Name : sys_set_orientation

Parameters:
orientation Set to "portrait", "landscape" or "toggle"
Returns:
TRUE for success, FALSE for failure

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

Definition at line 497 of file system.c.

References display_gain_control(), g_orientation, g_rotate_direction, LOGPRINTF, on_rotated(), ORIENTATION_LANDSCAPE_ANTICLOCKWISE, ORIENTATION_LANDSCAPE_CLOCKWISE, ORIENTATION_PORTRAIT, ROTATE_CLOCKWISE, sys_spawn_sync(), and WARNPRINTF.

Referenced by cb_menu_item_activated(), and cb_sys_rotate().

00498 {
00499     LOGPRINTF("entry");
00500     
00501     g_return_val_if_fail(orientation!=NULL, FALSE);
00502 
00503     static gboolean is_portrait = TRUE;
00504     gboolean retval = FALSE;
00505     gboolean is_changed = FALSE;
00506   
00507     if (g_ascii_strcasecmp(orientation, "portrait") == 0)
00508     {
00509         if (!is_portrait)
00510         {
00511             is_portrait = TRUE;
00512             is_changed = TRUE;
00513         }
00514     }
00515     else if (g_ascii_strcasecmp(orientation, "landscape") == 0)
00516     {
00517         if (is_portrait)
00518         {
00519             is_portrait = FALSE;
00520             is_changed = TRUE;
00521         }
00522     }
00523     else if (g_ascii_strcasecmp(orientation, "toggle") == 0)
00524     {
00525         is_portrait = !is_portrait;
00526         is_changed = TRUE;
00527     }
00528     else 
00529     {
00530         WARNPRINTF("Unknown orientation: %s", orientation);
00531     }
00532     
00533     if (is_changed)
00534     {
00535         display_gain_control();
00536 
00537         if (is_portrait)
00538         {
00539             // rotate screen (xrandr)
00540             sys_spawn_sync("xrandr -display 0:0 --screen 0 --orientation normal");
00541             g_orientation = ORIENTATION_PORTRAIT;
00542         }
00543         else  
00544         {
00545             /*
00546              *  GConf Setting:
00547              *  +----------+--------------+--------------+
00548              *  | Portrait | LH Landscape | RH Landscape |
00549              *  +----------+--------------+--------------+
00550              *  | normal   | clockwise    | anticlockwise|
00551              *  +----------+--------------+--------------+
00552              *  
00553              *  Sensor Layouts:
00554              *  +----------+--------------+--------------+
00555              *  | Portrait | LH Landscape | RH Landscape |
00556              *  +----------+--------------+--------------+
00557              *  | 1     5  |      5A1     |     5B1      |
00558              *  | A     B  |    1         |         5    |
00559              *  | 5     1  |    C         |         C    |
00560              *  |   1C5    |    5         |         1    |
00561              *  |          |      1B5     |     1A5      |
00562              *  +----------+--------------+--------------+
00563              * 
00564              *  Xrandr Orientation:
00565              *  +----------+--------------+--------------+
00566              *  | Portrait | LH Landscape | RH Landscape |
00567              *  +----------+--------------+--------------+
00568              *  | normal   | left         | right        |
00569              *  +----------+--------------+--------------+
00570              */ 
00571 
00572             if (g_rotate_direction == ROTATE_CLOCKWISE)
00573             {
00574                 // rotate screen (xrandr)
00575                 sys_spawn_sync("xrandr -display 0:0 --screen 0 --orientation left");
00576                 g_orientation = ORIENTATION_LANDSCAPE_CLOCKWISE;
00577             }
00578             else
00579             {
00580                 // rotate screen (xrandr)
00581                 sys_spawn_sync("xrandr -display 0:0 --screen 0 --orientation right");
00582                 g_orientation = ORIENTATION_LANDSCAPE_ANTICLOCKWISE;
00583             }
00584         }
00585         
00586         // wait time to allow rotation
00587         g_timeout_add(800, (GSourceFunc)on_rotated, NULL);
00588     }
00589 
00590     return retval;
00591 }

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean sys_set_pageturn_inverted ( gboolean  is_inverted  ) 

Setup direction to use for the flipbar.

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

Name : sys_set_pageturn_inverted

Parameters:
is_pageturn_inverted TRUE or FALSE
Returns:
TRUE for success, FALSE for failure

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

Definition at line 450 of file system.c.

References g_pageturn_inverted, ipc_send_changed_pageturn_inverted(), and LOGPRINTF.

Referenced by event_gconf_value_changed(), set_startup_defaults(), start_demo_mode(), and stop_demo_mode().

00451 {
00452     LOGPRINTF("entry");
00453 
00454     g_pageturn_inverted = is_inverted;
00455     
00456     ipc_send_changed_pageturn_inverted(g_pageturn_inverted);
00457 
00458     return TRUE;
00459 }

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean sys_set_power ( const char *  device,
gint  mode 
)

Definition at line 1412 of file system.c.

References LOGPRINTF, and write_power.

Referenced by wacom_disable(), wacom_enable(), and wacom_reset().

01413 {
01414     LOGPRINTF("entry");
01415     
01416     gboolean retval = FALSE;
01417     
01418     gchar *modestr = g_strdup_printf("%d", mode);
01419     retval = write_power(device, modestr);
01420     g_free(modestr);
01421     
01422     return retval;
01423 }

Here is the caller graph for this function:

gboolean sys_set_rgb_led ( enum led_color  color,
gint  flash_ms 
)

Set the main RGB led.

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

Name : sys_set_rgb_led

Parameters:
color Color value
flash_ms Length of flash duration in ms (with intervals of 500ms)

LED color values: 0: off 4: red 1: blue 5: magenta 2: green 6: yellow 3: cyan 7: white

Returns:
TRUE for success, FALSE for failure

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

Definition at line 417 of file system.c.

References buffer, LOGPRINTF, and write_ionkbd.

Referenced by sys_update_rgb_led().

00418 {
00419     LOGPRINTF("entry");
00420     
00421     gboolean retval  = FALSE;
00422     gchar    *buffer = NULL;
00423     
00424     // LED Color values:
00425     // 0: off  4: red
00426     // 1: blue 5: magenta
00427     // 2: green   6: yellow
00428     // 3: cyan 7: white
00429     
00430     // Value 1: LED Color [0..7]
00431     // Value 2: LED Flash rate (in units of 500ms)
00432 
00433     buffer = g_strdup_printf("%d %d", (color & 0xFF), (flash_ms / 500) & 0xFF);
00434     retval = write_ionkbd("rgbled", buffer);
00435     g_free(buffer);
00436     
00437     return retval;
00438 }

Here is the caller graph for this function:

gboolean sys_set_rotate_direction ( const char *  direction  ) 

Setup direction to use for rotation. To actually rotate the screen, call sys_set_orientation().

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

Name : sys_set_rotate_direction

Parameters:
direction Rotate "clockwise" or "anticlockwise"
Returns:
TRUE for success, FALSE for failure

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

Definition at line 462 of file system.c.

References g_rotate_direction, LOGPRINTF, ROTATE_ANTICLOCKWISE, and ROTATE_CLOCKWISE.

Referenced by event_gconf_value_changed(), and set_startup_defaults().

00463 {
00464     LOGPRINTF("entry");
00465     
00466     g_return_val_if_fail(direction!=NULL, FALSE);
00467     
00468     if (strcmp(direction, "clockwise") == 0)
00469     {
00470         g_rotate_direction = ROTATE_CLOCKWISE;    
00471     }
00472     else
00473     {
00474         g_rotate_direction = ROTATE_ANTICLOCKWISE;    
00475     }        
00476     
00477     return TRUE;
00478 }

Here is the caller graph for this function:

gboolean sys_set_sensor_feedback ( gboolean  use_light,
gboolean  use_sound 
)

Enable/disable audible and visual feedback by applications.

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

Name : sys_set_sensor_feedback

Parameters:
use_light TRUE to flash on sensor presses, FALSE to mute
use_sound TRUE to beep on sensor presses, FALSE to mute
Returns:
TRUE for success, FALSE for failure

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

Definition at line 594 of file system.c.

References buffer, LOGPRINTF, and write_ionkbd.

Referenced by event_gconf_value_changed(), and set_startup_defaults().

00595 {
00596     LOGPRINTF("entry");
00597     
00598     gboolean retval = FALSE;
00599     char *buffer    = NULL;
00600     
00601     // Value 1: bit 0 - buzzer enable, bit 1 - LED enable
00602 
00603     buffer = g_strdup_printf("%d", use_sound | (use_light << 1));
00604     retval = write_ionkbd("sensor_feedback", buffer);
00605     
00606     g_free(buffer);
00607     return retval;
00608 }

Here is the caller graph for this function:

gboolean sys_set_sensor_lock ( const char *  lock_mode  ) 

Block the sensor input.

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

Name : sys_set_sensor_lock

Parameters:
lock_mode Set to "lock", "unlock" or "toggle"
Returns:
TRUE for success, FALSE for failure

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

Definition at line 627 of file system.c.

References g_sensor_disable_config, g_sensor_locked, ipc_menu_set_item_state(), ipc_menu_set_statusitem_state(), LOGPRINTF, WARNPRINTF, and write_ionkbd.

Referenced by cb_menu_item_activated(), cb_sys_lock_sensors(), and sys_set_sensor_lock_config().

00628 {
00629     LOGPRINTF("entry");
00630     
00631     g_return_val_if_fail(lock_mode!=NULL, FALSE);
00632     
00633     gboolean retval = FALSE;
00634     gboolean is_changed = FALSE;
00635     
00636     if (g_ascii_strcasecmp(lock_mode, "lock") == 0)
00637     {
00638         if (!g_sensor_locked)
00639         {
00640             g_sensor_locked  = TRUE;
00641             is_changed = TRUE;
00642         }
00643     }
00644     else if (g_ascii_strcasecmp(lock_mode, "unlock") == 0)
00645     {
00646         if (g_sensor_locked)
00647         {
00648             g_sensor_locked  = FALSE;
00649             is_changed = TRUE;
00650         }
00651     }
00652     else if (g_ascii_strcasecmp(lock_mode, "toggle") == 0)
00653     {
00654         g_sensor_locked  = !g_sensor_locked;
00655         is_changed = TRUE;
00656     }
00657     else if (g_ascii_strcasecmp(lock_mode, "update") == 0)
00658     {
00659         if (g_sensor_locked)
00660         {
00661             is_changed = TRUE;
00662         }
00663         
00664         if (g_sensor_disable_config == 7)
00665         {
00666             g_sensor_locked = FALSE;
00667         }
00668     }
00669     else
00670     {
00671         WARNPRINTF("Unknown lock mode: %s", lock_mode);
00672     }
00673   
00674     if (is_changed)
00675     {
00676         if (g_sensor_locked)
00677         {
00678             // inform ionkbd
00679             char *lock_config = g_strdup_printf("%d", g_sensor_disable_config);
00680             write_ionkbd("sensor_enable", lock_config);
00681             g_free(lock_config);
00682             
00683             // update menu and statusbar item
00684             ipc_menu_set_item_state("lock", "general", "selected");
00685             ipc_menu_set_statusitem_state("statusbar_lock", "locked");
00686         }
00687         else
00688         {
00689             // inform ionkbd
00690             write_ionkbd("sensor_enable", "7"); // enable all three sensors
00691 
00692             // update menu and statusbar item
00693             ipc_menu_set_item_state("lock", "general", "normal");
00694             ipc_menu_set_statusitem_state("statusbar_lock", "normal");
00695         }
00696     }
00697 
00698     return retval;
00699 }

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean sys_set_sensor_lock_config ( gboolean  lock_left,
gboolean  lock_right,
gboolean  lock_middle 
)

Setup which sensor(s) to block when locked. To actually lock the sensors, call sys_set_sensor_lock().

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

Name : sys_set_sensor_lock_config

Parameters:
lock_left TRUE to lock sensor, FALSE to keep unlocked
lock_right TRUE to lock sensor, FALSE to keep unlocked
lock_middle TRUE to lock sensor, FALSE to keep unlocked
Returns:
TRUE for success, FALSE for failure

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

Definition at line 611 of file system.c.

References g_sensor_disable_config, LOGPRINTF, and sys_set_sensor_lock().

Referenced by event_gconf_value_changed(), and set_startup_defaults().

00612 {
00613     LOGPRINTF("entry");
00614     
00615     // NOTE: the micro has a sensor_enable setting so we invert the 
00616     //       lock to enable logic here
00617     // NOTE: left appears to be Sensor B, right is Sensor A
00618     g_sensor_disable_config = !lock_right | (!lock_left << 1) | (!lock_middle << 2);
00619 
00620     // if lock is currently active, make new config effective
00621     sys_set_sensor_lock("update");
00622     
00623     return TRUE;
00624 }

Here is the call graph for this function:

Here is the caller graph for this function:

void sys_set_services ( void   ) 

Initialize the system services. Find micro driver and set up battery level polling.

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

Name : sys_set_services

Parameters:
-- 
Returns:
--

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

Definition at line 230 of file system.c.

References BATTERY_LOW_THRESHOLD, charge_state, ERRORPRINTF, find_dir(), g_battery_level, g_idle_enabled, g_idle_time_source, g_power, g_serio, g_sysset, g_version_micro, IDLE_TIMEOUT_SEC, LOGPRINTF, micro_device_name, on_idle_timeout(), power_device_name, read_ionkbd, sys_devices, sys_get_battery(), sys_is_emulator(), sys_update_rgb_led(), sysset_device_name, and write_ionkbd_battery_alerts().

Referenced by main().

00231 {
00232     LOGPRINTF("entry");
00233     
00234     // find sysset partition
00235     //
00236     g_sysset = find_dir(sys_devices, sysset_device_name, TRUE);
00237     if (!g_sysset) 
00238     {
00239         ERRORPRINTF("%s not found or not unique", sysset_device_name);
00240     }
00241     else
00242     {
00243         LOGPRINTF("Sysset found at %s", g_sysset);
00244     }
00245 
00246     // find power
00247     //
00248     g_power = find_dir(sys_devices, power_device_name, TRUE);
00249     if (!g_power) 
00250     {
00251         ERRORPRINTF("%s not found or not unique", power_device_name);
00252     }
00253     else
00254     {
00255         LOGPRINTF("Ionpower found at %s", g_power);
00256     }
00257     
00258     // find micro driver
00259     //
00260     g_serio = find_dir(sys_devices, micro_device_name, FALSE);
00261     if (!g_serio) 
00262     {
00263         ERRORPRINTF("%s not found or not unique", micro_device_name);
00264     }
00265     else 
00266     {
00267         LOGPRINTF("Device micro found as %s", g_serio);
00268         
00269         read_ionkbd("micro_ver", "%f", &g_version_micro);
00270         LOGPRINTF("Micro version %.2f", g_version_micro);
00271         
00272         // set battery alert levels
00273         write_ionkbd_battery_alerts(BATTERY_LOW_THRESHOLD, 13, 38, 63, 88);
00274 
00275         // check battery state at startup
00276         sys_get_battery(&g_battery_level, &charge_state, NULL);
00277         
00278         // update led for battery state
00279         sys_update_rgb_led();
00280     }
00281 
00282     // set idle
00283 #if MACHINE_IS_DR1000S || MACHINE_IS_DR1000SW
00284     if (g_version_micro < 0.34f)
00285     {
00286         g_idle_enabled = FALSE;
00287     }
00288 #endif    
00289     if (sys_is_emulator())
00290     {
00291         g_idle_enabled = FALSE;
00292     }
00293     
00294     if (g_idle_enabled) 
00295     {
00296         g_idle_time_source = g_timeout_add_seconds(IDLE_TIMEOUT_SEC, on_idle_timeout, NULL);
00297     }
00298 }

Here is the call graph for this function:

Here is the caller graph for this function:

void sys_set_standby_mode ( gboolean  standby_if_plugged  ) 

Definition at line 357 of file system.c.

References g_standby_if_plugged.

Referenced by event_gconf_value_changed(), and set_startup_defaults().

00358 {
00359     g_standby_if_plugged = standby_if_plugged;
00360 }

Here is the caller graph for this function:

void sys_set_standby_time ( guint  time_sec  ) 

Definition at line 351 of file system.c.

References g_standby_timeout_sec.

Referenced by event_gconf_value_changed(), and set_startup_defaults().

00352 {
00353     g_standby_timeout_sec = time_sec;
00354 }

Here is the caller graph for this function:

gboolean sys_set_timezone_offset ( gint  tz_offset_sec  ) 

Set the offset from UTC time.

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

Name : sys_set_timezone_offset

Parameters:
tz_offset_sec Offset from UTC in seconds East of Greenwich
Returns:
TRUE for success, FALSE for failure

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

gboolean sys_spawn_async ( const char *  command  ) 

Definition at line 805 of file system.c.

References LOGPRINTF, and sys_spawn_async_with_callback().

Referenced by hal_device_property_modified(), hal_device_removed(), sys_set_card(), and udi_mount_volume().

00806 {
00807     LOGPRINTF("entry");
00808     return sys_spawn_async_with_callback(command, NULL, NULL);
00809 }

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean sys_spawn_async_with_callback ( const char *  command,
GChildWatchFunc  callback,
gpointer  data 
)

Definition at line 812 of file system.c.

References LOGPRINTF, and WARNPRINTF.

Referenced by conn_on_leave_standby(), sys_install_drz(), sys_set_card(), sys_spawn_async(), and unmount_volume().

00813 {
00814     LOGPRINTF("entry");
00815 
00816     g_return_val_if_fail(command!=NULL, FALSE);
00817 
00818     char *argv[4];
00819     gboolean retval = FALSE;
00820     GError *error = NULL;
00821     GPid child_pid;
00822 
00823     argv[0] = "/bin/sh";
00824     argv[1] = "-c";
00825     argv[2] = (char*) command;
00826     argv[3] = NULL;
00827 
00828     LOGPRINTF("Spawning: %s", argv[2]);
00829     
00830     if (callback)
00831     {
00832         retval = g_spawn_async(NULL, argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &child_pid, &error);
00833     }
00834     else
00835     {
00836         retval = g_spawn_async(NULL, argv, NULL, 0, NULL, NULL, NULL, &error);
00837     }        
00838     
00839     if (error)
00840     {
00841         WARNPRINTF("Execution of '%s' failed with error: %s", command, error->message);
00842         g_error_free(error);
00843         return FALSE;
00844     }
00845 
00846     if (retval && callback)
00847     {
00848         LOGPRINTF("Add callback handler for pid [%d]", (gint) child_pid);
00849         g_child_watch_add(child_pid, (GChildWatchFunc) callback, data);
00850     }
00851     
00852     return retval;
00853 }

Here is the caller graph for this function:

gboolean sys_spawn_sync ( const char *  command  ) 

Definition at line 856 of file system.c.

References LOGPRINTF, and WARNPRINTF.

Referenced by conn_on_enter_standby(), do_idle(), do_unmount(), on_medium_exited(), on_poweroff_continue(), on_restart_continue(), start_medium(), start_phase_2(), sys_set_card(), sys_set_orientation(), sys_standby(), usb_driver_load(), and usb_driver_unload().

00857 {
00858     LOGPRINTF("entry");
00859     
00860     g_return_val_if_fail(command!=NULL, FALSE);
00861 
00862     char *argv[4];
00863     gboolean retval = FALSE;
00864     GError *error = NULL;
00865     
00866     argv[0] = "/bin/sh";
00867     argv[1] = "-c";
00868     argv[2] = (char*) command;
00869     argv[3] = NULL;
00870 
00871     LOGPRINTF("Spawning: %s", argv[2]);
00872 
00873     retval = g_spawn_sync(NULL, argv, NULL, 0, NULL, NULL, NULL, NULL, NULL, &error);
00874     
00875     if (error)
00876     {
00877         WARNPRINTF("Execution of '%s' failed with error: %s", command, error->message);
00878         g_error_free(error);
00879         return FALSE;
00880     }
00881 
00882     return retval;
00883 }

Here is the caller graph for this function:

void sys_standby ( void   ) 

Definition at line 709 of file system.c.

References busy_add_background(), card_state, conf_get_first_boot(), device_state, do_poweroff(), g_holdoff_standby, LOGPRINTF, STATE_CARD_INDEXING, STATE_DEVICE_STARTING, STATE_USB_MOUNT_PENDING, STATE_USB_MOUNTED, sys_spawn_sync(), and usb_state.

Referenced by cb_menu_item_activated(), cb_sys_shutdown(), cb_sys_standby(), and do_idle().

00710 {
00711     LOGPRINTF("entry");
00712 
00713     // shutdown completely when standby switch is toggled during first boot of the device
00714     if ((device_state == STATE_DEVICE_STARTING) && conf_get_first_boot())
00715     {
00716         busy_add_background(0);                    
00717         sys_spawn_sync("shutdown -h now");
00718         return;
00719     }
00720 
00721     if ( usb_state == STATE_USB_MOUNT_PENDING ||
00722          usb_state == STATE_USB_MOUNTED || 
00723          card_state == STATE_CARD_INDEXING )
00724     {
00725         LOGPRINTF("System is connected to PC or indexing, don't enter standby");
00726         return;
00727     }
00728     
00729     if (g_holdoff_standby)
00730     {
00731         LOGPRINTF("Just back from standby, ignore key press");
00732         return;
00733     }
00734     
00735 #if MACHINE_IS_DR800SG || MACHINE_IS_DR800S || MACHINE_IS_DR800SW
00736     prepare_standby();
00737 #elif MACHINE_IS_DR1000S || MACHINE_IS_DR1000SW
00738     do_poweroff();
00739 #else
00740 #error Unhandled machine type
00741 #endif
00742 }

Here is the call graph for this function:

Here is the caller graph for this function:

void sys_starting_finished ( void   ) 

Definition at line 301 of file system.c.

References card_state, check_hardware(), conf_set_first_boot(), ipc_show_splash(), STATE_CARD_INACCESSIBLE, STATE_CARD_INDEXING, and STATE_CARD_MOUNTED.

Referenced by on_phase_3_complete().

00302 {
00303     if ((card_state != STATE_CARD_MOUNTED) &&
00304         (card_state != STATE_CARD_INACCESSIBLE) &&
00305         (card_state != STATE_CARD_INDEXING))
00306     {
00307         ipc_show_splash("nosd");
00308     }
00309     
00310     conf_set_first_boot(FALSE);
00311     
00312     // now that everything is up and running, check for USB connection
00313     check_hardware();
00314 }

Here is the call graph for this function:

Here is the caller graph for this function:

void sys_update_battery ( const char *  battery  ) 

Update the battery level and state.

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

Name : sys_update_battery

Parameters:
battery Battery state as read from sysfs
Returns:
--

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

Definition at line 932 of file system.c.

References get_battery_state(), LOGPRINTF, STATE_CHARGE_UNKNOWN, and update_battery_info().

Referenced by hal_device_property_modified().

00933 {
00934     gint                  charging  = 0;
00935     gint                  cur_level = 0;
00936     enum state_charge     cur_state = STATE_CHARGE_UNKNOWN;
00937     
00938     LOGPRINTF("entry");
00939     
00940     sscanf(battery, "%d %d", &cur_level, &charging);
00941     cur_state = get_battery_state(cur_level, charging);
00942     update_battery_info(cur_level, cur_state, FALSE);
00943 }

Here is the call graph for this function:

Here is the caller graph for this function:

void sys_update_hardware ( const char *  hardware  ) 

Update the hardware state.

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

Name : sys_update_hardware

Parameters:
hardware Hardware state as readf rom sysfs
Returns:
--

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

Definition at line 1074 of file system.c.

References card_state, LOGPRINTF, ST_HW_CARD, ST_HW_USB, STATE_CARD_UNKNOWN, stop_demo_mode(), sys_reset_idle_time(), and update_usb_state().

Referenced by check_hardware(), and hal_device_property_modified().

01075 {
01076     LOGPRINTF("entry");
01077     
01078     static gint         old_state           = 0;
01079     gint                cur_state           = 0;
01080  
01081     sscanf(hardware, "%d", &cur_state);
01082     
01083     LOGPRINTF("old state [%d] cur state [%d]", old_state, cur_state);
01084 
01085     if ( ((old_state & ST_HW_CARD) != (cur_state & ST_HW_CARD))
01086          || 
01087          (card_state == STATE_CARD_UNKNOWN) )
01088     {
01089         // NOTE reversed logic: 0 card is inserted, 1 card ejected
01090         //
01091         if (!(cur_state & ST_HW_CARD))
01092         {
01093             // event not handled here as storage device and volume will be added through HAL 
01094             LOGPRINTF("SD/MMC card inserted");
01095         }
01096         else
01097         {
01098             // event not handled here as storage device and volume will be removed through HAL
01099             LOGPRINTF("SD/MMC card ejected");
01100             stop_demo_mode();
01101         }
01102     }
01103 
01104     update_usb_state(cur_state & ST_HW_USB);
01105     
01106     // keep device awake for a while as HAL events can follow
01107     sys_reset_idle_time();
01108 
01109     // store state
01110     old_state = cur_state;
01111 }

Here is the call graph for this function:

Here is the caller graph for this function:

void sys_update_rgb_led ( void   ) 

Definition at line 1525 of file system.c.

References charge_state, COLOR_BLUE, COLOR_GREEN, COLOR_OFF, COLOR_RED, COLOR_YELLOW, conn_is_online(), is_busy_foreground(), LOGPRINTF, STATE_CHARGE_CHARGING, STATE_CHARGE_FULL, STATE_CHARGE_LOW, STATE_USB_DISCONNECTED, STATE_USB_UNKNOWN, sys_set_rgb_led(), and usb_state.

Referenced by do_idle(), do_update_rgb_led(), enter_connected_state(), enter_disconnected_state(), enter_off_state(), sys_set_services(), update(), and update_battery_info().

01526 {
01527     LOGPRINTF("entry");
01528     
01529     if (is_busy_foreground())
01530     {
01531         // Device Busy
01532         sys_set_rgb_led(COLOR_GREEN, 500);
01533         return;
01534     }
01535     
01536     if (conn_is_online())
01537     {
01538         // Connection Online
01539         sys_set_rgb_led(COLOR_BLUE, 0);
01540         return;
01541     }
01542     
01543     if (charge_state == STATE_CHARGE_CHARGING)
01544     {
01545         // Battery Charging
01546         sys_set_rgb_led(COLOR_YELLOW, 0);
01547         return;
01548     }
01549     else if (charge_state == STATE_CHARGE_FULL)
01550     {
01551         // Battery Fully Charged & USB attached
01552         if ((usb_state != STATE_USB_DISCONNECTED) && (usb_state != STATE_USB_UNKNOWN))
01553         {
01554             sys_set_rgb_led(COLOR_GREEN, 0);
01555             return;
01556         }
01557     }
01558     else if (charge_state == STATE_CHARGE_LOW)
01559     {
01560         // Battery Critically Low
01561         sys_set_rgb_led(COLOR_RED, 0);
01562         return;
01563     }
01564     
01565     // Device On -- default state
01566     sys_set_rgb_led(COLOR_OFF, 0);
01567 }

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean sys_usb_connect ( void   ) 

Establish USB connection by exporting file system.

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

Name : sys_usb_connect

Parameters:
-- 
Returns:
TRUE for success, FALSE for failure

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

Definition at line 783 of file system.c.

References card_state, do_unmount(), LOGPRINTF, on_usb_connected(), STATE_CARD_MOUNTED, STATE_USB_MOUNT_CONFIRM, STATE_USB_MOUNT_PENDING, usb_set_state(), and usb_state.

Referenced by on_confirm_usbconnect(), and usb_set_state().

00784 {
00785     gboolean retval = FALSE;
00786 
00787     LOGPRINTF("entry");
00788 
00789     if ((card_state == STATE_CARD_MOUNTED) &&
00790         (usb_state == STATE_USB_MOUNT_CONFIRM))
00791     {
00792         usb_set_state(STATE_USB_MOUNT_PENDING);
00793         do_unmount(TRUE, "usbconnect", on_usb_connected, NULL);
00794         retval = TRUE;
00795     }
00796     else
00797     {
00798         LOGPRINTF("no volume mounted or not confirmed");
00799     }
00800 
00801     return retval;
00802 }

Here is the call graph for this function:

Here is the caller graph for this function:

void sys_usb_no_connect ( void   ) 

Definition at line 1372 of file system.c.

References LOGPRINTF, STATE_USB_MOUNT_CONFIRM, STATE_USB_UNMOUNTED, usb_set_state(), and usb_state.

Referenced by on_confirm_usbconnect().

01373 {
01374     LOGPRINTF("entry");
01375     if (usb_state == STATE_USB_MOUNT_CONFIRM)
01376     {
01377         usb_set_state(STATE_USB_UNMOUNTED);
01378     }
01379 }

Here is the call graph for this function:

Here is the caller graph for this function:

Generated by  doxygen 1.6.2-20100208