Changeset 3438
- Timestamp:
- 11/19/07 14:59:28 (6 years ago)
- Location:
- trunk/src/target/OM-2007.2/applications/openmoko-dialer2
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
src/phone-kit/moko-dialer-sms.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog
r3437 r3438 1 2007-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 1 8 2007-11-19 Chris Lord <chris@openedhand.com> 2 9 -
trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/phone-kit/moko-dialer-sms.c
r3437 r3438 10 10 #include <libjana-ecal/jana-ecal.h> 11 11 #include <string.h> 12 #include <unistd.h> 12 13 13 14 #include "moko-dialer-sms-glue.h" … … 19 20 20 21 typedef struct _MokoDialerSMSPrivate MokoDialerSMSPrivate; 22 23 typedef struct { 24 GSource source; 25 GPollFD pollfd; 26 struct lgsm_handle *handle; 27 } MokoDialerSMSSource; 21 28 22 29 struct _MokoDialerSMSPrivate { … … 24 31 JanaStore *note_store; 25 32 JanaNote *last_msg; 33 MokoDialerSMSSource *source; 26 34 }; 27 35 … … 56 64 moko_dialer_sms_finalize (GObject *object) 57 65 { 66 MokoDialerSMSPrivate *priv = SMS_PRIVATE (object); 67 68 g_source_destroy ((GSource *)priv->source); 69 lgsm_exit (priv->handle); 70 58 71 G_OBJECT_CLASS (moko_dialer_sms_parent_class)->finalize (object); 59 72 } … … 270 283 } 271 284 285 static gboolean 286 connection_source_prepare (GSource* self, gint* timeout) 287 { 288 return FALSE; 289 } 290 291 static gboolean 292 connection_source_check (GSource* source) 293 { 294 MokoDialerSMSSource *self = (MokoDialerSMSSource *)source; 295 return self->pollfd.revents & G_IO_IN; 296 } 297 298 static gboolean 299 connection_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 272 320 static void 273 321 moko_dialer_sms_init (MokoDialerSMS *self) 274 322 { 275 323 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 276 331 MokoDialerSMSPrivate *priv = SMS_PRIVATE (self); 277 332 … … 301 356 /* List all messages to move to journal */ 302 357 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); 303 368 } 304 369
Note: See TracChangeset
for help on using the changeset viewer.
