Changeset 3438


Ignore:
Timestamp:
11/19/07 14:59:28 (6 years ago)
Author:
chris
Message:
  • src/phone-kit/moko-dialer-sms.c: (moko_dialer_sms_finalize), (connection_source_prepare), (connection_source_check), (connection_source_dispatch), (moko_dialer_sms_init): Don't forget to actually poll for events...
Location:
trunk/src/target/OM-2007.2/applications/openmoko-dialer2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog

    r3437 r3438  
     12007-11-19  Chris Lord  <chris@openedhand.com> 
     2 
     3        * src/phone-kit/moko-dialer-sms.c: (moko_dialer_sms_finalize), 
     4        (connection_source_prepare), (connection_source_check), 
     5        (connection_source_dispatch), (moko_dialer_sms_init): 
     6        Don't forget to actually poll for events... 
     7 
    182007-11-19  Chris Lord  <chris@openedhand.com> 
    29 
  • trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/phone-kit/moko-dialer-sms.c

    r3437 r3438  
    1010#include <libjana-ecal/jana-ecal.h> 
    1111#include <string.h> 
     12#include <unistd.h> 
    1213 
    1314#include "moko-dialer-sms-glue.h" 
     
    1920 
    2021typedef struct _MokoDialerSMSPrivate MokoDialerSMSPrivate; 
     22 
     23typedef struct { 
     24        GSource source; 
     25        GPollFD pollfd; 
     26        struct lgsm_handle *handle; 
     27} MokoDialerSMSSource; 
    2128 
    2229struct _MokoDialerSMSPrivate { 
     
    2431        JanaStore *note_store; 
    2532        JanaNote *last_msg; 
     33        MokoDialerSMSSource *source; 
    2634}; 
    2735 
     
    5664moko_dialer_sms_finalize (GObject *object) 
    5765{ 
     66        MokoDialerSMSPrivate *priv = SMS_PRIVATE (object); 
     67         
     68        g_source_destroy ((GSource *)priv->source); 
     69        lgsm_exit (priv->handle); 
     70 
    5871        G_OBJECT_CLASS (moko_dialer_sms_parent_class)->finalize (object); 
    5972} 
     
    270283} 
    271284 
     285static gboolean  
     286connection_source_prepare (GSource* self, gint* timeout) 
     287{ 
     288    return FALSE; 
     289} 
     290 
     291static gboolean  
     292connection_source_check (GSource* source) 
     293{ 
     294        MokoDialerSMSSource *self = (MokoDialerSMSSource *)source; 
     295        return self->pollfd.revents & G_IO_IN; 
     296} 
     297 
     298static gboolean  
     299connection_source_dispatch (GSource *source, GSourceFunc callback, 
     300                            gpointer data) 
     301{ 
     302        char buf[1025]; 
     303        int size; 
     304 
     305        MokoDialerSMSSource *self = (MokoDialerSMSSource *)source; 
     306 
     307        size = read (self->pollfd.fd, &buf, sizeof(buf)); 
     308        if (size < 0) { 
     309                g_warning ("moko_gsmd_connection_source_dispatch:%s %s", 
     310                        "read error from libgsmd:", strerror (errno)); 
     311        } else { 
     312                if (size == 0) /* EOF */ 
     313                        return FALSE; 
     314                lgsm_handle_packet (self->handle, buf, size); 
     315        } 
     316         
     317        return TRUE; 
     318} 
     319 
    272320static void 
    273321moko_dialer_sms_init (MokoDialerSMS *self) 
    274322{ 
    275323        static gboolean first_init = TRUE; 
     324        static GSourceFuncs funcs = { 
     325                connection_source_prepare, 
     326                connection_source_check, 
     327                connection_source_dispatch, 
     328                NULL, 
     329        }; 
     330         
    276331        MokoDialerSMSPrivate *priv = SMS_PRIVATE (self); 
    277332         
     
    301356        /* List all messages to move to journal */ 
    302357        lgsm_sms_list (priv->handle, GSMD_SMS_ALL); 
     358         
     359        /* Start polling for events */ 
     360        priv->source = (MokoDialerSMSSource *) 
     361                g_source_new (&funcs, sizeof (MokoDialerSMSSource)); 
     362        priv->source->handle = priv->handle; 
     363        priv->source->pollfd.fd = lgsm_fd (priv->handle); 
     364        priv->source->pollfd.events = G_IO_IN | G_IO_HUP | G_IO_ERR; 
     365        priv->source->pollfd.revents = 0; 
     366        g_source_add_poll ((GSource*)priv->source, &priv->source->pollfd); 
     367        g_source_attach ((GSource*)priv->source, NULL); 
    303368} 
    304369 
Note: See TracChangeset for help on using the changeset viewer.