stanza

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2021 License: BSD-3-Clause Imports: 11 Imported by: 0

README

XMPP Stanza

XMPP stanza package is used to parse, marshal and unmarshal XMPP stanzas and nonzas.

Stanza creation

When creating stanzas, you can use two approaches:

  1. You can create IQ, Presence or Message structs, set the fields and manually prepare extensions struct to add to the stanza.
  2. You can use stanza build helper to be guided when creating the stanza, and have more controls performed on the final stanza.

The methods are equivalent and you can use whatever suits you best. The helpers will finally generate the same type of struct that you can build by hand.

Composing stanzas manually with structs

Here is for example how you would generate an IQ discovery result:

iqResp := stanza.NewIQ(stanza.Attrs{Type: "result", From: iq.To, To: iq.From, Id: iq.Id})
identity := stanza.Identity{
	Name:     opts.Name,
	Category: opts.Category,
	Type:     opts.Type,
}
payload := stanza.DiscoInfo{
	XMLName: xml.Name{
		Space: stanza.NSDiscoInfo,
		Local: "query",
	},
	Identity: []stanza.Identity{identity},
	Features: []stanza.Feature{
		{Var: stanza.NSDiscoInfo},
		{Var: stanza.NSDiscoItems},
		{Var: "jabber:iq:version"},
		{Var: "urn:xmpp:delegation:1"},
	},
}
iqResp.Payload = &payload
Using helpers

Here is for example how you would generate an IQ discovery result using Builder:

iq := stanza.NewIQ(stanza.Attrs{Type: "get", To: "service.localhost", Id: "disco-get-1"})
disco := iq.DiscoInfo()
disco.AddIdentity("Test Component", "gateway", "service")
disco.AddFeatures(stanza.NSDiscoInfo, stanza.NSDiscoItems, "jabber:iq:version", "urn:xmpp:delegation:1")

Payload and extensions

Message

Here is the list of implemented message extensions:

  • Delegation

  • Markable

  • MarkAcknowledged

  • MarkDisplayed

  • MarkReceived

  • StateActive

  • StateComposing

  • StateGone

  • StateInactive

  • StatePaused

  • HTML

  • OOB

  • ReceiptReceived

  • ReceiptRequest

  • Mood

Presence

Here is the list of implemented presence extensions:

  • MucPresence
IQ

IQ (Information Queries) contain a payload associated with the request and possibly an error. The main difference with Message and Presence extension is that you can only have one payload per IQ. The XMPP specification does not support having multiple payloads.

Here is the list of structs implementing IQPayloads:

  • ControlSet
  • ControlSetResponse
  • Delegation
  • DiscoInfo
  • DiscoItems
  • Pubsub
  • Version
  • Node

Finally, when the payload of the parsed stanza is unknown, the parser will provide the unknown payload as a generic Node element. You can also use the Node struct to add custom information on stanza generation. However, in both cases, you may also consider adding your own custom extensions on stanzas.

Adding your own custom extensions on stanzas

Extensions are registered on launch using the Registry. It can be used to register you own custom payload. You may want to do so to support extensions we did not yet implement, or to add your own custom extensions to your XMPP stanzas.

To create an extension you need:

  1. to create a struct for that extension. It need to have XMLName for consistency and to tagged at the struct level with xml info.
  2. It need to implement one or several extensions interface: stanza.IQPayload, stanza.MsgExtension and / or stanza.PresExtension
  3. Add that custom extension to the stanza.TypeRegistry during the file init.

Here an example code showing how to create a custom IQPayload.

package myclient

import (
	"encoding/xml"

	"gosrc.io/xmpp/stanza"
)

type CustomPayload struct {
	XMLName xml.Name `xml:"my:custom:payload query"`
	Node    string   `xml:"node,attr,omitempty"`
}

func (c CustomPayload) Namespace() string {
	return c.XMLName.Space
}

func init() {
	stanza.TypeRegistry.MapExtension(stanza.PKTIQ, xml.Name{"my:custom:payload", "query"}, CustomPayload{})
}

Documentation

Overview

XMPP stanza package is used to parse, marshal and unmarshal XMPP stanzas and nonzas.

Index

Constants

View Source
const (
	CommandActionCancel   = "cancel"
	CommandActionComplete = "complete"
	CommandActionExecute  = "execute"
	CommandActionNext     = "next"
	CommandActionPrevious = "prev"

	CommandStatusCancelled = "canceled"
	CommandStatusCompleted = "completed"
	CommandStatusExecuting = "executing"

	CommandNoteTypeErr  = "error"
	CommandNoteTypeInfo = "info"
	CommandNoteTypeWarn = "warn"
)
View Source
const (
	FormTypeCancel = "cancel"
	FormTypeForm   = "form"
	FormTypeResult = "result"
	FormTypeSubmit = "submit"
)
View Source
const (
	FieldTypeBool        = "boolean"
	FieldTypeFixed       = "fixed"
	FieldTypeHidden      = "hidden"
	FieldTypeJidMulti    = "jid-multi"
	FieldTypeJidSingle   = "jid-single"
	FieldTypeListMulti   = "list-multi"
	FieldTypeListSingle  = "list-single"
	FieldTypeTextMulti   = "text-multi"
	FieldTypeTextPrivate = "text-private"
	FieldTypeTextSingle  = "text-Single"
)
View Source
const (
	// NSRoster is the Roster IQ namespace
	NSRoster = "jabber:iq:roster"
	// SubscriptionNone indicates the user does not have a subscription to
	// the contact's presence, and the contact does not have a subscription
	// to the user's presence; this is the default value, so if the subscription
	// attribute is not included then the state is to be understood as "none"
	SubscriptionNone = "none"

	// SubscriptionTo indicates the user has a subscription to the contact's
	// presence, but the contact does not have a subscription to the user's presence.
	SubscriptionTo = "to"

	// SubscriptionFrom indicates the contact has a subscription to the user's
	// presence, but the user does not have a subscription to the contact's presence
	SubscriptionFrom = "from"

	// SubscriptionBoth indicates the user and the contact have subscriptions to each
	// other's presence (also called a "mutual subscription")
	SubscriptionBoth = "both"
)
View Source
const (
	NSStream = "http://etherx.jabber.org/streams"

	NSSASL      = "urn:ietf:params:xml:ns:xmpp-sasl"
	NSBind      = "urn:ietf:params:xml:ns:xmpp-bind"
	NSSession   = "urn:ietf:params:xml:ns:xmpp-session"
	NSFraming   = "urn:ietf:params:xml:ns:xmpp-framing"
	NSClient    = "jabber:client"
	NSComponent = "jabber:component:accept"
)
View Source
const (
	AffiliationStatusMember      = "member"
	AffiliationStatusNone        = "none"
	AffiliationStatusOutcast     = "outcast"
	AffiliationStatusOwner       = "owner"
	AffiliationStatusPublisher   = "publisher"
	AffiliationStatusPublishOnly = "publish-only"
)
View Source
const (
	SubscriptionStatusNone         = "none"
	SubscriptionStatusPending      = "pending"
	SubscriptionStatusSubscribed   = "subscribed"
	SubscriptionStatusUnconfigured = "unconfigured"
)
View Source
const Assoc = "Associate"

********************* Associate *********************

View Source
const Disassoc = "Disassociate"

********************* Disassociate *********************

View Source
const (
	// NSDiscoInfo defines the namespace for disco IQ stanzas
	NSDiscoInfo = "http://jabber.org/protocol/disco#info"
)
View Source
const (
	NSDiscoItems = "http://jabber.org/protocol/disco#items"
)
View Source
const NSMsgChatMarkers = "urn:xmpp:chat-markers:0"
View Source
const NSMsgChatStateNotifications = "http://jabber.org/protocol/chatstates"
View Source
const NSMsgReceipts = "urn:xmpp:receipts"
View Source
const (
	// Common but not only possible namespace for query blocks in a result set context
	NSQuerySet = "jabber:iq:search"
)

Support for XEP-0059 See https://xmpp.org/extensions/xep-0059

View Source
const (
	NSStreamManagement = "urn:xmpp:sm:3"
)
View Source
const PubSubCollectionEventName = "Collection"
View Source
const PubSubConfigEventName = "Configuration"
View Source
const PubSubDeleteEventName = "Delete"

********************* Delete *********************

View Source
const PubSubItemsEventName = "List"
View Source
const PubSubPurgeEventName = "Purge"

********************* Purge *********************

View Source
const PubSubSubscriptionEventName = "Subscription"

********************* Subscription *********************

View Source
const StreamClose = "</stream:stream>"

Variables

