2 * Copyright 2017, Adrien Destugues, pulkomandy@pulkomandy.tk
3 * Distributed under terms of the MIT license.
7 #include "FileSender.h"
13 #include <SerialPort.h>
16 FileSender::~FileSender()
21 RawSender::RawSender(BDataIO
* source
, BSerialPort
* sink
, BHandler
* listener
)
23 // FIXME doing this all here in the constructor is not good. We need to
24 // do things asynchronously instead so as not to lock the application
29 BPositionIO
* pos
= dynamic_cast<BPositionIO
*>(source
);
31 pos
->GetSize(&sourceSize
);
36 BMessenger
messenger(listener
);
40 ssize_t s
= source
->Read(&buffer
, sizeof(buffer
));
44 sink
->Write(buffer
, s
);
47 BMessage
msg(kMsgProgress
);
48 msg
.AddInt32("pos", position
);
49 msg
.AddInt32("size", sourceSize
);
50 msg
.AddString("info", "Sending" B_UTF8_ELLIPSIS
);
51 messenger
.SendMessage(&msg
);
58 RawSender::~RawSender()
64 RawSender::BytesReceived(const uint8_t* data
, size_t length
)
66 // Nothing to do with received bytes, this protocol has no kind of
67 // acknowledgement from remote side.