Debian Codegraph @

interface/matrix.go

raw symbols SCIP
1 // gomuks - A terminal Matrix client written in Go.
2 // Copyright (C) 2020 Tulir Asokan
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
13 //
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <https://www.gnu.org/licenses/>.
16
17 package ifc
18
19 import (
20 "maunium.net/go/mautrix"
21 "maunium.net/go/mautrix/crypto/attachment"
22 "maunium.net/go/mautrix/event"
23 "maunium.net/go/mautrix/id"
24
25 "maunium.net/go/gomuks/config"
26 "maunium.net/go/gomuks/matrix/muksevt"
27 "maunium.net/go/gomuks/matrix/rooms"
28 )
29
30 type Relation struct {
31 Type event.RelationType
32 Event *muksevt.Event
33 }
34
35 type UploadedMediaInfo struct {
36 *mautrix.RespMediaUpload
37 EncryptionInfo *attachment.EncryptedFile
38 MsgType event.MessageType
39 Name string
40 Info *event.FileInfo
41 }
42
43 type MatrixContainer interface {
44 Client() *mautrix.Client
45 Preferences() *config.UserPreferences
46 InitClient(isStartup bool) error
47 Initialized() bool
48
49 Start()
50 Stop()
51
52 Login(user, password string) error
53 Logout()
54 UIAFallback(authType mautrix.AuthType, sessionID string) error
55
56 SendPreferencesToMatrix()
57 PrepareMarkdownMessage(roomID id.RoomID, msgtype event.MessageType, text, html string, relation *Relation) *muksevt.Event
58 PrepareMediaMessage(room *rooms.Room, path string, relation *Relation) (*muksevt.Event, error)
59 SendEvent(evt *muksevt.Event) (id.EventID, error)
60 Redact(roomID id.RoomID, eventID id.EventID, reason string) error
61 SendTyping(roomID id.RoomID, typing bool)
62 MarkRead(roomID id.RoomID, eventID id.EventID)
63 JoinRoom(roomID id.RoomID, server string) (*rooms.Room, error)
64 LeaveRoom(roomID id.RoomID) error
65 CreateRoom(req *mautrix.ReqCreateRoom) (*rooms.Room, error)
66
67 FetchMembers(room *rooms.Room) error
68 GetHistory(room *rooms.Room, limit int, dbPointer uint64) ([]*muksevt.Event, uint64, error)
69 GetEvent(room *rooms.Room, eventID id.EventID) (*muksevt.Event, error)
70 GetRoom(roomID id.RoomID) *rooms.Room
71 GetOrCreateRoom(roomID id.RoomID) *rooms.Room
72
73 UploadMedia(path string, encrypt bool) (*UploadedMediaInfo, error)
74 Download(uri id.ContentURI, file *attachment.EncryptedFile) ([]byte, error)
75 DownloadToDisk(uri id.ContentURI, file *attachment.EncryptedFile, target string) (string, error)
76 GetDownloadURL(uri id.ContentURI, file *attachment.EncryptedFile) string
77 GetCachePath(uri id.ContentURI) string
78
79 Crypto() Crypto
80 }
81
82 type Crypto interface {
83 Load() error
84 FlushStore() error
85 ProcessSyncResponse(resp *mautrix.RespSync, since string) bool
86 ProcessInRoomVerification(evt *event.Event) error
87 HandleMemberEvent(*event.Event)
88 DecryptMegolmEvent(*event.Event) (*event.Event, error)
89 EncryptMegolmEvent(id.RoomID, event.Type, interface{}) (*event.EncryptedEventContent, error)
90 ShareGroupSession(id.RoomID, []id.UserID) error
91 Fingerprint() string
92 }