X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=launcher%2Fsrc%2Fhomescreenhandler.cpp;fp=launcher%2Fsrc%2Fhomescreenhandler.cpp;h=2da71c8b6fe7da126cbfb77e3e01c55315aa0f1e;hb=3508d025b0046fffb337ffceb912947ef1dcf47d;hp=240f5c8cec87e1bddb9899f9a6871ac700c00000;hpb=353da85004c72efb2bd6f117a15713b58e0df866;p=apps%2Flauncher.git diff --git a/launcher/src/homescreenhandler.cpp b/launcher/src/homescreenhandler.cpp index 240f5c8..2da71c8 100644 --- a/launcher/src/homescreenhandler.cpp +++ b/launcher/src/homescreenhandler.cpp @@ -18,8 +18,15 @@ #include #include "homescreenhandler.h" #include +#include +#include +#include #include "hmi-debug.h" +#include "afm_user_daemon_proxy.h" +extern org::AGL::afm::user *afm_user_daemon_proxy; + +#define BUF_SIZE 1024 void* HomescreenHandler::myThis = 0; HomescreenHandler::HomescreenHandler(QObject *parent) : @@ -110,6 +117,20 @@ void HomescreenHandler::init(int port, const char *token, QLibWindowmanager *qwm } } }); + + mp_qhs->set_event_handler(QLibHomeScreen::Event_UpdateShortcut,[this](json_object *object){ + HMI_DEBUG("Launcher","Surface launcher got Event_UpdateShortcut\n"); + json_object *obj_p = json_object_object_get(object, "parameter"); + json_object *obj_array = json_object_object_get(obj_p, "shortcut"); + QStringList shortcut_list; + for(int i = 0; i < 3; i++) + { + shortcut_list << QString(QLatin1String(json_object_get_string(json_object_object_get(json_object_array_get_idx(obj_array, i), "shortcut_id")))); + shortcut_list << QString(QLatin1String(json_object_get_string(json_object_object_get(json_object_array_get_idx(obj_array, i), "shortcut_name")))); + } + HMI_DEBUG("Launcher","SEvent_UpdateShortcut id1 = %s", shortcut_list.at(2).toStdString().c_str()); + emit updateShortcutList(shortcut_list); + }); } void HomescreenHandler::tapShortcut(QString application_id) @@ -144,6 +165,51 @@ void HomescreenHandler::onRep(struct json_object* reply_contents) } } +void HomescreenHandler::hideWindow(QString application_id) +{ + mp_qhs->hideWindow(application_id.section('@', 0, 0).toStdString().c_str()); +} + +void HomescreenHandler::registerShortcut(QString shortcut_id, QString shortcut_name, QString position) +{ +// struct json_object* j_obj = json_object_new_object(); +// struct json_object* val_id = json_object_new_string(shortcut_id.toStdString().c_str()); +// struct json_object* val_name = json_object_new_string(shortcut_name.toStdString().c_str()); +// struct json_object* val_position = json_object_new_string(position.toStdString().c_str()); +// json_object_object_add(j_obj, "shortcut_id", val_id); +// json_object_object_add(j_obj, "shortcut_name", val_name); +// json_object_object_add(j_obj, "position", val_position); + + mp_qhs->registerShortcut(shortcut_id, shortcut_name, position); +} + +int HomescreenHandler::uninstallApplication(QString application_id) +{ + int result = -1; + HMI_DEBUG("launcher","Application uninstall %s.", application_id.toStdString().c_str()); + + result = afm_user_daemon_proxy->uninstall(application_id).value().toInt(); + HMI_DEBUG("launcher","ApplicationUninstall pid: %d.", result); + +// QProcess *process = new QProcess(); +// QString command = "/usr/bin/pkill " + application_id.section('@', 0, 0); +// HMI_DEBUG("launcher", "command is %s", command.toStdString().c_str()); +// process->start(command); + + return result; +} + +void HomescreenHandler::sendAppToMeter(QString application_id) +{ + HMI_DEBUG("Launcher","sendAppToMeter %s", application_id.toStdString().c_str()); + struct json_object* j_json = json_object_new_object(); + struct json_object* value; + value = json_object_new_string("master.split.sub"); + json_object_object_add(j_json, "area", value); + + mp_qhs->showWindow(application_id.section('@', 0, 0).toStdString().c_str(), j_json); +} + void HomescreenHandler::getRunnables(void) { mp_qhs->getRunnables();