View Source
var (
	IqTypeUnset  = errors.New("iq type is not set but is mandatory")
	IqIDUnset    = errors.New("iq stanza ID is not set but is mandatory")
	IqSGetNoPl   = errors.New("iq is of type get or set but has no payload")
	IqResNoPl    = errors.New("iq is of type result but has no payload")
	IqErrNoErrPl = errors.New("iq is of type error but has no error payload")
)
View Source
var InvalidDateInput = errors.New("could not parse date. Input might not be in a supported format")
View Source
var InvalidDateOutput = errors.New("could not format date as desired")
View Source
var TypeRegistry = newRegistry()

Functions

func InitStream

func InitStream(p *xml.Decoder) (sessionID string, err error)

Reads and checks the opening XMPP stream element. TODO It returns a stream structure containing:

  • Host: You can check the host against the host you were expecting to connect to
  • Id: the Stream ID is a temporary shared secret used for some hash calculation. It is also used by ProcessOne reattach features (allowing to resume an existing stream at the point the connection was interrupted, without getting through the authentication process.

TODO We should handle stream error from XEP-0114 ( <conflict/> or <host-unknown/> )

func NextStart

func NextStart(p *xml.Decoder) (xml.StartElement, error)

NextStart scans XML token stream to find next StartElement.

func NextXmppToken

func NextXmppToken(p *xml.Decoder) (xml.Token, error)

NextXmppToken scans XML token stream to find next StartElement or stream EndElement. We need the EndElement scan, because we must register stream close tags

Types

type Actions

type Actions struct {
	Prev     *struct{} `xml:"prev,omitempty"`
	Next     *struct{} `xml:"next,omitempty"`
	Complete *struct{} `xml:"complete,omitempty"`

	Execute string `xml:"execute,attr,omitempty"`
}

func (*Actions) Ref

func (a *Actions) Ref() string

type Affiliation

type Affiliation struct {
	AffiliationStatus string `xml:"affiliation"`
	Node              string `xml:"node,attr"`
}

type AffiliationOwner

type AffiliationOwner struct {
	XMLName           xml.Name `xml:"affiliation"`
	AffiliationStatus string   `xml:"affiliation,attr"`
	Jid               string   `xml:"jid,attr"`
}

type Affiliations

type Affiliations struct {
	List []Affiliation `xml:"affiliation"`
	Node string        `xml:"node,attr,omitempty"`
}

type AffiliationsOwner

type AffiliationsOwner struct {
	XMLName      xml.Name           `xml:"affiliations"`
	Affiliations []AffiliationOwner `xml:"affiliation,omitempty"`
	Node         string             `xml:"node,attr"`
}

func (AffiliationsOwner) UseCase

func (AffiliationsOwner) UseCase() string

type AssocDisassoc

type AssocDisassoc interface {
	GetAssocDisassoc() string
}

********************* Associate/Disassociate *********************

type AssociateEvent

type AssociateEvent struct {
	XMLName xml.Name `xml:"associate"`
	Node    string   `xml:"node,attr"`
}

func (*AssociateEvent) GetAssocDisassoc

func (a *AssociateEvent) GetAssocDisassoc() string

type Attr

type Attr struct {
	K string
	V string
}

Attr represents generic XML attributes, as used on the generic XML Node representation.

type Attrs

type Attrs struct {
	Type StanzaType `xml:"type,attr,omitempty"`
	Id   string     `xml:"id,attr,omitempty"`
	From string     `xml:"from,attr,omitempty"`
	To   string     `xml:"to,attr,omitempty"`
	Lang string     `xml:"lang,attr,omitempty"`
}

Attrs represents the common structure for base XMPP packets.

type BadFormat

type BadFormat struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas bad-format"`
}

func (*BadFormat) GroupErrorName

func (e *BadFormat) GroupErrorName() string

type BadNamespacePrefix

type BadNamespacePrefix struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas bad-namespace-prefix"`
}

func (*BadNamespacePrefix) GroupErrorName

func (e *BadNamespacePrefix) GroupErrorName() string

type Bind

type Bind struct {
	XMLName  xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-bind bind"`
	Resource string   `xml:"resource,omitempty"`
	Jid      string   `xml:"jid,omitempty"`
	// Result sets
	ResultSet *ResultSet `xml:"set,omitempty"`
}

Bind is an IQ payload used during session negotiation to bind user resource to the current XMPP stream. Reference: https://tools.ietf.org/html/rfc6120#section-7

func (*Bind) GetSet

func (b *Bind) GetSet() *ResultSet

func (*Bind) Namespace

func (b *Bind) Namespace() string

type Caps

type Caps struct {
	XMLName xml.Name `xml:"http://jabber.org/protocol/caps c"`
	Hash    string   `xml:"hash,attr"`
	Node    string   `xml:"node,attr"`
	Ver     string   `xml:"ver,attr"`
	Ext     string   `xml:"ext,attr,omitempty"`
}

Capabilities Reference: https://xmpp.org/extensions/xep-0115.html#stream

"A server MAY include its entity capabilities in a stream feature element so that connecting clients
 and peer servers do not need to send service discovery requests each time they connect."

This is not a stream feature but a way to let client cache server disco info.

type CollectionEvent

type CollectionEvent struct {
	AssocDisassoc AssocDisassoc
	Node          string `xml:"node,attr,omitempty"`
}

func (CollectionEvent) Name

func (c CollectionEvent) Name() string

type Command

type Command struct {
	XMLName xml.Name `xml:"http://jabber.org/protocol/commands command"`

	CommandElement CommandElement

	BadAction       *struct{} `xml:"bad-action,omitempty"`
	BadLocale       *struct{} `xml:"bad-locale,omitempty"`
	BadPayload      *struct{} `xml:"bad-payload,omitempty"`
	BadSessionId    *struct{} `xml:"bad-sessionid,omitempty"`
	MalformedAction *struct{} `xml:"malformed-action,omitempty"`
	SessionExpired  *struct{} `xml:"session-expired,omitempty"`

	// Attributes
	Action    string `xml:"action,attr,omitempty"`
	Node      string `xml:"node,attr"`
	SessionId string `xml:"sessionid,attr,omitempty"`
	Status    string `xml:"status,attr,omitempty"`
	Lang      string `xml:"lang,attr,omitempty"`

	// Result sets
	ResultSet *ResultSet `xml:"set,omitempty"`
}

func (*Command) GetSet

func (c *Command) GetSet() *ResultSet

func (*Command) Namespace

func (c *Command) Namespace() string

func (*Command) UnmarshalXML

func (c *Command) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type CommandElement

type CommandElement interface {
	Ref() string
}

type ConfigurationEvent

type ConfigurationEvent struct {
	Node string `xml:"node,attr,omitempty"`
	Form *Form
}

func (ConfigurationEvent) Name

func (c ConfigurationEvent) Name() string

type Configure

type Configure struct {
	Form *Form `xml:"x"`
}

type ConfigureOwner

type ConfigureOwner struct {
	XMLName xml.Name `xml:"configure"`
	Node    string   `xml:"node,attr,omitempty"`
	Form    *Form    `xml:"x,omitempty"`
}

func (*ConfigureOwner) UseCase

func (*ConfigureOwner) UseCase() string

type Conflict

type Conflict struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas conflict"`
}

func (*Conflict) GroupErrorName

func (e *Conflict) GroupErrorName() string

type ConnectionTimeout

type ConnectionTimeout struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas connection-timeout"`
}

func (*ConnectionTimeout) GroupErrorName

func (e *ConnectionTimeout) GroupErrorName() string

type ControlField

type ControlField struct {
	XMLName xml.Name
	Name    string `xml:"name,attr,omitempty"`
	Value   string `xml:"value,attr,omitempty"`
}

type ControlGetForm

type ControlGetForm struct {
	XMLName xml.Name `xml:"urn:xmpp:iot:control getForm"`
}

type ControlSet

type ControlSet struct {
	XMLName xml.Name       `xml:"urn:xmpp:iot:control set"`
	Fields  []ControlField `xml:",any"`
	// Result sets
	ResultSet *ResultSet `xml:"set,omitempty"`
}

func (*ControlSet) GetSet

func (c *ControlSet) GetSet() *ResultSet

func (*ControlSet) Namespace

func (c *ControlSet) Namespace() string

type ControlSetResponse

type ControlSetResponse struct {
	XMLName xml.Name `xml:"urn:xmpp:iot:control setResponse"`
}

func (*ControlSetResponse) GetSet

func (c *ControlSetResponse) GetSet() *ResultSet

func (*ControlSetResponse) Namespace

func (c *ControlSetResponse) Namespace() string

type Create

type Create struct {
	Node string `xml:"node,attr,omitempty"`
}

type Default

type Default struct {
	Node string `xml:"node,attr,omitempty"`
	Type string `xml:"type,attr,omitempty"`
	Form *Form  `xml:"x"`
}

type DefaultOwner

type DefaultOwner struct {
	XMLName xml.Name `xml:"default"`
	Form    *Form    `xml:"x,omitempty"`
}

func (*DefaultOwner) UseCase

func (*DefaultOwner) UseCase() string

