From: Katy Feng Date: Tue, 22 Aug 2023 18:11:41 +0000 (-0700) Subject: Removing appUtil library from open-vm-tools. X-Git-Tag: stable-12.3.0~54 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=016fa52e6bcbf868a08b5dbac0fdb8f19ab14c9a;p=thirdparty%2Fopen-vm-tools.git Removing appUtil library from open-vm-tools. Several Linux distributions have deprecated the use of gdk-pixbuf-xlib library and many may follow suit in future. Remove the appUtil library, which was required by Unity but is no longer supported on Linux guests. Github Issue: https://github.com/vmware/open-vm-tools/issues/658 --- diff --git a/open-vm-tools/configure.ac b/open-vm-tools/configure.ac index e4cea962a..cd8526d7c 100644 --- a/open-vm-tools/configure.ac +++ b/open-vm-tools/configure.ac @@ -1065,16 +1065,6 @@ else have_xcomposite="yes" fi - AC_VMW_CHECK_LIB([gdk_pixbuf_xlib-2.0], - [GDK_PIXBUF_XLIB2], - [gdk-pixbuf-xlib-2.0], - [], - [2.21.0], - [gdk-pixbuf-xlib/gdk-pixbuf-xlib.h], - [gdk_pixbuf_xlib_init], - [], - [AC_MSG_ERROR([gdk-pixbuf-xlib-2.0 not found. Please configure without X11 (using --without-x) or install the gdk-pixbuf-xlib-2.0 devel package.])]) - # Check whether we have gtk+ 3.0. if test "$with_gtk3" != "no"; then # gdk_display_get_default_group (added in gtk+ 2.4.0) is function currently @@ -1839,7 +1829,6 @@ AC_SUBST([UDEVRULESDIR]) AC_CONFIG_FILES([ \ Makefile \ lib/Makefile \ - lib/appUtil/Makefile \ lib/auth/Makefile \ lib/backdoor/Makefile \ lib/asyncsocket/Makefile \ diff --git a/open-vm-tools/lib/Makefile.am b/open-vm-tools/lib/Makefile.am index ecbab81a7..e37422cc1 100644 --- a/open-vm-tools/lib/Makefile.am +++ b/open-vm-tools/lib/Makefile.am @@ -1,5 +1,5 @@ ################################################################################ -### Copyright (c) 2007-2016,2020-2022 VMware, Inc. All rights reserved. +### Copyright (c) 2007-2016,2020-2023 VMware, Inc. All rights reserved. ### ### This program is free software; you can redistribute it and/or modify ### it under the terms of version 2 of the GNU General Public License as @@ -17,9 +17,6 @@ SUBDIRS = SUBDIRS += guestRpc -if HAVE_X11 - SUBDIRS += appUtil -endif SUBDIRS += auth SUBDIRS += backdoor if HAVE_VSOCK diff --git a/open-vm-tools/lib/appUtil/Makefile.am b/open-vm-tools/lib/appUtil/Makefile.am deleted file mode 100644 index 69ae23561..000000000 --- a/open-vm-tools/lib/appUtil/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ -################################################################################ -### Copyright (C) 2008-2016,2020 VMware, Inc. All rights reserved. -### -### This program is free software; you can redistribute it and/or modify -### it under the terms of version 2 of the GNU General Public License as -### published by the Free Software Foundation. -### -### This program is distributed in the hope that it will be useful, -### but WITHOUT ANY WARRANTY; without even the implied warranty of -### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -### GNU General Public License for more details. -### -### You should have received a copy of the GNU General Public License -### along with this program; if not, write to the Free Software -### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -################################################################################ - -noinst_LTLIBRARIES = libAppUtil.la - -libAppUtil_la_SOURCES = -libAppUtil_la_SOURCES += appUtil.c -libAppUtil_la_SOURCES += appUtilX11.c - -AM_CFLAGS = -AM_CFLAGS += @GTK_CPPFLAGS@ -AM_CFLAGS += @GDK_PIXBUF_XLIB2_CPPFLAGS@ - diff --git a/open-vm-tools/lib/appUtil/appUtil.c b/open-vm-tools/lib/appUtil/appUtil.c deleted file mode 100644 index 36d309644..000000000 --- a/open-vm-tools/lib/appUtil/appUtil.c +++ /dev/null @@ -1,83 +0,0 @@ -/********************************************************* - * Copyright (c) 2008-2019 VMware, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation version 2.1 and no later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - *********************************************************/ - -/* - * appUtil.c -- - * - * Utility functions for guest applications. - */ - - -#include -#include - -#include "appUtil.h" -#include "debug.h" -#include "rpcout.h" -#include "str.h" - - -/* - *---------------------------------------------------------------------------- - * - * AppUtil_SendGuestCaps -- - * - * Send a list of guest capabilities to the host. - * - * Results: - * None. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------------- - */ - -void -AppUtil_SendGuestCaps(const GuestCapabilities *caps, // IN: array of capabilities - size_t numCaps, // IN: number of capabilities - Bool enabled) // IN: capabilities status -{ - char *capsStr; - size_t capIdx; - - ASSERT(caps); - ASSERT(numCaps > 0); - - capsStr = strdup(GUEST_CAP_FEATURES); - for (capIdx = 0; capIdx < numCaps; capIdx++) { - char *capsTemp; - if (!capsStr) { - Debug("%s: Not enough memory to create capabilities string\n", __FUNCTION__); - return; - } - capsTemp = Str_Asprintf(NULL, - "%s %d=%d", - capsStr, - caps[capIdx], - (int)enabled); - free(capsStr); - capsStr = capsTemp; - } - - if (!RpcOut_sendOne(NULL, NULL, capsStr)) { - Debug("%s: could not set capabilities: older vmx?\n", __FUNCTION__); - } - - free(capsStr); -} diff --git a/open-vm-tools/lib/appUtil/appUtilX11.c b/open-vm-tools/lib/appUtil/appUtilX11.c deleted file mode 100644 index 871d10c8c..000000000 --- a/open-vm-tools/lib/appUtil/appUtilX11.c +++ /dev/null @@ -1,838 +0,0 @@ -/********************************************************* - * Copyright (c) 2008-2019,2022 VMware, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation version 2.1 and no later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - *********************************************************/ - -/* - * appUtilX11.c -- - * - * Utility functions to retrieve application icons. - */ - -#define _GNU_SOURCE 1 -#include -#include -#include - -#include "vmware.h" -#include "str.h" -#include "posix.h" -#include "debug.h" - -#include -#include -#include -#include -#include -#include -#include - -#if GTK_MAJOR_VERSION < 2 -#error "Gtk 2.0 or 3.0 is required" -#endif - - -/* - *----------------------------------------------------------------------------- - * - * AppUtilIconThemeReallyHasIcon -- - * - * Utility function to detect whether an icon is really available. This is necessary - * because sometimes gtk_icon_theme_has_icon() lies to us... - * - * Results: - * TRUE if the icon theme really has a usable icon, FALSE otherwise. - * - * Side effects: - * None. - * - *----------------------------------------------------------------------------- - */ - -static Bool -AppUtilIconThemeReallyHasIcon(GtkIconTheme *iconTheme, // IN - const char *iconName) // IN -{ - gint *iconSizes; - Bool retval; - - if (!gtk_icon_theme_has_icon(iconTheme, iconName)) { - return FALSE; - } - - iconSizes = gtk_icon_theme_get_icon_sizes(iconTheme, iconName); - retval = iconSizes && iconSizes[0]; - g_free(iconSizes); - - return retval; -} - - -/* - *----------------------------------------------------------------------------- - * - * AppUtilCollectNamedIcons -- - * - * Tries to find icons with a particular name (which may be a full filesystem path, - * a filename with extension, or just an abstract app name). - * - * Results: - * None. - * - * Side effects: - * May add icons into 'pixbufs' - * - *----------------------------------------------------------------------------- - */ - -static void -AppUtilCollectNamedIcons(GPtrArray *pixbufs, // IN/OUT - const char *iconName) // IN -{ - char *myIconName = NULL; - char *baseIconName; - /* - * Use the GtkIconTheme to track down any available icons for this app. - */ - GtkIconTheme *iconTheme = NULL; - char *ctmp2; - Bool foundItInTheme = FALSE; // Did we find this icon in the GtkIconTheme? - Bool foundItInFile = FALSE; // Did we find this icon directly in a file? - static const char *extraIconPaths[] = { - "/usr/share/icons", - "/usr/share/pixmaps", - "/usr/local/share/pixmaps", - "/usr/local/share/icons", - "/opt/kde3/share/icons", - "/opt/kde3/share/pixmaps", - "/opt/kde4/share/icons", - "/opt/kde4/share/pixmaps", - "/opt/gnome/share/icons", - "/opt/gnome/share/pixmaps" - }; - int iconNameLen; - - ASSERT(iconName); - - Debug("Collecting icons named %s\n", iconName); - - iconNameLen = strlen(iconName) + 1; - baseIconName = g_alloca(iconNameLen); // We need to modify the name sometimes - Str_Strcpy(baseIconName, iconName, iconNameLen); - - ctmp2 = strrchr(baseIconName, '.'); - if (*baseIconName != '/' && ctmp2 && strlen(ctmp2) <= 5) { - /* - * If it's a plain filename that we could possibly feed into GtkIconTheme as an - * icon ID, trim the file extension to turn it into an icon ID string and make - * GtkIconTheme happy. - */ - *ctmp2 = '\0'; - } - - iconTheme = gtk_icon_theme_get_default(); - g_object_ref(G_OBJECT(iconTheme)); - foundItInTheme = AppUtilIconThemeReallyHasIcon(iconTheme, baseIconName); - - if (!foundItInTheme) { - /* - * Try looking for it as a non-GtkIconTheme managed file, to deal with older - * systems. - */ - if (iconName[0] != '/') { - gchar *iconSearchName; - gsize iconSearchNameSize; - gboolean triedOtherExts = FALSE; - - char *ctmp2; - int i; - - static const char *iconExtensions[] = { - "", // MUST be first entry. - ".png", - ".xpm", - ".gif", - ".svg", - }; - - /* - * Make a local copy of iconName in case we need to search for icons with - * alternate extensions. - */ - iconSearchNameSize = strlen(iconName) + 1; - iconSearchName = g_alloca(iconSearchNameSize); - - /* Ignore return, returns length of the source string */ - /* coverity[check_return] */ - g_strlcpy(iconSearchName, iconName, iconSearchNameSize); - - myIconName = NULL; - - ctmp2 = g_alloca(PATH_MAX); -tryingOtherExts: - for (i = 0; !myIconName && i < ARRAYSIZE(extraIconPaths); i++) { - int j; - - if (!extraIconPaths[i]) { - continue; - } - - /* - * Per Desktop Entry Specification and Icon Theme Specification, I don't - * believe that the iconName, unless it's an absolute path, should include - * the file extension. - * - * However, empirical evidence shows that -many- applications ignore that - * and may specify an icon of, for example, "foo.png". We'll also handle - * those special cases here. - */ - for (j = 0; !myIconName && j < ARRAYSIZE(iconExtensions); j++) { - g_snprintf(ctmp2, PATH_MAX, "%s/%s%s", extraIconPaths[i], iconSearchName, - iconExtensions[j]); - if (!g_file_test(ctmp2, G_FILE_TEST_EXISTS)) { - continue; - } - - if (j != 0) { - /* - * Case 1: We located an icon by appending an image extension to - * IconName. Success! - */ - myIconName = ctmp2; // Will break "i" loop. - foundItInFile = TRUE; - break; - } else { - /* - * Case 2: We found an icon without appending an extension. Verify - * that the filename contains a valid image extension. - */ - int k; - char *ctmpext = strrchr(ctmp2, '.'); - for (k = 1; ctmpext && k < ARRAYSIZE(iconExtensions); k++) { - if (strcmp(ctmpext, iconExtensions[k]) == 0) { - myIconName = ctmp2; // Will break "i" loop. - foundItInFile = TRUE; - break; - } - } - } - } - } - - /* - * No dice. But we won't give up hope just yet! In some cases, icon-foo.png - * may not exist while icon-foo.xpm does. (Ex: Ubuntu 8.04's hwtest.) We'll - * try once more by searching for an icon with an alternate extension. - */ - if (!foundItInFile && !triedOtherExts) { - int extIndex; - - triedOtherExts = TRUE; - - /* - * Look to see if iconSearchName contains any of the known extensions - * listed above. If so, chop it off, then reattempt the search. - */ - for (extIndex = 1; extIndex < ARRAYSIZE(iconExtensions); extIndex++) { - if (g_str_has_suffix(iconSearchName, iconExtensions[extIndex])) { - gchar *extension; - extension = g_strrstr(iconSearchName, iconExtensions[extIndex]); - *extension = '\0'; - goto tryingOtherExts; - } - } - } - } else { - myIconName = g_alloca(iconNameLen + 1); - Str_Strcpy(myIconName, iconName, iconNameLen); - foundItInFile = TRUE; - } - } - - if (!foundItInTheme && !foundItInFile) { - /* - * Try looking through some auxiliary icon themes. - */ - int i; - static const char *extraThemes[] = { - /* - * Some other icon themes to try. - */ - "hicolor", - "Bluecurve", - "HighContrast-SVG", - "HighContrastLargePrint", - "crystalsvg", - "slick", - NULL - }; - g_object_unref(G_OBJECT(iconTheme)); - iconTheme = gtk_icon_theme_new(); - for (i = 0; i < ARRAYSIZE(extraIconPaths); i++) { - if (extraIconPaths[i]) { - if (g_file_test(extraIconPaths[i], G_FILE_TEST_EXISTS)) { - gtk_icon_theme_append_search_path(iconTheme, extraIconPaths[i]); - } else { - extraIconPaths[i] = NULL; - } - } - } - - for (i = 0; extraThemes[i]; i++) { - gtk_icon_theme_set_custom_theme(iconTheme, extraThemes[i]); - foundItInTheme = AppUtilIconThemeReallyHasIcon(iconTheme, baseIconName); - if (foundItInTheme) { - break; - } - } - } - - if (foundItInTheme) { - /* - * If we know this icon can be loaded via GtkIconTheme, do so. - */ - gint *iconSizes; - int i; - Bool needToUseScalable; - - iconSizes = gtk_icon_theme_get_icon_sizes(iconTheme, baseIconName); - Debug("Loading icon %s from iconTheme\n", baseIconName); - - ASSERT(iconSizes); - needToUseScalable = (iconSizes[0] == -1 && iconSizes[1] == 0); - - /* - * Before we try to actually dump the icons out to the host, count how many we - * actually can load. - */ - for (i = 0; iconSizes[i]; i++) { - GdkPixbuf *pixbuf; - GtkIconInfo *iconInfo; - gint thisSize; - - thisSize = iconSizes[i]; - if (thisSize == -1 && !needToUseScalable) { - continue; // Skip scalable icons if we have prerendered versions - } - - if (thisSize == -1) { - thisSize = 64; // Render SVG icons to 64x64 - } - - iconInfo = gtk_icon_theme_lookup_icon(iconTheme, baseIconName, thisSize, 0); - - if (!iconInfo) { - Debug("Couldn't find %s icon for size %d\n", baseIconName, thisSize); - continue; - } - - pixbuf = gtk_icon_info_load_icon(iconInfo, NULL); - - if (!pixbuf) { -#if GTK_MAJOR_VERSION == 3 -G_GNUC_BEGIN_IGNORE_DEPRECATIONS -#endif - pixbuf = gtk_icon_info_get_builtin_pixbuf(iconInfo); -#if GTK_MAJOR_VERSION == 3 -G_GNUC_END_IGNORE_DEPRECATIONS -#endif - } - - if (pixbuf) { - g_ptr_array_add(pixbufs, pixbuf); - } else { - Debug("WARNING: Not even a built-in pixbuf for icon %s\n", baseIconName); - } -#if GTK_MAJOR_VERSION == 3 - if (iconInfo) { - g_object_unref(iconInfo); - } -#else - gtk_icon_info_free(iconInfo); -#endif - } - - g_free(iconSizes); - - } else if (foundItInFile && myIconName && myIconName[0] == '/') { - GdkPixbuf *pixbuf; - Debug("Loading icon %s from file\n", myIconName); - pixbuf = gdk_pixbuf_new_from_file(myIconName, NULL); - if (pixbuf) { - g_ptr_array_add(pixbufs, pixbuf); - } - } - - if (iconTheme) { - g_object_unref(G_OBJECT(iconTheme)); - } -} - - -/* - *----------------------------------------------------------------------------- - * - * AppUtilComparePixbufSizes -- - * - * Compares two GdkPixbufs to sort them by image dimensions - * - * Results: - * -1 if A is larger than B, 0 if equal, 1 if A is smaller than B - * - * Side effects: - * None. - * - *----------------------------------------------------------------------------- - */ - -static gint -AppUtilComparePixbufSizes(gconstpointer a, // IN - gconstpointer b) // IN -{ - GdkPixbuf *pba; - GdkPixbuf *pbb; - int asize; - int bsize; - - if (a && !b) { - return -1; - } else if (!a && b) { - return 1; - } else if (!a && !b) { - return 0; - } - - pba = GDK_PIXBUF(*(gconstpointer *)a); - asize = gdk_pixbuf_get_width(pba) * gdk_pixbuf_get_height(pba); - - pbb = GDK_PIXBUF(*(gconstpointer *)b); - bsize = gdk_pixbuf_get_width(pbb) * gdk_pixbuf_get_height(pbb); - - if (asize > bsize) { - return -1; - } else if (asize < bsize) { - return 1; - } - - return 0; -} - - -/* - *----------------------------------------------------------------------------- - * - * AppUtil_CollectIconArray -- - * - * Given a variety of information about an application (its icon name, X window ID, - * etc.), return an array of GdkPixbufs that represent the icons for that - * application. - * - * Results: - * GPtrArray of GdkPixbufs, or NULL on failure. The returned array may have zero - * elements. The array will be sorted by icon size, largest to smallest. - * - * Side effects: - * Caller becomes owner of the array and pixbufs that are allocated during this - * function. - * - *----------------------------------------------------------------------------- - */ - -GPtrArray * -AppUtil_CollectIconArray(const char *iconName, // IN - unsigned long windowID) // IN -{ - GPtrArray *pixbufs; - - pixbufs = g_ptr_array_new(); - - if (iconName) { - AppUtilCollectNamedIcons(pixbufs, iconName); - } - - if (!pixbufs->len && windowID != None) { - /* - * Try loading the icon from the X Window's _NET_WM_ICON/WM_HINTS property. - */ - Display *dpy; - XWMHints *wmh; - Atom actualType = None; - int actualFormat; - unsigned long nitems = 0; - unsigned long bytesLeft; - XID *value; - XTextProperty wmIconName; - - dpy = gdk_x11_get_default_xdisplay(); - XGetWindowProperty(dpy, windowID, XInternAtom(dpy, "_NET_WM_ICON", FALSE), - 0, LONG_MAX, False, XA_CARDINAL, - &actualType, &actualFormat, &nitems, - &bytesLeft, (unsigned char **)&value); - - if (nitems) { - /* - * _NET_WM_ICON: Transform ARGB data into pixbufs... - */ - int i; - - for (i = 0; i < nitems; ) { - GdkPixbuf *pixbuf; - int width; - int height; - - ASSERT((nitems - i) >= 2); - width = value[i]; - height = value[i + 1]; - i += 2; - pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height); - if (pixbuf) { - int x; - int y; - int rowstride = gdk_pixbuf_get_rowstride(pixbuf); - guchar *pixels = gdk_pixbuf_get_pixels(pixbuf); - - for (y = 0; y < height; y++) { - for (x = 0; x < width && i < nitems; x++, i++) { - guchar *pixel = &pixels[y * rowstride + x * 4]; - XID currentValue = value[i]; - - /* - * Input data: BGRA data (high byte is A, low byte is B - - * freedesktop calls this ARGB, but that's not correct). - * - * Output data: RGBA data. - */ - *pixel = (currentValue >> 16) & 0xFF; - *(pixel + 1) = (currentValue >> 8) & 0xFF; - *(pixel + 2) = currentValue & 0xFF; - *(pixel + 3) = (currentValue >> 24) & 0xFF; - } - } - - g_ptr_array_add(pixbufs, pixbuf); - } else { - Debug("gdk_pixbuf_new failed when decoding _NET_WM_ICON\n"); - break; - } - } - XFree(value); - } - nitems = 0; - if (!pixbufs->len && - XGetWindowProperty(dpy, windowID, XInternAtom(dpy, "_NET_WM_ICON_NAME", FALSE), - 0, LONG_MAX, False, XInternAtom(dpy, "UTF8_STRING", FALSE), - &actualType, &actualFormat, &nitems, - &bytesLeft, (unsigned char **)&value) == Success - && nitems) { - /* - * _NET_WM_ICON_NAME - */ - AppUtilCollectNamedIcons(pixbufs, (char *)value); - XFree(value); - } - - if (!pixbufs->len && XGetWMIconName(dpy, windowID, &wmIconName)) { - /* - * WM_ICON_NAME - */ - AppUtilCollectNamedIcons(pixbufs, wmIconName.value); - XFree(wmIconName.value); - } - - if (!pixbufs->len && (wmh = XGetWMHints(dpy, windowID))) { - /* - * WM_HINTS - */ - if (wmh->flags & IconPixmapHint) { - Window dummyWin; - int x; - int y; - unsigned int width; - unsigned int height; - unsigned int border; - unsigned int depth; - GdkPixbuf *pixbuf = NULL; - - if (XGetGeometry(dpy, wmh->icon_pixmap, &dummyWin, - &x, &y, &width, &height, &border, &depth)) { - - pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height); - - if (!gdk_pixbuf_xlib_get_from_drawable (pixbuf, wmh->icon_pixmap, - DefaultColormap(dpy, 0), - DefaultVisual(dpy, 0), - 0, 0, 0, 0, width, height)) { - g_object_unref(G_OBJECT(pixbuf)); - pixbuf = NULL; - } - - if (pixbuf && (wmh->flags & IconMaskHint)) { - /* - * Apply the X bitmap mask. - */ - GdkPixbuf *pixbuf_mask; - - pixbuf_mask = - gdk_pixbuf_xlib_get_from_drawable(pixbuf, - wmh->icon_mask, - DefaultColormap(dpy, 0), - DefaultVisual(dpy, 0), - 0, 0, 0, 0, - width, height); - if (pixbuf_mask) { - int x; - int y; - int rowstride; - int rowstride_mask; - guchar *pixels; - guchar *pixels_mask; - int depth_mask; - int n_channels_mask; - - pixels = gdk_pixbuf_get_pixels(pixbuf); - pixels_mask = gdk_pixbuf_get_pixels(pixbuf_mask); - rowstride = gdk_pixbuf_get_rowstride(pixbuf); - rowstride_mask = gdk_pixbuf_get_rowstride(pixbuf_mask); - depth_mask = gdk_pixbuf_get_bits_per_sample(pixbuf_mask); - ASSERT(gdk_pixbuf_get_bits_per_sample(pixbuf) == 8); - n_channels_mask = gdk_pixbuf_get_n_channels(pixbuf_mask); - - for (y = 0; y < height; y++) { - guchar *thisrow_mask = pixels_mask + y * rowstride_mask; - guchar *thisrow = pixels + y * rowstride; - for (x = 0; x < width; x++) { - guchar newAlpha = 0xFF; - switch(depth_mask) { - case 1: - newAlpha = thisrow_mask[x * n_channels_mask / 8]; - newAlpha >>= (x % 8); - newAlpha = newAlpha ? 0xFF : 0; - break; - case 8: - /* - * For some reason, gdk-pixbuf-xlib turns a monochrome - * bitmap into 0/1 values in the blue channel of an RGBA - * pixmap. - */ - newAlpha = (thisrow_mask[x * n_channels_mask + 2]) - ? 0xFF : 0; - break; - default: - NOT_REACHED(); - break; - } - - thisrow[x * 4 + 3] = newAlpha; - } - } - } - } - - if (pixbuf) { - g_ptr_array_add(pixbufs, pixbuf); - } - } - } - - XFree(wmh); - } - - if (!pixbufs->len) { - /* - * Last resort - try using the WM_CLASS as an icon name - */ - - XClassHint hints; - - if (XGetClassHint(dpy, windowID, &hints)) { - if (hints.res_name) { - AppUtilCollectNamedIcons(pixbufs, hints.res_name); - } - - XFree(hints.res_name); - XFree(hints.res_class); - } - } - } - - /* - * In order to make it easy for AppUtil users to pick the icon they want, we sort them - * largest-to-smallest. - */ - g_ptr_array_sort(pixbufs, AppUtilComparePixbufSizes); - - if (!pixbufs->len) { - Debug("WARNING: No icons found for %s / %#lx\n", iconName, windowID); - } - - return pixbufs; -} - - -/* - *----------------------------------------------------------------------------- - * - * AppUtil_FreeIconArray -- - * - * Frees the result of AppUtil_CollectIconArray - * - * Results: - * None. - * - * Side effects: - * Array and its contents are destroyed - * - *----------------------------------------------------------------------------- - */ - -void -AppUtil_FreeIconArray(GPtrArray *pixbufs) // IN -{ - int i; - - if (!pixbufs) { - return; - } - - for (i = 0; i < pixbufs->len; i++) { - g_object_unref(G_OBJECT(g_ptr_array_index(pixbufs, i))); - } - - g_ptr_array_free(pixbufs, TRUE); -} -/* - *----------------------------------------------------------------------------- - * - * AppUtil_AppIsSkippable -- - * - * Can an executable be ignored for the purposes of determining the path to run an - * app with? Usually true for interpreters and the like, for which the script path - * should be used instead. - * - * Results: - * TRUE if the app should be ignored, FALSE otherwise. - * - * Side effects: - * None. - * - *----------------------------------------------------------------------------- - */ - -Bool -AppUtil_AppIsSkippable(const char *appName) -{ - static const char *skipAppsList[] = { - "python", - "python2.5", - "python2.4", - "python2.3", - "python2.2", - "perl", - "sh", - "bash", - }; - char cbuf[PATH_MAX]; - int i; - char *ctmp; - - Str_Strcpy(cbuf, appName, sizeof cbuf); - ctmp = basename(cbuf); - - for (i = 0; i < ARRAYSIZE(skipAppsList); i++) { - if (!strcmp(ctmp, skipAppsList[i])) { - return TRUE; - } - } - - return FALSE; -} - - -/* - *----------------------------------------------------------------------------- - * - * AppUtil_CanonicalizeAppName -- - * - * Turns the app name (or path) into a full path for the executable. - * - * Results: - * Path, or NULL if not available - * - * Side effects: - * Allocated memory is returned - * - *----------------------------------------------------------------------------- - */ - -char * -AppUtil_CanonicalizeAppName(const char *appName, // IN - const char *cwd) // IN -{ - char *ctmp; - ASSERT(appName); - - if (appName[0] == '/') { - ctmp = g_strdup(appName); - goto exit; - } - - ctmp = g_find_program_in_path(appName); - if (ctmp) { - goto exit; - } - - /* - * It's probably safe to assume that cwd is an absolute path (at the time of - * writing, it is derived from /proc), but let's check to be sure. - */ - if (cwd && cwd[0] == '/') { - - /* Don't add any unnecessary path separators. */ - char *cbuf = Str_Asprintf(NULL, "%s%s%s", cwd, - cwd[strlen(cwd) - 1] == '/' ? "" : "/", - appName); - if (cbuf) { - ctmp = Posix_RealPath(cbuf); - free(cbuf); - } - } - - exit: - return ctmp; -} - - -/* - *----------------------------------------------------------------------------- - * - * AppUtil_Init -- - * - * Initializes the AppUtil library for subsequent use. - * - * Results: - * None. - * - * Side effects: - * Internal state is initialized. Currently this is just gdk-pixbuf-xlib. - * - *----------------------------------------------------------------------------- - */ - -void -AppUtil_Init(void) -{ - gdk_pixbuf_xlib_init(gdk_x11_get_default_xdisplay(), 0); -} diff --git a/open-vm-tools/lib/include/appUtil.h b/open-vm-tools/lib/include/appUtil.h deleted file mode 100644 index 138c4139b..000000000 --- a/open-vm-tools/lib/include/appUtil.h +++ /dev/null @@ -1,183 +0,0 @@ -/********************************************************* - * Copyright (C) 2008-2019 VMware, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation version 2.1 and no later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - *********************************************************/ - -/* - * appUtil.h -- - * - * Utility functions for guest applications. - */ - -#ifndef _APP_UTIL_H_ -#define _APP_UTIL_H_ - -#ifdef _WIN32 -#include -#endif - -#include "vmware.h" - -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus -#include "vmware/guestrpc/capabilities.h" - -#ifdef __cplusplus -}; -#endif // __cplusplus - -/* - * Platform-agnostic bitmask of types of handlers to include. - * Used by the AppUtil file type functions. - */ -typedef enum { - FILE_TYPE_INCLUDE_NONE = 0, - FILE_TYPE_INCLUDE_URI = 1, // Include URI handlers - FILE_TYPE_INCLUDE_PERCEIVED_HANDLERS = 1 << 1, // Include perceived type handlers - // (see bug 1440812). - FILE_TYPE_INCLUDE_ALL = FILE_TYPE_INCLUDE_URI | - FILE_TYPE_INCLUDE_PERCEIVED_HANDLERS -} FileTypeInclusions; - -#ifdef _WIN32 - -/* The maximum number of icons that can be retrieved in a single query. */ -#define APPUTIL_MAX_NUM_ICONS 16 - -/* Predefined (N x N pixels) icon sizes */ -#define APPUTIL_ICON_SMALL 16 -#define APPUTIL_ICON_BIG 32 - -typedef struct AppUtilIconEntry { - uint32 width; // width of icon in pixels - uint32 height; // height of icon in pixels - uint32 widthBytes; // width of one row in bytes, including padding - uint32 dataLength; // length of bgra data, in bytes - unsigned char *dataBGRA; // pointer to bgra data -} AppUtilIconEntry; - -typedef struct AppUtilIconInfo { - uint32 numEntries; - AppUtilIconEntry *iconList; -} AppUtilIconInfo; - -typedef enum { - APPUTIL_UPPER_LEFT_DIB = -1, // the origin is the upper-left corner of the bitmap - APPUTIL_LOWER_LEFT_DIB = 1, // the origin is the lower-left corner of the bitmap -} AppUtilBitmapOrigin; - -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus - -Bool AppUtil_GetIconDataByHandle(HICON hIcon, - AppUtilBitmapOrigin origin, - AppUtilIconEntry *icon); - -Bool AppUtil_GetDIBitsAlloc(HDC hdc, - HBITMAP hbmp, - UINT uStartScan, - UINT cScanLines, - LPBITMAPINFO lpbi, - UINT uUsage, - char **bits); - -HICON AppUtil_GetWindowIcon(HWND hwnd, - uint32 iconSize); - -void AppUtil_BuildGlobalApplicationList(FileTypeInclusions inclusions); - -wchar_t* AppUtil_SanitizeCommandLine(const wchar_t *commandLineUtf16); -char *AppUtil_ActionURIForCommandLine(const WCHAR *commandLineUtf16); -Bool AppUtil_CommandLineForShellCommandURI(const char *shellCommandURI, - char **executablePath, - char **commandLine); - -Bool AppUtil_GetLinkIconData(const TCHAR *path, - AppUtilIconInfo *iconInfo, - AppUtilBitmapOrigin dibOrientation); - -Bool AppUtil_GetAppIconData(const TCHAR *path, - AppUtilIconInfo *iconInfo, - AppUtilBitmapOrigin dibOrientation); - -Bool AppUtil_LoadIcon(HMODULE module, - LPCWSTR resID, - AppUtilBitmapOrigin origin, - AppUtilIconInfo *icon); - -Bool AppUtil_CopyIcon(const AppUtilIconInfo *srcIcon, AppUtilIconInfo *dstIcon); - -void AppUtil_DestroyIcon(AppUtilIconInfo *icon); - -Bool AppUtil_GetIconIndexAndLocationForShortcut(const TCHAR *shortcut, - int maxLen, - TCHAR *iconFile, - int *iconIndex); - -PISECURITY_DESCRIPTOR AppUtil_AllocateLowIntegritySD(void); - -LPSTR AppUtil_ToLowerUtf8(LPCSTR s); -LPWSTR AppUtil_ToLowerUtf16(LPCWSTR s); - -Bool AppUtil_IsHorizonVDIAppRemotingMode(); -Bool AppUtil_IsHorizonUWPEnabled(); - -#ifdef __cplusplus -}; -#endif // __cplusplus - -#else // not _WIN32 - -#include - -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus - -void AppUtil_Init(void); -GPtrArray *AppUtil_CollectIconArray(const char *iconName, - unsigned long windowID); -void AppUtil_FreeIconArray(GPtrArray *pixbufs); - -Bool AppUtil_AppIsSkippable(const char *appName); -char *AppUtil_CanonicalizeAppName(const char *appName, - const char *cwd); - -#ifdef __cplusplus -}; -#endif // __cplusplus - -#endif - -/* - * Platform-independent functions. - */ - -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus - -void AppUtil_SendGuestCaps(const GuestCapabilities *caps, - size_t numCaps, - Bool enabled); - -#ifdef __cplusplus -}; -#endif // __cplusplus - -#endif // _APP_UTIL_H_