summaryrefslogtreecommitdiffstats
path: root/examples/network/remotecontrol/startup.cpp
blob: 985ee496541a1d4b4dee2cd512eec01b3c6390ac (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
#include "startup.h"
#include "remotectrlimpl.h"
#include "maindialog.h"
#include "ipcserver.h"

#include <tqsocket.h>
#include <ntqlabel.h>

static const TQ_UINT16 ipcPort = 54923;

StartUp::StartUp()
{
    remoteCtrl = 0;
    mainDialog = 0;

    socket = new TQSocket( this );
    connect( socket, TQ_SIGNAL(connected()), TQ_SLOT(startRemoteCtrl()) );
    connect( socket, TQ_SIGNAL(error(int)), TQ_SLOT(startMainDialog()) );
    socket->connectToHost( "localhost", ipcPort );
}

StartUp::~StartUp()
{
    delete remoteCtrl;
    delete mainDialog;
}

void StartUp::startRemoteCtrl()
{
    remoteCtrl = new RemoteCtrlImpl( socket );
    remoteCtrl->show();
}

void StartUp::startMainDialog()
{
    mainDialog = new MainDialog();
    mainDialog->show();

    IpcServer *server = new IpcServer( ipcPort, this );

    connect( server, TQ_SIGNAL(receivedText(const TQString&)),
	    mainDialog->description, TQ_SLOT(setText(const TQString&)) );
    connect( server, TQ_SIGNAL(receivedPixmap(const TQPixmap&)),
	    mainDialog->image, TQ_SLOT(setPixmap(const TQPixmap&)) );
}