1 \hypertarget{class_lib_home_screen}{}\section{Lib\+Home\+Screen Class Reference}
2 \label{class_lib_home_screen}\index{Lib\+Home\+Screen@{Lib\+Home\+Screen}}
5 {\ttfamily \#include $<$libhomescreen.\+hpp$>$}
7 \subsection*{Public Types}
8 \begin{DoxyCompactItemize}
10 enum \hyperlink{class_lib_home_screen_a82616c91ac211d2ad08e709b524bf154}{Event\+Type} \{ \hyperlink{class_lib_home_screen_a82616c91ac211d2ad08e709b524bf154a4b0a82d501e4db5fbfe25c254c92896f}{Event\+\_\+\+Tap\+Shortcut} = 1,
11 \hyperlink{class_lib_home_screen_a82616c91ac211d2ad08e709b524bf154aea56fa32a124a8ddcbea127755280a1d}{Event\+\_\+\+On\+Screen\+Message}
14 using \hyperlink{class_lib_home_screen_ae99dee1e03d494d59d26c9f17078e01f}{handler\+\_\+func} = std\+::function$<$ void(const char $\ast$)$>$
15 \end{DoxyCompactItemize}
16 \subsection*{Public Member Functions}
17 \begin{DoxyCompactItemize}
19 \hyperlink{class_lib_home_screen_a724bd949c4154fad041f96a15ef0f5dc}{Lib\+Home\+Screen} ()
21 \hyperlink{class_lib_home_screen_a249902aebf71a5383ca8ec6ae558d095}{$\sim$\+Lib\+Home\+Screen} ()
23 \hyperlink{class_lib_home_screen_a0fff2f703c8ce184eb9edd133e0f4137}{Lib\+Home\+Screen} (const \hyperlink{class_lib_home_screen}{Lib\+Home\+Screen} \&)=delete
25 \hyperlink{class_lib_home_screen}{Lib\+Home\+Screen} \& \hyperlink{class_lib_home_screen_a23bc17798453cfca50904562736f6b25}{operator=} (const \hyperlink{class_lib_home_screen}{Lib\+Home\+Screen} \&)=delete
27 int \hyperlink{class_lib_home_screen_a6a57b573cc767725762ba9beab032220}{init} (const int port, const std\+::string \&token)
29 int \hyperlink{class_lib_home_screen_a32d3282898d0f04151c24b4103511e00}{run\+Eventloop} ()
31 int \hyperlink{class_lib_home_screen_afb571c9577087b47065eb23e7fdbc903}{tap\+Shortcut} (const char $\ast$application\+\_\+name)
33 int \hyperlink{class_lib_home_screen_ac336482036a72b51a822725f1929523c}{on\+Screen\+Message} (const char $\ast$display\+\_\+message)
35 void \hyperlink{class_lib_home_screen_ab1b0e08bf35415de9064afed899e9f85}{set\+\_\+event\+\_\+handler} (enum \hyperlink{class_lib_home_screen_a82616c91ac211d2ad08e709b524bf154}{Event\+Type} et, \hyperlink{class_lib_home_screen_ae99dee1e03d494d59d26c9f17078e01f}{handler\+\_\+func} f)
37 void \hyperlink{class_lib_home_screen_a2789e8a5372202cc36f48e71dbb9b7cf}{register\+Callback} (void($\ast$event\+\_\+cb)(const std\+::string \&\hyperlink{structevent}{event}, struct json\+\_\+object $\ast$event\+\_\+contents), void($\ast$reply\+\_\+cb)(struct json\+\_\+object $\ast$reply\+\_\+contents), void($\ast$hangup\+\_\+cb)(void)=nullptr)
39 int \hyperlink{class_lib_home_screen_a527b49dcfe581be6275d0eb2236ba37f}{call} (const std\+::string \&verb, struct json\+\_\+object $\ast$arg)
41 int \hyperlink{class_lib_home_screen_ab5e8e8ab7d53e0f114e9e907fcbb7643}{call} (const char $\ast$verb, struct json\+\_\+object $\ast$arg)
43 int \hyperlink{class_lib_home_screen_aa4c189807b75d070f567967f0d690738}{subscribe} (const std\+::string \&event\+\_\+name)
45 int \hyperlink{class_lib_home_screen_aac03a45cbd453ba69ddb00c1016930a6}{unsubscribe} (const std\+::string \&event\+\_\+name)
47 void \hyperlink{class_lib_home_screen_ab1c1fa69f24b981e824dd9fb810c4b74}{on\+\_\+hangup} (void $\ast$closure, struct afb\+\_\+wsj1 $\ast$wsj)
49 void \hyperlink{class_lib_home_screen_a608638eb87b2772a3dcc92d8ca8f3596}{on\+\_\+call} (void $\ast$closure, const char $\ast$api, const char $\ast$verb, struct afb\+\_\+wsj1\+\_\+msg $\ast$msg)
51 void \hyperlink{class_lib_home_screen_a9c4885b51b43ab24a548d49fb3ab2de3}{on\+\_\+event} (void $\ast$closure, const char $\ast$\hyperlink{structevent}{event}, struct afb\+\_\+wsj1\+\_\+msg $\ast$msg)
53 void \hyperlink{class_lib_home_screen_a248d9648c6186287a7632ec1c75fc9c5}{on\+\_\+reply} (void $\ast$closure, struct afb\+\_\+wsj1\+\_\+msg $\ast$msg)
54 \end{DoxyCompactItemize}
55 \subsection*{Static Public Attributes}
56 \begin{DoxyCompactItemize}
58 static const std\+::vector$<$ std\+::string $>$ \hyperlink{class_lib_home_screen_a5593ff5ac78f6495ccb649904cf0ab08}{api\+\_\+list}
60 static const std\+::vector$<$ std\+::string $>$ \hyperlink{class_lib_home_screen_a6a6d8a4d33a006a08652e7377a4c29e9}{event\+\_\+list}
61 \end{DoxyCompactItemize}
64 \subsection{Detailed Description}
67 Definition at line 32 of file libhomescreen.\+hpp.
71 \subsection{Member Typedef Documentation}
72 \mbox{\Hypertarget{class_lib_home_screen_ae99dee1e03d494d59d26c9f17078e01f}\label{class_lib_home_screen_ae99dee1e03d494d59d26c9f17078e01f}}
73 \index{Lib\+Home\+Screen@{Lib\+Home\+Screen}!handler\+\_\+func@{handler\+\_\+func}}
74 \index{handler\+\_\+func@{handler\+\_\+func}!Lib\+Home\+Screen@{Lib\+Home\+Screen}}
75 \subsubsection{\texorpdfstring{handler\+\_\+func}{handler\_func}}
76 {\footnotesize\ttfamily using \hyperlink{class_lib_home_screen_ae99dee1e03d494d59d26c9f17078e01f}{Lib\+Home\+Screen\+::handler\+\_\+func} = std\+::function$<$void(const char$\ast$)$>$}
80 Definition at line 41 of file libhomescreen.\+hpp.
84 \subsection{Member Enumeration Documentation}
85 \mbox{\Hypertarget{class_lib_home_screen_a82616c91ac211d2ad08e709b524bf154}\label{class_lib_home_screen_a82616c91ac211d2ad08e709b524bf154}}
86 \index{Lib\+Home\+Screen@{Lib\+Home\+Screen}!Event\+Type@{Event\+Type}}
87 \index{Event\+Type@{Event\+Type}!Lib\+Home\+Screen@{Lib\+Home\+Screen}}
88 \subsubsection{\texorpdfstring{Event\+Type}{EventType}}
89 {\footnotesize\ttfamily enum \hyperlink{class_lib_home_screen_a82616c91ac211d2ad08e709b524bf154}{Lib\+Home\+Screen\+::\+Event\+Type}}
91 \begin{DoxyEnumFields}{Enumerator}
92 \raisebox{\heightof{T}}[0pt][0pt]{\index{Event\+\_\+\+Tap\+Shortcut@{Event\+\_\+\+Tap\+Shortcut}!Lib\+Home\+Screen@{Lib\+Home\+Screen}}\index{Lib\+Home\+Screen@{Lib\+Home\+Screen}!Event\+\_\+\+Tap\+Shortcut@{Event\+\_\+\+Tap\+Shortcut}}}\mbox{\Hypertarget{class_lib_home_screen_a82616c91ac211d2ad08e709b524bf154a4b0a82d501e4db5fbfe25c254c92896f}\label{class_lib_home_screen_a82616c91ac211d2ad08e709b524bf154a4b0a82d501e4db5fbfe25c254c92896f}}
93 Event\+\_\+\+Tap\+Shortcut&\\
96 \raisebox{\heightof{T}}[0pt][0pt]{\index{Event\+\_\+\+On\+Screen\+Message@{Event\+\_\+\+On\+Screen\+Message}!Lib\+Home\+Screen@{Lib\+Home\+Screen}}\index{Lib\+Home\+Screen@{Lib\+Home\+Screen}!Event\+\_\+\+On\+Screen\+Message@{Event\+\_\+\+On\+Screen\+Message}}}\mbox{\Hypertarget{class_lib_home_screen_a82616c91ac211d2ad08e709b524bf154aea56fa32a124a8ddcbea127755280a1d}\label{class_lib_home_screen_a82616c91ac211d2ad08e709b524bf154aea56fa32a124a8ddcbea127755280a1d}}
97 Event\+\_\+\+On\+Screen\+Message&\\
103 Definition at line 43 of file libhomescreen.\+hpp.
108 44 \hyperlink{class_lib_home_screen_a82616c91ac211d2ad08e709b524bf154a4b0a82d501e4db5fbfe25c254c92896f}{Event\_TapShortcut} = 1,
109 45 \hyperlink{class_lib_home_screen_a82616c91ac211d2ad08e709b524bf154aea56fa32a124a8ddcbea127755280a1d}{Event\_OnScreenMessage}
114 \subsection{Constructor \& Destructor Documentation}
115 \mbox{\Hypertarget{class_lib_home_screen_a724bd949c4154fad041f96a15ef0f5dc}\label{class_lib_home_screen_a724bd949c4154fad041f96a15ef0f5dc}}
116 \index{Lib\+Home\+Screen@{Lib\+Home\+Screen}!Lib\+Home\+Screen@{Lib\+Home\+Screen}}
117 \index{Lib\+Home\+Screen@{Lib\+Home\+Screen}!Lib\+Home\+Screen@{Lib\+Home\+Screen}}
118 \subsubsection{\texorpdfstring{Lib\+Home\+Screen()}{LibHomeScreen()}\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
119 {\footnotesize\ttfamily Lib\+Home\+Screen\+::\+Lib\+Home\+Screen (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}
123 Definition at line 85 of file libhomescreen.\+cpp.
131 \mbox{\Hypertarget{class_lib_home_screen_a249902aebf71a5383ca8ec6ae558d095}\label{class_lib_home_screen_a249902aebf71a5383ca8ec6ae558d095}}
132 \index{Lib\+Home\+Screen@{Lib\+Home\+Screen}!````~Lib\+Home\+Screen@{$\sim$\+Lib\+Home\+Screen}}
133 \index{````~Lib\+Home\+Screen@{$\sim$\+Lib\+Home\+Screen}!Lib\+Home\+Screen@{Lib\+Home\+Screen}}
134 \subsubsection{\texorpdfstring{$\sim$\+Lib\+Home\+Screen()}{~LibHomeScreen()}}
135 {\footnotesize\ttfamily Lib\+Home\+Screen\+::$\sim$\+Lib\+Home\+Screen (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}
139 Definition at line 93 of file libhomescreen.\+cpp.
144 95 \textcolor{keywordflow}{if}(mploop)
146 97 sd\_event\_unref(mploop);
148 99 \textcolor{keywordflow}{if}(sp\_websock != NULL)
150 101 free(sp\_websock);
154 \mbox{\Hypertarget{class_lib_home_screen_a0fff2f703c8ce184eb9edd133e0f4137}\label{class_lib_home_screen_a0fff2f703c8ce184eb9edd133e0f4137}}
155 \index{Lib\+Home\+Screen@{Lib\+Home\+Screen}!Lib\+Home\+Screen@{Lib\+Home\+Screen}}
156 \index{Lib\+Home\+Screen@{Lib\+Home\+Screen}!Lib\+Home\+Screen@{Lib\+Home\+Screen}}
157 \subsubsection{\texorpdfstring{Lib\+Home\+Screen()}{LibHomeScreen()}\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
158 {\footnotesize\ttfamily Lib\+Home\+Screen\+::\+Lib\+Home\+Screen (\begin{DoxyParamCaption}\item[{const \hyperlink{class_lib_home_screen}{Lib\+Home\+Screen} \&}]{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [delete]}}
162 \subsection{Member Function Documentation}
163 \mbox{\Hypertarget{class_lib_home_screen_a527b49dcfe581be6275d0eb2236ba37f}\label{class_lib_home_screen_a527b49dcfe581be6275d0eb2236ba37f}}
164 \index{Lib\+Home\+Screen@{Lib\+Home\+Screen}!call@{call}}
165 \index{call@{call}!Lib\+Home\+Screen@{Lib\+Home\+Screen}}
166 \subsubsection{\texorpdfstring{call()}{call()}\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
167 {\footnotesize\ttfamily int Lib\+Home\+Screen\+::call (\begin{DoxyParamCaption}\item[{const std\+::string \&}]{verb, }\item[{struct json\+\_\+object $\ast$}]{arg }\end{DoxyParamCaption})}
169 \mbox{\Hypertarget{class_lib_home_screen_ab5e8e8ab7d53e0f114e9e907fcbb7643}\label{class_lib_home_screen_ab5e8e8ab7d53e0f114e9e907fcbb7643}}
170 \index{Lib\+Home\+Screen@{Lib\+Home\+Screen}!call@{call}}
171 \index{call@{call}!Lib\+Home\+Screen@{Lib\+Home\+Screen}}
172 \subsubsection{\texorpdfstring{call()}{call()}\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
173 {\footnotesize\ttfamily int Lib\+Home\+Screen\+::call (\begin{DoxyParamCaption}\item[{const char $\ast$}]{verb, }\item[{struct json\+\_\+object $\ast$}]{arg }\end{DoxyParamCaption})}
175 This function calls the A\+PI of Home\+Screen via Web\+Socket This function is overload function of \char`\"{}call\char`\"{}
177 \subparagraph*{Parameters}
181 \item verb \mbox{[}in\mbox{]} \+: This argument should be specified to the A\+PI name (e.\+g. \char`\"{}tap\+\_\+shortcut\char`\"{})
182 \item arg \mbox{[}in\mbox{]} \+: This argument should be specified to the argument of A\+PI. And this argument expects J\+S\+ON object
185 \subparagraph*{Return}
189 \item Returns 0 on success or -\/1 in case of error.
194 To call Home\+Screen\textquotesingle{}s A\+P\+Is, the application should set its function name, arguments to J\+S\+ON format.
196 Definition at line 369 of file libhomescreen.\+cpp.
201 371 \textcolor{keywordtype}{int} ret;
202 372 \textcolor{keywordflow}{if}(!sp\_websock)
204 374 \textcolor{keywordflow}{return} -1;
206 376 \textcolor{keywordflow}{if} (!\hyperlink{libhomescreen_8cpp_a7a2176c3d71fec0f09dcb2aa0866b17e}{has\_verb}(\textcolor{keywordtype}{string}(verb)))
208 378 \hyperlink{libhomescreen_8cpp_a797aa3053bd6a29819d44f8fad8a5eca}{ELOG}(\textcolor{stringliteral}{"verb doesn't exit"});
209 379 \textcolor{keywordflow}{return} -1;
211 381 ret = afb\_wsj1\_call\_j(sp\_websock, \hyperlink{libhomescreen_8cpp_a1e2d6e77dd8f0162f830058579eab42f}{API}, verb, arg, \hyperlink{libhomescreen_8cpp_a7778933bffa862c63fa0a1b8219faa8b}{\_on\_reply\_static}, \textcolor{keyword}{this});
212 382 \textcolor{keywordflow}{if} (ret < 0) \{
213 383 \hyperlink{libhomescreen_8cpp_a797aa3053bd6a29819d44f8fad8a5eca}{ELOG}(\textcolor{stringliteral}{"Failed to call verb:%s"},verb);
215 385 \textcolor{keywordflow}{return} ret;
218 \mbox{\Hypertarget{class_lib_home_screen_a6a57b573cc767725762ba9beab032220}\label{class_lib_home_screen_a6a57b573cc767725762ba9beab032220}}
219 \index{Lib\+Home\+Screen@{Lib\+Home\+Screen}!init@{init}}
220 \index{init@{init}!Lib\+Home\+Screen@{Lib\+Home\+Screen}}
221 \subsubsection{\texorpdfstring{init()}{init()}}
222 {\footnotesize\ttfamily int Lib\+Home\+Screen\+::init (\begin{DoxyParamCaption}\item[{const int}]{port, }\item[{const std\+::string \&}]{token }\end{DoxyParamCaption})}
224 This function is initializer
226 \subparagraph*{Parameters}
230 \item port \mbox{[}in\mbox{]} \+: This argument should be specified to the port number to be used for websocket
231 \item token \mbox{[}in\mbox{]} \+: This argument should be specified to the token to be used for websocket
234 \subparagraph*{Return}
242 Definition at line 119 of file libhomescreen.\+cpp.
247 121 \textcolor{keywordtype}{int} ret = 0;
248 122 \textcolor{keywordflow}{if}(port > 0 && token.size() > 0)
253 127 \textcolor{keywordflow}{else}
255 129 \hyperlink{libhomescreen_8cpp_a797aa3053bd6a29819d44f8fad8a5eca}{ELOG}(\textcolor{stringliteral}{"port and token should be > 0, Initial port and token uses."});
258 132 ret = initialize\_websocket();
259 133 \textcolor{keywordflow}{if}(ret != 0 )
261 135 \hyperlink{libhomescreen_8cpp_a797aa3053bd6a29819d44f8fad8a5eca}{ELOG}(\textcolor{stringliteral}{"Failed to initialize websocket"});
263 137 \textcolor{keywordflow}{else}\{
264 138 \hyperlink{libhomescreen_8cpp_a4e42b2f5af2174dd24f958351becf63d}{DLOG}(\textcolor{stringliteral}{"Initialized"});
267 141 \textcolor{keywordflow}{return} ret;
270 \mbox{\Hypertarget{class_lib_home_screen_a608638eb87b2772a3dcc92d8ca8f3596}\label{class_lib_home_screen_a608638eb87b2772a3dcc92d8ca8f3596}}
271 \index{Lib\+Home\+Screen@{Lib\+Home\+Screen}!on\+\_\+call@{on\+\_\+call}}
272 \index{on\+\_\+call@{on\+\_\+call}!Lib\+Home\+Screen@{Lib\+Home\+Screen}}
273 \subsubsection{\texorpdfstring{on\+\_\+call()}{on\_call()}}
274 {\footnotesize\ttfamily void Lib\+Home\+Screen\+::on\+\_\+call (\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})}
278 Definition at line 457 of file libhomescreen.\+cpp.
285 \mbox{\Hypertarget{class_lib_home_screen_a9c4885b51b43ab24a548d49fb3ab2de3}\label{class_lib_home_screen_a9c4885b51b43ab24a548d49fb3ab2de3}}
286 \index{Lib\+Home\+Screen@{Lib\+Home\+Screen}!on\+\_\+event@{on\+\_\+event}}
287 \index{on\+\_\+event@{on\+\_\+event}!Lib\+Home\+Screen@{Lib\+Home\+Screen}}
288 \subsubsection{\texorpdfstring{on\+\_\+event()}{on\_event()}}
289 {\footnotesize\ttfamily void Lib\+Home\+Screen\+::on\+\_\+event (\begin{DoxyParamCaption}\item[{void $\ast$}]{closure, }\item[{const char $\ast$}]{event, }\item[{struct afb\+\_\+wsj1\+\_\+msg $\ast$}]{msg }\end{DoxyParamCaption})}
293 Definition at line 467 of file libhomescreen.\+cpp.
298 469 cout << \textcolor{stringliteral}{"[libhomescreen on\_event]: "} << \textcolor{keyword}{event} << \textcolor{stringliteral}{" ("} << afb\_wsj1\_msg\_object\_s(msg) << \textcolor{stringliteral}{")"} << endl;
300 471 \textcolor{keywordflow}{if} (strstr(\hyperlink{structevent}{event}, \hyperlink{libhomescreen_8cpp_a1e2d6e77dd8f0162f830058579eab42f}{API}) == NULL) \{
301 472 \textcolor{keywordflow}{return};
304 475 \textcolor{keyword}{struct }json\_object* ev\_contents = afb\_wsj1\_msg\_object\_j(msg);
305 476 \textcolor{keyword}{struct }json\_object *json\_data = json\_object\_object\_get(ev\_contents, \textcolor{stringliteral}{"data"});
307 478 \textcolor{keywordflow}{if}(onEvent != \textcolor{keyword}{nullptr})
309 480 \textcolor{keyword}{const} \textcolor{keywordtype}{string} ev(\hyperlink{structevent}{event});
310 481 onEvent(ev, ev\_contents);
313 484 \textcolor{keyword}{const} \textcolor{keywordtype}{char}* event\_only = strchr(\hyperlink{structevent}{event}, \textcolor{charliteral}{'/'});
314 485 \textcolor{keywordflow}{if} (event\_only != \textcolor{keyword}{nullptr}) \{
315 486 event\_only = event\_only + 1;
318 489 \textcolor{keywordflow}{if} (strcasecmp(event\_only, \hyperlink{class_lib_home_screen_a6a6d8a4d33a006a08652e7377a4c29e9}{LibHomeScreen::event\_list}[0].c\_str()) == 0) \{
319 490 \textcolor{keyword}{auto} i = this->handlers.find(\hyperlink{class_lib_home_screen_a82616c91ac211d2ad08e709b524bf154a4b0a82d501e4db5fbfe25c254c92896f}{Event\_TapShortcut});
321 492 \textcolor{keyword}{struct }json\_object *json\_application\_name = json\_object\_object\_get(json\_data, \textcolor{stringliteral}{"application\_name"});
322 493 \textcolor{keyword}{const} \textcolor{keywordtype}{char}* application\_name = json\_object\_get\_string(json\_application\_name);
324 495 \textcolor{keywordflow}{if} ( i != this->handlers.end() ) \{
325 496 i->second(application\_name);
328 499 \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (strcasecmp(event\_only, \hyperlink{class_lib_home_screen_a6a6d8a4d33a006a08652e7377a4c29e9}{LibHomeScreen::event\_list}[1].c\_str()) == 0) \{
330 501 \textcolor{keyword}{auto} i = this->handlers.find(\hyperlink{class_lib_home_screen_a82616c91ac211d2ad08e709b524bf154aea56fa32a124a8ddcbea127755280a1d}{Event\_OnScreenMessage});
332 503 \textcolor{keyword}{struct }json\_object *json\_display\_message = json\_object\_object\_get(json\_data, \textcolor{stringliteral}{"display\_message"});
333 504 \textcolor{keyword}{const} \textcolor{keywordtype}{char}* display\_message = json\_object\_get\_string(json\_display\_message);
335 506 \textcolor{keywordflow}{if} ( i != this->handlers.end() ) \{
336 507 i->second(display\_message);
341 512 json\_object\_put(ev\_contents);
344 \mbox{\Hypertarget{class_lib_home_screen_ab1c1fa69f24b981e824dd9fb810c4b74}\label{class_lib_home_screen_ab1c1fa69f24b981e824dd9fb810c4b74}}
345 \index{Lib\+Home\+Screen@{Lib\+Home\+Screen}!on\+\_\+hangup@{on\+\_\+hangup}}
346 \index{on\+\_\+hangup@{on\+\_\+hangup}!Lib\+Home\+Screen@{Lib\+Home\+Screen}}
347 \subsubsection{\texorpdfstring{on\+\_\+hangup()}{on\_hangup()}}
348 {\footnotesize\ttfamily void Lib\+Home\+Screen\+::on\+\_\+hangup (\begin{DoxyParamCaption}\item[{void $\ast$}]{closure, }\item[{struct afb\+\_\+wsj1 $\ast$}]{wsj }\end{DoxyParamCaption})}
352 Definition at line 448 of file libhomescreen.\+cpp.
357 450 \hyperlink{libhomescreen_8cpp_a4e42b2f5af2174dd24f958351becf63d}{DLOG}(\textcolor{stringliteral}{"%s called"}, \_\_FUNCTION\_\_);
358 451 \textcolor{keywordflow}{if}(onHangup != \textcolor{keyword}{nullptr})
364 \mbox{\Hypertarget{class_lib_home_screen_a248d9648c6186287a7632ec1c75fc9c5}\label{class_lib_home_screen_a248d9648c6186287a7632ec1c75fc9c5}}
365 \index{Lib\+Home\+Screen@{Lib\+Home\+Screen}!on\+\_\+reply@{on\+\_\+reply}}
366 \index{on\+\_\+reply@{on\+\_\+reply}!Lib\+Home\+Screen@{Lib\+Home\+Screen}}
367 \subsubsection{\texorpdfstring{on\+\_\+reply()}{on\_reply()}}
368 {\footnotesize\ttfamily void Lib\+Home\+Screen\+::on\+\_\+reply (\begin{DoxyParamCaption}\item[{void $\ast$}]{closure, }\item[{struct afb\+\_\+wsj1\+\_\+msg $\ast$}]{msg }\end{DoxyParamCaption})}
370 msg is like (\{\char`\"{}response\char`\"{}\+:\{\char`\"{}verb\char`\"{}\+:\char`\"{}subscribe\char`\"{},\char`\"{}error\char`\"{}\+:0\},\char`\"{}jtype\char`\"{}\+:\char`\"{}afb-\/reply\char`\"{},\char`\"{}request\char`\"{}\+:\{\char`\"{}status\char`\"{}\+:\char`\"{}success\char`\"{},\char`\"{}info\char`\"{}\+:\char`\"{}homescreen binder subscribe event name \mbox{[}on\+\_\+screen\+\_\+message\mbox{]}\char`\"{}\}\}) msg is like (\{\char`\"{}response\char`\"{}\+:\{\char`\"{}verb\char`\"{}\+:\char`\"{}tap\+\_\+shortcut\char`\"{},\char`\"{}error\char`\"{}\+:0\},\char`\"{}jtype\char`\"{}\+:\char`\"{}afb-\/reply\char`\"{},\char`\"{}request\char`\"{}\+:\{\char`\"{}status\char`\"{}\+:\char`\"{}success\char`\"{},\char`\"{}info\char`\"{}\+:\char`\"{}afb\+\_\+event\+\_\+push event \mbox{[}tap\+\_\+shortcut\mbox{]}\char`\"{}\}\})
372 Definition at line 519 of file libhomescreen.\+cpp.
377 521 cout << \textcolor{stringliteral}{"[libhomescreen on\_reply]: "} << \textcolor{stringliteral}{" ("} << afb\_wsj1\_msg\_object\_s(msg) << \textcolor{stringliteral}{")"} << endl;
378 522 \textcolor{keywordflow}{if}(onReply != \textcolor{keyword}{nullptr})
380 524 \textcolor{keyword}{struct }json\_object* reply = afb\_wsj1\_msg\_object\_j(msg);
383 527 json\_object\_put(reply);
387 \mbox{\Hypertarget{class_lib_home_screen_ac336482036a72b51a822725f1929523c}\label{class_lib_home_screen_ac336482036a72b51a822725f1929523c}}
388 \index{Lib\+Home\+Screen@{Lib\+Home\+Screen}!on\+Screen\+Message@{on\+Screen\+Message}}
389 \index{on\+Screen\+Message@{on\+Screen\+Message}!Lib\+Home\+Screen@{Lib\+Home\+Screen}}
390 \subsubsection{\texorpdfstring{on\+Screen\+Message()}{onScreenMessage()}}
391 {\footnotesize\ttfamily int Lib\+Home\+Screen\+::on\+Screen\+Message (\begin{DoxyParamCaption}\item[{const char $\ast$}]{display\+\_\+message }\end{DoxyParamCaption})}
393 Home\+Screenアプリに表示するメッセージイベントの発行
395 各アプリから\+Home\+Screenアプリケーションの\+On\+Screenに表示するイベントを発行する
397 \subparagraph*{Parameters}
401 \item display\+\_\+message \mbox{[}in\mbox{]} \+: 表示するメッセージ
404 \subparagraph*{Return}
408 \item Returns 0 on success or -\/1 in case of error.
411 Definition at line 280 of file libhomescreen.\+cpp.
416 282 \textcolor{keywordflow}{if}(!sp\_websock)
418 284 \textcolor{keywordflow}{return} -1;
421 287 \textcolor{keyword}{struct }json\_object* j\_obj = json\_object\_new\_object();
422 288 \textcolor{keyword}{struct }json\_object* val = json\_object\_new\_string(display\_message);
423 289 json\_object\_object\_add(j\_obj, \textcolor{stringliteral}{"display\_message"}, val);
424 290 \textcolor{keywordflow}{return} this->\hyperlink{class_lib_home_screen_a527b49dcfe581be6275d0eb2236ba37f}{call}(\textcolor{stringliteral}{"on\_screen\_message"}, j\_obj);
427 \mbox{\Hypertarget{class_lib_home_screen_a23bc17798453cfca50904562736f6b25}\label{class_lib_home_screen_a23bc17798453cfca50904562736f6b25}}
428 \index{Lib\+Home\+Screen@{Lib\+Home\+Screen}!operator=@{operator=}}
429 \index{operator=@{operator=}!Lib\+Home\+Screen@{Lib\+Home\+Screen}}
430 \subsubsection{\texorpdfstring{operator=()}{operator=()}}
431 {\footnotesize\ttfamily \hyperlink{class_lib_home_screen}{Lib\+Home\+Screen}\& Lib\+Home\+Screen\+::operator= (\begin{DoxyParamCaption}\item[{const \hyperlink{class_lib_home_screen}{Lib\+Home\+Screen} \&}]{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [delete]}}
433 \mbox{\Hypertarget{class_lib_home_screen_a2789e8a5372202cc36f48e71dbb9b7cf}\label{class_lib_home_screen_a2789e8a5372202cc36f48e71dbb9b7cf}}
434 \index{Lib\+Home\+Screen@{Lib\+Home\+Screen}!register\+Callback@{register\+Callback}}
435 \index{register\+Callback@{register\+Callback}!Lib\+Home\+Screen@{Lib\+Home\+Screen}}
436 \subsubsection{\texorpdfstring{register\+Callback()}{registerCallback()}}
437 {\footnotesize\ttfamily void Lib\+Home\+Screen\+::register\+Callback (\begin{DoxyParamCaption}\item[{void($\ast$)(const std\+::string \&\hyperlink{structevent}{event}, struct json\+\_\+object $\ast$event\+\_\+contents)}]{event\+\_\+cb, }\item[{void($\ast$)(struct json\+\_\+object $\ast$reply\+\_\+contents)}]{reply\+\_\+cb, }\item[{void($\ast$)(void)}]{hangup\+\_\+cb = {\ttfamily nullptr} }\end{DoxyParamCaption})}
439 This function register callback function for reply/event message from home screen
441 \subparagraph*{Parameters}
445 \item event\+\_\+cb \mbox{[}in\mbox{]} \+: This argument should be specified to the callback for subscribed event
446 \item reply\+\_\+cb \mbox{[}in\mbox{]} \+: This argument should be specified to the reply callback for call function
449 \subparagraph*{Return}
455 Event callback is invoked by home screen for event you subscribed. If you would like to get event, please call subscribe function before/after this function
457 Definition at line 158 of file libhomescreen.\+cpp.
462 163 onEvent = event\_cb;
463 164 onReply = reply\_cb;
464 165 onHangup = hangup\_cb;
467 \mbox{\Hypertarget{class_lib_home_screen_a32d3282898d0f04151c24b4103511e00}\label{class_lib_home_screen_a32d3282898d0f04151c24b4103511e00}}
468 \index{Lib\+Home\+Screen@{Lib\+Home\+Screen}!run\+Eventloop@{run\+Eventloop}}
469 \index{run\+Eventloop@{run\+Eventloop}!Lib\+Home\+Screen@{Lib\+Home\+Screen}}
470 \subsubsection{\texorpdfstring{run\+Eventloop()}{runEventloop()}}
471 {\footnotesize\ttfamily int Lib\+Home\+Screen\+::run\+Eventloop (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}
473 This function start receiving the reply/event message from home screen
475 \subparagraph*{Parameters}
479 \subparagraph*{Return}
483 \item Returns thread\+\_\+id on success or -\/1 in case of error.
488 Definition at line 224 of file libhomescreen.\+cpp.
493 226 \textcolor{keywordflow}{if}(mploop && sp\_websock)
495 228 pthread\_t thread\_id;
496 229 \textcolor{keywordtype}{int} ret = pthread\_create(&thread\_id, NULL, \hyperlink{libhomescreen_8cpp_aa73353e1bf62c68b6b0aba7a1e4e275e}{event\_loop\_run}, mploop);
497 230 \textcolor{keywordflow}{if}(ret != 0)
499 232 \hyperlink{libhomescreen_8cpp_a797aa3053bd6a29819d44f8fad8a5eca}{ELOG}(\textcolor{stringliteral}{"Cannot run eventloop due to error:%d"}, errno);
500 233 \textcolor{keywordflow}{return} -1;
502 235 \textcolor{keywordflow}{else}
503 236 \textcolor{keywordflow}{return} thread\_id;
505 238 \textcolor{keywordflow}{else}
507 240 \hyperlink{libhomescreen_8cpp_a797aa3053bd6a29819d44f8fad8a5eca}{ELOG}(\textcolor{stringliteral}{"Connecting is not established yet"});
508 241 \textcolor{keywordflow}{return} -1;
512 \mbox{\Hypertarget{class_lib_home_screen_ab1b0e08bf35415de9064afed899e9f85}\label{class_lib_home_screen_ab1b0e08bf35415de9064afed899e9f85}}
513 \index{Lib\+Home\+Screen@{Lib\+Home\+Screen}!set\+\_\+event\+\_\+handler@{set\+\_\+event\+\_\+handler}}
514 \index{set\+\_\+event\+\_\+handler@{set\+\_\+event\+\_\+handler}!Lib\+Home\+Screen@{Lib\+Home\+Screen}}
515 \subsubsection{\texorpdfstring{set\+\_\+event\+\_\+handler()}{set\_event\_handler()}}
516 {\footnotesize\ttfamily void Lib\+Home\+Screen\+::set\+\_\+event\+\_\+handler (\begin{DoxyParamCaption}\item[{enum \hyperlink{class_lib_home_screen_a82616c91ac211d2ad08e709b524bf154}{Event\+Type}}]{et, }\item[{\hyperlink{class_lib_home_screen_ae99dee1e03d494d59d26c9f17078e01f}{handler\+\_\+func}}]{f }\end{DoxyParamCaption})}
520 各アプリから\+Home\+Screenアプリケーションの\+On\+Screenに表示するイベントを発行する
522 \subparagraph*{Parameters}
526 \item et \mbox{[}in\mbox{]} \+: 対象のイベント
527 \item f \mbox{[}in\mbox{]} \+: イベントハンドラ
530 \subparagraph*{Return}
534 Definition at line 305 of file libhomescreen.\+cpp.
539 307 \textcolor{keywordflow}{if} (et >= 1 && et <= 2) \{
540 308 \textcolor{keywordflow}{switch} (et) \{
541 309 \textcolor{keywordflow}{case} \hyperlink{class_lib_home_screen_a82616c91ac211d2ad08e709b524bf154a4b0a82d501e4db5fbfe25c254c92896f}{Event\_TapShortcut}:
542 310 this->\hyperlink{class_lib_home_screen_aa4c189807b75d070f567967f0d690738}{subscribe}(\hyperlink{class_lib_home_screen_a6a6d8a4d33a006a08652e7377a4c29e9}{LibHomeScreen::event\_list}[0]);
543 311 \textcolor{keywordflow}{break};
544 312 \textcolor{keywordflow}{case} \hyperlink{class_lib_home_screen_a82616c91ac211d2ad08e709b524bf154aea56fa32a124a8ddcbea127755280a1d}{Event\_OnScreenMessage}:
545 313 this->\hyperlink{class_lib_home_screen_aa4c189807b75d070f567967f0d690738}{subscribe}(\hyperlink{class_lib_home_screen_a6a6d8a4d33a006a08652e7377a4c29e9}{LibHomeScreen::event\_list}[1]);
546 314 \textcolor{keywordflow}{break};
549 317 this->handlers[et] = std::move(f);
553 \mbox{\Hypertarget{class_lib_home_screen_aa4c189807b75d070f567967f0d690738}\label{class_lib_home_screen_aa4c189807b75d070f567967f0d690738}}
554 \index{Lib\+Home\+Screen@{Lib\+Home\+Screen}!subscribe@{subscribe}}
555 \index{subscribe@{subscribe}!Lib\+Home\+Screen@{Lib\+Home\+Screen}}
556 \subsubsection{\texorpdfstring{subscribe()}{subscribe()}}
557 {\footnotesize\ttfamily int Lib\+Home\+Screen\+::subscribe (\begin{DoxyParamCaption}\item[{const std\+::string \&}]{event\+\_\+name }\end{DoxyParamCaption})}
559 Register callback function for each event
561 \subparagraph*{Parameters}
565 \item event\+\_\+name \mbox{[}in\mbox{]} \+: This argument should be specified to the event name
568 \subparagraph*{Return}
572 \item Returns 0 on success or -\/1 in case of error.
577 This function enables to get an event to your callback function.
579 Definition at line 401 of file libhomescreen.\+cpp.
584 403 \textcolor{keywordflow}{if}(!sp\_websock)
586 405 \textcolor{keywordflow}{return} -1;
588 407 \textcolor{keyword}{struct }json\_object* j\_obj = json\_object\_new\_object();
589 408 json\_object\_object\_add(j\_obj, \textcolor{stringliteral}{"event"}, json\_object\_new\_string(event\_name.c\_str()));
591 410 \textcolor{keywordtype}{int} ret = afb\_wsj1\_call\_j(sp\_websock, \hyperlink{libhomescreen_8cpp_a1e2d6e77dd8f0162f830058579eab42f}{API}, \textcolor{stringliteral}{"subscribe"}, j\_obj,
592 \hyperlink{libhomescreen_8cpp_a7778933bffa862c63fa0a1b8219faa8b}{\_on\_reply\_static}, \textcolor{keyword}{this});
593 411 \textcolor{keywordflow}{if} (ret < 0) \{
594 412 \hyperlink{libhomescreen_8cpp_a797aa3053bd6a29819d44f8fad8a5eca}{ELOG}(\textcolor{stringliteral}{"Failed to call verb:%s"},\_\_FUNCTION\_\_);
596 414 \textcolor{keywordflow}{return} ret;
599 \mbox{\Hypertarget{class_lib_home_screen_afb571c9577087b47065eb23e7fdbc903}\label{class_lib_home_screen_afb571c9577087b47065eb23e7fdbc903}}
600 \index{Lib\+Home\+Screen@{Lib\+Home\+Screen}!tap\+Shortcut@{tap\+Shortcut}}
601 \index{tap\+Shortcut@{tap\+Shortcut}!Lib\+Home\+Screen@{Lib\+Home\+Screen}}
602 \subsubsection{\texorpdfstring{tap\+Shortcut()}{tapShortcut()}}
603 {\footnotesize\ttfamily int Lib\+Home\+Screen\+::tap\+Shortcut (\begin{DoxyParamCaption}\item[{const char $\ast$}]{application\+\_\+name }\end{DoxyParamCaption})}
605 ショートカットアイコンがタップされたイベントの発行
607 Home\+Screenアプリケーションにて各アプリアイコンがタップされたときにイベントを発行する
609 \subparagraph*{Parameters}
613 \item application\+\_\+name \mbox{[}in\mbox{]} \+: タップされたアプリケーションの名前(label)
616 \subparagraph*{Return}
620 \item Returns 0 on success or -\/1 in case of error.
623 Definition at line 256 of file libhomescreen.\+cpp.
628 258 \textcolor{keywordflow}{if}(!sp\_websock)
630 260 \textcolor{keywordflow}{return} -1;
633 263 \textcolor{keyword}{struct }json\_object* j\_obj = json\_object\_new\_object();
634 264 \textcolor{keyword}{struct }json\_object* val = json\_object\_new\_string(application\_name);
635 265 json\_object\_object\_add(j\_obj, \textcolor{stringliteral}{"application\_name"}, val);
636 266 \textcolor{keywordflow}{return} this->\hyperlink{class_lib_home_screen_a527b49dcfe581be6275d0eb2236ba37f}{call}(\textcolor{stringliteral}{"tap\_shortcut"}, j\_obj);
639 \mbox{\Hypertarget{class_lib_home_screen_aac03a45cbd453ba69ddb00c1016930a6}\label{class_lib_home_screen_aac03a45cbd453ba69ddb00c1016930a6}}
640 \index{Lib\+Home\+Screen@{Lib\+Home\+Screen}!unsubscribe@{unsubscribe}}
641 \index{unsubscribe@{unsubscribe}!Lib\+Home\+Screen@{Lib\+Home\+Screen}}
642 \subsubsection{\texorpdfstring{unsubscribe()}{unsubscribe()}}
643 {\footnotesize\ttfamily int Lib\+Home\+Screen\+::unsubscribe (\begin{DoxyParamCaption}\item[{const std\+::string \&}]{event\+\_\+name }\end{DoxyParamCaption})}
645 Unregister callback function for each event
647 \subparagraph*{Parameters}
651 \item event\+\_\+name \mbox{[}in\mbox{]} \+: This argument should be specified to the event name
654 \subparagraph*{Return}
658 \item Returns 0 on success or -\/1 in case of error.
663 This function disables to get an event to your callback function.
665 Definition at line 430 of file libhomescreen.\+cpp.
670 432 \textcolor{keywordflow}{if}(!sp\_websock)
672 434 \textcolor{keywordflow}{return} -1;
674 436 \textcolor{keyword}{struct }json\_object* j\_obj = json\_object\_new\_object();
675 437 json\_object\_object\_add(j\_obj, \textcolor{stringliteral}{"event"}, json\_object\_new\_string(event\_name.c\_str()));
677 439 \textcolor{keywordtype}{int} ret = afb\_wsj1\_call\_j(sp\_websock, \hyperlink{libhomescreen_8cpp_a1e2d6e77dd8f0162f830058579eab42f}{API}, \textcolor{stringliteral}{"unsubscribe"}, j\_obj,
678 \hyperlink{libhomescreen_8cpp_a7778933bffa862c63fa0a1b8219faa8b}{\_on\_reply\_static}, \textcolor{keyword}{this});
679 440 \textcolor{keywordflow}{if} (ret < 0) \{
680 441 \hyperlink{libhomescreen_8cpp_a797aa3053bd6a29819d44f8fad8a5eca}{ELOG}(\textcolor{stringliteral}{"Failed to call verb:%s"},\_\_FUNCTION\_\_);
682 443 \textcolor{keywordflow}{return} ret;
687 \subsection{Member Data Documentation}
688 \mbox{\Hypertarget{class_lib_home_screen_a5593ff5ac78f6495ccb649904cf0ab08}\label{class_lib_home_screen_a5593ff5ac78f6495ccb649904cf0ab08}}
689 \index{Lib\+Home\+Screen@{Lib\+Home\+Screen}!api\+\_\+list@{api\+\_\+list}}
690 \index{api\+\_\+list@{api\+\_\+list}!Lib\+Home\+Screen@{Lib\+Home\+Screen}}
691 \subsubsection{\texorpdfstring{api\+\_\+list}{api\_list}}
692 {\footnotesize\ttfamily const std\+::vector$<$ std\+::string $>$ Lib\+Home\+Screen\+::api\+\_\+list\hspace{0.3cm}{\ttfamily [static]}}
694 {\bfseries Initial value\+:}
697 std::string(\textcolor{stringliteral}{"ping"}),
698 std::string(\textcolor{stringliteral}{"tap\_shortcut"}),
699 std::string(\textcolor{stringliteral}{"on\_screen\_message"}),
700 std::string(\textcolor{stringliteral}{"subscribe"}),
701 std::string(\textcolor{stringliteral}{"unsubscribe"})
706 Definition at line 48 of file libhomescreen.\+hpp.
708 \mbox{\Hypertarget{class_lib_home_screen_a6a6d8a4d33a006a08652e7377a4c29e9}\label{class_lib_home_screen_a6a6d8a4d33a006a08652e7377a4c29e9}}
709 \index{Lib\+Home\+Screen@{Lib\+Home\+Screen}!event\+\_\+list@{event\+\_\+list}}
710 \index{event\+\_\+list@{event\+\_\+list}!Lib\+Home\+Screen@{Lib\+Home\+Screen}}
711 \subsubsection{\texorpdfstring{event\+\_\+list}{event\_list}}
712 {\footnotesize\ttfamily const std\+::vector$<$ std\+::string $>$ Lib\+Home\+Screen\+::event\+\_\+list\hspace{0.3cm}{\ttfamily [static]}}
714 {\bfseries Initial value\+:}
717 std::string(\textcolor{stringliteral}{"tap\_shortcut"}),
718 std::string(\textcolor{stringliteral}{"on\_screen\_message"}),
719 std::string(\textcolor{stringliteral}{"none"})
724 Definition at line 49 of file libhomescreen.\+hpp.
728 The documentation for this class was generated from the following files\+:\begin{DoxyCompactItemize}
730 include/libhomescreen/\hyperlink{libhomescreen_8hpp}{libhomescreen.\+hpp}\item
731 libhomescreen/\hyperlink{libhomescreen_8cpp}{libhomescreen.\+cpp}\end{DoxyCompactItemize}