mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-13 07:56:17 +01:00
Merge branch 'g-win32-app-info-enhancements-2' into 'main'
GWin32AppInfo: Retrieve display name for UWP / Packaged apps See merge request GNOME/glib!3168
This commit is contained in:
commit
ddf85f9d9e
@ -4,15 +4,42 @@
|
||||
*
|
||||
* This file is part of the w64 mingw-runtime package.
|
||||
* No warranty is given; refer to https://github.com/kinke/mingw-w64-crt/blob/master/DISCLAIMER.PD.
|
||||
*
|
||||
* Additional code derived from the windows-rs repository on GitHub
|
||||
* (https://github.com/microsoft/windows-rs) with the MIT license:
|
||||
*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE
|
||||
*/
|
||||
|
||||
typedef interface IPackageManager IPackageManager;
|
||||
typedef interface IPackage IPackage;
|
||||
typedef interface IPackageId IPackageId;
|
||||
typedef interface IPackageVersion IPackageVersion;
|
||||
typedef interface IPackage2 IPackage2;
|
||||
|
||||
DEFINE_GUID(IID_IPackageManager, 0x9A7D4B65, 0x5E8F, 0x4FC7, 0xA2, 0xE5, 0x7F, 0x69, 0x25, 0xCB, 0x8B, 0x53);
|
||||
DEFINE_GUID(IID_IPackage, 0x163C792F, 0xBD75, 0x413C, 0xBF, 0x23, 0xB1, 0xFE, 0x7B, 0x95, 0xD8, 0x25);
|
||||
DEFINE_GUID(IID_IPackage2, 0xA6612fb6, 0x7688, 0x4ACE, 0x95, 0xFB, 0x35, 0x95, 0x38, 0xE7, 0xAA, 0x01);
|
||||
|
||||
/* IPackageManager */
|
||||
typedef struct IPackageManagerVtbl {
|
||||
@ -270,3 +297,86 @@ interface IPackage {
|
||||
#define IPackage_get_InstalledLocation(This,value) (This)->lpVtbl->get_InstalledLocation(This,value)
|
||||
#define IPackage_get_IsFramework(This,value) (This)->lpVtbl->get_IsFramework(This,value)
|
||||
#define IPackage_get_Dependencies(This,value) (This)->lpVtbl->get_Dependencies(This,value)
|
||||
|
||||
/* IPackage2 */
|
||||
typedef struct IPackage2Vtbl {
|
||||
BEGIN_INTERFACE
|
||||
|
||||
/*** IUnknown methods ***/
|
||||
HRESULT (STDMETHODCALLTYPE *QueryInterface)(
|
||||
IPackage2 *This,
|
||||
REFIID riid,
|
||||
void **ppvObject);
|
||||
|
||||
ULONG (STDMETHODCALLTYPE *AddRef)(
|
||||
IPackage2 *This);
|
||||
|
||||
ULONG (STDMETHODCALLTYPE *Release)(
|
||||
IPackage2 *This);
|
||||
|
||||
/*** IInspectable methods ***/
|
||||
HRESULT (STDMETHODCALLTYPE *GetIids)(
|
||||
IPackage2 *This,
|
||||
UINT32 *count,
|
||||
IID **ids);
|
||||
|
||||
HRESULT (STDMETHODCALLTYPE *GetRuntimeClassName)(
|
||||
IPackage2 *This,
|
||||
HSTRING *className);
|
||||
|
||||
HRESULT (STDMETHODCALLTYPE *GetTrustLevel)(
|
||||
IPackage2 *This,
|
||||
TrustLevel *trustLevel);
|
||||
|
||||
/*** IPackage2 methods ***/
|
||||
HRESULT (STDMETHODCALLTYPE *get_DisplayName)(
|
||||
IPackage2 *This,
|
||||
HSTRING *value);
|
||||
|
||||
HRESULT (STDMETHODCALLTYPE *get_PublisherDisplayName)(
|
||||
IPackage2 *This,
|
||||
HSTRING *value);
|
||||
|
||||
HRESULT (STDMETHODCALLTYPE *get_Description)(
|
||||
IPackage2 *This,
|
||||
HSTRING *value);
|
||||
|
||||
HRESULT (STDMETHODCALLTYPE *get_Logo)(
|
||||
IPackage2 *This,
|
||||
void **value);
|
||||
|
||||
HRESULT (STDMETHODCALLTYPE *get_IsResourcePackage)(
|
||||
IPackage2 *This,
|
||||
UCHAR *value);
|
||||
|
||||
HRESULT (STDMETHODCALLTYPE *get_IsBundle)(
|
||||
IPackage2 *This,
|
||||
UCHAR *value);
|
||||
|
||||
HRESULT (STDMETHODCALLTYPE *get_IsDevelopmentMode)(
|
||||
IPackage2 *This,
|
||||
UCHAR *value);
|
||||
|
||||
END_INTERFACE
|
||||
} IPackage2Vtbl;
|
||||
|
||||
interface IPackage2 {
|
||||
CONST_VTBL IPackage2Vtbl* lpVtbl;
|
||||
};
|
||||
|
||||
/*** IUnknown methods ***/
|
||||
#define IPackage2_QueryInterface(This,riid,ppvObject) (This)->lpVtbl->QueryInterface(This,riid,ppvObject)
|
||||
#define IPackage2_AddRef(This) (This)->lpVtbl->AddRef(This)
|
||||
#define IPackage2_Release(This) (This)->lpVtbl->Release(This)
|
||||
/*** IInspectable methods ***/
|
||||
#define IPackage2_GetIids(This,count,ids) (This)->lpVtbl->GetIids(This,count,ids)
|
||||
#define IPackage2_GetRuntimeClassName(This,name) (This)->lpVtbl->GetRuntimeClassName(This,name)
|
||||
#define IPackage2_GetTrustLevel(This,level) (This)->lpVtbl->GetTrustLevel(This,level)
|
||||
/*** IPackage2 methods ***/
|
||||
#define IPackage2_get_DisplayName(This,value) (This)->lpVtbl->get_DisplayName(This,value)
|
||||
#define IPackage2_get_PublisherDisplayName(This,value) (This)->lpVtbl->get_PublisherDisplayName(This,value)
|
||||
#define IPackage2_get_Description(This,value) (This)->lpVtbl->get_Description(This,value)
|
||||
#define IPackage2_get_Logo(This,value) (This)->lpVtbl->get_Logo(This,value)
|
||||
#define IPackage2_get_IsResourcePackage(This,value) (This)->lpVtbl->get_IsResourcePackage(This,value)
|
||||
#define IPackage2_get_IsBundle(This,value) (This)->lpVtbl->get_IsBundle(This,value)
|
||||
#define IPackage2_get_IsDevelopmentMode(This,value) (This)->lpVtbl->get_IsDevelopmentMode(This,value)
|
||||
|
@ -3356,6 +3356,7 @@ static gboolean
|
||||
uwp_package_cb (gpointer user_data,
|
||||
const gunichar2 *full_package_name,
|
||||
const gunichar2 *package_name,
|
||||
const gunichar2 *display_name,
|
||||
const gunichar2 *app_user_model_id,
|
||||
gboolean show_in_applist,
|
||||
GPtrArray *supported_extgroups,
|
||||
@ -3384,6 +3385,13 @@ uwp_package_cb (gpointer user_data,
|
||||
FALSE,
|
||||
TRUE);
|
||||
|
||||
if (!app->pretty_name && !app->pretty_name_u8 && display_name)
|
||||
{
|
||||
char *display_name_u8 = g_utf16_to_utf8 (display_name, -1, NULL, NULL, NULL);
|
||||
app->pretty_name = g_wcsdup (display_name, -1);
|
||||
app->pretty_name_u8 = g_steal_pointer (&display_name_u8);
|
||||
}
|
||||
|
||||
extensions_considered = 0;
|
||||
|
||||
for (i = 0; i < supported_extgroups->len; i++)
|
||||
|
@ -141,6 +141,7 @@ struct _xml_sax_state
|
||||
gsize package_index;
|
||||
const wchar_t *wcs_full_name;
|
||||
const wchar_t *wcs_name;
|
||||
const wchar_t *wcs_display_name;
|
||||
HSTRING package_family;
|
||||
|
||||
gboolean applist;
|
||||
@ -322,17 +323,20 @@ g_win32_package_parser_enum_packages (GWin32PackageParserCallback callback,
|
||||
{
|
||||
IUnknown *item = NULL;
|
||||
IPackage *ipackage = NULL;
|
||||
IPackage2 *ipackage2 = NULL;
|
||||
IPackageId *ipackageid = NULL;
|
||||
IUnknown *package_install_location = NULL;
|
||||
IStorageItem *storage_item = NULL;
|
||||
HSTRING path = NULL;
|
||||
HSTRING name = NULL;
|
||||
HSTRING full_name = NULL;
|
||||
HSTRING display_name = NULL;
|
||||
HSTRING package_family = NULL;
|
||||
size_t manifest_filename_size;
|
||||
const wchar_t *wcs_path;
|
||||
const wchar_t *wcs_full_name;
|
||||
const wchar_t *wcs_name;
|
||||
const wchar_t *wcs_display_name;
|
||||
wchar_t *manifest_filename = NULL;
|
||||
|
||||
#define canned_com_error_handler_pkg(function_name_literal, where_to_go) \
|
||||
@ -353,6 +357,9 @@ g_win32_package_parser_enum_packages (GWin32PackageParserCallback callback,
|
||||
hr = IUnknown_QueryInterface (item, &IID_IPackage, (void **) &ipackage);
|
||||
canned_com_error_handler_pkg ("IUnknown_QueryInterface(IID_IPackage)", package_cleanup);
|
||||
|
||||
hr = IUnknown_QueryInterface (item, &IID_IPackage2, (void **) &ipackage2);
|
||||
canned_com_error_handler_pkg ("IUnknown_QueryInterface(IID_IPackage2)", package_cleanup);
|
||||
|
||||
hr = IPackage_get_Id (ipackage, &ipackageid);
|
||||
canned_com_error_handler_pkg ("IPackage_get_Id()", package_cleanup);
|
||||
|
||||
@ -362,8 +369,12 @@ g_win32_package_parser_enum_packages (GWin32PackageParserCallback callback,
|
||||
hr = IPackageId_get_Name (ipackageid, &name);
|
||||
canned_com_error_handler_pkg ("IPackageId_get_Name()", package_cleanup);
|
||||
|
||||
hr = IPackage2_get_DisplayName (ipackage2, &display_name);
|
||||
canned_com_error_handler_pkg ("IPackage2_get_DisplayName()", package_cleanup);
|
||||
|
||||
wcs_full_name = LoadedWindowsGetStringRawBuffer (full_name, NULL);
|
||||
wcs_name = LoadedWindowsGetStringRawBuffer (name, NULL);
|
||||
wcs_display_name = LoadedWindowsGetStringRawBuffer (display_name, NULL);
|
||||
|
||||
#define canned_com_error_handler_pkg_named(function_name_literal, where_to_go) \
|
||||
do \
|
||||
@ -402,6 +413,7 @@ g_win32_package_parser_enum_packages (GWin32PackageParserCallback callback,
|
||||
sax->package_index = package_index;
|
||||
sax->wcs_full_name = wcs_full_name;
|
||||
sax->wcs_name = wcs_name;
|
||||
sax->wcs_display_name = wcs_display_name;
|
||||
sax->package_family = package_family;
|
||||
sax->applist = TRUE;
|
||||
sax->exit_early = FALSE;
|
||||
@ -426,22 +438,26 @@ g_win32_package_parser_enum_packages (GWin32PackageParserCallback callback,
|
||||
|
||||
if (path)
|
||||
LoadedWindowsDeleteString (path);
|
||||
if (storage_item)
|
||||
(void) IStorageItem_Release (storage_item);
|
||||
if (package_install_location)
|
||||
(void) IUnknown_Release (package_install_location);
|
||||
if (ipackage)
|
||||
(void) IPackage_Release (ipackage);
|
||||
if (item)
|
||||
(void) IUnknown_Release (item);
|
||||
|
||||
if (package_family)
|
||||
LoadedWindowsDeleteString (package_family);
|
||||
if (display_name)
|
||||
LoadedWindowsDeleteString (display_name);
|
||||
if (name)
|
||||
LoadedWindowsDeleteString (name);
|
||||
if (full_name)
|
||||
LoadedWindowsDeleteString (full_name);
|
||||
|
||||
if (storage_item)
|
||||
(void) IStorageItem_Release (storage_item);
|
||||
if (package_install_location)
|
||||
(void) IUnknown_Release (package_install_location);
|
||||
if (ipackage2)
|
||||
(void) IPackage2_Release (ipackage2);
|
||||
if (ipackage)
|
||||
(void) IPackage_Release (ipackage);
|
||||
if (item)
|
||||
(void) IUnknown_Release (item);
|
||||
|
||||
if (ipackageid)
|
||||
(void) IPackageId_Release (ipackageid);
|
||||
if (sax->exit_early)
|
||||
@ -791,8 +807,8 @@ xml_parser_iteration (struct _xml_sax_state *sax,
|
||||
{
|
||||
if (sax->application_usermodelid != NULL)
|
||||
sax->exit_early = !sax->callback (sax->user_data, sax->wcs_full_name, sax->wcs_name,
|
||||
sax->application_usermodelid, sax->applist,
|
||||
sax->supported_extgroups, sax->supported_protocols);
|
||||
sax->wcs_display_name, sax->application_usermodelid,
|
||||
sax->applist, sax->supported_extgroups, sax->supported_protocols);
|
||||
g_clear_pointer (&sax->supported_extgroups, g_ptr_array_unref);
|
||||
g_clear_pointer (&sax->supported_protocols, g_ptr_array_unref);
|
||||
sax->supported_protocols = g_ptr_array_new_full (0, (GDestroyNotify) g_free);
|
||||
|
@ -36,6 +36,7 @@ struct _GWin32PackageExtGroup
|
||||
typedef gboolean (*GWin32PackageParserCallback)(gpointer user_data,
|
||||
const gunichar2 *full_package_name,
|
||||
const gunichar2 *package_name,
|
||||
const gunichar2 *display_name,
|
||||
const gunichar2 *app_user_model_id,
|
||||
gboolean show_in_applist,
|
||||
GPtrArray *supported_extgroups,
|
||||
|
Loading…
Reference in New Issue
Block a user