~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to libs/solid/control/modeminterface.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*  This file is part of the KDE project
 
2
    Copyright (C) 2010 Lamarque Souza <lamarque@gmail.com>
 
3
 
 
4
    This library is free software; you can redistribute it and/or
 
5
    modify it under the terms of the GNU Library General Public
 
6
    License version 2 as published by the Free Software Foundation.
 
7
 
 
8
    This library 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 GNU
 
11
    Library General Public License for more details.
 
12
 
 
13
    You should have received a copy of the GNU Library General Public License
 
14
    along with this library; see the file COPYING.LIB.  If not, write to
 
15
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
16
    Boston, MA 02110-1301, USA.
 
17
 
 
18
*/
 
19
 
 
20
#include <KLocale>
 
21
 
 
22
#include "modeminterface.h"
 
23
#include "modeminterface_p.h"
 
24
 
 
25
#include "soliddefs_p.h"
 
26
#include "ifaces/modeminterface.h"
 
27
 
 
28
Solid::Control::ModemInterface::ModemInterface(QObject *backendObject)
 
29
    : QObject(), d_ptr(new ModemInterfacePrivate(this))
 
30
{
 
31
    Q_D(ModemInterface); d->setBackendObject(backendObject);
 
32
}
 
33
 
 
34
Solid::Control::ModemInterface::ModemInterface(const ModemInterface &other)
 
35
    : QObject(), d_ptr(new ModemInterfacePrivate(this))
 
36
{
 
37
    Q_D(ModemInterface);
 
38
    d->setBackendObject(other.d_ptr->backendObject());
 
39
}
 
40
 
 
41
Solid::Control::ModemInterface::ModemInterface(ModemInterfacePrivate &dd, QObject *backendObject)
 
42
    : QObject(), d_ptr(&dd)
 
43
{
 
44
    Q_UNUSED(backendObject);
 
45
}
 
46
 
 
47
Solid::Control::ModemInterface::ModemInterface(ModemInterfacePrivate &dd, const ModemInterface &other)
 
48
    : d_ptr(&dd)
 
49
{
 
50
    Q_UNUSED(other);
 
51
}
 
52
 
 
53
Solid::Control::ModemInterface::~ModemInterface()
 
54
{
 
55
    delete d_ptr;
 
56
}
 
57
 
 
58
QString Solid::Control::ModemInterface::udi() const
 
59
{
 
60
    Q_D(const ModemInterface);
 
61
    return_SOLID_CALL(Ifaces::ModemInterface *, d->backendObject(), QString(), udi());
 
62
}
 
63
 
 
64
void Solid::Control::ModemInterface::enable(const bool enable) const
 
65
{
 
66
    Q_D(const ModemInterface);
 
67
    SOLID_CALL(Ifaces::ModemInterface *, d->backendObject(), enable(enable));
 
68
}
 
69
 
 
70
void Solid::Control::ModemInterface::connectModem(const QString & number) const
 
71
{
 
72
    Q_D(const ModemInterface);
 
73
    SOLID_CALL(Ifaces::ModemInterface *, d->backendObject(), connectModem(number));
 
74
}
 
75
 
 
76
void Solid::Control::ModemInterface::connectModem(const QVariantMap & properties) const
 
77
{
 
78
    Q_D(const ModemInterface);
 
79
    SOLID_CALL(Ifaces::ModemInterface *, d->backendObject(), connectModem(properties));
 
80
}
 
81
 
 
82
void Solid::Control::ModemInterface::disconnectModem() const
 
83
{
 
84
    Q_D(const ModemInterface);
 
85
    SOLID_CALL(Ifaces::ModemInterface *, d->backendObject(), disconnectModem());
 
86
}
 
87
 
 
88
Solid::Control::ModemInterface::Ip4ConfigType Solid::Control::ModemInterface::getIp4Config() const
 
89
{
 
90
    Q_D(const ModemInterface);
 
91
    return_SOLID_CALL(Ifaces::ModemInterface *, d->backendObject(), Ip4ConfigType(), getIp4Config());
 
92
}
 
93
 
 
94
Solid::Control::ModemInterface::InfoType Solid::Control::ModemInterface::getInfo() const
 
95
{
 
96
    Q_D(const ModemInterface);
 
97
    return_SOLID_CALL(Ifaces::ModemInterface *, d->backendObject(), InfoType(), getInfo());
 
98
}
 
99
 
 
100
QVariantMap Solid::Control::ModemInterface::getStatus() const
 
