summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth/manager/rfcpopup.cpp
blob: 7711f0afdcf2925e6f9b09c034876473cbeb0d33 (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121

#include "pppdialog.h"
#include "rfcpopup.h"
#include "rfcommassigndialogimpl.h"

/* OPIE */
#include <qpe/qpeapplication.h>
#include <opie2/odebug.h>
#include <opie2/oprocess.h>

using namespace Opie::Core;

/* QT */
#include <qtimer.h>

using namespace OpieTooth;

/*
 * c'tor init the QAction
 */
RfcCommPopup::RfcCommPopup(const OpieTooth::Services& service, 
  OpieTooth::BTDeviceItem* item)
        : QPopupMenu(), m_service(service)
{
    owarn << "RfcCommPopup c'tor" << oendl; 

    QAction* a;
    int port = service.protocolDescriptorList().last().port();
    QString mac = item->mac();
    unsigned int i;

    procId = -1;
    m_item = item;

    for (i = 0; i < sizeof(PPPDialog::conns) / sizeof(Connection); i++) {
      if (PPPDialog::conns[i].port == port && 
          PPPDialog::conns[i].btAddr == mac && 
          PPPDialog::conns[i].proc.isRunning()) {
          /* disconnect action */
          a = new QAction(  );
          a->setText("Disconnect");
          a->addTo( this );
          connect( a, SIGNAL( activated() ) ,
                this, SLOT( slotDisconnect() ) );
          procId = i;
          break;
      }
    }
    if (procId == -1) {
        /* connect action */
        a = new QAction(  ); // so it's get deleted
        a->setText("Connect");
        a->addTo( this );
        connect( a,  SIGNAL( activated() ),
                this, SLOT( slotConnect() ) );
    }

    /* foo action */
    a = new QAction(  );
    a->setText("Bind table");
    a->addTo( this );
    connect( a, SIGNAL( activated() ),
             this, SLOT( slotBind() ) );


    /* bar action */
    a = new QAction(  );
    a->setText( "Bar" );
    a->addTo( this );
    connect( a, SIGNAL( activated() ),
             this, SLOT( slotBar() ) );

};


RfcCommPopup::~RfcCommPopup()
{
    /*  delete m_con;
        delete m_dis;
        delete m_foo;
        delete m_bar; */
}


void RfcCommPopup::slotConnect()
{

    owarn << "connect" << oendl; 

    PPPDialog pppDialog(m_item->mac(), 
      m_service.protocolDescriptorList().last().port());
    QPEApplication::execDialog( &pppDialog );
}


void RfcCommPopup::slotDisconnect()
{
    owarn << "slot disconnected " << procId << oendl; 
    if (procId >= 0)
        PPPDialog::conns[procId].proc.kill();
}


void RfcCommPopup::slotBind()
{
    RfcommAssignDialog rfcommAssign ( this, "RfcommAssignDialog", true, WStyle_ContextHelp  );

    rfcommAssign.newDevice( m_item->mac() );

    if ( QPEApplication::execDialog( &rfcommAssign ) == QDialog::Accepted )
    {
        rfcommAssign.saveConfig();
    }
}


void RfcCommPopup::slotBar()
{
    owarn << "slotBar" << oendl; 
};