@@ -22,6 +22,7 @@
2222#include "backend/launcherbackend.h"
2323
2424#include <unity/shell/application/ApplicationInfoInterface.h>
25+#include <upstart-app-launch.h>
2526
2627using namespace unity::shell::application;
2728
@@ -195,6 +196,31 @@ void LauncherModel::setUser(const QString &username)
195196 m_backend->setUser(username);
196197}
197198
199+QString LauncherModel::getUrlForAppId(const QString &appId)
200+{
201+ // appId is either an appId or a legacy app name. Let's find out which
202+ QString url;
203+ gchar *package, *app, *version, *longAppId;
204+
205+ // assume legacy app until proven otherwise
206+ url = "application:///" + appId + ".desktop";
207+
208+ if (upstart_app_launch_app_id_parse(appId.first().toLatin1().constData(),
209+ &package, &app, &version)) {
210+ // Turn it back into an appId to test if it's a click app or not
211+ longAppId = upstart_app_launch_triplet_to_app_id(package, app, version);
212+ if (longAppId != nullptr) { // it is a click app!
213+ url = QString("appid://%1/%2/%3").args(package, app, version);
214+ g_free(longAppId);
215+ }
216+ g_free(package);
217+ g_free(app);
218+ g_free(version);
219+ }
220+
221+ return url;
222+}
223+
198224void LauncherModel::refreshStoredApplications()
199225{
200226 // First remove any existing ones