101
{
 
102
    Q_D(const ModemInterface);
 
103
    return_SOLID_CALL(Ifaces::ModemInterface *, d->backendObject(), QVariantMap(), getStatus());
 
104
}
 
105
 
 
106
QString Solid::Control::ModemInterface::device() const
 
107
{
 
108
    Q_D(const ModemInterface);
 
109
    return_SOLID_CALL(Ifaces::ModemInterface *, d->backendObject(), QString(), device());
 
110
}
 
111
 
 
112
QString Solid::Control::ModemInterface::masterDevice() const
 
113
{
 
114
    Q_D(const ModemInterface);
 
115
    return_SOLID_CALL(Ifaces::ModemInterface *, d->backendObject(), QString(), masterDevice());
 
116
}
 
117
 
 
118
QString Solid::Control::ModemInterface::driver() const
 
119
{
 
120
    Q_D(const ModemInterface);
 
121
    return_SOLID_CALL(Ifaces::ModemInterface *, d->backendObject(), QString(), driver());
 
122
}
 
123
 
 
124
Solid::Control::ModemInterface::Type Solid::Control::ModemInterface::type() const
 
125
{
 
126
    Q_D(const ModemInterface);
 
127
    return_SOLID_CALL(Ifaces::ModemInterface *, d->backendObject(), Solid::Control::ModemInterface::UnknownType, type());
 
128
}
 
129
 
 
130
bool Solid::Control::ModemInterface::enabled() const
 
131
{
 
132
    Q_D(const ModemInterface);
 
133
    return_SOLID_CALL(Ifaces::ModemInterface *, d->backendObject(), false, enabled());
 
134
}
 
135
 
 
136
QString Solid::Control::ModemInterface::unlockRequired() const
 
137
{
 
138
    Q_D(const ModemInterface);
 
139
    return_SOLID_CALL(Ifaces::ModemInterface *, d->backendObject(), QString(), unlockRequired());
 
140
}
 
141
 
 
142
Solid::Control::ModemInterface::Method Solid::Control::ModemInterface::ipMethod() const
 
143
{
 
144
    Q_D(const ModemInterface);
 
145
    return_SOLID_CALL(Ifaces::ModemInterface *, d->backendObject(), UnknownMethod, ipMethod());
 
146
}
 
147
 
 
148
void Solid::Control::ModemInterface::slotDeviceChanged(const QString & device)
 
149
{
 
150
    emit deviceChanged(device);
 
151
}
 
152
 
 
153
void Solid::Control::ModemInterface::slotMasterDeviceChanged(const QString & masterDevice)
 
154
{
 
155
    emit masterDeviceChanged(masterDevice);
 
156
}
 
157
 
 
158
void Solid::Control::ModemInterface::slotDriverChanged(const QString & driver)
 
159
{
 
160
    emit driverChanged(driver);
 
161
}
 
162
 
 
163
void Solid::Control::ModemInterface::slotUnlockRequiredChanged(const QString & codeRequired)
 
164
{
 
165
    emit unlockRequiredChanged(codeRequired);
 
166
}
 
167
 
 
168
void Solid::Control::ModemInterfacePrivate::setBackendObject(QObject *object)
 
169
{
 
170
    FrontendObjectPrivate::setBackendObject(object);
 
171
 
 
172
    if (object) {
 
173
        QObject::connect(object, SIGNAL(deviceChanged(const QString &)),
 
174
                         parent(), SLOT(slotDeviceChanged(const QString &)));
 
175
        QObject::connect(object, SIGNAL(masterDeviceChanged(const QString &)),
 
176
                         parent(), SLOT(slotMasterDeviceChanged(const QString &)));
 
177
        QObject::connect(object, SIGNAL(driverChanged(const QString &)),
 
178
                         parent(), SLOT(slotDriverChanged(const QString &)));
 
179
        QObject::connect(object, SIGNAL(typeChanged(const Solid::Control::ModemInterface::Type)),
 
180
                         parent(), SIGNAL(typeChanged(const Solid::Control::ModemInterface::Type)));
 
181
        QObject::connect(object, SIGNAL(enabledChanged(const bool)),
 
182
                         parent(), SIGNAL(enabledChanged(const bool)));
 
183
        QObject::connect(object, SIGNAL(unlockRequiredChanged(const QString &)),
 
184
                         parent(), SLOT(slotUnlockRequiredChanged(const QString &)));
 
185
        QObject::connect(object, SIGNAL(ipMethodChanged(const Solid::Control::ModemInterface::Method)),
 
186
                         parent(), SIGNAL(ipMethodChanged(const Solid::Control::ModemInterface::Method)));
 
187
    }
 
188
}
 
