muc

package
v0.4.0-el1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// RoomConfigOptionModerators represents the field option for "moderators"
	RoomConfigOptionModerators = "moderators"
	// RoomConfigOptionParticipants represents the field option for "participants"
	RoomConfigOptionParticipants = "participants"
	// RoomConfigOptionAnyone represents the field opion for "anyone"
	RoomConfigOptionAnyone = "anyone"
	// RoomConfigOptionModerator represents the field option for "moderator"
	RoomConfigOptionModerator = "moderator"
	// RoomConfigOptionParticipant represents the field option for "participant"
	RoomConfigOptionParticipant = "participant"
	// RoomConfigOptionVisitor represents the field option for "visitor"
	RoomConfigOptionVisitor = "visitor"
	// RoomConfigOptionNone represents the field option for "none"
	RoomConfigOptionNone = "0"
	// RoomConfigOption10 represents the field option for "10"
	RoomConfigOption10 = "10"
	// RoomConfigOption20 represents the field option for "20"
	RoomConfigOption20 = "20"
	// RoomConfigOption30 represents the field option for "30"
	RoomConfigOption30 = "30"
	// RoomConfigOption50 represents the field option for "50"
	RoomConfigOption50 = "50"
	// RoomConfigOption100 represents the field option for "100"
	RoomConfigOption100 = "100"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ByOccupantJid

type ByOccupantJid []*Occupant

ByOccupantJid sorts occupants by real JID and then nickname

func (ByOccupantJid) Len

func (s ByOccupantJid) Len() int

func (ByOccupantJid) Less

func (s ByOccupantJid) Less(i, j int) bool

func (ByOccupantJid) Swap

func (s ByOccupantJid) Swap(i, j int)

type ByOccupantNick

type ByOccupantNick []*Occupant

ByOccupantNick sorts occupants by nickname

func (ByOccupantNick) Len

func (s ByOccupantNick) Len() int

func (ByOccupantNick) Less

func (s ByOccupantNick) Less(i, j int) bool

func (ByOccupantNick) Swap

func (s ByOccupantNick) Swap(i, j int)

type ConfigListMultiField

type ConfigListMultiField interface {
	// UpdateField will update the list fields with the given "values" and "options"
	UpdateField([]string, []string)
}

ConfigListMultiField description

type ConfigListSingleField

type ConfigListSingleField interface {
	// UpdateField will update the list fields with the given "value" and "options"
	UpdateField(string, []string)
	// UpdateValue updates the current field value
	UpdateValue(string)
	// Value returns the current list value
	CurrentValue() string
	// Options returns the field options
	Options() []string
}

ConfigListSingleField description

type Occupant

type Occupant struct {
	// Nickname is the nickname of the person
	Nickname string

	// RealJid is the real JID of the person, if known. Otherwise it is nil
	RealJid jid.Full

	// Affiliation is the current affiliation of the occupant in the room
	Affiliation data.Affiliation

	// Role is the current role of the occupant in the room
	Role data.Role

	// Status contains the current status of the occupant in the room
	Status *roster.Status
}

Occupant contains information about a specific occupant in a specific room. This structure doesn't make sense without a connection to a room, since the information inside it depends on the room

func (*Occupant) Ban

func (o *Occupant) Ban()

Ban is a synonym for ChangeAffiliationToOutcast

func (*Occupant) CanAssignAndRemoveModeratorRole

func (o *Occupant) CanAssignAndRemoveModeratorRole() bool

CanAssignAndRemoveModeratorRole returns true if the occupant can assign and remove moderator role based on the occupant's affiliation

func (*Occupant) CanBanMembersAndUnaffiliatedUsers

func (o *Occupant) CanBanMembersAndUnaffiliatedUsers() bool

CanBanMembersAndUnaffiliatedUsers returns true if the occupant can ban members and unaffiliated users based on the occupant's affiliation

func (*Occupant) CanBroadcastPresenceToAllOccupants

func (o *Occupant) CanBroadcastPresenceToAllOccupants() bool

CanBroadcastPresenceToAllOccupants returns a boolean indicating if the occupant can send a broadcast presence to all occupants based on the occupant's role

func (*Occupant) CanChangeAffiliation

func (o *Occupant) CanChangeAffiliation(oc *Occupant) bool

CanChangeAffiliation returns a boolean indicating if the occupant can change the affiliation of the given occupant based on the occupant's affiliation

