Exemplo n.º 1
0
void
ServerProxy::setClipboard()
{
	// parse
	static String dataCached;
	ClipboardID id;
	UInt32 seq;
	
	int r = ClipboardChunk::assemble(m_stream, dataCached, id, seq);

	if (r == kStart) {
		size_t size = ClipboardChunk::getExpectedSize();
		LOG((CLOG_DEBUG "receiving clipboard %d size=%d", id, size));
	}
	else if (r == kFinish) {
		LOG((CLOG_DEBUG "received clipboard %d size=%d", id, dataCached.size()));
		
		// forward
		Clipboard clipboard;
		clipboard.unmarshall(dataCached, 0);
		m_client->setClipboard(id, &clipboard);

		LOG((CLOG_INFO "clipboard was updated"));
	}
}
Exemplo n.º 2
0
void
ServerProxy::setClipboard()
{
	// parse
	static String dataCached;
	ClipboardID id;
	UInt32 seq;
	
	int r = ClipboardChunk::assemble(m_stream, dataCached, id, seq);

	if (r == kFinish) {
		LOG((CLOG_DEBUG "received clipboard %d size=%d", id, dataCached.size()));
		
		// forward
		Clipboard clipboard;
		clipboard.unmarshall(dataCached, 0);
		m_client->setClipboard(id, &clipboard);

		LOG((CLOG_NOTIFY "clipboard transmission complete"));
	}
	else if (r == kStart) {
		size_t size = ClipboardChunk::getExpectedSize();
		LOG((CLOG_NOTIFY "clipboard transmission started: start receiving %u bytes of clipboard data", size));
	}
}
Exemplo n.º 3
0
TEST(ClipboardTests, unmarshall_withTextAndHtml_getHtmlIsValid)
{
    Clipboard clipboard;
    String data;
    data += (char)0;
    data += (char)0;
    data += (char)0;
    data += (char)2; // 2 formats added
    data += (char)0;
    data += (char)0;
    data += (char)0;
    data += (char)IClipboard::kText;
    data += (char)0;
    data += (char)0;
    data += (char)0;
    data += (char)14;
    data += "synergy rocks!";
    data += (char)0;
    data += (char)0;
    data += (char)0;
    data += (char)IClipboard::kHTML;
    data += (char)0;
    data += (char)0;
    data += (char)0;
    data += (char)10;
    data += "html sucks";

    clipboard.unmarshall(data, 0);

    clipboard.open(0);
    String actual = clipboard.get(IClipboard::kHTML);
    EXPECT_EQ("html sucks", actual);
}
Exemplo n.º 4
0
TEST(ClipboardTests, unmarshall_withTextSize285_getTextIsValid)
{
    Clipboard clipboard;

    // 285 chars
    String text;
    text.append("Synergy is Free and Open Source Software that lets you ");
    text.append("easily share your mouse and keyboard between multiple ");
    text.append("computers, where each computer has it's own display. No ");
    text.append("special hardware is required, all you need is a local area ");
    text.append("network. Synergy is supported on Windows, Mac OS X and Linux.");

    String data;
    data += (char)0;
    data += (char)0;
    data += (char)0;
    data += (char)1; // 1 format added
    data += (char)0;
    data += (char)0;
    data += (char)0;
    data += (char)IClipboard::kText;
    data += (char)0; // 285 >> 24 = 285 / (256^3) = 0
    data += (char)0; // 285 >> 16 = 285 / (256^2) = 0
    data += (char)1; // 285 >> 8 = 285 / (256^1) = 1(.11328125)
    data += (char)29; // 285 - 256 = 29
    data += text;

    clipboard.unmarshall(data, 0);

    clipboard.open(0);
    String actual = clipboard.get(IClipboard::kText);
    EXPECT_EQ(text, actual);
}
Exemplo n.º 5
0
TEST(ClipboardTests, unmarshall_emptyData_hasTextIsFalse)
{
    Clipboard clipboard;

    String data;
    data += (char)0;
    data += (char)0;
    data += (char)0;
    data += (char)0; // 0 formats added

    clipboard.unmarshall(data, 0);

    clipboard.open(0);
    bool actual = clipboard.has(IClipboard::kText);
    EXPECT_FALSE(actual);
}
Exemplo n.º 6
0
void
ServerProxy::setClipboard()
{
	// parse
	ClipboardID id;
	UInt32 seqNum;
	String data;
	ProtocolUtil::readf(m_stream, kMsgDClipboard + 4, &id, &seqNum, &data);
	LOG((CLOG_DEBUG "recv clipboard %d size=%d", id, data.size()));

	// validate
	if (id >= kClipboardEnd) {
		return;
	}

	// forward
	Clipboard clipboard;
	clipboard.unmarshall(data, 0);
	m_client->setClipboard(id, &clipboard);
}