HomeScreenBinding
Macros | Functions | Variables
homescreen.cpp File Reference
#include <memory>
#include <algorithm>
#include "hs-helper.h"
#include "hmi-debug.h"
#include "hs-clientmanager.h"

Go to the source code of this file.

Macros

#define _GNU_SOURCE
 

Functions

static void pingSample (afb_req_t request)
 
static void tap_shortcut (afb_req_t request)
 
static void on_screen_message (afb_req_t request)
 
static void on_screen_reply (afb_req_t request)
 
static void subscribe (afb_req_t request)
 
static void unsubscribe (afb_req_t request)
 
static void showWindow (afb_req_t request)
 
static void hideWindow (afb_req_t request)
 
static void replyShowWindow (afb_req_t request)
 
static void showNotification (afb_req_t request)
 
static void showInformation (afb_req_t request)
 
static int preinit (afb_api_t api)
 
static int init (afb_api_t api)
 
static void onevent (afb_api_t api, const char *event, struct json_object *object)
 

Variables

const char _error [] = "error"
 
const char _application_id [] = "application_id"
 
const char _display_message [] = "display_message"
 
const char _reply_message [] = "reply_message"
 
static HS_ClientManagerg_client_manager = HS_ClientManager::instance()
 
static const afb_verb_t verbs []
 
const afb_binding_t afbBindingExport
 

Macro Definition Documentation

#define _GNU_SOURCE

Definition at line 18 of file homescreen.cpp.

Function Documentation

static void hideWindow ( afb_req_t  request)
static

hideWindow event

Parameters

  • request : the request

Return

None

Definition at line 221 of file homescreen.cpp.

222 {
223  HMI_NOTICE("homescreen-service","called.");
224 
225  int ret = g_client_manager->hideWindow(request);
226  if (ret != 0) {
227  afb_req_fail_f(request, "failed", "called %s, Unknown parameter", __FUNCTION__);
228  return;
229  }
230 
231  // response to HomeScreen
232  struct json_object *res = json_object_new_object();
233  hs_add_object_to_json_object_func(res, __FUNCTION__, 2,
234  _error, ret);
235  afb_req_success(request, res, "afb_event_push event [hideWindow]");
236 }
int hideWindow(afb_req_t request)
#define HMI_NOTICE(prefix, args,...)
Definition: hmi-debug.h:40
const char _error[]
Definition: homescreen.cpp:27
static HS_ClientManager * g_client_manager
Definition: homescreen.cpp:32
void hs_add_object_to_json_object_func(struct json_object *j_obj, const char *verb_name, int count,...)
Definition: hs-helper.cpp:207
static int init ( afb_api_t  api)
static

homescreen binding init function

Parameters

  • api : the api serving the request

Return

None

Definition at line 368 of file homescreen.cpp.

369 {
370  HMI_NOTICE("homescreen-service","binding init");
371 
373 
374  return 0;
375 }
#define HMI_NOTICE(prefix, args,...)
Definition: hmi-debug.h:40
static HS_ClientManager * g_client_manager
Definition: homescreen.cpp:32
static void on_screen_message ( afb_req_t  request)
static

HomeScreen OnScreen message

Parameters

Request key

  • display_message : message for display

Return

None

Definition at line 85 of file homescreen.cpp.

86 {
87  HMI_NOTICE("homescreen-service","called.");
88 
89  int ret = g_client_manager->on_screen_message(request);
90  if (ret != 0) {
91  afb_req_fail_f(request, "failed", "called %s, Unknown parameter", __FUNCTION__);
92  return;
93  }
94 
95  // response to HomeScreen
96  struct json_object *res = json_object_new_object();
97  hs_add_object_to_json_object_func(res, __FUNCTION__, 2,
98  _error, ret);
99  afb_req_success(request, res, "afb_event_push event [on_screen_message]");
100 }
#define HMI_NOTICE(prefix, args,...)
Definition: hmi-debug.h:40
const char _error[]
Definition: homescreen.cpp:27
static HS_ClientManager * g_client_manager
Definition: homescreen.cpp:32
void hs_add_object_to_json_object_func(struct json_object *j_obj, const char *verb_name, int count,...)
Definition: hs-helper.cpp:207
int on_screen_message(afb_req_t request)
static void on_screen_reply ( afb_req_t  request)
static

HomeScreen OnScreen Reply

Parameters

Request key

  • reply_message : message for reply

Return

