#define PIPE_TIMEOUT 5*1000 //ms
#define SOCK_BUFFER 4096
-// TODO: Unify this with RemotePathChecker.cpp
-#define BUFSIZE 512
-std::wstring getUserName() {
- DWORD len = BUFSIZE;
- TCHAR buf[BUFSIZE];
- if (GetUserName(buf, &len)) {
- return std::wstring(&buf[0], len);
- } else {
- return std::wstring();
- }
-}
-
OCClientInterface::ContextMenuInfo OCClientInterface::FetchInfo()
{
- auto pipename = std::wstring(L"\\\\.\\pipe\\");
- pipename += L"ownCloud\\";
- pipename += getUserName();
+ auto pipename = CommunicationSocket::DefaultPipePath();
CommunicationSocket socket;
if (!WaitNamedPipe(pipename.data(), PIPE_TIMEOUT)) {
#include <fstream>
-#define BUFSIZE 1024
+#define DEFAULT_BUFLEN 4096
using namespace std;
-#define DEFAULT_BUFLEN 4096
+namespace {
+
+std::wstring getUserName() {
+ DWORD len = DEFAULT_BUFLEN;
+ TCHAR buf[DEFAULT_BUFLEN];
+ if (GetUserName(buf, &len)) {
+ return std::wstring(&buf[0], len);
+ } else {
+ return std::wstring();
+ }
+}
+
+}
+
+std::wstring CommunicationSocket::DefaultPipePath()
+{
+ auto pipename = std::wstring(L"\\\\.\\pipe\\");
+ pipename += L"ownCloud\\";
+ pipename += getUserName();
+ return pipename;
+}
CommunicationSocket::CommunicationSocket()
: _pipe(INVALID_HANDLE_VALUE)
class __declspec(dllexport) CommunicationSocket
{
public:
+ static std::wstring DefaultPipePath();
+
CommunicationSocket();
~CommunicationSocket();
bool _connected;
};
-#endif
\ No newline at end of file
+#endif
using namespace std;
-// FIXME: Unify this with OCClientInterface.cpp
-#define BUFSIZE 512
-std::wstring getUserName() {
- DWORD len = BUFSIZE;
- TCHAR buf[BUFSIZE];
- if (GetUserName(buf, &len)) {
- return std::wstring(&buf[0], len);
- } else {
- return std::wstring();
- }
-}
-
// This code is run in a thread
void RemotePathChecker::workerThreadLoop()
{
- auto pipename = std::wstring(L"\\\\.\\pipe\\");
- pipename += L"ownCloud\\";
- pipename += getUserName();
-
+ auto pipename = CommunicationSocket::DefaultPipePath();
bool connected = false;
CommunicationSocket socket;
std::unordered_set<std::wstring> asked;