summaryrefslogtreecommitdiff
path: root/src/examples/edbus/ofono-dial.c
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2012-12-28 17:53:25 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2012-12-28 17:53:25 +0000
commit331488d1ce3db2d07533ee276dabdc23f153fa61 (patch)
treea091fe83bfcf0c9d8f9f34ebfe44a5347537bff8 /src/examples/edbus/ofono-dial.c
parent6800b178dc918633ede220c572e5b99fa0046e7e (diff)
efl: merge edbus (v2).
SVN revision: 81825
Diffstat (limited to 'src/examples/edbus/ofono-dial.c')
-rw-r--r--src/examples/edbus/ofono-dial.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/src/examples/edbus/ofono-dial.c b/src/examples/edbus/ofono-dial.c
new file mode 100644
index 0000000000..5e833ddc4b
--- /dev/null
+++ b/src/examples/edbus/ofono-dial.c
@@ -0,0 +1,85 @@
1#include "EDBus.h"
2#include <Ecore.h>
3
4static void
5on_dial(void *data, const EDBus_Message *msg, EDBus_Pending *pending)
6{
7 const char *errname, *errmsg;
8 const char *call_path;
9
10 if (edbus_message_error_get(msg, &errname, &errmsg))
11 {
12 fprintf(stderr, "Error: %s %s\n", errname, errmsg);
13 return;
14 }
15
16 if (!edbus_message_arguments_get(msg, "o", &call_path))
17 {
18 fprintf(stderr, "Error: could not get call path\n");
19 return;
20 }
21
22 printf("dialed! call path: %s\n", call_path);
23}
24
25int
26main(int argc, char *argv[])
27{
28 EDBus_Connection *conn;
29 EDBus_Object *obj;
30 EDBus_Proxy *manager;
31 EDBus_Pending *pending;
32 const char *number, *hide_callerid;
33
34 if (argc < 2)
35 {
36 fprintf(stderr, "Usage:\n\t%s <number> [hide_callerid]\n", argv[0]);
37 return EXIT_FAILURE;
38 }
39
40 number = argv[1];
41 hide_callerid = (argc > 2) ? argv[2] : "";
42
43 ecore_init();
44 edbus_init();
45
46 conn = edbus_connection_get(EDBUS_CONNECTION_TYPE_SYSTEM);
47 if (!conn)
48 {
49 fprintf(stderr, "Error: could not get system bus\n");
50 return EXIT_FAILURE;
51 }
52
53 obj = edbus_object_get(conn, "org.ofono", "/");
54 if (!obj)
55 {
56 fprintf(stderr, "Error: could not get object\n");
57 return EXIT_FAILURE;
58 }
59
60 manager = edbus_proxy_get(obj, "org.ofono.Manager");
61 if (!manager)
62 {
63 fprintf(stderr, "Error: could not get proxy\n");
64 return EXIT_FAILURE;
65 }
66
67 pending = edbus_proxy_call(manager, "Dial", on_dial, NULL,
68 -1, "ss", number, hide_callerid);
69 if (!pending)
70 {
71 fprintf(stderr, "Error: could not call\n");
72 return EXIT_FAILURE;
73 }
74
75 ecore_main_loop_begin();
76
77 edbus_proxy_unref(manager);
78 edbus_object_unref(obj);
79 edbus_connection_unref(conn);
80
81 edbus_shutdown();
82 ecore_shutdown();
83 return 0;
84}
85