summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth/lib/startdunconnection.cpp
blob: 6b6d2477f7023e306711170e680dc7c5753fb741 (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

#include "startdunconnection.h"

using namespace OpieTooth;


StartDunConnection::StartDunConnection() {
    m_dunConnect = 0l;
    setConnectionType();
}

StartDunConnection::~StartDunConnection() {
    delete m_dunConnect;
}

StartDunConnection::StartDunConnection( QString mac )  {
    m_dunConnect = 0l;
    m_mac = mac;
    setConnectionType();
}

void StartDunConnection::setName( QString name ) {
    m_name = name;
}

QString StartDunConnection::name()  {
    return m_name;
}

void StartDunConnection::setConnectionType() {
    m_connectionType = Pan;
}

StartConnection::ConnectionType StartDunConnection::type() {
    return m_connectionType;
}

void StartDunConnection::start()  {
    m_dunConnect = new OProcess();
    *m_dunConnect << "dund" << "--listen" << "--connect"  << m_mac;

    connect( m_dunConnect, SIGNAL( processExited( OProcess* ) ) ,
             this, SLOT( slotExited( OProcess* ) ) );
    connect( m_dunConnect, SIGNAL( receivedStdout( OProcess*, char*, int ) ),
             this, SLOT( slotStdOut( OProcess*, char*, int ) ) );
    if (!m_dunConnect->start( OProcess::NotifyOnExit, OProcess::AllOutput) ) {
        qWarning( "could not start" );
        delete m_dunConnect;
    }
}


void StartDunConnection::slotExited( OProcess* proc ) {
    delete m_dunConnect;
}

void StartDunConnection::slotStdOut(OProcess* proc, char* chars, int len)
{}


void StartDunConnection::stop()  {
    if ( m_dunConnect )  {
        delete m_dunConnect;
        m_dunConnect = 0l;
    }
}