-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinitialsetup.go
142 lines (119 loc) · 3.32 KB
/
initialsetup.go
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
package main
import (
"fmt"
"log"
"log/slog"
"strings"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/lang"
"fyne.io/fyne/v2/widget"
"github.com/emersion/go-vcard"
"github.com/kothawoc/go-nntp"
"github.com/kothawoc/kothawoc/pkg/messages"
)
func displayWelcome() {
slog.Info("Done done dial start app", "uri", fyne.CurrentApp().Storage().RootURI())
label := widget.NewLabel(lang.L("Welcome: Create a new account"))
rt := widget.NewRichTextFromMarkdown(lang.L("App: Welcome Message"))
rt.Wrapping = fyne.TextWrapWord
dId := kc.DeviceId()
//dln := len(dId)
//shortId := dId[0:3] + "..." + dId[dln-3:]
groupName := widget.NewEntry()
groupDescription := widget.NewEntry()
idAlias := widget.NewEntry()
language := widget.NewEntry()
url := widget.NewEntry()
//{"post", "read", "reply", "cancel", "supersede"}
//labelSupersede := lang.L("Supersede")
//labelCancel := lang.L("Cancel")
labelRead := lang.L("Read")
labelReply := lang.L("Reply")
labelPost := lang.L("Post")
// labelUserId := lang.L("UserId")
checkGroup := widget.NewCheckGroup([]string{}, func(s []string) { fmt.Println("selected", s) })
checkGroup.Selected = []string{labelRead, labelReply}
checkGroup.Horizontal = true
sendFunc := func() {}
form := &widget.Form{
// Items: []*widget.FormItem{
// },
OnCancel: func() {
fmt.Println("Cancelled")
},
OnSubmit: func() {
sendFunc()
},
}
pm := NewPemsMgr(form)
//pm.Add()
pm.Render()
sendFunc = func() {
card := vcard.Card{}
card.SetValue(vcard.FieldNickname, idAlias.Text)
card.SetValue(vcard.FieldLanguage, language.Text)
card.SetValue(vcard.FieldURL, url.Text)
gParms := vcard.Params{}
for _, item := range checkGroup.Selected {
if item == labelRead {
gParms["read"] = []string{"true"}
}
if item == labelReply {
gParms["reply"] = []string{"true"}
}
if item == labelPost {
gParms["post"] = []string{"true"}
}
}
card.Add("X-KW-PERMS", &vcard.Field{
Value: "group",
Params: gParms,
})
for _, item := range pm.Items {
parms := vcard.Params{}
if item.Read.Checked {
parms["read"] = []string{"true"}
}
if item.Reply.Checked {
parms["reply"] = []string{"true"}
}
if item.Post.Checked {
parms["post"] = []string{"true"}
}
if item.Cancel.Checked {
parms["cancel"] = []string{"true"}
}
if item.Supersede.Checked {
parms["supersede"] = []string{"true"}
}
card.Add("X-KW-PERMS", &vcard.Field{
Value: item.TorId.Text,
Params: parms,
})
}
vcard.ToV4(card)
msg, err := messages.CreateNewsGroupMail(kc.DeviceKey(), kc.Server.IdGenerator, dId+"."+groupName.Text, groupDescription.Text, card, nntp.PostingPermitted) //(string, error)
if err != nil {
log.Printf("Failed at creating new groups mail.")
}
kc.NNTPclient.Post(strings.NewReader(msg))
}
// add group name
// group descripton
// group vcard
// CATEGORIES:public\,cabbage
// LANG:enCheckGroup Item 2
// NICKNAME:The magic bus
// URL:https://github.com/kothawoc
form.Append("ID Alias", idAlias)
form.Append("Description", groupDescription)
form.Append("Language", language)
form.Append("URL", url)
form.Append("Group Permissions", checkGroup)
form.Append("Extra Perms", pm.Vbox)
content.RemoveAll()
// label := widget.NewLabel("Select an item from the navigation pane")
content.Add(label)
content.Add(form)
content.Refresh()
}