None

Definition at line 113 of file homescreen.cpp.

114 {
115  HMI_NOTICE("homescreen-service","called.");
116 
117  int ret = g_client_manager->on_screen_reply(request);
118  if (ret != 0) {
119  afb_req_fail_f(request, "failed", "called %s, Unknown parameter", __FUNCTION__);
120  return;
121  }
122 
123  // response to HomeScreen
124  struct json_object *res = json_object_new_object();
125  hs_add_object_to_json_object_func(res, __FUNCTION__, 2,
126  _error, ret);
127  afb_req_success(request, res, "afb_event_push event [on_screen_reply]");
128 }
int on_screen_reply(afb_req_t request)
#define HMI_NOTICE(prefix, args,...)
Definition: hmi-debug.h:40
const char _error[]
Definition: homescreen.cpp:27
static HS_ClientManager * g_client_manager
Definition: homescreen.cpp:32
void hs_add_object_to_json_object_func(struct json_object *j_obj, const char *verb_name, int count,...)
Definition: hs-helper.cpp:207
static void onevent ( afb_api_t  api,
const char *  event,
struct json_object *  object 
)
static

homescreen binding event function

Parameters

  • api : the api serving the request
  • event : event name
  • object : event json object

Return

None

Definition at line 389 of file homescreen.cpp.

390 {
391  HMI_NOTICE("homescreen-service","on_event %s", event);
392 }
#define HMI_NOTICE(prefix, args,...)
Definition: hmi-debug.h:40
static void pingSample ( afb_req_t  request)
static

Definition at line 38 of file homescreen.cpp.

39 {
40  static int pingcount = 0;
41  afb_req_success_f(request, json_object_new_int(pingcount), "Ping count = %d", pingcount);
42  HMI_NOTICE("homescreen-service","Verbosity macro at level notice invoked at ping invocation count = %d", pingcount);
43  pingcount++;
44 }
#define HMI_NOTICE(prefix, args,...)
Definition: hmi-debug.h:40
static int preinit ( afb_api_t  api)
static

homescreen binding preinit function

Parameters

  • api : the api serving the request

Return

None

Definition at line 352 of file homescreen.cpp.

353 {
354  HMI_NOTICE("homescreen-service","binding preinit (was register)");
355  return 0;
356 }
#define HMI_NOTICE(prefix, args,...)
Definition: hmi-debug.h:40
static void replyShowWindow ( afb_req_t  request)
static

replyShowWindow event

Parameters

  • request : the request

Return

None

Definition at line 248 of file homescreen.cpp.

249 {
250  HMI_NOTICE("homescreen-service","called.");
251 
252  int ret = g_client_manager->replyShowWindow(request);
253  if (ret != 0) {
254  afb_req_fail_f(request, "failed", "called %s, Unknown parameter", __FUNCTION__);
255  return;
256  }
257 
258  // response to HomeScreen
259  struct json_object *res = json_object_new_object();
260  hs_add_object_to_json_object_func(res, __FUNCTION__, 2,
261  _error, ret);
262  afb_req_success(request, res, "afb_event_push event [replyShowWindow]");
263 }
#define HMI_NOTICE(prefix, args,...)
Definition: hmi-debug.h:40
const char _error[]
Definition: homescreen.cpp:27
int replyShowWindow(afb_req_t request)
static HS_ClientManager * g_client_manager
Definition: homescreen.cpp:32
void hs_add_object_to_json_object_func(struct json_object *j_obj, const char *verb_name, int count,...)
Definition: hs-helper.cpp:207
static void showInformation ( afb_req_t  request)
static

showInformation event

the contents to homescreen which display at bottom area.

Parameters

  • request : the request

Return

None

Definition at line 306 of file homescreen.cpp.

307 {
308  HMI_NOTICE("homescreen-service","called.");
309 
310  int ret = g_client_manager->showInformation(request);
311  if (ret != 0) {
312  afb_req_fail_f(request, "failed", "called %s, Unknown parameter", __FUNCTION__);
313  return;
314  }
315 
316  // response to Application
317  struct json_object *res = json_object_new_object();
318  hs_add_object_to_json_object_func(res, __FUNCTION__, 2,
319  _error, ret);
320  afb_req_success(request, res, "afb_event_push event [showInformation]");
321 }
#define HMI_NOTICE(prefix, args,...)
Definition: hmi-debug.h:40
const char _error[]
Definition: homescreen.cpp:27
static HS_ClientManager * g_client_manager
Definition: homescreen.cpp:32
int showInformation(afb_req_t request)
void hs_add_object_to_json_object_func(struct json_object *j_obj, const char *verb_name, int count,...)
Definition: hs-helper.cpp:207
static void showNotification ( afb_req_t  request)
static

