go-toast

Send toast notifications in Windows
Log | Files | Refs | README | LICENSE

toastnotification.go (2262B)


      1 // Code generated by winrt-go-gen. DO NOT EDIT.
      2 
      3 //go:build windows
      4 
      5 //nolint:all
      6 package notifications
      7 
      8 import (
      9 	"syscall"
     10 	"unsafe"
     11 
     12 	"git.sr.ht/~jackmordaunt/go-toast/v2/internal/winrt/data/xml/dom"
     13 	"github.com/go-ole/go-ole"
     14 )
     15 
     16 const SignatureToastNotification string = "rc(Windows.UI.Notifications.ToastNotification;{997e2675-059e-4e60-8b06-1760917c8b80})"
     17 
     18 func CreateToastNotification(content *dom.XmlDocument) (*ToastNotification, error) {
     19 	inspectable, err := ole.RoGetActivationFactory("Windows.UI.Notifications.ToastNotification", ole.NewGUID(GUIDiToastNotificationFactory))
     20 	if err != nil {
     21 		return nil, err
     22 	}
     23 	v := (*iToastNotificationFactory)(unsafe.Pointer(inspectable))
     24 
     25 	var out *ToastNotification
     26 	hr, _, _ := syscall.SyscallN(
     27 		v.VTable().CreateToastNotification,
     28 		0,                                // this is a static func, so there's no this
     29 		uintptr(unsafe.Pointer(content)), // in dom.XmlDocument
     30 		uintptr(unsafe.Pointer(&out)),    // out ToastNotification
     31 	)
     32 
     33 	if hr != 0 {
     34 		return nil, ole.NewError(hr)
     35 	}
     36 
     37 	return out, nil
     38 }
     39 
     40 type ToastNotification struct {
     41 	ole.IUnknown
     42 }
     43 
     44 const (
     45 	GUIDiToastNotification      string = "997e2675-059e-4e60-8b06-1760917c8b80"
     46 	SignatureiToastNotification string = "{997e2675-059e-4e60-8b06-1760917c8b80}"
     47 )
     48 
     49 type iToastNotification struct {
     50 	ole.IInspectable
     51 }
     52 
     53 type iToastNotificationVtbl struct {
     54 	ole.IInspectableVtbl
     55 
     56 	GetContent        uintptr
     57 	SetExpirationTime uintptr
     58 	GetExpirationTime uintptr
     59 	AddDismissed      uintptr
     60 	RemoveDismissed   uintptr
     61 	AddActivated      uintptr
     62 	RemoveActivated   uintptr
     63 	AddFailed         uintptr
     64 	RemoveFailed      uintptr
     65 }
     66 
     67 func (v *iToastNotification) VTable() *iToastNotificationVtbl {
     68 	return (*iToastNotificationVtbl)(unsafe.Pointer(v.RawVTable))
     69 }
     70 
     71 const (
     72 	GUIDiToastNotificationFactory      string = "04124b20-82c6-4229-b109-fd9ed4662b53"
     73 	SignatureiToastNotificationFactory string = "{04124b20-82c6-4229-b109-fd9ed4662b53}"
     74 )
     75 
     76 type iToastNotificationFactory struct {
     77 	ole.IInspectable
     78 }
     79 
     80 type iToastNotificationFactoryVtbl struct {
     81 	ole.IInspectableVtbl
     82 
     83 	CreateToastNotification uintptr
     84 }
     85 
     86 func (v *iToastNotificationFactory) VTable() *iToastNotificationFactoryVtbl {
     87 	return (*iToastNotificationFactoryVtbl)(unsafe.Pointer(v.RawVTable))
     88 }