~zeller-benjamin/ubuntu-system-settings/applauncherd

« back to all changes in this revision

Viewing changes to plugins/cellular/plugin/cellular-plugin.cpp

  • Committer: CI Train Bot
  • Author(s): Ken VanDine
  • Date: 2016-02-08 14:32:32 UTC
  • mfrom: (1506.12.15 dynamic_visibility)
  • Revision ID: ci-train-bot@canonical.com-20160208143232-m5px96oh6oxx22mz
Make cellular and phone dynamically visible
 Fixes: #1541588
Approved by: Jonas G. Drange

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of system-settings
 
3
 *
 
4
 * Copyright (C) 2015 Canonical Ltd.
 
5
 *
 
6
 * Contact: Ken VanDine <ken.vandine@canonical.com>
 
7
 *
 
8
 * This program is free software: you can redistribute it and/or modify it
 
9
 * under the terms of the GNU General Public License version 3, as published
 
10
 * by the Free Software Foundation.
 
11
 *
 
12
 * This program is distributed in the hope that it will be useful, but
 
13
 * WITHOUT ANY WARRANTY; without even the implied warranties of
 
14
 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
 
15
 * PURPOSE.  See the GNU General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU General Public License along
 
18
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
 */
 
20
 
 
21
#include "cellular-plugin.h"
 
22
 
 
23
#include <QDebug>
 
24
#include <QDBusInterface>
 
25
#include <QDBusPendingReply>
 
26
#include <QProcessEnvironment>
 
27
#include <QtDBus>
 
28
#include <SystemSettings/ItemBase>
 
29
 
 
30
using namespace SystemSettings;
 
31
 
 
32
class CellularItem: public ItemBase
 
33
{
 
34
    Q_OBJECT
 
35
 
 
36
public:
 
37
    explicit CellularItem(const QVariantMap &staticData, QObject *parent = 0);
 
38
    void setVisibility(bool visible);
 
39
};
 
40
 
 
41
 
 
42
CellularItem::CellularItem(const QVariantMap &staticData, QObject *parent):
 
43
    ItemBase(staticData, parent)
 
44
{
 
45
    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
 
46
    if (env.contains(QLatin1String("USS_SHOW_ALL_UI"))) {
 
47
        QString showAllS = env.value("USS_SHOW_ALL_UI", QString());
 
48
 
 
49
        if(!showAllS.isEmpty()) {
 
50
            setVisibility(true);
 
51
            return;
 
52
        }
 
53
    }
 
54
 
 
55
    bool supportedDevice(true);
 
56
 
 
57
    QDBusInterface m_NetStatusPropertiesIface(
 
58
            "com.ubuntu.connectivity1",
 
59
            "/com/ubuntu/connectivity1/NetworkingStatus",
 
60
            "org.freedesktop.DBus.Properties",
 
61
            QDBusConnection::sessionBus());
 
62
    QDBusPendingReply<QVariant> modemReply = m_NetStatusPropertiesIface.call(
 
63
        "Get", "com.ubuntu.connectivity1.NetworkingStatus", "ModemAvailable");
 
64
    modemReply.waitForFinished();
 
65
    if (modemReply.isValid()) {
 
66
        supportedDevice = modemReply.argumentAt<0>().toBool();
 
67
    }
 
68
 
 
69
    setVisibility(supportedDevice);
 
70
}
 
71
 
 
72
void CellularItem::setVisibility(bool visible)
 
73
{
 
74
    setVisible(visible);
 
75
}
 
76
 
 
77
ItemBase *CellularPlugin::createItem(const QVariantMap &staticData,
 
78
                                 QObject *parent)
 
79
{
 
80
    return new CellularItem(staticData, parent);
 
81
}
 
82
 
 
83
#include "cellular-plugin.moc"