showNotification event

the contents to homescreen which display at top area.

Parameters

  • request : the request

Return

None

Definition at line 277 of file homescreen.cpp.

278 {
279  HMI_NOTICE("homescreen-service","called.");
280 
281  int ret = g_client_manager->showNotification(request);
282  if (ret != 0) {
283  afb_req_fail_f(request, "failed", "called %s, Unknown parameter", __FUNCTION__);
284  return;
285  }
286 
287  // response to Application
288  struct json_object *res = json_object_new_object();
289  hs_add_object_to_json_object_func(res, __FUNCTION__, 2,
290  _error, ret);
291  afb_req_success(request, res, "afb_event_push event [showNotification]");
292 }
#define HMI_NOTICE(prefix, args,...)
Definition: hmi-debug.h:40
const char _error[]
Definition: homescreen.cpp:27
static HS_ClientManager * g_client_manager
Definition: homescreen.cpp:32
void hs_add_object_to_json_object_func(struct json_object *j_obj, const char *verb_name, int count,...)
Definition: hs-helper.cpp:207
int showNotification(afb_req_t request)
static void showWindow ( afb_req_t  request)
static

showWindow event

Parameters

  • request : the request

Return

None

Definition at line 194 of file homescreen.cpp.

195 {
196  HMI_NOTICE("homescreen-service","called.");
197 
198  int ret = g_client_manager->showWindow(request);
199  if (ret != 0) {
200  afb_req_fail_f(request, "failed", "called %s, Unknown parameter", __FUNCTION__);
201  return;
202  }
203 
204  // response to HomeScreen
205  struct json_object *res = json_object_new_object();
206  hs_add_object_to_json_object_func(res, __FUNCTION__, 2,
207  _error, ret);
208  afb_req_success(request, res, "afb_event_push event [showWindow]");
209 }
#define HMI_NOTICE(prefix, args,...)
Definition: hmi-debug.h:40
int showWindow(afb_req_t request)
const char _error[]
Definition: homescreen.cpp:27
static HS_ClientManager * g_client_manager
Definition: homescreen.cpp:32
void hs_add_object_to_json_object_func(struct json_object *j_obj, const char *verb_name, int count,...)
Definition: hs-helper.cpp:207
static void subscribe ( afb_req_t  request)
static

Subscribe event

Parameters

Return

None

Definition at line 140 of file homescreen.cpp.

141 {
142  HMI_NOTICE("homescreen-service","called.");
143 
144  int ret = g_client_manager->subscribe(request);
145  if(ret) {
146  afb_req_fail_f(request, "afb_req_subscribe failed", "called %s.", __FUNCTION__);
147  return;
148  }
149 
150  /*create response json object*/
151  struct json_object *res = json_object_new_object();
152  hs_add_object_to_json_object_func(res, __FUNCTION__, 2,
153  _error, ret);
154  afb_req_success_f(request, res, "homescreen binder subscribe.");
155 }
int subscribe(afb_req_t request)
#define HMI_NOTICE(prefix, args,...)
Definition: hmi-debug.h:40
const char _error[]
Definition: homescreen.cpp:27
static HS_ClientManager * g_client_manager
Definition: homescreen.cpp:32
void hs_add_object_to_json_object_func(struct json_object *j_obj, const char *verb_name, int count,...)
Definition: hs-helper.cpp:207
static void tap_shortcut ( afb_req_t  request)
static

tap_shortcut notify for homescreen When Shortcut area is tapped, notify these applciations

Parameters

Request key

  • application_id : application id

Return

None

Definition at line 58 of file homescreen.cpp.