func (*Occupant) CanChangeAvailabilityStatus

func (o *Occupant) CanChangeAvailabilityStatus() bool

CanChangeAvailabilityStatus returns a boolean indicating if the occupant can change their availability status based on the occupant's role

func (*Occupant) CanChangeRole

func (o *Occupant) CanChangeRole(oc *Occupant) bool

CanChangeRole returns a boolean indicating if the occupant can change the role of the given occupant based on the occupant's role and affiliation

func (*Occupant) CanChangeRoomConfiguration

func (o *Occupant) CanChangeRoomConfiguration() bool

CanChangeRoomConfiguration returns true if the occupant can change the room configuration based on the occupant's affiliation

func (*Occupant) CanChangeRoomNickname

func (o *Occupant) CanChangeRoomNickname() bool

CanChangeRoomNickname returns a boolean indicating if the occupant can change the room nickname based on the occupant's role

func (*Occupant) CanDestroyRoom

func (o *Occupant) CanDestroyRoom() bool

CanDestroyRoom returns true if the occupant can destroy the room based on the occupant's affiliation

func (*Occupant) CanEditAdminList

func (o *Occupant) CanEditAdminList() bool

CanEditAdminList returns true if the occupant can edit the admin list based on the occupant's affiliation

func (*Occupant) CanEditMemberList

func (o *Occupant) CanEditMemberList() bool

CanEditMemberList returns true if the occupant can edit the members list based on the occupant's affiliation

func (*Occupant) CanEditOwnerList

func (o *Occupant) CanEditOwnerList() bool

CanEditOwnerList returns true if the occupant can edit the owners list based on the occupant's affiliation

func (*Occupant) CanEnterMembersOnlyRoom

func (o *Occupant) CanEnterMembersOnlyRoom() bool

CanEnterMembersOnlyRoom returns true if the occupant can enter to a members only room based on the occupant's affiliation

func (*Occupant) CanEnterOpenRoom

func (o *Occupant) CanEnterOpenRoom() bool

CanEnterOpenRoom returns true if the occupant can enter to an open room based on the occupant's affiliation

func (*Occupant) CanGrantVoice

func (o *Occupant) CanGrantVoice() bool

CanGrantVoice returns a boolean indicating if the occupant can grant voice based on the occupant's role

func (*Occupant) CanInviteOtherUsers

func (o *Occupant) CanInviteOtherUsers() bool

CanInviteOtherUsers returns a boolean indicating if the occupant can invite other users based on the occupant's role

func (*Occupant) CanKickParticipantsAndVisitors

func (o *Occupant) CanKickParticipantsAndVisitors() bool

CanKickParticipantsAndVisitors returns a boolean indicating if the occupant can kick participants and visitors based on the occupant's role

func (*Occupant) CanModifySubject

func (o *Occupant) CanModifySubject() bool

CanModifySubject returns a boolean indicating if the occupant can modify the room's subject based on the occupant's role

func (*Occupant) CanPresentInRoom

func (o *Occupant) CanPresentInRoom() bool

CanPresentInRoom returns a boolean indicating if the occupant can be present in the room based on the occupant's role

func (*Occupant) CanReceiveMessage

func (o *Occupant) CanReceiveMessage() bool

CanReceiveMessage returns a boolean indicating if the occupant can receive messages based on the occupant's role

func (*Occupant) CanReceiveOccupantPresence

func (o *Occupant) CanReceiveOccupantPresence() bool

CanReceiveOccupantPresence returns a boolean indicating if the occupant can receive occupant presence based on the occupant's role

func (*Occupant) CanRegisterWithOpenRoom

func (o *Occupant) CanRegisterWithOpenRoom() bool

CanRegisterWithOpenRoom returns true if the occupant can register with open room based on the occupant's affiliation

func (*Occupant) CanRetrieveMemberList

func (o *Occupant) CanRetrieveMemberList() bool

CanRetrieveMemberList returns true if the occupant can retrieve the members list based on the occupant's affiliation

func (*Occupant) CanRevokeVoice

func (o *Occupant) CanRevokeVoice(oc *Occupant) bool

CanRevokeVoice returns a boolean indicating if the occupant can revoke voice based on the occupant's role

func (*Occupant) CanSendMessagesToAll

func (o *Occupant) CanSendMessagesToAll() bool

CanSendMessagesToAll returns a boolean indicating if the occupant can send messages to all based on the occupant's role