type Delegated

type Delegated struct {
	XMLName   xml.Name `xml:"delegated"`
	Namespace string   `xml:"namespace,attr,omitempty"`
}

type Delegation

type Delegation struct {
	MsgExtension
	XMLName   xml.Name   `xml:"urn:xmpp:delegation:1 delegation"`
	Forwarded *Forwarded // This is used in iq to wrap delegated iqs
	Delegated *Delegated // This is used in a message to confirm delegated namespace
	// Result sets
	ResultSet *ResultSet `xml:"set,omitempty"`
}

Delegation can be used both on message (for delegated) and IQ (for Forwarded), depending on the context.

func (*Delegation) GetSet

func (d *Delegation) GetSet() *ResultSet

func (*Delegation) Namespace

func (d *Delegation) Namespace() string

type DeleteEvent

type DeleteEvent struct {
	Node     string         `xml:"node,attr"`
	Redirect *RedirectEvent `xml:"redirect"`
}

func (DeleteEvent) Name

func (c DeleteEvent) Name() string

type DeleteOwner

type DeleteOwner struct {
	XMLName       xml.Name       `xml:"delete"`
	RedirectOwner *RedirectOwner `xml:"redirect,omitempty"`
	Node          string         `xml:"node,attr,omitempty"`
}

func (*DeleteOwner) UseCase

func (*DeleteOwner) UseCase() string

type DisassociateEvent

type DisassociateEvent struct {
	XMLName xml.Name `xml:"disassociate"`
	Node    string   `xml:"node,attr"`
}

func (*DisassociateEvent) GetAssocDisassoc

func (e *DisassociateEvent) GetAssocDisassoc() string

type DiscoInfo

type DiscoInfo struct {
	XMLName   xml.Name   `xml:"http://jabber.org/protocol/disco#info query"`
	Node      string     `xml:"node,attr,omitempty"`
	Identity  []Identity `xml:"identity"`
	Features  []Feature  `xml:"feature"`
	ResultSet *ResultSet `xml:"set,omitempty"`
}

func (*DiscoInfo) AddFeatures

func (d *DiscoInfo) AddFeatures(namespace ...string)

func (*DiscoInfo) AddIdentity

func (d *DiscoInfo) AddIdentity(name, category, typ string)

func (*DiscoInfo) GetSet

func (d *DiscoInfo) GetSet() *ResultSet

func (*DiscoInfo) Namespace

func (d *DiscoInfo) Namespace() string

Namespace lets DiscoInfo implement the IQPayload interface

func (*DiscoInfo) SetFeatures

func (d *DiscoInfo) SetFeatures(namespace ...string) *DiscoInfo

func (*DiscoInfo) SetIdentities

func (d *DiscoInfo) SetIdentities(ident ...Identity) *DiscoInfo

func (*DiscoInfo) SetNode

func (d *DiscoInfo) SetNode(node string) *DiscoInfo

type DiscoItem

type DiscoItem struct {
	XMLName xml.Name `xml:"item"`
	JID     string   `xml:"jid,attr,omitempty"`
	Node    string   `xml:"node,attr,omitempty"`
	Name    string   `xml:"name,attr,omitempty"`
}

type DiscoItems

type DiscoItems struct {
	XMLName xml.Name    `xml:"http://jabber.org/protocol/disco#items query"`
	Node    string      `xml:"node,attr,omitempty"`
	Items   []DiscoItem `xml:"item"`

	// Result sets
	ResultSet *ResultSet `xml:"set,omitempty"`
}

func (*DiscoItems) AddItem

func (d *DiscoItems) AddItem(jid, node, name string) *DiscoItems

func (*DiscoItems) GetSet

func (d *DiscoItems) GetSet() *ResultSet

func (*DiscoItems) Namespace

func (d *DiscoItems) Namespace() string

func (*DiscoItems) SetNode

func (d *DiscoItems) SetNode(node string) *DiscoItems

type Err

type Err struct {
	XMLName xml.Name  `xml:"error"`
	Code    int       `xml:"code,attr,omitempty"`
	Type    ErrorType `xml:"type,attr"` // required
	Reason  string
	Text    string `xml:"urn:ietf:params:xml:ns:xmpp-stanzas text,omitempty"`
}

Err is an XMPP stanza payload that is used to report error on message, presence or iq stanza. It is intended to be added in the payload of the erroneous stanza.

func (Err) MarshalXML

func (x Err) MarshalXML(e *xml.Encoder, start xml.StartElement) (err error)

func (*Err) UnmarshalXML

func (x *Err) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML implements custom parsing for XMPP errors

type ErrorType

type ErrorType string

ErrorType is a Enum of error attribute type

const (
	ErrorTypeAuth     ErrorType = "auth"
	ErrorTypeCancel   ErrorType = "cancel"
	ErrorTypeContinue ErrorType = "continue"
	ErrorTypeModify   ErrorType = "modify"
	ErrorTypeWait     ErrorType = "wait"
)

RFC 6120: part of A.5 Client Namespace and A.6 Server Namespace

type EventElement

type EventElement interface {
	Name() string
}

type Feature

type Feature struct {
	XMLName xml.Name `xml:"feature"`
	Var     string   `xml:"var,attr"`
}

type Field

type Field struct {
	XMLName     xml.Name `xml:"field"`
	Description string   `xml:"desc,omitempty"`
	Required    *string  `xml:"required"`
	ValuesList  []string `xml:"value"`
	Options     []Option `xml:"option,omitempty"`
	Var         string   `xml:"var,attr,omitempty"`
	Type        string   `xml:"type,attr,omitempty"`
	Label       string   `xml:"label,attr,omitempty"`
}

type FieldType

type FieldType string

type FifoQueue

type FifoQueue interface {
	// Pop returns the first inserted element still in queue and deletes it from queue. If queue is empty, returns nil
	// No guarantee regarding thread safety !
	Pop() Queueable

	// PopN returns the N first inserted elements still in queue and deletes them from queue. If queue is empty or i<=0, returns nil
	// If number to pop is greater than queue length, returns all queue elements
	// No guarantee regarding thread safety !
	PopN(i int) []Queueable

	// Peek returns a copy of the first inserted element in queue without deleting it. If queue is empty, returns nil
	// No guarantee regarding thread safety !
	Peek() Queueable

	// Peek returns a copy of the first inserted element in queue without deleting it. If queue is empty or i<=0, returns nil.
	// If number to peek is greater than queue length, returns all queue elements
	// No guarantee regarding thread safety !
	PeekN() []Queueable
	// Push adds an element to the queue
	// No guarantee regarding thread safety !
	Push(s Queueable) error

	// Empty returns true if queue is empty
	// No guarantee regarding thread safety !
	Empty() bool
}

FIFO queue for string contents Implementations have no guarantee regarding thread safety !

type First

type First struct {
	XMLName xml.Name `xml:"first"`
	Content string
	Index   *int `xml:"index,attr,omitempty"`
}

type Form

type Form struct {
	XMLName      xml.Name   `xml:"jabber:x:data x"`
	Instructions []string   `xml:"instructions"`
	Title        string     `xml:"title,omitempty"`
	Fields       []*Field   `xml:"field,omitempty"`
	Reported     *FormItem  `xml:"reported"`
	Items        []FormItem `xml:"item,omitempty"`
	Type         string     `xml:"type,attr"`
}

See XEP-0004 and XEP-0068 Pointer semantics

func NewForm

func NewForm(fields []*Field, formType string) *Form

func (*Form) Ref

func (f *Form) Ref() string

type FormItem

type FormItem struct {
	XMLName xml.Name
	Fields  []Field `xml:"field,omitempty"`
}

type FormType

type FormType string

type Forwarded

type Forwarded struct {
	XMLName xml.Name `xml:"urn:xmpp:forward:0 forwarded"`
	Stanza  Packet
}

Forwarded is used to wrapped forwarded stanzas. TODO: Move it in another file, as it is not limited to components.

func (*Forwarded) UnmarshalXML

func (f *Forwarded) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML is a custom unmarshal function used by xml.Unmarshal to transform generic XML content into hierarchical Node structure.

type HTML

type HTML struct {
	MsgExtension
	XMLName xml.Name `xml:"http://jabber.org/protocol/xhtml-im html"`
	Body    HTMLBody
	Lang    string `xml:"xml:lang,attr,omitempty"`
}

type HTMLBody

type HTMLBody struct {
	XMLName xml.Name `xml:"http://www.w3.org/1999/xhtml body"`
	// InnerXML MUST be valid xhtml. We do not check if it is valid when generating the XMPP stanza.
	InnerXML string `xml:",innerxml"`
}

type Handshake

type Handshake struct {
	XMLName xml.Name `xml:"jabber:component:accept handshake"`
	// TODO Add handshake value with test for proper serialization
	Value string `xml:",innerxml"`
}

