Allow to set notifications for the progress bar
[apps/homescreen.git] / homescreen / src / main.cpp
index 2d9ac4d..a82921e 100644 (file)
@@ -49,19 +49,27 @@ struct shell_container {
        // used to propagate events from C/C++ event handlers from the protocol
        // to the QML in case we need them
        Shell *a_shell;
+       ApplicationLauncher *launcher;
 };
 
 static void
 application_id_event(void *data, struct agl_shell_desktop *agl_shell_desktop,
-               const char *app_id)
+                    const char *app_id)
 {
+       // this event is sent  only when surfaces are being created.  we call
+       // setCurrent() to take care of this the first time, with later state
+       // event changes being handled by the application_state_event()
+       struct shell_container *sc = static_cast<struct shell_container *>(data);
+       sc->launcher->setCurrent(QString(app_id));
 }
 
 static void
 application_state_event(void *data, struct agl_shell_desktop *agl_shell_desktop,
-                    const char *app_id, const char *app_data,
-                    uint32_t app_state, uint32_t app_role)
+                       const char *app_id, const char *app_data,
+                       uint32_t app_state, uint32_t app_role)
 {
+       struct shell_container *sc = static_cast<struct shell_container *>(data);
+       sc->launcher->setCurrent(QString(app_id));
 }
 
 static const struct agl_shell_desktop_listener agl_shell_desktop_listener = {
@@ -268,6 +276,7 @@ int main(int argc, char *argv[])
     }
 
     HMI_DEBUG("HomeScreen","port = %d, token = %s", port, token.toStdString().c_str());
+    ApplicationLauncher *launcher = new ApplicationLauncher();
 
     sc = register_agl_shell(native);
     if (!sc) {
@@ -280,6 +289,7 @@ int main(int argc, char *argv[])
            shell_desktop{sc->agl_shell_desktop, agl_shell_desktop_destroy};
     Shell *aglShell = new Shell(shell, shell_desktop, &a);
     sc->a_shell = aglShell;
+    sc->launcher = launcher;
 
     // import C++ class to QML
     // qmlRegisterType<ApplicationLauncher>("HomeScreen", 1, 0, "ApplicationLauncher");
@@ -288,9 +298,8 @@ int main(int argc, char *argv[])
     qmlRegisterUncreatableType<ChromeController>("SpeechChrome", 1, 0, "SpeechChromeController",
                                                  QLatin1String("SpeechChromeController is uncreatable."));
 
-    ApplicationLauncher *launcher = new ApplicationLauncher();
 
-    HomescreenHandler* homescreenHandler = new HomescreenHandler(aglShell);
+    HomescreenHandler* homescreenHandler = new HomescreenHandler(aglShell, launcher);
     homescreenHandler->init(port, token.toStdString().c_str());
 
     QUrl bindingAddress;