Changeset 3422
- Timestamp:
- 11/14/07 15:20:26 (6 years ago)
- Location:
- trunk/src/target/OM-2007.2/applications/openmoko-dialer2
- Files:
-
- 4 edited
-
ChangeLog (modified) (1 diff)
-
src/phone-kit/moko-dialer-sms-dbus.xml (modified) (1 diff)
-
src/phone-kit/moko-dialer-sms.c (modified) (11 diffs)
-
src/phone-kit/moko-dialer-sms.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog
r3420 r3422 1 2007-11-14 Chris Lord <chris@openedhand.com> 2 3 * src/phone-kit/moko-dialer-sms-dbus.xml: 4 Remove signals, handled by the storage (jana/eds), return the UID of a 5 sent message 6 7 * src/phone-kit/moko-dialer-sms.c: (gsmd_eventhandler), 8 (sms_msghandler), (moko_dialer_sms_init), (moko_dialer_sms_new), 9 (moko_dialer_sms_get_default), (moko_dialer_sms_send): 10 * src/phone-kit/moko-dialer-sms.h: 11 Add status reports, sending confirmation and synchronisation with 12 storage 13 1 14 2007-11-14 Chris Lord <chris@openedhand.com> 2 15 -
trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/phone-kit/moko-dialer-sms-dbus.xml
r3420 r3422 6 6 <arg type="s" name="number" /> 7 7 <arg type="s" name="message" /> 8 <arg type="s" name="uid" direction="out" /> 8 9 </method> 9 10 <signal name="Sending">11 </signal>12 13 <signal name="Sent">14 </signal>15 16 <signal name="Rejected">17 <arg type="s" name="message" />18 </signal>19 20 10 </interface> 21 11 </node> -
trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/phone-kit/moko-dialer-sms.c
r3420 r3422 23 23 struct lgsm_handle *handle; 24 24 JanaStore *note_store; 25 JanaNote *last_msg; 25 26 }; 26 27 enum {28 SENDING,29 SENT,30 REJECTED,31 LAST_SIGNAL32 };33 34 static guint signals[LAST_SIGNAL];35 27 36 28 static void … … 78 70 object_class->dispose = moko_dialer_sms_dispose; 79 71 object_class->finalize = moko_dialer_sms_finalize; 80 81 signals[SENDING] = g_signal_new ("sending", 82 G_TYPE_FROM_CLASS (object_class), 83 G_SIGNAL_RUN_LAST, 84 G_STRUCT_OFFSET (MokoDialerSMSClass, sending), 85 NULL, NULL, 86 g_cclosure_marshal_VOID__VOID, 87 G_TYPE_NONE, 0); 88 89 signals[SENT] = g_signal_new ("sent", 90 G_TYPE_FROM_CLASS (object_class), 91 G_SIGNAL_RUN_LAST, 92 G_STRUCT_OFFSET (MokoDialerSMSClass, sent), 93 NULL, NULL, 94 g_cclosure_marshal_VOID__VOID, 95 G_TYPE_NONE, 0); 96 97 signals[REJECTED] = g_signal_new ("rejected", 98 G_TYPE_FROM_CLASS (object_class), 99 G_SIGNAL_RUN_LAST, 100 G_STRUCT_OFFSET (MokoDialerSMSClass, rejected), 101 NULL, NULL, 102 g_cclosure_marshal_VOID__STRING, 103 G_TYPE_NONE, 1, G_TYPE_STRING); 72 } 73 74 static void 75 status_report_added_cb (JanaStoreView *view, GList *components, gchar *ref) 76 { 77 MokoDialerSMSPrivate *priv = SMS_PRIVATE ( 78 moko_dialer_sms_get_default ()); 79 80 for (; components; components = components->next) { 81 gchar *compref; 82 JanaComponent *comp = JANA_COMPONENT (components->data); 83 84 compref = jana_component_get_custom_prop ( 85 comp, "X-PHONEKIT-SMS-REF"); 86 if (compref && (strcmp (compref, ref) == 0)) { 87 jana_utils_component_remove_category (comp, "Sending"); 88 jana_utils_component_insert_category (comp, "Sent", 0); 89 jana_store_modify_component (priv->note_store, comp); 90 } 91 g_free (ref); 92 } 93 } 94 95 static void 96 status_report_progress_cb (JanaStoreView *view, gint percent, gchar *ref) 97 { 98 if (percent != 100) return; 99 100 g_object_unref (view); 101 g_free (ref); 104 102 } 105 103 … … 111 109 moko_dialer_sms_get_default ()); 112 110 111 /* TODO: Handle events that aren't in-line */ 112 113 113 switch (evt_type) { 114 114 case GSMD_EVT_IN_SMS : /* Incoming SMS */ 115 /* TODO: Read UDH for multi-part messages */ 115 116 if (aux->u.sms.inlined) { 116 117 gchar *message; … … 173 174 } 174 175 } else { 176 g_warning ("Not an in-line event, unhandled"); 175 177 } 176 178 break; 177 179 case GSMD_EVT_IN_DS : /* SMS status report */ 180 if (aux->u.ds.inlined) { 181 struct gsmd_sms_list *sms = 182 (struct gsmd_sms_list *) aux->data; 183 184 /* TODO: I'm not entirely sure of the spec when if 185 * storing an unsent message means it failed? 186 */ 187 if (sms->payload.coding_scheme == LGSM_SMS_STO_SENT) { 188 gchar *ref = g_strdup_printf ("%d", sms->index); 189 JanaStoreView *view = jana_store_get_view ( 190 priv->note_store); 191 jana_store_view_add_match (view, 192 JANA_STORE_VIEW_CATEGORY, "Sending"); 193 g_signal_connect (view, "added", G_CALLBACK ( 194 status_report_added_cb), ref); 195 g_signal_connect (view, "progress", G_CALLBACK ( 196 status_report_progress_cb), ref); 197 } 198 } else { 199 g_warning ("Not an in-line event, unhandled"); 200 } 178 201 break; 179 202 default : 180 203 g_warning ("Unhandled gsmd event (%d)", evt_type); 204 } 205 206 return 0; 207 } 208 209 static int 210 sms_msghandler (struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh) 211 { 212 MokoDialerSMS *sms = moko_dialer_sms_get_default (); 213 MokoDialerSMSPrivate *priv = SMS_PRIVATE (sms); 214 215 /* Store sent messages */ 216 if ((gmh->msg_subtype == GSMD_SMS_SEND) && priv->last_msg) { 217 int *result = (int *) ((void *) gmh + sizeof(*gmh)); 218 gchar *uid = jana_component_get_uid ( 219 JANA_COMPONENT (priv->last_msg)); 220 221 if (*result >= 0) { 222 gchar *ref = g_strdup_printf ("%d", *result); 223 jana_component_set_custom_prop ( 224 JANA_COMPONENT (priv->last_msg), 225 "X-PHONEKIT-SMS-REF", ref); 226 g_free (ref); 227 } else { 228 jana_utils_component_remove_category ( 229 JANA_COMPONENT(priv->last_msg), "Sending"); 230 jana_utils_component_insert_category ( 231 JANA_COMPONENT(priv->last_msg), "Rejected", 0); 232 /* TODO: Add error codes? 42 = congestion? */ 233 } 234 jana_store_modify_component (priv->note_store, 235 JANA_COMPONENT (priv->last_msg)); 236 237 g_free (uid); 238 g_object_unref (priv->last_msg); 239 priv->last_msg = NULL; 181 240 } 182 241 … … 202 261 /* Initialise gsmd and connect event handler */ 203 262 if (!(priv->handle = lgsm_init (LGSMD_DEVICE_GSMD))) { 204 g_ warning ("Failed to connect to gsmd, signals won't work");263 g_error ("Failed to connect to gsmd"); 205 264 } else { 206 265 lgsm_evt_handler_register (priv->handle, GSMD_EVT_IN_SMS, … … 209 268 gsmd_eventhandler); 210 269 } 270 271 /* Connect SMS message handler (to get sent message references) */ 272 lgsm_register_handler (priv->handle, GSMD_MSG_SMS, &sms_msghandler); 273 274 /* TODO: Move any existing SMS messages off of sim and to journal */ 211 275 } 212 276 … … 231 295 gboolean 232 296 moko_dialer_sms_send (MokoDialerSMS *self, const gchar *number, 233 const gchar *message, GError **error)297 const gchar *message, gchar **uid, GError **error) 234 298 { 235 299 MokoDialerSMSPrivate *priv; … … 237 301 gint msg_length, c; 238 302 gboolean ascii; 303 JanaNote *note; 304 gchar *author; 239 305 240 306 g_assert (self && number && message); … … 242 308 priv = SMS_PRIVATE (self); 243 309 244 /* TODO: Delivery report */245 sms.ask_ds = 0;310 /* Ask for delivery report */ 311 sms.ask_ds = 1; 246 312 247 313 /* Set destination number */ … … 263 329 } 264 330 } 331 332 /* TODO: Multi-part messages using UDH */ 265 333 msg_length = strlen (message); 266 334 if ((ascii && (msg_length > 160)) || (msg_length > 140)) { … … 280 348 lgsm_sms_send (priv->handle, &sms); 281 349 350 /* Store sent message in journal */ 351 note = jana_ecal_note_new (); 352 jana_note_set_recipient (note, number); 353 354 /* TODO: Normalise number necessary? */ 355 author = g_strdup_printf ("%d", 356 lgsm_get_subscriber_num (priv->handle)); 357 jana_note_set_author (note, author); 358 g_free (author); 359 360 jana_note_set_body (note, message); 361 jana_component_set_categories (JANA_COMPONENT (note), 362 (const gchar *[]){ "Sending", NULL}); 363 364 jana_store_add_component (priv->note_store, 365 JANA_COMPONENT (note)); 366 if (uid) *uid = jana_component_get_uid (JANA_COMPONENT (note)); 367 368 if (priv->last_msg) { 369 g_warning ("Confirmation not received for last sent SMS, " 370 "delivery report will be lost."); 371 g_object_unref (priv->last_msg); 372 priv->last_msg = NULL; 373 } 374 priv->last_msg = note; 375 282 376 return TRUE; 283 377 } 284 285 void286 moko_dialer_sms_sending (MokoDialerSMS *sms)287 {288 g_signal_emit (sms, signals[SENDING], 0);289 }290 291 void292 moko_dialer_sms_sent (MokoDialerSMS *sms)293 {294 g_signal_emit (sms, signals[SENT], 0);295 }296 297 void298 moko_dialer_sms_rejected (MokoDialerSMS *sms, const gchar *message)299 {300 g_signal_emit (sms, signals[REJECTED], 0, message);301 }302 -
trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/phone-kit/moko-dialer-sms.h
r3420 r3422 41 41 typedef struct { 42 42 GObjectClass parent_class; 43 44 void (*sending) (MokoDialerSMS *sms);45 void (*sent) (MokoDialerSMS *sms);46 void (*rejected) (MokoDialerSMS *sms, const gchar *message);47 43 } MokoDialerSMSClass; 48 44 … … 54 50 55 51 gboolean moko_dialer_sms_send (MokoDialerSMS *sms, const gchar *number, 56 const gchar *message, GError **error); 57 58 void moko_dialer_sms_sending (MokoDialerSMS *sms); 59 void moko_dialer_sms_sent (MokoDialerSMS *sms); 60 void moko_dialer_sms_rejected (MokoDialerSMS *sms, const gchar *message); 52 const gchar *message, gchar **uid, 53 GError **error); 61 54 62 55 G_END_DECLS
Note: See TracChangeset
for help on using the changeset viewer.
