~ubuntu-branches/ubuntu/precise/networkmanagement/precise-updates

« back to all changes in this revision

Viewing changes to settings/config/mobileconnectionwizard.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michael Biebl, Modestas Vainius, Michael Biebl
  • Date: 2011-05-27 12:18:25 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20110527121825-vfufwquq3vy0k3zn
Tags: 0.1+git20110526.911025d-1
[ Modestas Vainius ]
* Use official KDE branding in the package descriptions.

[ Michael Biebl ]
* New upstream Git snapshot 911025d81fdfbe09b64705e94e5411f521c38e3e.
* debian/control
  - Bump Build-Depends on kdelibs5-dev and kdebase-workspace-dev to
    (>= 4:4.6.0).
  - Bump Build-Depends on network-manager-dev and libnm-util-dev to
    (>= 0.8.1).
  - Bump Depends on network-manager to (>= 0.8.1).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
2
2
/*
3
 
Copyright 2010 Lamarque Souza <lamarque@gmail.com>
 
3
Copyright 2010-2011 Lamarque Souza <lamarque@gmail.com>
4
4
 
5
5
This program is free software; you can redistribute it and/or
6
6
modify it under the terms of the GNU General Public License as
28
28
#include <KIconLoader>
29
29
#ifdef COMPILE_MODEM_MANAGER_SUPPORT
30
30
#include <solid/control/modemmanager.h>
 
31
#include <solid/device.h>
31
32
#endif
32
33
 
33
34
#include "mobileconnectionwizard.h"
34
35
 
35
 
MobileConnectionWizard::MobileConnectionWizard(QWidget * parent): QWizard(parent)
 
36
MobileConnectionWizard::MobileConnectionWizard(Knm::Connection::Type connectionType, QWidget * parent): QWizard(parent)
36
37
{
 
38
    if (connectionType == Knm::Connection::Unknown) {
 
39
        mInitialMethodType = false;
 
40
    } else {
 
41
        mInitialMethodType = true;
 
42
 
 
43
        if (connectionType == Knm::Connection::Bluetooth) {
 
44
            mType = Knm::Connection::Gsm;
 
45
        } else {
 
46
            mType = connectionType;
 
47
        }
 
48
    }
 
49
 
37
50
    mProviders = new MobileProviders();
38
51
    setWindowTitle(i18nc("Mobile Connection Wizard", "New Mobile Broadband Connection"));
39
52
    addPage(createIntroPage());
61
74
void MobileConnectionWizard::initializePage(int id)
62
75
{
63
76
    switch (id) {
64
 
        case 1: // Country Page
 
77
        case 1: { // Country Page
65
78
            //QString country = KGlobal::locale()->country();
66
79
            if (country.isEmpty()) {
67
80
                country = mProviders->countryFromLocale();
75
88
                }
76
89
            }
77
90
 
78
 
            mIface = Solid::Control::NetworkManager::findNetworkInterface(mDeviceComboBox->itemData(mDeviceComboBox->currentIndex()).toString());
 
91
            if (!mInitialMethodType) {
 
92
                Solid::Control::NetworkInterface *iface = Solid::Control::NetworkManager::findNetworkInterface(mDeviceComboBox->itemData(mDeviceComboBox->currentIndex()).toString());
 
93
                if (iface && iface->type() == Solid::Control::NetworkInterface::Cdma) {
 
94
                    mType = Knm::Connection::Cdma;
 
95
                } else {
 
96
                    mType = Knm::Connection::Gsm;
 
97
                }
 
98
            }
 
99
 
79
100
            if (mProviders->getError() != MobileProviders::Success) {
80
101
                accept();
81
102
            }
82
103
            break;
 
104
        }
83
105
 
84
106
        case 2: // Providers Page
85
107
            country = mCountryList->currentItem()->text();
204
226
    return temp;
205
227
}
206
228
 
207
 
Knm::Connection::Type MobileConnectionWizard::type() const
208
 
{
209
 
    if (mIface && mIface->type() == Solid::Control::NetworkInterface::Cdma) {
210
 
        return Knm::Connection::Cdma;
211
 
    }
212
 
 
213
 
    return Knm::Connection::Gsm;
214
 
}
215
 
 
216
229
/**********************************************************/
217
230
/* Intro page */
218
231
/**********************************************************/
236
249
                                    arg(i18nc("Mobile Connection Wizard", "(in some cases) Your broadband billing plan APN (Access Point Name)")));