189
 
 
190
QString Solid::Control::ModemInterface::convertTypeToString(const Solid::Control::ModemInterface::Type type)
 
191
{
 
192
    switch (type) {
 
193
        case UnknownType: return i18nc("Unknown cellular type","Unknown");
 
194
        case GsmType: return i18nc("Gsm cellular type","Gsm");
 
195
        case CdmaType: return i18nc("Cdma cellular type","Cdma");
 
196
    }
 
197
 
 
198
    return i18nc("Unknown cellular type","Unknown");
 
199
}
 
200
 
 
201
QString Solid::Control::ModemInterface::convertBandToString(const Solid::Control::ModemInterface::Band band)
 
202
{
 
203
    switch (band) {
 
204
        case UnknownBand: return i18nc("Unknown cellular frequency band","Unknown");
 
205
        case AnyBand: return i18nc("Any cellular frequency band","Any");
 
206
        case Egsm: return i18nc("Cellular frequency band","GSM/GPRS/EDGE 900 MHz");
 
207
        case Dcs: return i18nc("Cellular frequency band","GSM/GPRS/EDGE 1800 MHz");
 
208
        case Pcs: return i18nc("Cellular frequency band","GSM/GPRS/EDGE 1900 MHz");
 
209
        case G850: return i18nc("Cellular frequency band","GSM/GPRS/EDGE 850 MHz");
 
210
        case U2100: return i18nc("Cellular frequency band","WCDMA 2100 MHz (Class I)");
 
211
        case U1800: return i18nc("Cellular frequency band","WCDMA 3GPP 1800 MHz (Class III)");
 
212
        case U17IV: return i18nc("Cellular frequency band","WCDMA 3GPP AWS 1700/2100 MHz (Class IV)");
 
213
        case U800: return i18nc("Cellular frequency band","WCDMA 3GPP UMTS 800 MHz (Class VI)");
 
214
        case U850: return i18nc("Cellular frequency band","WCDMA 3GPP UMTS 850 MHz (Class V)");
 
215
        case U900: return i18nc("Cellular frequency band","WCDMA 3GPP UMTS 900 MHz (Class VIII)");
 
216
        case U17IX: return i18nc("Cellular frequency band","WCDMA 3GPP UMTS 1700 MHz (Class IX)");
 
217
        case U19IX: return i18nc("Cellular frequency band","WCDMA 3GPP UMTS 1900 MHz (Class II)");
 
218
    }
 
219
 
 
220
    return i18nc("Unknown cellular frequency band","Unknown");
 
221
}
 
222
 
 
223
QString Solid::Control::ModemInterface::convertAllowedModeToString(const Solid::Control::ModemInterface::AllowedMode mode)
 
224
{
 
225
    switch (mode) {
 
226
        case AnyModeAllowed: return i18nc("Allowed Gsm modes (2G/3G/any)","Any");
 
227
        case Prefer2g: return i18nc("Allowed Gsm modes (2G/3G/any)","Prefer 2G");
 
228
        case Prefer3g: return i18nc("Allowed Gsm modes (2G/3G/any)","Prefer 3G");
 
229
        case UseOnly2g: return i18nc("Allowed Gsm modes (2G/3G/any)","Only 2G");
 
230
        case UseOnly3g: return i18nc("Allowed Gsm modes (2G/3G/any)","Only 3G");
 
231
    }
 
232
 
 
233
    return i18nc("Allowed Gsm modes (2G/3G/any)","Any");
 
234
}
 
235
 
 
236
QString Solid::Control::ModemInterface::convertAccessTechnologyToString(const Solid::Control::ModemInterface::AccessTechnology tech)
 
237
{
 
238
    switch (tech) {
 
239
        case UnknownTechnology: return i18nc("Unknown cellular access technology","Unknown");
 
240
        case Gsm: return i18nc("Cellular access technology","GSM");
 
241
        case GsmCompact: return i18nc("Cellular access technology","Compact GSM");
 
242
        case Gprs: return i18nc("Cellular access technology","GPRS");
 
243
        case Edge: return i18nc("Cellular access technology","EDGE");
 
244
        case Umts: return i18nc("Cellular access technology","UMTS");
 
245
        case Hsdpa: return i18nc("Cellular access technology","HSDPA");
 
246
        case Hsupa: return i18nc("Cellular access technology","HSUPA");
 
247
        case Hspa: return i18nc("Cellular access technology","HSPA");
 
248
    }
 
249
 
 
250
    return i18nc("Unknown cellular access technology","Unknown");
 
251
}
 
252
 
 
253
#include "modeminterface.moc"