~ubuntu-branches/ubuntu/precise/plasma-widget-networkmanagement/precise

« back to all changes in this revision

Viewing changes to libs/ui/ipv4widget.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2011-03-21 13:52:36 UTC
  • mfrom: (1.1.16 upstream)
  • Revision ID: james.westby@ubuntu.com-20110321135236-mfkytyn2hujfwapm
Tags: 0.9~svngit20110312-0ubuntu1
* New upstream snapshot
* Add build-dep and runtime depends on mobile-broadband-provider-info
* Add =binary version to plasma-widget-networkmanagement depends on knm-runtime

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
    IpV4WidgetPrivate() : setting(0), isAdvancedModeOn(false)
43
43
    {
44
44
    }
45
 
    enum MethodIndex { AutomaticMethodIndex = 0, AutomaticOnlyIPMethodIndex, LinkLocalMethodIndex, ManualMethodIndex, SharedMethodIndex };
 
45
 
 
46
    // Make sure that this order is same as the combobox shown in ipv4.ui file
 
47
    enum MethodIndex { AutomaticMethodIndex = 0, AutomaticOnlyIPMethodIndex, ManualMethodIndex, LinkLocalMethodIndex, SharedMethodIndex };
46
48
    Ui_SettingsIp4Config ui;
47
49
    Knm::Ipv4Setting * setting;
48
50
    bool isAdvancedModeOn;
61
63
    QString str_auto_only;
62
64
    Knm::Connection::Type connType = connection->type();
63
65
 
 
66
    kDebug() << connection->name() << connection->uuid().toString() << connection->typeAsString(connection->type());
 
67
 
64
68
    if (Knm::Connection::Vpn == connType) {
65
69
        str_auto = i18nc("@item:inlistbox IPv4 settings configuration method",
66
70
                         "Automatic (VPN)");
108
112
    connect(d->ui.dnsSearchMorePushButton, SIGNAL(clicked()), this, SLOT(showDnsSearchEditor()));
109
113
 
110
114
    d->setting = static_cast<Knm::Ipv4Setting*>(connection->setting(Knm::Setting::Ipv4));
 
115
 
 
116
    kDebug() << "Method is" << d->setting->method() << d->setting->dhcpclientid();
 
117
 
111
118
    connect(d->ui.method, SIGNAL(currentIndexChanged(int)), this, SLOT(methodChanged(int)));
112
119
    methodChanged(d->AutomaticMethodIndex);
113
120
}
118
125
 
119
126
void IpV4Widget::readConfig()
120
127
{
 
128
    kDebug() << "Reading IPv4 settings...";
 
129
 
121
130
    Q_D(IpV4Widget);
122
131
    // The following flags are used to not fill disabled fields.
123
132
    // Setting and handling them is quite redundant, but it's necessary
127
136
 
128
137
    switch (d->setting->method()) {
129
138
        case Knm::Ipv4Setting::EnumMethod::Automatic:
 
139
            kDebug() << "Method: Automatic";
130
140
            if (d->setting->ignoredhcpdns()) {
131
141
                d->ui.method->setCurrentIndex(d->AutomaticOnlyIPMethodIndex);
132
142
                dnsPartEnabled = true;
136
146
            }
137
147
            break;
138
148
        case Knm::Ipv4Setting::EnumMethod::LinkLocal:
 
149
            kDebug() << "Method: LinkLocal";
139
150
            d->ui.method->setCurrentIndex(d->LinkLocalMethodIndex);
140
151
            break;
141
152
        case Knm::Ipv4Setting::EnumMethod::Manual:
 
153
            kDebug() << "Method: Manual";
142
154
            d->ui.method->setCurrentIndex(d->ManualMethodIndex);
143
155
            addressPartEnabled = dnsPartEnabled = true;
144
156
            break;
145
157
        case Knm::Ipv4Setting::EnumMethod::Shared:
 
158
            kDebug() << "Method: Shared";
146
159
            d->ui.method->setCurrentIndex(d->SharedMethodIndex);
147
160
            break;
148
161
        default:
398
411
    dnsSearchEditor->show();
399
412
}
400
413
 
 
414
void IpV4Widget::setDns(const QList<QVariant> dnsList)
 
415
{
 
416
    if (dnsList.isEmpty()) {
 
417
        return;
 
418
    }
 
419
 
 
420
    Q_D(IpV4Widget);
 
421
    QList<QHostAddress> temp;
 
422
    foreach (const QVariant &dns, dnsList) {
 
423
        QHostAddress dnsAddr(dns.toString());
 
424
        if (dnsAddr != QHostAddress::Null) {
 
425
            temp << dnsAddr;
 
426
        }
 
427
    }
 
428
 
 
429
    d->setting->setMethod(Knm::Ipv4Setting::EnumMethod::Automatic);
 
430
    d->setting->setIgnoredhcpdns(true);
 
431
    d->setting->setDns(temp);
 
432
    readConfig();
 
433
}
 
434
 
401
435
void IpV4Widget::validate()
402
436
{
403
437