commit ff2916162cca3ab5397ac545d58b812c2fbff42a Author: Sarah Jamie Lewis Date: Sat Mar 14 20:27:35 2020 -0700 Initial Commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b70b0e4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +*moc.cpp +moc_*.go +*cpp +*.h +rcc* +.idea/ +vendor/ +deploy/ +tor/ diff --git a/garden.go b/garden.go new file mode 100644 index 0000000..4dbe786 --- /dev/null +++ b/garden.go @@ -0,0 +1,57 @@ +package main + +import ( + "cwtch.im/tapir" + tapirtor "cwtch.im/tapir/networks/tor" + "cwtch.im/tapir/primitives" + "fmt" + "git.openprivacy.ca/openprivacy/connectivity" + "git.openprivacy.ca/openprivacy/connectivity/tor" + "git.openprivacy.ca/openprivacy/log" + api "git.openprivacy.ca/sarah/garden/ui" + "github.com/therecipe/qt/core" + "github.com/therecipe/qt/qml" + "github.com/therecipe/qt/quickcontrols2" + "github.com/therecipe/qt/widgets" + "os" +) + +func main() { + log.SetLevel(log.LevelDebug) + var acn connectivity.ACN + acn, _ = tor.NewTorACN(".", "") + acn.WaitTillBootstrapped() + + core.QCoreApplication_SetAttribute(core.Qt__AA_EnableHighDpiScaling, true) + + app := widgets.NewQApplication(len(os.Args), os.Args) + app.SetAttribute(core.Qt__AA_EnableHighDpiScaling, true) + quickcontrols2.QQuickStyle_SetStyle("Material") + engine := qml.NewQQmlApplicationEngine(nil) + + // Generate Server Keys + id, sk := primitives.InitializeEphemeralIdentity() + fmt.Printf("Ephemeral Garden: %v\n", id.Hostname()) + gapi := api.NewGardenAPI(nil) + // Init the Server running the Simple App. + var service tapir.Service + service = new(tapirtor.BaseOnionService) + service.Init(acn, sk, &id) + + if len(os.Args) < 2 { + go service.Listen(gapi) + } else { + service.Connect(os.Args[1], gapi) + } + engine.RootContext().SetContextProperty("garden", gapi) + // load the embedded qml file + // created by either qtrcc or qtdeploy + //engine.Load(core.NewQUrl3("qrc:/qml/main.qml", 0)) + // you can also load a local file like this instead: + engine.Load(core.QUrl_FromLocalFile("./qml/main.qml")) + + // start the main Qt event loop + // and block until app.Exit() is called + // or the window is closed by the user + widgets.QApplication_Exec() +} diff --git a/garden.pro b/garden.pro new file mode 100644 index 0000000..26a69f5 --- /dev/null +++ b/garden.pro @@ -0,0 +1,34 @@ +QT += quick charts + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which as been marked deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +SOURCES += \ + main.go + +#RESOURCES += qml.qrc + +#TRANSLATIONS = i18n/translation_en.ts \ +# i18n/translation_de.ts \ +# i18n/translation_pt.ts \ +# i18n/translation_fr.ts + +# Additional import path used to resolve QML modules in Qt Creator's code model +QML_IMPORT_PATH = + +# Additional import path used to resolve QML modules just for Qt Quick Designer +QML_DESIGNER_IMPORT_PATH = + +# Default rules for deployment. +#qnx: target.path = /tmp/$${TARGET}/bin +#else: unix:!android: target.path = /opt/$${TARGET}/bin +#!isEmpty(target.path): INSTALLS += target + diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..b4e77cf --- /dev/null +++ b/go.mod @@ -0,0 +1,9 @@ +module git.openprivacy.ca/sarah/garden + +go 1.13 + +require ( + cwtch.im/tapir v0.1.16 + git.openprivacy.ca/openprivacy/connectivity v1.1.1 + github.com/therecipe/qt v0.0.0-20191101232336-18864661ae4f +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..e0c957a --- /dev/null +++ b/go.sum @@ -0,0 +1,63 @@ +cwtch.im/tapir v0.1.16 h1:xDczK/QjhesTgU9Fmj2JOgrXKxmKTlKaczQPNoyX1sU= +cwtch.im/tapir v0.1.16/go.mod h1:HzezugpEx+nZ3LdyDsl0w6n45IJYnOt8uqldkLWmaqs= +git.openprivacy.ca/openprivacy/connectivity v1.1.0/go.mod h1:4P8mirZZslKbo2zBrXXVjgEdqGwHo/6qoFBwFQW6d6E= +git.openprivacy.ca/openprivacy/connectivity v1.1.1 h1:hKxBOmxP7Jdu3K1BJ93mRtKNiWUoP6YHt/o2snE2Z0w= +git.openprivacy.ca/openprivacy/connectivity v1.1.1/go.mod h1:4P8mirZZslKbo2zBrXXVjgEdqGwHo/6qoFBwFQW6d6E= +git.openprivacy.ca/openprivacy/log v1.0.0 h1:Rvqm1weUdR4AOnJ79b1upHCc9vC/QF1rhSD2Um7sr1Y= +git.openprivacy.ca/openprivacy/log v1.0.0/go.mod h1:gGYK8xHtndRLDymFtmjkG26GaMQNgyhioNS82m812Iw= +github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412 h1:w1UutsfOrms1J05zt7ISrnJIXKzwaspym5BTKGx93EI= +github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412/go.mod h1:WPjqKcmVOxf0XSf3YxCJs6N6AOSrOx3obionmG7T0y0= +github.com/cretz/bine v0.1.1-0.20200124154328-f9f678b84cca h1:Q2r7AxHdJwWfLtBZwvW621M3sPqxPc6ITv2j1FGsYpw= +github.com/cretz/bine v0.1.1-0.20200124154328-f9f678b84cca/go.mod h1:6PF6fWAvYtwjRGkAuDEJeWNOv3a2hUouSP/yRYXmvHw= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/gopherjs/gopherjs v0.0.0-20190411002643-bd77b112433e h1:XWcjeEtTFTOVA9Fs1w7n2XBftk5ib4oZrhzWk0B+3eA= +github.com/gopherjs/gopherjs v0.0.0-20190411002643-bd77b112433e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gtank/merlin v0.1.1 h1:eQ90iG7K9pOhtereWsmyRJ6RAwcP4tHTDBHXNg+u5is= +github.com/gtank/merlin v0.1.1/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= +github.com/gtank/ristretto255 v0.1.2 h1:JEqUCPA1NvLq5DwYtuzigd7ss8fwbYay9fi4/5uMzcc= +github.com/gtank/ristretto255 v0.1.2/go.mod h1:Ph5OpO6c7xKUGROZfWVLiJf9icMDwUeIvY4OmlYW69o= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 h1:hLDRPB66XQT/8+wG9WsDpiCvZf1yKO7sz7scAjSlBa0= +github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/therecipe/qt v0.0.0-20191101232336-18864661ae4f h1:06ICDSmDOBUC9jwgv44ngvyHzwudJNLa5H+rbCyDFRY= +github.com/therecipe/qt v0.0.0-20191101232336-18864661ae4f/go.mod h1:SUUR2j3aE1z6/g76SdD6NwACEpvCxb3fvG82eKbD6us= +github.com/therecipe/qt v0.0.0-20200126204426-5074eb6d8c41 h1:yBVcrpbaQYJBdKT2pxTdlL4hBE/eM4UPcyj9YpyvSok= +github.com/therecipe/qt v0.0.0-20200126204426-5074eb6d8c41/go.mod h1:SUUR2j3aE1z6/g76SdD6NwACEpvCxb3fvG82eKbD6us= +go.etcd.io/bbolt v1.3.3 h1:MUGmc65QhB3pIlaQ5bB4LwqSj6GIonVJXpZiaKNyaKk= +go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190418165655-df01cb2cc480/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= +golang.org/x/crypto v0.0.0-20200204104054-c9f3fb736b72/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200206161412-a0c6ece9d31a h1:aczoJ0HPNE92XKa7DrIzkNN6esOKO2TBwiiYoKcINhA= +golang.org/x/crypto v0.0.0-20200206161412-a0c6ece9d31a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190420063019-afa5a82059c6/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5 h1:LfCXLvNmTYH9kEmVgqbnsWfruoXZIrh4YBgqVHtDvw0= +golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/qml/main.qml b/qml/main.qml new file mode 100644 index 0000000..8ef38ad --- /dev/null +++ b/qml/main.qml @@ -0,0 +1,57 @@ +import QtQuick 2.7 //ApplicationWindow +import QtQuick.Controls 2.1 //Dialog +import QtQuick.Layouts 1.12 +import QtQuick.Controls 2.12 + +import QtQuick 2.0 + + +ApplicationWindow { + id: root + visible: true + title: "Garden" + minimumWidth: 640 + minimumHeight: 640 + + + + Canvas { + id: canvas + width: parent.width + height: parent.height + + property real lastX + property real lastY + property bool clear + + onPaint: { + var ctx = getContext("2d"); + if (!clear) { + ctx.fillStyle = Qt.rgba(0x8e/0xff, 0x64/0xff, 0xa5/0xff, 1); + ctx.fillRect(0, 0, width, height); + clear = true; + } + ctx.fillStyle = Qt.rgba(0xfd/0xff, 0xf3/0xff, 0xfc/0xff, 0.3); + ctx.fillRect(canvas.lastX, canvas.lastY, 5, 5); + } + MouseArea { + id: area + anchors.fill: parent + onPositionChanged: { + canvas.lastX = mouseX + canvas.lastY = mouseY + canvas.requestPaint() + garden.newDrawEvent(canvas.lastX,canvas.lastY ) + } + } + } + + Connections { // POPUPS ARE INVOKED BY GO FUNCS + target: garden + onDrawEvent: function(x,y) { + canvas.lastX = x + canvas.lastY = y + canvas.requestPaint() + } + } +} diff --git a/ui/api.go b/ui/api.go new file mode 100644 index 0000000..af9d861 --- /dev/null +++ b/ui/api.go @@ -0,0 +1,65 @@ +package api + +import ( + "cwtch.im/tapir" + "cwtch.im/tapir/applications" + "encoding/json" + "github.com/therecipe/qt/core" + "github.com/therecipe/qt/qml" + "sync" +) + +type GardenAPI struct { + applications.AuthApp + connection tapir.Connection + core.QObject + lock sync.Mutex + + QMLEngine *qml.QQmlApplicationEngine + Translator *core.QTranslator + + _ func(x int, y int) `signal:"DrawEvent"` + + _ func(x int, y int) `signal:"newDrawEvent,auto"` +} + +func (ea *GardenAPI) newDrawEvent(x int, y int) { + event := new(UpdateEvent) + event.X = x + event.Y = y + data, _ := json.Marshal(event) + ea.lock.Lock() + defer ea.lock.Unlock() + ea.connection.Send(data) +} + +// NewInstance should always return a new instantiation of the application. +func (ea *GardenAPI) NewInstance() tapir.Application { + return ea +} + +// Init is run when the connection is first started. +func (ea *GardenAPI) Init(connection tapir.Connection) { + // First run the Authentication App + ea.AuthApp.Init(connection) + + if connection.HasCapability(applications.AuthCapability) { + // The code for out simple application (We just send and receive "Hello" + ea.connection = connection + go ea.listen() + } +} + +type UpdateEvent struct { + X int + Y int +} + +func (ea *GardenAPI) listen() { + for { + data := ea.connection.Expect() + event := new(UpdateEvent) + json.Unmarshal(data, event) + ea.DrawEvent(event.X, event.Y) + } +} diff --git a/ui/moc.go b/ui/moc.go new file mode 100644 index 0000000..aae449e --- /dev/null +++ b/ui/moc.go @@ -0,0 +1,532 @@ +package api + +//#include +//#include +//#include +//#include "moc.h" +import "C" +import ( + "runtime" + "strings" + "unsafe" + + "github.com/therecipe/qt" + std_core "github.com/therecipe/qt/core" +) + +func cGoUnpackString(s C.struct_Moc_PackedString) string { + if int(s.len) == -1 { + return C.GoString(s.data) + } + return C.GoStringN(s.data, C.int(s.len)) +} +func cGoUnpackBytes(s C.struct_Moc_PackedString) []byte { + if int(s.len) == -1 { + gs := C.GoString(s.data) + return *(*[]byte)(unsafe.Pointer(&gs)) + } + return C.GoBytes(unsafe.Pointer(s.data), C.int(s.len)) +} +func unpackStringList(s string) []string { + if len(s) == 0 { + return make([]string, 0) + } + return strings.Split(s, "¡¦!") +} + +type GardenAPI_ITF interface { + std_core.QObject_ITF + GardenAPI_PTR() *GardenAPI +} + +func (ptr *GardenAPI) GardenAPI_PTR() *GardenAPI { + return ptr +} + +func (ptr *GardenAPI) Pointer() unsafe.Pointer { + if ptr != nil { + return ptr.QObject_PTR().Pointer() + } + return nil +} + +func (ptr *GardenAPI) SetPointer(p unsafe.Pointer) { + if ptr != nil { + ptr.QObject_PTR().SetPointer(p) + } +} + +func PointerFromGardenAPI(ptr GardenAPI_ITF) unsafe.Pointer { + if ptr != nil { + return ptr.GardenAPI_PTR().Pointer() + } + return nil +} + +func NewGardenAPIFromPointer(ptr unsafe.Pointer) (n *GardenAPI) { + if gPtr, ok := qt.Receive(ptr); !ok { + n = new(GardenAPI) + n.SetPointer(ptr) + } else { + switch deduced := gPtr.(type) { + case *GardenAPI: + n = deduced + + case *std_core.QObject: + n = &GardenAPI{QObject: *deduced} + + default: + n = new(GardenAPI) + n.SetPointer(ptr) + } + } + return +} + +//export callbackGardenAPIaf70b6_Constructor +func callbackGardenAPIaf70b6_Constructor(ptr unsafe.Pointer) { + this := NewGardenAPIFromPointer(ptr) + qt.Register(ptr, this) + this.ConnectNewDrawEvent(this.newDrawEvent) +} + +//export callbackGardenAPIaf70b6_DrawEvent +func callbackGardenAPIaf70b6_DrawEvent(ptr unsafe.Pointer, x C.int, y C.int) { + if signal := qt.GetSignal(ptr, "drawEvent"); signal != nil { + (*(*func(int, int))(signal))(int(int32(x)), int(int32(y))) + } + +} + +func (ptr *GardenAPI) ConnectDrawEvent(f func(x int, y int)) { + if ptr.Pointer() != nil { + + if !qt.ExistsSignal(ptr.Pointer(), "drawEvent") { + C.GardenAPIaf70b6_ConnectDrawEvent(ptr.Pointer(), C.longlong(qt.ConnectionType(ptr.Pointer(), "drawEvent"))) + } + + if signal := qt.LendSignal(ptr.Pointer(), "drawEvent"); signal != nil { + f := func(x int, y int) { + (*(*func(int, int))(signal))(x, y) + f(x, y) + } + qt.ConnectSignal(ptr.Pointer(), "drawEvent", unsafe.Pointer(&f)) + } else { + qt.ConnectSignal(ptr.Pointer(), "drawEvent", unsafe.Pointer(&f)) + } + } +} + +func (ptr *GardenAPI) DisconnectDrawEvent() { + if ptr.Pointer() != nil { + C.GardenAPIaf70b6_DisconnectDrawEvent(ptr.Pointer()) + qt.DisconnectSignal(ptr.Pointer(), "drawEvent") + } +} + +func (ptr *GardenAPI) DrawEvent(x int, y int) { + if ptr.Pointer() != nil { + C.GardenAPIaf70b6_DrawEvent(ptr.Pointer(), C.int(int32(x)), C.int(int32(y))) + } +} + +//export callbackGardenAPIaf70b6_NewDrawEvent +func callbackGardenAPIaf70b6_NewDrawEvent(ptr unsafe.Pointer, x C.int, y C.int) { + if signal := qt.GetSignal(ptr, "newDrawEvent"); signal != nil { + (*(*func(int, int))(signal))(int(int32(x)), int(int32(y))) + } + +} + +func (ptr *GardenAPI) ConnectNewDrawEvent(f func(x int, y int)) { + if ptr.Pointer() != nil { + + if !qt.ExistsSignal(ptr.Pointer(), "newDrawEvent") { + C.GardenAPIaf70b6_ConnectNewDrawEvent(ptr.Pointer(), C.longlong(qt.ConnectionType(ptr.Pointer(), "newDrawEvent"))) + } + + if signal := qt.LendSignal(ptr.Pointer(), "newDrawEvent"); signal != nil { + f := func(x int, y int) { + (*(*func(int, int))(signal))(x, y) + f(x, y) + } + qt.ConnectSignal(ptr.Pointer(), "newDrawEvent", unsafe.Pointer(&f)) + } else { + qt.ConnectSignal(ptr.Pointer(), "newDrawEvent", unsafe.Pointer(&f)) + } + } +} + +func (ptr *GardenAPI) DisconnectNewDrawEvent() { + if ptr.Pointer() != nil { + C.GardenAPIaf70b6_DisconnectNewDrawEvent(ptr.Pointer()) + qt.DisconnectSignal(ptr.Pointer(), "newDrawEvent") + } +} + +func (ptr *GardenAPI) NewDrawEvent(x int, y int) { + if ptr.Pointer() != nil { + C.GardenAPIaf70b6_NewDrawEvent(ptr.Pointer(), C.int(int32(x)), C.int(int32(y))) + } +} + +func GardenAPI_QRegisterMetaType() int { + return int(int32(C.GardenAPIaf70b6_GardenAPIaf70b6_QRegisterMetaType())) +} + +func (ptr *GardenAPI) QRegisterMetaType() int { + return int(int32(C.GardenAPIaf70b6_GardenAPIaf70b6_QRegisterMetaType())) +} + +func GardenAPI_QRegisterMetaType2(typeName string) int { + var typeNameC *C.char + if typeName != "" { + typeNameC = C.CString(typeName) + defer C.free(unsafe.Pointer(typeNameC)) + } + return int(int32(C.GardenAPIaf70b6_GardenAPIaf70b6_QRegisterMetaType2(typeNameC))) +} + +func (ptr *GardenAPI) QRegisterMetaType2(typeName string) int { + var typeNameC *C.char + if typeName != "" { + typeNameC = C.CString(typeName) + defer C.free(unsafe.Pointer(typeNameC)) + } + return int(int32(C.GardenAPIaf70b6_GardenAPIaf70b6_QRegisterMetaType2(typeNameC))) +} + +func GardenAPI_QmlRegisterType() int { + return int(int32(C.GardenAPIaf70b6_GardenAPIaf70b6_QmlRegisterType())) +} + +func (ptr *GardenAPI) QmlRegisterType() int { + return int(int32(C.GardenAPIaf70b6_GardenAPIaf70b6_QmlRegisterType())) +} + +func GardenAPI_QmlRegisterType2(uri string, versionMajor int, versionMinor int, qmlName string) int { + var uriC *C.char + if uri != "" { + uriC = C.CString(uri) + defer C.free(unsafe.Pointer(uriC)) + } + var qmlNameC *C.char + if qmlName != "" { + qmlNameC = C.CString(qmlName) + defer C.free(unsafe.Pointer(qmlNameC)) + } + return int(int32(C.GardenAPIaf70b6_GardenAPIaf70b6_QmlRegisterType2(uriC, C.int(int32(versionMajor)), C.int(int32(versionMinor)), qmlNameC))) +} + +func (ptr *GardenAPI) QmlRegisterType2(uri string, versionMajor int, versionMinor int, qmlName string) int { + var uriC *C.char + if uri != "" { + uriC = C.CString(uri) + defer C.free(unsafe.Pointer(uriC)) + } + var qmlNameC *C.char + if qmlName != "" { + qmlNameC = C.CString(qmlName) + defer C.free(unsafe.Pointer(qmlNameC)) + } + return int(int32(C.GardenAPIaf70b6_GardenAPIaf70b6_QmlRegisterType2(uriC, C.int(int32(versionMajor)), C.int(int32(versionMinor)), qmlNameC))) +} + +func (ptr *GardenAPI) __children_atList(i int) *std_core.QObject { + if ptr.Pointer() != nil { + tmpValue := std_core.NewQObjectFromPointer(C.GardenAPIaf70b6___children_atList(ptr.Pointer(), C.int(int32(i)))) + if !qt.ExistsSignal(tmpValue.Pointer(), "destroyed") { + tmpValue.ConnectDestroyed(func(*std_core.QObject) { tmpValue.SetPointer(nil) }) + } + return tmpValue + } + return nil +} + +func (ptr *GardenAPI) __children_setList(i std_core.QObject_ITF) { + if ptr.Pointer() != nil { + C.GardenAPIaf70b6___children_setList(ptr.Pointer(), std_core.PointerFromQObject(i)) + } +} + +func (ptr *GardenAPI) __children_newList() unsafe.Pointer { + return C.GardenAPIaf70b6___children_newList(ptr.Pointer()) +} + +func (ptr *GardenAPI) __dynamicPropertyNames_atList(i int) *std_core.QByteArray { + if ptr.Pointer() != nil { + tmpValue := std_core.NewQByteArrayFromPointer(C.GardenAPIaf70b6___dynamicPropertyNames_atList(ptr.Pointer(), C.int(int32(i)))) + runtime.SetFinalizer(tmpValue, (*std_core.QByteArray).DestroyQByteArray) + return tmpValue + } + return nil +} + +func (ptr *GardenAPI) __dynamicPropertyNames_setList(i std_core.QByteArray_ITF) { + if ptr.Pointer() != nil { + C.GardenAPIaf70b6___dynamicPropertyNames_setList(ptr.Pointer(), std_core.PointerFromQByteArray(i)) + } +} + +func (ptr *GardenAPI) __dynamicPropertyNames_newList() unsafe.Pointer { + return C.GardenAPIaf70b6___dynamicPropertyNames_newList(ptr.Pointer()) +} + +func (ptr *GardenAPI) __findChildren_atList(i int) *std_core.QObject { + if ptr.Pointer() != nil { + tmpValue := std_core.NewQObjectFromPointer(C.GardenAPIaf70b6___findChildren_atList(ptr.Pointer(), C.int(int32(i)))) + if !qt.ExistsSignal(tmpValue.Pointer(), "destroyed") { + tmpValue.ConnectDestroyed(func(*std_core.QObject) { tmpValue.SetPointer(nil) }) + } + return tmpValue + } + return nil +} + +func (ptr *GardenAPI) __findChildren_setList(i std_core.QObject_ITF) { + if ptr.Pointer() != nil { + C.GardenAPIaf70b6___findChildren_setList(ptr.Pointer(), std_core.PointerFromQObject(i)) + } +} + +func (ptr *GardenAPI) __findChildren_newList() unsafe.Pointer { + return C.GardenAPIaf70b6___findChildren_newList(ptr.Pointer()) +} + +func (ptr *GardenAPI) __findChildren_atList3(i int) *std_core.QObject { + if ptr.Pointer() != nil { + tmpValue := std_core.NewQObjectFromPointer(C.GardenAPIaf70b6___findChildren_atList3(ptr.Pointer(), C.int(int32(i)))) + if !qt.ExistsSignal(tmpValue.Pointer(), "destroyed") { + tmpValue.ConnectDestroyed(func(*std_core.QObject) { tmpValue.SetPointer(nil) }) + } + return tmpValue + } + return nil +} + +func (ptr *GardenAPI) __findChildren_setList3(i std_core.QObject_ITF) { + if ptr.Pointer() != nil { + C.GardenAPIaf70b6___findChildren_setList3(ptr.Pointer(), std_core.PointerFromQObject(i)) + } +} + +func (ptr *GardenAPI) __findChildren_newList3() unsafe.Pointer { + return C.GardenAPIaf70b6___findChildren_newList3(ptr.Pointer()) +} + +func (ptr *GardenAPI) __qFindChildren_atList2(i int) *std_core.QObject { + if ptr.Pointer() != nil { + tmpValue := std_core.NewQObjectFromPointer(C.GardenAPIaf70b6___qFindChildren_atList2(ptr.Pointer(), C.int(int32(i)))) + if !qt.ExistsSignal(tmpValue.Pointer(), "destroyed") { + tmpValue.ConnectDestroyed(func(*std_core.QObject) { tmpValue.SetPointer(nil) }) + } + return tmpValue + } + return nil +} + +func (ptr *GardenAPI) __qFindChildren_setList2(i std_core.QObject_ITF) { + if ptr.Pointer() != nil { + C.GardenAPIaf70b6___qFindChildren_setList2(ptr.Pointer(), std_core.PointerFromQObject(i)) + } +} + +func (ptr *GardenAPI) __qFindChildren_newList2() unsafe.Pointer { + return C.GardenAPIaf70b6___qFindChildren_newList2(ptr.Pointer()) +} + +func NewGardenAPI(parent std_core.QObject_ITF) *GardenAPI { + GardenAPI_QRegisterMetaType() + tmpValue := NewGardenAPIFromPointer(C.GardenAPIaf70b6_NewGardenAPI(std_core.PointerFromQObject(parent))) + if !qt.ExistsSignal(tmpValue.Pointer(), "destroyed") { + tmpValue.ConnectDestroyed(func(*std_core.QObject) { tmpValue.SetPointer(nil) }) + } + return tmpValue +} + +//export callbackGardenAPIaf70b6_DestroyGardenAPI +func callbackGardenAPIaf70b6_DestroyGardenAPI(ptr unsafe.Pointer) { + if signal := qt.GetSignal(ptr, "~GardenAPI"); signal != nil { + (*(*func())(signal))() + } else { + NewGardenAPIFromPointer(ptr).DestroyGardenAPIDefault() + } +} + +func (ptr *GardenAPI) ConnectDestroyGardenAPI(f func()) { + if ptr.Pointer() != nil { + + if signal := qt.LendSignal(ptr.Pointer(), "~GardenAPI"); signal != nil { + f := func() { + (*(*func())(signal))() + f() + } + qt.ConnectSignal(ptr.Pointer(), "~GardenAPI", unsafe.Pointer(&f)) + } else { + qt.ConnectSignal(ptr.Pointer(), "~GardenAPI", unsafe.Pointer(&f)) + } + } +} + +func (ptr *GardenAPI) DisconnectDestroyGardenAPI() { + if ptr.Pointer() != nil { + + qt.DisconnectSignal(ptr.Pointer(), "~GardenAPI") + } +} + +func (ptr *GardenAPI) DestroyGardenAPI() { + if ptr.Pointer() != nil { + C.GardenAPIaf70b6_DestroyGardenAPI(ptr.Pointer()) + ptr.SetPointer(nil) + runtime.SetFinalizer(ptr, nil) + } +} + +func (ptr *GardenAPI) DestroyGardenAPIDefault() { + if ptr.Pointer() != nil { + C.GardenAPIaf70b6_DestroyGardenAPIDefault(ptr.Pointer()) + ptr.SetPointer(nil) + runtime.SetFinalizer(ptr, nil) + } +} + +//export callbackGardenAPIaf70b6_ChildEvent +func callbackGardenAPIaf70b6_ChildEvent(ptr unsafe.Pointer, event unsafe.Pointer) { + if signal := qt.GetSignal(ptr, "childEvent"); signal != nil { + (*(*func(*std_core.QChildEvent))(signal))(std_core.NewQChildEventFromPointer(event)) + } else { + NewGardenAPIFromPointer(ptr).ChildEventDefault(std_core.NewQChildEventFromPointer(event)) + } +} + +func (ptr *GardenAPI) ChildEventDefault(event std_core.QChildEvent_ITF) { + if ptr.Pointer() != nil { + C.GardenAPIaf70b6_ChildEventDefault(ptr.Pointer(), std_core.PointerFromQChildEvent(event)) + } +} + +//export callbackGardenAPIaf70b6_ConnectNotify +func callbackGardenAPIaf70b6_ConnectNotify(ptr unsafe.Pointer, sign unsafe.Pointer) { + if signal := qt.GetSignal(ptr, "connectNotify"); signal != nil { + (*(*func(*std_core.QMetaMethod))(signal))(std_core.NewQMetaMethodFromPointer(sign)) + } else { + NewGardenAPIFromPointer(ptr).ConnectNotifyDefault(std_core.NewQMetaMethodFromPointer(sign)) + } +} + +func (ptr *GardenAPI) ConnectNotifyDefault(sign std_core.QMetaMethod_ITF) { + if ptr.Pointer() != nil { + C.GardenAPIaf70b6_ConnectNotifyDefault(ptr.Pointer(), std_core.PointerFromQMetaMethod(sign)) + } +} + +//export callbackGardenAPIaf70b6_CustomEvent +func callbackGardenAPIaf70b6_CustomEvent(ptr unsafe.Pointer, event unsafe.Pointer) { + if signal := qt.GetSignal(ptr, "customEvent"); signal != nil { + (*(*func(*std_core.QEvent))(signal))(std_core.NewQEventFromPointer(event)) + } else { + NewGardenAPIFromPointer(ptr).CustomEventDefault(std_core.NewQEventFromPointer(event)) + } +} + +func (ptr *GardenAPI) CustomEventDefault(event std_core.QEvent_ITF) { + if ptr.Pointer() != nil { + C.GardenAPIaf70b6_CustomEventDefault(ptr.Pointer(), std_core.PointerFromQEvent(event)) + } +} + +//export callbackGardenAPIaf70b6_DeleteLater +func callbackGardenAPIaf70b6_DeleteLater(ptr unsafe.Pointer) { + if signal := qt.GetSignal(ptr, "deleteLater"); signal != nil { + (*(*func())(signal))() + } else { + NewGardenAPIFromPointer(ptr).DeleteLaterDefault() + } +} + +func (ptr *GardenAPI) DeleteLaterDefault() { + if ptr.Pointer() != nil { + C.GardenAPIaf70b6_DeleteLaterDefault(ptr.Pointer()) + runtime.SetFinalizer(ptr, nil) + } +} + +//export callbackGardenAPIaf70b6_Destroyed +func callbackGardenAPIaf70b6_Destroyed(ptr unsafe.Pointer, obj unsafe.Pointer) { + if signal := qt.GetSignal(ptr, "destroyed"); signal != nil { + (*(*func(*std_core.QObject))(signal))(std_core.NewQObjectFromPointer(obj)) + } + qt.Unregister(ptr) + +} + +//export callbackGardenAPIaf70b6_DisconnectNotify +func callbackGardenAPIaf70b6_DisconnectNotify(ptr unsafe.Pointer, sign unsafe.Pointer) { + if signal := qt.GetSignal(ptr, "disconnectNotify"); signal != nil { + (*(*func(*std_core.QMetaMethod))(signal))(std_core.NewQMetaMethodFromPointer(sign)) + } else { + NewGardenAPIFromPointer(ptr).DisconnectNotifyDefault(std_core.NewQMetaMethodFromPointer(sign)) + } +} + +func (ptr *GardenAPI) DisconnectNotifyDefault(sign std_core.QMetaMethod_ITF) { + if ptr.Pointer() != nil { + C.GardenAPIaf70b6_DisconnectNotifyDefault(ptr.Pointer(), std_core.PointerFromQMetaMethod(sign)) + } +} + +//export callbackGardenAPIaf70b6_Event +func callbackGardenAPIaf70b6_Event(ptr unsafe.Pointer, e unsafe.Pointer) C.char { + if signal := qt.GetSignal(ptr, "event"); signal != nil { + return C.char(int8(qt.GoBoolToInt((*(*func(*std_core.QEvent) bool)(signal))(std_core.NewQEventFromPointer(e))))) + } + + return C.char(int8(qt.GoBoolToInt(NewGardenAPIFromPointer(ptr).EventDefault(std_core.NewQEventFromPointer(e))))) +} + +func (ptr *GardenAPI) EventDefault(e std_core.QEvent_ITF) bool { + if ptr.Pointer() != nil { + return int8(C.GardenAPIaf70b6_EventDefault(ptr.Pointer(), std_core.PointerFromQEvent(e))) != 0 + } + return false +} + +//export callbackGardenAPIaf70b6_EventFilter +func callbackGardenAPIaf70b6_EventFilter(ptr unsafe.Pointer, watched unsafe.Pointer, event unsafe.Pointer) C.char { + if signal := qt.GetSignal(ptr, "eventFilter"); signal != nil { + return C.char(int8(qt.GoBoolToInt((*(*func(*std_core.QObject, *std_core.QEvent) bool)(signal))(std_core.NewQObjectFromPointer(watched), std_core.NewQEventFromPointer(event))))) + } + + return C.char(int8(qt.GoBoolToInt(NewGardenAPIFromPointer(ptr).EventFilterDefault(std_core.NewQObjectFromPointer(watched), std_core.NewQEventFromPointer(event))))) +} + +func (ptr *GardenAPI) EventFilterDefault(watched std_core.QObject_ITF, event std_core.QEvent_ITF) bool { + if ptr.Pointer() != nil { + return int8(C.GardenAPIaf70b6_EventFilterDefault(ptr.Pointer(), std_core.PointerFromQObject(watched), std_core.PointerFromQEvent(event))) != 0 + } + return false +} + +//export callbackGardenAPIaf70b6_ObjectNameChanged +func callbackGardenAPIaf70b6_ObjectNameChanged(ptr unsafe.Pointer, objectName C.struct_Moc_PackedString) { + if signal := qt.GetSignal(ptr, "objectNameChanged"); signal != nil { + (*(*func(string))(signal))(cGoUnpackString(objectName)) + } + +} + +//export callbackGardenAPIaf70b6_TimerEvent +func callbackGardenAPIaf70b6_TimerEvent(ptr unsafe.Pointer, event unsafe.Pointer) { + if signal := qt.GetSignal(ptr, "timerEvent"); signal != nil { + (*(*func(*std_core.QTimerEvent))(signal))(std_core.NewQTimerEventFromPointer(event)) + } else { + NewGardenAPIFromPointer(ptr).TimerEventDefault(std_core.NewQTimerEventFromPointer(event)) + } +} + +func (ptr *GardenAPI) TimerEventDefault(event std_core.QTimerEvent_ITF) { + if ptr.Pointer() != nil { + C.GardenAPIaf70b6_TimerEventDefault(ptr.Pointer(), std_core.PointerFromQTimerEvent(event)) + } +}