HomeScreenBinding
|
#include <libhomescreen.hpp>
Public Types | |
enum | EventType { Event_ShowWindow = 1, Event_TapShortcut = 1, Event_OnScreenMessage, Event_OnScreenReply, Event_HideWindow, Event_ReplyShowWindow, Event_ShowNotification, Event_ShowInformation } |
using | handler_func = std::function< void(json_object *)> |
Public Member Functions | |
LibHomeScreen () | |
~LibHomeScreen () | |
LibHomeScreen (const LibHomeScreen &)=delete | |
LibHomeScreen & | operator= (const LibHomeScreen &)=delete |
int | init (const int port, const std::string &token) |
int | tapShortcut (const char *application_id) |
int | onScreenMessage (const char *display_message) |
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) |
int | call (const std::string &verb, struct json_object *arg) |
int | call (const char *verb, struct json_object *arg) |
int | subscribe (const std::string &event_name) |
int | unsubscribe (const std::string &event_name) |
int | showWindow (const char *application_id, json_object *json) |
int | hideWindow (const char *application_id) |
int | replyShowWindow (const char *application_id, json_object *json) |
int | showNotification (json_object *json) |
int | showInformation (json_object *json) |
void | on_hangup (void *closure, struct afb_wsj1 *wsj) |
void | on_call (void *closure, const char *api, const char *verb, struct afb_wsj1_msg *msg) |
void | on_event (void *closure, const char *event, struct afb_wsj1_msg *msg) |
void | on_reply (void *closure, struct afb_wsj1_msg *msg) |
Public Attributes | |
const char * | _keyParameter = "parameter" |
const char * | _keyArea = "area" |
const char * | _areaNormal = "normal" |
const char * | _areaFullScreen = "fullscreen" |
const char * | _areaSplitMain = "split.main" |
const char * | _areaSplitSub = "split.sub" |
Static Public Attributes | |
static const std::vector< std::string > | api_list |
static const std::vector< std::string > | event_list |
Definition at line 31 of file libhomescreen.hpp.
using LibHomeScreen::handler_func = std::function<void(json_object*)> |
Definition at line 40 of file libhomescreen.hpp.
Enumerator | |
---|---|
Event_ShowWindow | |
Event_TapShortcut | |
Event_OnScreenMessage | |
Event_OnScreenReply | |
Event_HideWindow | |
Event_ReplyShowWindow | |
Event_ShowNotification | |
Event_ShowInformation |
Definition at line 42 of file libhomescreen.hpp.
LibHomeScreen::LibHomeScreen | ( | ) |
LibHomeScreen::~LibHomeScreen | ( | ) |
destructor
Definition at line 100 of file libhomescreen.cpp.
|
delete |
int LibHomeScreen::call | ( | const std::string & | verb, |
struct json_object * | arg | ||
) |
int LibHomeScreen::call | ( | const char * | verb, |
struct json_object * | arg | ||
) |
This function calls the API of HomeScreen via WebSocket This function is overload function of "call"
To call HomeScreen's APIs, the application should set its function name, arguments to JSON format.
Definition at line 377 of file libhomescreen.cpp.
int LibHomeScreen::hideWindow | ( | const char * | application_id | ) |
Sending hide window event
Call HomeScreen Service's hideWindow verb to release id's screen.
Definition at line 503 of file libhomescreen.cpp.
int LibHomeScreen::init | ( | const int | port, |
const std::string & | token | ||
) |
This function is initializer
Nothing
Use this constructor
Definition at line 126 of file libhomescreen.cpp.
void LibHomeScreen::on_call | ( | void * | closure, |
const char * | api, | ||
const char * | verb, | ||
struct afb_wsj1_msg * | msg | ||
) |
Definition at line 606 of file libhomescreen.cpp.
void LibHomeScreen::on_event | ( | void * | closure, |
const char * | event, | ||
struct afb_wsj1_msg * | msg | ||
) |
Definition at line 616 of file libhomescreen.cpp.
void LibHomeScreen::on_hangup | ( | void * | closure, |
struct afb_wsj1 * | wsj | ||
) |
Definition at line 597 of file libhomescreen.cpp.
void LibHomeScreen::on_reply | ( | void * | closure, |
struct afb_wsj1_msg * | msg | ||
) |
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 695 of file libhomescreen.cpp.
int LibHomeScreen::onScreenMessage | ( | const char * | display_message | ) |
Sending onScreen message event
Sending OnScreen message event to HomeScreen from applications
Definition at line 242 of file libhomescreen.cpp.
int LibHomeScreen::onScreenReply | ( | const char * | reply_message | ) |
Sending onScreen reply event
Sending OnScreen reply event to applications from HomeScreen
Definition at line 266 of file libhomescreen.cpp.
|
delete |
void LibHomeScreen::registerCallback | ( | void(*)(const std::string &event, struct json_object *event_contents) | event_cb, |
void(*)(struct json_object *reply_contents) | reply_cb, | ||
void(*)(void) | hangup_cb = nullptr |
||
) |
This function register callback function for reply/event message from home screen
Nothing
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 165 of file libhomescreen.cpp.
int LibHomeScreen::replyShowWindow | ( | const char * | application_id, |
json_object * | json | ||
) |
Sending reply onscreen message event
Call HomeScreen Service's replyShowWindow verb to reply onscreen message.
Definition at line 530 of file libhomescreen.cpp.
void LibHomeScreen::set_event_handler | ( | enum EventType | et, |
handler_func | f | ||
) |
Setting Event Handler
Setting event handler for Homescreen
Nothing
Don't release json_object by json_object_put in handler_func. The resource is released by libafbwsc library.
Definition at line 295 of file libhomescreen.cpp.
int LibHomeScreen::showInformation | ( | json_object * | json | ) |
Sending show information event
Call HomeScreen Service's information verb to show notification on Information Bar.
Definition at line 584 of file libhomescreen.cpp.
int LibHomeScreen::showNotification | ( | json_object * | json | ) |
Sending show notification event
Call HomeScreen Service's notification verb to show notification on Status Bar.
Definition at line 562 of file libhomescreen.cpp.
int LibHomeScreen::showWindow | ( | const char * | application_id, |
json_object * | json | ||
) |
Sending show window event
Call HomeScreen Service's showWindow verb to request display id's screen.
Definition at line 467 of file libhomescreen.cpp.
int LibHomeScreen::subscribe | ( | const std::string & | event_name | ) |
Register callback function for each event
This function enables to get an event to your callback function.
Definition at line 409 of file libhomescreen.cpp.
int LibHomeScreen::tapShortcut | ( | const char * | application_id | ) |
Sending ShortCut Icon tapped event
When HomeScreen shortcut area is tapped, sending a event
Definition at line 222 of file libhomescreen.cpp.
int LibHomeScreen::unsubscribe | ( | const std::string & | event_name | ) |
Unregister callback function for each event
This function disables to get an event to your callback function.
Definition at line 438 of file libhomescreen.cpp.
const char* LibHomeScreen::_areaFullScreen = "fullscreen" |
Definition at line 59 of file libhomescreen.hpp.
const char* LibHomeScreen::_areaNormal = "normal" |
Definition at line 58 of file libhomescreen.hpp.
const char* LibHomeScreen::_areaSplitMain = "split.main" |
Definition at line 60 of file libhomescreen.hpp.
const char* LibHomeScreen::_areaSplitSub = "split.sub" |
Definition at line 61 of file libhomescreen.hpp.
const char* LibHomeScreen::_keyArea = "area" |
Definition at line 55 of file libhomescreen.hpp.
const char* LibHomeScreen::_keyParameter = "parameter" |
Definition at line 54 of file libhomescreen.hpp.
|
static |
Definition at line 63 of file libhomescreen.hpp.
|
static |
Definition at line 64 of file libhomescreen.hpp.