-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrooms.go
More file actions
80 lines (72 loc) · 1.8 KB
/
rooms.go
File metadata and controls
80 lines (72 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package citadel
import (
"fmt"
"time"
)
var Rooms struct {
List []room
Updated int
}
type room struct {
Name string // Actual name of this room; may include '\' to separate trees
Flag int // QRFlags of this room
Floor floor // The floor number its on
NoUnread int // 1 Number of unread messages in this room
NoTotal int // 2 Number of total messages in this room
Modified time.Time // 15 From Server
Updated time.Time // Time this was fatched by us
}
// Enter a specific room by name
func (c *Citadel) Goto(ro string) (ok bool) {
if c.Request(fmt.Sprintf("GOTO %s", ro)) {
no := len(c.Resp)
if no > 14 {
r := new(room)
r.Name = c.Resp[0] // From Citadel to get correct Upper/Lower case
r.Updated = time.Now().UTC() // email servers should always run in UTC mode
r.Modified, ok = StrToTime(c.Resp[15])
ok = true
}
}
return
}
// Retrieve modification time of current room
func (c *Citadel) RoomsStat() (ok bool) {
if c.Request("STAT") {
c.Check()
if c.Resp[0] == c.Room.Name {
c.Room.Updated = time.Now().UTC() // a email servers should always run in UTC mode
c.Room.Modified, ok = StrToTime(c.Resp[1])
ok = true
}
}
return
}
// List all accessible Rooms
func (c *Citadel) RoomsAll() bool {
return c.rooms("LRMS")
}
// List all Public Rooms
func (c *Citadel) RoomsPublic() bool {
return c.rooms("LPRM")
}
func (c *Citadel) rooms(code string) (ok bool) {
c.Request(code)
if c.Code == CODE_LISTING_FOLLOWS {
res := c.Responce()
ok = true
no := len(res)
if no != 0 {
for i := 0; i < no; i++ {
r := res[i]
if r[0] == "000" {
break
}
flag, _ := StrToInt(r[1])
floor, _ := StrToInt(r[2])
Rooms.List = append(Rooms.List, room{Name: r[0], Flag: flag, Floor: Floors[floor]})
}
}
}
return
}