237
250
    layout->addWidget(label);
238
251
 
239
 
    label = new QLabel("\n" + i18nc("Mobile Connection Wizard", "Create a connection for &this mobile broadband device:"));
240
 
    layout->addWidget(label);
241
 
 
242
 
    mDeviceComboBox = new QComboBox();
243
 
    mDeviceComboBox->addItem(i18nc("Mobile Connection Wizard", "Any device"));
244
 
    mDeviceComboBox->insertSeparator(1);
245
 
    label->setBuddy(mDeviceComboBox);
246
 
    layout->addWidget(mDeviceComboBox);
247
 
 
248
 
    QObject::connect(Solid::Control::NetworkManager::notifier(), SIGNAL(networkInterfaceAdded(const QString)),
249
 
                     this, SLOT(introDeviceAdded(const QString)));
250
 
    QObject::connect(Solid::Control::NetworkManager::notifier(), SIGNAL(networkInterfaceRemoved(const QString)),
251
 
                     this, SLOT(introDeviceRemoved(const QString)));
252
 
    QObject::connect(Solid::Control::NetworkManager::notifier(), SIGNAL(statusChanged(Solid::Networking::Status)),
253
 
                     this, SLOT(introStatusChanged(Solid::Networking::Status)));
254
 
 
255
 
    introAddInitialDevices();
 
252
    if (!mInitialMethodType) {
 
253
        label = new QLabel("\n" + i18nc("Mobile Connection Wizard", "Create a connection for &this mobile broadband device:"));
 
254
        layout->addWidget(label);
 
255
    
 
256
        mDeviceComboBox = new QComboBox();
 
257
        mDeviceComboBox->addItem(i18nc("Mobile Connection Wizard", "Any device"));
 
258
        mDeviceComboBox->insertSeparator(1);
 
259
        label->setBuddy(mDeviceComboBox);
 
260
        layout->addWidget(mDeviceComboBox);
 
261
    
 
262
        QObject::connect(Solid::Control::NetworkManager::notifier(), SIGNAL(networkInterfaceAdded(const QString)),
 
263
                         this, SLOT(introDeviceAdded(const QString)));
 
264
        QObject::connect(Solid::Control::NetworkManager::notifier(), SIGNAL(networkInterfaceRemoved(const QString)),
 
265
                         this, SLOT(introDeviceRemoved(const QString)));
 
266
        QObject::connect(Solid::Control::NetworkManager::notifier(), SIGNAL(statusChanged(Solid::Networking::Status)),
 
267
                         this, SLOT(introStatusChanged(Solid::Networking::Status)));
 
268
    
 
269
        introAddInitialDevices();
 
270
    }
256
271
 
257
272
    page->setLayout(layout);
258
273
 
265
280
 
266
281
#ifdef COMPILE_MODEM_MANAGER_SUPPORT
267
282
    Solid::Control::ModemInterface *modem = Solid::Control::ModemManager::findModemInterface(device->udi(), Solid::Control::ModemInterface::GsmCard);
268
 
    if (modem && modem->enabled()) {
269
 
        desc.append(modem->getInfo().manufacturer);
270
 
        desc.append(" ");
271
 
        desc.append(modem->getInfo().model);
 
283
    if (modem) {
 
284
        if (modem->enabled()) {
 
285
            desc.append(modem->getInfo().manufacturer);
 
286
            desc.append(" ");
 
287
            desc.append(modem->getInfo().model);
 
288
        } else {
 
289
            QString deviceName = modem->masterDevice();
 
290
            foreach (const Solid::Device &d, Solid::Device::allDevices()) {
 
291
                if (d.udi().contains(deviceName, Qt::CaseInsensitive)) {
 
292
                    deviceName = d.product();
 
293
                    if (!deviceName.startsWith(d.vendor())) {
 
294
                        deviceName = d.vendor() + " " + deviceName;
 
295
                    }
 
296
                    desc.append(deviceName);
 
297
                    break;
 
298
                }
 
299
            }
 
300
        }
272
301
    }
273
302
#endif
274
303