shell_integration: Fetch the share menu title from the client on Windows

The context menu will now show "Share with ownCloud" instead of "Share" as
it does on other platforms.

This also updates the submodule to point to matching binaries.
This commit is contained in:
Jocelyn Turcotte 2015-02-13 16:00:22 +01:00
parent 40dbc78407
commit 23e248b5d1
5 changed files with 22 additions and 11 deletions

2
binary

@ -1 +1 @@
Subproject commit 96dd38811b58b28146a204124a8e764b3513b7f4
Subproject commit 5a664de4d3ac2b6edb6a16edbb5e376724e64e76

View file

@ -81,7 +81,7 @@ file manager integration works.
.. image:: images/client8.png
When you are in your local ownCloud folder you can right-click any file or
folder, and then left-click Share to create a share link. Note that Windows
folder, and then left-click "Share with ownCloud" to create a share link. Note that Windows
may also have a Share With option. This is not the ownCloud Share option. The
ownCloud share dialog looks like the following example:

View file

@ -34,28 +34,33 @@ using namespace std;
#define PIPE_TIMEOUT 5*1000 //ms
#define SOCK_BUFFER 4096
std::vector<std::wstring> OCClientInterface::WatchedDirectories()
OCClientInterface::ContextMenuInfo OCClientInterface::FetchInfo()
{
auto pipename = std::wstring(L"\\\\.\\pipe\\");
pipename += L"ownCloud";
CommunicationSocket socket;
if (!WaitNamedPipe(pipename.data(), PIPE_TIMEOUT)) {
return std::vector<std::wstring>();
return {};
}
if (!socket.Connect(pipename)) {
return std::vector<std::wstring>();
return {};
}
std::vector<std::wstring> watchedDirectories;
socket.SendMsg(L"SHARE_MENU_TITLE\n");
ContextMenuInfo info;
std::wstring response;
Sleep(50);
while (socket.ReadLine(&response)) {
if (StringUtil::begins_with(response, wstring(L"REGISTER_PATH:"))) {
wstring responsePath = response.substr(14); // length of REGISTER_PATH
watchedDirectories.push_back(responsePath);
info.watchedDirectories.push_back(responsePath);
}
else if (StringUtil::begins_with(response, wstring(L"SHARE_MENU_TITLE:"))) {
info.shareMenuTitle = response.substr(17); // length of SHARE_MENU_TITLE:
}
}
return watchedDirectories;
return info;
}
void OCClientInterface::ShareObject(const std::wstring &path)

View file

@ -43,7 +43,11 @@ class CommunicationSocket;
class OCClientInterface
{
public:
static std::vector<std::wstring> WatchedDirectories();
struct ContextMenuInfo {
std::vector<std::wstring> watchedDirectories;
std::wstring shareMenuTitle;
};
static ContextMenuInfo FetchInfo();
static void ShareObject(const std::wstring &path);
};

View file

@ -150,8 +150,9 @@ IFACEMETHODIMP OCContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT
return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(0));
}
OCClientInterface::ContextMenuInfo info = OCClientInterface::FetchInfo();
bool skip = true;
for (const std::wstring path : OCClientInterface::WatchedDirectories()) {
for (const std::wstring path : info.watchedDirectories) {
if (StringUtil::begins_with(std::wstring(m_szSelectedFile), path)) {
skip = false;
break;
@ -165,11 +166,12 @@ IFACEMETHODIMP OCContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT
InsertSeperator(hMenu, indexMenu);
indexMenu++;
assert(!info.shareMenuTitle.empty());
MENUITEMINFO mii = { sizeof(mii) };
mii.fMask = MIIM_BITMAP | MIIM_STRING | MIIM_FTYPE | MIIM_ID | MIIM_STATE;
mii.wID = idCmdFirst + IDM_SHARE;
mii.fType = MFT_STRING;
mii.dwTypeData = m_pszMenuText;
mii.dwTypeData = &info.shareMenuTitle[0];
mii.fState = MFS_ENABLED;
if (!InsertMenuItem(hMenu, indexMenu, TRUE, &mii))
{