Handshake is a stanza used by XMPP components to authenticate on XMPP component port.

func (Handshake) Name

func (Handshake) Name() string

type HintNoCopy

type HintNoCopy struct {
	MsgExtension
	XMLName xml.Name `xml:"urn:xmpp:hints no-copy"`
}

type HintNoPermanentStore

type HintNoPermanentStore struct {
	MsgExtension
	XMLName xml.Name `xml:"urn:xmpp:hints no-permanent-store"`
}

type HintNoStore

type HintNoStore struct {
	MsgExtension
	XMLName xml.Name `xml:"urn:xmpp:hints no-store"`
}

type HintStore

type HintStore struct {
	MsgExtension
	XMLName xml.Name `xml:"urn:xmpp:hints store"`
}

type History

type History struct {
	XMLName    xml.Name
	MaxChars   NullableInt `xml:"maxchars,attr,omitempty"`
	MaxStanzas NullableInt `xml:"maxstanzas,attr,omitempty"`
	Seconds    NullableInt `xml:"seconds,attr,omitempty"`
	Since      time.Time   `xml:"since,attr,omitempty"`
}

History implements XEP-0045: Multi-User Chat - 19.1

func (History) MarshalXML

func (h History) MarshalXML(e *xml.Encoder, start xml.StartElement) (err error)

func (*History) UnmarshalXML

func (h *History) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML implements custom parsing for history element

type HostGone

type HostGone struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas host-gone"`
}

func (*HostGone) GroupErrorName

func (e *HostGone) GroupErrorName() string

type HostUnknown

type HostUnknown struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas host-unknown"`
}

func (*HostUnknown) GroupErrorName

func (e *HostUnknown) GroupErrorName() string

type IQ

type IQ struct {
	XMLName xml.Name `xml:"iq"`
	// MUST have a ID
	Attrs
	// We can only have one payload on IQ:
	//   "An IQ stanza of type "get" or "set" MUST contain exactly one
	//    child element, which specifies the semantics of the particular
	//    request."
	Payload IQPayload `xml:",omitempty"`
	Error   *Err      `xml:"error,omitempty"`
	// Any is used to decode unknown payload as a generic structure
	Any *Node `xml:",any"`
}

IQ implements RFC 6120 - A.5 Client Namespace (a part)

func NewAffiliationListRequest

func NewAffiliationListRequest(serviceId, nodeID string) (*IQ, error)

NewAffiliationListRequest creates a request to list all affiliated entities See 8.9.1 Retrieve List List

func NewApprovePendingSubRequest

func NewApprovePendingSubRequest(serviceId, sessionId, nodeId string) (*IQ, error)

NewGetPendingSubRequests creates a new request for all pending subscriptions to be approved on a given node Upon receiving the data form for managing subscription requests, the owner then MAY request pending subscription approval requests for a given node. See 8.7.4 Per-Node Request

func NewConfigureNode

func NewConfigureNode(serviceId, nodeName string) (*IQ, error)

NewConfigureNode creates a request to configure a node on the given service. A form will be returned by the service, to which the user must respond using for instance the NewFormSubmission function. See 8.2 Configure a Node

func NewCreateAndConfigNode

func NewCreateAndConfigNode(serviceId, nodeID string, confForm *Form) (*IQ, error)

NewCreateAndConfigNode makes a request for node creation that has the desired node configuration. See 8.1.3 Create and Configure a Node

func NewCreateNode

func NewCreateNode(serviceId, nodeName string) (*IQ, error)

NewCreateNode builds a request to create a node on the service referenced by "serviceId" See 8.1 Create a Node

func NewDelItemFromNode

func NewDelItemFromNode(serviceId, nodeID, itemId string, notify *bool) (*IQ, error)

NewDelItemFromNode creates a request to delete and item from a node, given its id. To delete an item, the publisher sends a retract request. This helper function follows 7.2 Delete an Item from a Node

func NewDelNode

func NewDelNode(serviceId, nodeID string) (*IQ, error)

NewDelNode creates a request to delete node "nodeID" from the "serviceId" service See 8.4 Delete a Node

func NewFormSubmission

func NewFormSubmission(serviceId string, subInfo SubInfo, form *Form) (*IQ, error)

NewFormSubmission builds a form submission pubsub IQ Information about the subscription and the requester are separated. subInfo contains information about the subscription. 6.3.5 Form Submission

func NewFormSubmissionOwner

func NewFormSubmissionOwner(serviceId, nodeName string, fields []*Field) (*IQ, error)

NewFormSubmission builds a form submission pubsub IQ, in the Owner namespace This is typically used to respond to a form issued by the server when configuring a node. See 8.2.4 Form Submission

func NewGetPendingSubRequests

func NewGetPendingSubRequests(serviceId string) (*IQ, error)

NewGetPendingSubRequests creates a new request for all pending subscriptions to all their nodes at a service This feature MUST be implemented using the Ad-Hoc Commands (XEP-0050) protocol 8.7 Process Pending Subscription Requests

func NewIQ

func NewIQ(a Attrs) (*IQ, error)

func NewItemsRequest

func NewItemsRequest(serviceId string, node string, maxItems int) (*IQ, error)

NewItemsRequest creates a request to query existing items from a node. Specify a "maxItems" value to request only the last maxItems items. If 0, requests all items. 6.5.2 Requesting All List AND 6.5.7 Requesting the Most Recent List

func NewModifAffiliationRequest

func NewModifAffiliationRequest(serviceId, nodeID string, newAffils []AffiliationOwner) (*IQ, error)

NewModifAffiliationRequest creates a request to either modify one or more affiliations, or delete one or more affiliations 8.9.2 Modify Affiliation & 8.9.2.4 Multiple Simultaneous Modifications & 8.9.3 Delete an Entity (just set the status to "none")

func NewPublishItemOptsRq

func NewPublishItemOptsRq(serviceId, nodeID string, items []Item, options *PublishOptions) (*IQ, error)

NewPublishItemOptsRq creates a request to publish items to a node identified by its provided ID, along with configuration options A pubsub service MAY support the ability to specify options along with a publish request (if so, it MUST advertise support for the "http://jabber.org/protocol/pubsub#publish-options" feature).

func NewPublishItemRq

func NewPublishItemRq(serviceId, nodeID, pubItemID string, item Item) (*IQ, error)

NewPublishItemRq creates a request to publish a single item to a node identified by its provided ID

func NewPurgeAllItems

func NewPurgeAllItems(serviceId, nodeId string) (*IQ, error)

NewPurgeAllItems creates a new purge request for the "nodeId" node, at "serviceId" service See 8.5 Purge All Node Items

func NewRequestDefaultConfig

func NewRequestDefaultConfig(serviceId string) (*IQ, error)

NewRequestDefaultConfig build a request to ask the service for the default config of its nodes See 8.3 Request Default Node Configuration Options

func NewRetrieveAllAffilsRequest

func NewRetrieveAllAffilsRequest(serviceId string) (*IQ, error)

NewRetrieveAllAffilsRequest builds a request to retrieve all affiliations from all nodes In order to make the request of the service, the requesting entity includes an empty <affiliations/> element with no attributes.

func NewRetrieveAllSubsRequest

func NewRetrieveAllSubsRequest(serviceId string) (*IQ, error)

NewRetrieveAllSubsRequest builds a request to retrieve all subscriptions from all nodes In order to make the request, the requesting entity MUST send an IQ-get whose <pubsub/> child contains an empty <subscriptions/> element with no attributes.

func NewSpecificItemRequest

func NewSpecificItemRequest(serviceId, node, itemId string) (*IQ, error)

NewItemsRequest creates a request to get a specific item from a node. 6.5.8 Requesting a Particular Item

func NewSubAndConfig

func NewSubAndConfig(serviceId string, subInfo SubInfo, form *Form) (*IQ, error)

NewSubAndConfig builds a subscribe request that contains configuration options for the service From XEP-0060 : The <options/> element MUST follow the <subscribe/> element and MUST NOT possess a 'node' attribute or 'jid' attribute, since the value of the <subscribe/> element's 'node' attribute specifies the desired NodeID and the value of the <subscribe/> element's 'jid' attribute specifies the subscriber's JID 6.3.7 Subscribe and Configure

func NewSubListRqPl

func NewSubListRqPl(serviceId, nodeID string) (*IQ, error)

NewSubListRequest creates a request to list subscriptions of the client, for all nodes at the service. It's a Get type IQ 8.8.1 Retrieve Subscriptions

func NewSubOptsRq

func NewSubOptsRq(serviceId string, subInfo SubInfo) (*IQ, error)

NewSubOptsRq builds a request for the subscription options. It's a Get type IQ Information about the subscription and the requester are separated. subInfo contains information about the subscription. 6.3 Configure Subscription Options

func NewSubRq

func NewSubRq(serviceId string, subInfo SubInfo) (*IQ, error)

