X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=doc%2Fapi-ref%2Fhtml%2Fde%2Fdd0%2Fclass_lib_home_screen.html;fp=doc%2Fapi-ref%2Fhtml%2Fde%2Fdd0%2Fclass_lib_home_screen.html;h=2181e107c80e40c0decf37c491d23ab6f05cc809;hb=599de8d3f35cb0fe56c7e27591862d61944b456b;hp=42548a65015a94afd63d4501bee2c3f48c879e69;hpb=26ec25e2f9271396328c208ae1a256fdf1a92c91;p=apps%2Fagl-service-homescreen.git diff --git a/doc/api-ref/html/de/dd0/class_lib_home_screen.html b/doc/api-ref/html/de/dd0/class_lib_home_screen.html index 42548a6..2181e10 100644 --- a/doc/api-ref/html/de/dd0/class_lib_home_screen.html +++ b/doc/api-ref/html/de/dd0/class_lib_home_screen.html @@ -73,11 +73,12 @@ $(function() {

Public Types

enum  EventType { Event_TapShortcut = 1, -Event_OnScreenMessage +Event_OnScreenMessage, +Event_OnScreenReply }   -using handler_func = std::function< void(const char *)> -  +using handler_func = std::function< void(json_object *)> +  @@ -91,13 +92,13 @@ Public Member Functions - - - + + + @@ -129,19 +130,19 @@ Static Public Attributes

Definition at line 32 of file libhomescreen.hpp.

Member Typedef Documentation

- -

◆ handler_func

+ +

◆ handler_func

Public Member Functions

 
int init (const int port, const std::string &token)
 
int runEventloop ()
 
int tapShortcut (const char *application_name)
 
int onScreenMessage (const char *display_message)
 
void set_event_handler (enum EventType et, handler_func f)
int onScreenReply (const char *reply_message)
 
void set_event_handler (enum EventType et, handler_func f)
 
void registerCallback (void(*event_cb)(const std::string &event, struct json_object *event_contents), void(*reply_cb)(struct json_object *reply_contents), void(*hangup_cb)(void)=nullptr)
 
- +
using LibHomeScreen::handler_func = std::function<void(const char*)>using LibHomeScreen::handler_func = std::function<void(json_object*)>
-

Definition at line 41 of file libhomescreen.hpp.

+

Definition at line 42 of file libhomescreen.hpp.

@@ -160,11 +161,13 @@ Static Public Attributes +
Enumerator
Event_TapShortcut 
Event_OnScreenMessage 
Event_OnScreenReply 
-

Definition at line 43 of file libhomescreen.hpp.

-
43  {
44  Event_TapShortcut = 1,
45  Event_OnScreenMessage
46  };
-
+

Definition at line 44 of file libhomescreen.hpp.

+
44  {
48  };
+ +
@@ -185,8 +188,8 @@ Static Public Attributes

constructor

-

Definition at line 85 of file libhomescreen.cpp.

-
86 {
87 
88 }
+

Definition at line 83 of file libhomescreen.cpp.

+
84 {
85 }
@@ -205,8 +208,8 @@ Static Public Attributes

destructor

-

Definition at line 93 of file libhomescreen.cpp.

-
94 {
95  if(mploop)
96  {
97  sd_event_unref(mploop);
98  }
99  if(sp_websock != NULL)
100  {
101  free(sp_websock);
102  }
103 }
+

Definition at line 90 of file libhomescreen.cpp.

+
91 {
92  if(mploop)
93  {
94  sd_event_unref(mploop);
95  }
96  if(sp_websock != NULL)
97  {
98  afb_wsj1_unref(sp_websock);
99  }
100 }
@@ -302,11 +305,11 @@ Static Public Attributes

Note

To call HomeScreen's APIs, the application should set its function name, arguments to JSON format.

-

Definition at line 369 of file libhomescreen.cpp.

-
370 {
371  int ret;
372  if(!sp_websock)
373  {
374  return -1;
375  }
376  if (!has_verb(string(verb)))
377  {
378  ELOG("verb doesn't exit");
379  return -1;
380  }
381  ret = afb_wsj1_call_j(sp_websock, API, verb, arg, _on_reply_static, this);
382  if (ret < 0) {
383  ELOG("Failed to call verb:%s",verb);
384  }
385  return ret;
386 }
static const char API[]
-
#define ELOG(args,...)
-
static bool has_verb(const string &verb)
-
static void _on_reply_static(void *closure, struct afb_wsj1_msg *msg)
+

Definition at line 360 of file libhomescreen.cpp.

+
361 {
362  int ret;
363  if(!sp_websock)
364  {
365  return -1;
366  }
367  if (!has_verb(string(verb)))
368  {
369  HMI_ERROR("libhomescreen","verb doesn't exit");
370  return -1;
371  }
372  ret = afb_wsj1_call_j(sp_websock, API, verb, arg, _on_reply_static, this);
373  if (ret < 0) {
374  HMI_ERROR("libhomescreen","Failed to call verb:%s",verb);
375  }
376  return ret;
377 }
#define HMI_ERROR(prefix, args,...)
Definition: hmi-debug.h:18
+
static const char API[]
+
static bool has_verb(const string &verb)
+
static void _on_reply_static(void *closure, struct afb_wsj1_msg *msg)
@@ -346,9 +349,9 @@ Static Public Attributes

Note

Use this constructor

-

Definition at line 119 of file libhomescreen.cpp.

-
120 {
121  int ret = 0;
122  if(port > 0 && token.size() > 0)
123  {
124  mport = port;
125  mtoken = token;
126  }
127  else
128  {
129  ELOG("port and token should be > 0, Initial port and token uses.");
130  }
131 
132  ret = initialize_websocket();
133  if(ret != 0 )
134  {
135  ELOG("Failed to initialize websocket");
136  }
137  else{
138  DLOG("Initialized");
139  }
140 
141  return ret;
142 }
#define DLOG(args,...)
-
#define ELOG(args,...)
+

Definition at line 116 of file libhomescreen.cpp.

+
117 {
118  int ret = 0;
119  if(port > 0 && token.size() > 0)
120  {
121  mport = port;
122  mtoken = token;
123  }
124  else
125  {
126  HMI_ERROR("libhomescreen","port and token should be > 0, Initial port and token uses.");
127  }
128 
129  ret = initialize_websocket();
130  if(ret != 0 )
131  {
132  HMI_ERROR("libhomescreen","Failed to initialize websocket");
133  }
134  else{
135  HMI_DEBUG("libhomescreen","Initialized");
136  }
137 
138  return ret;
139 }
#define HMI_ERROR(prefix, args,...)
Definition: hmi-debug.h:18
+
#define HMI_DEBUG(prefix, args,...)
Definition: hmi-debug.h:22
@@ -390,8 +393,8 @@ Static Public Attributes
-

Definition at line 457 of file libhomescreen.cpp.

-
458 {
459 }
+

Definition at line 448 of file libhomescreen.cpp.

+
449 {
450 }
@@ -426,12 +429,14 @@ Static Public Attributes
-

Definition at line 467 of file libhomescreen.cpp.

-
468 {
469  cout << "[libhomescreen on_event]: " << event << " (" << afb_wsj1_msg_object_s(msg) << ")" << endl;
470 
471  if (strstr(event, API) == NULL) {
472  return;
473  }
474 
475  struct json_object* ev_contents = afb_wsj1_msg_object_j(msg);
476  struct json_object *json_data = json_object_object_get(ev_contents, "data");
477 
478  if(onEvent != nullptr)
479  {
480  const string ev(event);
481  onEvent(ev, ev_contents);
482  }
483 
484  const char* event_only = strchr(event, '/');
485  if (event_only != nullptr) {
486  event_only = event_only + 1;
487  }
488 
489  if (strcasecmp(event_only, LibHomeScreen::event_list[0].c_str()) == 0) {
490  auto i = this->handlers.find(Event_TapShortcut);
491 
492  struct json_object *json_application_name = json_object_object_get(json_data, "application_name");
493  const char* application_name = json_object_get_string(json_application_name);
494 
495  if ( i != this->handlers.end() ) {
496  i->second(application_name);
497  }
498  }
499  else if (strcasecmp(event_only, LibHomeScreen::event_list[1].c_str()) == 0) {
500 
501  auto i = this->handlers.find(Event_OnScreenMessage);
502 
503  struct json_object *json_display_message = json_object_object_get(json_data, "display_message");
504  const char* display_message = json_object_get_string(json_display_message);
505 
506  if ( i != this->handlers.end() ) {
507  i->second(display_message);
508  }
509 
510  }
511 
512  json_object_put(ev_contents);
513 }
-
static const char API[]
- -
static const std::vector< std::string > event_list
- +

Definition at line 458 of file libhomescreen.cpp.

+
459 {
460  HMI_DEBUG("libhomescreen","event: (%s) msg: (%s).", event, afb_wsj1_msg_object_s(msg));
461 
462  if (strstr(event, API) == NULL) {
463  return;
464  }
465 
466  struct json_object* ev_contents = afb_wsj1_msg_object_j(msg);
467  struct json_object *json_data = json_object_object_get(ev_contents, "data");
468 
469  if(onEvent != nullptr)
470  {
471  const string ev(event);
472  onEvent(ev, ev_contents);
473  }
474 
475  const char* event_only = strchr(event, '/');
476  if (event_only != nullptr) {
477  event_only = event_only + 1;
478  }
479 
480  if (strcasecmp(event_only, LibHomeScreen::event_list[0].c_str()) == 0) {
481  auto i = this->handlers.find(Event_TapShortcut);
482  if ( i != this->handlers.end() ) {
483  i->second(json_data);
484  }
485  }
486  else if (strcasecmp(event_only, LibHomeScreen::event_list[1].c_str()) == 0) {
487  auto i = this->handlers.find(Event_OnScreenMessage);
488  if ( i != this->handlers.end() ) {
489  i->second(json_data);
490  }
491  }
492  else if (strcasecmp(event_only, LibHomeScreen::event_list[2].c_str()) == 0) {
493  auto i = this->handlers.find(Event_OnScreenReply);
494  if ( i != this->handlers.end() ) {
495  i->second(json_data);
496  }
497  }
498 
499  json_object_put(ev_contents);
500 }
#define HMI_DEBUG(prefix, args,...)
Definition: hmi-debug.h:22
+ +
static const char API[]
+ + +
static const std::vector< std::string > event_list
+
@@ -461,8 +466,8 @@ Static Public Attributes
-

Definition at line 448 of file libhomescreen.cpp.

-
449 {
450  DLOG("%s called", __FUNCTION__);
451  if(onHangup != nullptr)
452  {
453  onHangup();
454  }
455 }
#define DLOG(args,...)
+

Definition at line 439 of file libhomescreen.cpp.

+
440 {
441  HMI_DEBUG("libhomescreen","%s called", __FUNCTION__);
442  if(onHangup != nullptr)
443  {
444  onHangup();
445  }
446 }
#define HMI_DEBUG(prefix, args,...)
Definition: hmi-debug.h:22
@@ -493,8 +498,9 @@ Static Public Attributes

msg is like ({"response":{"verb":"subscribe","error":0},"jtype":"afb-reply","request":{"status":"success","info":"homescreen binder subscribe event name [on_screen_message]"}}) msg is like ({"response":{"verb":"tap_shortcut","error":0},"jtype":"afb-reply","request":{"status":"success","info":"afb_event_push event [tap_shortcut]"}})

-

Definition at line 519 of file libhomescreen.cpp.

-
520 {
521  cout << "[libhomescreen on_reply]: " << " (" << afb_wsj1_msg_object_s(msg) << ")" << endl;
522  if(onReply != nullptr)
523  {
524  struct json_object* reply = afb_wsj1_msg_object_j(msg);
525  onReply(reply);
526 
527  json_object_put(reply);
528  }
529 }
+

Definition at line 506 of file libhomescreen.cpp.

+
507 {
508  HMI_DEBUG("libhomescreen","msg: (%s)", afb_wsj1_msg_object_s(msg));
509  if(onReply != nullptr)
510  {
511  struct json_object* reply = afb_wsj1_msg_object_j(msg);
512  onReply(reply);
513 
514  json_object_put(reply);
515  }
516 }
#define HMI_DEBUG(prefix, args,...)
Definition: hmi-debug.h:22
+
@@ -512,19 +518,50 @@ Static Public Attributes
-

HomeScreenアプリに表示するメッセージイベントの発行

-

各アプリからHomeScreenアプリケーションのOnScreenに表示するイベントを発行する

+

Sending onScreen message event

+

Sending OnScreen message event to HomeScreen from applications

+

Parameters

+ +

Return

+ + +

Definition at line 244 of file libhomescreen.cpp.

+
245 {
246  if(!sp_websock)
247  {
248  return -1;
249  }
250 
251  struct json_object* j_obj = json_object_new_object();
252  struct json_object* val = json_object_new_string(display_message);
253  json_object_object_add(j_obj, "display_message", val);
254  return this->call("on_screen_message", j_obj);
255 }
int call(const std::string &verb, struct json_object *arg)
+
+
+ + +

◆ onScreenReply()

+ +
+
+ + + + + + + + +
int LibHomeScreen::onScreenReply (const char * reply_message)
+
+

Sending onScreen reply event

+

Sending OnScreen reply event to applications from HomeScreen

Parameters

Return

-

Definition at line 280 of file libhomescreen.cpp.

-
281 {
282  if(!sp_websock)
283  {
284  return -1;
285  }
286 
287  struct json_object* j_obj = json_object_new_object();
288  struct json_object* val = json_object_new_string(display_message);
289  json_object_object_add(j_obj, "display_message", val);
290  return this->call("on_screen_message", j_obj);
291 }
int call(const std::string &verb, struct json_object *arg)
+

Definition at line 268 of file libhomescreen.cpp.

+
269 {
270  if(!sp_websock)
271  {
272  return -1;
273  }
274 
275  struct json_object* j_obj = json_object_new_object();
276  struct json_object* val = json_object_new_string(reply_message);
277  json_object_object_add(j_obj, "reply_message", val);
278  return this->call("on_screen_reply", j_obj);
279 }
int call(const std::string &verb, struct json_object *arg)
@@ -596,37 +633,8 @@ Static Public Attributes

Note

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

-

Definition at line 158 of file libhomescreen.cpp.

-
162 {
163  onEvent = event_cb;
164  onReply = reply_cb;
165  onHangup = hangup_cb;
166 }
-
- - -

◆ runEventloop()

- -
-
- - - - - - - -
int LibHomeScreen::runEventloop ()
-
-

This function start receiving the reply/event message from home screen

-

Parameters

-

Nothing

-

Return

- -

Note

- -

Definition at line 224 of file libhomescreen.cpp.

-
225 {
226  if(mploop && sp_websock)
227  {
228  pthread_t thread_id;
229  int ret = pthread_create(&thread_id, NULL, event_loop_run, mploop);
230  if(ret != 0)
231  {
232  ELOG("Cannot run eventloop due to error:%d", errno);
233  return -1;
234  }
235  else
236  return thread_id;
237  }
238  else
239  {
240  ELOG("Connecting is not established yet");
241  return -1;
242  }
243 }
#define ELOG(args,...)
-
static void * event_loop_run(void *args)
-
+

Definition at line 155 of file libhomescreen.cpp.

+
159 {
160  onEvent = event_cb;
161  onReply = reply_cb;
162  onHangup = hangup_cb;
163 }
@@ -644,7 +652,7 @@ Static Public Attributes - handler_func  + handler_func  f  @@ -654,21 +662,22 @@ Static Public Attributes
-

イベントハンドラの登録

-

各アプリからHomeScreenアプリケーションのOnScreenに表示するイベントを発行する

+

Setting Event Handler

+

Setting event handler for Homescreen

Parameters

Return

Nothing

-

Definition at line 305 of file libhomescreen.cpp.

-
306 {
307  if (et >= 1 && et <= 2) {
308  switch (et) {
309  case Event_TapShortcut:
311  break;
314  break;
315  }
316 
317  this->handlers[et] = std::move(f);
318  }
319 }
-
int subscribe(const std::string &event_name)
-
static const std::vector< std::string > event_list
- +

Definition at line 293 of file libhomescreen.cpp.

+
294 {
295  if (et >= 1 && et <= 3) {
296  switch (et) {
297  case Event_TapShortcut:
299  break;
302  break;
303  case Event_OnScreenReply:
305  break;
306  }
307 
308  this->handlers[et] = std::move(f);
309  }
310 }
+ +
int subscribe(const std::string &event_name)
+
static const std::vector< std::string > event_list
+
@@ -699,10 +708,10 @@ Static Public Attributes

Note

This function enables to get an event to your callback function.

-

Definition at line 401 of file libhomescreen.cpp.

-
402 {
403  if(!sp_websock)
404  {
405  return -1;
406  }
407  struct json_object* j_obj = json_object_new_object();
408  json_object_object_add(j_obj, "event", json_object_new_string(event_name.c_str()));
409 
410  int ret = afb_wsj1_call_j(sp_websock, API, "subscribe", j_obj, _on_reply_static, this);
411  if (ret < 0) {
412  ELOG("Failed to call verb:%s",__FUNCTION__);
413  }
414  return ret;
415 }
static const char API[]
-
#define ELOG(args,...)
-
static void _on_reply_static(void *closure, struct afb_wsj1_msg *msg)
+

Definition at line 392 of file libhomescreen.cpp.

+
393 {
394  if(!sp_websock)
395  {
396  return -1;
397  }
398  struct json_object* j_obj = json_object_new_object();
399  json_object_object_add(j_obj, "event", json_object_new_string(event_name.c_str()));
400 
401  int ret = afb_wsj1_call_j(sp_websock, API, "subscribe", j_obj, _on_reply_static, this);
402  if (ret < 0) {
403  HMI_ERROR("libhomescreen","Failed to call verb:%s",__FUNCTION__);
404  }
405  return ret;
406 }
#define HMI_ERROR(prefix, args,...)
Definition: hmi-debug.h:18
+
static const char API[]
+
static void _on_reply_static(void *closure, struct afb_wsj1_msg *msg)
@@ -721,19 +730,19 @@ Static Public Attributes
-

ショートカットアイコンがタップされたイベントの発行

-

HomeScreenアプリケーションにて各アプリアイコンがタップされたときにイベントを発行する

+

Sending ShortCut Icon tapped event

+

When HomeScreen shortcut area is tapped, sending a event

Parameters

Return

-

Definition at line 256 of file libhomescreen.cpp.

-
257 {
258  if(!sp_websock)
259  {
260  return -1;
261  }
262 
263  struct json_object* j_obj = json_object_new_object();
264  struct json_object* val = json_object_new_string(application_name);
265  json_object_object_add(j_obj, "application_name", val);
266  return this->call("tap_shortcut", j_obj);
267 }
int call(const std::string &verb, struct json_object *arg)
+

Definition at line 220 of file libhomescreen.cpp.

+
221 {
222  if(!sp_websock)
223  {
224  return -1;
225  }
226 
227  struct json_object* j_obj = json_object_new_object();
228  struct json_object* val = json_object_new_string(application_name);
229  json_object_object_add(j_obj, "application_name", val);
230  return this->call("tap_shortcut", j_obj);
231 }
int call(const std::string &verb, struct json_object *arg)
@@ -764,10 +773,10 @@ Static Public Attributes

Note

This function disables to get an event to your callback function.

-

Definition at line 430 of file libhomescreen.cpp.

-
431 {
432  if(!sp_websock)
433  {
434  return -1;
435  }
436  struct json_object* j_obj = json_object_new_object();
437  json_object_object_add(j_obj, "event", json_object_new_string(event_name.c_str()));
438 
439  int ret = afb_wsj1_call_j(sp_websock, API, "unsubscribe", j_obj, _on_reply_static, this);
440  if (ret < 0) {
441  ELOG("Failed to call verb:%s",__FUNCTION__);
442  }
443  return ret;
444 }
static const char API[]
-
#define ELOG(args,...)
-
static void _on_reply_static(void *closure, struct afb_wsj1_msg *msg)
+

Definition at line 421 of file libhomescreen.cpp.

+
422 {
423  if(!sp_websock)
424  {
425  return -1;
426  }
427  struct json_object* j_obj = json_object_new_object();
428  json_object_object_add(j_obj, "event", json_object_new_string(event_name.c_str()));
429 
430  int ret = afb_wsj1_call_j(sp_websock, API, "unsubscribe", j_obj, _on_reply_static, this);
431  if (ret < 0) {
432  HMI_ERROR("libhomescreen","Failed to call verb:%s",__FUNCTION__);
433  }
434  return ret;
435 }
#define HMI_ERROR(prefix, args,...)
Definition: hmi-debug.h:18
+
static const char API[]
+
static void _on_reply_static(void *closure, struct afb_wsj1_msg *msg)
@@ -791,8 +800,8 @@ Static Public Attributes
-Initial value:
{
std::string("ping"),
std::string("tap_shortcut"),
std::string("on_screen_message"),
std::string("subscribe"),
std::string("unsubscribe")
}
-

Definition at line 48 of file libhomescreen.hpp.

+Initial value:
{
std::string("ping"),
std::string("tap_shortcut"),
std::string("on_screen_message"),
std::string("on_screen_reply"),
std::string("subscribe"),
std::string("unsubscribe")
}
+

Definition at line 50 of file libhomescreen.hpp.

@@ -815,13 +824,13 @@ Static Public Attributes
-Initial value:
{
std::string("tap_shortcut"),
std::string("on_screen_message"),
std::string("none")
}
-

Definition at line 49 of file libhomescreen.hpp.

+Initial value:
{
std::string("tap_shortcut"),
std::string("on_screen_message"),
std::string("on_screen_reply"),
std::string("none")
}
+

Definition at line 51 of file libhomescreen.hpp.


The documentation for this class was generated from the following files: