00001 #include <stdlib.h>
00002 #include <stdio.h>
00003 #include <fcntl.h>
00004 #include <sys/termios.h>
00005
00006 #include <qmultilineedit.h>
00007 #include <qsocketnotifier.h>
00008
00009 #include "../profile.h"
00010 #include "../io_serial.h"
00011 #include "../filetransfer.h"
00012 #include "../filereceive.h"
00013
00014 #include <opie2/oprocess.h>
00015
00016 #include "senderui.h"
00017
00018 using namespace Opie::Core;
00019 using namespace Opie::Core;
00020 SenderUI::SenderUI()
00021 : Sender() {
00022
00023
00024 Profile prof;
00025 QString str = "/dev/bty0";
00026 prof.writeEntry("Device",str );
00027 prof.writeEntry("Baud", 19200 );
00028
00029 owarn << "prof " + prof.readEntry("Device") + " " + str << oendl;
00030 ser = new IOSerial(prof);
00031 connect(ser, SIGNAL(received(const QByteArray&) ),
00032 this, SLOT(got(const QByteArray&) ) );
00033
00034 if ( ser->open() )
00035 owarn << "opened!!!" << oendl;
00036 else
00037 owarn << "could not open" << oendl;
00038
00039
00040 }
00041 SenderUI::~SenderUI() {
00042
00043 }
00044 void SenderUI::slotSendFile() {
00045
00046 sz = new FileTransfer(FileTransfer::SY, ser);
00047 sz->sendFile("/home/ich/bootopie-v06-13.jffs2");
00048
00049 connect (sz, SIGNAL(sent()),
00050 this, SLOT(fileTransComplete()));
00051 }
00052
00053 void SenderUI::slotSend() {
00054 QCString str = MultiLineEdit1->text().utf8();
00055 owarn << "sending: " << str.data() << "" << oendl;
00056 str = str.replace( QRegExp("\n"), "\r");
00057 ser->send( str );
00058 }
00059 void SenderUI::got(const QByteArray& ar) {
00060 owarn << "got:" << oendl;
00061 for ( uint i = 0; i < ar.count(); i++ ) {
00062 printf("%c", ar[i] );
00063 }
00064 printf("\n");
00065 }
00066
00067 void SenderUI::fileTransComplete() {
00068
00069 owarn << "file transfer complete" << oendl;
00070 }
00071 void SenderUI::send() {
00072
00073 }
00074 void SenderUI::slotRev(){
00075 owarn << "Going to receive!" << oendl;
00076 FileReceive *rev = new FileReceive( FileReceive::SZ, ser );
00077 rev->receive();
00078
00079 }