NewSubRq builds a subscription request to a node at the given service. It's a Set type IQ. Information about the subscription and the requester are separated. subInfo contains information about the subscription. 6.1 Subscribe to a Node

func NewSubsForEntitiesRequest

func NewSubsForEntitiesRequest(serviceId, nodeID string, subs []SubscriptionOwner) (*IQ, error)

func NewUnsubRq

func NewUnsubRq(serviceId string, subInfo SubInfo) (*IQ, error)

NewUnsubRq builds an unsub request to a node at the given service. It's a Set type IQ Information about the subscription and the requester are separated. subInfo contains information about the subscription. 6.2 Unsubscribe from a Node

func (*IQ) DiscoInfo

func (iq *IQ) DiscoInfo() *DiscoInfo

DiscoInfo builds a default DiscoInfo payload

func (*IQ) DiscoItems

func (iq *IQ) DiscoItems() *DiscoItems

DiscoItems builds a default DiscoItems payload

func (*IQ) GetFormFields

func (iq *IQ) GetFormFields() (map[string]*Field, error)

GetFormFields gets the fields from a form in a IQ stanza of type result, as a map. Key is the "var" attribute of the field, and field is the value. The user can then select and modify the fields they want to alter, and submit a new form to the service using the NewFormSubmission function to build the IQ. TODO : remove restriction on IQ type ?

func (*IQ) IsValid

func (iq *IQ) IsValid() (bool, error)

IsValid checks if the IQ is valid. If not, return an error with the reason as a message Following RFC-3920 for IQs

func (*IQ) MakeError

func (iq *IQ) MakeError(xerror Err) *IQ

func (*IQ) Name

func (*IQ) Name() string

func (*IQ) NoOp

func (*IQ) NoOp()

NoOp to implement BiDirIteratorElt

func (*IQ) RosterIQ

func (iq *IQ) RosterIQ() *Roster

RosterIQ builds a default Roster payload

func (*IQ) RosterItems

func (iq *IQ) RosterItems() *RosterItems

RosterItems builds a default RosterItems payload

func (*IQ) UnmarshalXML

func (iq *IQ) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML implements custom parsing for IQs

func (*IQ) Version

func (iq *IQ) Version() *Version

Version builds a default software version payload

type IQPayload

type IQPayload interface {
	Namespace() string
	GetSet() *ResultSet
}

type Identity

type Identity struct {
	XMLName  xml.Name `xml:"identity,omitempty"`
	Name     string   `xml:"name,attr,omitempty"`
	Category string   `xml:"category,attr,omitempty"`
	Type     string   `xml:"type,attr,omitempty"`
}

type ImproperAddressing

type ImproperAddressing struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas improper-addressing"`
}

func (*ImproperAddressing) GroupErrorName

func (e *ImproperAddressing) GroupErrorName() string

type InternalServerError

type InternalServerError struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas internal-server-error"`
}

func (*InternalServerError) GroupErrorName

func (e *InternalServerError) GroupErrorName() string

type InvalidForm

type InvalidForm struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas invalid-from"`
}

func (*InvalidForm) GroupErrorName

func (e *InvalidForm) GroupErrorName() string

type InvalidId

type InvalidId struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas invalid-id"`
}

func (*InvalidId) GroupErrorName

func (e *InvalidId) GroupErrorName() string

type InvalidNamespace

type InvalidNamespace struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas invalid-namespace"`
}

func (*InvalidNamespace) GroupErrorName

func (e *InvalidNamespace) GroupErrorName() string

type InvalidXML

type InvalidXML struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas invalid-xml"`
}

func (*InvalidXML) GroupErrorName

func (e *InvalidXML) GroupErrorName() string

type Item

type Item struct {
	XMLName   xml.Name `xml:"item"`
	Id        string   `xml:"id,attr,omitempty"`
	Publisher string   `xml:"publisher,attr,omitempty"`
	Any       *Node    `xml:",any"`
}

type ItemEvent

type ItemEvent struct {
	XMLName   xml.Name `xml:"item"`
	Id        string   `xml:"id,attr,omitempty"`
	Publisher string   `xml:"publisher,attr,omitempty"`
	Any       *Node    `xml:",any"`
}

type Items

type Items struct {
	List     []Item `xml:"item,omitempty"`
	MaxItems int    `xml:"max_items,attr,omitempty"`
	Node     string `xml:"node,attr"`
	SubId    string `xml:"subid,attr,omitempty"`
}

type ItemsEvent

type ItemsEvent struct {
	XMLName xml.Name      `xml:"items"`
	Items   []ItemEvent   `xml:"item,omitempty"`
	Node    string        `xml:"node,attr"`
	Retract *RetractEvent `xml:"retract"`
}

func (ItemsEvent) Name

func (i ItemsEvent) Name() string

type JabberDate

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

func NewJabberDateFromString

func NewJabberDateFromString(strDate string) (JabberDate, error)

func (JabberDate) DateTimeToString

func (d JabberDate) DateTimeToString(nanos bool) string

func (JabberDate) DateToString

func (d JabberDate) DateToString() string

func (JabberDate) TimeToString

func (d JabberDate) TimeToString(nanos bool) (string, error)

type Jid

type Jid struct {
	Node     string
	Domain   string
	Resource string
}

func NewJid

func NewJid(sjid string) (*Jid, error)

func (*Jid) Bare

func (j *Jid) Bare() string

func (*Jid) Full

func (j *Jid) Full() string

type MarkAcknowledged

type MarkAcknowledged struct {
	MsgExtension
	XMLName xml.Name `xml:"urn:xmpp:chat-markers:0 acknowledged"`
	ID      string   `xml:"id,attr"`
}

type MarkDisplayed

type MarkDisplayed struct {
	MsgExtension
	XMLName xml.Name `xml:"urn:xmpp:chat-markers:0 displayed"`
	ID      string   `xml:"id,attr"`
}

type MarkReceived

type MarkReceived struct {
	MsgExtension
	XMLName xml.Name `xml:"urn:xmpp:chat-markers:0 received"`
	ID      string   `xml:"id,attr"`
}

type Markable

type Markable struct {
	MsgExtension
	XMLName xml.Name `xml:"urn:xmpp:chat-markers:0 markable"`
}

type Message

type Message struct {
	XMLName xml.Name `xml:"message"`
	Attrs

	Subject    string         `xml:"subject,omitempty"`
	Body       string         `xml:"body,omitempty"`
	Thread     string         `xml:"thread,omitempty"`
	Error      Err            `xml:"error,omitempty"`
	Extensions []MsgExtension `xml:",omitempty"`
}

Message implements RFC 6120 - A.5 Client Namespace (a part)

func NewApproveSubRequest

func NewApproveSubRequest(serviceId, reqID string, apprForm *Form) (Message, error)

NewApproveSubRequest creates a new sub approval response to a request from the service to the owner of the node In order to approve the request, the owner shall submit the form and set the "pubsub#allow" field to a value of "1" or "true" For tracking purposes the message MUST reflect the 'id' attribute originally provided in the request. See 8.6 Manage Subscription Requests

func NewMessage

func NewMessage(a Attrs) Message

func (*Message) Get

func (msg *Message) Get(ext MsgExtension) bool

Get search and extracts a specific extension on a message. It receives a pointer to an MsgExtension. It will panic if the caller does not pass a pointer. It will return true if the passed extension is found and set the pointer to the extension passed as parameter to the found extension. It will return false if the extension is not found on the message.

Example usage:

  var oob xmpp.OOB
  if ok := msg.Get(&oob); ok {
    // oob extension has been found
	 }

func (Message) Name

func (Message) Name() string

func (*Message) UnmarshalXML

func (msg *Message) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML implements custom parsing for messages

func (*Message) XMPPFormat

func (msg *Message) XMPPFormat() string

XMPPFormat with all Extensions

type Mood

type Mood struct {
	MsgExtension          // Mood can be added as a message extension
	XMLName      xml.Name `xml:"http://jabber.org/protocol/mood mood"`
	// TODO: Custom parsing to extract mood type from tag name.
	// Note: the list is predefined.
	// Mood type
	Text string `xml:"text,omitempty"`
}

Mood defines data model for XEP-0107 - User Mood See: https://xmpp.org/extensions/xep-0107.html

type MsgExtension

type MsgExtension interface{}

type MucPresence

type MucPresence struct {
	PresExtension
	XMLName  xml.Name `xml:"http://jabber.org/protocol/muc x"`
	Password string   `xml:"password,omitempty"`
	History  History  `xml:"history,omitempty"`
}

MucPresence implements XEP-0045: Multi-User Chat - 19.1

type Node

type Node struct {
	XMLName xml.Name
	Attrs   []xml.Attr `xml:"-"`
	Content string     `xml:",cdata"`
	Nodes   []Node     `xml:",any"`
}

