xml

package
v0.1.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2018 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// GetType represents a 'get' IQ type.
	GetType = "get"

	// SetType represents a 'set' IQ type.
	SetType = "set"

	// ResultType represents a 'result' IQ type.
	ResultType = "result"
)
View Source
const (
	// NormalType represents a 'normal' message type.
	NormalType = "normal"

	// HeadlineType represents a 'headline' message type.
	HeadlineType = "headline"

	// ChatType represents a 'chat' message type.
	ChatType = "chat"

	// GroupChatType represents a 'groupchat' message type.
	GroupChatType = "groupchat"
)
View Source
const (
	// AvailableType represents an 'available' Presence type.
	AvailableType = "available"

	// UnavailableType represents a 'unavailable' Presence type.
	UnavailableType = "unavailable"

	// SubscribeType represents a 'subscribe' Presence type.
	SubscribeType = "subscribe"

	// UnsubscribeType represents a 'unsubscribe' Presence type.
	UnsubscribeType = "unsubscribe"

	// SubscribedType represents a 'subscribed' Presence type.
	SubscribedType = "subscribed"

	// UnsubscribedType represents a 'unsubscribed' Presence type.
	UnsubscribedType = "unsubscribed"
)
View Source
const ErrorType = "error"

ErrorType represents an 'error' stanza type.

Variables

View Source
var (
	// ErrBadRequest is returned by the stream when the  sender
	// has sent XML that is malformed or that cannot be processed.
	ErrBadRequest = newErrorElement(400, modifyErrorType, badRequestErrorReason)

	// ErrConflict is returned by the stream when access cannot be
	// granted because an existing resource or session exists with
	// the same name or address.
	ErrConflict = newErrorElement(409, cancelErrorType, conflictErrorReason)

	// ErrFeatureNotImplemented is returned by the stream when the feature
	// requested is not implemented by the server and therefore cannot be processed.
	ErrFeatureNotImplemented = newErrorElement(501, cancelErrorType, featureNotImplementedErrorReason)

	// ErrForbidden is returned by the stream when the requesting
	// entity does not possess the required permissions to perform the action.
	ErrForbidden = newErrorElement(403, authErrorType, forbiddenErrorReason)

	// ErrGone is returned by the stream when the recipient or server
	// can no longer be contacted at this address.
	ErrGone = newErrorElement(302, modifyErrorType, goneErrorReason)

	// ErrInternalServerError is returned by the stream when the server
	// could not process the stanza because of a misconfiguration
	// or an otherwise-undefined internal server error.
	ErrInternalServerError = newErrorElement(500, waitErrorType, internalServerErrorErrorReason)

	// ErrItemNotFound is returned by the stream when the addressed
	// JID or item requested cannot be found.
	ErrItemNotFound = newErrorElement(404, cancelErrorType, itemNotFoundErrorReason)

	// ErrJidMalformed is returned by the stream when the sending entity
	// has provided or communicated an XMPP address or aspect thereof that
	// does not adhere to the syntax defined in https://xmpp.org/rfcs/rfc3920.html#addressing.
	ErrJidMalformed = newErrorElement(400, modifyErrorType, jidMalformedErrorReason)

	// ErrNotAcceptable is returned by the stream when the server
	// understands the request but is refusing to process it because
	// it does not meet the defined criteria.
	ErrNotAcceptable = newErrorElement(406, modifyErrorType, notAcceptableErrorReason)

	// ErrNotAllowed is returned by the stream when the recipient
	// or server does not allow any entity to perform the action.
	ErrNotAllowed = newErrorElement(405, cancelErrorType, notAllowedErrorReason)

	// ErrNotAuthorized is returned by the stream when the sender
	// must provide proper credentials before being allowed to perform the action,
	// or has provided improper credentials.
	ErrNotAuthorized = newErrorElement(405, authErrorType, notAuthroizedErrorReason)

	// ErrPaymentRequired is returned by the stream when the requesting entity
	// is not authorized to access the requested service because payment is required.
	ErrPaymentRequired = newErrorElement(402, authErrorType, paymentRequiredErrorReason)

	// ErrRecipientUnavailable is returned by the stream when the intended
	// recipient is temporarily unavailable.
	ErrRecipientUnavailable = newErrorElement(404, waitErrorType, recipientUnavailableErrorReason)

	// ErrRedirect is returned by the stream when the recipient or server
	// is redirecting requests for this information to another entity, usually temporarily.
	ErrRedirect = newErrorElement(302, modifyErrorType, redirectErrorReason)

	// ErrRegistrationRequired is returned by the stream when the requesting entity
	// is not authorized to access the requested service because registration is required.
	ErrRegistrationRequired = newErrorElement(407, authErrorType, registrationRequiredErrorReason)

	// ErrRemoteServerNotFound is returned by the stream when a remote server
	// or service specified as part or all of the JID of the intended recipient does not exist.
	ErrRemoteServerNotFound = newErrorElement(404, cancelErrorType, remoteServerNotFoundErrorReason)

	// ErrRemoteServerTimeout is returned by the stream when a remote server
	// or service specified as part or all of the JID of the intended recipient
	// could not be contacted within a reasonable amount of time.
	ErrRemoteServerTimeout = newErrorElement(504, waitErrorType, remoteServerTimeoutErrorReason)

	// ErrResourceConstraint is returned by the stream when the server or recipient
	// lacks the system resources necessary to service the request.
	ErrResourceConstraint = newErrorElement(500, waitErrorType, resourceConstraintErrorReason)

	// ErrServiceUnavailable is returned by the stream when the server or recipient
	// does not currently provide the requested service.
	ErrServiceUnavailable = newErrorElement(503, cancelErrorType, serviceUnavailableErrorReason)

	// ErrSubscriptionRequired is returned by the stream when the requesting entity
	// is not authorized to access the requested service because a subscription is required.
	ErrSubscriptionRequired = newErrorElement(407, authErrorType, subscriptionRequiredErrorReason)

	// ErrUndefinedCondition is returned by the stream when the error condition
	// is not one of those defined by the other conditions in this list.
	ErrUndefinedCondition = newErrorElement(500, waitErrorType, undefinedConditionErrorReason)

	// ErrUnexpectedCondition is returned by the stream when the recipient or server
	// understood the request but was not expecting it at this time.
	ErrUnexpectedCondition = newErrorElement(400, waitErrorType, unexpectedConditionErrorReason)
)
View Source
var ErrStreamClosedByPeer = errors.New("stream closed by peer")

