From 018299d70b9168386b3173d32e5336e2a9cdb045 Mon Sep 17 00:00:00 2001 From: Halil Durmus Date: Thu, 1 Jun 2023 14:49:31 +0300 Subject: [PATCH] feat(windows_system): add `Launcher` APIs (#228) --- .../windows_applicationmodel/pubspec.yaml | 7 +- .../windows_system/lib/src/exports.g.dart | 13 + .../lib/src/folderlauncheroptions.dart | 50 +++ .../lib/src/ifolderlauncheroptions.dart | 55 +++ .../lib/src/ilauncheroptions.dart | 322 ++++++++++++++ .../lib/src/ilauncheroptions2.dart | 120 ++++++ .../lib/src/ilauncheroptions3.dart | 66 +++ .../lib/src/ilauncheroptions4.dart | 66 +++ .../lib/src/ilauncherstatics.dart | 153 +++++++ .../lib/src/ilauncherstatics2.dart | 408 ++++++++++++++++++ .../lib/src/ilauncherstatics3.dart | 91 ++++ .../lib/src/ilauncherstatics4.dart | 350 +++++++++++++++ .../lib/src/ilauncherstatics5.dart | 160 +++++++ .../lib/src/ilauncheruioptions.dart | 159 +++++++ .../lib/src/ilauncherviewoptions.dart | 68 +++ .../lib/src/ilaunchuriresult.dart | 77 ++++ packages/windows_system/lib/src/launcher.dart | 207 +++++++++ .../lib/src/launcheroptions.dart | 136 ++++++ .../lib/src/launcheruioptions.dart | 49 +++ .../lib/src/launchuriresult.dart | 34 ++ packages/windows_system/pubspec.yaml | 6 +- packages/winrtgen/data/objects.json | 5 + 22 files changed, 2597 insertions(+), 5 deletions(-) create mode 100644 packages/windows_system/lib/src/folderlauncheroptions.dart create mode 100644 packages/windows_system/lib/src/ifolderlauncheroptions.dart create mode 100644 packages/windows_system/lib/src/ilauncheroptions.dart create mode 100644 packages/windows_system/lib/src/ilauncheroptions2.dart create mode 100644 packages/windows_system/lib/src/ilauncheroptions3.dart create mode 100644 packages/windows_system/lib/src/ilauncheroptions4.dart create mode 100644 packages/windows_system/lib/src/ilauncherstatics.dart create mode 100644 packages/windows_system/lib/src/ilauncherstatics2.dart create mode 100644 packages/windows_system/lib/src/ilauncherstatics3.dart create mode 100644 packages/windows_system/lib/src/ilauncherstatics4.dart create mode 100644 packages/windows_system/lib/src/ilauncherstatics5.dart create mode 100644 packages/windows_system/lib/src/ilauncheruioptions.dart create mode 100644 packages/windows_system/lib/src/ilauncherviewoptions.dart create mode 100644 packages/windows_system/lib/src/ilaunchuriresult.dart create mode 100644 packages/windows_system/lib/src/launcher.dart create mode 100644 packages/windows_system/lib/src/launcheroptions.dart create mode 100644 packages/windows_system/lib/src/launcheruioptions.dart create mode 100644 packages/windows_system/lib/src/launchuriresult.dart diff --git a/packages/windows_applicationmodel/pubspec.yaml b/packages/windows_applicationmodel/pubspec.yaml index 79ad4a7b..70858769 100644 --- a/packages/windows_applicationmodel/pubspec.yaml +++ b/packages/windows_applicationmodel/pubspec.yaml @@ -21,9 +21,10 @@ platforms: dependencies: ffi: ^2.0.1 - win32: ^5.0.0 - windows_foundation: ^0.0.2 - windows_system: ^0.0.3 + win32: ^5.0.3 + windows_foundation: ^0.0.6 + windows_storage: ^0.0.2 + windows_system: ^0.0.2 dev_dependencies: test: ^1.24.1 diff --git a/packages/windows_system/lib/src/exports.g.dart b/packages/windows_system/lib/src/exports.g.dart index 7955360a..33a9b6c5 100644 --- a/packages/windows_system/lib/src/exports.g.dart +++ b/packages/windows_system/lib/src/exports.g.dart @@ -4,12 +4,25 @@ // THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. +export 'folderlauncheroptions.dart'; +export 'ifolderlauncheroptions.dart'; +export 'ilauncheroptions.dart'; +export 'ilauncheroptions2.dart'; +export 'ilauncheroptions3.dart'; +export 'ilauncheroptions4.dart'; +export 'ilauncheruioptions.dart'; +export 'ilauncherviewoptions.dart'; +export 'ilaunchuriresult.dart'; export 'iuser.dart'; export 'iuser2.dart'; export 'iuserwatcher.dart'; export 'knownuserproperties.dart'; +export 'launcher.dart'; +export 'launcheroptions.dart'; +export 'launcheruioptions.dart'; export 'launchquerysupportstatus.dart'; export 'launchquerysupporttype.dart'; +export 'launchuriresult.dart'; export 'launchuristatus.dart'; export 'power/batterystatus.dart'; export 'power/energysaverstatus.dart'; diff --git a/packages/windows_system/lib/src/folderlauncheroptions.dart b/packages/windows_system/lib/src/folderlauncheroptions.dart new file mode 100644 index 00000000..5f113e6b --- /dev/null +++ b/packages/windows_system/lib/src/folderlauncheroptions.dart @@ -0,0 +1,50 @@ +// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. +// All rights reserved. Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. + +// ignore_for_file: constant_identifier_names, non_constant_identifier_names +// ignore_for_file: unnecessary_import, unused_import + +import 'dart:async'; +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; +import 'package:win32/win32.dart' hide DocumentProperties; +import 'package:windows_foundation/internal.dart'; +import 'package:windows_foundation/windows_foundation.dart'; +import 'package:windows_storage/windows_storage.dart'; +import 'package:windows_ui/windows_ui.dart'; + +import 'ifolderlauncheroptions.dart'; +import 'ilauncherviewoptions.dart'; + +/// Specifies the options to use when launching File Explorer to display the +/// contents of a specific folder by calling the +/// LaunchFolderAsync(IStorageFolder, FolderLauncherOptions) method. +/// +/// {@category class} +class FolderLauncherOptions extends IInspectable + implements IFolderLauncherOptions, ILauncherViewOptions { + FolderLauncherOptions() : super(activateClass(_className)); + FolderLauncherOptions.fromPtr(super.ptr); + + static const _className = 'Windows.System.FolderLauncherOptions'; + + late final _iFolderLauncherOptions = IFolderLauncherOptions.from(this); + + @override + IVector get itemsToSelect => + _iFolderLauncherOptions.itemsToSelect; + + late final _iLauncherViewOptions = ILauncherViewOptions.from(this); + + @override + ViewSizePreference get desiredRemainingView => + _iLauncherViewOptions.desiredRemainingView; + + @override + set desiredRemainingView(ViewSizePreference value) => + _iLauncherViewOptions.desiredRemainingView = value; +} diff --git a/packages/windows_system/lib/src/ifolderlauncheroptions.dart b/packages/windows_system/lib/src/ifolderlauncheroptions.dart new file mode 100644 index 00000000..8aa0793e --- /dev/null +++ b/packages/windows_system/lib/src/ifolderlauncheroptions.dart @@ -0,0 +1,55 @@ +// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. +// All rights reserved. Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. + +// ignore_for_file: constant_identifier_names, non_constant_identifier_names +// ignore_for_file: unnecessary_import, unused_import + +import 'dart:async'; +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; +import 'package:win32/win32.dart' hide DocumentProperties; +import 'package:windows_foundation/internal.dart'; +import 'package:windows_foundation/windows_foundation.dart'; +import 'package:windows_storage/windows_storage.dart'; + +/// @nodoc +const IID_IFolderLauncherOptions = '{bb91c27d-6b87-432a-bd04-776c6f5fb2ab}'; + +/// {@category interface} +class IFolderLauncherOptions extends IInspectable { + // vtable begins at 6, is 1 entries long. + IFolderLauncherOptions.fromPtr(super.ptr); + + factory IFolderLauncherOptions.from(IInspectable interface) => + IFolderLauncherOptions.fromPtr( + interface.toInterface(IID_IFolderLauncherOptions)); + + IVector get itemsToSelect { + final retValuePtr = calloc(); + + final hr = ptr.ref.vtable + .elementAt(6) + .cast< + Pointer< + NativeFunction< + HRESULT Function(VTablePointer lpVtbl, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, + Pointer retValuePtr)>()(ptr.ref.lpVtbl, retValuePtr); + + if (FAILED(hr)) { + free(retValuePtr); + throw WindowsException(hr); + } + + return IVector.fromPtr(retValuePtr, + iterableIid: '{bb8b8418-65d1-544b-b083-6d172f568c73}', + creator: IStorageItem.fromPtr); + } +} diff --git a/packages/windows_system/lib/src/ilauncheroptions.dart b/packages/windows_system/lib/src/ilauncheroptions.dart new file mode 100644 index 00000000..9439d8df --- /dev/null +++ b/packages/windows_system/lib/src/ilauncheroptions.dart @@ -0,0 +1,322 @@ +// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. +// All rights reserved. Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. + +// ignore_for_file: constant_identifier_names, non_constant_identifier_names +// ignore_for_file: unnecessary_import, unused_import + +import 'dart:async'; +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; +import 'package:win32/win32.dart' hide DocumentProperties; +import 'package:windows_foundation/internal.dart'; +import 'package:windows_foundation/windows_foundation.dart'; + +import 'launcheruioptions.dart'; + +/// @nodoc +const IID_ILauncherOptions = '{bafa21d8-b071-4cd8-853e-341203e557d3}'; + +/// {@category interface} +class ILauncherOptions extends IInspectable { + // vtable begins at 6, is 13 entries long. + ILauncherOptions.fromPtr(super.ptr); + + factory ILauncherOptions.from(IInspectable interface) => + ILauncherOptions.fromPtr(interface.toInterface(IID_ILauncherOptions)); + + bool get treatAsUntrusted { + final retValuePtr = calloc(); + + try { + final hr = ptr.ref.vtable + .elementAt(6) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, + Pointer retValuePtr)>()(ptr.ref.lpVtbl, retValuePtr); + + if (FAILED(hr)) throw WindowsException(hr); + + return retValuePtr.value; + } finally { + free(retValuePtr); + } + } + + set treatAsUntrusted(bool value) { + final hr = ptr.ref.vtable + .elementAt(7) + .cast< + Pointer< + NativeFunction< + HRESULT Function(VTablePointer lpVtbl, Bool value)>>>() + .value + .asFunction()( + ptr.ref.lpVtbl, value); + + if (FAILED(hr)) throw WindowsException(hr); + } + + bool get displayApplicationPicker { + final retValuePtr = calloc(); + + try { + final hr = ptr.ref.vtable + .elementAt(8) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, + Pointer retValuePtr)>()(ptr.ref.lpVtbl, retValuePtr); + + if (FAILED(hr)) throw WindowsException(hr); + + return retValuePtr.value; + } finally { + free(retValuePtr); + } + } + + set displayApplicationPicker(bool value) { + final hr = ptr.ref.vtable + .elementAt(9) + .cast< + Pointer< + NativeFunction< + HRESULT Function(VTablePointer lpVtbl, Bool value)>>>() + .value + .asFunction()( + ptr.ref.lpVtbl, value); + + if (FAILED(hr)) throw WindowsException(hr); + } + + LauncherUIOptions? get ui { + final retValuePtr = calloc(); + + final hr = ptr.ref.vtable + .elementAt(10) + .cast< + Pointer< + NativeFunction< + HRESULT Function(VTablePointer lpVtbl, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, + Pointer retValuePtr)>()(ptr.ref.lpVtbl, retValuePtr); + + if (FAILED(hr)) { + free(retValuePtr); + throw WindowsException(hr); + } + + if (retValuePtr.ref.isNull) { + free(retValuePtr); + return null; + } + + return LauncherUIOptions.fromPtr(retValuePtr); + } + + String get preferredApplicationPackageFamilyName { + final retValuePtr = calloc(); + + try { + final hr = ptr.ref.vtable + .elementAt(11) + .cast< + Pointer< + NativeFunction< + HRESULT Function(VTablePointer lpVtbl, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, + Pointer retValuePtr)>()(ptr.ref.lpVtbl, retValuePtr); + + if (FAILED(hr)) throw WindowsException(hr); + + return retValuePtr.toDartString(); + } finally { + WindowsDeleteString(retValuePtr.value); + free(retValuePtr); + } + } + + set preferredApplicationPackageFamilyName(String value) { + final hString = value.toHString(); + + try { + final hr = + ptr.ref.vtable + .elementAt(12) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, IntPtr value)>>>() + .value + .asFunction()( + ptr.ref.lpVtbl, hString); + + if (FAILED(hr)) throw WindowsException(hr); + } finally { + WindowsDeleteString(hString); + } + } + + String get preferredApplicationDisplayName { + final retValuePtr = calloc(); + + try { + final hr = ptr.ref.vtable + .elementAt(13) + .cast< + Pointer< + NativeFunction< + HRESULT Function(VTablePointer lpVtbl, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, + Pointer retValuePtr)>()(ptr.ref.lpVtbl, retValuePtr); + + if (FAILED(hr)) throw WindowsException(hr); + + return retValuePtr.toDartString(); + } finally { + WindowsDeleteString(retValuePtr.value); + free(retValuePtr); + } + } + + set preferredApplicationDisplayName(String value) { + final hString = value.toHString(); + + try { + final hr = + ptr.ref.vtable + .elementAt(14) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, IntPtr value)>>>() + .value + .asFunction()( + ptr.ref.lpVtbl, hString); + + if (FAILED(hr)) throw WindowsException(hr); + } finally { + WindowsDeleteString(hString); + } + } + + Uri? get fallbackUri { + final retValuePtr = calloc(); + + final hr = ptr.ref.vtable + .elementAt(15) + .cast< + Pointer< + NativeFunction< + HRESULT Function(VTablePointer lpVtbl, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, + Pointer retValuePtr)>()(ptr.ref.lpVtbl, retValuePtr); + + if (FAILED(hr)) { + free(retValuePtr); + throw WindowsException(hr); + } + + if (retValuePtr.ref.isNull) { + free(retValuePtr); + return null; + } + + final winrtUri = retValuePtr.toWinRTUri(); + return winrtUri.toDartUri(); + } + + set fallbackUri(Uri? value) { + final winrtUri = value?.toWinRTUri(); + + final hr = ptr.ref.vtable + .elementAt(16) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, VTablePointer value)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, VTablePointer value)>()( + ptr.ref.lpVtbl, winrtUri == null ? nullptr : winrtUri.ptr.ref.lpVtbl); + + if (FAILED(hr)) throw WindowsException(hr); + } + + String get contentType { + final retValuePtr = calloc(); + + try { + final hr = ptr.ref.vtable + .elementAt(17) + .cast< + Pointer< + NativeFunction< + HRESULT Function(VTablePointer lpVtbl, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, + Pointer retValuePtr)>()(ptr.ref.lpVtbl, retValuePtr); + + if (FAILED(hr)) throw WindowsException(hr); + + return retValuePtr.toDartString(); + } finally { + WindowsDeleteString(retValuePtr.value); + free(retValuePtr); + } + } + + set contentType(String value) { + final hString = value.toHString(); + + try { + final hr = + ptr.ref.vtable + .elementAt(18) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, IntPtr value)>>>() + .value + .asFunction()( + ptr.ref.lpVtbl, hString); + + if (FAILED(hr)) throw WindowsException(hr); + } finally { + WindowsDeleteString(hString); + } + } +} diff --git a/packages/windows_system/lib/src/ilauncheroptions2.dart b/packages/windows_system/lib/src/ilauncheroptions2.dart new file mode 100644 index 00000000..063c4e68 --- /dev/null +++ b/packages/windows_system/lib/src/ilauncheroptions2.dart @@ -0,0 +1,120 @@ +// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. +// All rights reserved. Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. + +// ignore_for_file: constant_identifier_names, non_constant_identifier_names +// ignore_for_file: unnecessary_import, unused_import + +import 'dart:async'; +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; +import 'package:win32/win32.dart' hide DocumentProperties; +import 'package:windows_foundation/internal.dart'; +import 'package:windows_foundation/windows_foundation.dart'; +import 'package:windows_storage/windows_storage.dart'; + +/// @nodoc +const IID_ILauncherOptions2 = '{3ba08eb4-6e40-4dce-a1a3-2f53950afb49}'; + +/// {@category interface} +class ILauncherOptions2 extends IInspectable { + // vtable begins at 6, is 4 entries long. + ILauncherOptions2.fromPtr(super.ptr); + + factory ILauncherOptions2.from(IInspectable interface) => + ILauncherOptions2.fromPtr(interface.toInterface(IID_ILauncherOptions2)); + + String get targetApplicationPackageFamilyName { + final retValuePtr = calloc(); + + try { + final hr = ptr.ref.vtable + .elementAt(6) + .cast< + Pointer< + NativeFunction< + HRESULT Function(VTablePointer lpVtbl, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, + Pointer retValuePtr)>()(ptr.ref.lpVtbl, retValuePtr); + + if (FAILED(hr)) throw WindowsException(hr); + + return retValuePtr.toDartString(); + } finally { + WindowsDeleteString(retValuePtr.value); + free(retValuePtr); + } + } + + set targetApplicationPackageFamilyName(String value) { + final hString = value.toHString(); + + try { + final hr = + ptr.ref.vtable + .elementAt(7) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, IntPtr value)>>>() + .value + .asFunction()( + ptr.ref.lpVtbl, hString); + + if (FAILED(hr)) throw WindowsException(hr); + } finally { + WindowsDeleteString(hString); + } + } + + StorageFileQueryResult? get neighboringFilesQuery { + final retValuePtr = calloc(); + + final hr = ptr.ref.vtable + .elementAt(8) + .cast< + Pointer< + NativeFunction< + HRESULT Function(VTablePointer lpVtbl, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, + Pointer retValuePtr)>()(ptr.ref.lpVtbl, retValuePtr); + + if (FAILED(hr)) { + free(retValuePtr); + throw WindowsException(hr); + } + + if (retValuePtr.ref.isNull) { + free(retValuePtr); + return null; + } + + return StorageFileQueryResult.fromPtr(retValuePtr); + } + + set neighboringFilesQuery(StorageFileQueryResult? value) { + final hr = ptr.ref.vtable + .elementAt(9) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, VTablePointer value)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, VTablePointer value)>()( + ptr.ref.lpVtbl, value == null ? nullptr : value.ptr.ref.lpVtbl); + + if (FAILED(hr)) throw WindowsException(hr); + } +} diff --git a/packages/windows_system/lib/src/ilauncheroptions3.dart b/packages/windows_system/lib/src/ilauncheroptions3.dart new file mode 100644 index 00000000..1bbea7f8 --- /dev/null +++ b/packages/windows_system/lib/src/ilauncheroptions3.dart @@ -0,0 +1,66 @@ +// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. +// All rights reserved. Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. + +// ignore_for_file: constant_identifier_names, non_constant_identifier_names +// ignore_for_file: unnecessary_import, unused_import + +import 'dart:async'; +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; +import 'package:win32/win32.dart' hide DocumentProperties; +import 'package:windows_foundation/internal.dart'; +import 'package:windows_foundation/windows_foundation.dart'; + +/// @nodoc +const IID_ILauncherOptions3 = '{f0770655-4b63-4e3a-9107-4e687841923a}'; + +/// {@category interface} +class ILauncherOptions3 extends IInspectable { + // vtable begins at 6, is 2 entries long. + ILauncherOptions3.fromPtr(super.ptr); + + factory ILauncherOptions3.from(IInspectable interface) => + ILauncherOptions3.fromPtr(interface.toInterface(IID_ILauncherOptions3)); + + bool get ignoreAppUriHandlers { + final retValuePtr = calloc(); + + try { + final hr = ptr.ref.vtable + .elementAt(6) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, + Pointer retValuePtr)>()(ptr.ref.lpVtbl, retValuePtr); + + if (FAILED(hr)) throw WindowsException(hr); + + return retValuePtr.value; + } finally { + free(retValuePtr); + } + } + + set ignoreAppUriHandlers(bool value) { + final hr = ptr.ref.vtable + .elementAt(7) + .cast< + Pointer< + NativeFunction< + HRESULT Function(VTablePointer lpVtbl, Bool value)>>>() + .value + .asFunction()( + ptr.ref.lpVtbl, value); + + if (FAILED(hr)) throw WindowsException(hr); + } +} diff --git a/packages/windows_system/lib/src/ilauncheroptions4.dart b/packages/windows_system/lib/src/ilauncheroptions4.dart new file mode 100644 index 00000000..426d6386 --- /dev/null +++ b/packages/windows_system/lib/src/ilauncheroptions4.dart @@ -0,0 +1,66 @@ +// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. +// All rights reserved. Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. + +// ignore_for_file: constant_identifier_names, non_constant_identifier_names +// ignore_for_file: unnecessary_import, unused_import + +import 'dart:async'; +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; +import 'package:win32/win32.dart' hide DocumentProperties; +import 'package:windows_foundation/internal.dart'; +import 'package:windows_foundation/windows_foundation.dart'; + +/// @nodoc +const IID_ILauncherOptions4 = '{ef6fd10e-e6fb-4814-a44e-57e8b9d9a01b}'; + +/// {@category interface} +class ILauncherOptions4 extends IInspectable { + // vtable begins at 6, is 2 entries long. + ILauncherOptions4.fromPtr(super.ptr); + + factory ILauncherOptions4.from(IInspectable interface) => + ILauncherOptions4.fromPtr(interface.toInterface(IID_ILauncherOptions4)); + + bool get limitPickerToCurrentAppAndAppUriHandlers { + final retValuePtr = calloc(); + + try { + final hr = ptr.ref.vtable + .elementAt(6) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, + Pointer retValuePtr)>()(ptr.ref.lpVtbl, retValuePtr); + + if (FAILED(hr)) throw WindowsException(hr); + + return retValuePtr.value; + } finally { + free(retValuePtr); + } + } + + set limitPickerToCurrentAppAndAppUriHandlers(bool value) { + final hr = ptr.ref.vtable + .elementAt(7) + .cast< + Pointer< + NativeFunction< + HRESULT Function(VTablePointer lpVtbl, Bool value)>>>() + .value + .asFunction()( + ptr.ref.lpVtbl, value); + + if (FAILED(hr)) throw WindowsException(hr); + } +} diff --git a/packages/windows_system/lib/src/ilauncherstatics.dart b/packages/windows_system/lib/src/ilauncherstatics.dart new file mode 100644 index 00000000..f09ec79f --- /dev/null +++ b/packages/windows_system/lib/src/ilauncherstatics.dart @@ -0,0 +1,153 @@ +// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. +// All rights reserved. Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. + +// ignore_for_file: constant_identifier_names, non_constant_identifier_names +// ignore_for_file: unnecessary_import, unused_import + +import 'dart:async'; +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; +import 'package:win32/win32.dart' hide DocumentProperties; +import 'package:windows_foundation/internal.dart'; +import 'package:windows_foundation/windows_foundation.dart'; +import 'package:windows_storage/windows_storage.dart'; + +import 'launcheroptions.dart'; + +/// @nodoc +const IID_ILauncherStatics = '{277151c3-9e3e-42f6-91a4-5dfdeb232451}'; + +/// {@category interface} +class ILauncherStatics extends IInspectable { + // vtable begins at 6, is 4 entries long. + ILauncherStatics.fromPtr(super.ptr); + + factory ILauncherStatics.from(IInspectable interface) => + ILauncherStatics.fromPtr(interface.toInterface(IID_ILauncherStatics)); + + Future launchFileAsync(IStorageFile? file) { + final retValuePtr = calloc(); + final filePtr = file == null ? nullptr : file.ptr.ref.lpVtbl; + + final hr = + ptr.ref.vtable + .elementAt(6) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, + VTablePointer file, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, VTablePointer file, + Pointer retValuePtr)>()( + ptr.ref.lpVtbl, filePtr, retValuePtr); + + if (FAILED(hr)) { + free(retValuePtr); + throw WindowsException(hr); + } + + final asyncOperation = IAsyncOperation.fromPtr(retValuePtr); + return asyncOperation.toFuture(asyncOperation.getResults); + } + + Future launchFileWithOptionsAsync( + IStorageFile? file, LauncherOptions? options) { + final retValuePtr = calloc(); + final filePtr = file == null ? nullptr : file.ptr.ref.lpVtbl; + final optionsPtr = options == null ? nullptr : options.ptr.ref.lpVtbl; + + final hr = ptr.ref.vtable + .elementAt(7) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, + VTablePointer file, + VTablePointer options, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, VTablePointer file, + VTablePointer options, Pointer retValuePtr)>()( + ptr.ref.lpVtbl, filePtr, optionsPtr, retValuePtr); + + if (FAILED(hr)) { + free(retValuePtr); + throw WindowsException(hr); + } + + final asyncOperation = IAsyncOperation.fromPtr(retValuePtr); + return asyncOperation.toFuture(asyncOperation.getResults); + } + + Future launchUriAsync(Uri? uri) { + final retValuePtr = calloc(); + final uriUri = uri?.toWinRTUri(); + + final hr = + ptr.ref.vtable + .elementAt(8) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, + VTablePointer uri, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, VTablePointer uri, + Pointer retValuePtr)>()(ptr.ref.lpVtbl, + uriUri == null ? nullptr : uriUri.ptr.ref.lpVtbl, retValuePtr); + + if (FAILED(hr)) { + free(retValuePtr); + throw WindowsException(hr); + } + + final asyncOperation = IAsyncOperation.fromPtr(retValuePtr); + return asyncOperation.toFuture(asyncOperation.getResults); + } + + Future launchUriWithOptionsAsync(Uri? uri, LauncherOptions? options) { + final retValuePtr = calloc(); + final uriUri = uri?.toWinRTUri(); + final optionsPtr = options == null ? nullptr : options.ptr.ref.lpVtbl; + + final hr = ptr.ref.vtable + .elementAt(9) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, + VTablePointer uri, + VTablePointer options, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, VTablePointer uri, + VTablePointer options, Pointer retValuePtr)>()( + ptr.ref.lpVtbl, + uriUri == null ? nullptr : uriUri.ptr.ref.lpVtbl, + optionsPtr, + retValuePtr); + + if (FAILED(hr)) { + free(retValuePtr); + throw WindowsException(hr); + } + + final asyncOperation = IAsyncOperation.fromPtr(retValuePtr); + return asyncOperation.toFuture(asyncOperation.getResults); + } +} diff --git a/packages/windows_system/lib/src/ilauncherstatics2.dart b/packages/windows_system/lib/src/ilauncherstatics2.dart new file mode 100644 index 00000000..c905a5c2 --- /dev/null +++ b/packages/windows_system/lib/src/ilauncherstatics2.dart @@ -0,0 +1,408 @@ +// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. +// All rights reserved. Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. + +// ignore_for_file: constant_identifier_names, non_constant_identifier_names +// ignore_for_file: unnecessary_import, unused_import + +import 'dart:async'; +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; +import 'package:win32/win32.dart' hide DocumentProperties; +import 'package:windows_applicationmodel/windows_applicationmodel.dart'; +import 'package:windows_foundation/internal.dart'; +import 'package:windows_foundation/windows_foundation.dart'; +import 'package:windows_storage/windows_storage.dart'; + +import 'launcheroptions.dart'; +import 'launchquerysupportstatus.dart'; +import 'launchquerysupporttype.dart'; +import 'launchuriresult.dart'; + +/// @nodoc +const IID_ILauncherStatics2 = '{59ba2fbb-24cb-4c02-a4c4-8294569d54f1}'; + +/// {@category interface} +class ILauncherStatics2 extends IInspectable { + // vtable begins at 6, is 10 entries long. + ILauncherStatics2.fromPtr(super.ptr); + + factory ILauncherStatics2.from(IInspectable interface) => + ILauncherStatics2.fromPtr(interface.toInterface(IID_ILauncherStatics2)); + + Future launchUriForResultsAsync( + Uri? uri, LauncherOptions? options) { + final retValuePtr = calloc(); + final uriUri = uri?.toWinRTUri(); + final optionsPtr = options == null ? nullptr : options.ptr.ref.lpVtbl; + + final hr = ptr.ref.vtable + .elementAt(6) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, + VTablePointer uri, + VTablePointer options, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, VTablePointer uri, + VTablePointer options, Pointer retValuePtr)>()( + ptr.ref.lpVtbl, + uriUri == null ? nullptr : uriUri.ptr.ref.lpVtbl, + optionsPtr, + retValuePtr); + + if (FAILED(hr)) { + free(retValuePtr); + throw WindowsException(hr); + } + + final asyncOperation = IAsyncOperation.fromPtr( + retValuePtr, + creator: LaunchUriResult.fromPtr); + return asyncOperation.toFuture(asyncOperation.getResults); + } + + Future launchUriForResultsWithDataAsync( + Uri? uri, LauncherOptions? options, ValueSet inputData) { + final retValuePtr = calloc(); + final uriUri = uri?.toWinRTUri(); + final optionsPtr = options == null ? nullptr : options.ptr.ref.lpVtbl; + final inputDataPtr = inputData.ptr.ref.lpVtbl; + + final hr = ptr.ref.vtable + .elementAt(7) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, + VTablePointer uri, + VTablePointer options, + VTablePointer inputData, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function( + VTablePointer lpVtbl, + VTablePointer uri, + VTablePointer options, + VTablePointer inputData, + Pointer retValuePtr)>()( + ptr.ref.lpVtbl, + uriUri == null ? nullptr : uriUri.ptr.ref.lpVtbl, + optionsPtr, + inputDataPtr, + retValuePtr); + + if (FAILED(hr)) { + free(retValuePtr); + throw WindowsException(hr); + } + + final asyncOperation = IAsyncOperation.fromPtr( + retValuePtr, + creator: LaunchUriResult.fromPtr); + return asyncOperation.toFuture(asyncOperation.getResults); + } + + Future launchUriWithDataAsync( + Uri? uri, LauncherOptions? options, ValueSet inputData) { + final retValuePtr = calloc(); + final uriUri = uri?.toWinRTUri(); + final optionsPtr = options == null ? nullptr : options.ptr.ref.lpVtbl; + final inputDataPtr = inputData.ptr.ref.lpVtbl; + + final hr = ptr.ref.vtable + .elementAt(8) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, + VTablePointer uri, + VTablePointer options, + VTablePointer inputData, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function( + VTablePointer lpVtbl, + VTablePointer uri, + VTablePointer options, + VTablePointer inputData, + Pointer retValuePtr)>()( + ptr.ref.lpVtbl, + uriUri == null ? nullptr : uriUri.ptr.ref.lpVtbl, + optionsPtr, + inputDataPtr, + retValuePtr); + + if (FAILED(hr)) { + free(retValuePtr); + throw WindowsException(hr); + } + + final asyncOperation = IAsyncOperation.fromPtr(retValuePtr); + return asyncOperation.toFuture(asyncOperation.getResults); + } + + Future queryUriSupportAsync( + Uri? uri, LaunchQuerySupportType launchQuerySupportType) { + final retValuePtr = calloc(); + final uriUri = uri?.toWinRTUri(); + + final hr = ptr.ref.vtable + .elementAt(9) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, + VTablePointer uri, + Int32 launchQuerySupportType, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function( + VTablePointer lpVtbl, + VTablePointer uri, + int launchQuerySupportType, + Pointer retValuePtr)>()( + ptr.ref.lpVtbl, + uriUri == null ? nullptr : uriUri.ptr.ref.lpVtbl, + launchQuerySupportType.value, + retValuePtr); + + if (FAILED(hr)) { + free(retValuePtr); + throw WindowsException(hr); + } + + final asyncOperation = IAsyncOperation.fromPtr( + retValuePtr, + enumCreator: LaunchQuerySupportStatus.from); + return asyncOperation.toFuture(asyncOperation.getResults); + } + + Future queryUriSupportWithPackageFamilyNameAsync( + Uri? uri, + LaunchQuerySupportType launchQuerySupportType, + String packageFamilyName) { + final retValuePtr = calloc(); + final uriUri = uri?.toWinRTUri(); + final packageFamilyNameHString = packageFamilyName.toHString(); + + final hr = ptr.ref.vtable + .elementAt(10) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, + VTablePointer uri, + Int32 launchQuerySupportType, + IntPtr packageFamilyName, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function( + VTablePointer lpVtbl, + VTablePointer uri, + int launchQuerySupportType, + int packageFamilyName, + Pointer retValuePtr)>()( + ptr.ref.lpVtbl, + uriUri == null ? nullptr : uriUri.ptr.ref.lpVtbl, + launchQuerySupportType.value, + packageFamilyNameHString, + retValuePtr); + + WindowsDeleteString(packageFamilyNameHString); + + if (FAILED(hr)) { + free(retValuePtr); + throw WindowsException(hr); + } + + final asyncOperation = IAsyncOperation.fromPtr( + retValuePtr, + enumCreator: LaunchQuerySupportStatus.from); + return asyncOperation.toFuture(asyncOperation.getResults); + } + + Future queryFileSupportAsync(StorageFile? file) { + final retValuePtr = calloc(); + final filePtr = file == null ? nullptr : file.ptr.ref.lpVtbl; + + final hr = + ptr.ref.vtable + .elementAt(11) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, + VTablePointer file, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, VTablePointer file, + Pointer retValuePtr)>()( + ptr.ref.lpVtbl, filePtr, retValuePtr); + + if (FAILED(hr)) { + free(retValuePtr); + throw WindowsException(hr); + } + + final asyncOperation = IAsyncOperation.fromPtr( + retValuePtr, + enumCreator: LaunchQuerySupportStatus.from); + return asyncOperation.toFuture(asyncOperation.getResults); + } + + Future queryFileSupportWithPackageFamilyNameAsync( + StorageFile? file, String packageFamilyName) { + final retValuePtr = calloc(); + final filePtr = file == null ? nullptr : file.ptr.ref.lpVtbl; + final packageFamilyNameHString = packageFamilyName.toHString(); + + final hr = ptr.ref.vtable + .elementAt(12) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, + VTablePointer file, + IntPtr packageFamilyName, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, VTablePointer file, + int packageFamilyName, Pointer retValuePtr)>()( + ptr.ref.lpVtbl, filePtr, packageFamilyNameHString, retValuePtr); + + WindowsDeleteString(packageFamilyNameHString); + + if (FAILED(hr)) { + free(retValuePtr); + throw WindowsException(hr); + } + + final asyncOperation = IAsyncOperation.fromPtr( + retValuePtr, + enumCreator: LaunchQuerySupportStatus.from); + return asyncOperation.toFuture(asyncOperation.getResults); + } + + Future> findUriSchemeHandlersAsync(String scheme) { + final retValuePtr = calloc(); + final schemeHString = scheme.toHString(); + + final hr = ptr.ref.vtable + .elementAt(13) + .cast< + Pointer< + NativeFunction< + HRESULT Function(VTablePointer lpVtbl, IntPtr scheme, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, int scheme, + Pointer retValuePtr)>()( + ptr.ref.lpVtbl, schemeHString, retValuePtr); + + WindowsDeleteString(schemeHString); + + if (FAILED(hr)) { + free(retValuePtr); + throw WindowsException(hr); + } + + final asyncOperation = IAsyncOperation>.fromPtr( + retValuePtr, + creator: (ptr) => IVectorView.fromPtr(ptr, + creator: AppInfo.fromPtr, + iterableIid: '{63d0bffe-0e34-55b3-83d5-314caff2b137}')); + return asyncOperation.toFuture(() => asyncOperation.getResults().toList()); + } + + Future> findUriSchemeHandlersWithLaunchUriTypeAsync( + String scheme, LaunchQuerySupportType launchQuerySupportType) { + final retValuePtr = calloc(); + final schemeHString = scheme.toHString(); + + final hr = ptr.ref.vtable + .elementAt(14) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, + IntPtr scheme, + Int32 launchQuerySupportType, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function( + VTablePointer lpVtbl, + int scheme, + int launchQuerySupportType, + Pointer retValuePtr)>()(ptr.ref.lpVtbl, + schemeHString, launchQuerySupportType.value, retValuePtr); + + WindowsDeleteString(schemeHString); + + if (FAILED(hr)) { + free(retValuePtr); + throw WindowsException(hr); + } + + final asyncOperation = IAsyncOperation>.fromPtr( + retValuePtr, + creator: (ptr) => IVectorView.fromPtr(ptr, + creator: AppInfo.fromPtr, + iterableIid: '{63d0bffe-0e34-55b3-83d5-314caff2b137}')); + return asyncOperation.toFuture(() => asyncOperation.getResults().toList()); + } + + Future> findFileHandlersAsync(String extension) { + final retValuePtr = calloc(); + final extensionHString = extension.toHString(); + + final hr = ptr.ref.vtable + .elementAt(15) + .cast< + Pointer< + NativeFunction< + HRESULT Function(VTablePointer lpVtbl, IntPtr extension, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, int extension, + Pointer retValuePtr)>()( + ptr.ref.lpVtbl, extensionHString, retValuePtr); + + WindowsDeleteString(extensionHString); + + if (FAILED(hr)) { + free(retValuePtr); + throw WindowsException(hr); + } + + final asyncOperation = IAsyncOperation>.fromPtr( + retValuePtr, + creator: (ptr) => IVectorView.fromPtr(ptr, + creator: AppInfo.fromPtr, + iterableIid: '{63d0bffe-0e34-55b3-83d5-314caff2b137}')); + return asyncOperation.toFuture(() => asyncOperation.getResults().toList()); + } +} diff --git a/packages/windows_system/lib/src/ilauncherstatics3.dart b/packages/windows_system/lib/src/ilauncherstatics3.dart new file mode 100644 index 00000000..3d3eb07a --- /dev/null +++ b/packages/windows_system/lib/src/ilauncherstatics3.dart @@ -0,0 +1,91 @@ +// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. +// All rights reserved. Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. + +// ignore_for_file: constant_identifier_names, non_constant_identifier_names +// ignore_for_file: unnecessary_import, unused_import + +import 'dart:async'; +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; +import 'package:win32/win32.dart' hide DocumentProperties; +import 'package:windows_foundation/internal.dart'; +import 'package:windows_foundation/windows_foundation.dart'; +import 'package:windows_storage/windows_storage.dart'; + +import 'folderlauncheroptions.dart'; + +/// @nodoc +const IID_ILauncherStatics3 = '{234261a8-9db3-4683-aa42-dc6f51d33847}'; + +/// {@category interface} +class ILauncherStatics3 extends IInspectable { + // vtable begins at 6, is 2 entries long. + ILauncherStatics3.fromPtr(super.ptr); + + factory ILauncherStatics3.from(IInspectable interface) => + ILauncherStatics3.fromPtr(interface.toInterface(IID_ILauncherStatics3)); + + Future launchFolderAsync(IStorageFolder? folder) { + final retValuePtr = calloc(); + final folderPtr = folder == null ? nullptr : folder.ptr.ref.lpVtbl; + + final hr = + ptr.ref.vtable + .elementAt(6) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, + VTablePointer folder, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, VTablePointer folder, + Pointer retValuePtr)>()( + ptr.ref.lpVtbl, folderPtr, retValuePtr); + + if (FAILED(hr)) { + free(retValuePtr); + throw WindowsException(hr); + } + + final asyncOperation = IAsyncOperation.fromPtr(retValuePtr); + return asyncOperation.toFuture(asyncOperation.getResults); + } + + Future launchFolderWithOptionsAsync( + IStorageFolder? folder, FolderLauncherOptions? options) { + final retValuePtr = calloc(); + final folderPtr = folder == null ? nullptr : folder.ptr.ref.lpVtbl; + final optionsPtr = options == null ? nullptr : options.ptr.ref.lpVtbl; + + final hr = ptr.ref.vtable + .elementAt(7) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, + VTablePointer folder, + VTablePointer options, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, VTablePointer folder, + VTablePointer options, Pointer retValuePtr)>()( + ptr.ref.lpVtbl, folderPtr, optionsPtr, retValuePtr); + + if (FAILED(hr)) { + free(retValuePtr); + throw WindowsException(hr); + } + + final asyncOperation = IAsyncOperation.fromPtr(retValuePtr); + return asyncOperation.toFuture(asyncOperation.getResults); + } +} diff --git a/packages/windows_system/lib/src/ilauncherstatics4.dart b/packages/windows_system/lib/src/ilauncherstatics4.dart new file mode 100644 index 00000000..dc181b01 --- /dev/null +++ b/packages/windows_system/lib/src/ilauncherstatics4.dart @@ -0,0 +1,350 @@ +// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. +// All rights reserved. Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. + +// ignore_for_file: constant_identifier_names, non_constant_identifier_names +// ignore_for_file: unnecessary_import, unused_import + +import 'dart:async'; +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; +import 'package:win32/win32.dart' hide DocumentProperties; +import 'package:windows_applicationmodel/windows_applicationmodel.dart'; +import 'package:windows_foundation/internal.dart'; +import 'package:windows_foundation/windows_foundation.dart'; + +import 'launcheroptions.dart'; +import 'launchquerysupportstatus.dart'; +import 'launchuriresult.dart'; +import 'launchuristatus.dart'; +import 'user.dart'; + +/// @nodoc +const IID_ILauncherStatics4 = '{b9ec819f-b5a5-41c6-b3b3-dd1b3178bcf2}'; + +/// {@category interface} +class ILauncherStatics4 extends IInspectable { + // vtable begins at 6, is 8 entries long. + ILauncherStatics4.fromPtr(super.ptr); + + factory ILauncherStatics4.from(IInspectable interface) => + ILauncherStatics4.fromPtr(interface.toInterface(IID_ILauncherStatics4)); + + Future queryAppUriSupportAsync(Uri? uri) { + final retValuePtr = calloc(); + final uriUri = uri?.toWinRTUri(); + + final hr = + ptr.ref.vtable + .elementAt(6) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, + VTablePointer uri, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, VTablePointer uri, + Pointer retValuePtr)>()(ptr.ref.lpVtbl, + uriUri == null ? nullptr : uriUri.ptr.ref.lpVtbl, retValuePtr); + + if (FAILED(hr)) { + free(retValuePtr); + throw WindowsException(hr); + } + + final asyncOperation = IAsyncOperation.fromPtr( + retValuePtr, + enumCreator: LaunchQuerySupportStatus.from); + return asyncOperation.toFuture(asyncOperation.getResults); + } + + Future queryAppUriSupportWithPackageFamilyNameAsync( + Uri? uri, String packageFamilyName) { + final retValuePtr = calloc(); + final uriUri = uri?.toWinRTUri(); + final packageFamilyNameHString = packageFamilyName.toHString(); + + final hr = ptr.ref.vtable + .elementAt(7) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, + VTablePointer uri, + IntPtr packageFamilyName, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, VTablePointer uri, + int packageFamilyName, Pointer retValuePtr)>()( + ptr.ref.lpVtbl, + uriUri == null ? nullptr : uriUri.ptr.ref.lpVtbl, + packageFamilyNameHString, + retValuePtr); + + WindowsDeleteString(packageFamilyNameHString); + + if (FAILED(hr)) { + free(retValuePtr); + throw WindowsException(hr); + } + + final asyncOperation = IAsyncOperation.fromPtr( + retValuePtr, + enumCreator: LaunchQuerySupportStatus.from); + return asyncOperation.toFuture(asyncOperation.getResults); + } + + Future> findAppUriHandlersAsync(Uri? uri) { + final retValuePtr = calloc(); + final uriUri = uri?.toWinRTUri(); + + final hr = + ptr.ref.vtable + .elementAt(8) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, + VTablePointer uri, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, VTablePointer uri, + Pointer retValuePtr)>()(ptr.ref.lpVtbl, + uriUri == null ? nullptr : uriUri.ptr.ref.lpVtbl, retValuePtr); + + if (FAILED(hr)) { + free(retValuePtr); + throw WindowsException(hr); + } + + final asyncOperation = IAsyncOperation>.fromPtr( + retValuePtr, + creator: (ptr) => IVectorView.fromPtr(ptr, + creator: AppInfo.fromPtr, + iterableIid: '{63d0bffe-0e34-55b3-83d5-314caff2b137}')); + return asyncOperation.toFuture(() => asyncOperation.getResults().toList()); + } + + Future launchUriForUserAsync(User? user, Uri? uri) { + final retValuePtr = calloc(); + final userPtr = user == null ? nullptr : user.ptr.ref.lpVtbl; + final uriUri = uri?.toWinRTUri(); + + final hr = + ptr.ref.vtable + .elementAt(9) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, + VTablePointer user, + VTablePointer uri, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, VTablePointer user, + VTablePointer uri, Pointer retValuePtr)>()( + ptr.ref.lpVtbl, + userPtr, + uriUri == null ? nullptr : uriUri.ptr.ref.lpVtbl, + retValuePtr); + + if (FAILED(hr)) { + free(retValuePtr); + throw WindowsException(hr); + } + + final asyncOperation = IAsyncOperation.fromPtr(retValuePtr, + enumCreator: LaunchUriStatus.from); + return asyncOperation.toFuture(asyncOperation.getResults); + } + + Future launchUriWithOptionsForUserAsync( + User? user, Uri? uri, LauncherOptions? options) { + final retValuePtr = calloc(); + final userPtr = user == null ? nullptr : user.ptr.ref.lpVtbl; + final uriUri = uri?.toWinRTUri(); + final optionsPtr = options == null ? nullptr : options.ptr.ref.lpVtbl; + + final hr = ptr.ref.vtable + .elementAt(10) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, + VTablePointer user, + VTablePointer uri, + VTablePointer options, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function( + VTablePointer lpVtbl, + VTablePointer user, + VTablePointer uri, + VTablePointer options, + Pointer retValuePtr)>()( + ptr.ref.lpVtbl, + userPtr, + uriUri == null ? nullptr : uriUri.ptr.ref.lpVtbl, + optionsPtr, + retValuePtr); + + if (FAILED(hr)) { + free(retValuePtr); + throw WindowsException(hr); + } + + final asyncOperation = IAsyncOperation.fromPtr(retValuePtr, + enumCreator: LaunchUriStatus.from); + return asyncOperation.toFuture(asyncOperation.getResults); + } + + Future launchUriWithDataForUserAsync( + User? user, Uri? uri, LauncherOptions? options, ValueSet inputData) { + final retValuePtr = calloc(); + final userPtr = user == null ? nullptr : user.ptr.ref.lpVtbl; + final uriUri = uri?.toWinRTUri(); + final optionsPtr = options == null ? nullptr : options.ptr.ref.lpVtbl; + final inputDataPtr = inputData.ptr.ref.lpVtbl; + + final hr = ptr.ref.vtable + .elementAt(11) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, + VTablePointer user, + VTablePointer uri, + VTablePointer options, + VTablePointer inputData, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function( + VTablePointer lpVtbl, + VTablePointer user, + VTablePointer uri, + VTablePointer options, + VTablePointer inputData, + Pointer retValuePtr)>()( + ptr.ref.lpVtbl, + userPtr, + uriUri == null ? nullptr : uriUri.ptr.ref.lpVtbl, + optionsPtr, + inputDataPtr, + retValuePtr); + + if (FAILED(hr)) { + free(retValuePtr); + throw WindowsException(hr); + } + + final asyncOperation = IAsyncOperation.fromPtr(retValuePtr, + enumCreator: LaunchUriStatus.from); + return asyncOperation.toFuture(asyncOperation.getResults); + } + + Future launchUriForResultsForUserAsync( + User? user, Uri? uri, LauncherOptions? options) { + final retValuePtr = calloc(); + final userPtr = user == null ? nullptr : user.ptr.ref.lpVtbl; + final uriUri = uri?.toWinRTUri(); + final optionsPtr = options == null ? nullptr : options.ptr.ref.lpVtbl; + + final hr = ptr.ref.vtable + .elementAt(12) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, + VTablePointer user, + VTablePointer uri, + VTablePointer options, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function( + VTablePointer lpVtbl, + VTablePointer user, + VTablePointer uri, + VTablePointer options, + Pointer retValuePtr)>()( + ptr.ref.lpVtbl, + userPtr, + uriUri == null ? nullptr : uriUri.ptr.ref.lpVtbl, + optionsPtr, + retValuePtr); + + if (FAILED(hr)) { + free(retValuePtr); + throw WindowsException(hr); + } + + final asyncOperation = IAsyncOperation.fromPtr( + retValuePtr, + creator: LaunchUriResult.fromPtr); + return asyncOperation.toFuture(asyncOperation.getResults); + } + + Future launchUriForResultsWithDataForUserAsync( + User? user, Uri? uri, LauncherOptions? options, ValueSet inputData) { + final retValuePtr = calloc(); + final userPtr = user == null ? nullptr : user.ptr.ref.lpVtbl; + final uriUri = uri?.toWinRTUri(); + final optionsPtr = options == null ? nullptr : options.ptr.ref.lpVtbl; + final inputDataPtr = inputData.ptr.ref.lpVtbl; + + final hr = ptr.ref.vtable + .elementAt(13) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, + VTablePointer user, + VTablePointer uri, + VTablePointer options, + VTablePointer inputData, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function( + VTablePointer lpVtbl, + VTablePointer user, + VTablePointer uri, + VTablePointer options, + VTablePointer inputData, + Pointer retValuePtr)>()( + ptr.ref.lpVtbl, + userPtr, + uriUri == null ? nullptr : uriUri.ptr.ref.lpVtbl, + optionsPtr, + inputDataPtr, + retValuePtr); + + if (FAILED(hr)) { + free(retValuePtr); + throw WindowsException(hr); + } + + final asyncOperation = IAsyncOperation.fromPtr( + retValuePtr, + creator: LaunchUriResult.fromPtr); + return asyncOperation.toFuture(asyncOperation.getResults); + } +} diff --git a/packages/windows_system/lib/src/ilauncherstatics5.dart b/packages/windows_system/lib/src/ilauncherstatics5.dart new file mode 100644 index 00000000..b9773e81 --- /dev/null +++ b/packages/windows_system/lib/src/ilauncherstatics5.dart @@ -0,0 +1,160 @@ +// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. +// All rights reserved. Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. + +// ignore_for_file: constant_identifier_names, non_constant_identifier_names +// ignore_for_file: unnecessary_import, unused_import + +import 'dart:async'; +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; +import 'package:win32/win32.dart' hide DocumentProperties; +import 'package:windows_foundation/internal.dart'; +import 'package:windows_foundation/windows_foundation.dart'; + +import 'folderlauncheroptions.dart'; +import 'user.dart'; + +/// @nodoc +const IID_ILauncherStatics5 = '{5b24ef84-d895-5fea-9153-1ac49aed9ba9}'; + +/// {@category interface} +class ILauncherStatics5 extends IInspectable { + // vtable begins at 6, is 4 entries long. + ILauncherStatics5.fromPtr(super.ptr); + + factory ILauncherStatics5.from(IInspectable interface) => + ILauncherStatics5.fromPtr(interface.toInterface(IID_ILauncherStatics5)); + + Future launchFolderPathAsync(String path) { + final retValuePtr = calloc(); + final pathHString = path.toHString(); + + final hr = ptr.ref.vtable + .elementAt(6) + .cast< + Pointer< + NativeFunction< + HRESULT Function(VTablePointer lpVtbl, IntPtr path, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, int path, + Pointer retValuePtr)>()( + ptr.ref.lpVtbl, pathHString, retValuePtr); + + WindowsDeleteString(pathHString); + + if (FAILED(hr)) { + free(retValuePtr); + throw WindowsException(hr); + } + + final asyncOperation = IAsyncOperation.fromPtr(retValuePtr); + return asyncOperation.toFuture(asyncOperation.getResults); + } + + Future launchFolderPathWithOptionsAsync( + String path, FolderLauncherOptions? options) { + final retValuePtr = calloc(); + final pathHString = path.toHString(); + final optionsPtr = options == null ? nullptr : options.ptr.ref.lpVtbl; + + final hr = ptr.ref.vtable + .elementAt(7) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, + IntPtr path, + VTablePointer options, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, int path, + VTablePointer options, Pointer retValuePtr)>()( + ptr.ref.lpVtbl, pathHString, optionsPtr, retValuePtr); + + WindowsDeleteString(pathHString); + + if (FAILED(hr)) { + free(retValuePtr); + throw WindowsException(hr); + } + + final asyncOperation = IAsyncOperation.fromPtr(retValuePtr); + return asyncOperation.toFuture(asyncOperation.getResults); + } + + Future launchFolderPathForUserAsync(User? user, String path) { + final retValuePtr = calloc(); + final userPtr = user == null ? nullptr : user.ptr.ref.lpVtbl; + final pathHString = path.toHString(); + + final hr = + ptr.ref.vtable + .elementAt(8) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, + VTablePointer user, + IntPtr path, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, VTablePointer user, + int path, Pointer retValuePtr)>()( + ptr.ref.lpVtbl, userPtr, pathHString, retValuePtr); + + WindowsDeleteString(pathHString); + + if (FAILED(hr)) { + free(retValuePtr); + throw WindowsException(hr); + } + + final asyncOperation = IAsyncOperation.fromPtr(retValuePtr); + return asyncOperation.toFuture(asyncOperation.getResults); + } + + Future launchFolderPathWithOptionsForUserAsync( + User? user, String path, FolderLauncherOptions? options) { + final retValuePtr = calloc(); + final userPtr = user == null ? nullptr : user.ptr.ref.lpVtbl; + final pathHString = path.toHString(); + final optionsPtr = options == null ? nullptr : options.ptr.ref.lpVtbl; + + final hr = ptr.ref.vtable + .elementAt(9) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, + VTablePointer user, + IntPtr path, + VTablePointer options, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, VTablePointer user, int path, + VTablePointer options, Pointer retValuePtr)>()( + ptr.ref.lpVtbl, userPtr, pathHString, optionsPtr, retValuePtr); + + WindowsDeleteString(pathHString); + + if (FAILED(hr)) { + free(retValuePtr); + throw WindowsException(hr); + } + + final asyncOperation = IAsyncOperation.fromPtr(retValuePtr); + return asyncOperation.toFuture(asyncOperation.getResults); + } +} diff --git a/packages/windows_system/lib/src/ilauncheruioptions.dart b/packages/windows_system/lib/src/ilauncheruioptions.dart new file mode 100644 index 00000000..7ecd4a8a --- /dev/null +++ b/packages/windows_system/lib/src/ilauncheruioptions.dart @@ -0,0 +1,159 @@ +// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. +// All rights reserved. Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. + +// ignore_for_file: constant_identifier_names, non_constant_identifier_names +// ignore_for_file: unnecessary_import, unused_import + +import 'dart:async'; +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; +import 'package:win32/win32.dart' hide DocumentProperties; +import 'package:windows_foundation/internal.dart'; +import 'package:windows_foundation/windows_foundation.dart'; +import 'package:windows_ui/windows_ui.dart'; + +/// @nodoc +const IID_ILauncherUIOptions = '{1b25da6e-8aa6-41e9-8251-4165f5985f49}'; + +/// {@category interface} +class ILauncherUIOptions extends IInspectable { + // vtable begins at 6, is 6 entries long. + ILauncherUIOptions.fromPtr(super.ptr); + + factory ILauncherUIOptions.from(IInspectable interface) => + ILauncherUIOptions.fromPtr(interface.toInterface(IID_ILauncherUIOptions)); + + Point? get invocationPoint { + final retValuePtr = calloc(); + + final hr = ptr.ref.vtable + .elementAt(6) + .cast< + Pointer< + NativeFunction< + HRESULT Function(VTablePointer lpVtbl, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, + Pointer retValuePtr)>()(ptr.ref.lpVtbl, retValuePtr); + + if (FAILED(hr)) { + free(retValuePtr); + throw WindowsException(hr); + } + + if (retValuePtr.ref.isNull) { + free(retValuePtr); + return null; + } + + final reference = IReference.fromPtr(retValuePtr, + referenceIid: '{84f14c22-a00a-5272-8d3d-82112e66df00}'); + return reference.value; + } + + set invocationPoint(Point? value) { + final hr = ptr.ref.vtable + .elementAt(7) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, VTablePointer value)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, VTablePointer value)>()( + ptr.ref.lpVtbl, value?.toReference().ptr.ref.lpVtbl ?? nullptr); + + if (FAILED(hr)) throw WindowsException(hr); + } + + Rect? get selectionRect { + final retValuePtr = calloc(); + + final hr = ptr.ref.vtable + .elementAt(8) + .cast< + Pointer< + NativeFunction< + HRESULT Function(VTablePointer lpVtbl, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, + Pointer retValuePtr)>()(ptr.ref.lpVtbl, retValuePtr); + + if (FAILED(hr)) { + free(retValuePtr); + throw WindowsException(hr); + } + + if (retValuePtr.ref.isNull) { + free(retValuePtr); + return null; + } + + final reference = IReference.fromPtr(retValuePtr, + referenceIid: '{80423f11-054f-5eac-afd3-63b6ce15e77b}'); + return reference.value; + } + + set selectionRect(Rect? value) { + final hr = ptr.ref.vtable + .elementAt(9) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, VTablePointer value)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, VTablePointer value)>()( + ptr.ref.lpVtbl, value?.toReference().ptr.ref.lpVtbl ?? nullptr); + + if (FAILED(hr)) throw WindowsException(hr); + } + + Placement get preferredPlacement { + final retValuePtr = calloc(); + + try { + final hr = ptr.ref.vtable + .elementAt(10) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, + Pointer retValuePtr)>()(ptr.ref.lpVtbl, retValuePtr); + + if (FAILED(hr)) throw WindowsException(hr); + + return Placement.from(retValuePtr.value); + } finally { + free(retValuePtr); + } + } + + set preferredPlacement(Placement value) { + final hr = ptr.ref.vtable + .elementAt(11) + .cast< + Pointer< + NativeFunction< + HRESULT Function(VTablePointer lpVtbl, Int32 value)>>>() + .value + .asFunction()( + ptr.ref.lpVtbl, value.value); + + if (FAILED(hr)) throw WindowsException(hr); + } +} diff --git a/packages/windows_system/lib/src/ilauncherviewoptions.dart b/packages/windows_system/lib/src/ilauncherviewoptions.dart new file mode 100644 index 00000000..ce9330a2 --- /dev/null +++ b/packages/windows_system/lib/src/ilauncherviewoptions.dart @@ -0,0 +1,68 @@ +// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. +// All rights reserved. Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. + +// ignore_for_file: constant_identifier_names, non_constant_identifier_names +// ignore_for_file: unnecessary_import, unused_import + +import 'dart:async'; +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; +import 'package:win32/win32.dart' hide DocumentProperties; +import 'package:windows_foundation/internal.dart'; +import 'package:windows_foundation/windows_foundation.dart'; +import 'package:windows_ui/windows_ui.dart'; + +/// @nodoc +const IID_ILauncherViewOptions = '{8a9b29f1-7ca7-49de-9bd3-3c5b7184f616}'; + +/// {@category interface} +class ILauncherViewOptions extends IInspectable { + // vtable begins at 6, is 2 entries long. + ILauncherViewOptions.fromPtr(super.ptr); + + factory ILauncherViewOptions.from(IInspectable interface) => + ILauncherViewOptions.fromPtr( + interface.toInterface(IID_ILauncherViewOptions)); + + ViewSizePreference get desiredRemainingView { + final retValuePtr = calloc(); + + try { + final hr = ptr.ref.vtable + .elementAt(6) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, + Pointer retValuePtr)>()(ptr.ref.lpVtbl, retValuePtr); + + if (FAILED(hr)) throw WindowsException(hr); + + return ViewSizePreference.from(retValuePtr.value); + } finally { + free(retValuePtr); + } + } + + set desiredRemainingView(ViewSizePreference value) { + final hr = ptr.ref.vtable + .elementAt(7) + .cast< + Pointer< + NativeFunction< + HRESULT Function(VTablePointer lpVtbl, Int32 value)>>>() + .value + .asFunction()( + ptr.ref.lpVtbl, value.value); + + if (FAILED(hr)) throw WindowsException(hr); + } +} diff --git a/packages/windows_system/lib/src/ilaunchuriresult.dart b/packages/windows_system/lib/src/ilaunchuriresult.dart new file mode 100644 index 00000000..acd16df9 --- /dev/null +++ b/packages/windows_system/lib/src/ilaunchuriresult.dart @@ -0,0 +1,77 @@ +// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. +// All rights reserved. Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. + +// ignore_for_file: constant_identifier_names, non_constant_identifier_names +// ignore_for_file: unnecessary_import, unused_import + +import 'dart:async'; +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; +import 'package:win32/win32.dart' hide DocumentProperties; +import 'package:windows_foundation/internal.dart'; +import 'package:windows_foundation/windows_foundation.dart'; + +import 'launchuristatus.dart'; + +/// @nodoc +const IID_ILaunchUriResult = '{ec27a8df-f6d5-45ca-913a-70a40c5c8221}'; + +/// {@category interface} +class ILaunchUriResult extends IInspectable { + // vtable begins at 6, is 2 entries long. + ILaunchUriResult.fromPtr(super.ptr); + + factory ILaunchUriResult.from(IInspectable interface) => + ILaunchUriResult.fromPtr(interface.toInterface(IID_ILaunchUriResult)); + + LaunchUriStatus get status { + final retValuePtr = calloc(); + + try { + final hr = ptr.ref.vtable + .elementAt(6) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, + Pointer retValuePtr)>()(ptr.ref.lpVtbl, retValuePtr); + + if (FAILED(hr)) throw WindowsException(hr); + + return LaunchUriStatus.from(retValuePtr.value); + } finally { + free(retValuePtr); + } + } + + ValueSet get result { + final retValuePtr = calloc(); + + final hr = ptr.ref.vtable + .elementAt(7) + .cast< + Pointer< + NativeFunction< + HRESULT Function(VTablePointer lpVtbl, + Pointer retValuePtr)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, + Pointer retValuePtr)>()(ptr.ref.lpVtbl, retValuePtr); + + if (FAILED(hr)) { + free(retValuePtr); + throw WindowsException(hr); + } + + return ValueSet.fromPtr(retValuePtr); + } +} diff --git a/packages/windows_system/lib/src/launcher.dart b/packages/windows_system/lib/src/launcher.dart new file mode 100644 index 00000000..72b5cf48 --- /dev/null +++ b/packages/windows_system/lib/src/launcher.dart @@ -0,0 +1,207 @@ +// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. +// All rights reserved. Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. + +// ignore_for_file: constant_identifier_names, non_constant_identifier_names +// ignore_for_file: unnecessary_import, unused_import + +import 'dart:async'; +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; +import 'package:win32/win32.dart' hide DocumentProperties; +import 'package:windows_applicationmodel/windows_applicationmodel.dart'; +import 'package:windows_foundation/internal.dart'; +import 'package:windows_foundation/windows_foundation.dart'; +import 'package:windows_storage/windows_storage.dart'; + +import 'folderlauncheroptions.dart'; +import 'ilauncherstatics.dart'; +import 'ilauncherstatics2.dart'; +import 'ilauncherstatics3.dart'; +import 'ilauncherstatics4.dart'; +import 'ilauncherstatics5.dart'; +import 'launcheroptions.dart'; +import 'launchquerysupportstatus.dart'; +import 'launchquerysupporttype.dart'; +import 'launchuriresult.dart'; +import 'launchuristatus.dart'; +import 'user.dart'; + +/// Starts the default app associated with the specified file or URI. +/// +/// {@category class} +class Launcher extends IInspectable { + Launcher.fromPtr(super.ptr); + + static const _className = 'Windows.System.Launcher'; + + static Future launchFileAsync(IStorageFile? file) => + createActivationFactory( + ILauncherStatics.fromPtr, _className, IID_ILauncherStatics) + .launchFileAsync(file); + + static Future launchFileWithOptionsAsync( + IStorageFile? file, LauncherOptions? options) => + createActivationFactory( + ILauncherStatics.fromPtr, _className, IID_ILauncherStatics) + .launchFileWithOptionsAsync(file, options); + + static Future launchUriAsync(Uri? uri) => createActivationFactory( + ILauncherStatics.fromPtr, _className, IID_ILauncherStatics) + .launchUriAsync(uri); + + static Future launchUriWithOptionsAsync( + Uri? uri, LauncherOptions? options) => + createActivationFactory( + ILauncherStatics.fromPtr, _className, IID_ILauncherStatics) + .launchUriWithOptionsAsync(uri, options); + + static Future launchUriForResultsAsync( + Uri? uri, LauncherOptions? options) => + createActivationFactory( + ILauncherStatics2.fromPtr, _className, IID_ILauncherStatics2) + .launchUriForResultsAsync(uri, options); + + static Future launchUriForResultsWithDataAsync( + Uri? uri, LauncherOptions? options, ValueSet inputData) => + createActivationFactory( + ILauncherStatics2.fromPtr, _className, IID_ILauncherStatics2) + .launchUriForResultsWithDataAsync(uri, options, inputData); + + static Future launchUriWithDataAsync( + Uri? uri, LauncherOptions? options, ValueSet inputData) => + createActivationFactory( + ILauncherStatics2.fromPtr, _className, IID_ILauncherStatics2) + .launchUriWithDataAsync(uri, options, inputData); + + static Future queryUriSupportAsync( + Uri? uri, LaunchQuerySupportType launchQuerySupportType) => + createActivationFactory( + ILauncherStatics2.fromPtr, _className, IID_ILauncherStatics2) + .queryUriSupportAsync(uri, launchQuerySupportType); + + static Future + queryUriSupportWithPackageFamilyNameAsync( + Uri? uri, + LaunchQuerySupportType launchQuerySupportType, + String packageFamilyName) => + createActivationFactory( + ILauncherStatics2.fromPtr, _className, IID_ILauncherStatics2) + .queryUriSupportWithPackageFamilyNameAsync( + uri, launchQuerySupportType, packageFamilyName); + + static Future queryFileSupportAsync( + StorageFile? file) => + createActivationFactory( + ILauncherStatics2.fromPtr, _className, IID_ILauncherStatics2) + .queryFileSupportAsync(file); + + static Future + queryFileSupportWithPackageFamilyNameAsync( + StorageFile? file, String packageFamilyName) => + createActivationFactory( + ILauncherStatics2.fromPtr, _className, IID_ILauncherStatics2) + .queryFileSupportWithPackageFamilyNameAsync( + file, packageFamilyName); + + static Future> findUriSchemeHandlersAsync(String scheme) => + createActivationFactory( + ILauncherStatics2.fromPtr, _className, IID_ILauncherStatics2) + .findUriSchemeHandlersAsync(scheme); + + static Future> findUriSchemeHandlersWithLaunchUriTypeAsync( + String scheme, LaunchQuerySupportType launchQuerySupportType) => + createActivationFactory( + ILauncherStatics2.fromPtr, _className, IID_ILauncherStatics2) + .findUriSchemeHandlersWithLaunchUriTypeAsync( + scheme, launchQuerySupportType); + + static Future> findFileHandlersAsync(String extension) => + createActivationFactory( + ILauncherStatics2.fromPtr, _className, IID_ILauncherStatics2) + .findFileHandlersAsync(extension); + + static Future launchFolderAsync(IStorageFolder? folder) => + createActivationFactory( + ILauncherStatics3.fromPtr, _className, IID_ILauncherStatics3) + .launchFolderAsync(folder); + + static Future launchFolderWithOptionsAsync( + IStorageFolder? folder, FolderLauncherOptions? options) => + createActivationFactory( + ILauncherStatics3.fromPtr, _className, IID_ILauncherStatics3) + .launchFolderWithOptionsAsync(folder, options); + + static Future queryAppUriSupportAsync(Uri? uri) => + createActivationFactory( + ILauncherStatics4.fromPtr, _className, IID_ILauncherStatics4) + .queryAppUriSupportAsync(uri); + + static Future + queryAppUriSupportWithPackageFamilyNameAsync( + Uri? uri, String packageFamilyName) => + createActivationFactory( + ILauncherStatics4.fromPtr, _className, IID_ILauncherStatics4) + .queryAppUriSupportWithPackageFamilyNameAsync( + uri, packageFamilyName); + + static Future> findAppUriHandlersAsync(Uri? uri) => + createActivationFactory( + ILauncherStatics4.fromPtr, _className, IID_ILauncherStatics4) + .findAppUriHandlersAsync(uri); + + static Future launchUriForUserAsync(User? user, Uri? uri) => + createActivationFactory( + ILauncherStatics4.fromPtr, _className, IID_ILauncherStatics4) + .launchUriForUserAsync(user, uri); + + static Future launchUriWithOptionsForUserAsync( + User? user, Uri? uri, LauncherOptions? options) => + createActivationFactory( + ILauncherStatics4.fromPtr, _className, IID_ILauncherStatics4) + .launchUriWithOptionsForUserAsync(user, uri, options); + + static Future launchUriWithDataForUserAsync( + User? user, Uri? uri, LauncherOptions? options, ValueSet inputData) => + createActivationFactory( + ILauncherStatics4.fromPtr, _className, IID_ILauncherStatics4) + .launchUriWithDataForUserAsync(user, uri, options, inputData); + + static Future launchUriForResultsForUserAsync( + User? user, Uri? uri, LauncherOptions? options) => + createActivationFactory( + ILauncherStatics4.fromPtr, _className, IID_ILauncherStatics4) + .launchUriForResultsForUserAsync(user, uri, options); + + static Future launchUriForResultsWithDataForUserAsync( + User? user, Uri? uri, LauncherOptions? options, ValueSet inputData) => + createActivationFactory( + ILauncherStatics4.fromPtr, _className, IID_ILauncherStatics4) + .launchUriForResultsWithDataForUserAsync( + user, uri, options, inputData); + + static Future launchFolderPathAsync(String path) => + createActivationFactory( + ILauncherStatics5.fromPtr, _className, IID_ILauncherStatics5) + .launchFolderPathAsync(path); + + static Future launchFolderPathWithOptionsAsync( + String path, FolderLauncherOptions? options) => + createActivationFactory( + ILauncherStatics5.fromPtr, _className, IID_ILauncherStatics5) + .launchFolderPathWithOptionsAsync(path, options); + + static Future launchFolderPathForUserAsync(User? user, String path) => + createActivationFactory( + ILauncherStatics5.fromPtr, _className, IID_ILauncherStatics5) + .launchFolderPathForUserAsync(user, path); + + static Future launchFolderPathWithOptionsForUserAsync( + User? user, String path, FolderLauncherOptions? options) => + createActivationFactory( + ILauncherStatics5.fromPtr, _className, IID_ILauncherStatics5) + .launchFolderPathWithOptionsForUserAsync(user, path, options); +} diff --git a/packages/windows_system/lib/src/launcheroptions.dart b/packages/windows_system/lib/src/launcheroptions.dart new file mode 100644 index 00000000..3a5b315c --- /dev/null +++ b/packages/windows_system/lib/src/launcheroptions.dart @@ -0,0 +1,136 @@ +// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. +// All rights reserved. Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. + +// ignore_for_file: constant_identifier_names, non_constant_identifier_names +// ignore_for_file: unnecessary_import, unused_import + +import 'dart:async'; +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; +import 'package:win32/win32.dart' hide DocumentProperties; +import 'package:windows_foundation/internal.dart'; +import 'package:windows_foundation/windows_foundation.dart'; +import 'package:windows_storage/windows_storage.dart'; +import 'package:windows_ui/windows_ui.dart'; + +import 'ilauncheroptions.dart'; +import 'ilauncheroptions2.dart'; +import 'ilauncheroptions3.dart'; +import 'ilauncheroptions4.dart'; +import 'ilauncherviewoptions.dart'; +import 'launcheruioptions.dart'; + +/// Specifies the options used to launch the default app for a file or URI. +/// +/// {@category class} +class LauncherOptions extends IInspectable + implements + ILauncherOptions2, + ILauncherOptions, + ILauncherOptions3, + ILauncherOptions4, + ILauncherViewOptions { + LauncherOptions() : super(activateClass(_className)); + LauncherOptions.fromPtr(super.ptr); + + static const _className = 'Windows.System.LauncherOptions'; + + late final _iLauncherOptions2 = ILauncherOptions2.from(this); + + @override + String get targetApplicationPackageFamilyName => + _iLauncherOptions2.targetApplicationPackageFamilyName; + + @override + set targetApplicationPackageFamilyName(String value) => + _iLauncherOptions2.targetApplicationPackageFamilyName = value; + + @override + StorageFileQueryResult? get neighboringFilesQuery => + _iLauncherOptions2.neighboringFilesQuery; + + @override + set neighboringFilesQuery(StorageFileQueryResult? value) => + _iLauncherOptions2.neighboringFilesQuery = value; + + late final _iLauncherOptions = ILauncherOptions.from(this); + + @override + bool get treatAsUntrusted => _iLauncherOptions.treatAsUntrusted; + + @override + set treatAsUntrusted(bool value) => + _iLauncherOptions.treatAsUntrusted = value; + + @override + bool get displayApplicationPicker => + _iLauncherOptions.displayApplicationPicker; + + @override + set displayApplicationPicker(bool value) => + _iLauncherOptions.displayApplicationPicker = value; + + @override + LauncherUIOptions? get ui => _iLauncherOptions.ui; + + @override + String get preferredApplicationPackageFamilyName => + _iLauncherOptions.preferredApplicationPackageFamilyName; + + @override + set preferredApplicationPackageFamilyName(String value) => + _iLauncherOptions.preferredApplicationPackageFamilyName = value; + + @override + String get preferredApplicationDisplayName => + _iLauncherOptions.preferredApplicationDisplayName; + + @override + set preferredApplicationDisplayName(String value) => + _iLauncherOptions.preferredApplicationDisplayName = value; + + @override + Uri? get fallbackUri => _iLauncherOptions.fallbackUri; + + @override + set fallbackUri(Uri? value) => _iLauncherOptions.fallbackUri = value; + + @override + String get contentType => _iLauncherOptions.contentType; + + @override + set contentType(String value) => _iLauncherOptions.contentType = value; + + late final _iLauncherOptions3 = ILauncherOptions3.from(this); + + @override + bool get ignoreAppUriHandlers => _iLauncherOptions3.ignoreAppUriHandlers; + + @override + set ignoreAppUriHandlers(bool value) => + _iLauncherOptions3.ignoreAppUriHandlers = value; + + late final _iLauncherOptions4 = ILauncherOptions4.from(this); + + @override + bool get limitPickerToCurrentAppAndAppUriHandlers => + _iLauncherOptions4.limitPickerToCurrentAppAndAppUriHandlers; + + @override + set limitPickerToCurrentAppAndAppUriHandlers(bool value) => + _iLauncherOptions4.limitPickerToCurrentAppAndAppUriHandlers = value; + + late final _iLauncherViewOptions = ILauncherViewOptions.from(this); + + @override + ViewSizePreference get desiredRemainingView => + _iLauncherViewOptions.desiredRemainingView; + + @override + set desiredRemainingView(ViewSizePreference value) => + _iLauncherViewOptions.desiredRemainingView = value; +} diff --git a/packages/windows_system/lib/src/launcheruioptions.dart b/packages/windows_system/lib/src/launcheruioptions.dart new file mode 100644 index 00000000..9ea338cd --- /dev/null +++ b/packages/windows_system/lib/src/launcheruioptions.dart @@ -0,0 +1,49 @@ +// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. +// All rights reserved. Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. + +// ignore_for_file: constant_identifier_names, non_constant_identifier_names +// ignore_for_file: unnecessary_import, unused_import + +import 'dart:async'; +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; +import 'package:win32/win32.dart' hide DocumentProperties; +import 'package:windows_foundation/internal.dart'; +import 'package:windows_foundation/windows_foundation.dart'; +import 'package:windows_ui/windows_ui.dart'; + +import 'ilauncheruioptions.dart'; + +/// Specifies options for user interface elements such as the application +/// picker that can be invoked by this API. +/// +/// {@category class} +class LauncherUIOptions extends IInspectable implements ILauncherUIOptions { + LauncherUIOptions.fromPtr(super.ptr); + + late final _iLauncherUIOptions = ILauncherUIOptions.from(this); + + @override + Point? get invocationPoint => _iLauncherUIOptions.invocationPoint; + + @override + set invocationPoint(Point? value) => + _iLauncherUIOptions.invocationPoint = value; + + @override + Rect? get selectionRect => _iLauncherUIOptions.selectionRect; + + @override + set selectionRect(Rect? value) => _iLauncherUIOptions.selectionRect = value; + + @override + Placement get preferredPlacement => _iLauncherUIOptions.preferredPlacement; + + @override + set preferredPlacement(Placement value) => + _iLauncherUIOptions.preferredPlacement = value; +} diff --git a/packages/windows_system/lib/src/launchuriresult.dart b/packages/windows_system/lib/src/launchuriresult.dart new file mode 100644 index 00000000..e49a05bf --- /dev/null +++ b/packages/windows_system/lib/src/launchuriresult.dart @@ -0,0 +1,34 @@ +// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. +// All rights reserved. Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. + +// ignore_for_file: constant_identifier_names, non_constant_identifier_names +// ignore_for_file: unnecessary_import, unused_import + +import 'dart:async'; +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; +import 'package:win32/win32.dart' hide DocumentProperties; +import 'package:windows_foundation/internal.dart'; +import 'package:windows_foundation/windows_foundation.dart'; + +import 'ilaunchuriresult.dart'; +import 'launchuristatus.dart'; + +/// Represents the results of a Uri launch. +/// +/// {@category class} +class LaunchUriResult extends IInspectable implements ILaunchUriResult { + LaunchUriResult.fromPtr(super.ptr); + + late final _iLaunchUriResult = ILaunchUriResult.from(this); + + @override + LaunchUriStatus get status => _iLaunchUriResult.status; + + @override + ValueSet get result => _iLaunchUriResult.result; +} diff --git a/packages/windows_system/pubspec.yaml b/packages/windows_system/pubspec.yaml index 3ee95a72..14baf55f 100644 --- a/packages/windows_system/pubspec.yaml +++ b/packages/windows_system/pubspec.yaml @@ -21,9 +21,11 @@ platforms: dependencies: ffi: ^2.0.1 - win32: ^5.0.0 - windows_foundation: ^0.0.4 + win32: ^5.0.3 + windows_applicationmodel: ^0.0.3 + windows_foundation: ^0.0.6 windows_storage: ^0.0.2 + windows_ui: ^0.0.3 dev_dependencies: test: ^1.24.1 diff --git a/packages/winrtgen/data/objects.json b/packages/winrtgen/data/objects.json index b19a8488..d318d29e 100644 --- a/packages/winrtgen/data/objects.json +++ b/packages/winrtgen/data/objects.json @@ -176,7 +176,12 @@ "Windows.Storage.Streams.RandomAccessStreamOverStream": "Provides a Windows Runtime random access stream for an IStream base implementation.", "Windows.Storage.Streams.RandomAccessStreamReference": "Provides random access of data in input and output streams for a file.", "Windows.Storage.UserDataPaths": "Returns full paths for common user data folders. User data folders are based on the KNOWNFOLDERID naming pattern.", + "Windows.System.FolderLauncherOptions": "Specifies the options to use when launching File Explorer to display the contents of a specific folder by calling the LaunchFolderAsync(IStorageFolder, FolderLauncherOptions) method.", "Windows.System.KnownUserProperties": "Contains basic information about a user.", + "Windows.System.LaunchUriResult": "Represents the results of a Uri launch.", + "Windows.System.Launcher": "Starts the default app associated with the specified file or URI.", + "Windows.System.LauncherOptions": "Specifies the options used to launch the default app for a file or URI.", + "Windows.System.LauncherUIOptions": "Specifies options for user interface elements such as the application picker that can be invoked by this API.", "Windows.System.Power.PowerManager": "Provides access to information about a device's battery and power supply status.", "Windows.System.User": "Represents a user.", "Windows.System.UserWatcher": "Provides events that fire during enumeration of users, when the collection of users changes, or when a user's authentication status changes.",