Add agl-service-homescreen-2017
[apps/agl-service-homescreen.git] / doc / api-ref / latex / d0 / d8a / libhomescreen_8cpp.tex
1 \hypertarget{libhomescreen_8cpp}{}\section{libhomescreen/libhomescreen.cpp File Reference}
2 \label{libhomescreen_8cpp}\index{libhomescreen/libhomescreen.\+cpp@{libhomescreen/libhomescreen.\+cpp}}
3 {\ttfamily \#include $<$stdarg.\+h$>$}\newline
4 {\ttfamily \#include $<$sys/socket.\+h$>$}\newline
5 {\ttfamily \#include $<$iostream$>$}\newline
6 {\ttfamily \#include $<$algorithm$>$}\newline
7 {\ttfamily \#include $<$thread$>$}\newline
8 {\ttfamily \#include $<$errno.\+h$>$}\newline
9 {\ttfamily \#include $<$cassert$>$}\newline
10 {\ttfamily \#include $<$cctype$>$}\newline
11 {\ttfamily \#include $<$cerrno$>$}\newline
12 {\ttfamily \#include $<$cstdio$>$}\newline
13 {\ttfamily \#include $<$cstdlib$>$}\newline
14 {\ttfamily \#include $<$cstring$>$}\newline
15 {\ttfamily \#include $<$libhomescreen/libhomescreen.\+hpp$>$}\newline
16 \subsection*{Macros}
17 \begin{DoxyCompactItemize}
18 \item 
19 \#define \hyperlink{libhomescreen_8cpp_a797aa3053bd6a29819d44f8fad8a5eca}{E\+L\+OG}(args, ...)~\hyperlink{libhomescreen_8cpp_af583e7770fe13e35089388a45eaf9d9d}{\+\_\+\+E\+L\+OG}(\+\_\+\+\_\+\+F\+U\+N\+C\+T\+I\+O\+N\+\_\+\+\_\+,\+\_\+\+\_\+\+L\+I\+N\+E\+\_\+\+\_\+,args,\#\#\+\_\+\+\_\+\+V\+A\+\_\+\+A\+R\+G\+S\+\_\+\+\_\+)
20 \item 
21 \#define \hyperlink{libhomescreen_8cpp_a4e42b2f5af2174dd24f958351becf63d}{D\+L\+OG}(args, ...)~\hyperlink{libhomescreen_8cpp_a7639744c63851d916fb673963e234124}{\+\_\+\+D\+L\+OG}(\+\_\+\+\_\+\+F\+U\+N\+C\+T\+I\+O\+N\+\_\+\+\_\+,\+\_\+\+\_\+\+L\+I\+N\+E\+\_\+\+\_\+,args,\#\#\+\_\+\+\_\+\+V\+A\+\_\+\+A\+R\+G\+S\+\_\+\+\_\+)
22 \end{DoxyCompactItemize}
23 \subsection*{Functions}
24 \begin{DoxyCompactItemize}
25 \item 
26 static void \hyperlink{libhomescreen_8cpp_a7639744c63851d916fb673963e234124}{\+\_\+\+D\+L\+OG} (const char $\ast$func, const int line, const char $\ast$log,...)
27 \item 
28 static void \hyperlink{libhomescreen_8cpp_af583e7770fe13e35089388a45eaf9d9d}{\+\_\+\+E\+L\+OG} (const char $\ast$func, const int line, const char $\ast$log,...)
29 \item 
30 static bool \hyperlink{libhomescreen_8cpp_a7a2176c3d71fec0f09dcb2aa0866b17e}{has\+\_\+verb} (const string \&verb)
31 \item 
32 static void \hyperlink{libhomescreen_8cpp_a73c05b96c151e5e46c28585ccb143c1c}{\+\_\+on\+\_\+hangup\+\_\+static} (void $\ast$closure, struct afb\+\_\+wsj1 $\ast$wsj)
33 \item 
34 static void \hyperlink{libhomescreen_8cpp_a782a05fde0f1c17e0c4c8f972a3f53c8}{\+\_\+on\+\_\+call\+\_\+static} (void $\ast$closure, const char $\ast$api, const char $\ast$verb, struct afb\+\_\+wsj1\+\_\+msg $\ast$msg)
35 \item 
36 static void \hyperlink{libhomescreen_8cpp_a3df86185aa9453726556da201d95a6f9}{\+\_\+on\+\_\+event\+\_\+static} (void $\ast$closure, const char $\ast$\hyperlink{structevent}{event}, struct afb\+\_\+wsj1\+\_\+msg $\ast$msg)
37 \item 
38 static void \hyperlink{libhomescreen_8cpp_a7778933bffa862c63fa0a1b8219faa8b}{\+\_\+on\+\_\+reply\+\_\+static} (void $\ast$closure, struct afb\+\_\+wsj1\+\_\+msg $\ast$msg)
39 \item 
40 static void $\ast$ \hyperlink{libhomescreen_8cpp_aa73353e1bf62c68b6b0aba7a1e4e275e}{event\+\_\+loop\+\_\+run} (void $\ast$args)
41 \end{DoxyCompactItemize}
42 \subsection*{Variables}
43 \begin{DoxyCompactItemize}
44 \item 
45 static const char \hyperlink{libhomescreen_8cpp_a1e2d6e77dd8f0162f830058579eab42f}{A\+PI} \mbox{[}$\,$\mbox{]} = \char`\"{}homescreen\char`\"{}
46 \end{DoxyCompactItemize}
47
48
49 \subsection{Macro Definition Documentation}
50 \mbox{\Hypertarget{libhomescreen_8cpp_a4e42b2f5af2174dd24f958351becf63d}\label{libhomescreen_8cpp_a4e42b2f5af2174dd24f958351becf63d}} 
51 \index{libhomescreen.\+cpp@{libhomescreen.\+cpp}!D\+L\+OG@{D\+L\+OG}}
52 \index{D\+L\+OG@{D\+L\+OG}!libhomescreen.\+cpp@{libhomescreen.\+cpp}}
53 \subsubsection{\texorpdfstring{D\+L\+OG}{DLOG}}
54 {\footnotesize\ttfamily \#define D\+L\+OG(\begin{DoxyParamCaption}\item[{}]{args,  }\item[{}]{... }\end{DoxyParamCaption})~\hyperlink{libhomescreen_8cpp_a7639744c63851d916fb673963e234124}{\+\_\+\+D\+L\+OG}(\+\_\+\+\_\+\+F\+U\+N\+C\+T\+I\+O\+N\+\_\+\+\_\+,\+\_\+\+\_\+\+L\+I\+N\+E\+\_\+\+\_\+,args,\#\#\+\_\+\+\_\+\+V\+A\+\_\+\+A\+R\+G\+S\+\_\+\+\_\+)}
55
56
57
58 Definition at line 33 of file libhomescreen.\+cpp.
59
60 \mbox{\Hypertarget{libhomescreen_8cpp_a797aa3053bd6a29819d44f8fad8a5eca}\label{libhomescreen_8cpp_a797aa3053bd6a29819d44f8fad8a5eca}} 
61 \index{libhomescreen.\+cpp@{libhomescreen.\+cpp}!E\+L\+OG@{E\+L\+OG}}
62 \index{E\+L\+OG@{E\+L\+OG}!libhomescreen.\+cpp@{libhomescreen.\+cpp}}
63 \subsubsection{\texorpdfstring{E\+L\+OG}{ELOG}}
64 {\footnotesize\ttfamily \#define E\+L\+OG(\begin{DoxyParamCaption}\item[{}]{args,  }\item[{}]{... }\end{DoxyParamCaption})~\hyperlink{libhomescreen_8cpp_af583e7770fe13e35089388a45eaf9d9d}{\+\_\+\+E\+L\+OG}(\+\_\+\+\_\+\+F\+U\+N\+C\+T\+I\+O\+N\+\_\+\+\_\+,\+\_\+\+\_\+\+L\+I\+N\+E\+\_\+\+\_\+,args,\#\#\+\_\+\+\_\+\+V\+A\+\_\+\+A\+R\+G\+S\+\_\+\+\_\+)}
65
66
67
68 Definition at line 32 of file libhomescreen.\+cpp.
69
70
71
72 \subsection{Function Documentation}
73 \mbox{\Hypertarget{libhomescreen_8cpp_a7639744c63851d916fb673963e234124}\label{libhomescreen_8cpp_a7639744c63851d916fb673963e234124}} 
74 \index{libhomescreen.\+cpp@{libhomescreen.\+cpp}!\+\_\+\+D\+L\+OG@{\+\_\+\+D\+L\+OG}}
75 \index{\+\_\+\+D\+L\+OG@{\+\_\+\+D\+L\+OG}!libhomescreen.\+cpp@{libhomescreen.\+cpp}}
76 \subsubsection{\texorpdfstring{\+\_\+\+D\+L\+O\+G()}{\_DLOG()}}
77 {\footnotesize\ttfamily static void \+\_\+\+D\+L\+OG (\begin{DoxyParamCaption}\item[{const char $\ast$}]{func,  }\item[{const int}]{line,  }\item[{const char $\ast$}]{log,  }\item[{}]{... }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}
78
79
80
81 Definition at line 545 of file libhomescreen.\+cpp.
82
83
84 \begin{DoxyCode}
85 546 \{
86 547     \textcolor{keywordtype}{char} *message;
87 548     va\_list args;
88 549     va\_start(args, log);
89 550     \textcolor{keywordflow}{if} (log == NULL || vasprintf(&message, log, args) < 0)
90 551         message = NULL;
91 552     cout << \textcolor{stringliteral}{"[libhomescreen DEBUG]"} << func << \textcolor{stringliteral}{"("} << line << \textcolor{stringliteral}{"):"} << message << endl;
92 553     va\_end(args);
93 554     free(message);
94 555 \}
95 \end{DoxyCode}
96 \mbox{\Hypertarget{libhomescreen_8cpp_af583e7770fe13e35089388a45eaf9d9d}\label{libhomescreen_8cpp_af583e7770fe13e35089388a45eaf9d9d}} 
97 \index{libhomescreen.\+cpp@{libhomescreen.\+cpp}!\+\_\+\+E\+L\+OG@{\+\_\+\+E\+L\+OG}}
98 \index{\+\_\+\+E\+L\+OG@{\+\_\+\+E\+L\+OG}!libhomescreen.\+cpp@{libhomescreen.\+cpp}}
99 \subsubsection{\texorpdfstring{\+\_\+\+E\+L\+O\+G()}{\_ELOG()}}
100 {\footnotesize\ttfamily static void \+\_\+\+E\+L\+OG (\begin{DoxyParamCaption}\item[{const char $\ast$}]{func,  }\item[{const int}]{line,  }\item[{const char $\ast$}]{log,  }\item[{}]{... }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}
101
102
103
104 Definition at line 533 of file libhomescreen.\+cpp.
105
106
107 \begin{DoxyCode}
108 534 \{
109 535     \textcolor{keywordtype}{char} *message;
110 536     va\_list args;
111 537     va\_start(args, log);
112 538     \textcolor{keywordflow}{if} (log == NULL || vasprintf(&message, log, args) < 0)
113 539         message = NULL;
114 540     cout << \textcolor{stringliteral}{"[libhomescreen ERROR]"} << func << \textcolor{stringliteral}{"("} << line << \textcolor{stringliteral}{"):"} << message << endl;
115 541     va\_end(args);
116 542     free(message);
117 543 \}
118 \end{DoxyCode}
119 \mbox{\Hypertarget{libhomescreen_8cpp_a782a05fde0f1c17e0c4c8f972a3f53c8}\label{libhomescreen_8cpp_a782a05fde0f1c17e0c4c8f972a3f53c8}} 
120 \index{libhomescreen.\+cpp@{libhomescreen.\+cpp}!\+\_\+on\+\_\+call\+\_\+static@{\+\_\+on\+\_\+call\+\_\+static}}
121 \index{\+\_\+on\+\_\+call\+\_\+static@{\+\_\+on\+\_\+call\+\_\+static}!libhomescreen.\+cpp@{libhomescreen.\+cpp}}
122 \subsubsection{\texorpdfstring{\+\_\+on\+\_\+call\+\_\+static()}{\_on\_call\_static()}}
123 {\footnotesize\ttfamily static void \+\_\+on\+\_\+call\+\_\+static (\begin{DoxyParamCaption}\item[{void $\ast$}]{closure,  }\item[{const char $\ast$}]{api,  }\item[{const char $\ast$}]{verb,  }\item[{struct afb\+\_\+wsj1\+\_\+msg $\ast$}]{msg }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}
124
125
126
127 Definition at line 66 of file libhomescreen.\+cpp.
128
129
130 \begin{DoxyCode}
131 67 \{
132 68     \textcolor{comment}{/* LibHomeScreen is not called from other process */}
133 69 \}
134 \end{DoxyCode}
135 \mbox{\Hypertarget{libhomescreen_8cpp_a3df86185aa9453726556da201d95a6f9}\label{libhomescreen_8cpp_a3df86185aa9453726556da201d95a6f9}} 
136 \index{libhomescreen.\+cpp@{libhomescreen.\+cpp}!\+\_\+on\+\_\+event\+\_\+static@{\+\_\+on\+\_\+event\+\_\+static}}
137 \index{\+\_\+on\+\_\+event\+\_\+static@{\+\_\+on\+\_\+event\+\_\+static}!libhomescreen.\+cpp@{libhomescreen.\+cpp}}
138 \subsubsection{\texorpdfstring{\+\_\+on\+\_\+event\+\_\+static()}{\_on\_event\_static()}}
139 {\footnotesize\ttfamily static void \+\_\+on\+\_\+event\+\_\+static (\begin{DoxyParamCaption}\item[{void $\ast$}]{closure,  }\item[{const char $\ast$}]{event,  }\item[{struct afb\+\_\+wsj1\+\_\+msg $\ast$}]{msg }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}
140
141
142
143 Definition at line 71 of file libhomescreen.\+cpp.
144
145
146 \begin{DoxyCode}
147 72 \{
148 73     \textcolor{keyword}{static\_cast<}\hyperlink{class_lib_home_screen}{LibHomeScreen}*\textcolor{keyword}{>}(closure)->on\_event(NULL,\hyperlink{structevent}{event},msg);
149 74 \}
150 \end{DoxyCode}
151 \mbox{\Hypertarget{libhomescreen_8cpp_a73c05b96c151e5e46c28585ccb143c1c}\label{libhomescreen_8cpp_a73c05b96c151e5e46c28585ccb143c1c}} 
152 \index{libhomescreen.\+cpp@{libhomescreen.\+cpp}!\+\_\+on\+\_\+hangup\+\_\+static@{\+\_\+on\+\_\+hangup\+\_\+static}}
153 \index{\+\_\+on\+\_\+hangup\+\_\+static@{\+\_\+on\+\_\+hangup\+\_\+static}!libhomescreen.\+cpp@{libhomescreen.\+cpp}}
154 \subsubsection{\texorpdfstring{\+\_\+on\+\_\+hangup\+\_\+static()}{\_on\_hangup\_static()}}
155 {\footnotesize\ttfamily static void \+\_\+on\+\_\+hangup\+\_\+static (\begin{DoxyParamCaption}\item[{void $\ast$}]{closure,  }\item[{struct afb\+\_\+wsj1 $\ast$}]{wsj }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}
156
157 websocket 
158
159 Definition at line 61 of file libhomescreen.\+cpp.
160
161
162 \begin{DoxyCode}
163 62 \{
164 63     \textcolor{keyword}{static\_cast<}\hyperlink{class_lib_home_screen}{LibHomeScreen}*\textcolor{keyword}{>}(closure)->on\_hangup(NULL,wsj);
165 64 \}
166 \end{DoxyCode}
167 \mbox{\Hypertarget{libhomescreen_8cpp_a7778933bffa862c63fa0a1b8219faa8b}\label{libhomescreen_8cpp_a7778933bffa862c63fa0a1b8219faa8b}} 
168 \index{libhomescreen.\+cpp@{libhomescreen.\+cpp}!\+\_\+on\+\_\+reply\+\_\+static@{\+\_\+on\+\_\+reply\+\_\+static}}
169 \index{\+\_\+on\+\_\+reply\+\_\+static@{\+\_\+on\+\_\+reply\+\_\+static}!libhomescreen.\+cpp@{libhomescreen.\+cpp}}
170 \subsubsection{\texorpdfstring{\+\_\+on\+\_\+reply\+\_\+static()}{\_on\_reply\_static()}}
171 {\footnotesize\ttfamily static void \+\_\+on\+\_\+reply\+\_\+static (\begin{DoxyParamCaption}\item[{void $\ast$}]{closure,  }\item[{struct afb\+\_\+wsj1\+\_\+msg $\ast$}]{msg }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}
172
173
174
175 Definition at line 76 of file libhomescreen.\+cpp.
176
177
178 \begin{DoxyCode}
179 77 \{
180 78     \textcolor{keyword}{static\_cast<}\hyperlink{class_lib_home_screen}{LibHomeScreen}*\textcolor{keyword}{>}(closure)->on\_reply(NULL,msg);
181 79 \}
182 \end{DoxyCode}
183 \mbox{\Hypertarget{libhomescreen_8cpp_aa73353e1bf62c68b6b0aba7a1e4e275e}\label{libhomescreen_8cpp_aa73353e1bf62c68b6b0aba7a1e4e275e}} 
184 \index{libhomescreen.\+cpp@{libhomescreen.\+cpp}!event\+\_\+loop\+\_\+run@{event\+\_\+loop\+\_\+run}}
185 \index{event\+\_\+loop\+\_\+run@{event\+\_\+loop\+\_\+run}!libhomescreen.\+cpp@{libhomescreen.\+cpp}}
186 \subsubsection{\texorpdfstring{event\+\_\+loop\+\_\+run()}{event\_loop\_run()}}
187 {\footnotesize\ttfamily static void$\ast$ event\+\_\+loop\+\_\+run (\begin{DoxyParamCaption}\item[{void $\ast$}]{args }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}
188
189
190
191 Definition at line 204 of file libhomescreen.\+cpp.
192
193
194 \begin{DoxyCode}
195 205 \{
196 206     \textcolor{keyword}{struct }sd\_event* loop = (\textcolor{keyword}{struct }sd\_event*)(args);
197 207     \hyperlink{libhomescreen_8cpp_a4e42b2f5af2174dd24f958351becf63d}{DLOG}(\textcolor{stringliteral}{"start eventloop"});
198 208     \textcolor{keywordflow}{for}(;;)
199 209         sd\_event\_run(loop, 30000000);
200 210 \}
201 \end{DoxyCode}
202 \mbox{\Hypertarget{libhomescreen_8cpp_a7a2176c3d71fec0f09dcb2aa0866b17e}\label{libhomescreen_8cpp_a7a2176c3d71fec0f09dcb2aa0866b17e}} 
203 \index{libhomescreen.\+cpp@{libhomescreen.\+cpp}!has\+\_\+verb@{has\+\_\+verb}}
204 \index{has\+\_\+verb@{has\+\_\+verb}!libhomescreen.\+cpp@{libhomescreen.\+cpp}}
205 \subsubsection{\texorpdfstring{has\+\_\+verb()}{has\_verb()}}
206 {\footnotesize\ttfamily static bool has\+\_\+verb (\begin{DoxyParamCaption}\item[{const string \&}]{verb }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}
207
208
209
210 Definition at line 557 of file libhomescreen.\+cpp.
211
212
213 \begin{DoxyCode}
214 558 \{
215 559     \hyperlink{libhomescreen_8cpp_a4e42b2f5af2174dd24f958351becf63d}{DLOG}(\textcolor{stringliteral}{"verb is %s"}, verb.c\_str());
216 560     \textcolor{keywordflow}{if}(find(\hyperlink{class_lib_home_screen_a5593ff5ac78f6495ccb649904cf0ab08}{LibHomeScreen::api\_list}.begin(), 
217       \hyperlink{class_lib_home_screen_a5593ff5ac78f6495ccb649904cf0ab08}{LibHomeScreen::api\_list}.end(), verb) != 
218       \hyperlink{class_lib_home_screen_a5593ff5ac78f6495ccb649904cf0ab08}{LibHomeScreen::api\_list}.end())
219 561         \textcolor{keywordflow}{return} \textcolor{keyword}{true};
220 562     \textcolor{keywordflow}{else}
221 563         \textcolor{keywordflow}{return} \textcolor{keyword}{false};
222 564 \}
223 \end{DoxyCode}
224
225
226 \subsection{Variable Documentation}
227 \mbox{\Hypertarget{libhomescreen_8cpp_a1e2d6e77dd8f0162f830058579eab42f}\label{libhomescreen_8cpp_a1e2d6e77dd8f0162f830058579eab42f}} 
228 \index{libhomescreen.\+cpp@{libhomescreen.\+cpp}!A\+PI@{A\+PI}}
229 \index{A\+PI@{A\+PI}!libhomescreen.\+cpp@{libhomescreen.\+cpp}}
230 \subsubsection{\texorpdfstring{A\+PI}{API}}
231 {\footnotesize\ttfamily const char A\+PI\mbox{[}$\,$\mbox{]} = \char`\"{}homescreen\char`\"{}\hspace{0.3cm}{\ttfamily [static]}}
232
233
234
235 Definition at line 40 of file libhomescreen.\+cpp.
236