forked from wailsapp/go-webview2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathICoreWebView2BasicAuthenticationResponse.go
More file actions
109 lines (93 loc) · 2.9 KB
/
Copy pathICoreWebView2BasicAuthenticationResponse.go
File metadata and controls
109 lines (93 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
//go:build windows
package webview2
import (
"golang.org/x/sys/windows"
"syscall"
"unsafe"
)
type ICoreWebView2BasicAuthenticationResponseVtbl struct {
IUnknownVtbl
GetUserName ComProc
PutUserName ComProc
GetPassword ComProc
PutPassword ComProc
}
type ICoreWebView2BasicAuthenticationResponse struct {
Vtbl *ICoreWebView2BasicAuthenticationResponseVtbl
}
func (i *ICoreWebView2BasicAuthenticationResponse) AddRef() uintptr {
refCounter, _, _ := i.Vtbl.AddRef.Call(uintptr(unsafe.Pointer(i)))
return refCounter
}
// Release drops one reference and returns the new count.
//
// AddRef was generated for all 252 interfaces and Release for none, which left every caller of a
// Get<Interface>() accessor leaking: QueryInterface AddRefs on success and there was no matching
// call to make, short of reaching through the embedded IUnknownVtbl for CallRelease. Additive, so
// no existing caller changes.
//
// Not generated for handler interfaces: those are objects WE implement and hand to WebView2, so
// their lifetime is the Go object's, and calling through the vtable would re-enter our own impl.
func (i *ICoreWebView2BasicAuthenticationResponse) Release() uint32 {
return i.Vtbl.CallRelease(unsafe.Pointer(i))
}
func (i *ICoreWebView2BasicAuthenticationResponse) GetUserName() (string, error) {
// Create *uint16 to hold result
var _userName *uint16
hr, _, _ := i.Vtbl.GetUserName.Call(
uintptr(unsafe.Pointer(i)),
uintptr(unsafe.Pointer(&_userName)),
)
if windows.Handle(hr) != windows.S_OK {
return "", syscall.Errno(hr)
}
// Get result and cleanup
userName := UTF16PtrToString(_userName)
CoTaskMemFree(unsafe.Pointer(_userName))
return userName, nil
}
func (i *ICoreWebView2BasicAuthenticationResponse) PutUserName(userName string) error {
// Convert string 'userName' to *uint16
_userName, err := UTF16PtrFromString(userName)
if err != nil {
return err
}
hr, _, _ := i.Vtbl.PutUserName.Call(
uintptr(unsafe.Pointer(i)),
uintptr(unsafe.Pointer(_userName)),
)
if windows.Handle(hr) != windows.S_OK {
return syscall.Errno(hr)
}
return nil
}
func (i *ICoreWebView2BasicAuthenticationResponse) GetPassword() (string, error) {
// Create *uint16 to hold result
var _password *uint16
hr, _, _ := i.Vtbl.GetPassword.Call(
uintptr(unsafe.Pointer(i)),
uintptr(unsafe.Pointer(&_password)),
)
if windows.Handle(hr) != windows.S_OK {
return "", syscall.Errno(hr)
}
// Get result and cleanup
password := UTF16PtrToString(_password)
CoTaskMemFree(unsafe.Pointer(_password))
return password, nil
}
func (i *ICoreWebView2BasicAuthenticationResponse) PutPassword(password string) error {
// Convert string 'password' to *uint16
_password, err := UTF16PtrFromString(password)
if err != nil {
return err
}
hr, _, _ := i.Vtbl.PutPassword.Call(
uintptr(unsafe.Pointer(i)),
uintptr(unsafe.Pointer(_password)),
)
if windows.Handle(hr) != windows.S_OK {
return syscall.Errno(hr)
}
return nil
}