ErrStreamClosedByPeer is returned by Parse when peer closes the stream by sending '</stream:stream>' closing tag.

Functions

This section is empty.

Types

type Attribute

type Attribute struct {
	Label string
	Value string
}

Attribute represents an XML node attribute (label=value).

type Element

type Element interface {
	fmt.Stringer

	Name() string
	Namespace() string

	ID() string
	Language() string
	Version() string
	From() string
	To() string
	Type() string

	Text() string
	TextLen() int

	Attribute(label string) string
	Attributes() []Attribute
	AttributesCount() int

	FindElement(name string) Element
	FindElements(name string) []Element
	FindElementNamespace(name, namespace string) Element
	FindElementsNamespace(name, namespace string) []Element

	Elements() []Element
	ElementsCount() int

	ToError(stanzaError *StanzaError) Element
	Error() Element

	ToXML(writer io.Writer, includeClosing bool)

	FromBytes(r io.Reader)
	ToBytes(w io.Writer)
}

Element represents an XML node element.

type IQ

type IQ struct {
	MutableElement
	// contains filtered or unexported fields
}

IQ type represents an <iq> element. All incoming <iq> elements providing from the stream will automatically be converted to IQ objects.

func NewIQFromElement

func NewIQFromElement(e Element, from *JID, to *JID) (*IQ, error)

NewIQFromElement creates an IQ object from Element.

func NewIQType

func NewIQType(identifier string, iqType string) *IQ

NewIQType creates and returns a new IQ element.

func (*IQ) Attribute

func (e *IQ) Attribute(label string) string

Attribute returns XML node attribute value.

func (*IQ) Attributes

func (e *IQ) Attributes() []Attribute

Attributes returns all XML node attributes.

func (*IQ) AttributesCount

func (e *IQ) AttributesCount() int

AttributesCount XML attributes count.

func (*IQ) BadRequestError

func (el *IQ) BadRequestError() Element

BadRequestError returns an error copy of the element attaching 'bad-request' error sub element.

func (*IQ) ConflictError

func (el *IQ) ConflictError() Element

ConflictError returns an error copy of the element attaching 'conflict' error sub element.

func (*IQ) Copy

func (e *IQ) Copy() *MutableElement

Copy returns a deep copy of this message stanza.

func (*IQ) Elements

func (e *IQ) Elements() []Element

Elements returns all instance's child elements.

func (*IQ) ElementsCount

func (e *IQ) ElementsCount() int

ElementsCount returns child elements count.

func (*IQ) Error

func (e *IQ) Error() Element

Error returns element error sub element.

func (*IQ) FeatureNotImplementedError

func (el *IQ) FeatureNotImplementedError() Element

FeatureNotImplementedError returns an error copy of the element attaching 'feature-not-implemented' error sub element.

func (*IQ) FindElement

func (e *IQ) FindElement(name string) Element

FindElement returns first element identified by name. Returns nil if no element is found.

func (*IQ) FindElementNamespace

func (e *IQ) FindElementNamespace(name, namespace string) Element

FindElementNamespace returns first element identified by name and namespace. Returns nil if no element is found.

func (*IQ) FindElements

func (e *IQ) FindElements(name string) []Element

FindElements returns all elements identified by name. Returns an empty array if no elements are found.

func (*IQ) FindElementsNamespace

func (e *IQ) FindElementsNamespace(name, namespace string) []Element

FindElementsNamespace returns all elements identified by name and namespace. Returns an empty array if no elements are found.

func (*IQ) ForbiddenError

func (el *IQ) ForbiddenError() Element

ForbiddenError returns an error copy of the element attaching 'forbidden' error sub element.

func (*IQ) From

func (e *IQ) From() string

From returns 'from' node attribute.

func (*IQ) FromBytes

func (e *IQ) FromBytes(r io.Reader)

FromBytes deserializes XML element from it's gob binary representation.

func (*IQ) FromJID

func (iq *IQ) FromJID() *JID

FromJID returns presence 'from' JID value.

func (*IQ) GoneError

func (el *IQ) GoneError() Element

GoneError returns an error copy of the element attaching 'gone' error sub element.

func (*IQ) ID

func (e *IQ) ID() string

ID returns 'id' node attribute.

func (*IQ) InternalServerError

func (el *IQ) InternalServerError() Element

InternalServerError returns an error copy of the element attaching 'internal-server-error' error sub element.

func (*IQ) IsError

func (e *IQ) IsError() bool

IsError returns true if element has a 'type' attribute of value 'error'.

func (*IQ) IsGet

func (iq *IQ) IsGet() bool

IsGet returns true if this is a 'get' type IQ.

func (*IQ) IsResult

func (iq *IQ) IsResult() bool

IsResult returns true if this is a 'result' type IQ.

func (*IQ) IsSet

func (iq *IQ) IsSet() bool

IsSet returns true if this is a 'set' type IQ.

func (*IQ) ItemNotFoundError

func (el *IQ) ItemNotFoundError() Element

ItemNotFoundError returns an error copy of the element attaching 'item-not-found' error sub element.

func (*IQ) JidMalformedError

func (el *IQ) JidMalformedError() Element

JidMalformedError returns an error copy of the element attaching 'jid-malformed' error sub element.

func (*IQ) Language

func (e *IQ) Language() string

Language returns 'xml:lang' node attribute.

func (*IQ) Name

func (e *IQ) Name() string