59 {
60  HMI_NOTICE("homescreen-service","called.");
61  int ret = g_client_manager->tap_shortcut(request);
62  if (ret != 0) {
63  afb_req_fail_f(request, "failed", "called %s, Unknown parameter", __FUNCTION__);
64  return;
65  }
66 
67  // response to HomeScreen
68  struct json_object *res = json_object_new_object();
69  hs_add_object_to_json_object_func(res, __FUNCTION__, 2,
70  _error, ret);
71  afb_req_success(request, res, "afb_event_push event [tap_shortcut]");
72 }
int tap_shortcut(afb_req_t request)
#define HMI_NOTICE(prefix, args,...)
Definition: hmi-debug.h:40
const char _error[]
Definition: homescreen.cpp:27
static HS_ClientManager * g_client_manager
Definition: homescreen.cpp:32
void hs_add_object_to_json_object_func(struct json_object *j_obj, const char *verb_name, int count,...)
Definition: hs-helper.cpp:207
static void unsubscribe ( afb_req_t  request)
static

Unsubscribe event

Parameters

Return

None

Definition at line 167 of file homescreen.cpp.

168 {
169  HMI_NOTICE("homescreen-service","called.");
170 
171  int ret = g_client_manager->unsubscribe(request);
172  if(ret) {
173  afb_req_fail_f(request, "afb_req_unsubscribe failed", "called %s.", __FUNCTION__);
174  return;
175  }
176 
177  /*create response json object*/
178  struct json_object *res = json_object_new_object();
179  hs_add_object_to_json_object_func(res, __FUNCTION__, 2,
180  _error, ret);
181  afb_req_success_f(request, res, "homescreen binder unsubscribe success.");
182 }
#define HMI_NOTICE(prefix, args,...)
Definition: hmi-debug.h:40
int unsubscribe(afb_req_t request)
const char _error[]
Definition: homescreen.cpp:27
static HS_ClientManager * g_client_manager
Definition: homescreen.cpp:32
void hs_add_object_to_json_object_func(struct json_object *j_obj, const char *verb_name, int count,...)
Definition: hs-helper.cpp:207

Variable Documentation

const char _application_id[] = "application_id"

Definition at line 28 of file homescreen.cpp.

const char _display_message[] = "display_message"

Definition at line 29 of file homescreen.cpp.

const char _error[] = "error"

Definition at line 27 of file homescreen.cpp.

const char _reply_message[] = "reply_message"

Definition at line 30 of file homescreen.cpp.

const afb_binding_t afbBindingExport
Initial value:
= {
.api = "homescreen",
.specification = NULL,
.info = NULL,
.verbs = verbs,
.preinit = preinit,
.init = init,
.onevent = onevent
}
static const afb_verb_t verbs[]
Definition: homescreen.cpp:326
static void onevent(afb_api_t api, const char *event, struct json_object *object)
Definition: homescreen.cpp:389
static int preinit(afb_api_t api)
Definition: homescreen.cpp:352
static int init(afb_api_t api)
Definition: homescreen.cpp:368

Definition at line 394 of file homescreen.cpp.

HS_ClientManager* g_client_manager = HS_ClientManager::instance()
static

Definition at line 32 of file homescreen.cpp.

const afb_verb_t verbs[]
static
Initial value:
= {
{ .verb="ping", .callback=pingSample },
{ .verb="tap_shortcut", .callback=tap_shortcut },
{ .verb="showWindow", .callback=showWindow },
{ .verb="hideWindow", .callback=hideWindow },
{ .verb="replyShowWindow", .callback=replyShowWindow },
{ .verb="on_screen_message", .callback=on_screen_message },
{ .verb="on_screen_reply", .callback=on_screen_reply },
{ .verb="subscribe", .callback=subscribe },
{ .verb="unsubscribe", .callback=unsubscribe },
{ .verb="showNotification", .callback=showNotification },
{ .verb="showInformation", .callback=showInformation },
{NULL }
}
static void showWindow(afb_req_t request)
Definition: homescreen.cpp:194
static void on_screen_reply(afb_req_t request)
Definition: homescreen.cpp:113
static void on_screen_message(afb_req_t request)
Definition: homescreen.cpp:85
static void subscribe(afb_req_t request)
Definition: homescreen.cpp:140
static void unsubscribe(afb_req_t request)
Definition: homescreen.cpp:167
static void showInformation(afb_req_t request)
Definition: homescreen.cpp:306
static void pingSample(afb_req_t request)
Definition: homescreen.cpp:38
static void hideWindow(afb_req_t request)
Definition: homescreen.cpp:221
static void replyShowWindow(afb_req_t request)
Definition: homescreen.cpp:248
static void showNotification(afb_req_t request)
Definition: homescreen.cpp:277
static void tap_shortcut(afb_req_t request)
Definition: homescreen.cpp:58

Definition at line 326 of file homescreen.cpp.