Node is a generic structure to represent XML data. It is used to parse unreferenced or custom stanza payload.

func (Node) MarshalXML

func (n Node) MarshalXML(e *xml.Encoder, start xml.StartElement) (err error)

MarshalXML is a custom XML serializer used by xml.Marshal to serialize a Node structure to XML.

func (*Node) Namespace

func (n *Node) Namespace() string

func (*Node) Ref

func (n *Node) Ref() string

func (*Node) UnmarshalXML

func (n *Node) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML is a custom unmarshal function used by xml.Unmarshal to transform generic XML content into hierarchical Node structure.

type NotAuthorized

type NotAuthorized struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas not-authorized"`
}

func (*NotAuthorized) GroupErrorName

func (e *NotAuthorized) GroupErrorName() string

type NotWellFormed

type NotWellFormed struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas not-well-formed"`
}

func (*NotWellFormed) GroupErrorName

func (e *NotWellFormed) GroupErrorName() string

type Note

type Note struct {
	Text string `xml:",cdata"`
	Type string `xml:"type,attr,omitempty"`
}

func (*Note) Ref

func (n *Note) Ref() string

type NullableInt

type NullableInt struct {
	Value int
	// contains filtered or unexported fields
}

func NewNullableInt

func NewNullableInt(val int) NullableInt

func (NullableInt) Get

func (n NullableInt) Get() (v int, ok bool)

type OOB

type OOB struct {
	MsgExtension
	XMLName xml.Name `xml:"jabber:x:oob x"`
	URL     string   `xml:"url"`
	Desc    string   `xml:"desc,omitempty"`
}

type Option

type Option struct {
	XMLName    xml.Name `xml:"option"`
	Label      string   `xml:"label,attr,omitempty"`
	ValuesList []string `xml:"value"`
}

type OwnerUseCase

type OwnerUseCase interface {
	UseCase() string
}

type Packet

type Packet interface {
	Name() string
}

func NextPacket

func NextPacket(p *xml.Decoder) (Packet, error)

NextPacket scans XML token stream for next complete XMPP stanza. Once the type of stanza has been identified, a structure is created to decode that stanza and returned. TODO Use an interface to return packets interface xmppDecoder TODO make auth and bind use NextPacket instead of directly NextStart

type PacketType

type PacketType uint8
const (
	PKTPresence PacketType = iota
	PKTMessage
	PKTIQ
)

type PolicyViolation

type PolicyViolation struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas policy-violation"`
}

func (*PolicyViolation) GroupErrorName

func (e *PolicyViolation) GroupErrorName() string

type PresExtension

type PresExtension interface{}

type Presence

type Presence struct {
	XMLName xml.Name `xml:"presence"`
	Attrs
	Show       PresenceShow    `xml:"show,omitempty"`
	Status     string          `xml:"status,omitempty"`
	Priority   int8            `xml:"priority,omitempty"` // default: 0
	Error      Err             `xml:"error,omitempty"`
	Extensions []PresExtension `xml:",omitempty"`
}

Presence implements RFC 6120 - A.5 Client Namespace (a part)

func NewPresence

func NewPresence(a Attrs) Presence

func (*Presence) Get

func (pres *Presence) Get(ext PresExtension) bool

Get search and extracts a specific extension on a presence stanza. It receives a pointer to an PresExtension. It will panic if the caller does not pass a pointer. It will return true if the passed extension is found and set the pointer to the extension passed as parameter to the found extension. It will return false if the extension is not found on the presence.

Example usage:

  var muc xmpp.MucPresence
  if ok := msg.Get(&muc); ok {
    // muc presence extension has been found
	 }

func (Presence) Name

func (Presence) Name() string

func (*Presence) UnmarshalXML

func (pres *Presence) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML implements custom parsing for presence stanza

type PresenceShow

type PresenceShow string

PresenceShow is a Enum of presence element show

const (
	PresenceShowAway PresenceShow = "away"
	PresenceShowChat PresenceShow = "chat"
	PresenceShowDND  PresenceShow = "dnd"
	PresenceShowXA   PresenceShow = "xa"
)

RFC 6120: part of A.5 Client Namespace and A.6 Server Namespace

type PubSubEvent

type PubSubEvent struct {
	XMLName xml.Name `xml:"http://jabber.org/protocol/pubsub#event event"`
	MsgExtension
	EventElement EventElement
}

Implementation of the http://jabber.org/protocol/pubsub#event namespace

func (*PubSubEvent) UnmarshalXML

func (pse *PubSubEvent) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type PubSubGeneric

type PubSubGeneric struct {
	XMLName xml.Name `xml:"http://jabber.org/protocol/pubsub pubsub"`

	Create    *Create    `xml:"create,omitempty"`
	Configure *Configure `xml:"configure,omitempty"`

	Subscribe  *SubInfo    `xml:"subscribe,omitempty"`
	SubOptions *SubOptions `xml:"options,omitempty"`

	Publish        *Publish        `xml:"publish,omitempty"`
	PublishOptions *PublishOptions `xml:"publish-options"`

	Affiliations *Affiliations `xml:"affiliations,omitempty"`
	Default      *Default      `xml:"default,omitempty"`

	Items        *Items        `xml:"items,omitempty"`
	Retract      *Retract      `xml:"retract,omitempty"`
	Subscription *Subscription `xml:"subscription,omitempty"`

	Subscriptions *Subscriptions `xml:"subscriptions,omitempty"`
	// To use in responses to sub/unsub for instance
	// Subscription options
	Unsubscribe *SubInfo `xml:"unsubscribe,omitempty"`

	// Result sets
	ResultSet *ResultSet `xml:"set,omitempty"`
}

func (*PubSubGeneric) GetSet

func (p *PubSubGeneric) GetSet() *ResultSet

func (*PubSubGeneric) Namespace

func (p *PubSubGeneric) Namespace() string

type PubSubOption

type PubSubOption struct {
	XMLName xml.Name `xml:"jabber:x:data options"`
	Form    `xml:"x"`
}

type PubSubOwner

type PubSubOwner struct {
	XMLName      xml.Name `xml:"http://jabber.org/protocol/pubsub#owner pubsub"`
	OwnerUseCase OwnerUseCase
	// Result sets
	ResultSet *ResultSet `xml:"set,omitempty"`
}

func (*PubSubOwner) GetSet

func (pso *PubSubOwner) GetSet() *ResultSet

func (*PubSubOwner) Namespace

func (pso *PubSubOwner) Namespace() string

func (*PubSubOwner) UnmarshalXML

func (pso *PubSubOwner) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type Publish

type Publish struct {
	XMLName xml.Name `xml:"publish"`
	Node    string   `xml:"node,attr"`
	Items   []Item   `xml:"item,omitempty"` // xsd says there can be many. See also 12.10 Batch Processing of XEP-0060
}

type PublishOptions

type PublishOptions struct {
	XMLName xml.Name `xml:"publish-options"`
	Form    *Form
}

type PurgeEvent

type PurgeEvent struct {
	XMLName xml.Name `xml:"purge"`
	Node    string   `xml:"node,attr"`
}

func (PurgeEvent) Name

func (p PurgeEvent) Name() string

type PurgeOwner

type PurgeOwner struct {
	XMLName xml.Name `xml:"purge"`
	Node    string   `xml:"node,attr"`
}

func (*PurgeOwner) UseCase

func (*PurgeOwner) UseCase() string

type Queueable

type Queueable interface {
	QueueableName() string
}

type ReceiptReceived

type ReceiptReceived struct {
	MsgExtension
	XMLName xml.Name `xml:"urn:xmpp:receipts received"`
	ID      string   `xml:"id,attr"`
}

type ReceiptRequest

type ReceiptRequest struct {
	MsgExtension
	XMLName xml.Name `xml:"urn:xmpp:receipts request"`
}

Used on outgoing message, to tell the recipient that you are requesting a message receipt / ack.

type RedirectEvent

type RedirectEvent struct {
	URI string `xml:"uri,attr"`
}

********************* Redirect *********************

type RedirectOwner

type RedirectOwner struct {
	XMLName xml.Name `xml:"redirect"`
	URI     string   `xml:"uri,attr"`
}

type RemoteConnectionFailed

type RemoteConnectionFailed struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas remote-connection-failed"`
}

func (*RemoteConnectionFailed) GroupErrorName

func (e *RemoteConnectionFailed) GroupErrorName() string

type Reset

type Reset struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas reset"`
}

func (*Reset) GroupErrorName

func (e *Reset) GroupErrorName() string

type ResourceConstraint

type ResourceConstraint struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas resource-constraint"`
}

func (*ResourceConstraint) GroupErrorName

func (e *ResourceConstraint) GroupErrorName() string

type RestrictedXML

type RestrictedXML struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas restricted-xml"`
}

func (*RestrictedXML) GroupErrorName

func (e *RestrictedXML) GroupErrorName() string