Name returns XML node name.

func (*IQ) Namespace

func (e *IQ) Namespace() string

Namespace returns 'xmlns' node attribute.

func (*IQ) NotAcceptableError

func (el *IQ) NotAcceptableError() Element

NotAcceptableError returns an error copy of the element attaching 'not-acceptable' error sub element.

func (*IQ) NotAllowedError

func (el *IQ) NotAllowedError() Element

NotAllowedError returns an error copy of the element attaching 'not-allowed' error sub element.

func (*IQ) NotAuthorizedError

func (el *IQ) NotAuthorizedError() Element

NotAuthorizedError returns an error copy of the element attaching 'not-authorized' error sub element.

func (*IQ) PaymentRequiredError

func (el *IQ) PaymentRequiredError() Element

PaymentRequiredError returns an error copy of the element attaching 'payment-required' error sub element.

func (*IQ) RecipientUnavailableError

func (el *IQ) RecipientUnavailableError() Element

RecipientUnavailableError returns an error copy of the element attaching 'recipient-unavailable' error sub element.

func (*IQ) RedirectError

func (el *IQ) RedirectError() Element

RedirectError returns an error copy of the element attaching 'redirect' error sub element.

func (*IQ) RegistrationRequiredError

func (el *IQ) RegistrationRequiredError() Element

RegistrationRequiredError returns an error copy of the element attaching 'registration-required' error sub element.

func (*IQ) RemoteServerNotFoundError

func (el *IQ) RemoteServerNotFoundError() Element

RemoteServerNotFoundError returns an error copy of the element attaching 'remote-server-not-found' error sub element.

func (*IQ) RemoteServerTimeoutError

func (el *IQ) RemoteServerTimeoutError() Element

RemoteServerNotFoundError returns an error copy of the element attaching 'remote-server-timeout' error sub element.

func (*IQ) ResourceConstraintError

func (el *IQ) ResourceConstraintError() Element

ResourceConstraintError returns an error copy of the element attaching 'resource-constraint' error sub element.

func (*IQ) ResultIQ

func (iq *IQ) ResultIQ() *IQ

ResultIQ returns the instance associated result IQ.

func (*IQ) ServiceUnavailableError

func (el *IQ) ServiceUnavailableError() Element

ServiceUnavailableError returns an error copy of the element attaching 'service-unavailable' error sub element.

func (*IQ) SetFromJID

func (iq *IQ) SetFromJID(from *JID)

SetFromJID sets the IQ 'from' JID value.

func (*IQ) SetToJID

func (iq *IQ) SetToJID(to *JID)

SetToJID sets the IQ 'to' JID value.

func (*IQ) String

func (e *IQ) String() string

String returns a string representation of the element.

func (*IQ) SubscriptionRequiredError

func (el *IQ) SubscriptionRequiredError() Element

SubscriptionRequiredError returns an error copy of the element attaching 'subscription-required' error sub element.

func (*IQ) Text

func (e *IQ) Text() string

Text returns XML node text value. Returns an empty string if not set.

func (*IQ) TextLen

func (e *IQ) TextLen() int

TextLen returns XML node text value length.

func (*IQ) To

func (e *IQ) To() string

To returns 'to' node attribute.

func (*IQ) ToBytes

func (e *IQ) ToBytes(w io.Writer)

ToBytes serializes XML element to it's gob binary representation.

func (*IQ) ToError

func (el *IQ) ToError(stanzaError *StanzaError) Element

ToError returns an error copy element attaching stanza error sub element.

func (*IQ) ToJID

func (iq *IQ) ToJID() *JID

ToJID returns iq 'from' JID value.

func (*IQ) ToXML

func (e *IQ) ToXML(w io.Writer, includeClosing bool)

ToXML serializes element to a raw XML representation. includeClosing determines if closing tag should be attached.

func (*IQ) Type

func (e *IQ) Type() string

Type returns 'type' node attribute.

func (*IQ) UndefinedConditionError

func (el *IQ) UndefinedConditionError() Element

UndefinedConditionError returns an error copy of the element attaching 'undefined-condition' error sub element.

func (*IQ) UnexpectedConditionError

func (el *IQ) UnexpectedConditionError() Element

UnexpectedConditionError returns an error copy of the element attaching 'unexpected-condition' error sub element.

func (*IQ) Version

func (e *IQ) Version() string

Version returns 'version' node attribute.

type JID

type JID struct {
	// contains filtered or unexported fields
}

JID represents an XMPP address (JID). A JID is made up of a node (generally a username), a domain, and a resource. The node and resource are optional; domain is required.

func NewJID

func NewJID(node, domain, resource string, skipStringPrep bool) (*JID, error)

NewJID constructs a JID given a user, domain, and resource. This construction allows the caller to specify if stringprep should be applied or not.

func NewJIDString

func NewJIDString(str string, skipStringPrep bool) (*JID, error)

NewJIDString constructs a JID from it's string representation. This construction allows the caller to specify if stringprep should be applied or not.

func (*JID) Domain

func (j *JID) Domain() string

Domain returns the domain.

func (*JID) IsBare

func (j *JID) IsBare() bool

IsBare returns true if instance is a bare JID.

func (*JID) IsEqual

func (j *JID) IsEqual(j2 *JID) bool

IsEqual returns true if two JID's are equivalent.

func (*JID) IsFull

func (j *JID) IsFull() bool

IsFull returns true if instance is a full JID.

func (*JID) IsServer

func (j *JID) IsServer() bool

IsServer returns true if instance is a server JID.

func (*JID) Node

func (j *JID) Node() string

Node returns the node, or empty string if this JID does not contain node information.

func (*JID) Resource

func (j *JID) Resource() string

Resource returns the resource, or empty string if this JID does not contain resource information.

func (*JID) String

func (j *JID) String() string

String returns a string representation of the JID.

func (*JID) ToBareJID

func (j *JID) ToBareJID() *JID

ToBareJID returns the JID equivalent of the bare JID, which is the JID with resource information removed.

