[Pkg-owncloud-commits] [owncloud-client] 454/470: Windows Shell Integration: Unify path lookups
Sandro Knauß
hefee-guest at moszumanska.debian.org
Thu May 12 16:25:43 UTC 2016
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit 0e9170cb36576813ca277b2df4a9475dd16234c6
Author: Daniel Molkentin <danimo at owncloud.com>
Date: Mon May 9 15:49:52 2016 +0200
Windows Shell Integration: Unify path lookups
---
.../windows/OCContextMenu/OCClientInterface.cpp | 16 +--------------
.../windows/OCUtil/CommunicationSocket.cpp | 24 ++++++++++++++++++++--
.../windows/OCUtil/CommunicationSocket.h | 4 +++-
.../windows/OCUtil/RemotePathChecker.cpp | 17 +--------------
4 files changed, 27 insertions(+), 34 deletions(-)
diff --git a/shell_integration/windows/OCContextMenu/OCClientInterface.cpp b/shell_integration/windows/OCContextMenu/OCClientInterface.cpp
index 7f21292..598a10d 100644
--- a/shell_integration/windows/OCContextMenu/OCClientInterface.cpp
+++ b/shell_integration/windows/OCContextMenu/OCClientInterface.cpp
@@ -34,23 +34,9 @@ using namespace std;
#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)) {
diff --git a/shell_integration/windows/OCUtil/CommunicationSocket.cpp b/shell_integration/windows/OCUtil/CommunicationSocket.cpp
index a4004f7..e37487b 100644
--- a/shell_integration/windows/OCUtil/CommunicationSocket.cpp
+++ b/shell_integration/windows/OCUtil/CommunicationSocket.cpp
@@ -24,11 +24,31 @@
#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)
diff --git a/shell_integration/windows/OCUtil/CommunicationSocket.h b/shell_integration/windows/OCUtil/CommunicationSocket.h
index 312f470..fc06f06 100644
--- a/shell_integration/windows/OCUtil/CommunicationSocket.h
+++ b/shell_integration/windows/OCUtil/CommunicationSocket.h
@@ -26,6 +26,8 @@
class __declspec(dllexport) CommunicationSocket
{
public:
+ static std::wstring DefaultPipePath();
+
CommunicationSocket();
~CommunicationSocket();
@@ -43,4 +45,4 @@ private:
bool _connected;
};
-#endif
\ No newline at end of file
+#endif
diff --git a/shell_integration/windows/OCUtil/RemotePathChecker.cpp b/shell_integration/windows/OCUtil/RemotePathChecker.cpp
index fcca989..b0b4df0 100644
--- a/shell_integration/windows/OCUtil/RemotePathChecker.cpp
+++ b/shell_integration/windows/OCUtil/RemotePathChecker.cpp
@@ -31,25 +31,10 @@
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;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list