summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/test/senderui.cpp
blob: 4a7202d171288e9c8604b3ded2f4a29456c0a19f (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
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/termios.h>

#include <qmultilineedit.h>
#include <qsocketnotifier.h>

#include "../profile.h"
#include "../io_serial.h"
#include "../filetransfer.h"
#include "../filereceive.h"

#include <opie2/oprocess.h>

#include "senderui.h"

SenderUI::SenderUI()
    : Sender() {

    /* we do that manually */
    Profile prof;
    QString str = "/dev/bty0";
    prof.writeEntry("Device",str );
    prof.writeEntry("Baud", 19200 );

    qWarning("prof " + prof.readEntry("Device")  + " " + str);
    ser = new IOSerial(prof);
    connect(ser, SIGNAL(received(const QByteArray& ) ),
            this, SLOT(got(const QByteArray&) ) );

    if ( ser->open() )
        qWarning("opened!!!");
    else
        qWarning("could not open");


}
SenderUI::~SenderUI() {

}
void SenderUI::slotSendFile() {

    sz = new FileTransfer(FileTransfer::SY, ser);
    sz->sendFile("/home/ich/bootopie-v06-13.jffs2");

    connect (sz, SIGNAL(sent()),
             this, SLOT(fileTransComplete()));
}

void SenderUI::slotSend() {
    QCString str = MultiLineEdit1->text().utf8();
    qWarning("sending: %s", str.data() );
    str = str.replace( QRegExp("\n"), "\r");
    ser->send( str );
}
void SenderUI::got(const QByteArray& ar) {
    qWarning("got:");
    for ( uint i = 0; i < ar.count(); i++ ) {
        printf("%c", ar[i] );
    }
    printf("\n");
}

void SenderUI::fileTransComplete() {

    qWarning("file transfer complete");
}
void SenderUI::send() {

}
void SenderUI::slotRev(){
qWarning("Going to receive!");
FileReceive *rev = new FileReceive( FileReceive::SZ, ser );
rev->receive();

}