energy/cef/types-request.go

246 lines
5.8 KiB
Go
Raw Normal View History

2022-10-04 13:21:05 +08:00
//----------------------------------------
//
// Copyright © yanghy. All Rights Reserved.
//
// Licensed under Apache License Version 2.0, January 2004
//
// https://www.apache.org/licenses/LICENSE-2.0
2022-10-04 13:21:05 +08:00
//
//----------------------------------------
2023-02-20 14:42:17 +08:00
// CEF Request
2023-05-31 17:41:14 +08:00
2022-10-04 13:21:05 +08:00
package cef
import (
"github.com/energye/energy/v2/cef/internal/def"
2023-05-31 18:00:34 +08:00
"github.com/energye/energy/v2/common/imports"
. "github.com/energye/energy/v2/consts"
2022-10-04 13:21:05 +08:00
"github.com/energye/golcl/lcl/api"
"unsafe"
)
2023-03-04 11:58:35 +08:00
// RequestRef -> ICefRequest
var RequestRef request
// request
type request uintptr
2023-05-31 17:41:14 +08:00
func (*request) New() *ICefRequest {
var result uintptr
imports.Proc(def.CefRequestRef_New).Call(uintptr(unsafe.Pointer(&result)))
2023-05-31 17:41:14 +08:00
if result != 0 {
return &ICefRequest{instance: unsafe.Pointer(result)}
}
return nil
}
2023-03-04 11:58:35 +08:00
func (*request) UnWrap(data *ICefRequest) *ICefRequest {
var result uintptr
imports.Proc(def.CefRequestRef_UnWrap).Call(data.Instance(), uintptr(unsafe.Pointer(&result)))
2023-03-04 11:58:35 +08:00
data.instance = unsafe.Pointer(result)
return data
}
2023-02-26 23:21:44 +08:00
// Instance 实例
2023-02-26 19:14:49 +08:00
func (m *ICefRequest) Instance() uintptr {
return uintptr(m.instance)
}
2023-02-27 11:33:00 +08:00
func (m *ICefRequest) IsValid() bool {
if m == nil || m.instance == nil {
return false
}
return true
}
2023-02-20 14:42:17 +08:00
// IsReadOnly 是否只读
2022-10-04 13:21:05 +08:00
func (m *ICefRequest) IsReadOnly() bool {
2023-02-27 11:33:00 +08:00
if !m.IsValid() {
return false
}
r1, _, _ := imports.Proc(def.CefRequest_IsReadOnly).Call(m.Instance())
2023-02-26 23:21:44 +08:00
return api.GoBool(r1)
2022-10-04 13:21:05 +08:00
}
func (m *ICefRequest) URL() (r string) {
2023-05-31 17:41:14 +08:00
if !m.IsValid() {
return ""
}
value := NewTString()
imports.Proc(def.CefRequest_GetUrl).Call(m.Instance(), value.Instance())
r = value.Value()
value.Free()
return
2023-05-31 17:41:14 +08:00
}
2023-02-20 14:42:17 +08:00
// SetURL 设置URL
func (m *ICefRequest) SetURL(url string) {
2023-02-27 11:33:00 +08:00
if !m.IsValid() {
return
}
imports.Proc(def.CefRequest_SetUrl).Call(m.Instance(), api.PascalStr(url))
2022-10-04 13:21:05 +08:00
}
func (m *ICefRequest) Method() (r string) {
2023-05-31 17:41:14 +08:00
if !m.IsValid() {
return ""
}
value := NewTString()
imports.Proc(def.CefRequest_GetMethod).Call(m.Instance(), value.Instance())
r = value.Value()
value.Free()
return
2023-05-31 17:41:14 +08:00
}
2023-02-20 14:42:17 +08:00
// SetMethod 设置请求方式
2022-10-04 13:21:05 +08:00
func (m *ICefRequest) SetMethod(method string) {
2023-02-27 11:33:00 +08:00
if !m.IsValid() {
return
}
imports.Proc(def.CefRequest_SetMethod).Call(m.Instance(), api.PascalStr(method))
2022-10-04 13:21:05 +08:00
}
func (m *ICefRequest) ReferrerUrl() (r string) {
2023-05-31 17:41:14 +08:00
if !m.IsValid() {
return ""
}
value := NewTString()
imports.Proc(def.CefRequest_GetReferrerUrl).Call(m.Instance(), value.Instance())
r = value.Value()
value.Free()
return r
2023-05-31 17:41:14 +08:00
}
2023-02-20 14:42:17 +08:00
// SetReferrer 设置来源策略
2022-10-04 13:21:05 +08:00
func (m *ICefRequest) SetReferrer(referrerUrl string, policy TCefReferrerPolicy) {
2023-02-27 11:33:00 +08:00
if !m.IsValid() {
return
}
imports.Proc(def.CefRequest_SetReferrer).Call(m.Instance(), api.PascalStr(referrerUrl), policy.ToPtr())
2022-10-04 13:21:05 +08:00
}
2023-05-31 17:41:14 +08:00
func (m *ICefRequest) ReferrerPolicy() TCefReferrerPolicy {
if !m.IsValid() {
return 0
}
r1, _, _ := imports.Proc(def.CefRequest_GetReferrerPolicy).Call(m.Instance())
2023-05-31 17:41:14 +08:00
return TCefReferrerPolicy(r1)
}
func (m *ICefRequest) Flags() TCefUrlRequestFlags {
if !m.IsValid() {
return 0
}
r1, _, _ := imports.Proc(def.CefRequest_GetFlags).Call(m.Instance())
2023-05-31 17:41:14 +08:00
return TCefUrlRequestFlags(r1)
}
2023-02-20 14:42:17 +08:00
// SetFlags 设置请求标记
2022-10-04 13:21:05 +08:00
func (m *ICefRequest) SetFlags(flags TCefUrlRequestFlags) {
2023-02-27 11:33:00 +08:00
if !m.IsValid() {
return
}
imports.Proc(def.CefRequest_SetFlags).Call(m.Instance(), flags.ToPtr())
2022-10-04 13:21:05 +08:00
}
2023-05-31 17:41:14 +08:00
func (m *ICefRequest) GetFirstPartyForCookies() string {
if !m.IsValid() {
return ""
}
r1, _, _ := imports.Proc(def.CefRequest_GetFirstPartyForCookies).Call(m.Instance())
2023-05-31 17:41:14 +08:00
return api.GoStr(r1)
}
2023-02-20 14:42:17 +08:00
// SetFirstPartyForCookies
2022-10-04 13:21:05 +08:00
func (m *ICefRequest) SetFirstPartyForCookies(url string) {
2023-02-27 11:33:00 +08:00
if !m.IsValid() {
return
}
imports.Proc(def.CefRequest_SetFirstPartyForCookies).Call(m.Instance(), api.PascalStr(url))
2022-10-04 13:21:05 +08:00
}
2023-02-20 14:42:17 +08:00
// GetHeaderByName
func (m *ICefRequest) GetHeaderByName(name string) (r string) {
2023-02-27 11:33:00 +08:00
if !m.IsValid() {
return ""
}
value := NewTString()
imports.Proc(def.CefRequest_GetHeaderByName).Call(m.Instance(), api.PascalStr(name), value.Instance())
r = value.Value()
value.Free()
return r
2022-10-04 13:21:05 +08:00
}
2023-02-20 14:42:17 +08:00
// SetHeaderByName
2022-10-04 13:21:05 +08:00
func (m *ICefRequest) SetHeaderByName(name, value string, overwrite bool) {
2023-02-27 11:33:00 +08:00
if !m.IsValid() {
return
}
imports.Proc(def.CefRequest_SetHeaderByName).Call(m.Instance(), api.PascalStr(name), api.PascalStr(value), api.PascalBool(overwrite))
2022-10-04 13:21:05 +08:00
}
2023-02-20 14:42:17 +08:00
// GetHeaderMap
2022-10-04 13:21:05 +08:00
func (m *ICefRequest) GetHeaderMap() *ICefStringMultiMap {
2023-02-27 11:33:00 +08:00
if !m.IsValid() {
return nil
}
2023-02-26 23:21:44 +08:00
var result uintptr
imports.Proc(def.CefRequest_GetHeaderMap).Call(m.Instance(), uintptr(unsafe.Pointer(&result)))
2023-02-26 23:21:44 +08:00
return &ICefStringMultiMap{instance: unsafe.Pointer(result)}
2022-10-04 13:21:05 +08:00
}
func (m *ICefRequest) SetHeaderMap(headerMap *ICefStringMultiMap) {
2023-02-27 11:33:00 +08:00
if !m.IsValid() {
return
}
imports.Proc(def.CefRequest_SetHeaderMap).Call(m.Instance(), headerMap.Instance())
}
2023-02-26 23:21:44 +08:00
func (m *ICefRequest) GetPostData() *ICefPostData {
2023-02-27 11:33:00 +08:00
if !m.IsValid() {
return nil
}
2023-02-26 23:21:44 +08:00
var result uintptr
imports.Proc(def.CefRequest_GetPostData).Call(m.Instance(), uintptr(unsafe.Pointer(&result)))
2023-02-26 23:21:44 +08:00
return &ICefPostData{instance: unsafe.Pointer(result)}
2022-10-04 13:21:05 +08:00
}
2023-02-26 23:21:44 +08:00
func (m *ICefRequest) SetPostData(value *ICefPostData) {
2023-02-27 11:33:00 +08:00
if !m.IsValid() {
return
}
imports.Proc(def.CefRequest_SetPostData).Call(m.Instance(), value.Instance())
}
2023-03-13 11:54:52 +08:00
2023-05-31 17:41:14 +08:00
func (m *ICefRequest) ResourceType() TCefResourceType {
if !m.IsValid() {
return 0
}
r1, _, _ := imports.Proc(def.CefRequest_GetResourceType).Call(m.Instance())
2023-05-31 17:41:14 +08:00
return TCefResourceType(r1)
}
func (m *ICefRequest) TransitionType() TCefTransitionType {
if !m.IsValid() {
return 0
}
r1, _, _ := imports.Proc(def.CefRequest_GetTransitionType).Call(m.Instance())
2023-05-31 17:41:14 +08:00
return TCefTransitionType(r1)
}
func (m *ICefRequest) Identifier() (result uint64) {
if !m.IsValid() {
return 0
}
imports.Proc(def.CefRequest_GetIdentifier).Call(m.Instance(), uintptr(unsafe.Pointer(&result)))
2023-05-31 17:41:14 +08:00
return
}
2023-03-13 11:54:52 +08:00
func (m *ICefRequest) Free() {
if m.instance != nil {
m.base.Free(m.Instance())
m.instance = nil
}
}