aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwang_zhiqiang <wang_zhiqiang@dl.cn.nexty-ele.com>2018-10-19 13:21:12 +0800
committerwang_zhiqiang <wang_zhiqiang@dl.cn.nexty-ele.com>2018-10-19 13:21:12 +0800
commitf8e700f74b4d07fec7f4e31dbb837070a9105149 (patch)
tree49009168b7ca5b4b040e50624236774d94209760
parent840301eadc6deb4e8ed9b910f9c30b4b7e6195b4 (diff)
update applist
Change-Id: I2d919cb8a0829d48f74a34346daaf1c7adeb00f5
-rw-r--r--launcher/qml/Launcher.qml8
-rw-r--r--launcher/src/appfwhandler.cpp46
-rw-r--r--launcher/src/appfwhandler.h3
-rw-r--r--launcher/src/applicationmodel.cpp50
-rw-r--r--launcher/src/applicationmodel.h2
-rw-r--r--launcher/src/main.cpp5
-rw-r--r--package/config.xml2
7 files changed, 113 insertions, 3 deletions
diff --git a/launcher/qml/Launcher.qml b/launcher/qml/Launcher.qml
index 6d55271..ec0220f 100644
--- a/launcher/qml/Launcher.qml
+++ b/launcher/qml/Launcher.qml
@@ -59,6 +59,14 @@ ApplicationWindow {
height: grid.cellHeight
}
+ Connections {
+ target: appfwhandler
+ onApplistupdate: {
+ console.warn("applist update in Launcher.qml")
+ applicationModel.updateApplist(info);
+ }
+ }
+
MouseArea {
id: loc
anchors.fill: parent
diff --git a/launcher/src/appfwhandler.cpp b/launcher/src/appfwhandler.cpp
index 7f92b9d..9df6d7d 100644
--- a/launcher/src/appfwhandler.cpp
+++ b/launcher/src/appfwhandler.cpp
@@ -31,14 +31,47 @@ static void _on_pws_hangup(void *closure)
static void _on_pws_reply(void *closure, void *request, struct json_object *obj, const char *error, const char *info)
{
HMI_DEBUG("AppFwHandler", "%s called,error=[%s], info=[%s], obj=[%s]", __FUNCTION__, error, info, json_object_to_json_string(obj));
+ if(json_object_is_type(obj, json_type_object)) {
+ struct json_object *obj1, *obj2, *obj3;
+ json_object_object_get_ex(obj, "icon", &obj1);
+ json_object_object_get_ex(obj, "name", &obj2);
+ json_object_object_get_ex(obj, "id", &obj3);
+ if(json_object_is_type(obj3, json_type_null))
+ return;
+ QString icon = json_object_get_string(obj1);
+ QString name = json_object_get_string(obj2);
+ QString id = json_object_get_string(obj3);
+ QStringList info;
+ info << icon << name << id;
+ emit AppFwHandler::myself->applistupdate(info);
+ }
}
static void _on_pws_event_broadcast(void *closure, const char *event_name, struct json_object *data)
{
HMI_DEBUG("AppFwHandler", "%s called,event=%s, [%s]", __FUNCTION__, event_name, json_object_to_json_string(data));
QStringList list = QString(event_name).split('/');
- if(list[0] == "afm-main" && list[1] == "application-list-changed")
- emit AppFwHandler::myself->applistupdate(data);
+ if(list[0] == "afm-main" && list[1] == "application-list-changed") {
+ struct json_object *obj1, *obj2;
+ json_object_object_get_ex(data, "operation", &obj1);
+ json_object_object_get_ex(data, "data", &obj2);
+ QString oper = json_object_get_string(obj1);
+ QString id = json_object_get_string(obj2);
+
+ if(oper == "uninstall") {
+ QStringList info;
+ // icon, name, id
+ info << "" << "" << id;
+ emit AppFwHandler::myself->applistupdate(info);
+ }
+ else if (oper == "install") {
+ // call state
+ AppFwHandler::myself->detail(id);
+ }
+ else {
+ HMI_DEBUG("AppFwHandler","data error");
+ }
+ }
}
// the callback interface for pws
@@ -94,6 +127,15 @@ int AppFwHandler::runnables(void)
return ret;
}
+int AppFwHandler::detail(QString id)
+{
+ int ret = 1;
+ HMI_DEBUG("AppFwHandler", "detail id is %s\n", id.toStdString().c_str());
+ if(call(__FUNCTION__, id.toStdString().c_str()) < 0)
+ ret = 0;
+ return ret;
+}
+
int AppFwHandler::try_connect_pws(void)
{
m_pws = afb_ws_client_connect_api(m_evloop, m_uri.toStdString().c_str(), &pws_itf, NULL);
diff --git a/launcher/src/appfwhandler.h b/launcher/src/appfwhandler.h
index 275afeb..25a401b 100644
--- a/launcher/src/appfwhandler.h
+++ b/launcher/src/appfwhandler.h
@@ -38,6 +38,7 @@ public:
int init(void);
int runnables(void);
+ int detail(QString id);
void on_pws_hangup(void);
void registerCallback(
/* can't be NULL */
@@ -53,7 +54,7 @@ public:
static AppFwHandler* myself;
signals:
- void applistupdate(struct json_object * obj);
+ void applistupdate(QStringList info);
private slots:
void connect_pws_timer_slot(void);
diff --git a/launcher/src/applicationmodel.cpp b/launcher/src/applicationmodel.cpp
index 17e38fb..dded7e6 100644
--- a/launcher/src/applicationmodel.cpp
+++ b/launcher/src/applicationmodel.cpp
@@ -33,6 +33,9 @@ class ApplicationModel::Private
public:
Private();
+ void addApp(QString icon, QString name, QString id);
+ void removeApp(QString id);
+
QList<AppInfo> data;
};
@@ -71,6 +74,29 @@ ApplicationModel::Private::Private()
}
}
+void ApplicationModel::Private::addApp(QString icon, QString name, QString id)
+{
+ HMI_DEBUG("addApp","name: %s icon: %s id: %s.", name.toStdString().c_str(), icon.toStdString().c_str(), id.toStdString().c_str());
+ QString _icon = name.toLower();
+ if ( !QFile::exists(QString(":/images/%1_active.svg").arg(_icon)) ||
+ !QFile::exists(QString(":/images/%1_inactive.svg").arg(_icon)) )
+ {
+ _icon = "blank";
+ }
+ this->data.append(AppInfo(_icon, name, id));
+}
+
+void ApplicationModel::Private::removeApp(QString id)
+{
+ HMI_DEBUG("removeApp","id: %s.",id.toStdString().c_str());
+ for (int i = 0; i < this->data.size(); ++i) {
+ if (this->data.at(i).id() == id) {
+ this->data.removeAt(i);
+ break;
+ }
+ }
+}
+
ApplicationModel::ApplicationModel(QObject *parent)
: QAbstractListModel(parent)
, d(new Private())
@@ -154,3 +180,27 @@ void ApplicationModel::move(int from, int to)
HMI_NOTICE("launcher","from : %d, to : %d. false.", from, to);
}
}
+
+void ApplicationModel::updateApplist(QStringList info)
+{
+ QString icon = info.at(0);
+ QString name = info.at(1);
+ QString id = info.at(2);
+ QString appid = id.split('@')[0];
+
+ if ( appid == "launcher" ||
+ appid == "homescreen-2017" ||
+ appid == "homescreen" ||
+ appid.contains("onscreen", Qt::CaseInsensitive)) {
+ return;
+ }
+ beginResetModel();
+ if(icon == "") { // uninstall
+ d->removeApp(id);
+ }
+ else {
+ // new app
+ d->addApp(icon, name, id);
+ }
+ endResetModel();
+}
diff --git a/launcher/src/applicationmodel.h b/launcher/src/applicationmodel.h
index 8398b62..153a596 100644
--- a/launcher/src/applicationmodel.h
+++ b/launcher/src/applicationmodel.h
@@ -34,6 +34,8 @@ public:
Q_INVOKABLE QString id(int index) const;
Q_INVOKABLE QString name(int index) const;
Q_INVOKABLE void move(int from, int to);
+ Q_INVOKABLE void updateApplist(QStringList info);
+
private:
class Private;
diff --git a/launcher/src/main.cpp b/launcher/src/main.cpp
index 91a1d80..7b66972 100644
--- a/launcher/src/main.cpp
+++ b/launcher/src/main.cpp
@@ -31,6 +31,7 @@
#include "afm_user_daemon_proxy.h"
#include "qlibhomescreen.h"
#include "hmi-debug.h"
+#include "appfwhandler.h"
// XXX: We want this DBus connection to be shared across the different
// QML objects, is there another way to do this, a nice way, perhaps?
@@ -136,6 +137,9 @@ int main(int argc, char *argv[])
}
});
+ AppFwHandler* appfwhandler = new AppFwHandler(myname.toStdString().c_str());
+ appfwhandler->init();
+
QUrl bindingAddress;
bindingAddress.setScheme(QStringLiteral("ws"));
bindingAddress.setHost(QStringLiteral("localhost"));
@@ -162,6 +166,7 @@ int main(int argc, char *argv[])
engine.rootContext()->setContextProperty(QStringLiteral("homescreenHandler"), homescreenHandler);
engine.rootContext()->setContextProperty(QStringLiteral("launcher"), launcher);
engine.rootContext()->setContextProperty(QStringLiteral("screenInfo"), &screenInfo);
+ engine.rootContext()->setContextProperty(QStringLiteral("appfwhandler"), appfwhandler);
engine.load(QUrl(QStringLiteral("qrc:/Launcher.qml")));
QObject *root = engine.rootObjects().first();
diff --git a/package/config.xml b/package/config.xml
index d9b15cc..0c7c021 100644
--- a/package/config.xml
+++ b/package/config.xml
@@ -16,5 +16,7 @@
<param name="urn:AGL:permission::system:run-by-default" value="required" />
<param name="http://tizen.org/privilege/internal/dbus" value="required" />
<param name="urn:AGL:permission:afm:system:widget" value="required" />
+ <param name="urn:AGL:permission:afm:system:runner" value="required" />
+ <param name="urn:AGL:permission:afm:system:runner:state" value="required" />
</feature>
</widget>