roster

package
v0.0.111-test1 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2021 License: GPL-3.0 Imports: 6 Imported by: 5

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

func (*Group) UnsortedPeers added in v0.3.8

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

UnsortedPeers returns an unsorted 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 jid.WithoutResource) (*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 jid.WithoutResource) (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 jid.WithoutResource, code, tp, more string)

LatestError will set the latest error on the jid in question

func (*List) PeerBecameUnavailable

func (l *List) PeerBecameUnavailable(j jid.Any) bool

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

func (*List) PeerPresenceUpdate

func (l *List) PeerPresenceUpdate(peer jid.WithResource, 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 jid.WithoutResource) (*Peer, bool)

Remove returns the Peer with the jid from the List 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 jid.WithoutResource) (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) SubscribeRequest

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

SubscribeRequest adds a new pending subscribe request

func (*List) Subscribed

func (l *List) Subscribed(jid jid.WithoutResource)

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 jid.WithoutResource)

Unsubscribed will mark the jid as unsubscribed

type Peer

type Peer struct {
	Jid                jid.WithoutResource
	Subscription       string
	Name               string
	Nickname           string
	Groups             map[string]bool
	Asked              bool
	PendingSubscribeID string
	BelongsTo          string
	LatestError        *PeerError

	HasConfigData bool
	// contains filtered or unexported fields
}

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 jid.WithoutResource, status, statusMsg, belongsTo string, resource jid.Resource) *Peer

PeerWithState returns a new Peer that contains the given state information

func (*Peer) AddResource added in v0.3.3

func (p *Peer) AddResource(ss jid.Resource, status, statusMsg string)

AddResource adds the given resource if it isn't blank

func (*Peer) ClearResources added in v0.3.3

func (p *Peer) ClearResources()

ClearResources removes all known resources for the given peer

func (*Peer) Dump

func (p *Peer) Dump() string

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

func (*Peer) HasResources added in v0.3.3

func (p *Peer) HasResources() bool

HasResources returns true if this peer has any online resources

func (*Peer) IsOnline added in v0.3.9

func (p *Peer) IsOnline() bool

IsOnline returns true if any of the resources are online

func (*Peer) LastSeen added in v0.3.9

func (p *Peer) LastSeen(r jid.Any)

LastSeen sets the last resource used

func (*Peer) MainStatus added in v0.3.9

func (p *Peer) MainStatus() string

MainStatus returns the status of the current main resource

func (*Peer) MainStatusMsg added in v0.3.9

func (p *Peer) MainStatusMsg() string

MainStatusMsg returns the status message of the current main resource

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) RemoveResource added in v0.3.3

func (p *Peer) RemoveResource(s jid.Resource)

RemoveResource removes the given resource

func (*Peer) ResourceToUse added in v0.3.3

func (p *Peer) ResourceToUse() jid.Resource

ResourceToUse returns the resource to use for this peer

func (*Peer) ResourceToUseFallback

func (p *Peer) ResourceToUseFallback() jid.Resource

ResourceToUseFallback returns the resource to use for this peer or any resource if one exists

func (*Peer) Resources added in v0.3.3

func (p *Peer) Resources() []jid.Resource

Resources returns the resources for this peer

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

type Status added in v0.3.9

type Status struct {
	Status    string
	StatusMsg string
}

Status contains the status information for a specific resource

Jump to

Keyboard shortcuts

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