func (*Occupant) CanSendPrivateMessages

func (o *Occupant) CanSendPrivateMessages() bool

CanSendPrivateMessages returns a boolean indicating if the occupant can send private messages based on the occupant's role

func (*Occupant) ChangeAffiliationToAdmin

func (o *Occupant) ChangeAffiliationToAdmin()

ChangeAffiliationToAdmin changes the affiliation to the admin affiliation

func (*Occupant) ChangeAffiliationToMember

func (o *Occupant) ChangeAffiliationToMember()

ChangeAffiliationToMember changes the affiliation to the member affiliation

func (*Occupant) ChangeAffiliationToNone

func (o *Occupant) ChangeAffiliationToNone()

ChangeAffiliationToNone changes the affiliation to the none affiliation

func (*Occupant) ChangeAffiliationToOutcast

func (o *Occupant) ChangeAffiliationToOutcast()

ChangeAffiliationToOutcast changes the affiliation to the outcast affiliation

func (*Occupant) ChangeAffiliationToOwner

func (o *Occupant) ChangeAffiliationToOwner()

ChangeAffiliationToOwner changes the affiliation to the owner affiliation

func (*Occupant) ChangeRoleToModerator

func (o *Occupant) ChangeRoleToModerator()

ChangeRoleToModerator changes the role to the moderator role

func (*Occupant) ChangeRoleToNone

func (o *Occupant) ChangeRoleToNone()

ChangeRoleToNone changes the role to the none role

func (*Occupant) ChangeRoleToParticipant

func (o *Occupant) ChangeRoleToParticipant()

ChangeRoleToParticipant changes the role to the participant role

func (*Occupant) ChangeRoleToVisitor

func (o *Occupant) ChangeRoleToVisitor()

ChangeRoleToVisitor changes the role to the visitor role

func (*Occupant) HasVoice

func (o *Occupant) HasVoice() bool

HasVoice returns a boolean indicating if the occupant has voice based on the role

func (*Occupant) Update

func (o *Occupant) Update(nickname string, affiliation data.Affiliation, role data.Role, status, statusMessage string, realJid jid.Full)

Update will update the information in this occupant object with the given information.

func (*Occupant) UpdateAffiliation

func (o *Occupant) UpdateAffiliation(a data.Affiliation)

UpdateAffiliation will update the occupant's affiliation

func (*Occupant) UpdateRole

func (o *Occupant) UpdateRole(a data.Role)

UpdateRole will update the occupant's role

func (*Occupant) UpdateStatus

func (o *Occupant) UpdateStatus(status, statusMsg string)

UpdateStatus will update the occupant's status

type OccupantAffiliationRole

type OccupantAffiliationRole struct {
	Affiliation data.Affiliation
	Role        data.Role
	Actor       string
	Reason      string
}

OccupantAffiliationRole contains information for the Presence Info received when the occupant affialiation or role was updated

type OccupantPresenceInfo

type OccupantPresenceInfo struct {
	Nickname        string
	RealJid         jid.Full
	AffiliationRole *OccupantAffiliationRole
	Status          string
	StatusMessage   string
}

OccupantPresenceInfo containts information for an occupant presence

type Room

type Room struct {
	ID jid.Bare

	MaxHistoryFetch       int
	AllowPrivateMessages  string // This can be 'anyone', 'participants', 'moderators', 'none'
	AllowInvites          bool
	ChangeSubject         bool
	EnableLogging         bool
	GetMemberList         []string // This is a list of the roles that can get the member list, 'moderator', 'participant' or 'visitor'
	Language              string
	PubSub                string
	MaxUsers              int
	MembersOnly           bool
	ModeratedRoom         bool
	PasswordProtectedRoom bool
	PersistentRoom        bool
	PresenceBroadcast     []string // This is a list of the roles for which presence is broadcast, 'moderator', 'participant' or 'visitor'
	PublicRoom            bool
	Description           string
	Name                  string
	Whois                 string // This can either be 'moderators' or 'anyone'
	// contains filtered or unexported fields
}

Room represents a multi user chat room that a session is currently connected to. It contains information about the room configuration itself, and the participants in the room

func NewRoom

func NewRoom(roomID jid.Bare) *Room

NewRoom returns a newly created room

func (*Room) AddSelfOccupant

func (r *Room) AddSelfOccupant(occupant *Occupant)

