Renamed FileChunker to StreamChunker #4601
This commit is contained in:
parent
4c36c08099
commit
30f96b9fbb
|
@ -27,7 +27,7 @@
|
||||||
#include "synergy/ProtocolUtil.h"
|
#include "synergy/ProtocolUtil.h"
|
||||||
#include "synergy/protocol_types.h"
|
#include "synergy/protocol_types.h"
|
||||||
#include "synergy/XSynergy.h"
|
#include "synergy/XSynergy.h"
|
||||||
#include "synergy/FileChunker.h"
|
#include "synergy/StreamChunker.h"
|
||||||
#include "synergy/IPlatformScreen.h"
|
#include "synergy/IPlatformScreen.h"
|
||||||
#include "mt/Thread.h"
|
#include "mt/Thread.h"
|
||||||
#include "net/TCPSocket.h"
|
#include "net/TCPSocket.h"
|
||||||
|
@ -422,12 +422,12 @@ Client::sendConnectionFailedEvent(const char* msg)
|
||||||
void
|
void
|
||||||
Client::sendFileChunk(const void* data)
|
Client::sendFileChunk(const void* data)
|
||||||
{
|
{
|
||||||
FileChunker::FileChunk* fileChunk = reinterpret_cast<FileChunker::FileChunk*>(const_cast<void*>(data));
|
StreamChunker::Chunk* chunk = reinterpret_cast<StreamChunker::Chunk*>(const_cast<void*>(data));
|
||||||
LOG((CLOG_DEBUG1 "sendFileChunk"));
|
LOG((CLOG_DEBUG1 "send file chunk"));
|
||||||
assert(m_server != NULL);
|
assert(m_server != NULL);
|
||||||
|
|
||||||
// relay
|
// relay
|
||||||
m_server->fileChunkSending(fileChunk->m_chunk[0], &(fileChunk->m_chunk[1]), fileChunk->m_dataSize);
|
m_server->fileChunkSending(chunk->m_chunk[0], &(chunk->m_chunk[1]), chunk->m_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -821,7 +821,7 @@ Client::sendFileThread(void* filename)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
char* name = reinterpret_cast<char*>(filename);
|
char* name = reinterpret_cast<char*>(filename);
|
||||||
FileChunker::sendFileChunks(name, m_events, this);
|
StreamChunker::sendFileChunks(name, m_events, this);
|
||||||
}
|
}
|
||||||
catch (std::runtime_error error) {
|
catch (std::runtime_error error) {
|
||||||
LOG((CLOG_ERR "failed sending file chunks: %s", error.what()));
|
LOG((CLOG_ERR "failed sending file chunks: %s", error.what()));
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include "server/ClientProxy1_5.h"
|
#include "server/ClientProxy1_5.h"
|
||||||
|
|
||||||
#include "server/Server.h"
|
#include "server/Server.h"
|
||||||
#include "synergy/FileChunker.h"
|
#include "synergy/StreamChunker.h"
|
||||||
#include "synergy/ProtocolUtil.h"
|
#include "synergy/ProtocolUtil.h"
|
||||||
#include "io/IStream.h"
|
#include "io/IStream.h"
|
||||||
#include "base/Log.h"
|
#include "base/Log.h"
|
||||||
|
|
|
@ -2033,13 +2033,13 @@ Server::onMouseWheel(SInt32 xDelta, SInt32 yDelta)
|
||||||
void
|
void
|
||||||
Server::onFileChunkSending(const void* data)
|
Server::onFileChunkSending(const void* data)
|
||||||
{
|
{
|
||||||
FileChunker::FileChunk* fileChunk = reinterpret_cast<FileChunker::FileChunk*>(const_cast<void*>(data));
|
StreamChunker::Chunk* chunk = reinterpret_cast<StreamChunker::Chunk*>(const_cast<void*>(data));
|
||||||
|
|
||||||
LOG((CLOG_DEBUG1 "onFileChunkSending"));
|
LOG((CLOG_DEBUG1 "sending file chunk"));
|
||||||
assert(m_active != NULL);
|
assert(m_active != NULL);
|
||||||
|
|
||||||
// relay
|
// relay
|
||||||
m_active->fileChunkSending(fileChunk->m_chunk[0], &(fileChunk->m_chunk[1]), fileChunk->m_dataSize);
|
m_active->fileChunkSending(chunk->m_chunk[0], &(chunk->m_chunk[1]), chunk->m_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -2376,7 +2376,7 @@ Server::sendFileThread(void* data)
|
||||||
try {
|
try {
|
||||||
char* filename = reinterpret_cast<char*>(data);
|
char* filename = reinterpret_cast<char*>(data);
|
||||||
LOG((CLOG_DEBUG "sending file to client, filename=%s", filename));
|
LOG((CLOG_DEBUG "sending file to client, filename=%s", filename));
|
||||||
FileChunker::sendFileChunks(filename, m_events, this);
|
StreamChunker::sendFileChunks(filename, m_events, this);
|
||||||
}
|
}
|
||||||
catch (std::runtime_error error) {
|
catch (std::runtime_error error) {
|
||||||
LOG((CLOG_ERR "failed sending file chunks, error: %s", error.what()));
|
LOG((CLOG_ERR "failed sending file chunks, error: %s", error.what()));
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "synergy/FileChunker.h"
|
#include "synergy/StreamChunker.h"
|
||||||
|
|
||||||
#include "synergy/protocol_types.h"
|
#include "synergy/protocol_types.h"
|
||||||
#include "base/EventTypes.h"
|
#include "base/EventTypes.h"
|
||||||
|
@ -33,10 +33,10 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
const size_t FileChunker::m_chunkSize = 512 * 1024; // 512kb
|
const size_t StreamChunker::m_chunkSize = 512 * 1024; // 512kb
|
||||||
|
|
||||||
void
|
void
|
||||||
FileChunker::sendFileChunks(char* filename, IEventQueue* events, void* eventTarget)
|
StreamChunker::sendFileChunks(char* filename, IEventQueue* events, void* eventTarget)
|
||||||
{
|
{
|
||||||
std::fstream file(reinterpret_cast<char*>(filename), std::ios::in | std::ios::binary);
|
std::fstream file(reinterpret_cast<char*>(filename), std::ios::in | std::ios::binary);
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ FileChunker::sendFileChunks(char* filename, IEventQueue* events, void* eventTarg
|
||||||
// send first message (file size)
|
// send first message (file size)
|
||||||
String fileSize = intToString(size);
|
String fileSize = intToString(size);
|
||||||
size_t sizeLength = fileSize.size();
|
size_t sizeLength = fileSize.size();
|
||||||
FileChunk* sizeMessage = new FileChunk(sizeLength + 2);
|
Chunk* sizeMessage = new Chunk(sizeLength + 2);
|
||||||
char* chunkData = sizeMessage->m_chunk;
|
char* chunkData = sizeMessage->m_chunk;
|
||||||
|
|
||||||
chunkData[0] = kDataStart;
|
chunkData[0] = kDataStart;
|
||||||
|
@ -73,7 +73,7 @@ FileChunker::sendFileChunks(char* filename, IEventQueue* events, void* eventTarg
|
||||||
}
|
}
|
||||||
|
|
||||||
// for fileChunk->m_chunk, the first byte is the chunk mark, last is \0
|
// for fileChunk->m_chunk, the first byte is the chunk mark, last is \0
|
||||||
FileChunk* fileChunk = new FileChunk(chunkSize + 2);
|
Chunk* fileChunk = new Chunk(chunkSize + 2);
|
||||||
char* chunkData = fileChunk->m_chunk;
|
char* chunkData = fileChunk->m_chunk;
|
||||||
|
|
||||||
chunkData[0] = kDataChunk;
|
chunkData[0] = kDataChunk;
|
||||||
|
@ -93,7 +93,7 @@ FileChunker::sendFileChunks(char* filename, IEventQueue* events, void* eventTarg
|
||||||
}
|
}
|
||||||
|
|
||||||
// send last message
|
// send last message
|
||||||
FileChunk* transferFinished = new FileChunk(2);
|
Chunk* transferFinished = new Chunk(2);
|
||||||
chunkData = transferFinished->m_chunk;
|
chunkData = transferFinished->m_chunk;
|
||||||
|
|
||||||
chunkData[0] = kDataEnd;
|
chunkData[0] = kDataEnd;
|
||||||
|
@ -104,8 +104,9 @@ FileChunker::sendFileChunks(char* filename, IEventQueue* events, void* eventTarg
|
||||||
}
|
}
|
||||||
|
|
||||||
String
|
String
|
||||||
FileChunker::intToString(size_t i)
|
StreamChunker::intToString(size_t i)
|
||||||
{
|
{
|
||||||
|
//TODO: this should be in string
|
||||||
stringstream ss;
|
stringstream ss;
|
||||||
ss << i;
|
ss << i;
|
||||||
return ss.str();
|
return ss.str();
|
|
@ -21,20 +21,20 @@
|
||||||
|
|
||||||
class IEventQueue;
|
class IEventQueue;
|
||||||
|
|
||||||
class FileChunker {
|
class StreamChunker {
|
||||||
public:
|
public:
|
||||||
//! FileChunk data
|
//! FileChunk data
|
||||||
class FileChunk {
|
class Chunk {
|
||||||
public:
|
public:
|
||||||
FileChunk(size_t chunkSize) : m_dataSize(chunkSize - 2)
|
Chunk(size_t size) : m_size(size - 2)
|
||||||
{
|
{
|
||||||
m_chunk = new char[chunkSize];
|
m_chunk = new char[size];
|
||||||
}
|
}
|
||||||
|
|
||||||
~FileChunk() { delete[] m_chunk; }
|
~Chunk() { delete[] m_chunk; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const size_t m_dataSize;
|
const size_t m_size;
|
||||||
char* m_chunk;
|
char* m_chunk;
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#include "server/Server.h"
|
#include "server/Server.h"
|
||||||
#include "server/ClientListener.h"
|
#include "server/ClientListener.h"
|
||||||
#include "client/Client.h"
|
#include "client/Client.h"
|
||||||
#include "synergy/FileChunker.h"
|
#include "synergy/StreamChunker.h"
|
||||||
#include "net/SocketMultiplexer.h"
|
#include "net/SocketMultiplexer.h"
|
||||||
#include "net/NetworkAddress.h"
|
#include "net/NetworkAddress.h"
|
||||||
#include "net/TCPSocketFactory.h"
|
#include "net/TCPSocketFactory.h"
|
||||||
|
@ -417,7 +417,7 @@ NetworkTests::sendMockData(void* eventTarget)
|
||||||
// send first message (file size)
|
// send first message (file size)
|
||||||
String size = intToString(kMockDataSize);
|
String size = intToString(kMockDataSize);
|
||||||
size_t sizeLength = size.size();
|
size_t sizeLength = size.size();
|
||||||
FileChunker::FileChunk* sizeMessage = new FileChunker::FileChunk(sizeLength + 2);
|
StreamChunker::Chunk* sizeMessage = new StreamChunker::Chunk(sizeLength + 2);
|
||||||
char* chunkData = sizeMessage->m_chunk;
|
char* chunkData = sizeMessage->m_chunk;
|
||||||
|
|
||||||
chunkData[0] = kDataStart;
|
chunkData[0] = kDataStart;
|
||||||
|
@ -437,7 +437,7 @@ NetworkTests::sendMockData(void* eventTarget)
|
||||||
}
|
}
|
||||||
|
|
||||||
// first byte is the chunk mark, last is \0
|
// first byte is the chunk mark, last is \0
|
||||||
FileChunker::FileChunk* fileChunk = new FileChunker::FileChunk(chunkSize + 2);
|
StreamChunker::Chunk* fileChunk = new StreamChunker::Chunk(chunkSize + 2);
|
||||||
char* chunkData = fileChunk->m_chunk;
|
char* chunkData = fileChunk->m_chunk;
|
||||||
|
|
||||||
chunkData[0] = kDataChunk;
|
chunkData[0] = kDataChunk;
|
||||||
|
@ -455,7 +455,7 @@ NetworkTests::sendMockData(void* eventTarget)
|
||||||
}
|
}
|
||||||
|
|
||||||
// send last message
|
// send last message
|
||||||
FileChunker::FileChunk* transferFinished = new FileChunker::FileChunk(2);
|
StreamChunker::Chunk* transferFinished = new StreamChunker::Chunk(2);
|
||||||
chunkData = transferFinished->m_chunk;
|
chunkData = transferFinished->m_chunk;
|
||||||
|
|
||||||
chunkData[0] = kDataEnd;
|
chunkData[0] = kDataEnd;
|
||||||
|
|
Loading…
Reference in New Issue