on 96870d5 help sign in
unity8/plugins/Unity/Launcher/asadapter.cpp
63 lines 1.9 kB history raw
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Michael Zanetti <michael.zanetti@canonical.com>
18 */
20#include "asadapter.h"
21#include "launcheritem.h"
22#include "AccountsServiceDBusAdaptor.h"
24#include <QDebug>
26ASAdapter::ASAdapter()
28 m_accounts = new AccountsServiceDBusAdaptor();
29 m_user = qgetenv("USER");
30 if (m_user.isEmpty()) {
31 qWarning() << "$USER not valid. Account Service integration will not work.";
32 }
35ASAdapter::~ASAdapter()
37 m_accounts->deleteLater();
40void ASAdapter::syncItems(QList<LauncherItem *> m_list)
42 if (m_accounts && !m_user.isEmpty()) {
43 QList<QVariantMap> items;
45 Q_FOREACH(LauncherItem *item, m_list) {
46 items << itemToVariant(item);
47 }
49 m_accounts->setUserPropertyAsync(m_user, "com.canonical.unity.AccountsService", "LauncherItems", QVariant::fromValue(items));
50 }
53QVariantMap ASAdapter::itemToVariant(LauncherItem *item) const
55 QVariantMap details;
56 details.insert("id", item->appId());
57 details.insert("name", item->name());
58 details.insert("icon", item->icon());
59 details.insert("count", item->count());
60 details.insert("countVisible", item->countVisible());
61 details.insert("pinned", item->pinned());
62 return details;