type Message

type Message struct {
	MutableElement
	// contains filtered or unexported fields
}

Message type represents a <message> element. All incoming <message> elements providing from the stream will automatically be converted to Message objects.

func NewMessageFromElement

func NewMessageFromElement(e Element, from *JID, to *JID) (*Message, error)

NewMessageFromElement creates a Message object from Element.

func NewMessageType

func NewMessageType(identifier string, messageType string) *Message

NewMessageType creates and returns a new Message element.

func (*Message) Attribute

func (e *Message) Attribute(label string) string

Attribute returns XML node attribute value.

func (*Message) Attributes

func (e *Message) Attributes() []Attribute

Attributes returns all XML node attributes.

func (*Message) AttributesCount

func (e *Message) AttributesCount() int

AttributesCount XML attributes count.

func (*Message) BadRequestError

func (el *Message) BadRequestError() Element

BadRequestError returns an error copy of the element attaching 'bad-request' error sub element.

func (*Message) ConflictError

func (el *Message) ConflictError() Element

ConflictError returns an error copy of the element attaching 'conflict' error sub element.

func (*Message) Copy

func (e *Message) Copy() *MutableElement

Copy returns a deep copy of this message stanza.

func (*Message) Elements

func (e *Message) Elements() []Element

Elements returns all instance's child elements.

func (*Message) ElementsCount

func (e *Message) ElementsCount() int

ElementsCount returns child elements count.

func (*Message) Error

func (e *Message) Error() Element

Error returns element error sub element.

func (*Message) FeatureNotImplementedError

func (el *Message) FeatureNotImplementedError() Element

FeatureNotImplementedError returns an error copy of the element attaching 'feature-not-implemented' error sub element.

func (*Message) FindElement

func (e *Message) FindElement(name string) Element

FindElement returns first element identified by name. Returns nil if no element is found.

func (*Message) FindElementNamespace

func (e *Message) FindElementNamespace(name, namespace string) Element

FindElementNamespace returns first element identified by name and namespace. Returns nil if no element is found.

func (*Message) FindElements

func (e *Message) FindElements(name string) []Element

FindElements returns all elements identified by name. Returns an empty array if no elements are found.

func (*Message) FindElementsNamespace

func (e *Message) FindElementsNamespace(name, namespace string) []Element

FindElementsNamespace returns all elements identified by name and namespace. Returns an empty array if no elements are found.

func (*Message) ForbiddenError

func (el *Message) ForbiddenError() Element

ForbiddenError returns an error copy of the element attaching 'forbidden' error sub element.

func (*Message) From

func (e *Message) From() string

From returns 'from' node attribute.

func (*Message) FromBytes

func (e *Message) FromBytes(r io.Reader)

FromBytes deserializes XML element from it's gob binary representation.

func (*Message) FromJID

func (m *Message) FromJID() *JID

FromJID returns message 'from' JID value.

func (*Message) GoneError

func (el *Message) GoneError() Element

GoneError returns an error copy of the element attaching 'gone' error sub element.

func (*Message) ID

func (e *Message) ID() string

ID returns 'id' node attribute.

func (*Message) InternalServerError

func (el *Message) InternalServerError() Element

InternalServerError returns an error copy of the element attaching 'internal-server-error' error sub element.

func (*Message) IsChat

func (m *Message) IsChat() bool

IsChat returns true if this is a 'chat' type Message.

func (*Message) IsError

func (e *Message) IsError() bool

IsError returns true if element has a 'type' attribute of value 'error'.

func (*Message) IsGroupChat

func (m *Message) IsGroupChat() bool

IsGroupChat returns true if this is a 'groupchat' type Message.

func (*Message) IsHeadline

func (m *Message) IsHeadline() bool

IsHeadline returns true if this is a 'headline' type Message.

func (*Message) IsMessageWithBody

func (m *Message) IsMessageWithBody() bool

IsMessageWithBody returns true if the message has a body sub element.

func (*Message) IsNormal

func (m *Message) IsNormal() bool

IsNormal returns true if this is a 'normal' type Message.

func (*Message) ItemNotFoundError

func (el *Message) ItemNotFoundError() Element

ItemNotFoundError returns an error copy of the element attaching 'item-not-found' error sub element.

func (*Message) JidMalformedError

func (el *Message) JidMalformedError() Element

JidMalformedError returns an error copy of the element attaching 'jid-malformed' error sub element.

func (*Message) Language

func (e *Message) Language() string

Language returns 'xml:lang' node attribute.

func (*Message) Name

func (e *Message) Name() string

Name returns XML node name.

func (*Message) Namespace

func (e *Message) Namespace() string

Namespace returns 'xmlns' node attribute.

func (*Message) NotAcceptableError

func (el *Message) NotAcceptableError() Element

NotAcceptableError returns an error copy of the element attaching 'not-acceptable' error sub element.

func (*Message) NotAllowedError

func (el *Message) NotAllowedError() Element

NotAllowedError returns an error copy of the element attaching 'not-allowed' error sub element.

func (*Message) NotAuthorizedError

func (el *Message) NotAuthorizedError() Element

NotAuthorizedError returns an error copy of the element attaching 'not-authorized' error sub element.

func (*Message) PaymentRequiredError

func (el *Message) PaymentRequiredError() Element

PaymentRequiredError returns an error copy of the element attaching 'payment-required' error sub element.

func (*Message) RecipientUnavailableError

func (el *Message) RecipientUnavailableError() Element

RecipientUnavailableError returns an error copy of the element attaching 'recipient-unavailable' error sub element.

func (*Message) RedirectError

func (el *Message) RedirectError() Element

RedirectError returns an error copy of the element attaching 'redirect' error sub element.

func (*Message) RegistrationRequiredError

func (el *Message) RegistrationRequiredError() Element

RegistrationRequiredError returns an error copy of the element attaching 'registration-required' error sub element.

func (*Message) RemoteServerNotFoundError

