00001 #ifndef __SYSTEM_H__ 00002 #define __SYSTEM_H__ 00003 00004 /** 00005 * File Name : system.h 00006 * 00007 * Description: System handling functions 00008 */ 00009 00010 /* 00011 * This file is part of sysd. 00012 * 00013 * sysd is free software: you can redistribute it and/or modify 00014 * it under the terms of the GNU General Public License as published by 00015 * the Free Software Foundation, either version 2 of the License, or 00016 * (at your option) any later version. 00017 * 00018 * sysd is distributed in the hope that it will be useful, 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00021 * GNU General Public License for more details. 00022 * 00023 * You should have received a copy of the GNU General Public License 00024 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00025 */ 00026 00027 /** 00028 * Copyright (C) 2008 iRex Technologies B.V. 00029 * All rights reserved. 00030 */ 00031 00032 00033 //---------------------------------------------------------------------------- 00034 // Include Files 00035 //---------------------------------------------------------------------------- 00036 00037 G_BEGIN_DECLS 00038 00039 00040 //---------------------------------------------------------------------------- 00041 // Definitions 00042 //---------------------------------------------------------------------------- 00043 00044 enum state_device 00045 { 00046 STATE_DEVICE_UNKNOWN = 0, 00047 STATE_DEVICE_STARTING, 00048 STATE_DEVICE_STARTED, 00049 STATE_DEVICE_STOPPING 00050 }; 00051 00052 enum state_card 00053 { 00054 STATE_CARD_UNKNOWN = 0, 00055 STATE_CARD_INACCESSIBLE, 00056 STATE_CARD_EJECTED, 00057 STATE_CARD_UNMOUNTING, 00058 STATE_CARD_UNMOUNTED, 00059 STATE_CARD_INDEXING, 00060 STATE_CARD_MOUNTED 00061 }; 00062 00063 enum state_charge 00064 { 00065 STATE_CHARGE_UNKNOWN = 0, 00066 STATE_CHARGE_LOW, 00067 STATE_CHARGE_CHARGING, 00068 STATE_CHARGE_DISCHARGING, 00069 STATE_CHARGE_FULL 00070 }; 00071 00072 enum state_stylus 00073 { 00074 STATE_STYLUS_UNKNOWN = 0, 00075 STATE_STYLUS_IDLE, 00076 STATE_STYLUS_SCRIBBLING 00077 }; 00078 00079 enum state_power 00080 { 00081 STATE_POWER_UNKNOWN = 0, 00082 STATE_POWER_OFF, 00083 STATE_POWER_RUN, 00084 STATE_POWER_IDLE, 00085 STATE_POWER_STANDBY 00086 }; 00087 00088 enum led_color 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 }; 00099 00100 enum rotate_direction 00101 { 00102 ROTATE_UNKOWN = 0, 00103 ROTATE_CLOCKWISE, 00104 ROTATE_ANTICLOCKWISE 00105 }; 00106 00107 enum display_orientation 00108 { 00109 ORIENTATION_PORTRAIT = 0, 00110 ORIENTATION_LANDSCAPE_CLOCKWISE, 00111 ORIENTATION_LANDSCAPE_ANTICLOCKWISE 00112 }; 00113 00114 enum busy_dialog 00115 { 00116 BUSY_DIALOG_NONE = 0, 00117 BUSY_DIALOG_DELAYED, 00118 BUSY_DIALOG_DIRECT 00119 }; 00120 00121 00122 //---------------------------------------------------------------------------- 00123 // Forward Declarations 00124 //---------------------------------------------------------------------------- 00125 00126 00127 //---------------------------------------------------------------------------- 00128 // Type Declarations 00129 //---------------------------------------------------------------------------- 00130 00131 00132 //---------------------------------------------------------------------------- 00133 // Global Constants 00134 //---------------------------------------------------------------------------- 00135 00136 00137 //============================================================================ 00138 // Public Functions 00139 //============================================================================ 00140 00141 /**--------------------------------------------------------------------------- 00142 * 00143 * Name : sys_set_services 00144 * 00145 * @brief Initialize the system services. Find micro driver and set up 00146 * battery level polling. 00147 * 00148 * @param -- 00149 * 00150 * @return -- 00151 * 00152 *--------------------------------------------------------------------------*/ 00153 void sys_set_services(void); 00154 00155 /**--------------------------------------------------------------------------- 00156 * 00157 * Name : sys_get_battery 00158 * 00159 * @brief Return battery level and charge information 00160 * 00161 * @param [out] level Set to current battery charge in percent 00162 * @param [out] state Charge state 00163 * @param [out] timeleft Minutes to emtpy (discharging/low) or -1 (charging/full) 00164 * 00165 * @return TRUE for success, FALSE for failure 00166 * 00167 *--------------------------------------------------------------------------*/ 00168 gboolean sys_get_battery(int *level, enum state_charge *state, int *timeleft); 00169 00170 /**--------------------------------------------------------------------------- 00171 * 00172 * Name : sys_get_device_capabilities 00173 * 00174 * @brief Return device capabilities 00175 * 00176 * @param has_stylus 00177 * @param has_wifi 00178 * @param has_bluetooth 00179 * @param has_3g 00180 * 00181 * @return -- 00182 * 00183 *--------------------------------------------------------------------------*/ 00184 void sys_get_device_capabilities(gboolean *has_stylus, gboolean *has_wifi, gboolean *has_bluetooth, gboolean *has_3g); 00185 00186 /**--------------------------------------------------------------------------- 00187 * 00188 * Name : sys_set_busy 00189 * 00190 * @brief Set the busy state for eg LED indication 00191 * 00192 * @param is_busy TRUE for busy, FALSE otherwise 00193 * 00194 * @return TRUE for success, FALSE for failure 00195 * 00196 *--------------------------------------------------------------------------*/ 00197 gboolean sys_set_busy(gboolean is_busy); 00198 00199 /**--------------------------------------------------------------------------- 00200 * 00201 * Name : sys_set_beeper_config 00202 * 00203 * @brief Enable/disable audible feedback by applications 00204 * 00205 * @param use_sound TRUE for beeps, FALSE to mute 00206 * 00207 * @return TRUE for success, FALSE for failure 00208 * 00209 *--------------------------------------------------------------------------*/ 00210 gboolean sys_set_beeper_config(gboolean use_sound); 00211 00212 /**--------------------------------------------------------------------------- 00213 * 00214 * Name : sys_set_beeper_config 00215 * 00216 * @brief Enable/disable audible feedback 00217 * 00218 * @param duration_ms Length of tone in ms (use intervals of 10ms) 00219 * @param tone Beep tone "high" or "low" 00220 * 00221 * @return TRUE for success, FALSE for failure 00222 * 00223 *--------------------------------------------------------------------------*/ 00224 gboolean sys_set_beeper(gint duration_ms, const char *tone); 00225 00226 /**--------------------------------------------------------------------------- 00227 * 00228 * Name : sys_set_pageturn_inverted 00229 * 00230 * @brief Setup direction to use for the flipbar. 00231 * 00232 * @param is_pageturn_inverted TRUE or FALSE 00233 * 00234 * @return TRUE for success, FALSE for failure 00235 * 00236 *--------------------------------------------------------------------------*/ 00237 gboolean sys_set_pageturn_inverted(gboolean is_inverted); 00238 00239 /**--------------------------------------------------------------------------- 00240 * 00241 * Name : sys_set_rotate_direction 00242 * 00243 * @brief Setup direction to use for rotation. To actually rotate the screen, 00244 * call sys_set_orientation(). 00245 * 00246 * @param direction Rotate "clockwise" or "anticlockwise" 00247 * 00248 * @return TRUE for success, FALSE for failure 00249 * 00250 *--------------------------------------------------------------------------*/ 00251 gboolean sys_set_rotate_direction(const char *direction); 00252 00253 /**--------------------------------------------------------------------------- 00254 * 00255 * Name : sys_set_orientation 00256 * 00257 * @brief Change the orientation of the screen. The rotation direction is set 00258 * by sys_set_rotate_direction(). 00259 * 00260 * @param orientation Set to "portrait", "landscape" or "toggle" 00261 * 00262 * @return TRUE for success, FALSE for failure 00263 * 00264 *--------------------------------------------------------------------------*/ 00265 gboolean sys_set_orientation(const char *orientation); 00266 00267 /**--------------------------------------------------------------------------- 00268 * 00269 * Name : sys_set_sensor_feedback 00270 * 00271 * @brief Enable/disable audible and visual feedback by applications 00272 * 00273 * @param use_light TRUE to flash on sensor presses, FALSE to mute 00274 * @param use_sound TRUE to beep on sensor presses, FALSE to mute 00275 * 00276 * @return TRUE for success, FALSE for failure 00277 * 00278 *--------------------------------------------------------------------------*/ 00279 gboolean sys_set_sensor_feedback(gboolean use_light, gboolean use_sound); 00280 00281 /**--------------------------------------------------------------------------- 00282 * 00283 * Name : sys_set_sensor_lock_config 00284 * 00285 * @brief Setup which sensor(s) to block when locked. To actually lock the 00286 * sensors, call sys_set_sensor_lock(). 00287 * 00288 * @param lock_left TRUE to lock sensor, FALSE to keep unlocked 00289 * @param lock_right TRUE to lock sensor, FALSE to keep unlocked 00290 * @param lock_middle TRUE to lock sensor, FALSE to keep unlocked 00291 * 00292 * @return TRUE for success, FALSE for failure 00293 * 00294 *--------------------------------------------------------------------------*/ 00295 gboolean sys_set_sensor_lock_config(gboolean lock_left, gboolean lock_right, gboolean lock_middle); 00296 00297 /**--------------------------------------------------------------------------- 00298 * 00299 * Name : sys_set_sensor_lock 00300 * 00301 * @brief Block the sensor input 00302 * 00303 * @param lock_mode Set to "lock", "unlock" or "toggle" 00304 * 00305 * @return TRUE for success, FALSE for failure 00306 * 00307 *--------------------------------------------------------------------------*/ 00308 gboolean sys_set_sensor_lock(const char *lock_mode); 00309 00310 /**--------------------------------------------------------------------------- 00311 * 00312 * Name : sys_set_rgb_led 00313 * 00314 * @brief Set the main RGB led 00315 * 00316 * @param color Color value 00317 * @param flash_ms Length of flash duration in ms (with intervals of 500ms) 00318 * 00319 * LED color values: 00320 * 0: off 4: red 00321 * 1: blue 5: magenta 00322 * 2: green 6: yellow 00323 * 3: cyan 7: white 00324 * 00325 * @return TRUE for success, FALSE for failure 00326 * 00327 *--------------------------------------------------------------------------*/ 00328 gboolean sys_set_rgb_led(enum led_color color, gint flash_ms); 00329 00330 /**--------------------------------------------------------------------------- 00331 * 00332 * Name : sys_set_timezone_offset 00333 * 00334 * @brief Set the offset from UTC time 00335 * 00336 * @param tz_offset_sec Offset from UTC in seconds East of Greenwich 00337 * 00338 * @return TRUE for success, FALSE for failure 00339 * 00340 *--------------------------------------------------------------------------*/ 00341 gboolean sys_set_timezone_offset(gint tz_offset_sec); 00342 00343 /**--------------------------------------------------------------------------- 00344 * 00345 * Name : sys_eject_card 00346 * 00347 * @brief Unmount all volumes etc before the SD care can be safely ejected 00348 * 00349 * @param silent [Input] TRUE to suppress dialogs, FALSE otherwise 00350 * 00351 * @return -- 00352 * 00353 *--------------------------------------------------------------------------*/ 00354 void sys_eject_card(gboolean silent); 00355 00356 /**--------------------------------------------------------------------------- 00357 * 00358 * Name : sys_update_battery 00359 * 00360 * @brief Update the battery level and state 00361 * 00362 * @param battery Battery state as read from sysfs 00363 * 00364 * @return -- 00365 * 00366 *--------------------------------------------------------------------------*/ 00367 void sys_update_battery(const char *battery); 00368 00369 /**--------------------------------------------------------------------------- 00370 * 00371 * Name : sys_update_hardware 00372 * 00373 * @brief Update the hardware state 00374 * 00375 * @param hardware Hardware state as readf rom sysfs 00376 * 00377 * @return -- 00378 * 00379 *--------------------------------------------------------------------------*/ 00380 void sys_update_hardware(const char *hardware); 00381 00382 /**--------------------------------------------------------------------------- 00383 * 00384 * Name : sys_usb_connect 00385 * 00386 * @brief Establish USB connection by exporting file system 00387 * 00388 * @param -- 00389 * 00390 * @return TRUE for success, FALSE for failure 00391 * 00392 *--------------------------------------------------------------------------*/ 00393 gboolean sys_usb_connect(void); 00394 00395 void sys_set_card(enum state_card new_state); 00396 void sys_set_idle_mode(gboolean idle_enabled); 00397 void sys_set_standby_time(guint time_sec); 00398 void sys_set_standby_mode(gboolean standby_if_plugged); 00399 void sys_reset_idle_time(void); 00400 void sys_usb_no_connect(void); 00401 void sys_standby(void); 00402 void sys_restart(void); 00403 gboolean sys_request_popup(const char *state); 00404 gboolean sys_set_power(const char *device, gint mode); 00405 gboolean sys_get_power(const char *device, gint *mode); 00406 guint sys_get_orientation(void); 00407 gboolean sys_get_pageturn_inverted(void); 00408 gfloat sys_get_display_vcom(void); 00409 void sys_install_drz(void); 00410 enum state_device sys_get_device_state(void); 00411 enum state_power sys_get_power_state(void); 00412 enum state_card sys_get_card(void); 00413 void sys_set_device_state(enum state_device); 00414 gboolean sys_has_stylus(void); 00415 gboolean sys_has_network(void); 00416 gboolean sys_is_emulator(void); 00417 void sys_update_rgb_led(void); 00418 gboolean sys_spawn_async(const char *command); 00419 gboolean sys_spawn_async_with_callback(const char *command, GChildWatchFunc callback, gpointer data); 00420 gboolean sys_spawn_sync(const char *command); 00421 gboolean sys_is_dr800(void); 00422 00423 gboolean sys_get_enable_index_splash(void); 00424 void sys_set_enable_index_splash(gboolean value); 00425 gboolean sys_set_index_with_metadata(gboolean value); 00426 gint sys_battery_level(void); 00427 void sys_starting_finished(void); 00428 00429 G_END_DECLS 00430 00431 #endif /* __SYSTEM_H__ */