Skip to content

Commit

Permalink
Merge pull request #710 from p12tic/use-std-string-2
Browse files Browse the repository at this point in the history
lib/client: Use std::string directly instead of String typedef
  • Loading branch information
shymega committed May 30, 2020
2 parents 4039bc2 + a0af288 commit df15e76
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 26 deletions.
18 changes: 8 additions & 10 deletions src/lib/client/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,10 @@
// Client
//

Client::Client(
IEventQueue* events,
const String& name, const NetworkAddress& address,
ISocketFactory* socketFactory,
barrier::Screen* screen,
ClientArgs const& args) :
Client::Client(IEventQueue* events, const std::string& name, const NetworkAddress& address,
ISocketFactory* socketFactory,
barrier::Screen* screen,
ClientArgs const& args) :
m_mock(false),
m_name(name),
m_serverAddress(address),
Expand Down Expand Up @@ -373,7 +371,7 @@ Client::setOptions(const OptionsList& options)
m_screen->setOptions(options);
}

String
std::string
Client::getName() const
{
return m_name;
Expand Down Expand Up @@ -403,7 +401,7 @@ Client::sendClipboard(ClipboardID id)
m_timeClipboard[id] = clipboard.getTime();

// marshall the data
String data = clipboard.marshall();
std::string data = clipboard.marshall();

// save and send data if different or not yet sent
if (!m_sentClipboard[id] || data != m_dataClipboard[id]) {
Expand Down Expand Up @@ -783,7 +781,7 @@ Client::writeToDropDirThread(void*)
}

void
Client::dragInfoReceived(UInt32 fileNum, String data)
Client::dragInfoReceived(UInt32 fileNum, std::string data)
{
// TODO: fix duplicate function from CServer
if (!m_args.m_enableDragDrop) {
Expand Down Expand Up @@ -830,7 +828,7 @@ Client::sendFileThread(void* filename)
}

void
Client::sendDragInfo(UInt32 fileCount, String& info, size_t size)
Client::sendDragInfo(UInt32 fileCount, std::string& info, size_t size)
{
m_server->sendDragInfo(fileCount, info.c_str(), size);
}
20 changes: 10 additions & 10 deletions src/lib/client/Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Client : public IClient, public INode {
public:
FailInfo(const char* what) : m_retry(false), m_what(what) { }
bool m_retry;
String m_what;
std::string m_what;
};

public:
Expand All @@ -57,7 +57,7 @@ class Client : public IClient, public INode {
as its name and \p address as the server's address and \p factory
to create the socket. \p screen is the local screen.
*/
Client(IEventQueue* events, const String& name,
Client(IEventQueue* events, const std::string& name,
const NetworkAddress& address, ISocketFactory* socketFactory,
barrier::Screen* screen, ClientArgs const& args);

Expand Down Expand Up @@ -86,13 +86,13 @@ class Client : public IClient, public INode {
virtual void handshakeComplete();

//! Received drag information
void dragInfoReceived(UInt32 fileNum, String data);
void dragInfoReceived(UInt32 fileNum, std::string data);

//! Create a new thread and use it to send file to Server
void sendFileToServer(const char* filename);

//! Send dragging file information back to server
void sendDragInfo(UInt32 fileCount, String& info, size_t size);
void sendDragInfo(UInt32 fileCount, std::string& info, size_t size);


//@}
Expand Down Expand Up @@ -126,7 +126,7 @@ class Client : public IClient, public INode {
size_t& getExpectedFileSize() { return m_expectedFileSize; }

//! Return received file data
String& getReceivedFileData() { return m_receivedFileData; }
std::string& getReceivedFileData() { return m_receivedFileData; }

//! Return drag file list
DragFileList getDragFileList() { return m_dragFileList; }
Expand Down Expand Up @@ -160,7 +160,7 @@ class Client : public IClient, public INode {
virtual void screensaver(bool activate);
virtual void resetOptions();
virtual void setOptions(const OptionsList& options);
virtual String getName() const;
virtual std::string getName() const;

private:
void sendClipboard(ClipboardID);
Expand Down Expand Up @@ -198,7 +198,7 @@ class Client : public IClient, public INode {
bool m_mock;

private:
String m_name;
std::string m_name;
NetworkAddress m_serverAddress;
ISocketFactory* m_socketFactory;
barrier::Screen* m_screen;
Expand All @@ -212,12 +212,12 @@ class Client : public IClient, public INode {
bool m_ownClipboard[kClipboardEnd];
bool m_sentClipboard[kClipboardEnd];
IClipboard::Time m_timeClipboard[kClipboardEnd];
String m_dataClipboard[kClipboardEnd];
std::string m_dataClipboard[kClipboardEnd];
IEventQueue* m_events;
std::size_t m_expectedFileSize;
String m_receivedFileData;
std::string m_receivedFileData;
DragFileList m_dragFileList;
String m_dragFileExt;
std::string m_dragFileExt;
Thread* m_sendFileThread;
Thread* m_writeToDropDirThread;
TCPSocket* m_socket;
Expand Down
10 changes: 5 additions & 5 deletions src/lib/client/ServerProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ ServerProxy::onGrabClipboard(ClipboardID id)
void
ServerProxy::onClipboardChanged(ClipboardID id, const IClipboard* clipboard)
{
String data = IClipboard::marshall(clipboard);
std::string data = IClipboard::marshall(clipboard);
LOG((CLOG_DEBUG "sending clipboard %d seqnum=%d", id, m_seqNum));

StreamChunker::sendClipboard(data, data.size(), id, m_seqNum, m_events, this);
Expand Down Expand Up @@ -550,7 +550,7 @@ void
ServerProxy::setClipboard()
{
// parse
static String dataCached;
static std::string dataCached;
ClipboardID id;
UInt32 seq;

Expand Down Expand Up @@ -872,7 +872,7 @@ ServerProxy::fileChunkReceived()
}
else if (result == kStart) {
if (m_client->getDragFileList().size() > 0) {
String filename = m_client->getDragFileList().at(0).getFilename();
std::string filename = m_client->getDragFileList().at(0).getFilename();
LOG((CLOG_DEBUG "start receiving %s", filename.c_str()));
}
}
Expand All @@ -883,7 +883,7 @@ ServerProxy::dragInfoReceived()
{
// parse
UInt32 fileNum = 0;
String content;
std::string content;
ProtocolUtil::readf(m_stream, kMsgDDragInfo + 4, &fileNum, &content);

m_client->dragInfoReceived(fileNum, content);
Expand All @@ -904,6 +904,6 @@ ServerProxy::fileChunkSending(UInt8 mark, char* data, size_t dataSize)
void
ServerProxy::sendDragInfo(UInt32 fileCount, const char* info, size_t size)
{
String data(info, size);
std::string data(info, size);
ProtocolUtil::writef(m_stream, kMsgDDragInfo, fileCount, &data);
}
1 change: 0 additions & 1 deletion src/lib/client/ServerProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "barrier/key_types.h"
#include "base/Event.h"
#include "base/Stopwatch.h"
#include "base/String.h"

class Client;
class ClientInfo;
Expand Down

0 comments on commit df15e76

Please sign in to comment.