bookmarks

package
v0.21.4 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2023 License: BSD-2-Clause Imports: 10 Imported by: 2

Documentation

Overview

Package bookmarks implements storing bookmarks to chat rooms.

Index

Constants

View Source
const (
	NS       = "urn:xmpp:bookmarks:1"
	NSNotify = "urn:xmpp:bookmarks:1+notify"
	NSCompat = "urn:xmpp:bookmarks:1#compat"
)

Namespaces used by this package.

Variables

View Source
var (
	Feature       = info.Feature{Var: NS}
	FeatureNotify = info.Feature{Var: NSNotify}
)

A list of service discovery features that are supported by this package.

Functions

func Delete

func Delete(ctx context.Context, s *xmpp.Session, b jid.JID) error

Delete removes the bookmark.

func DeleteIQ

func DeleteIQ(ctx context.Context, s *xmpp.Session, iq stanza.IQ, b jid.JID) error

DeleteIQ is like Delete except that it allows modifying the IQ. Changes to the IQ type will have no effect.

func Publish

func Publish(ctx context.Context, s *xmpp.Session, b Channel) error

Publish creates or updates the bookmark.

func PublishIQ

func PublishIQ(ctx context.Context, s *xmpp.Session, iq stanza.IQ, b Channel) error

PublishIQ is like Publish except that it allows modifying the IQ. Changes to the IQ type will have no effect.

Types

type Channel

type Channel struct {
	JID        jid.JID
	Autojoin   bool
	Name       string
	Nick       string
	Password   string
	Extensions []byte
}

Channel represents a single chat room with various properties.

func (Channel) MarshalXML

func (c Channel) MarshalXML(e *xml.Encoder, _ xml.StartElement) error

MarshalXML implements xml.Marshaler.

func (Channel) TokenReader

func (c Channel) TokenReader() xml.TokenReader

TokenReader satisfies the xmlstream.Marshaler interface.

func (*Channel) UnmarshalXML

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

UnmarshalXML implements xml.Unmarshaler.

func (Channel) WriteXML

func (c Channel) WriteXML(w xmlstream.TokenWriter) (n int, err error)

WriteXML satisfies the xmlstream.WriterTo interface. It is like MarshalXML except it writes tokens to w.

type Handler

type Handler struct {
}

Handler can be registered against a mux to handle bookmark pushes.

func (Handler) ForFeatures

func (h Handler) ForFeatures(node string, f func(info.Feature) error) error

ForFeatures implements info.FeatureIter.

type Iter

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

Iter is an iterator over bookmarks.

func Fetch

func Fetch(ctx context.Context, s *xmpp.Session) *Iter

Fetch requests all bookmarks from the server and returns an iterator over the results (blocking until the response is received and the iterator is fully consumed or closed).

func FetchIQ

func FetchIQ(ctx context.Context, iq stanza.IQ, s *xmpp.Session) *Iter

FetchIQ is like Fetch but it allows you to customize the IQ. Changing the type of the provided IQ has no effect.

func (*Iter) Bookmark

func (i *Iter) Bookmark() Channel

Bookmark returns the last bookmark parsed by the iterator.

func (*Iter) Close

func (i *Iter) Close() error

Close indicates that we are finished with the given iterator and processing the stream may continue. Calling it multiple times has no effect.

func (*Iter) Err

func (i *Iter) Err() error

Err returns the last error encountered by the iterator (if any).

func (*Iter) Next

func (i *Iter) Next() bool

Next returns true if there are more items to decode.

Jump to

Keyboard shortcuts

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