Rather than having the library do all the serialization to a DynBuf (containing an ASCII
representation sent over the backdoor) return the individual items in their original form
and defer the serialization to the plugin which is more acquainted with the transport
requirements.
Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
{
return GHIPlatformGetBinaryHandlers(ghiPlatformData, pathUtf8);
}
-#endif // !OPEN_VM_TOOLS && !__FreeBSD__ && !sun && !__APPLE__
/*
*----------------------------------------------------------------------------
*/
-Bool
-GHI_OpenStartMenuTree(const char *rootUtf8, // IN: root of the tree
- uint32 flags, // IN: flags from VMX
- DynBuf *buf) // OUT: number of items
+Bool GHI_OpenStartMenuTree(const char *rootUtf8, // IN:
+ uint32 flags, // IN:
+ uint32 &handle, // OUT: handle for menu
+ uint32 &numItems) // OUT: number of items in menu
{
- return GHIPlatformOpenStartMenuTree(ghiPlatformData, rootUtf8, flags, buf);
+ return GHIPlatformOpenStartMenuTree(ghiPlatformData, rootUtf8, flags, handle, numItems);
}
*/
Bool
-GHI_GetStartMenuItem(uint32 handle, // IN: tree handle
- uint32 itemIndex, // IN: the index of the item in the tree
- DynBuf *buf) // OUT: item
+GHI_GetStartMenuItem(uint32 handle, // IN: tree handle
+ uint32 itemIndex, // IN: the index of the item in the tree
+ Bool &isSubmenu, // OUT: True if this item is a submenu
+ utf::string &menuPath, // OUT: Path to the submenu (if this item is a submenu)
+ utf::string &itemPathURI, // OUT: URI for the item (empty if this is a submenu)
+ utf::string &itemName) // OUT: The name/label for the item
{
- return GHIPlatformGetStartMenuItem(ghiPlatformData, handle, itemIndex, buf);
+ return GHIPlatformGetStartMenuItem(ghiPlatformData, handle, itemIndex,
+ isSubmenu, menuPath, itemPathURI, itemName);
}
{
return GHIPlatformCloseStartMenuTree(ghiPlatformData, handle);
}
+#endif // !OPEN_VM_TOOLS && !__FreeBSD__ && !sun && !__APPLE__
/*
#if defined(__cplusplus)
#if !defined(OPEN_VM_TOOLS) && !defined(__FreeBSD__) && !defined(sun) && !defined(__APPLE__)
#include "appUtilFileTypes.h"
+#include "stringxx/string.hh"
#endif // !OPEN_VM_TOOLS && !__FREEBSD__ && !sun && !__APPLE__
+
#include <vector>
#include <string>
#include <list>
void GHI_Init(GMainLoop *mainLoop, const char **envp, GHIHostCallbacks hostCallbacks);
void GHI_Cleanup(void);
-Bool GHI_OpenStartMenuTree(const char *rootUtf8, uint32 flags, DynBuf *buf);
-Bool GHI_GetStartMenuItem(uint32 handle, uint32 itemIndex, DynBuf *buf);
-Bool GHI_CloseStartMenuTree(uint32 handle);
-
Bool GHI_ShellOpen(const char *fileURIUtf8);
Bool GHI_ShellAction(const char *actionURI,
const char *targetURI,
} GHIBinaryIconInfo;
Bool GHI_GetBinaryInfo(const char *pathUriUtf8, std::string &friendlyName, std::list<GHIBinaryIconInfo> &iconList);
+
+#if !defined(OPEN_VM_TOOLS) && !defined(__FreeBSD__) && !defined(sun) && !defined(__APPLE__)
+Bool GHI_OpenStartMenuTree(const char *rootUtf8, uint32 flags, uint32 &handle, uint32 &numItems);
+Bool GHI_GetStartMenuItem(uint32 handle,
+ uint32 itemIndex,
+ Bool &isSubmenu,
+ utf::string &menuPath,
+ utf::string &itemPathURI,
+ utf::string &itemName);
+Bool GHI_CloseStartMenuTree(uint32 handle);
+#endif // !OPEN_VM_TOOLS && !__FreeBSD__ && !sun && !__APPLE__
#endif // __cplusplus
#endif // _GH_INTEGRATION_H_
Bool GHIPlatformIsSupported(void);
GHIPlatform *GHIPlatformInit(GMainLoop *mainLoop, const char **envp, GHIHostCallbacks hostcallbacks);
void GHIPlatformCleanup(GHIPlatform *ghip);
-Bool GHIPlatformOpenStartMenuTree(GHIPlatform *ghip,
- const char *rootUtf8,
- uint32 flags,
- DynBuf *buf);
-Bool GHIPlatformGetStartMenuItem(GHIPlatform *ghip,
- uint32 handle,
- uint32 itemIndex,
- DynBuf *buf);
-Bool GHIPlatformCloseStartMenuTree(GHIPlatform *ghip,
- uint32 handle);
Bool GHIPlatformShellOpen(GHIPlatform *ghip,
const char *fileUtf8);
Bool GHIPlatformShellAction(GHIPlatform *ghip,
#if !defined(OPEN_VM_TOOLS) && !defined(__FreeBSD__) && !defined(sun) && !defined(__APPLE__)
const FileTypeList& GHIPlatformGetBinaryHandlers(GHIPlatform *ghip, const char *pathUtf8);
+
+Bool GHIPlatformOpenStartMenuTree(GHIPlatform *ghip,
+ const char *rootUtf8,
+ uint32 flags,
+ uint32 &handle,
+ uint32 &numItems);
+Bool GHIPlatformGetStartMenuItem(GHIPlatform *ghip,
+ uint32 handle,
+ uint32 itemIndex,
+ Bool &isSubmenu,
+ utf::string &menuPath,
+ utf::string &itemPathURI,
+ utf::string &itemName);
+Bool GHIPlatformCloseStartMenuTree(GHIPlatform *ghip,
+ uint32 handle);
#endif // !OPEN_VM_TOOLS && !__FreeBSD__ && !sun && !__APPLE__
Bool GHIPlatformGetBinaryInfo(GHIPlatform *ghip, const char *pathUriUtf8, std::string &friendlyName, std::list<GHIBinaryIconInfo> &iconList);
{
return sEmptyFileTypeList;
}
-#endif // OPEN_VM_TOOLS
/*
GHIPlatformOpenStartMenuTree(GHIPlatform *ghip, // IN: platform-specific state
const char *rootUtf8, // IN: root of the tree
uint32 flags, // IN: flags
- DynBuf *buf) // OUT: number of items
+ uint32 &handle, // OUT: menu handle
+ uint32 &numItems) // OUT: number of items
{
Bool success = FALSE;
#ifdef REDIST_GMENU
std::pair<uint32,uint32> descriptor;
if (ghip->menuItemManager->OpenMenuTree(rootUtf8, &descriptor)) {
- char tmp[2 * sizeof MAKESTR(UINT_MAX)];
- Str_Sprintf(tmp, sizeof tmp, "%u %u", descriptor.first, descriptor.second);
- DynBuf_AppendString(buf, tmp);
+ handle = descriptor.first;
+ numItems = descriptor.second;
success = TRUE;
}
#endif
}
+/*
+ *----------------------------------------------------------------------------
+ *
+ * GHIPlatformGetStartMenuItem --
+ *
+ * Get start menu item at a given index. This function should be called
+ * in the loop to get all items for a menu sub-tree.
+ * If there are no more items, the function will return FALSE.
+ *
+ * Results:
+ * TRUE if there's an item at a given index, FALSE otherwise.
+ *
+ * Side effects:
+ * None
+ *
+ *----------------------------------------------------------------------------
+ */
+
+Bool
+GHIPlatformGetStartMenuItem(GHIPlatform *ghip, // IN: platform-specific state
+ uint32 handle, // IN: tree handle
+ uint32 itemIndex, // IN: the index of the item in the tree
+ Bool &isSubmenu, // OUT: True if this item is a submenu
+ utf::string &menuPath, // OUT: Path to the submenu (if this item is a submenu)
+ utf::string &itemPathURI, // OUT: URI for the item (empty if this is a submenu)
+ utf::string &itemName) // OUT: The name/label for the item
+{
+ Bool success = FALSE;
+
+#ifdef REDIST_GMENU
+ const MenuItem* menuItem;
+ const Glib::ustring* path;
+
+ if (ghip->menuItemManager->GetMenuItem(handle, itemIndex, &menuItem, &path)) {
+ Glib::ustring key = *path + "/" + menuItem->key;
+ menuPath = key;
+
+ isSubmenu = menuItem->isFolder;
+
+ itemPathURI = menuItem->execPath.c_str();
+ itemName = menuItem->displayName.c_str();
+ success = TRUE;
+ }
+#endif
+
+ return success;
+}
+
+
+/*
+ *----------------------------------------------------------------------------
+ *
+ * GHIPlatformCloseStartMenu --
+ *
+ * Free all memory associated with this start menu tree and cleanup.
+ *
+ * Results:
+ * TRUE if the handle is valid
+ * FALSE otherwise
+ *
+ * Side effects:
+ * None
+ *
+ *----------------------------------------------------------------------------
+ */
+
+Bool
+GHIPlatformCloseStartMenuTree(GHIPlatform *ghip, // IN: platform-specific state
+ uint32 handle) // IN: handle to the tree to be closed
+{
+#ifdef REDIST_GMENU
+ return ghip->menuItemManager->CloseMenuTree(handle);
+#else
+ return FALSE;
+#endif
+}
+#endif // OPEN_VM_TOOLS
+
+
/*
*-----------------------------------------------------------------------------
*
}
-/*
- *----------------------------------------------------------------------------
- *
- * GHIPlatformGetStartMenuItem --
- *
- * Get start menu item at a given index. This function should be called
- * in the loop to get all items for a menu sub-tree.
- * If there are no more items, the function will return FALSE.
- *
- * Upon returning, 'buf' will hold a nul-delimited array of strings:
- * 1. User-visible item name.
- * 2. UNITY_START_MENU_ITEM_* flag.
- * 3. Executable path.
- * 4. Localized user-visible item name.
- *
- * Results:
- * TRUE if there's an item at a given index, FALSE otherwise.
- *
- * Side effects:
- * None
- *
- *----------------------------------------------------------------------------
- */
-
-Bool
-GHIPlatformGetStartMenuItem(GHIPlatform *ghip, // IN: platform-specific state
- uint32 handle, // IN: tree handle
- uint32 itemIndex, // IN: the index of the item in the tree
- DynBuf *buf) // OUT: item
-{
- Bool success = FALSE;
-
-#ifdef REDIST_GMENU
- const MenuItem* menuItem;
- const Glib::ustring* path;
-
- if (ghip->menuItemManager->GetMenuItem(handle, itemIndex, &menuItem, &path)) {
- Glib::ustring key = *path + "/" + menuItem->key;
- DynBuf_AppendString(buf, key.c_str());
-
- char tmp[sizeof MAKESTR(UINT_MAX)];
- Str_Sprintf(tmp, sizeof tmp, "%u", menuItem->isFolder ? 1 : 0);
- DynBuf_AppendString(buf, tmp);
-
- DynBuf_AppendString(buf, menuItem->execPath.c_str());
- DynBuf_AppendString(buf, menuItem->displayName.c_str());
- success = TRUE;
- }
-#endif
-
- return success;
-}
-
-
-/*
- *----------------------------------------------------------------------------
- *
- * GHIPlatformCloseStartMenu --
- *
- * Free all memory associated with this start menu tree and cleanup.
- *
- * Results:
- * TRUE if the handle is valid
- * FALSE otherwise
- *
- * Side effects:
- * None
- *
- *----------------------------------------------------------------------------
- */
-
-Bool
-GHIPlatformCloseStartMenuTree(GHIPlatform *ghip, // IN: platform-specific state
- uint32 handle) // IN: handle to the tree to be closed
-{
-#ifdef REDIST_GMENU
- return ghip->menuItemManager->CloseMenuTree(handle);
-#else
- return FALSE;
-#endif
-}
-
-
#if 0 // REMOVE AFTER IMPLEMENTING GHIPlatformShellAction
/*
*-----------------------------------------------------------------------------
DynBuf *buf = &gTcloUpdate;
uint32 flags = 0;
uint32 index = 0;
+ uint32 menuHandle = 0;
+ uint32 numItems = 0;
+
Bool ret = TRUE;
/* Check our arguments. */
}
DynBuf_SetSize(buf, 0);
- if (!GHI_OpenStartMenuTree(rootUtf8, flags, buf)) {
+#if !defined(OPEN_VM_TOOLS)
+ if (!GHI_OpenStartMenuTree(rootUtf8, flags, menuHandle, numItems)) {
Debug("%s: Could not open start menu.\n", __FUNCTION__);
ret = RPCIN_SETRETVALS(data,
"Could not get start menu count",
FALSE);
goto exit;
+ } else {
+ char temp[256];
+ Str_Sprintf(temp, sizeof temp, "%d %d", menuHandle, numItems);
+ DynBuf_AppendString(buf, temp);
}
+#endif // OPEN_VM_TOOLS
/*
* Write the final result into the result out parameters and return!
Bool ret = TRUE;
uint32 itemIndex = 0;
uint32 handle = 0;
+#if !defined(OPEN_VM_TOOLS)
+ Bool isSubmenu;
+ utf::string menuPath;
+ utf::string itemPathURI;
+ utf::string itemName;
+#endif // OPEN_VM_TOOLS
/* Check our arguments. */
ASSERT(data);
}
DynBuf_SetSize(buf, 0);
- if (!GHI_GetStartMenuItem(handle, itemIndex, buf)) {
+#if !defined(OPEN_VM_TOOLS)
+ if (!GHI_GetStartMenuItem(handle, itemIndex,
+ isSubmenu, menuPath, itemPathURI, itemName)) {
Debug("%s: Could not get start menu item.\n", __FUNCTION__);
return RPCIN_SETRETVALS(data,
"Could not get start menu item",
FALSE);
}
+ DynBuf_AppendString(buf, menuPath.c_str());
+ DynBuf_AppendString(buf, isSubmenu ? "1" : "0");
+ DynBuf_AppendString(buf, itemPathURI.c_str());
+ DynBuf_AppendString(buf, itemName.c_str());
+#else
+ return RPCIN_SETRETVALS(data,
+ "Could not get start menu item",
+ FALSE);
+#endif // OPEN_VM_TOOLS
+
/*
* Write the final result into the result out parameters and return!
*/
FALSE);
}
+#if !defined(OPEN_VM_TOOLS)
GHI_CloseStartMenuTree(handle);
+#endif // OPEN_VM_TOOLS
return RPCIN_SETRETVALS(data, "", TRUE);
}