on 5aef858 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 qDebug() << "syncing items to AS" << m_list.count();
43 if (m_accounts && !m_user.isEmpty()) {
44 QList<QVariantMap> items;
46 Q_FOREACH(LauncherItem *item, m_list) {
47 items << itemToVariant(item);
48 }
50 m_accounts->setUserPropertyAsync(m_user, "com.canonical.unity.AccountsService", "launcher-items", QVariant::fromValue(items));
51 }
54QVariantMap ASAdapter::itemToVariant(LauncherItem *item) const
56 QVariantMap details;
57 details.insert("id", item->appId());
58 details.insert("name", item->name());
59 details.insert("icon", item->icon());
60 details.insert("count", item->count());
61 details.insert("countVisible", item->countVisible());
62 return details;