Exemplo n.º 1
0
bool ContextMenuUtil::PerformAction(int command)
{
	ContextMenuItem*  item;
	
	if(!GetContextMenuItem(command, &item))
	{
		return false;
	}

	wstring* list = new wstring();

	if(!ParserUtil::SerializeList(_selectedFiles, list, true))
	{
		return false;
	}
	
	wchar_t* buffer = new wchar_t(10);

	_itow_s(item->GetId(), buffer, 10, 10);

	wstring* idString = new wstring(buffer);

	map<wstring*, wstring*>* message = new map<wstring*, wstring*>();
	wstring* id = new wstring(ID);
	wstring* files = new wstring(FILES);

	message->insert(make_pair(id, idString));
	message->insert(make_pair(files, list));

	wstring* messageString = new wstring();

	if(!ParserUtil::SerializeMessage(message, messageString, true))
	{
		return false;
	}

	NativityMessage* nativityMessage = new NativityMessage();
	
	wstring* title = new wstring(PERFORM_ACTION);
	nativityMessage->SetCommand(title);
	nativityMessage->SetValue(messageString);

	wstring* nativityMessageString = new wstring();

	if(!ParserUtil::SerializeMessage(nativityMessage, nativityMessageString))
	{
		return false;
	}

	wstring* response = new wstring();

	if(!_communicationSocket->SendMessageReceiveResponse(nativityMessageString->c_str(), response))
	{
		return false;
	}

	return true;
}
Exemplo n.º 2
0
bool ContextMenuUtil::GetContextMenuAction(int action, ContextMenuAction** item)
{
	ContextMenuItem* contextMenuItem;

	if(GetContextMenuItem(action, &contextMenuItem))
	{
			ContextMenuAction* action = new ContextMenuAction();
			action->SetId(contextMenuItem->GetId());
			action->SetFiles(_selectedFiles);

			item = &action;
			
			return true;
	}

	return false;
}
Exemplo n.º 3
0
bool ContextMenuUtil::GetContextMenuAction(std::wstring* title, ContextMenuAction** item)
{
	for(vector<ContextMenuItem*>::iterator it = _menuList->begin(); it != _menuList->end(); it++)
	{
		ContextMenuItem* temp = *it;
		wstring* currentTitle = temp->GetTitle();

		if(currentTitle->compare(*title) == 0)
		{
			ContextMenuAction* action = new ContextMenuAction();
			action->SetId(temp->GetId());
			action->SetFiles(_selectedFiles);

			item = &action;
			return true;
		}
	}

	return false;
}
IFACEMETHODIMP LiferayNativityContextMenus::GetCommandString(UINT_PTR idCommand, UINT uFlags, UINT* pwReserved, LPSTR pszName, UINT cchMax)
{
	HRESULT hResult = S_OK;
	ContextMenuItem* item;

	switch (uFlags)
	{
		case GCS_HELPTEXTW:
			if (!_contextMenuUtil->GetContextMenuItem((int)idCommand, &item))
			{
				return E_FAIL;
			}

			if (item->GetHelpText() == 0)
			{
				return E_FAIL;
			}

			wcscpy_s((wchar_t*)pszName, cchMax, item->GetHelpText()->c_str());

			break;

		case GCS_VERBW:
			if (!_contextMenuUtil->GetContextMenuItem((int)idCommand, &item))
			{
				return E_FAIL;
			}

			_itow_s(item->GetId(), (wchar_t*)pszName, cchMax, 10);

			break;

		default:
			hResult = S_OK;
	}

	return hResult;
}