2021-11-09 23:47:33 +00:00
|
|
|
package peer
|
|
|
|
|
|
|
|
import (
|
|
|
|
"cwtch.im/cwtch/event"
|
|
|
|
"cwtch.im/cwtch/model"
|
|
|
|
"cwtch.im/cwtch/model/attr"
|
|
|
|
"cwtch.im/cwtch/protocol/connections"
|
|
|
|
"git.openprivacy.ca/openprivacy/connectivity"
|
|
|
|
)
|
|
|
|
|
|
|
|
// AccessPeeringState provides access to functions relating to the underlying connections of a peer.
|
|
|
|
type AccessPeeringState interface {
|
2021-11-17 22:34:13 +00:00
|
|
|
GetPeerState(string) connections.ConnectionState
|
2021-11-09 23:47:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ModifyPeeringState is a meta-interface intended to restrict callers to modify-only access to connection peers
|
|
|
|
type ModifyPeeringState interface {
|
|
|
|
BlockUnknownConnections()
|
|
|
|
AllowUnknownConnections()
|
|
|
|
PeerWithOnion(string)
|
|
|
|
JoinServer(string) error
|
|
|
|
}
|
|
|
|
|
|
|
|
// ModifyContactsAndPeers is a meta-interface intended to restrict a call to reading and modifying contacts
|
|
|
|
// and peers.
|
|
|
|
type ModifyContactsAndPeers interface {
|
|
|
|
ModifyPeeringState
|
|
|
|
}
|
|
|
|
|
|
|
|
// ReadServers provides access to the servers
|
|
|
|
type ReadServers interface {
|
|
|
|
GetServers() []string
|
|
|
|
}
|
|
|
|
|
|
|
|
// ModifyGroups provides write-only access add/edit/remove new groups
|
|
|
|
type ModifyGroups interface {
|
2021-11-11 00:41:43 +00:00
|
|
|
ImportGroup(string) (int, error)
|
2021-11-16 23:06:30 +00:00
|
|
|
StartGroup(string, string) (int, error)
|
2021-11-09 23:47:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ModifyServers provides write-only access to servers
|
|
|
|
type ModifyServers interface {
|
2021-11-19 08:09:19 +00:00
|
|
|
AddServer(string) (string, error)
|
2021-11-09 23:47:33 +00:00
|
|
|
ResyncServer(onion string) error
|
|
|
|
}
|
|
|
|
|
|
|
|
// SendMessages enables a caller to sender messages to a contact
|
|
|
|
type SendMessages interface {
|
2022-03-23 21:08:30 +00:00
|
|
|
SendMessage(conversation int, message string) (int, error)
|
|
|
|
SendInviteToConversation(conversationID int, inviteConversationID int) (int, error)
|
2021-11-17 22:34:13 +00:00
|
|
|
SendScopedZonedGetValToContact(conversationID int, scope attr.Scope, zone attr.Zone, key string)
|
2021-11-09 23:47:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// CwtchPeer provides us with a way of testing systems built on top of cwtch without having to
|
|
|
|
// directly implement a cwtchPeer.
|
|
|
|
type CwtchPeer interface {
|
|
|
|
|
|
|
|
// Core Cwtch Peer Functions that should not be exposed to
|
|
|
|
// most functions
|
|
|
|
Init(event.Manager)
|
2021-11-11 00:41:43 +00:00
|
|
|
|
|
|
|
GenerateProtocolEngine(acn connectivity.ACN, bus event.Manager) (connections.Engine, error)
|
2021-11-09 23:47:33 +00:00
|
|
|
|
|
|
|
AutoHandleEvents(events []event.Type)
|
|
|
|
Listen()
|
|
|
|
StartPeersConnections()
|
|
|
|
StartServerConnections()
|
|
|
|
Shutdown()
|
|
|
|
|
|
|
|
// GetOnion is deprecated. If you find yourself needing to rely on this method it is time
|
|
|
|
// to consider replacing this with a GetAddress(es) function that can fully expand cwtch beyond the boundaries
|
|
|
|
// of tor v3 onion services.
|
|
|
|
// Deprecated
|
|
|
|
GetOnion() string
|
|
|
|
|
|
|
|
// SetScopedZonedAttribute allows the setting of an attribute by scope and zone
|
|
|
|
// scope.zone.key = value
|
|
|
|
SetScopedZonedAttribute(scope attr.Scope, zone attr.Zone, key string, value string)
|
|
|
|
|
|
|
|
// GetScopedZonedAttribute allows the retrieval of an attribute by scope and zone
|
|
|
|
// scope.zone.key = value
|
|
|
|
GetScopedZonedAttribute(scope attr.Scope, zone attr.Zone, key string) (string, bool)
|
|
|
|
|
2022-07-06 03:41:16 +00:00
|
|
|
// GetScopedZonedAttributeKeys returns all keys associated with a given scope and zone
|
|
|
|
GetScopedZonedAttributeKeys(scope attr.Scope, zone attr.Zone) ([]string, error)
|
2022-07-05 22:31:44 +00:00
|
|
|
|
2021-11-09 23:47:33 +00:00
|
|
|
AccessPeeringState
|
|
|
|
ModifyPeeringState
|
|
|
|
|
|
|
|
ModifyGroups
|
|
|
|
|
|
|
|
ReadServers
|
|
|
|
ModifyServers
|
|
|
|
|
|
|
|
SendMessages
|
|
|
|
|
2021-11-16 23:06:30 +00:00
|
|
|
// Import Bundle
|
|
|
|
ImportBundle(string) error
|
|
|
|
|
2021-11-09 23:47:33 +00:00
|
|
|
// New Unified Conversation Interfaces
|
2021-11-11 00:41:43 +00:00
|
|
|
NewContactConversation(handle string, acl model.AccessControl, accepted bool) (int, error)
|
2021-11-10 22:28:52 +00:00
|
|
|
FetchConversations() ([]*model.Conversation, error)
|
2021-11-11 00:41:43 +00:00
|
|
|
GetConversationInfo(conversation int) (*model.Conversation, error)
|
2021-11-09 23:47:33 +00:00
|
|
|
FetchConversationInfo(handle string) (*model.Conversation, error)
|
2021-11-10 22:28:52 +00:00
|
|
|
AcceptConversation(conversation int) error
|
2021-11-17 22:34:13 +00:00
|
|
|
BlockConversation(conversation int) error
|
2022-01-06 17:55:26 +00:00
|
|
|
UnblockConversation(conversation int) error
|
2021-11-10 22:28:52 +00:00
|
|
|
SetConversationAttribute(conversation int, path attr.ScopedZonedPath, value string) error
|
|
|
|
GetConversationAttribute(conversation int, path attr.ScopedZonedPath) (string, error)
|
|
|
|
DeleteConversation(conversation int) error
|
2021-11-09 23:47:33 +00:00
|
|
|
|
2021-11-17 22:34:13 +00:00
|
|
|
// New Unified Conversation Channel Interfaces
|
2021-11-10 22:28:52 +00:00
|
|
|
GetChannelMessage(conversation int, channel int, id int) (string, model.Attributes, error)
|
2021-11-17 22:34:13 +00:00
|
|
|
GetChannelMessageCount(conversation int, channel int) (int, error)
|
2021-11-18 23:43:58 +00:00
|
|
|
GetChannelMessageByContentHash(conversation int, channel int, contenthash string) (int, error)
|
2021-11-17 22:34:13 +00:00
|
|
|
GetMostRecentMessages(conversation int, channel int, offset int, limit int) ([]model.ConversationMessage, error)
|
2021-11-19 20:27:52 +00:00
|
|
|
UpdateMessageAttribute(conversation int, channel int, id int, key string, value string) error
|
2021-11-09 23:47:33 +00:00
|
|
|
|
|
|
|
ShareFile(fileKey string, serializedManifest string)
|
2022-07-05 22:31:44 +00:00
|
|
|
StopFileShare(fileKey string)
|
2022-07-06 18:06:06 +00:00
|
|
|
StopAllFileShares()
|
2021-11-19 19:49:04 +00:00
|
|
|
CheckPassword(password string) bool
|
2021-12-17 21:58:54 +00:00
|
|
|
ChangePassword(oldpassword string, newpassword string, newpasswordAgain string) error
|
2022-03-08 21:45:26 +00:00
|
|
|
Export(file string) error
|
2021-11-19 19:49:04 +00:00
|
|
|
Delete()
|
2021-11-09 23:47:33 +00:00
|
|
|
}
|