func (el *Message) RemoteServerNotFoundError() Element

RemoteServerNotFoundError returns an error copy of the element attaching 'remote-server-not-found' error sub element.

func (*Message) RemoteServerTimeoutError

func (el *Message) RemoteServerTimeoutError() Element

RemoteServerNotFoundError returns an error copy of the element attaching 'remote-server-timeout' error sub element.

func (*Message) ResourceConstraintError

func (el *Message) ResourceConstraintError() Element

ResourceConstraintError returns an error copy of the element attaching 'resource-constraint' error sub element.

func (*Message) ServiceUnavailableError

func (el *Message) ServiceUnavailableError() Element

ServiceUnavailableError returns an error copy of the element attaching 'service-unavailable' error sub element.

func (*Message) SetFromJID

func (m *Message) SetFromJID(from *JID)

SetFromJID sets the message 'from' JID value.

func (*Message) SetToJID

func (m *Message) SetToJID(to *JID)

SetToJID sets the message 'to' JID value.

func (*Message) String

func (e *Message) String() string

String returns a string representation of the element.

func (*Message) SubscriptionRequiredError

func (el *Message) SubscriptionRequiredError() Element

SubscriptionRequiredError returns an error copy of the element attaching 'subscription-required' error sub element.

func (*Message) Text

func (e *Message) Text() string

Text returns XML node text value. Returns an empty string if not set.

func (*Message) TextLen

func (e *Message) TextLen() int

TextLen returns XML node text value length.

func (*Message) To

func (e *Message) To() string

To returns 'to' node attribute.

func (*Message) ToBytes

func (e *Message) ToBytes(w io.Writer)

ToBytes serializes XML element to it's gob binary representation.

func (*Message) ToError

func (el *Message) ToError(stanzaError *StanzaError) Element

ToError returns an error copy element attaching stanza error sub element.

func (*Message) ToJID

func (m *Message) ToJID() *JID

ToJID returns message 'to' JID value.

func (*Message) ToXML

func (e *Message) ToXML(w io.Writer, includeClosing bool)

ToXML serializes element to a raw XML representation. includeClosing determines if closing tag should be attached.

func (*Message) Type

func (e *Message) Type() string

Type returns 'type' node attribute.

func (*Message) UndefinedConditionError

func (el *Message) UndefinedConditionError() Element

UndefinedConditionError returns an error copy of the element attaching 'undefined-condition' error sub element.

func (*Message) UnexpectedConditionError

func (el *Message) UnexpectedConditionError() Element

UnexpectedConditionError returns an error copy of the element attaching 'unexpected-condition' error sub element.

func (*Message) Version

func (e *Message) Version() string

Version returns 'version' node attribute.

type MutableElement

type MutableElement struct {
	// contains filtered or unexported fields
}

MutableElement represents a mutable XML node element.

func NewElementFromElement

func NewElementFromElement(elem Element) *MutableElement

NewElementFromElement creates a mutable XML Element by copying an element.

func NewElementName

func NewElementName(name string) *MutableElement

NewElementName creates a mutable XML Element instance with a given name.

func NewElementNamespace

func NewElementNamespace(name, namespace string) *MutableElement

NewElementNamespace creates a mutable XML Element instance with a given name and namespace.

func (*MutableElement) AppendElement

func (m *MutableElement) AppendElement(element Element)

AppendElement appends a new sub element.

func (*MutableElement) AppendElements

func (m *MutableElement) AppendElements(elements []Element)

AppendElements appends an array of sub elements.

func (*MutableElement) Attribute

func (e *MutableElement) Attribute(label string) string

Attribute returns XML node attribute value.

func (*MutableElement) Attributes

func (e *MutableElement) Attributes() []Attribute

Attributes returns all XML node attributes.

func (*MutableElement) AttributesCount

func (e *MutableElement) AttributesCount() int

AttributesCount XML attributes count.

func (*MutableElement) BadRequestError

func (el *MutableElement) BadRequestError() Element

BadRequestError returns an error copy of the element attaching 'bad-request' error sub element.

func (*MutableElement) ClearElements

func (m *MutableElement) ClearElements()

ClearElements removes all elements.

func (*MutableElement) ConflictError

func (el *MutableElement) ConflictError() Element

ConflictError returns an error copy of the element attaching 'conflict' error sub element.

func (*MutableElement) Copy

func (e *MutableElement) Copy() *MutableElement

Copy returns a deep copy of this message stanza.

func (*MutableElement) Delay

func (m *MutableElement) Delay(from string, text string)

Delay attaches element's Delayed Delivery information.

func (*MutableElement) Elements

func (e *MutableElement) Elements() []Element

Elements returns all instance's child elements.

func (*MutableElement) ElementsCount

func (e *MutableElement) ElementsCount() int

ElementsCount returns child elements count.

func (*MutableElement) Error

func (e *MutableElement) Error() Element

Error returns element error sub element.

func (*MutableElement) FeatureNotImplementedError

func (el *MutableElement) FeatureNotImplementedError() Element

FeatureNotImplementedError returns an error copy of the element attaching 'feature-not-implemented' error sub element.

func (*MutableElement) FindElement

func (e *MutableElement) FindElement(name string) Element

FindElement returns first element identified by name. Returns nil if no element is found.

func (*MutableElement) FindElementNamespace

func (e *MutableElement) FindElementNamespace(name, namespace string) Element

FindElementNamespace returns first element identified by name and namespace. Returns nil if no element is found.

func (*MutableElement) FindElements

func (e *MutableElement) FindElements(name string) []Element

FindElements returns all elements identified by name. Returns an empty array if no elements are found.

func (*MutableElement) FindElementsNamespace

func (e *MutableElement) FindElementsNamespace(name, namespace string) []Element

FindElementsNamespace returns all elements identified by name and namespace. Returns an empty array if no elements are found.

func (*MutableElement) ForbiddenError

func (el *MutableElement) ForbiddenError() Element

