diff options
-rw-r--r-- | src/qlibhomescreen.cpp | 133 | ||||
-rw-r--r-- | src/qlibhomescreen.h | 16 |
2 files changed, 146 insertions, 3 deletions
diff --git a/src/qlibhomescreen.cpp b/src/qlibhomescreen.cpp index aded770..f769469 100644 --- a/src/qlibhomescreen.cpp +++ b/src/qlibhomescreen.cpp @@ -178,5 +178,134 @@ void QLibHomeScreen::set_event_handler(enum QEventType et, handler_fun f) void QLibHomeScreen::tapShortcut(QString application_id) { HMI_DEBUG("qlibhomescreen","tapShortcut %s", application_id.toStdString().c_str()); - this->mp_hs->tapShortcut(application_id.toStdString().c_str()); -}
\ No newline at end of file + mp_hs->showWindow(application_id.toStdString().c_str(), nullptr); +} + +/** + * show application by application id + * + * #### Parameters + * - application_id : application id + * - json : json parameters + * + * #### Return + * - None. + * + */ +void QLibHomeScreen::showWindow(QString application_id, json_object* json) +{ + mp_hs->showWindow(application_id.toStdString().c_str(), json); +} + +/** + * show application by application id, json string + * + * #### Parameters + * - application_id : application id + * - json : json parameters + * + * #### Return + * - None. + * + */ +void QLibHomeScreen::showWindow(QString application_id, QString json) +{ + if(json.isNull()) + mp_hs->showWindow(application_id.toStdString().c_str(), nullptr); + else + mp_hs->showWindow(application_id.toStdString().c_str(), json_tokener_parse(json.toStdString().c_str())); +} + +/** + * hide application by application id + * + * #### Parameters + * - application_id : application id + * + * #### Return + * - None. + * + */ +void QLibHomeScreen::hideWindow(QString application_id) +{ + mp_hs->hideWindow(application_id.toStdString().c_str()); +} + +/** + * send onscreen or software keyboard message to application + * + * #### Parameters + * - application_id : application id + * - json : json parameters + * + * #### Return + * - None. + * + */ +void QLibHomeScreen::replyShowWindow(QString application_id, json_object* json) +{ + mp_hs->replyShowWindow(application_id.toStdString().c_str(), json); +} + +/** + * send onscreen or software keyboard message to application + * + * #### Parameters + * - application_id : application id + * - json : json parameters + * + * #### Return + * - None. + * + */ +void QLibHomeScreen::replyShowWindow(QString application_id, QString json) +{ + if(json.isNull()) + mp_hs->replyShowWindow(application_id.toStdString().c_str(), nullptr); + else + mp_hs->replyShowWindow(application_id.toStdString().c_str(), json_tokener_parse(json.toStdString().c_str())); +} + +/** + * show information + * + * use libhomescreen api to push information to menubarApp + * + * #### Parameters + * - params : json parameters + * + * #### Return + * - None. + * + */ +void QLibHomeScreen::showInformation(QString info) +{ + struct json_object* j_obj = json_object_new_object(); + struct json_object* val = json_object_new_string(info.toStdString().c_str()); + json_object_object_add(j_obj, "info", val); + + mp_hs->showInformation(j_obj); +} + +/** + * show notification + * + * use libhomescreen api to push notification to menubarApp + * + * #### Parameters + * - params : json parameters + * + * #### Resturn + * - None. + * + */ +void QLibHomeScreen::showNotification(QString icon, QString text) +{ + struct json_object* j_obj = json_object_new_object(); + struct json_object* val_icon = json_object_new_string(icon.toStdString().c_str()); + struct json_object* val_text = json_object_new_string(text.toStdString().c_str()); + json_object_object_add(j_obj, "icon", val_icon); + json_object_object_add(j_obj, "text", val_text); + + mp_hs->showNotification(j_obj); +} diff --git a/src/qlibhomescreen.h b/src/qlibhomescreen.h index bf43963..e613de3 100644 --- a/src/qlibhomescreen.h +++ b/src/qlibhomescreen.h @@ -34,16 +34,30 @@ public: enum QEventType { Event_TapShortcut = LibHomeScreen::Event_TapShortcut, - Event_OnScreenReply = LibHomeScreen::Event_OnScreenReply + Event_ShowWindow = LibHomeScreen::Event_ShowWindow, + Event_OnScreenMessage = LibHomeScreen::Event_OnScreenMessage, + Event_OnScreenReply = LibHomeScreen::Event_OnScreenReply, + Event_HideWindow = LibHomeScreen::Event_HideWindow, + Event_ReplyShowWindow = LibHomeScreen::Event_ReplyShowWindow, + Event_ShowNotification = LibHomeScreen::Event_ShowNotification, + Event_ShowInformation = LibHomeScreen::Event_ShowInformation }; using handler_fun = std::function<void(json_object *object)>; void init(int port, const QString &token); void set_event_handler(enum QEventType et, handler_fun f); + void showWindow(QString application_id, json_object* json); + void replyShowWindow(QString application_id, json_object* json); + Q_INVOKABLE void showInformation(QString info); + Q_INVOKABLE void showNotification(QString icon, QString text); + Q_INVOKABLE int onScreenMessage(const QString &message); Q_INVOKABLE int subscribe(const QString &eventName); Q_INVOKABLE int unsubscribe(const QString &eventName); Q_INVOKABLE void tapShortcut(QString application_id); + Q_INVOKABLE void showWindow(QString application_id, QString json); + Q_INVOKABLE void hideWindow(QString application_id); + Q_INVOKABLE void replyShowWindow(QString application_id, QString json); signals: |