AddSelfOccupant set the own occupant of the room

func (*Room) GetSubject

func (r *Room) GetSubject() string

GetSubject returns the room subject

func (*Room) IsSelfOccupantAnOwner

func (r *Room) IsSelfOccupantAnOwner() bool

IsSelfOccupantAnOwner returns a boolean indicating if the self occupant is an owner

func (*Room) IsSelfOccupantInTheRoom

func (r *Room) IsSelfOccupantInTheRoom() bool

IsSelfOccupantInTheRoom returns true if the self occupant is in the room, false in otherwise

func (*Room) Publish

func (r *Room) Publish(ev events.MUC)

Publish will publish a new room event

func (*Room) Roster

func (r *Room) Roster() *RoomRoster

Roster returns the RoomRoster for this room

func (*Room) SelfOccupant

func (r *Room) SelfOccupant() *Occupant

SelfOccupant returns the self occupant of the room

func (*Room) SelfOccupantNickname

func (r *Room) SelfOccupantNickname() string

SelfOccupantNickname returns the nickname of the room's self occupant

func (*Room) Subscribe

func (r *Room) Subscribe(f func(events.MUC))

Subscribe subscribes the observer to room events

func (*Room) UpdateSubject

func (r *Room) UpdateSubject(s string) bool

UpdateSubject updates the room subject and returns a boolean indicating if the subject was updated (true) or not (false)

type RoomConfigForm

type RoomConfigForm struct {
	MaxHistoryFetch                ConfigListSingleField
	AllowPrivateMessages           ConfigListSingleField
	OccupantsCanInvite             bool
	OccupantsCanChangeSubject      bool
	Logged                         bool
	RetrieveMembersList            ConfigListMultiField
	Language                       string
	AssociatedPublishSubscribeNode string
	MaxOccupantsNumber             ConfigListSingleField
	MembersOnly                    bool
	Moderated                      bool
	PasswordProtected              bool
	Persistent                     bool
	PresenceBroadcast              ConfigListMultiField
	Public                         bool
	Admins                         []jid.Any
	Description                    string
	Title                          string
	Owners                         []jid.Any
	Password                       string
	Whois                          ConfigListSingleField
}

RoomConfigForm represents a room configuration form

func NewRoomConfigRom

func NewRoomConfigRom(form *xmppData.Form) *RoomConfigForm

NewRoomConfigRom creates a new room configuration form instance

func (*RoomConfigForm) GetFormData

func (rcf *RoomConfigForm) GetFormData() *xmppData.Form

GetFormData returns a representation of the room config FORM_TYPE as described in the XMPP specification for MUC

For more information see: https://xmpp.org/extensions/xep-0045.html#createroom-reserved https://xmpp.org/extensions/xep-0045.html#example-163

func (*RoomConfigForm) SetFormFields

func (rcf *RoomConfigForm) SetFormFields(form *xmppData.Form)

SetFormFields extract the form fields and updates the room config form properties based on each data

type RoomListing

type RoomListing struct {
	Service     jid.Any
	ServiceName string
	Jid         jid.Bare
	Name        string

	data.RoomDiscoInfo
	// contains filtered or unexported fields
}

RoomListing contains the information about a room for listing it

func NewRoomListing

func NewRoomListing() *RoomListing

NewRoomListing creates and returns a new room listing

func (*RoomListing) GetDiscoInfo

func (rl *RoomListing) GetDiscoInfo() data.RoomDiscoInfo

GetDiscoInfo returns the room disco info from the room listing

func (*RoomListing) OnUpdate

func (rl *RoomListing) OnUpdate(f func(*RoomListing, interface{}), data interface{})

OnUpdate takes a function and some data, and when this room listing is updated, that function will be called with the current room listing and the associated data

func (*RoomListing) SetFeatures

func (rl *RoomListing) SetFeatures(features []xmppData.DiscoveryFeature)

SetFeatures receive a list of features and updates the room listing properties based on each feature

func (*RoomListing) SetFormsData

func (rl *RoomListing) SetFormsData(forms []xmppData.Form)

SetFormsData extract the forms data and updates the room listing properties based on each data

func (*RoomListing) Updated

func (rl *RoomListing) Updated()

Updated should be called after a room listing has been updated, to notify observers of the update

type RoomManager

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

RoomManager contains information about each room that is currently active for a user When a window is closed, the room stays in this list. A room will only be removed from this list when the current user leaves that room.