ForbiddenError returns an error copy of the element attaching 'forbidden' error sub element.

func (*MutableElement) From

func (e *MutableElement) From() string

From returns 'from' node attribute.

func (*MutableElement) FromBytes

func (e *MutableElement) FromBytes(r io.Reader)

FromBytes deserializes XML element from it's gob binary representation.

func (*MutableElement) GoneError

func (el *MutableElement) GoneError() Element

GoneError returns an error copy of the element attaching 'gone' error sub element.

func (*MutableElement) ID

func (e *MutableElement) ID() string

ID returns 'id' node attribute.

func (*MutableElement) InternalServerError

func (el *MutableElement) InternalServerError() Element

InternalServerError returns an error copy of the element attaching 'internal-server-error' error sub element.

func (*MutableElement) IsError

func (e *MutableElement) IsError() bool

IsError returns true if element has a 'type' attribute of value 'error'.

func (*MutableElement) ItemNotFoundError

func (el *MutableElement) ItemNotFoundError() Element

ItemNotFoundError returns an error copy of the element attaching 'item-not-found' error sub element.

func (*MutableElement) JidMalformedError

func (el *MutableElement) JidMalformedError() Element

JidMalformedError returns an error copy of the element attaching 'jid-malformed' error sub element.

func (*MutableElement) Language

func (e *MutableElement) Language() string

Language returns 'xml:lang' node attribute.

func (*MutableElement) Name

func (e *MutableElement) Name() string

Name returns XML node name.

func (*MutableElement) Namespace

func (e *MutableElement) Namespace() string

Namespace returns 'xmlns' node attribute.

func (*MutableElement) NotAcceptableError

func (el *MutableElement) NotAcceptableError() Element

NotAcceptableError returns an error copy of the element attaching 'not-acceptable' error sub element.

func (*MutableElement) NotAllowedError

func (el *MutableElement) NotAllowedError() Element

NotAllowedError returns an error copy of the element attaching 'not-allowed' error sub element.

func (*MutableElement) NotAuthorizedError

func (el *MutableElement) NotAuthorizedError() Element

NotAuthorizedError returns an error copy of the element attaching 'not-authorized' error sub element.

func (*MutableElement) PaymentRequiredError

func (el *MutableElement) PaymentRequiredError() Element

PaymentRequiredError returns an error copy of the element attaching 'payment-required' error sub element.

func (*MutableElement) RecipientUnavailableError

func (el *MutableElement) RecipientUnavailableError() Element

RecipientUnavailableError returns an error copy of the element attaching 'recipient-unavailable' error sub element.

func (*MutableElement) RedirectError

func (el *MutableElement) RedirectError() Element

RedirectError returns an error copy of the element attaching 'redirect' error sub element.

func (*MutableElement) RegistrationRequiredError

func (el *MutableElement) RegistrationRequiredError() Element

RegistrationRequiredError returns an error copy of the element attaching 'registration-required' error sub element.

func (*MutableElement) RemoteServerNotFoundError

func (el *MutableElement) RemoteServerNotFoundError() Element

RemoteServerNotFoundError returns an error copy of the element attaching 'remote-server-not-found' error sub element.

func (*MutableElement) RemoteServerTimeoutError

func (el *MutableElement) RemoteServerTimeoutError() Element

RemoteServerNotFoundError returns an error copy of the element attaching 'remote-server-timeout' error sub element.

func (*MutableElement) RemoveAttribute

func (m *MutableElement) RemoveAttribute(label string)

RemoveAttribute removes an XML node attribute.

func (*MutableElement) RemoveElements

func (m *MutableElement) RemoveElements(name string)

RemoveElements removes all elements with a given name.

func (*MutableElement) RemoveElementsNamespace

func (m *MutableElement) RemoveElementsNamespace(name, namespace string)

RemoveElementsNamespace removes all elements with a given name and namespace.

func (*MutableElement) ResourceConstraintError

func (el *MutableElement) ResourceConstraintError() Element

ResourceConstraintError returns an error copy of the element attaching 'resource-constraint' error sub element.

func (*MutableElement) ServiceUnavailableError

func (el *MutableElement) ServiceUnavailableError() Element

ServiceUnavailableError returns an error copy of the element attaching 'service-unavailable' error sub element.

func (*MutableElement) SetAttribute

func (m *MutableElement) SetAttribute(label, value string)

SetAttribute sets an XML node attribute (label=value)

func (*MutableElement) SetFrom

func (m *MutableElement) SetFrom(from string)

SetFrom sets 'from' node attribute.

func (*MutableElement) SetID

func (m *MutableElement) SetID(identifier string)

SetID sets 'id' node attribute.

func (*MutableElement) SetLanguage

func (m *MutableElement) SetLanguage(language string)

SetLanguage sets 'xml:lang' node attribute.

func (*MutableElement) SetName

func (m *MutableElement) SetName(name string)

SetName sets XML node name.

func (*MutableElement) SetNamespace

func (m *MutableElement) SetNamespace(namespace string)

SetNamespace sets 'xmlns' node attribute.

func (*MutableElement) SetText

func (m *MutableElement) SetText(text string)

SetText sets XML node text value.

func (*MutableElement) SetTo

func (m *MutableElement) SetTo(to string)

SetTo sets 'to' node attribute.

func (*MutableElement) SetType

func (m *MutableElement) SetType(tp string)

SetType sets 'type' node attribute.

func (*MutableElement) SetVersion

func (m *MutableElement) SetVersion(version string)

SetVersion sets 'version' node attribute.

func (*MutableElement) String

func (e *MutableElement) String() string

String returns a string representation of the element.

func (*MutableElement) SubscriptionRequiredError

func (el *MutableElement) SubscriptionRequiredError() Element

SubscriptionRequiredError returns an error copy of the element attaching 'subscription-required' error sub element.

func (*MutableElement) Text

func (e *MutableElement) Text() string

Text returns XML node text value. Returns an empty string if not set.

