/*This file is automatically generated by pkg.deepin.io/dbus-generator. Don't edit it*/
package modemmanager1

import "pkg.deepin.io/lib/dbus"
import "pkg.deepin.io/lib/dbus/property"
import "reflect"
import "sync"
import "runtime"
import "fmt"
import "errors"

/*prevent compile error*/
var _ = fmt.Println
var _ = runtime.SetFinalizer
var _ = sync.NewCond
var _ = reflect.TypeOf
var _ = property.BaseObserver{}

type Sms struct {
	Path     dbus.ObjectPath
	DestName string
	core     *dbus.Object

	signals       map[<-chan *dbus.Signal]struct{}
	signalsLocker sync.Mutex

	State                 *dbusPropertySmsState
	PduType               *dbusPropertySmsPduType
	Number                *dbusPropertySmsNumber
	Text                  *dbusPropertySmsText
	Data                  *dbusPropertySmsData
	SMSC                  *dbusPropertySmsSMSC
	Validity              *dbusPropertySmsValidity
	Class                 *dbusPropertySmsClass
	TeleserviceId         *dbusPropertySmsTeleserviceId
	ServiceCategory       *dbusPropertySmsServiceCategory
	DeliveryReportRequest *dbusPropertySmsDeliveryReportRequest
	MessageReference      *dbusPropertySmsMessageReference
	Timestamp             *dbusPropertySmsTimestamp
	DischargeTimestamp    *dbusPropertySmsDischargeTimestamp
	DeliveryState         *dbusPropertySmsDeliveryState
	Storage               *dbusPropertySmsStorage
}

func (obj *Sms) _createSignalChan() <-chan *dbus.Signal {
	obj.signalsLocker.Lock()
	ch := getBus().Signal()
	obj.signals[ch] = struct{}{}
	obj.signalsLocker.Unlock()
	return ch
}
func (obj *Sms) _deleteSignalChan(ch <-chan *dbus.Signal) {
	obj.signalsLocker.Lock()
	delete(obj.signals, ch)
	getBus().DetachSignal(ch)
	obj.signalsLocker.Unlock()
}
func DestroySms(obj *Sms) {
	obj.signalsLocker.Lock()
	defer obj.signalsLocker.Unlock()
	if obj.signals == nil {
		return
	}
	for ch, _ := range obj.signals {
		getBus().DetachSignal(ch)
	}
	obj.signals = nil

	runtime.SetFinalizer(obj, nil)

	dbusRemoveMatch("type='signal',path='" + string(obj.Path) + "',interface='org.freedesktop.DBus.Properties',sender='" + obj.DestName + "',member='PropertiesChanged'")
	dbusRemoveMatch("type='signal',path='" + string(obj.Path) + "',interface='org.freedesktop.ModemManager1.Sms',sender='" + obj.DestName + "',member='PropertiesChanged'")

	obj.State.Reset()
	obj.PduType.Reset()
	obj.Number.Reset()
	obj.Text.Reset()
	obj.Data.Reset()
	obj.SMSC.Reset()
	obj.Validity.Reset()
	obj.Class.Reset()
	obj.TeleserviceId.Reset()
	obj.ServiceCategory.Reset()
	obj.DeliveryReportRequest.Reset()
	obj.MessageReference.Reset()
	obj.Timestamp.Reset()
	obj.DischargeTimestamp.Reset()
	obj.DeliveryState.Reset()
	obj.Storage.Reset()
}

