summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth/manager/dunpopup.cpp
blob: c304b2d05a0eb6b20baed55e4bec8066e2806ed1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/* $Id$ */
/* DUN context menu */
/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/
#include <qpe/qcopenvelope_qws.h>
#include <qmessagebox.h>
#include <opie2/odebug.h>
#include <opie2/oprocess.h>
#include <qpe/qpeapplication.h>
using namespace Opie::Core;

#include "dunpopup.h"
#include "dundialog.h"

using namespace OpieTooth;

/*
 * c'tor init the QAction
 */
DunPopup::DunPopup( const Services& service,
    BTDeviceItem* item ) : QPopupMenu(), m_service(service) {

    owarn << "DunPopup c'tor" << oendl; 

    m_item = item;
    QAction *a, *b, *c;

    a = new QAction(); // so it's get deleted
    a->setText( tr("connect") );
    a->addTo( this );
    connect( a, SIGNAL( activated() ), this, SLOT( slotConnect() ) );

    b = new QAction();
    b->setText( tr( "connect+conf" ) );
    b->addTo( this );
    connect( b, SIGNAL( activated() ), this, SLOT( slotConnectAndConfig() ) );

    c = new QAction();
    c->setText( tr( "disconnect" ) );
    c->addTo( this );
    connect( c, SIGNAL( activated() ), this, SLOT( slotDisconnect() ) );

};

DunPopup::~DunPopup() {

}

void DunPopup::slotConnect() {
    odebug << "connect" << oendl;
    DunDialog dundlg(m_item->mac(),
        m_service.protocolDescriptorList().last().port());
    QPEApplication::execDialog( &dundlg );
}

void DunPopup::slotDisconnect()  {
    OProcess dunDis;
    OProcess pppDis;
    dunDis << tr("dund") << tr("--kill") << m_item->mac();
    dunDis.start(OProcess::DontCare, OProcess::NoCommunication);
    pppDis << tr("killall") << tr("-q") << tr("pppd");
    pppDis.start(OProcess::DontCare, OProcess::NoCommunication);
    sleep(1);
    QMessageBox::information(this, tr("DUN Disconnect"), tr("DUN Disconnected"));
}


void DunPopup::slotConnectAndConfig() {
    slotConnect();

    // more intelligence here later like passing the device ( bnepX )
    QCopEnvelope e( "QPE/System", "execute(QString)" );
    e << QString( "networksettings" );
}