roster

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2016 License: GPL-3.0 Imports: 6 Imported by: 23

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IterAll

func IterAll(cb func(int, *Peer), ls ...*List)

IterAll calls the cb function once for each peer in all the lists

Types

type Group

type Group struct {
	GroupName string
	// contains filtered or unexported fields
}

Group represents a grouping of accounts and groups

func TopLevelGroup

func TopLevelGroup() *Group

TopLevelGroup returns a new top level group

func (*Group) FullGroupName

func (g *Group) FullGroupName() string

FullGroupName returns the full group name

func (*Group) Groups

func (g *Group) Groups() []*Group

Groups returns a sorted list of all the groups in this group

func (*Group) Peers

func (g *Group) Peers() []*Peer

Peers returns a sorted list of all the peers in this group

type List

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

List represent a list of peers. It takes care of both roster and presence information transparently and presents a unified view of this information to any UI List is not ordered, but can be asked to present its information in various orders depending on what policy is in use It also contains information about pending subscribes One invariant is that the list will only ever contain one Peer for each bare jid.

func New

func New() *List

New returns a new List

func (*List) AddOrMerge

func (l *List) AddOrMerge(p *Peer) bool

AddOrMerge will add a new entry or merge with an existing entry the information from the given Peer It returns true if it added the entry and false otherwise

func (*List) AddOrReplace

func (l *List) AddOrReplace(p *Peer) bool

AddOrReplace will add a new entry or replace an existing entry with the information from the given Peer It returns true if it added the entry and false otherwise

func (*List) AddTo

func (l *List) AddTo(topLevel *Group, delim string)

AddTo will add the peers in the receiver to the given group top level

func (*List) Clear

func (l *List) Clear()

Clear removes all current entries in the list

func (*List) Get

func (l *List) Get(jid string) (*Peer, bool)

Get returns the peer if it's known and false otherwise

func (*List) GetGroupNames

func (l *List) GetGroupNames() map[string]bool

GetGroupNames return all group names for this peer list.

func (*List) GetPendingSubscribe

func (l *List) GetPendingSubscribe(jid string) (string, bool)

GetPendingSubscribe will return a subscribe id without removing it

func (*List) Grouped

func (l *List) Grouped(delim string) *Group

Grouped will group the peers in the given list

func (*List) Iter

func (l *List) Iter(cb func(int, *Peer))

Iter calls the cb function once for each peer in the list

func (*List) LatestError

func (l *List) LatestError(jid string, code, tp, more string)

LatestError will set the latest error on the jid in question

func (*List) PeerBecameUnavailable

func (l *List) PeerBecameUnavailable(jid string) bool

PeerBecameUnavailable marks the peer as unavailable if they exist Returns true if they existed, otherwise false

func (*List) PeerPresenceUpdate

func (l *List) PeerPresenceUpdate(jid, status, statusMsg, belongsTo string) bool

PeerPresenceUpdate updates the status for the peer It returns true if it actually updated the status of the user

func (*List) Remove

func (l *List) Remove(jid string) (*Peer, bool)

Remove returns the Peer with the jid from the List - it will first turn the jid into a bare jid. It returns true if it could remove the entry and false otherwise. It also returns the removed entry.

func (*List) RemovePendingSubscribe

func (l *List) RemovePendingSubscribe(jid string) (string, bool)

RemovePendingSubscribe will return a subscribe id and remove the pending subscribe if it exists It will return false if no such subscribe is in flight

func (*List) StateOf

func (l *List) StateOf(jid string) (status, statusMsg string, ok bool)

StateOf returns the status and status msg of the peer if it exists. It returns not ok if the peer doesn't exist.

func (*List) SubscribeRequest

func (l *List) SubscribeRequest(jid, id, belongsTo string)

SubscribeRequest adds a new pending subscribe request

func (*List) Subscribed

func (l *List) Subscribed(jid string)

Subscribed will mark the jid as subscribed

func (*List) ToSlice

func (l *List) ToSlice() []*Peer

ToSlice returns a slice of all the peers in this roster list

func (*List) Unsubscribed

func (l *List) Unsubscribed(jid string)

Unsubscribed will mark the jid as unsubscribed

type Peer

type Peer struct {
	// The bare jid of the peer
	Jid                string
	Subscription       string
	Name               string
	Nickname           string
	Groups             map[string]bool
	Status             string
	StatusMsg          string
	Online             bool
	Asked              bool
	PendingSubscribeID string
	BelongsTo          string
	LatestError        *PeerError
}

Peer represents and contains all the information you have about a specific peer. A Peer is always part of at least one roster.List, which is associated with an account.

func PeerFrom

func PeerFrom(e data.RosterEntry, belongsTo, nickname string, groups []string) *Peer

PeerFrom returns a new Peer that contains the same information as the RosterEntry given

func PeerWithState

func PeerWithState(jid, status, statusMsg, belongsTo string) *Peer

PeerWithState returns a new Peer that contains the given state information

func (*Peer) Dump

func (p *Peer) Dump() string

Dump will dump all info in the peer in a very verbose format

func (*Peer) MergeWith

func (p *Peer) MergeWith(p2 *Peer) *Peer

MergeWith returns a new Peer that is the merger of the receiver and the argument, giving precedence to the argument when needed

func (*Peer) NameForPresentation

func (p *Peer) NameForPresentation() string

NameForPresentation returns the name if it exists and otherwise the JID

func (*Peer) SetGroups

func (p *Peer) SetGroups(groups []string)

SetGroups set the Peer groups

func (*Peer) SetLatestError

func (p *Peer) SetLatestError(code, tp, more string)

SetLatestError will set the latest error on the jid in question

func (*Peer) ToEntry

func (p *Peer) ToEntry() data.RosterEntry

ToEntry returns a new RosterEntry with the same values

type PeerError

type PeerError struct {
	Code string
	Type string
	More string
}

PeerError contains information about an error for this peer

Jump to

Keyboard shortcuts

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