func NewRoomManager

func NewRoomManager() *RoomManager

NewRoomManager returns a newly created room manager

func (*RoomManager) AddRoom

func (rm *RoomManager) AddRoom(r *Room) bool

AddRoom adds the room to the manager. If the room is already in the manager, this method will return false

func (*RoomManager) GetRoom

func (rm *RoomManager) GetRoom(roomID jid.Bare) (*Room, bool)

GetRoom returns the room corresponding to the given identifier, or returns false if it can't be found

func (*RoomManager) LeaveRoom

func (rm *RoomManager) LeaveRoom(room jid.Bare) bool

LeaveRoom will remove the room with the given identifier from the manager. If the room doesn't exist, this method will return false

type RoomRoster

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

RoomRoster contains information about all the occupants in a room

func (*RoomRoster) Admins

func (r *RoomRoster) Admins() []*Occupant

Admins returns all occupants that are administrators in a room, sorted by nickname.

func (*RoomRoster) AllOccupants

func (r *RoomRoster) AllOccupants() []*Occupant

AllOccupants returns a list of all occupants in the room, sorted by nickname

func (*RoomRoster) Banned

func (r *RoomRoster) Banned() []*Occupant

Banned returns all occupants that are banned in a room, sorted by nickname. This should likely not return anything.

func (*RoomRoster) GetOccupant

func (r *RoomRoster) GetOccupant(nickname string) (*Occupant, bool)

GetOccupant return an occupant if this exist in the roster, otherwise return nil and false

func (*RoomRoster) Members

func (r *RoomRoster) Members() []*Occupant

Members returns all occupants that are members in a room, sorted by nickname.

func (*RoomRoster) Moderators

func (r *RoomRoster) Moderators() []*Occupant

Moderators returns all occupants that have the moderator role in a room, sorted by nickname

func (*RoomRoster) NoAffiliation

func (r *RoomRoster) NoAffiliation() []*Occupant

NoAffiliation returns all occupants that have no affiliation in a room, sorted by nickname

func (*RoomRoster) NoRole

func (r *RoomRoster) NoRole() []*Occupant

NoRole returns all occupants that have no role in a room, sorted by nickname

func (*RoomRoster) OccupantsByAffiliation

func (r *RoomRoster) OccupantsByAffiliation() (none, banned, members, admins, owners []*Occupant)

OccupantsByAffiliation returns all occupants, divided into the different affiliations

func (*RoomRoster) OccupantsByRole

func (r *RoomRoster) OccupantsByRole() (none, visitors, participants, moderators []*Occupant)

OccupantsByRole returns all occupants, divided into the different roles

func (*RoomRoster) Owners

func (r *RoomRoster) Owners() []*Occupant

Owners returns all occupants that are owners in a room, sorted by nickname.

func (*RoomRoster) Participants

func (r *RoomRoster) Participants() []*Occupant

Participants returns all occupants that have the participant role in a room, sorted by nickname

func (*RoomRoster) RemoveOccupant

func (r *RoomRoster) RemoveOccupant(nickname string) error

RemoveOccupant delete an occupant if that exists

func (*RoomRoster) UpdateNickname

func (r *RoomRoster) UpdateNickname(nickname, newNickname string) error

UpdateNickname should be called when receiving an unavailable with status code 303 The new nickname should be given without the room name

func (*RoomRoster) UpdateOrAddOccupant

func (r *RoomRoster) UpdateOrAddOccupant(op *OccupantPresenceInfo) bool

UpdateOrAddOccupant return true if the occupant was updated or false if that was added

func (*RoomRoster) UpdatePresence

func (r *RoomRoster) UpdatePresence(op *OccupantPresenceInfo, tp string) (joined, left bool, err error)

UpdatePresence should be called when receiving a regular presence update with no type, or with unavailable as type. It will return indications on whether the presence update means the person joined the room, or left the room. Notice that updating of nick names is done separately and should not be done by calling this method.

func (*RoomRoster) Visitors

func (r *RoomRoster) Visitors() []*Occupant

Visitors returns all occupants that have the visitor role in a room, sorted by nickname

type ServiceListing

type ServiceListing struct {
	Jid  jid.Any
	Name string
}

ServiceListing contains the information about a service for listing it

func NewServiceListing

func NewServiceListing(service jid.Any, name string) *ServiceListing

NewServiceListing creates and returns a new service listing

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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