type ResultSet

type ResultSet struct {
	XMLName xml.Name `xml:"http://jabber.org/protocol/rsm set"`
	After   *string  `xml:"after,omitempty"`
	Before  *string  `xml:"before,omitempty"`
	Count   *int     `xml:"count,omitempty"`
	First   *First   `xml:"first,omitempty"`
	Index   *int     `xml:"index,omitempty"`
	Last    *string  `xml:"last,omitempty"`
	Max     *int     `xml:"max,omitempty"`
}

type Retract

type Retract struct {
	XMLName xml.Name `xml:"retract"`
	Node    string   `xml:"node,attr"`
	Notify  *bool    `xml:"notify,attr,omitempty"`
	Items   []Item   `xml:"item"`
}

type RetractEvent

type RetractEvent struct {
	XMLName xml.Name `xml:"retract"`
	ID      string   `xml:"node,attr"`
}

type Roster

type Roster struct {
	XMLName xml.Name `xml:"jabber:iq:roster query"`
	// Result sets
	ResultSet *ResultSet `xml:"set,omitempty"`
}

Roster struct represents Roster IQs

func (*Roster) GetSet

func (r *Roster) GetSet() *ResultSet

func (*Roster) Namespace

func (r *Roster) Namespace() string

Namespace defines the namespace for the RosterIQ

type RosterItem

type RosterItem struct {
	XMLName      xml.Name `xml:"jabber:iq:roster item"`
	Jid          string   `xml:"jid,attr"`
	Ask          string   `xml:"ask,attr,omitempty"`
	Name         string   `xml:"name,attr,omitempty"`
	Subscription string   `xml:"subscription,attr,omitempty"`
	Groups       []string `xml:"group"`
}

RosterItem represents an item in the roster iq

type RosterItems

type RosterItems struct {
	XMLName xml.Name     `xml:"jabber:iq:roster query"`
	Items   []RosterItem `xml:"item"`
	// Result sets
	ResultSet *ResultSet `xml:"set,omitempty"`
}

RosterItems represents the list of items in a roster IQ

func (*RosterItems) AddItem

func (r *RosterItems) AddItem(jid, subscription, ask, name string, groups []string) *RosterItems

AddItem builds an item and ads it to the roster IQ

func (*RosterItems) GetSet

func (r *RosterItems) GetSet() *ResultSet

func (*RosterItems) Namespace

func (r *RosterItems) Namespace() string

Namespace lets RosterItems implement the IQPayload interface

type SASLAuth

type SASLAuth struct {
	XMLName   xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl auth"`
	Mechanism string   `xml:"mechanism,attr"`
	Value     string   `xml:",innerxml"`
}

SASLAuth implements SASL Authentication initiation. Reference: https://tools.ietf.org/html/rfc6120#section-6.4.2

type SASLFailure

type SASLFailure struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl failure"`
	Any     xml.Name // error reason is a subelement
}

SASLFailure

func (SASLFailure) Name

func (SASLFailure) Name() string

type SASLSuccess

type SASLSuccess struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl success"`
}

SASLSuccess implements SASL Success nonza, sent by server as a result of the SASL auth negotiation. Reference: https://tools.ietf.org/html/rfc6120#section-6.4.6

func (SASLSuccess) Name

func (SASLSuccess) Name() string

type SMAnswer

type SMAnswer struct {
	XMLName xml.Name `xml:"urn:xmpp:sm:3 a"`
	H       uint     `xml:"h,attr"`
}

Answer as defined in Stream Management spec Reference: https://xmpp.org/extensions/xep-0198.html#acking

func (SMAnswer) Name

func (SMAnswer) Name() string

type SMEnable

type SMEnable struct {
	XMLName xml.Name `xml:"urn:xmpp:sm:3 enable"`
	Max     *uint    `xml:"max,attr,omitempty"`
	Resume  *bool    `xml:"resume,attr,omitempty"`
}

type SMEnabled

type SMEnabled struct {
	XMLName  xml.Name `xml:"urn:xmpp:sm:3 enabled"`
	Id       string   `xml:"id,attr,omitempty"`
	Location string   `xml:"location,attr,omitempty"`
	Resume   string   `xml:"resume,attr,omitempty"`
	Max      uint     `xml:"max,attr,omitempty"`
}

Enabled as defined in Stream Management spec Reference: https://xmpp.org/extensions/xep-0198.html#enable

func (SMEnabled) Name

func (SMEnabled) Name() string

type SMFailed

type SMFailed struct {
	XMLName xml.Name `xml:"urn:xmpp:sm:3 failed"`
	H       *uint    `xml:"h,attr,omitempty"`

	StreamErrorGroup StanzaErrorGroup
}

Failed as defined in Stream Management spec Reference: https://xmpp.org/extensions/xep-0198.html#acking

func (SMFailed) Name

func (SMFailed) Name() string

func (*SMFailed) UnmarshalXML

func (smf *SMFailed) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type SMRequest

type SMRequest struct {
	XMLName xml.Name `xml:"urn:xmpp:sm:3 r"`
}

Request as defined in Stream Management spec Reference: https://xmpp.org/extensions/xep-0198.html#acking

func (SMRequest) Name

func (SMRequest) Name() string

type SMResume

type SMResume struct {
	XMLName xml.Name `xml:"urn:xmpp:sm:3 resume"`
	PrevId  string   `xml:"previd,attr,omitempty"`
	H       *uint    `xml:"h,attr,omitempty"`
}

Resume as defined in Stream Management spec Reference: https://xmpp.org/extensions/xep-0198.html#acking

func (SMResume) Name

func (SMResume) Name() string

type SMResumed

type SMResumed struct {
	XMLName xml.Name `xml:"urn:xmpp:sm:3 resumed"`
	PrevId  string   `xml:"previd,attr,omitempty"`
	H       *uint    `xml:"h,attr,omitempty"`
}

Resumed as defined in Stream Management spec Reference: https://xmpp.org/extensions/xep-0198.html#acking

func (SMResumed) Name

func (SMResumed) Name() string

type SeeOtherHost

type SeeOtherHost struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas see-other-host"`
}

func (*SeeOtherHost) GroupErrorName

func (e *SeeOtherHost) GroupErrorName() string

type StanzaErrorGroup

type StanzaErrorGroup interface {
	GroupErrorName() string
}

type StanzaType

type StanzaType string
const (
	IQTypeError  StanzaType = "error"
	IQTypeGet    StanzaType = "get"
	IQTypeResult StanzaType = "result"
	IQTypeSet    StanzaType = "set"

	MessageTypeChat      StanzaType = "chat"
	MessageTypeError     StanzaType = "error"
	MessageTypeGroupchat StanzaType = "groupchat"
	MessageTypeHeadline  StanzaType = "headline"
	MessageTypeNormal    StanzaType = "normal" // Default

	PresenceTypeError        StanzaType = "error"
	PresenceTypeProbe        StanzaType = "probe"
	PresenceTypeSubscribe    StanzaType = "subscribe"
	PresenceTypeSubscribed   StanzaType = "subscribed"
	PresenceTypeUnavailable  StanzaType = "unavailable"
	PresenceTypeUnsubscribe  StanzaType = "unsubscribe"
	PresenceTypeUnsubscribed StanzaType = "unsubscribed"
)

RFC 6120: part of A.5 Client Namespace and A.6 Server Namespace

func (StanzaType) IsEmpty

func (s StanzaType) IsEmpty() bool

type StateActive

type StateActive struct {
	MsgExtension
	XMLName xml.Name `xml:"http://jabber.org/protocol/chatstates active"`
}

type StateComposing

type StateComposing struct {
	MsgExtension
	XMLName xml.Name `xml:"http://jabber.org/protocol/chatstates composing"`
}

type StateGone

type StateGone struct {
	MsgExtension
	XMLName xml.Name `xml:"http://jabber.org/protocol/chatstates gone"`
}

type StateInactive

type StateInactive struct {
	MsgExtension
	XMLName xml.Name `xml:"http://jabber.org/protocol/chatstates inactive"`
}

type StatePaused

type StatePaused struct {
	MsgExtension
	XMLName xml.Name `xml:"http://jabber.org/protocol/chatstates paused"`
}

type Stream

type Stream struct {
	XMLName xml.Name `xml:"http://etherx.jabber.org/streams stream"`
	From    string   `xml:"from,attr"`
	To      string   `xml:"to,attr"`
	Id      string   `xml:"id,attr"`
	Version string   `xml:"version,attr"`
}

Start of stream Reference: XMPP Core stream open

https://tools.ietf.org/html/rfc6120#section-4.2

type StreamClosePacket

type StreamClosePacket struct{}

This is just a closing tag and hold no information

func (StreamClosePacket) Name

func (StreamClosePacket) Name() string

type StreamError

