sum7
/
yaja
Archived
1
0
Fork 0

[TASK] add roster in xmpp library

This commit is contained in:
Martin/Geno 2018-02-22 03:12:07 +01:00
parent 255c2ef9ad
commit 7d73d323a6
No known key found for this signature in database
GPG Key ID: F0D39A37E925E941
19 changed files with 73 additions and 49 deletions

View File

@ -31,8 +31,9 @@
all implementation of all comman (RFCs and XEPs) xml element
**Version**
- [RFC 6120 (XMPP - Core)](https://xmpp.org/rfcs/rfc3920.html)
- [XEP 0030: Service Discovery](https://xmpp.org/extensions/xep-0030.html)
- [RFC 6120 (XMPP - Core)](https://xmpp.org/rfcs/rfc6120.html)
- [RFC 6121 (XMPP - Instant Messaging and Presence)](https://xmpp.org/rfcs/rfc6121.html)
- [XEP-0030: Service Discovery](https://xmpp.org/extensions/xep-0030.html)
- [XEP-0049: Private XML Storage](https://xmpp.org/extensions/xep-0049.html)
- [XEP-0092: Software Version](https://xmpp.org/extensions/xep-0092.html)
- [XEP-0138: Stream Compression](https://xmpp.org/extensions/xep-0138.html)

View File

@ -9,8 +9,7 @@ type ErrorClient struct {
Type ErrorType `xml:"type,attr"` // required
Text *Text
// RFC 6120 A.8 Resource binding namespace
StanzaErrorGroup
StanzaErrorGroup // RFC 6120: A.8 Resource binding namespace
// Any hasn't matched element
Other []XMLElement `xml:",any"`

View File

@ -16,7 +16,8 @@ type IQClient struct {
Type IQType `xml:"type,attr"` // required
Error *ErrorClient
Bind *Bind // RFC 6120 A.7 Resource binding namespace (But in a IQ?)
Bind *Bind // RFC 6120: A.7 Resource binding namespace (But in a IQ?)
Roster *xmppiq.RosterQuery // RFC 6121: Appendix D.
DiscoQueryInfo *xmppiq.DiscoQueryInfo // XEP-0030: XMPP Service Discovery (see iq/service_discovery.go)
DiscoQueryItem *xmppiq.DiscoQueryItem // XEP-0030: XMPP Service Discovery (see iq/service_discovery.go)
PrivateXMLStorage *xmppiq.PrivateXMLStorage // XEP-0049: Private XML Storage (see iq/private_xml_storage.go)

View File

@ -10,7 +10,7 @@ import (
type StreamFeatures struct {
XMLName xml.Name `xml:"http://etherx.jabber.org/streams features"`
StartTLS *TLSStartTLS
Mechanisms SASLMechanisms // RFC 6120 - A.4 SASL Namespace (see sasl.go)
Mechanisms SASLMechanisms // RFC 6120: A.4 SASL Namespace (see sasl.go)
Compression *CompressionFeature // XEP-0138: Stream Compression (see compression.go)
Bind *Bind
Session bool
@ -32,7 +32,7 @@ type TLSFailure struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-tls failure"`
}
// Bind implements RFC 6120 A.7 Resource binding namespace
// Bind implements RFC 6120 - A.7 Resource binding namespace
type Bind struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-bind bind"`
Resource string `xml:"resource"`

View File

@ -3,7 +3,7 @@ package xmpp
// ErrorType is a Enum of error attribute type
type ErrorType string
// RFC 6120 part of A.5 Client Namespace and A.6 Server Namespace
// RFC 6120: part of A.5 Client Namespace and A.6 Server Namespace
const (
ErrorTypeAuth ErrorType = "auth"
ErrorTypeCancel ErrorType = "cancel"

View File

@ -3,7 +3,7 @@ package xmpp
// IQType is a Enum of iq attribute type
type IQType string
// RFC 6120 part of A.5 Client Namespace and A.6 Server Namespace
// RFC 6120: part of A.5 Client Namespace and A.6 Server Namespace
const (
IQTypeError IQType = "error"
IQTypeGet IQType = "get"

View File

@ -3,7 +3,7 @@ package xmpp
// MessageType is a Enum of message attribute type
type MessageType string
// RFC 6120 part of A.5 Client Namespace and A.6 Server Namespace
// RFC 6120: part of A.5 Client Namespace and A.6 Server Namespace
const (
MessageTypeChat MessageType = "chat"
MessageTypeError MessageType = "error"

View File

@ -3,7 +3,7 @@ package xmpp
// PresenceType is a Enum of presence attribute type
type PresenceType string
// RFC 6120 part of A.5 Client Namespace and A.6 Server Namespace
// RFC 6120: part of A.5 Client Namespace and A.6 Server Namespace
const (
PresenceTypeError PresenceType = "error"
PresenceTypeProbe PresenceType = "probe"
@ -17,7 +17,7 @@ const (
// PresenceShow is a Enum of presence element show
type PresenceShow string
// RFC 6120 part of A.5 Client Namespace and A.6 Server Namespace
// RFC 6120: part of A.5 Client Namespace and A.6 Server Namespace
const (
PresenceShowAway PresenceShow = "away"
PresenceShowChat PresenceShow = "chat"

View File

@ -2,7 +2,7 @@ package xmpp
import "encoding/xml"
// StanzaErrorGroup implements RFC 6120 A.8 Resource binding namespace
// StanzaErrorGroup implements RFC 6120 - A.8 Resource binding namespace
type StanzaErrorGroup struct {
BadRequest *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas bad-request"`
Conflict *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas conflict"`

View File

@ -2,7 +2,7 @@ package xmpp
import "encoding/xml"
// StreamErrorGroup implements RFC 6120 A.2 Stream Error Namespace
// StreamErrorGroup implements RFC 6120 - A.2 Stream Error Namespace
type StreamErrorGroup struct {
BadFormat *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams bad-format"`
BadNamespacePrefix *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams bad-namespace-prefix"`
@ -31,7 +31,7 @@ type StreamErrorGroup struct {
UnsupportedVersion *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams unsupported-version"`
}
// StreamError implements RFC 6120 A.2 Stream Error Namespace
// StreamError implements RFC 6120 - A.2 Stream Error Namespace
type StreamError struct {
XMLName xml.Name `xml:"http://etherx.jabber.org/streams error"`
Text *Text

View File

@ -2,7 +2,7 @@ package xmpp
import "encoding/xml"
// Text implements RFC 6120 part of A.2 Stream Error Namespace, A.4 SASL Namespace and A.8 Stanza Error Namespace
// Text implements RFC 6120 - part of A.2 Stream Error Namespace, A.4 SASL Namespace and A.8 Stanza Error Namespace
type Text struct {
// `xml:"urn:ietf:params:xml:ns:xmpp-streams text"`
// `xml:"urn:ietf:params:xml:ns:xmpp-sasl text"`

View File

@ -1,10 +1,10 @@
package xmppiq
const (
// NSDiscoInfo implements XEP 0030: Service Discovery - 11.1 disco#info
// NSDiscoInfo implements XEP-0030: Service Discovery - 11.1 disco#info
NSDiscoInfo = "http://jabber.org/protocol/disco#info"
// NSDiscoItems implements XEP 0030: Service Discovery - 11.2 disco#items
// NSDiscoItems implements XEP-0030: Service Discovery - 11.2 disco#items
NSDiscoItems = "http://jabber.org/protocol/disco#items"
// NSPrivateXMLStorage implements XEP-0049: Private XML Storage - 7

45
xmpp/iq/roster.go Normal file
View File

@ -0,0 +1,45 @@
package xmppiq
import (
"encoding/xml"
"dev.sum7.eu/genofire/yaja/xmpp/base"
)
// RosterQuery implements RFC 6121 - Appendix D. XML Schema for jabber:iq:roster
type RosterQuery struct {
XMLName xml.Name `xml:"jabber:iq:roster query"`
Version string `xml:"ver,attr,omitempty"`
Items []RosterItem `xml:"item"`
}
// RosterAskType is a Enum of item attribute ask
type RosterAskType string
// RFC 6121: Appendix D. XML Schema for jabber:iq:roster
const (
RosterAskSubscribe RosterAskType = "subscribe"
RosterAskNone RosterAskType = ""
)
// RosterAskType is a Enum of item attribute subscription
type RosterSubscriptionType string
// RFC 6121: Appendix D. XML Schema for jabber:iq:roster
const (
RosterSubscriptionBoth RosterSubscriptionType = "both"
RosterSubscriptionFrom RosterSubscriptionType = "from"
RosterSubscriptionNone RosterSubscriptionType = "none"
RosterSubscriptionRemove RosterSubscriptionType = "remove"
RosterSubscriptionTo RosterSubscriptionType = "to"
)
// RosterItem implements RFC 6121 - Appendix D. XML Schema for jabber:iq:roster
type RosterItem struct {
JID *xmppbase.JID `xml:"jid,attr"`
Approved *bool `xml:"approved,attr,omitempty"`
Ask RosterAskType `xml:"ask,attr,omitempty"`
Name string `xml:"name,attr,omitempty"`
Subscription RosterSubscriptionType `xml:"subscription,attr"`
Group []string `xml:"group"`
}

View File

@ -6,7 +6,7 @@ import (
"dev.sum7.eu/genofire/yaja/xmpp/base"
)
// DiscoQueryInfo implements XEP 0030: Service Discovery - 11.1 disco#info
// DiscoQueryInfo implements XEP-0030: Service Discovery - 11.1 disco#info
type DiscoQueryInfo struct {
XMLName xml.Name `xml:"http://jabber.org/protocol/disco#info query"`
Node string `xml:"node,attr,omitempty"`
@ -14,7 +14,7 @@ type DiscoQueryInfo struct {
Features []*DiscoFeature
}
// DiscoIdentity implements XEP 0030: Service Discovery - 11.1 disco#info
// DiscoIdentity implements XEP-0030: Service Discovery - 11.1 disco#info
type DiscoIdentity struct {
XMLName xml.Name `xml:"http://jabber.org/protocol/disco#info identity"`
Category string `xml:"category"` //required
@ -22,20 +22,20 @@ type DiscoIdentity struct {
Type string `xml:"type"` //required
}
// DiscoFeature implements XEP 0030: Service Discovery - 11.1 disco#info
// DiscoFeature implements XEP-0030: Service Discovery - 11.1 disco#info
type DiscoFeature struct {
XMLName xml.Name `xml:"http://jabber.org/protocol/disco#info feature"`
Var string `xml:"var"` //required
}
// DiscoQueryItem implements XEP 0030: Service Discovery - 11.2 disco#items
// DiscoQueryItem implements XEP-0030: Service Discovery - 11.2 disco#items
type DiscoQueryItem struct {
XMLName xml.Name `xml:"http://jabber.org/protocol/disco#items query"`
Node string `xml:"node,attr,omitempty"`
Items []*DiscoItem
}
// DiscoItem implements XEP 0030: Service Discovery - 11.2 disco#items
// DiscoItem implements XEP-0030: Service Discovery - 11.2 disco#items
type DiscoItem struct {
XMLName xml.Name `xml:"http://jabber.org/protocol/disco#items item"`
JID *xmppbase.JID `xml:"jid"`

View File

@ -1,21 +0,0 @@
package xmpp
import (
"encoding/xml"
"dev.sum7.eu/genofire/yaja/xmpp/base"
)
// ClientQuery implements which XEP ????
type ClientQuery struct {
Item []RosterItem
}
// RosterItem implements which XEP ????
type RosterItem struct {
XMLName xml.Name `xml:"jabber:iq:roster item"`
JID *xmppbase.JID `xml:",attr"`
Name string `xml:",attr"`
Subscription string `xml:",attr"`
Group []string
}

View File

@ -9,8 +9,7 @@ type ErrorServer struct {
Type ErrorType `xml:"type,attr"` // required
Text *Text
// RFC 6120 A.8 Resource binding namespace
StanzaErrorGroup
StanzaErrorGroup // RFC 6120: A.8 - Resource binding namespace
// Any hasn't matched element
Other []XMLElement `xml:",any"`

View File

@ -16,7 +16,7 @@ type IQServer struct {
Type IQType `xml:"type,attr"` // required
Error *ErrorServer
Bind *Bind // RFC 6120 A.7 Resource binding namespace (But in a IQ?)
Bind *Bind // RFC 6120: A.7 Resource binding namespace (But in a IQ?)
Ping *xmppiq.Ping // XEP-0199: XMPP Ping (see iq/ping.go)
// Any hasn't matched element