\hypertarget{connman-list-services_8c-example}{}\doxysection{connman-\/list-\/services.\+c}
Client to list networks/services from connman.


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{comment}{//Compile with:}}
\DoxyCodeLine{\textcolor{comment}{// gcc -\/o connman-\/list-\/services connman-\/list-\/services.c `pkg-\/config -\/-\/cflags -\/-\/libs eldbus ecore`}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#include "Eldbus.h"}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <Ecore.h>}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{on\_services\_get(\textcolor{keywordtype}{void} *data \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \textcolor{keyword}{const} \mbox{\hyperlink{group__Eldbus__Core_ga14e8c4d4b96af5fb8bb5c66dc315593a}{Eldbus\_Message}} *msg, \mbox{\hyperlink{group__Eldbus__Core_ga7a5d4dc070bd925034de6e52c4260be7}{Eldbus\_Pending}} *pending \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eldbus__Core_ga08a70c6651064414e56d75fba2232925}{Eldbus\_Message\_Iter}} *array, *entry;}
\DoxyCodeLine{   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *errname, *errmsg;}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (\mbox{\hyperlink{group__Eldbus__Message_ga3aeec7d275bef2bb244ed9a045540921}{eldbus\_message\_error\_get}}(msg, \&errname, \&errmsg))}
\DoxyCodeLine{     \{}
\DoxyCodeLine{        fprintf(stderr, \textcolor{stringliteral}{"Error: \%s \%s\(\backslash\)n"}, errname, errmsg);}
\DoxyCodeLine{        \textcolor{keywordflow}{return};}
\DoxyCodeLine{     \}}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (!\mbox{\hyperlink{group__Eldbus__Message_ga7aec6beec8e8a73982c7f43bd1322df8}{eldbus\_message\_arguments\_get}}(msg, \textcolor{stringliteral}{"a(oa\{sv\})"}, \&array))}
\DoxyCodeLine{     \{}
\DoxyCodeLine{        fprintf(stderr, \textcolor{stringliteral}{"Error: could not get array\(\backslash\)n"});}
\DoxyCodeLine{        \textcolor{keywordflow}{return};}
\DoxyCodeLine{     \}}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{while} (\mbox{\hyperlink{group__Eldbus__Message__Iter_ga45c7d707ee830ae5be39c17df05af615}{eldbus\_message\_iter\_get\_and\_next}}(array, \textcolor{charliteral}{'r'}, \&entry))}
\DoxyCodeLine{     \{}
\DoxyCodeLine{        \mbox{\hyperlink{group__Eldbus__Core_ga08a70c6651064414e56d75fba2232925}{Eldbus\_Message\_Iter}} *properties, *dict\_entry;}
\DoxyCodeLine{        \textcolor{keyword}{const} \textcolor{keywordtype}{char} *path;}
\DoxyCodeLine{}
\DoxyCodeLine{        \textcolor{keywordflow}{if} (!\mbox{\hyperlink{group__Eldbus__Message__Iter_gae44918ce0b571a30546219d1d5040da0}{eldbus\_message\_iter\_arguments\_get}}(entry, \textcolor{stringliteral}{"oa\{sv\}"}, \&path, \&properties))}
\DoxyCodeLine{          \{}
\DoxyCodeLine{             fprintf(stderr, \textcolor{stringliteral}{"Error: could not get entry contents\(\backslash\)n"});}
\DoxyCodeLine{             \textcolor{keywordflow}{return};}
\DoxyCodeLine{          \}}
\DoxyCodeLine{}
\DoxyCodeLine{        printf(\textcolor{stringliteral}{"service: \%s\(\backslash\)n"}, path);}
\DoxyCodeLine{}
\DoxyCodeLine{        \textcolor{keywordflow}{while} (\mbox{\hyperlink{group__Eldbus__Message__Iter_ga45c7d707ee830ae5be39c17df05af615}{eldbus\_message\_iter\_get\_and\_next}}(properties, \textcolor{charliteral}{'e'}, \&dict\_entry))}
\DoxyCodeLine{          \{}
\DoxyCodeLine{             \mbox{\hyperlink{group__Eldbus__Core_ga08a70c6651064414e56d75fba2232925}{Eldbus\_Message\_Iter}} *variant;}
\DoxyCodeLine{             \textcolor{keyword}{const} \textcolor{keywordtype}{char} *key;}
\DoxyCodeLine{}
\DoxyCodeLine{             \textcolor{keywordflow}{if} (!\mbox{\hyperlink{group__Eldbus__Message__Iter_gae44918ce0b571a30546219d1d5040da0}{eldbus\_message\_iter\_arguments\_get}}(dict\_entry, \textcolor{stringliteral}{"sv"}, \&key,}
\DoxyCodeLine{                                                      \&variant))}
\DoxyCodeLine{               \{}
\DoxyCodeLine{                  fprintf(stderr,}
\DoxyCodeLine{                          \textcolor{stringliteral}{"Error: could not get property contents\(\backslash\)n"});}
\DoxyCodeLine{                  \textcolor{keywordflow}{return};}
\DoxyCodeLine{               \}}
\DoxyCodeLine{}
\DoxyCodeLine{             printf(\textcolor{stringliteral}{"\(\backslash\)t\%s: type \%s\(\backslash\)n"}, key,}
\DoxyCodeLine{                    \mbox{\hyperlink{group__Eldbus__Message__Iter_gab0201e1d78d70477ba337d0aa2977802}{eldbus\_message\_iter\_signature\_get}}(variant));}
\DoxyCodeLine{}
\DoxyCodeLine{             \textcolor{comment}{/* TODO: get the value from variant */}}
\DoxyCodeLine{          \}}
\DoxyCodeLine{     \}}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordtype}{int}}
\DoxyCodeLine{main(\textcolor{keywordtype}{void})}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eldbus_ga1de8233c3e9240291bb952776810c831}{Eldbus\_Connection}} *conn;}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eldbus_gab374430ed25089e7c5213767cc637191}{Eldbus\_Object}} *obj;}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eldbus_ga82047f6a5efc1980ae445a898c2ed9c0}{Eldbus\_Proxy}} *manager;}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eldbus__Core_ga7a5d4dc070bd925034de6e52c4260be7}{Eldbus\_Pending}} *pending;}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Init__Group_ga77757609684a2c922dc5ec398274751b}{ecore\_init}}();}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eldbus__Core_gadd7c8b8a43b5dd590f7fd06166288754}{eldbus\_init}}();}
\DoxyCodeLine{}
\DoxyCodeLine{   conn = \mbox{\hyperlink{group__Eldbus__Conneciton_ga203ec794fc0c7e1bddce4eb18b628c04}{eldbus\_connection\_get}}(ELDBUS\_CONNECTION\_TYPE\_SYSTEM);}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (!conn)}
\DoxyCodeLine{     \{}
\DoxyCodeLine{        fprintf(stderr, \textcolor{stringliteral}{"Error: could not get system bus\(\backslash\)n"});}
\DoxyCodeLine{        \textcolor{keywordflow}{return} EXIT\_FAILURE;}
\DoxyCodeLine{     \}}
\DoxyCodeLine{}
\DoxyCodeLine{   obj = \mbox{\hyperlink{group__Eldbus__Object__Mapper_ga067d5c8eba2590fb58e7dc39de87d203}{eldbus\_object\_get}}(conn, \textcolor{stringliteral}{"net.connman"}, \textcolor{stringliteral}{"/"});}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (!obj)}
\DoxyCodeLine{     \{}
\DoxyCodeLine{        fprintf(stderr, \textcolor{stringliteral}{"Error: could not get object\(\backslash\)n"});}
\DoxyCodeLine{        \textcolor{keywordflow}{return} EXIT\_FAILURE;}
\DoxyCodeLine{     \}}
\DoxyCodeLine{}
\DoxyCodeLine{   manager = \mbox{\hyperlink{group__Eldbus__Proxy_ga58b8d61188435800e1e866ab3fdc7090}{eldbus\_proxy\_get}}(obj, \textcolor{stringliteral}{"net.connman.Manager"});}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (!manager)}
\DoxyCodeLine{     \{}
\DoxyCodeLine{        fprintf(stderr, \textcolor{stringliteral}{"Error: could not get proxy\(\backslash\)n"});}
\DoxyCodeLine{        \textcolor{keywordflow}{return} EXIT\_FAILURE;}
\DoxyCodeLine{     \}}
\DoxyCodeLine{}
\DoxyCodeLine{   pending = \mbox{\hyperlink{group__Eldbus__Proxy_ga0eaac8e928bd7605855bf61d97eea37c}{eldbus\_proxy\_call}}(manager, \textcolor{stringliteral}{"GetServices"}, on\_services\_get, NULL,}
\DoxyCodeLine{                              -\/1, \textcolor{stringliteral}{""});}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (!pending)}
\DoxyCodeLine{     \{}
\DoxyCodeLine{        fprintf(stderr, \textcolor{stringliteral}{"Error: could not call\(\backslash\)n"});}
\DoxyCodeLine{        \textcolor{keywordflow}{return} EXIT\_FAILURE;}
\DoxyCodeLine{     \}}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Main__Loop__Group_gaf103b9f668bb3e4fed12e52c6180132d}{ecore\_main\_loop\_begin}}();}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eldbus__Proxy_gab8b43f9e377544b987d2e0151c660aa7}{eldbus\_proxy\_unref}}(manager);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eldbus__Object__Mapper_gabf9de9a1f28df4a8b0b3b2cd416d647e}{eldbus\_object\_unref}}(obj);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eldbus__Conneciton_ga1c035aac8b601b416bba11d0d68f80ae}{eldbus\_connection\_unref}}(conn);}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eldbus__Core_ga255ee3e090da6704d009ee74ba9d8a79}{eldbus\_shutdown}}();}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Init__Group_ga768298b932f18d7e7593a447493e5cde}{ecore\_shutdown}}();}
\DoxyCodeLine{   \textcolor{keywordflow}{return} 0;}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\end{DoxyCodeInclude}
 