\hypertarget{ofono-dial_8c-example}{}\section{ofono-\/dial.\+c}
Client to ask o\+Fono to dial.


\begin{DoxyCodeInclude}
\textcolor{comment}{//Compile with:}
\textcolor{comment}{// gcc -o ofono-dial ofono-dial.c `pkg-config --cflags --libs eldbus ecore`}

\textcolor{preprocessor}{#include "Eldbus.h"}
\textcolor{preprocessor}{#include <Ecore.h>}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
on\_dial(\textcolor{keywordtype}{void} *data \hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}, \textcolor{keyword}{const} \hyperlink{group__Eldbus__Core_ga14e8c4d4b96af5fb8bb5c66dc315593a}{Eldbus\_Message} *msg, 
      \hyperlink{group__Eldbus__Core_ga7a5d4dc070bd925034de6e52c4260be7}{Eldbus\_Pending} *pending EINA\_UNUSED)
\{
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *errname, *errmsg;
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *call\_path;

   \textcolor{keywordflow}{if} (\hyperlink{group__Eldbus__Message_ga3aeec7d275bef2bb244ed9a045540921}{eldbus\_message\_error\_get}(msg, &errname, &errmsg))
     \{
        fprintf(stderr, \textcolor{stringliteral}{"Error: %s %s\(\backslash\)n"}, errname, errmsg);
        \textcolor{keywordflow}{return};
     \}

   \textcolor{keywordflow}{if} (!\hyperlink{group__Eldbus__Message_ga7aec6beec8e8a73982c7f43bd1322df8}{eldbus\_message\_arguments\_get}(msg, \textcolor{stringliteral}{"o"}, &call\_path))
     \{
        fprintf(stderr, \textcolor{stringliteral}{"Error: could not get call path\(\backslash\)n"});
        \textcolor{keywordflow}{return};
     \}

   printf(\textcolor{stringliteral}{"dialed! call path: %s\(\backslash\)n"}, call\_path);
\}

\textcolor{keywordtype}{int}
main(\textcolor{keywordtype}{int} argc, \textcolor{keywordtype}{char} *argv[])
\{
   \hyperlink{group__Eldbus__Core_ga5f0557a7e65ed263fcc1678874b8f7e7}{Eldbus\_Connection} *conn;
   \hyperlink{group__Eldbus__Core_ga49914ed24559a149426b5f2bb8294a06}{Eldbus\_Object} *obj;
   \hyperlink{group__Eldbus__Core_ga5598fdabe4f36f8c13ef7a07dc219a3c}{Eldbus\_Proxy} *manager;
   \hyperlink{group__Eldbus__Core_ga7a5d4dc070bd925034de6e52c4260be7}{Eldbus\_Pending} *pending;
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *number, *hide\_callerid;

   \textcolor{keywordflow}{if} (argc < 2)
     \{
        fprintf(stderr, \textcolor{stringliteral}{"Usage:\(\backslash\)n\(\backslash\)t%s <number> [hide\_callerid]\(\backslash\)n"}, argv[0]);
        \textcolor{keywordflow}{return} EXIT\_FAILURE;
     \}

   number = argv[1];
   hide\_callerid = (argc > 2) ? argv[2] : \textcolor{stringliteral}{""};

   \hyperlink{group__Ecore__Init__Group_ga77757609684a2c922dc5ec398274751b}{ecore\_init}();
   \hyperlink{group__Eldbus__Core_gadd7c8b8a43b5dd590f7fd06166288754}{eldbus\_init}();

   conn = \hyperlink{group__Eldbus__Conneciton_ga203ec794fc0c7e1bddce4eb18b628c04}{eldbus\_connection\_get}(ELDBUS\_CONNECTION\_TYPE\_SYSTEM);
   \textcolor{keywordflow}{if} (!conn)
     \{
        fprintf(stderr, \textcolor{stringliteral}{"Error: could not get system bus\(\backslash\)n"});
        \textcolor{keywordflow}{return} EXIT\_FAILURE;
     \}

   obj = \hyperlink{group__Eldbus__Object__Mapper_ga067d5c8eba2590fb58e7dc39de87d203}{eldbus\_object\_get}(conn, \textcolor{stringliteral}{"org.ofono"}, \textcolor{stringliteral}{"/"});
   \textcolor{keywordflow}{if} (!obj)
     \{
        fprintf(stderr, \textcolor{stringliteral}{"Error: could not get object\(\backslash\)n"});
        \textcolor{keywordflow}{return} EXIT\_FAILURE;
     \}

   manager = \hyperlink{group__Eldbus__Proxy_ga58b8d61188435800e1e866ab3fdc7090}{eldbus\_proxy\_get}(obj, \textcolor{stringliteral}{"org.ofono.Manager"});
   \textcolor{keywordflow}{if} (!manager)
     \{
        fprintf(stderr, \textcolor{stringliteral}{"Error: could not get proxy\(\backslash\)n"});
        \textcolor{keywordflow}{return} EXIT\_FAILURE;
     \}

   pending = \hyperlink{group__Eldbus__Proxy_ga0eaac8e928bd7605855bf61d97eea37c}{eldbus\_proxy\_call}(manager, \textcolor{stringliteral}{"Dial"}, on\_dial, NULL,
                              -1, \textcolor{stringliteral}{"ss"}, number, hide\_callerid);
   \textcolor{keywordflow}{if} (!pending)
     \{
        fprintf(stderr, \textcolor{stringliteral}{"Error: could not call\(\backslash\)n"});
        \textcolor{keywordflow}{return} EXIT\_FAILURE;
     \}

   \hyperlink{group__Ecore__Main__Loop__Group_gaf103b9f668bb3e4fed12e52c6180132d}{ecore\_main\_loop\_begin}();

   \hyperlink{group__Eldbus__Proxy_gab8b43f9e377544b987d2e0151c660aa7}{eldbus\_proxy\_unref}(manager);
   \hyperlink{group__Eldbus__Object__Mapper_gabf9de9a1f28df4a8b0b3b2cd416d647e}{eldbus\_object\_unref}(obj);
   \hyperlink{group__Eldbus__Conneciton_ga1c035aac8b601b416bba11d0d68f80ae}{eldbus\_connection\_unref}(conn);

   \hyperlink{group__Eldbus__Core_ga255ee3e090da6704d009ee74ba9d8a79}{eldbus\_shutdown}();
   \hyperlink{group__Ecore__Init__Group_ga768298b932f18d7e7593a447493e5cde}{ecore\_shutdown}();
   \textcolor{keywordflow}{return} 0;
\}

\end{DoxyCodeInclude}
 