func (*MutableElement) TextLen

func (e *MutableElement) TextLen() int

TextLen returns XML node text value length.

func (*MutableElement) To

func (e *MutableElement) To() string

To returns 'to' node attribute.

func (*MutableElement) ToBytes

func (e *MutableElement) ToBytes(w io.Writer)

ToBytes serializes XML element to it's gob binary representation.

func (*MutableElement) ToError

func (el *MutableElement) ToError(stanzaError *StanzaError) Element

ToError returns an error copy element attaching stanza error sub element.

func (*MutableElement) ToXML

func (e *MutableElement) ToXML(w io.Writer, includeClosing bool)

ToXML serializes element to a raw XML representation. includeClosing determines if closing tag should be attached.

func (*MutableElement) Type

func (e *MutableElement) Type() string

Type returns 'type' node attribute.

func (*MutableElement) UndefinedConditionError

func (el *MutableElement) UndefinedConditionError() Element

UndefinedConditionError returns an error copy of the element attaching 'undefined-condition' error sub element.

func (*MutableElement) UnexpectedConditionError

func (el *MutableElement) UnexpectedConditionError() Element

UnexpectedConditionError returns an error copy of the element attaching 'unexpected-condition' error sub element.

func (*MutableElement) Version

func (e *MutableElement) Version() string

Version returns 'version' node attribute.

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser parses arbitrary XML input and builds an array with the structure of all tag and data elements.

func NewParser

func NewParser(reader io.Reader) *Parser

NewParser creates an empty Parser instance.

func (*Parser) ParseElement

func (p *Parser) ParseElement() (Element, error)

ParseElement parses next available XML element from reader.

type Presence

type Presence struct {
	MutableElement
	// contains filtered or unexported fields
}

Presence type represents an <presence> element. All incoming <presence> elements providing from the stream will automatically be converted to Presence objects.

func NewPresence

func NewPresence(from *JID, to *JID, presenceType string) *Presence

NewPresence creates and returns a new Presence element.

func NewPresenceFromElement

func NewPresenceFromElement(e Element, from *JID, to *JID) (*Presence, error)

NewPresenceFromElement creates a Presence object from Element.

func (*Presence) Attribute

func (e *Presence) Attribute(label string) string

Attribute returns XML node attribute value.

func (*Presence) Attributes

func (e *Presence) Attributes() []Attribute

Attributes returns all XML node attributes.

func (*Presence) AttributesCount

func (e *Presence) AttributesCount() int

AttributesCount XML attributes count.

func (*Presence) BadRequestError

func (el *Presence) BadRequestError() Element

BadRequestError returns an error copy of the element attaching 'bad-request' error sub element.

func (*Presence) ConflictError

func (el *Presence) ConflictError() Element

ConflictError returns an error copy of the element attaching 'conflict' error sub element.

func (*Presence) Copy

func (e *Presence) Copy() *MutableElement

Copy returns a deep copy of this message stanza.

func (*Presence) Elements

func (e *Presence) Elements() []Element

Elements returns all instance's child elements.

func (*Presence) ElementsCount

func (e *Presence) ElementsCount() int

ElementsCount returns child elements count.

func (*Presence) Error

func (e *Presence) Error() Element

Error returns element error sub element.

func (*Presence) FeatureNotImplementedError

func (el *Presence) FeatureNotImplementedError() Element

FeatureNotImplementedError returns an error copy of the element attaching 'feature-not-implemented' error sub element.

func (*Presence) FindElement

func (e *Presence) FindElement(name string) Element

FindElement returns first element identified by name. Returns nil if no element is found.

func (*Presence) FindElementNamespace

func (e *Presence) FindElementNamespace(name, namespace string) Element

FindElementNamespace returns first element identified by name and namespace. Returns nil if no element is found.

func (*Presence) FindElements

func (e *Presence) FindElements(name string) []Element

FindElements returns all elements identified by name. Returns an empty array if no elements are found.

func (*Presence) FindElementsNamespace

func (e *Presence) FindElementsNamespace(name, namespace string) []Element

FindElementsNamespace returns all elements identified by name and namespace. Returns an empty array if no elements are found.

func (*Presence) ForbiddenError

func (el *Presence) ForbiddenError() Element

ForbiddenError returns an error copy of the element attaching 'forbidden' error sub element.

func (*Presence) From

func (e *Presence) From() string

From returns 'from' node attribute.

func (*Presence) FromBytes

func (e *Presence) FromBytes(r io.Reader)

FromBytes deserializes XML element from it's gob binary representation.

func (*Presence) FromJID

func (p *Presence) FromJID() *JID

FromJID returns presence 'from' JID value.

func (*Presence) GoneError

func (el *Presence) GoneError() Element

GoneError returns an error copy of the element attaching 'gone' error sub element.

func (*Presence) ID

func (e *Presence) ID() string

ID returns 'id' node attribute.

func (*Presence) InternalServerError

func (el *Presence) InternalServerError() Element

InternalServerError returns an error copy of the element attaching 'internal-server-error' error sub element.

func (*Presence) IsAvailable

func (p *Presence) IsAvailable() bool

IsAvailable returns true if this is an 'available' type Presence.

func (*Presence) IsError

func (e *Presence) IsError() bool

IsError returns true if element has a 'type' attribute of value 'error'.

func (*Presence) IsSubscribe

func (p *Presence) IsSubscribe() bool

IsSubscribe returns true if this is a 'subscribe' type Presence.

func (*Presence) IsSubscribed

func (p *Presence) IsSubscribed() bool

IsSubscribed returns true if this is a 'subscribed' type Presence.

func (*Presence) IsUnavailable

func (p *Presence) IsUnavailable() bool

IsUnavailable returns true if this is an 'unavailable' type Presence.

func (*Presence) IsUnsubscribe

func (p *Presence) IsUnsubscribe() bool

IsUnsubscribe returns true if this is an 'unsubscribe' type Presence.

func (*Presence) IsUnsubscribed

