From 0ad62245e8cf44e41f062cc6562614de79fea902 Mon Sep 17 00:00:00 2001 From: Martin/Geno Date: Thu, 6 Sep 2018 13:30:42 +0200 Subject: [PATCH] [WIP] Library XEP-0045 Multi-User Chat (Base for History + Password) --- xmpp/client_presence.go | 3 +++ xmpp/x/muc/base.go | 21 +++++++++++++++++++++ xmpp/x/muc/namespaces.go | 15 +++++++++++++++ xmpp/x/muc/test.go | 7 +++++++ xmpp/x/muc/test_test.go | 5 +++++ 5 files changed, 51 insertions(+) create mode 100644 xmpp/x/muc/base.go create mode 100644 xmpp/x/muc/namespaces.go create mode 100644 xmpp/x/muc/test.go create mode 100644 xmpp/x/muc/test_test.go diff --git a/xmpp/client_presence.go b/xmpp/client_presence.go index 4e9f3f0..331ec97 100644 --- a/xmpp/client_presence.go +++ b/xmpp/client_presence.go @@ -4,6 +4,7 @@ import ( "encoding/xml" "dev.sum7.eu/genofire/yaja/xmpp/base" + "dev.sum7.eu/genofire/yaja/xmpp/x/muc" ) // PresenceClient implements RFC 6120 - A.5 Client Namespace (a part) @@ -21,6 +22,8 @@ type PresenceClient struct { Error *ErrorClient + MUC *xmuc.Base // XEP-0045: Multi-User Chat (see x/muc/base.go) + Delay *Delay `xml:"delay"` // which XEP ? // which XEP ? diff --git a/xmpp/x/muc/base.go b/xmpp/x/muc/base.go new file mode 100644 index 0000000..4205b54 --- /dev/null +++ b/xmpp/x/muc/base.go @@ -0,0 +1,21 @@ +package xmuc + +import ( + "encoding/xml" + "time" +) + +// Base implements XEP-0045: Multi-User Chat - 19.1 +type Base struct { + XMLName xml.Name `xml:"http://jabber.org/protocol/muc x"` + History *History `xml:"history,omitempty"` + Password string `xml:"password,omitempty"` +} + +// History implements XEP-0045: Multi-User Chat - 19.1 +type History struct { + MaxChars *int `xml:"maxchars,attr,omitempty"` + MaxStanzas *int `xml:"maxstanzas,attr,omitempty"` + Seconds *int `xml:"seconds,attr,omitempty"` + Since *time.Time `xml:"since,attr,omitempty"` +} diff --git a/xmpp/x/muc/namespaces.go b/xmpp/x/muc/namespaces.go new file mode 100644 index 0000000..f9ad3c8 --- /dev/null +++ b/xmpp/x/muc/namespaces.go @@ -0,0 +1,15 @@ +package xmuc + +const ( + // NSMUC implements XEP-0045: Multi-User Chat - 19.1 muc + NSMUC = "http://jabber.org/protocol/muc" + + // NSMUCUser implements XEP-0045: Multi-User Chat - 19.2 muc#user + NSMUCUser = "http://jabber.org/protocol/muc#user" + + // NSMUCAdmin implements XEP-0045: Multi-User Chat - 19.3 muc#admin + NSMUCAdmin = "http://jabber.org/protocol/muc#admin" + + // NSMUCOwner implements XEP-0045: Multi-User Chat - 19.4 muc#owner + NSMUCOwner = "http://jabber.org/protocol/muc#user" +) diff --git a/xmpp/x/muc/test.go b/xmpp/x/muc/test.go new file mode 100644 index 0000000..b836c66 --- /dev/null +++ b/xmpp/x/muc/test.go @@ -0,0 +1,7 @@ +package xmuc + +// just to validate, there is no functions in here +func init() { + a := 1 + a++ +} diff --git a/xmpp/x/muc/test_test.go b/xmpp/x/muc/test_test.go new file mode 100644 index 0000000..2ae5712 --- /dev/null +++ b/xmpp/x/muc/test_test.go @@ -0,0 +1,5 @@ +package xmuc + +import "testing" + +func Test(t *testing.T) {}