func (obj *Sms) Send() (_err error) {
	_err = obj.core.Call("org.freedesktop.ModemManager1.Sms.Send", 0).Store()
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *Sms) Store(storage uint32) (_err error) {
	_err = obj.core.Call("org.freedesktop.ModemManager1.Sms.Store", 0, storage).Store()
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

type dbusPropertySmsState struct {
	*property.BaseObserver
	core *dbus.Object
}

func (this *dbusPropertySmsState) SetValue(notwritable interface{}) {
	fmt.Println("org.freedesktop.ModemManager1.Sms.State is not writable")
}

func (this *dbusPropertySmsState) Get() uint32 {
	v, _ := this.GetValue()
	return v.(uint32)
}
func (this *dbusPropertySmsState) GetValue() (interface{} /*uint32*/, error) {
	var r dbus.Variant
	err := this.core.Call("org.freedesktop.DBus.Properties.Get", 0, "org.freedesktop.ModemManager1.Sms", "State").Store(&r)
	if err == nil && r.Signature().String() == "u" {
		return r.Value().(uint32), nil
	}
	return *new(uint32), err
}
func (this *dbusPropertySmsState) GetType() reflect.Type {
	return reflect.TypeOf((*uint32)(nil)).Elem()
}

type dbusPropertySmsPduType struct {
	*property.BaseObserver
	core *dbus.Object
}

func (this *dbusPropertySmsPduType) SetValue(notwritable interface{}) {
	fmt.Println("org.freedesktop.ModemManager1.Sms.PduType is not writable")
}

func (this *dbusPropertySmsPduType) Get() uint32 {
	v, _ := this.GetValue()
	return v.(uint32)
}
func (this *dbusPropertySmsPduType) GetValue() (interface{} /*uint32*/, error) {
	var r dbus.Variant
	err := this.core.Call("org.freedesktop.DBus.Properties.Get", 0, "org.freedesktop.ModemManager1.Sms", "PduType").Store(&r)
	if err == nil && r.Signature().String() == "u" {
		return r.Value().(uint32), nil
	}
	return *new(uint32), err
}
func (this *dbusPropertySmsPduType) GetType() reflect.Type {
	return reflect.TypeOf((*uint32)(nil)).Elem()
}

type dbusPropertySmsNumber struct {
	*property.BaseObserver
	core *dbus.Object
}

func (this *dbusPropertySmsNumber) SetValue(notwritable interface{}) {
	fmt.Println("org.freedesktop.ModemManager1.Sms.Number is not writable")
}

func (this *dbusPropertySmsNumber) Get() string {
	v, _ := this.GetValue()
	return v.(string)
}
func (this *dbusPropertySmsNumber) GetValue() (interface{} /*string*/, error) {
	var r dbus.Variant
	err := this.core.Call("org.freedesktop.DBus.Properties.Get", 0, "org.freedesktop.ModemManager1.Sms", "Number").Store(&r)
	if err == nil && r.Signature().String() == "s" {
		return r.Value().(string), nil
	}
	return *new(string), err
}
func (this *dbusPropertySmsNumber) GetType() reflect.Type {
	return reflect.TypeOf((*string)(nil)).Elem()
}

type dbusPropertySmsText struct {
	*property.BaseObserver
	core *dbus.Object
}

func (this *dbusPropertySmsText) SetValue(notwritable interface{}) {
	fmt.Println("org.freedesktop.ModemManager1.Sms.Text is not writable")
}

func (this *dbusPropertySmsText) Get() string {
	v, _ := this.GetValue()
	return v.(string)
}
func (this *dbusPropertySmsText) GetValue() (interface{} /*string*/, error) {
	var r dbus.Variant
	err := this.core.Call("org.freedesktop.DBus.Properties.Get", 0, "org.freedesktop.ModemManager1.Sms", "Text").Store(&r)
	if err == nil && r.Signature().String() == "s" {
		return r.Value().(string), nil
	}
	return *new(string), err
}
func (this *dbusPropertySmsText) GetType() reflect.Type {
	return reflect.TypeOf((*string)(nil)).Elem()
}

type dbusPropertySmsData struct {
	*property.BaseObserver
	core *dbus.Object
}

func (this *dbusPropertySmsData) SetValue(notwritable interface{}) {
	fmt.Println("org.freedesktop.ModemManager1.Sms.Data is not writable")
}

func (this *dbusPropertySmsData) Get() []uint8 {
	v, _ := this.GetValue()
	return v.([]uint8)
}
func (this *dbusPropertySmsData) GetValue() (interface{} /*[]uint8*/, error) {
	var r dbus.Variant
	err := this.core.Call("org.freedesktop.DBus.Properties.Get", 0, "org.freedesktop.ModemManager1.Sms", "Data").Store(&r)
	if err == nil && r.Signature().String() == "ay" {
		return r.Value().([]uint8), nil
	}
	return *new([]uint8), err
}
func (this *dbusPropertySmsData) GetType() reflect.Type {
	return reflect.TypeOf((*[]uint8)(nil)).Elem()
}

type dbusPropertySmsSMSC struct {
	*property.BaseObserver
	core *dbus.Object
}

func (this *dbusPropertySmsSMSC) SetValue(notwritable interface{}) {
	fmt.Println("org.freedesktop.ModemManager1.Sms.SMSC is not writable")
}

func (this *dbusPropertySmsSMSC) Get() string {
	v, _ := this.GetValue()
	return v.(string)
}
func (this *dbusPropertySmsSMSC) GetValue() (interface{} /*string*/, error) {
	var r dbus.Variant
	err := this.core.Call("org.freedesktop.DBus.Properties.Get", 0, "org.freedesktop.ModemManager1.Sms", "SMSC").Store(&r)
	if err == nil && r.Signature().String() == "s" {
		return r.Value().(string), nil
	}
	return *new(string), err
}
func (this *dbusPropertySmsSMSC) GetType() reflect.Type {
	return reflect.TypeOf((*string)(nil)).Elem()
}

type dbusPropertySmsValidity struct {
	*property.BaseObserver
	core *dbus.Object
}

func (this *dbusPropertySmsValidity) SetValue(notwritable interface{}) {
	fmt.Println("org.freedesktop.ModemManager1.Sms.Validity is not writable")
}

func (this *dbusPropertySmsValidity) Get() []interface{} {
	v, _ := this.GetValue()
	return v.([]interface{})
}
func (this *dbusPropertySmsValidity) GetValue() (interface{} /*[]interface {}*/, error) {
	var r dbus.Variant
	err := this.core.Call("org.freedesktop.DBus.Properties.Get", 0, "org.freedesktop.ModemManager1.Sms", "Validity").Store(&r)
	if err == nil && r.Signature().String() == "(uv)" {
		return r.Value().([]interface{}), nil
	}
	return *new([]interface{}), err
}
func (this *dbusPropertySmsValidity) GetType() reflect.Type {
	return reflect.TypeOf((*[]interface{})(nil)).Elem()
}

type dbusPropertySmsClass struct {
	*property.BaseObserver
	core *dbus.Object
}

func (this *dbusPropertySmsClass) SetValue(notwritable interface{}) {
	fmt.Println("org.freedesktop.ModemManager1.Sms.Class is not writable")
}

func (this *dbusPropertySmsClass) Get() int32 {
	v, _ := this.GetValue()
	return v.(int32)
}
func (this *dbusPropertySmsClass) GetValue() (interface{} /*int32*/, error) {
	var r dbus.Variant
	err := this.core.Call("org.freedesktop.DBus.Properties.Get", 0, "org.freedesktop.ModemManager1.Sms", "Class").Store(&r)
	if err == nil && r.Signature().String() == "i" {
		return r.Value().(int32), nil
	}
	return *new(int32), err
}
func (this *dbusPropertySmsClass) GetType() reflect.Type {
	return reflect.TypeOf((*int32)(nil)).Elem()
}

type dbusPropertySmsTeleserviceId struct {
	*property.BaseObserver
	core *dbus.Object
}

func (this *dbusPropertySmsTeleserviceId) SetValue(notwritable interface{}) {
	fmt.Println("org.freedesktop.ModemManager1.Sms.TeleserviceId is not writable")
}

func (this *dbusPropertySmsTeleserviceId) Get() uint32 {
	v, _ := this.GetValue()
	return v.(uint32)
}
func (this *dbusPropertySmsTeleserviceId) GetValue() (interface{} /*uint32*/, error) {
	var r dbus.Variant
	err := this.core.Call("org.freedesktop.DBus.Properties.Get", 0, "org.freedesktop.ModemManager1.Sms", "TeleserviceId").Store(&r)
	if err == nil && r.Signature().String() == "u" {
		return r.Value().(uint32), nil
	}
	return *new(uint32), err
}
func (this *dbusPropertySmsTeleserviceId) GetType() reflect.Type {
	return reflect.TypeOf((*uint32)(nil)).Elem()
}

type dbusPropertySmsServiceCategory struct {
	*property.BaseObserver
	core *dbus.Object
}

func (this *dbusPropertySmsServiceCategory) SetValue(notwritable interface{}) {
	fmt.Println("org.freedesktop.ModemManager1.Sms.ServiceCategory is not writable")
}

func (this *dbusPropertySmsServiceCategory) Get() uint32 {
	v, _ := this.GetValue()
	return v.(uint32)
}
func (this *dbusPropertySmsServiceCategory) GetValue() (interface{} /*uint32*/, error) {
	var r dbus.Variant
	err := this.core.Call("org.freedesktop.DBus.Properties.Get", 0, "org.freedesktop.ModemManager1.Sms", "ServiceCategory").Store(&r)
	if err == nil && r.Signature().String() == "u" {
		return r.Value().(uint32), nil
	}
	return *new(uint32), err
}
func (this *dbusPropertySmsServiceCategory) GetType() reflect.Type {
	return reflect.TypeOf((*uint32)(nil)).Elem()
}

type dbusPropertySmsDeliveryReportRequest struct {
	*property.BaseObserver
	core *dbus.Object
}

func (this *dbusPropertySmsDeliveryReportRequest) SetValue(notwritable interface{}) {
	fmt.Println("org.freedesktop.ModemManager1.Sms.DeliveryReportRequest is not writable")
}

func (this *dbusPropertySmsDeliveryReportRequest) Get() bool {
	v, _ := this.GetValue()
	return v.(bool)
}
func (this *dbusPropertySmsDeliveryReportRequest) GetValue() (interface{} /*bool*/, error) {
	var r dbus.Variant
	err := this.core.Call("org.freedesktop.DBus.Properties.Get", 0, "org.freedesktop.ModemManager1.Sms", "DeliveryReportRequest").Store(&r)
	if err == nil && r.Signature().String() == "b" {
		return r.Value().(bool), nil
	}
	return *new(bool), err
}
func (this *dbusPropertySmsDeliveryReportRequest) GetType() reflect.Type {
	return reflect.TypeOf((*bool)(nil)).Elem()
}

type dbusPropertySmsMessageReference struct {
	*property.BaseObserver
	core *dbus.Object
}

func (this *dbusPropertySmsMessageReference) SetValue(notwritable interface{}) {
	fmt.Println("org.freedesktop.ModemManager1.Sms.MessageReference is not writable")
}

func (this *dbusPropertySmsMessageReference) Get() uint32 {
	v, _ := this.GetValue()
	return v.(uint32)
}
func (this *dbusPropertySmsMessageReference) GetValue() (interface{} /*uint32*/, error) {
	var r dbus.Variant
	err := this.core.Call("org.freedesktop.DBus.Properties.Get", 0, "org.freedesktop.ModemManager1.Sms", "MessageReference").Store(&r)
	if err == nil && r.Signature().String() == "u" {
		return r.Value().(uint32), nil
	}
	return *new(uint32), err
}
func (this *dbusPropertySmsMessageReference) GetType() reflect.Type {
	return reflect.TypeOf((*uint32)(nil)).Elem()
}

type dbusPropertySmsTimestamp struct {
	*property.BaseObserver
	core *dbus.Object
}

func (this *dbusPropertySmsTimestamp) SetValue(notwritable interface{}) {
	fmt.Println("org.freedesktop.ModemManager1.Sms.Timestamp is not writable")
}

func (this *dbusPropertySmsTimestamp) Get() string {
	v, _ := this.GetValue()
	return v.(string)
}
func (this *dbusPropertySmsTimestamp) GetValue() (interface{} /*string*/, error) {
	var r dbus.Variant
	err := this.core.Call("org.freedesktop.DBus.Properties.Get", 0, "org.freedesktop.ModemManager1.Sms", "Timestamp").Store(&r)
	if err == nil && r.Signature().String() == "s" {
		return r.Value().(string), nil
	}
	return *new(string), err
}
func (this *dbusPropertySmsTimestamp) GetType() reflect.Type {
	return reflect.TypeOf((*string)(nil)).Elem()
}

type dbusPropertySmsDischargeTimestamp struct {
	*property.BaseObserver
	core *dbus.Object
}

func (this *dbusPropertySmsDischargeTimestamp) SetValue(notwritable interface{}) {
	fmt.Println("org.freedesktop.ModemManager1.Sms.DischargeTimestamp is not writable")
}

func (this *dbusPropertySmsDischargeTimestamp) Get() string {
	v, _ := this.GetValue()
	return v.(string)
}
func (this *dbusPropertySmsDischargeTimestamp) GetValue() (interface{} /*string*/, error) {
	var r dbus.Variant
	err := this.core.Call("org.freedesktop.DBus.Properties.Get", 0, "org.freedesktop.ModemManager1.Sms", "DischargeTimestamp").Store(&r)
	if err == nil && r.Signature().String() == "s" {
		return r.Value().(string), nil
	}
	return *new(string), err
}
func (this *dbusPropertySmsDischargeTimestamp) GetType() reflect.Type {
	return reflect.TypeOf((*string)(nil)).Elem()
}

type dbusPropertySmsDeliveryState struct {
	*property.BaseObserver
	core *dbus.Object
}

func (this *dbusPropertySmsDeliveryState) SetValue(notwritable interface{}) {
	fmt.Println("org.freedesktop.ModemManager1.Sms.DeliveryState is not writable")
}

func (this *dbusPropertySmsDeliveryState) Get() uint32 {
	v, _ := this.GetValue()
	return v.(uint32)
}
func (this *dbusPropertySmsDeliveryState) GetValue() (interface{} /*uint32*/, error) {
	var r dbus.Variant
	err := this.core.Call("org.freedesktop.DBus.Properties.Get", 0, "org.freedesktop.ModemManager1.Sms", "DeliveryState").Store(&r)
	if err == nil && r.Signature().String() == "u" {
		return r.Value().(uint32), nil
	}
	return *new(uint32), err
}
func (this *dbusPropertySmsDeliveryState) GetType() reflect.Type {
	return reflect.TypeOf((*uint32)(nil)).Elem()
}

type dbusPropertySmsStorage struct {
	*property.BaseObserver
	core *dbus.Object
}

func (this *dbusPropertySmsStorage) SetValue(notwritable interface{}) {
	fmt.Println("org.freedesktop.ModemManager1.Sms.Storage is not writable")
}

func (this *dbusPropertySmsStorage) Get() uint32 {
	v, _ := this.GetValue()
	return v.(uint32)
}
func (this *dbusPropertySmsStorage) GetValue() (interface{} /*uint32*/, error) {
	var r dbus.Variant
	err := this.core.Call("org.freedesktop.DBus.Properties.Get", 0, "org.freedesktop.ModemManager1.Sms", "Storage").Store(&r)
	if err == nil && r.Signature().String() == "u" {
		return r.Value().(uint32), nil
	}
	return *new(uint32), err
}
func (this *dbusPropertySmsStorage) GetType() reflect.Type {
	return reflect.TypeOf((*uint32)(nil)).Elem()
}

func NewSms(destName string, path dbus.ObjectPath) (*Sms, error) {
	if !path.IsValid() {
		return nil, errors.New("The path of '" + string(path) + "' is invalid.")
	}

	core := getBus().Object(destName, path)

	obj := &Sms{Path: path, DestName: destName, core: core, signals: make(map[<-chan *dbus.Signal]struct{})}

	obj.State = &dbusPropertySmsState{&property.BaseObserver{}, core}
	obj.PduType = &dbusPropertySmsPduType{&property.BaseObserver{}, core}
	obj.Number = &dbusPropertySmsNumber{&property.BaseObserver{}, core}
	obj.Text = &dbusPropertySmsText{&property.BaseObserver{}, core}
	obj.Data = &dbusPropertySmsData{&property.BaseObserver{}, core}
	obj.SMSC = &dbusPropertySmsSMSC{&property.BaseObserver{}, core}
	obj.Validity = &dbusPropertySmsValidity{&property.BaseObserver{}, core}
	obj.Class = &dbusPropertySmsClass{&property.BaseObserver{}, core}
	obj.TeleserviceId = &dbusPropertySmsTeleserviceId{&property.BaseObserver{}, core}
	obj.ServiceCategory = &dbusPropertySmsServiceCategory{&property.BaseObserver{}, core}
	obj.DeliveryReportRequest = &dbusPropertySmsDeliveryReportRequest{&property.BaseObserver{}, core}
	obj.MessageReference = &dbusPropertySmsMessageReference{&property.BaseObserver{}, core}
	obj.Timestamp = &dbusPropertySmsTimestamp{&property.BaseObserver{}, core}
	obj.DischargeTimestamp = &dbusPropertySmsDischargeTimestamp{&property.BaseObserver{}, core}
	obj.DeliveryState = &dbusPropertySmsDeliveryState{&property.BaseObserver{}, core}
	obj.Storage = &dbusPropertySmsStorage{&property.BaseObserver{}, core}

	dbusAddMatch("type='signal',path='" + string(path) + "',interface='org.freedesktop.DBus.Properties',sender='" + destName + "',member='PropertiesChanged'")
	dbusAddMatch("type='signal',path='" + string(path) + "',interface='org.freedesktop.ModemManager1.Sms',sender='" + destName + "',member='PropertiesChanged'")
	sigChan := obj._createSignalChan()
	go func() {
		typeString := reflect.TypeOf("")
		typeKeyValues := reflect.TypeOf(map[string]dbus.Variant{})
		typeArrayValues := reflect.TypeOf([]string{})
		for v := range sigChan {
			if v.Name == "org.freedesktop.DBus.Properties.PropertiesChanged" &&
				len(v.Body) == 3 &&
				reflect.TypeOf(v.Body[0]) == typeString &&
				reflect.TypeOf(v.Body[1]) == typeKeyValues &&
				reflect.TypeOf(v.Body[2]) == typeArrayValues &&
				v.Body[0].(string) == "org.freedesktop.ModemManager1.Sms" {
				props := v.Body[1].(map[string]dbus.Variant)
				for key, _ := range props {
					if false {
					} else if key == "State" {
						obj.State.Notify()

					} else if key == "PduType" {
						obj.PduType.Notify()

					} else if key == "Number" {
						obj.Number.Notify()

					} else if key == "Text" {
						obj.Text.Notify()

					} else if key == "Data" {
						obj.Data.Notify()

					} else if key == "SMSC" {
						obj.SMSC.Notify()

					} else if key == "Validity" {
						obj.Validity.Notify()

					} else if key == "Class" {
						obj.Class.Notify()

					} else if key == "TeleserviceId" {
						obj.TeleserviceId.Notify()

					} else if key == "ServiceCategory" {
						obj.ServiceCategory.Notify()

					} else if key == "DeliveryReportRequest" {
						obj.DeliveryReportRequest.Notify()

					} else if key == "MessageReference" {
						obj.MessageReference.Notify()

					} else if key == "Timestamp" {
						obj.Timestamp.Notify()

					} else if key == "DischargeTimestamp" {
						obj.DischargeTimestamp.Notify()

					} else if key == "DeliveryState" {
						obj.DeliveryState.Notify()

					} else if key == "Storage" {
						obj.Storage.Notify()
					}
				}
			} else if v.Name == "org.freedesktop.ModemManager1.Sms.PropertiesChanged" && len(v.Body) == 1 && reflect.TypeOf(v.Body[0]) == typeKeyValues {
				for key, _ := range v.Body[0].(map[string]dbus.Variant) {
					if false {
					} else if key == "State" {
						obj.State.Notify()

					} else if key == "PduType" {
						obj.PduType.Notify()

					} else if key == "Number" {
						obj.Number.Notify()

					} else if key == "Text" {
						obj.Text.Notify()

					} else if key == "Data" {
						obj.Data.Notify()

					} else if key == "SMSC" {
						obj.SMSC.Notify()

					} else if key == "Validity" {
						obj.Validity.Notify()

					} else if key == "Class" {
						obj.Class.Notify()

					} else if key == "TeleserviceId" {
						obj.TeleserviceId.Notify()

					} else if key == "ServiceCategory" {
						obj.ServiceCategory.Notify()

					} else if key == "DeliveryReportRequest" {
						obj.DeliveryReportRequest.Notify()

					} else if key == "MessageReference" {
						obj.MessageReference.Notify()

					} else if key == "Timestamp" {
						obj.Timestamp.Notify()

					} else if key == "DischargeTimestamp" {
						obj.DischargeTimestamp.Notify()

					} else if key == "DeliveryState" {
						obj.DeliveryState.Notify()

					} else if key == "Storage" {
						obj.Storage.Notify()
					}
				}
			}
		}
	}()

	runtime.SetFinalizer(obj, func(_obj *Sms) { DestroySms(_obj) })
	return obj, nil
}