type StreamError struct {
	XMLName xml.Name `xml:"http://etherx.jabber.org/streams error"`
	Error   xml.Name `xml:",any"`
	Text    string   `xml:"urn:ietf:params:xml:ns:xmpp-streams text"`
}

func (StreamError) Name

func (StreamError) Name() string

type StreamFeatures

type StreamFeatures struct {
	XMLName xml.Name `xml:"http://etherx.jabber.org/streams features"`
	// Server capabilities hash
	Caps Caps
	// Stream features
	StartTLS         TlsStartTLS
	Mechanisms       saslMechanisms
	Bind             Bind
	StreamManagement streamManagement
	// Obsolete
	Session StreamSession
	// ProcessOne Stream Features
	P1Push   p1Push
	P1Rebind p1Rebind

	Any []xml.Name `xml:",any"`
	// contains filtered or unexported fields
}

func (*StreamFeatures) DoesStartTLS

func (sf *StreamFeatures) DoesStartTLS() (feature TlsStartTLS, isSupported bool)

func (*StreamFeatures) DoesStreamManagement

func (sf *StreamFeatures) DoesStreamManagement() (isSupported bool)

func (StreamFeatures) Name

func (StreamFeatures) Name() string

type StreamSession

type StreamSession struct {
	XMLName  xml.Name  `xml:"urn:ietf:params:xml:ns:xmpp-session session"`
	Optional *struct{} // If element does exist, it mean we are not required to open session
	// Result sets
	ResultSet *ResultSet `xml:"set,omitempty"`
}

Session is both a stream feature and an obsolete IQ Payload, used to bind a resource to the current XMPP stream on RFC 3121 only XMPP servers. Session is obsolete in RFC 6121. It is added to Fluux XMPP for compliance with RFC 3121. Reference: https://xmpp.org/rfcs/rfc3921.html#session

This is the draft defining how to handle the transition:

https://tools.ietf.org/html/draft-cridland-xmpp-session-01

func (*StreamSession) GetSet

func (s *StreamSession) GetSet() *ResultSet

func (*StreamSession) IsOptional

func (s *StreamSession) IsOptional() bool

func (*StreamSession) Namespace

func (s *StreamSession) Namespace() string

type SubInfo

type SubInfo struct {
	Node string `xml:"node,attr,omitempty"`
	Jid  string `xml:"jid,attr,omitempty"`
	// Sub ID is optional
	SubId *string `xml:"subid,attr,omitempty"`
}

SubInfo represents information about a subscription Node is the node related to the subscription Jid is the subscription JID of the subscribed entity SubID is the subscription ID

type SubOptions

type SubOptions struct {
	SubInfo
	Form *Form `xml:"x"`
}

type Subscribe

type Subscribe struct {
	XMLName xml.Name `xml:"subscribe"`
	SubInfo
}

type Subscription

type Subscription struct {
	SubStatus string `xml:"subscription,attr,omitempty"`
	SubInfo   `xml:",omitempty"`
	// Seems like we can't marshal a self-closing tag for now : https://github.com/golang/go/issues/21399
	// subscribe-options should be like this as per XEP-0060:
	//    <subscribe-options>
	//        <required/>
	//    </subscribe-options>
	// Used to indicate if configuration options is required.
	Required *struct{}
}

Handles the "5.6 Retrieve Subscriptions" and the 6.1 Subscribe to a Node and so on of XEP-0060

type SubscriptionEvent

type SubscriptionEvent struct {
	SubStatus string `xml:"subscription,attr,omitempty"`
	Expiry    string `xml:"expiry,attr,omitempty"`
	SubInfo   `xml:",omitempty"`
}

func (SubscriptionEvent) Name

func (s SubscriptionEvent) Name() string

type SubscriptionOwner

type SubscriptionOwner struct {
	SubscriptionStatus string `xml:"subscription"`
	Jid                string `xml:"jid,attr"`
}

type Subscriptions

type Subscriptions struct {
	XMLName xml.Name       `xml:"subscriptions"`
	List    []Subscription `xml:"subscription,omitempty"`
}

Handles the "5.6 Retrieve Subscriptions" of XEP-0060

type SubscriptionsOwner

type SubscriptionsOwner struct {
	XMLName       xml.Name            `xml:"subscriptions"`
	Subscriptions []SubscriptionOwner `xml:"subscription"`
	Node          string              `xml:"node,attr"`
}

func (*SubscriptionsOwner) UseCase

func (*SubscriptionsOwner) UseCase() string

type SystemShutdown

type SystemShutdown struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas system-shutdown"`
}

func (*SystemShutdown) GroupErrorName

func (e *SystemShutdown) GroupErrorName() string

type TLSProceed

type TLSProceed struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-tls proceed"`
}

Used during stream initiation / session establishment

type TlsStartTLS

type TlsStartTLS struct {
	XMLName  xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-tls starttls"`
	Required bool
}

StartTLS feature Reference: RFC 6120 - https://tools.ietf.org/html/rfc6120#section-5.4

func (*TlsStartTLS) UnmarshalXML

func (stls *TlsStartTLS) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML implements custom parsing startTLS required flag

type Tune

type Tune struct {
	XMLName xml.Name `xml:"http://jabber.org/protocol/tune tune"`
	Artist  string   `xml:"artist,omitempty"`
	Length  int      `xml:"length,omitempty"`
	Rating  int      `xml:"rating,omitempty"`
	Source  string   `xml:"source,omitempty"`
	Title   string   `xml:"title,omitempty"`
	Track   string   `xml:"track,omitempty"`
	Uri     string   `xml:"uri,omitempty"`
}

type UnAckQueue

type UnAckQueue struct {
	Uslice []*UnAckedStz
	sync.RWMutex
}

func NewUnAckQueue

func NewUnAckQueue() *UnAckQueue

func (*UnAckQueue) Empty

func (uaq *UnAckQueue) Empty() bool

func (*UnAckQueue) Peek

func (uaq *UnAckQueue) Peek() Queueable

func (*UnAckQueue) PeekN

func (uaq *UnAckQueue) PeekN(n int) []Queueable

func (*UnAckQueue) Pop

func (uaq *UnAckQueue) Pop() Queueable

No guarantee regarding thread safety !

func (*UnAckQueue) PopN

func (uaq *UnAckQueue) PopN(n int) []Queueable

No guarantee regarding thread safety !

func (*UnAckQueue) Push

func (uaq *UnAckQueue) Push(s Queueable) error

type UnAckedStz

type UnAckedStz struct {
	Id  int
	Stz string
}

func (*UnAckedStz) QueueableName

func (u *UnAckedStz) QueueableName() string

type UndefinedCondition

type UndefinedCondition struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas undefined-condition"`
}

func (*UndefinedCondition) GroupErrorName

func (e *UndefinedCondition) GroupErrorName() string

type UnexpectedRequest

type UnexpectedRequest struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas unexpected-request"`
}

func (*UnexpectedRequest) GroupErrorName

func (e *UnexpectedRequest) GroupErrorName() string

type Unsubscribe

type Unsubscribe struct {
	XMLName xml.Name `xml:"unsubscribe"`
	SubInfo
}

type UnsupportedEncoding

type UnsupportedEncoding struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas unsupported-encoding"`
}

func (*UnsupportedEncoding) GroupErrorName

func (e *UnsupportedEncoding) GroupErrorName() string

type UnsupportedStanzaType

type UnsupportedStanzaType struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas unsupported-stanza-type"`
}

func (*UnsupportedStanzaType) GroupErrorName

func (e *UnsupportedStanzaType) GroupErrorName() string

type UnsupportedVersion

type UnsupportedVersion struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas unsupported-version"`
}

func (*UnsupportedVersion) GroupErrorName

func (e *UnsupportedVersion) GroupErrorName() string

type Version

type Version struct {
	XMLName xml.Name `xml:"jabber:iq:version query"`
	Name    string   `xml:"name,omitempty"`
	Version string   `xml:"version,omitempty"`
	OS      string   `xml:"os,omitempty"`
	// Result sets
	ResultSet *ResultSet `xml:"set,omitempty"`
}

Version

func (*Version) GetSet

func (v *Version) GetSet() *ResultSet

func (*Version) Namespace

func (v *Version) Namespace() string

func (*Version) SetInfo

func (v *Version) SetInfo(name, version, os string) *Version

Set all software version info

type WebsocketOpen

type WebsocketOpen struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-framing open"`
	From    string   `xml:"from,attr"`
	Id      string   `xml:"id,attr"`
	Version string   `xml:"version,attr"`
}

Open Packet Reference: WebSocket connections must start with this element

https://tools.ietf.org/html/rfc7395#section-3.4

type XMLNotWellFormed

type XMLNotWellFormed struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas xml-not-well-formed"`
}

func (*XMLNotWellFormed) GroupErrorName

func (e *XMLNotWellFormed) GroupErrorName() string

Jump to

Keyboard shortcuts

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