#include "runxdg.hpp"
#define RUNXDG_CONFIG "runxdg.toml"
+#define AREA_NORMAL_FULL "normal.full"
void fatal(const char* format, ...)
{
std::function< void(json_object*) > h_syncdraw =
[this](json_object* object) {
AGL_DEBUG("Got Event_SyncDraw");
- json_object* obj = json_object_new_object();
- json_object_object_add(obj, this->m_wm->kKeyDrawingName,
- json_object_new_string(this->m_role.c_str()));
- this->m_wm->endDraw(obj);
+ this->m_wm->endDraw(this->m_role.c_str());
};
std::function< void(json_object*) > h_flushdraw= [](json_object* object) {
}
std::function< void(json_object*) > handler = [this] (json_object* object) {
- json_object *val;
-
- if (json_object_object_get_ex(object, "application_name", &val)) {
- const char *name = json_object_get_string(val);
-
- AGL_DEBUG("Event_TapShortcut <%s>", name);
-
- if (strcmp(name, this->m_role.c_str()) == 0) {
- // check app exist and re-launch if needed
- AGL_DEBUG("Activesurface %s ", this->m_role.c_str());
-
- json_object *obj = json_object_new_object();
- json_object_object_add(obj, this->m_wm->kKeyDrawingName,
- json_object_new_string(this->m_role.c_str()));
- json_object_object_add(obj, this->m_wm->kKeyDrawingArea,
- json_object_new_string("normal.full"));
-
- this->m_wm->activateSurface(obj);
- }
- }
+ AGL_DEBUG("Activesurface %s ", this->m_role.c_str());
+ this->m_wm->activateWindow(this->m_role.c_str(), AREA_NORMAL_FULL);
};
m_hs->set_event_handler(LibHomeScreen::Event_TapShortcut, handler);
auto params = app->get_array_of<std::string>("params");
for (const auto& param : *params)
{
+ // replace special string "@port@" and "@token@"
+ size_t found = param.find("@port@");
+ if (found != std::string::npos) {
+ std::string sub1 = param.substr(0, found);
+ std::string sub2 = param.substr(found + 6, param.size() - found);
+ std::string str = sub1 + std::to_string(m_port) + sub2;
+ pl->m_args_v.push_back(str);
+ AGL_DEBUG("params[%s] (match @port@)", str.c_str());
+ continue;
+ }
+
+ found = param.find("@token@");
+ if (found != std::string::npos) {
+ std::string sub1 = param.substr(0, found);
+ std::string sub2 = param.substr(found + 7, param.size() - found);
+ std::string str = sub1 + m_token + sub2;
+ pl->m_args_v.push_back(str);
+ AGL_DEBUG("params[%s] (match @token@)", str.c_str());
+ continue;
+ }
+
pl->m_args_v.push_back(param);
+
AGL_DEBUG("params[%s]", param.c_str());
}
std::string sid = std::to_string(id);
// This surface is mine, register pair app_name and ivi id.
- json_object *obj = json_object_new_object();
- json_object_object_add(obj, m_wm->kKeyDrawingName,
- json_object_new_string(m_role.c_str()));
- json_object_object_add(obj, m_wm->kKeyIviId,
- json_object_new_string(sid.c_str()));
-
- AGL_DEBUG("requestSurfaceXDG(%s,%s)", m_role.c_str(), sid.c_str());
- m_wm->requestSurfaceXDG(obj);
+ AGL_DEBUG("requestSurfaceXDG(%s,%d)", m_role.c_str(), id);
+ m_wm->requestSurfaceXDG(this->m_role.c_str(), id);
if (m_pending_create) {
// Recovering 1st time tap_shortcut is dropped because
// the application has not been run yet (1st time launch)
m_pending_create = false;
-
- json_object *obj = json_object_new_object();
- json_object_object_add(obj, m_wm->kKeyDrawingName,
- json_object_new_string(m_role.c_str()));
- json_object_object_add(obj, m_wm->kKeyDrawingArea,
- json_object_new_string("normal.full"));
- m_wm->activateSurface(obj);
+ m_wm->activateWindow(this->m_role.c_str(), AREA_NORMAL_FULL);
}
}