Changeset 3350


Ignore:
Timestamp:
11/04/07 18:46:06 (6 years ago)
Author:
mickey
Message:

neod: check initial charger status on startup and send via dbus

Location:
trunk/src/target/OM-2007.2/daemons/neod/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/target/OM-2007.2/daemons/neod/src/buttonactions.c

    r3348 r3350  
    2121#include <gtk/gtkmenuitem.h> 
    2222#include <gtk/gtkcheckmenuitem.h> 
     23#include <gtk/gtkseparatormenuitem.h> 
    2324 
    2425#include <gdk/gdkx.h> 
     
    7576#define HEADPHONE_INSERTION_SWITCHCODE 0x02 
    7677#define CHARGER_INSERTION_BUTTON 0xa4 
     78 
     79#define BIT_MASK( name, numbits )                                        \ 
     80    unsigned short  name[ ((numbits) - 1) / (sizeof( short ) * 8) + 1 ];    \ 
     81    memset( name, 0, sizeof( name ) ) 
     82#define BIT_TEST( bitmask, bit )    \ 
     83    ( bitmask[ (bit) / sizeof(short) / 8 ] & (1u << ( (bit) % (sizeof(short) * 8))) ) 
    7784 
    7885GPollFD input_fd[10]; 
     
    499506void neod_buttonactions_popup_selected_fullscreen( GtkMenuItem* menu, gpointer user_data ) 
    500507{ 
    501     static is_fullscreen = 0; 
     508    static int is_fullscreen = 0; 
    502509 
    503510    gtk_widget_hide( aux_menu ); 
     
    708715        { 
    709716            g_debug( "sorry, i'm not going to close the today window" ); 
    710             return; 
     717            return FALSE; 
    711718        } 
    712719 
     
    831838{ 
    832839    if ( pm_value != FULL ) 
    833         return; 
     840        return FALSE; 
    834841    g_debug( "mainmenu powersave timeout 3" ); 
    835842    //FIXME talk to neod 
     
    891898} 
    892899 
     900gboolean neod_buttonactions_initial_update() 
     901{ 
     902    g_debug( "neod_buttonactions_initial_update" ); 
     903    for ( int i = 0; i <= max_input_fd; ++i ) 
     904    { 
     905        char name[256] = "Unknown"; 
     906        if( ioctl( input_fd[i].fd, EVIOCGNAME(sizeof(name)), name ) < 0) 
     907        { 
     908            perror("evdev ioctl"); 
     909            continue; 
     910        } 
     911 
     912        g_debug( "input node %d corresponds to %s", i, name ); 
     913 
     914        BIT_MASK( keys, KEY_MAX ); 
     915        if( ioctl( input_fd[i].fd, EVIOCGKEY(sizeof(keys)), keys ) < 0) 
     916        { 
     917            perror("evdev ioctl"); 
     918            continue; 
     919        } 
     920 
     921        if ( BIT_TEST( keys, CHARGER_INSERTION_BUTTON ) ) 
     922        { 
     923            g_debug( "charger already inserted" ); 
     924            g_spawn_command_line_async( "dbus-send /org/freedesktop/PowerManagement org.freesmartphone.powermanagement.ChargerConnected", NULL ); 
     925        } 
     926        else 
     927        { 
     928            g_debug( "charger not yet inserted" ); 
     929            g_spawn_command_line_async( "dbus-send /org/freedesktop/PowerManagement org.freesmartphone.powermanagement.ChargerDisconnected", NULL ); 
     930        } 
     931    } 
     932 
     933    return FALSE; 
     934} 
  • trunk/src/target/OM-2007.2/daemons/neod/src/buttonactions.h

    r2899 r3350  
    4141void neod_buttonactions_set_display( int brightness ); 
    4242void neod_buttonactions_sound_play( const gchar* samplename ); 
     43gboolean neod_buttonactions_initial_update(); 
    4344 
    4445#endif 
  • trunk/src/target/OM-2007.2/daemons/neod/src/neod-main.c

    r2665 r3350  
    2727        neod_buttonactions_set_display( 100 ); 
    2828        neod_buttonactions_sound_init(); 
     29        g_timeout_add_seconds( 10, (GSourceFunc) neod_buttonactions_initial_update, NULL ); 
    2930        gtk_main(); 
    3031        return 0; 
Note: See TracChangeset for help on using the changeset viewer.