utils: add dial() and unify simple dialing and error handling.
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Tue, 21 Aug 2012 09:54:03 +0000 (06:54 -0300)
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Tue, 21 Aug 2012 09:54:03 +0000 (06:54 -0300)
dialer/callscreen.c
dialer/contacts.c
dialer/gui.c
dialer/history.c
dialer/keypad.c
dialer/util.c
dialer/util.h

index a5653a7..f0d57e5 100644 (file)
@@ -287,7 +287,7 @@ static void _popup_redial(void *data, Evas_Object *o __UNUSED__, void *event __U
 {
        Callscreen *ctx = data;
 
-       ofono_dial(ctx->disconnected.number, NULL, NULL, NULL);
+       dial(ctx->disconnected.number);
        _popup_close(ctx, NULL, NULL);
 }
 
index 783ecea..9d2d016 100644 (file)
@@ -521,7 +521,7 @@ static void _on_number_clicked(void *data, Evas_Object *obj __UNUSED__,
                                void *event_inf __UNUSED__)
 {
        const char *number = data;
-       ofono_dial(number, NULL, NULL, NULL);
+       dial(number);
 }
 
 static void _on_item_click(void *data, Evas_Object *obj __UNUSED__,
index e4ab4bf..b01e2bd 100644 (file)
@@ -407,27 +407,13 @@ static void _gui_call_sync(void *data __UNUSED__, Evas_Object *o __UNUSED__,
        in_flip_anim = EINA_FALSE;
 }
 
-static void _dial_reply(void *data, OFono_Error err,
-                       OFono_Call *call __UNUSED__)
-{
-       const char *number = data;
-
-       if (err != OFONO_ERROR_NONE) {
-               char buf[1024];
-               const char *msg = ofono_error_message_get(err);
-               snprintf(buf, sizeof(buf), "Could not call %s: %s",
-                               number, msg);
-               gui_simple_popup("Error", buf);
-       }
-}
-
 static void _gui_voicemail(void)
 {
        const char *number = ofono_voicemail_number_get();
        EINA_SAFETY_ON_NULL_RETURN(number);
        EINA_SAFETY_ON_FALSE_RETURN(*number != '\0');
 
-       ofono_dial(number, NULL, _dial_reply, number);
+       dial(number);
 }
 
 static void _on_clicked(void *data __UNUSED__, Evas_Object *o __UNUSED__,
index d1d0b41..7f2394a 100644 (file)
@@ -232,20 +232,6 @@ static Eina_Bool _history_call_info_update(Call_Info *call_info)
        return EINA_FALSE;
 }
 
-static void _dial_reply(void *data, OFono_Error err,
-                       OFono_Call *call __UNUSED__)
-{
-       const char *number = data;
-
-       if (err != OFONO_ERROR_NONE) {
-               char buf[1024];
-               const char *msg = ofono_error_message_get(err);
-               snprintf(buf, sizeof(buf), "Could not call %s: %s",
-                               number, msg);
-               gui_simple_popup("Error", buf);
-       }
-}
-
 static void _on_item_clicked(void *data, Evas_Object *obj __UNUSED__,
                                void *event_info)
 {
@@ -253,7 +239,7 @@ static void _on_item_clicked(void *data, Evas_Object *obj __UNUSED__,
        const char *number = data;
 
        INF("call %s", number);
-       ofono_dial(number, NULL, _dial_reply, number);
+       dial(number);
        elm_genlist_item_selected_set(it, EINA_FALSE);
 }
 
index f9e188b..83f22d3 100644 (file)
@@ -232,26 +232,12 @@ static Eina_Bool _handle_if_mmi(Keypad *ctx)
        return EINA_FALSE;
 }
 
-static void _dial_reply(void *data, OFono_Error err,
-                       OFono_Call *call __UNUSED__)
-{
-       Keypad *ctx = data;
-
-       if (err != OFONO_ERROR_NONE) {
-               char buf[1024];
-               const char *msg = ofono_error_message_get(err);
-               snprintf(buf, sizeof(buf), "Could not call %s: %s",
-                               eina_strbuf_string_get(ctx->number), msg);
-               gui_simple_popup("Error", buf);
-       }
-}
-
 static void _dial(Keypad *ctx)
 {
        const char *number = eina_strbuf_string_get(ctx->number);
 
        INF("call %s", number);
-       ofono_dial(number, NULL, _dial_reply, ctx);
+       dial(number);
        eina_stringshare_replace(&(ctx->last), number);
        eina_strbuf_reset(ctx->number);
        _number_display(ctx);
index de3bd44..ade73e1 100644 (file)
@@ -7,6 +7,7 @@
 #include <Evas.h>
 #include <Elementary.h>
 
+#include "gui.h"
 #include "util.h"
 
 /* TODO: find a configurable way to format the number.
@@ -119,3 +120,25 @@ Evas_Object *picture_icon_get(Evas_Object *parent, const char *picture)
        }
        return icon;
 }
+
+static void _dial_reply(void *data, OFono_Error err,
+                       OFono_Call *call __UNUSED__)
+{
+       char *number = data;
+
+       if (err != OFONO_ERROR_NONE) {
+               char buf[1024];
+               const char *msg = ofono_error_message_get(err);
+               snprintf(buf, sizeof(buf), "Could not call %s: %s",
+                               number, msg);
+               gui_simple_popup("Error", buf);
+       }
+
+       free(number);
+}
+
+OFono_Pending *dial(const char *number)
+{
+       char *copy = strdup(number);
+       return ofono_dial(copy, NULL, _dial_reply, copy);
+}
index ee23986..774612f 100644 (file)
@@ -8,10 +8,14 @@
 #define MONTH ((DAY) * 30)
 #define YEAR ((MONTH) *12)
 
+#include "ofono.h"
+
 char *phone_format(const char *number);
 
 char *date_format(time_t date);
 
 Evas_Object *picture_icon_get(Evas_Object *parent, const char *picture);
 
+OFono_Pending *dial(const char *number);
+
 #endif