~ubuntu-branches/ubuntu/precise/kwlan/precise

« back to all changes in this revision

Viewing changes to kwlan/kwlantraywin.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mark Purcell
  • Date: 2007-03-29 22:23:38 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070329222338-3p6oilnz17bz7b6x
Tags: 0.6.1-2
Upload to unstable 

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
    m_wpaMenu->setItemParameter(WPASETTINGSID,WPASETTINGSID);
49
49
    connect (m_wpaMenu,SIGNAL(activated(int )), this, SLOT(handleWpaMenuEvent(int )));
50
50
    m_wpaMenu->setItemEnabled(WPASTOPID,FALSE);
51
 
    
 
51
    m_interfacesMenu = new KPopupMenu();
 
52
    connect (m_interfacesMenu, SIGNAL(activated(int )),SLOT(slotHandleInterfacesMenu( int )));
 
53
    m_configureInterfacesMenu = new KPopupMenu();
 
54
    connect (m_configureInterfacesMenu, SIGNAL(activated(int )),SLOT(slotHandleConfigureInterfacesMenu( int )));
52
55
    m_timer = new QTimer(this);
53
56
    if (m_timer){
54
57
        connect (m_timer, SIGNAL(timeout()),SLOT(updateIcon()));
90
93
void KwlanTrayWin::contextMenuAboutToShow( KPopupMenu *r ) {
91
94
    QString *prof, curProf;
92
95
    updateNetworks();
93
 
    if (! m_interface) return;
 
96
    if (! m_interface) 
 
97
    {
 
98
        kdDebug() << "Context menu cannot be shown: No interface found!!!" << endl;
 
99
        return;
 
100
    }
94
101
    curProf = m_interface->getCurrentProfile();
95
102
    int id;
96
103
    r->clear();
97
104
    r->insertTitle(SmallIcon ("kwlan"), "Kwlan - KDE Connection Manager");
 
105
    
 
106
    m_configureInterfacesMenu->clear();
 
107
    m_interfacesMenu->clear();
 
108
    id = 1;
 
109
 
98
110
    if (m_interface->getConfigureInterface())
99
111
    {
100
112
        // Now fill in the profiles into profile menu
101
 
        id = 1;
102
 
        m_profileMenu->clear();
103
 
        if (m_interface->getType()!=KwlanInterface::PPP){
104
 
            m_profileMenu->insertItem(i18n("Edit profiles"),id);
105
 
            m_profileMenu->setItemParameter(id,id);
106
 
            id++;
107
 
            if (m_interface->getInterfaceData().wirelessDevice)
108
 
            {
109
 
                m_profileMenu->insertItem(i18n("Scan"),id);
110
 
                m_profileMenu->setItemParameter(id,id);
111
 
                id++;
112
 
            }
113
 
            if (!m_profiles.isEmpty())
114
 
            {
115
 
                m_profileMenu->insertSeparator(id);
116
 
                id++;
117
 
            }
 
113
        if (m_interface->getType()!=KwlanInterface::PPP)
 
114
        {
 
115
            if (!(m_interface->getMainWin())) return;
 
116
            QStringList interfaces = ((m_interface->getMainWin())->getInterfaces());
 
117
            for (QStringList::iterator it = interfaces.begin(); it !=interfaces.end();it++)
 
118
            {
 
119
                m_interfacesMenu->insertItem(*it,id);
 
120
                m_interfacesMenu->setItemParameter(id,id);
 
121
                m_interfacesMenu->setItemChecked(id, mainConfiguration().readMonitorInterface( *it));
 
122
                m_configureInterfacesMenu->insertItem(*it,id);
 
123
                m_configureInterfacesMenu->setItemParameter(id,id);
 
124
                m_configureInterfacesMenu->setItemChecked(id, mainConfiguration().readConfigureInterface( *it));
 
125
                id++;
 
126
            }
 
127
            r->insertItem(i18n("Monitor interfaces"),m_interfacesMenu);
 
128
            r->insertItem(i18n("Configure interfaces"),m_configureInterfacesMenu);
 
129
            id = 1;
 
130
            m_profileMenu->clear();
118
131
            prof = m_profiles.first();
119
 
            while (prof){
 
132
            while (prof)
 
133
            {
120
134
            //kdDebug() << "Inserting profile " << *prof << endl;
121
135
                m_profileMenu->insertItem(*prof,id);
122
136
                m_profileMenu->setItemParameter(id,id);
127
141
                prof=m_profiles.next();
128
142
                id++;
129
143
            }
130
 
            r->insertItem(i18n("Profiles"),m_profileMenu);
 
144
            r->insertItem(i18n("Activate Profile"),m_profileMenu);
131
145
            r->insertItem(i18n("Wpa"),m_wpaMenu);
132
146
            r->insertSeparator();
133
147
        }
134
 
        //now set the interface enable / disable menu
 
148
    }
 
149
    //now set the interface enable / disable menu
 
150
    if (m_interface->getConfigureInterface() || (m_interface->getType() == KwlanInterface::PPP))
 
151
    {
135
152
        QString enableMenu;
136
153
        if (m_interface->getInterfaceData().up) enableMenu = i18n("Disable");
137
154
        else enableMenu = i18n("Enable");
146
163
    }
147
164
    
148
165
}
 
166
void KwlanTrayWin::slotHandleInterfacesMenu( int id)
 
167
{
 
168
    if (::debugOutput) kdDebug()<< "Monitor interface " <<m_interfacesMenu->text(id) << endl;
 
169
    mainConfiguration().writeMonitorInterface( m_interfacesMenu->text(id), !m_interfacesMenu->isItemChecked(id));
 
170
    emit sigMonitorInterface( m_interfacesMenu->text(id),!m_interfacesMenu->isItemChecked(id));
 
171
}
 
172
 
 
173
void KwlanTrayWin::slotHandleConfigureInterfacesMenu( int id)
 
174
{
 
175
    if (::debugOutput) kdDebug()<< "Configure interface " <<m_configureInterfacesMenu->text(id) << endl;
 
176
    mainConfiguration().writeConfigureInterface( m_configureInterfacesMenu->text(id), !m_configureInterfacesMenu->isItemChecked(id));
 
177
    emit sigConfigureInterface( m_configureInterfacesMenu->text(id),!m_configureInterfacesMenu->isItemChecked(id));
 
178
}
149
179
 
150
180
void KwlanTrayWin::clearProfiles()
151
181
{
157
187
    QStringList networks;
158
188
    clearProfiles();
159
189
    if (!m_interface) return;
160
 
    networks= m_interface->listProfiles();
 
190
    //networks= m_interface->listProfiles();
 
191
    if (mainConfiguration().readShowAvailableOnly())
 
192
        networks = m_interface->getAvailableProfiles();
 
193
    else networks = m_interface->listProfiles();
161
194
    for (QStringList::Iterator it=networks.begin();it != networks.end();it++){
162
195
        m_profiles.append(new QString(*it));
163
196
    }
228
261
void KwlanTrayWin::selectProfile(int id)
229
262
{
230
263
    //kdDebug() <<"select Profile " <<m_profileMenu->text(id) << endl;
 
264
    emit profileChanged(m_profileMenu->text(id));
 
265
    /*
231
266
    switch (id)
232
267
    {
233
268
        case 1:
239
274
        default:
240
275
            emit profileChanged(m_profileMenu->text(id));
241
276
    }
 
277
    */
242
278
}
243
279
 
244
280
void KwlanTrayWin::wpaStart()
298
334
 
299
335
void KwlanTrayWin::slotInterfaceGone(KwlanInterface *interface)
300
336
{
301
 
    kdDebug() << "Closing traywin..." << endl;
 
337
    if (::debugOutput) kdDebug() << "Closing traywin..." << endl;
302
338
    m_interface=0L;
303
339
    m_timer->stop();
304
340
    close();
384
420
    wireless_disconnected = kIcon->iconPath("kwlan/wireless-disconnected",KIcon::Desktop);
385
421
    wired_connected = kIcon->iconPath("kwlan/wired-none",KIcon::Desktop);
386
422
    wired_disconnected = kIcon->iconPath("kwlan/wired-disconnected",KIcon::Desktop);
387
 
    if (data.connected) {
 
423
    //if (data.connected) {
 
424
    if (parent->getInterface()->getState()==KwlanInterface::CONFIGURED) {
388
425
        if (parent->getInterface()->getType() == KwlanInterface::PPP)
389
426
        {
390
427
            tooltip = QString("<center><img align=center src=%1></center>").arg(dialup);
434
471
            tooltip = QString("<center><img align=center src=%1></center>").arg(wired_disconnected);
435
472
        }
436
473
        tooltip += QString("<center><table border=0 bgcolor=#000000 cellspacing=1 cellpadding=1>");
437
 
        tooltip += QString(i18n("<tr><td bgcolor=#DD0500><center>[ %1 ] <b>is disconnected</b></center></td></tr>")).arg(ifname);
438
 
        if (data.wirelessDevice && wData.radioOff) {
439
 
            tooltip += QString(i18n("<tr><td bgcolor=#CCCCCC><center>The radio is off</center></td></tr>"));
 
474
        switch (parent->getInterface()->getState())
 
475
        {
 
476
            case KwlanInterface::DISABLED:
 
477
                tooltip += QString(i18n("<tr><td bgcolor=#DD0500><center>[ %1 ] <b>is disabled</b></center></td></tr>")).arg(ifname);
 
478
                if (data.wirelessDevice && wData.radioOff) {
 
479
                    tooltip += QString(i18n("<tr><td bgcolor=#CCCCCC><center>The radio is off</center></td></tr>"));
 
480
                }
 
481
                break;
 
482
            case KwlanInterface::CONNECTED:
 
483
                tooltip += QString(i18n("<tr><td bgcolor=#DD0500><center>[ %1 ] <b> is requesting ip address</b></center></td></tr>")).arg(ifname);
 
484
                break;
 
485
            case KwlanInterface::NOTCONNECTED:
 
486
                tooltip += QString(i18n("<tr><td bgcolor=#DD0500><center>[ %1 ] <b>is not connected</b></center></td></tr>")).arg(ifname);
440
487
        }
441
488
        tooltip += QString("</table></center>");
442
489
    }