2015-10-24 18:18:24 +03:00
|
|
|
package dbus
|
|
|
|
|
2015-12-06 02:56:16 +03:00
|
|
|
//#include "dbus.h"
|
2015-10-24 18:18:24 +03:00
|
|
|
import "C"
|
|
|
|
import (
|
|
|
|
"github.com/therecipe/qt"
|
2015-12-06 02:56:16 +03:00
|
|
|
"log"
|
2015-10-24 18:18:24 +03:00
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
|
|
|
type QDBusContext struct {
|
|
|
|
ptr unsafe.Pointer
|
|
|
|
}
|
|
|
|
|
2015-11-09 20:23:42 +03:00
|
|
|
type QDBusContext_ITF interface {
|
|
|
|
QDBusContext_PTR() *QDBusContext
|
2015-10-24 18:18:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *QDBusContext) Pointer() unsafe.Pointer {
|
|
|
|
return p.ptr
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *QDBusContext) SetPointer(ptr unsafe.Pointer) {
|
|
|
|
p.ptr = ptr
|
|
|
|
}
|
|
|
|
|
2015-11-09 20:23:42 +03:00
|
|
|
func PointerFromQDBusContext(ptr QDBusContext_ITF) unsafe.Pointer {
|
2015-10-24 18:18:24 +03:00
|
|
|
if ptr != nil {
|
2015-11-09 20:23:42 +03:00
|
|
|
return ptr.QDBusContext_PTR().Pointer()
|
2015-10-24 18:18:24 +03:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-11-09 20:23:42 +03:00
|
|
|
func NewQDBusContextFromPointer(ptr unsafe.Pointer) *QDBusContext {
|
2015-10-24 18:18:24 +03:00
|
|
|
var n = new(QDBusContext)
|
|
|
|
n.SetPointer(ptr)
|
|
|
|
return n
|
|
|
|
}
|
|
|
|
|
2015-11-09 20:23:42 +03:00
|
|
|
func (ptr *QDBusContext) QDBusContext_PTR() *QDBusContext {
|
2015-10-24 18:18:24 +03:00
|
|
|
return ptr
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewQDBusContext() *QDBusContext {
|
2015-12-06 02:56:16 +03:00
|
|
|
defer func() {
|
|
|
|
if recover() != nil {
|
|
|
|
log.Println("recovered in QDBusContext::QDBusContext")
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
2015-11-09 20:23:42 +03:00
|
|
|
return NewQDBusContextFromPointer(C.QDBusContext_NewQDBusContext())
|
2015-10-24 18:18:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func (ptr *QDBusContext) CalledFromDBus() bool {
|
2015-12-06 02:56:16 +03:00
|
|
|
defer func() {
|
|
|
|
if recover() != nil {
|
|
|
|
log.Println("recovered in QDBusContext::calledFromDBus")
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
2015-10-24 18:18:24 +03:00
|
|
|
if ptr.Pointer() != nil {
|
2015-11-09 20:23:42 +03:00
|
|
|
return C.QDBusContext_CalledFromDBus(ptr.Pointer()) != 0
|
2015-10-24 18:18:24 +03:00
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ptr *QDBusContext) IsDelayedReply() bool {
|
2015-12-06 02:56:16 +03:00
|
|
|
defer func() {
|
|
|
|
if recover() != nil {
|
|
|
|
log.Println("recovered in QDBusContext::isDelayedReply")
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
2015-10-24 18:18:24 +03:00
|
|
|
if ptr.Pointer() != nil {
|
2015-11-09 20:23:42 +03:00
|
|
|
return C.QDBusContext_IsDelayedReply(ptr.Pointer()) != 0
|
2015-10-24 18:18:24 +03:00
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ptr *QDBusContext) SendErrorReply2(ty QDBusError__ErrorType, msg string) {
|
2015-12-06 02:56:16 +03:00
|
|
|
defer func() {
|
|
|
|
if recover() != nil {
|
|
|
|
log.Println("recovered in QDBusContext::sendErrorReply")
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
2015-10-24 18:18:24 +03:00
|
|
|
if ptr.Pointer() != nil {
|
2015-11-09 20:23:42 +03:00
|
|
|
C.QDBusContext_SendErrorReply2(ptr.Pointer(), C.int(ty), C.CString(msg))
|
2015-10-24 18:18:24 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ptr *QDBusContext) SendErrorReply(name string, msg string) {
|
2015-12-06 02:56:16 +03:00
|
|
|
defer func() {
|
|
|
|
if recover() != nil {
|
|
|
|
log.Println("recovered in QDBusContext::sendErrorReply")
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
2015-10-24 18:18:24 +03:00
|
|
|
if ptr.Pointer() != nil {
|
2015-11-09 20:23:42 +03:00
|
|
|
C.QDBusContext_SendErrorReply(ptr.Pointer(), C.CString(name), C.CString(msg))
|
2015-10-24 18:18:24 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ptr *QDBusContext) SetDelayedReply(enable bool) {
|
2015-12-06 02:56:16 +03:00
|
|
|
defer func() {
|
|
|
|
if recover() != nil {
|
|
|
|
log.Println("recovered in QDBusContext::setDelayedReply")
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
2015-10-24 18:18:24 +03:00
|
|
|
if ptr.Pointer() != nil {
|
2015-11-09 20:23:42 +03:00
|
|
|
C.QDBusContext_SetDelayedReply(ptr.Pointer(), C.int(qt.GoBoolToInt(enable)))
|
2015-10-24 18:18:24 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ptr *QDBusContext) DestroyQDBusContext() {
|
2015-12-06 02:56:16 +03:00
|
|
|
defer func() {
|
|
|
|
if recover() != nil {
|
|
|
|
log.Println("recovered in QDBusContext::~QDBusContext")
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
2015-10-24 18:18:24 +03:00
|
|
|
if ptr.Pointer() != nil {
|
2015-11-09 20:23:42 +03:00
|
|
|
C.QDBusContext_DestroyQDBusContext(ptr.Pointer())
|
2015-10-24 18:18:24 +03:00
|
|
|
}
|
|
|
|
}
|