func (p *Presence) IsUnsubscribed() bool

IsUnsubscribed returns true if this is an 'unsubscribed' type Presence.

func (*Presence) ItemNotFoundError

func (el *Presence) ItemNotFoundError() Element

ItemNotFoundError returns an error copy of the element attaching 'item-not-found' error sub element.

func (*Presence) JidMalformedError

func (el *Presence) JidMalformedError() Element

JidMalformedError returns an error copy of the element attaching 'jid-malformed' error sub element.

func (*Presence) Language

func (e *Presence) Language() string

Language returns 'xml:lang' node attribute.

func (*Presence) Name

func (e *Presence) Name() string

Name returns XML node name.

func (*Presence) Namespace

func (e *Presence) Namespace() string

Namespace returns 'xmlns' node attribute.

func (*Presence) NotAcceptableError

func (el *Presence) NotAcceptableError() Element

NotAcceptableError returns an error copy of the element attaching 'not-acceptable' error sub element.

func (*Presence) NotAllowedError

func (el *Presence) NotAllowedError() Element

NotAllowedError returns an error copy of the element attaching 'not-allowed' error sub element.

func (*Presence) NotAuthorizedError

func (el *Presence) NotAuthorizedError() Element

NotAuthorizedError returns an error copy of the element attaching 'not-authorized' error sub element.

func (*Presence) PaymentRequiredError

func (el *Presence) PaymentRequiredError() Element

PaymentRequiredError returns an error copy of the element attaching 'payment-required' error sub element.

func (*Presence) Priority

func (p *Presence) Priority() int8

Priority returns presence stanza priority value.

func (*Presence) RecipientUnavailableError

func (el *Presence) RecipientUnavailableError() Element

RecipientUnavailableError returns an error copy of the element attaching 'recipient-unavailable' error sub element.

func (*Presence) RedirectError

func (el *Presence) RedirectError() Element

RedirectError returns an error copy of the element attaching 'redirect' error sub element.

func (*Presence) RegistrationRequiredError

func (el *Presence) RegistrationRequiredError() Element

RegistrationRequiredError returns an error copy of the element attaching 'registration-required' error sub element.

func (*Presence) RemoteServerNotFoundError

func (el *Presence) RemoteServerNotFoundError() Element

RemoteServerNotFoundError returns an error copy of the element attaching 'remote-server-not-found' error sub element.

func (*Presence) RemoteServerTimeoutError

func (el *Presence) RemoteServerTimeoutError() Element

RemoteServerNotFoundError returns an error copy of the element attaching 'remote-server-timeout' error sub element.

func (*Presence) ResourceConstraintError

func (el *Presence) ResourceConstraintError() Element

ResourceConstraintError returns an error copy of the element attaching 'resource-constraint' error sub element.

func (*Presence) ServiceUnavailableError

func (el *Presence) ServiceUnavailableError() Element

ServiceUnavailableError returns an error copy of the element attaching 'service-unavailable' error sub element.

func (*Presence) SetFromJID

func (p *Presence) SetFromJID(from *JID)

SetFromJID sets the presence 'from' JID value.

func (*Presence) SetToJID

func (p *Presence) SetToJID(to *JID)

SetToJID sets the presence 'to' JID value.

func (*Presence) ShowState

func (p *Presence) ShowState() ShowState

ShowState returns presence stanza show state.

func (*Presence) String

func (e *Presence) String() string

String returns a string representation of the element.

func (*Presence) SubscriptionRequiredError

func (el *Presence) SubscriptionRequiredError() Element

SubscriptionRequiredError returns an error copy of the element attaching 'subscription-required' error sub element.

func (*Presence) Text

func (e *Presence) Text() string

Text returns XML node text value. Returns an empty string if not set.

func (*Presence) TextLen

func (e *Presence) TextLen() int

TextLen returns XML node text value length.

func (*Presence) To

func (e *Presence) To() string

To returns 'to' node attribute.

func (*Presence) ToBytes

func (e *Presence) ToBytes(w io.Writer)

ToBytes serializes XML element to it's gob binary representation.

func (*Presence) ToError

func (el *Presence) ToError(stanzaError *StanzaError) Element

ToError returns an error copy element attaching stanza error sub element.

func (*Presence) ToJID

func (p *Presence) ToJID() *JID

ToJID returns presence 'to' JID value.

func (*Presence) ToXML

func (e *Presence) ToXML(w io.Writer, includeClosing bool)

ToXML serializes element to a raw XML representation. includeClosing determines if closing tag should be attached.

func (*Presence) Type

func (e *Presence) Type() string

Type returns 'type' node attribute.

func (*Presence) UndefinedConditionError

func (el *Presence) UndefinedConditionError() Element

UndefinedConditionError returns an error copy of the element attaching 'undefined-condition' error sub element.

func (*Presence) UnexpectedConditionError

func (el *Presence) UnexpectedConditionError() Element

UnexpectedConditionError returns an error copy of the element attaching 'unexpected-condition' error sub element.

func (*Presence) Version

func (e *Presence) Version() string

Version returns 'version' node attribute.

type ShowState

type ShowState int

ShowState represents Presence show state.

const (
	// AvailableShowState represents 'available' Presence show state.
	AvailableShowState ShowState = iota

	// AwayShowState represents 'away' Presence show state.
	AwayShowState

	// ChatShowState represents 'chat' Presence show state.
	ChatShowState

	// DoNotDisturbShowState represents 'dnd' Presence show state.
	DoNotDisturbShowState

	// ExtendedAwaysShowState represents 'xa' Presence show state.
	ExtendedAwaysShowState
)

type StanzaError

type StanzaError struct {
	// contains filtered or unexported fields
}

StanzaError represents a stanza "error" element.

func (*StanzaError) Element

func (se *StanzaError) Element() Element

Element returns StanzaError equivalent XML element.

func (*StanzaError) Error

func (se *StanzaError) Error() string

Error satisfies error interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL