-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
194 lines (169 loc) · 4.81 KB
/
main.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
package main
import (
"net/url"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/layout"
"fyne.io/fyne/v2/widget"
"github.com/nomin-project/nomin-mobile/sender"
)
func main() {
application := app.New()
window := application.NewWindow("Nomin")
from := widget.NewSelectEntry(curators)
from.SetPlaceHolder("FROM:")
to := widget.NewSelectEntry(galleries)
to.SetPlaceHolder("TO:")
subject := widget.NewEntry()
subject.SetPlaceHolder("SUBJECT:")
text := widget.NewMultiLineEntry()
text.SetPlaceHolder("TEXT:")
server := widget.NewEntry()
server.SetPlaceHolder("SMTP server address")
port := widget.NewEntry()
port.SetPlaceHolder("Port number")
provider := widget.NewSelect(providers, func(option string) {
setProvider(option, server, port)
})
provider.PlaceHolder = "Choose your internet provider"
sendButton := widget.NewButton("Send Mail", func() {
verifyAndSend(from, to, subject, text, server, port, window)
})
sendButton.Importance = widget.HighImportance
aboutURL, _ := url.Parse("https://gajdosik.org/nomin")
aboutNomin := widget.NewHyperlink("About Nomin app.", aboutURL)
mailAbout := widget.NewRichTextWithText("Get recommended by a famous curator. Write an email recommending your artistic persona, select the sending curator and receiving gallery or other institution and just get recommended without any need for boring and slow networking!")
mailAbout.Wrapping = fyne.TextWrapWord
smtpAbout := widget.NewRichTextWithText("To send the email Nomin needs the ADDRESS and the PORT of open SMTP mail server. You can insert one manually or choose SMTP server of your internet provider.")
smtpAbout.Wrapping = fyne.TextWrapWord
sendAbout := widget.NewRichTextWithText("Check the texts, addresses and configuration. If everything is allright, just send it out!")
sendAbout.Wrapping = fyne.TextWrapWord
smtpLayout := container.NewVBox(
container.NewPadded(
smtpAbout,
),
provider,
server,
port,
)
mailLayout := container.NewVBox(
container.NewPadded(
mailAbout,
),
from,
to,
subject,
text,
)
sendLayout :=
container.New(
layout.NewVBoxLayout(),
container.NewPadded(
sendAbout,
),
sendButton,
layout.NewSpacer(),
container.NewMax(
container.NewCenter(
aboutNomin,
),
),
)
tabs := container.NewAppTabs(
container.NewTabItem("1 Write", mailLayout),
container.NewTabItem("2 Configure", smtpLayout),
container.NewTabItem("3 Send", sendLayout),
)
window.SetContent(tabs)
window.Show()
application.Run()
}
func verifyAndSend(from, to *widget.SelectEntry, subject, text, address, port *widget.Entry, window fyne.Window) {
err := sender.SendMail(
from.Text,
to.Text,
subject.Text,
text.Text,
address.Text,
port.Text,
)
if err != nil {
w := dialog.NewInformation("Error!", "Message was not sent.\n\n1. Check your network connection.\n2. Check your SMTP configuration.\n\n"+err.Error(), window)
w.Resize(window.Content().Size())
w.Show()
} else {
w := dialog.NewInformation("Success!", "Email successfully sent!", window)
w.Resize(window.Content().Size())
w.Show()
}
}
var providers = []string{
"CZ: UPC",
"CZ: Vodafone",
"CZ: T-Mobile",
"DE: Vodafone",
"DE: T-Mobile",
"DE: 02 Telefonica",
"custom",
}
func setProvider(provider string, server, port *widget.Entry) {
var s, p string
switch provider {
case "CZ: UPC":
s = "mail.upcmail.cz"
p = "25"
case "CZ: Vodafone":
s = "smtp.vodafonemail.cz"
p = "25"
case "CZ: T-Mobile":
s = "smtp.t-email.cz"
p = "25"
case "DE: Vodafone":
s = "smtp.vodafonemail.de"
p = "25"
case "DE: T-Mobile":
s = "smtp.t-online.de"
p = "25"
case "DE: 02 Telefonica":
s = "smtp.o2online.de"
p = "25"
default:
s = ""
p = "25"
}
server.SetText(s)
port.SetText(p)
}
var curators = []string{
"Naomi Beckwith <nbeckwith@guggenheim.org>",
"Nicolas Bourriaud <NicolasBourriaud@moco.art>",
"Cornelia Butler <cbutler@hammer.ucla.edu>",
"RoseLee Goldberg <roselee.goldberg@nyu.edu>",
"Thelma Golden <TGolden@studiomuseum.org>",
"Hanru Hou <hanru.hou@fondazionemaxxi.it>",
"Candice Hopkins <chopkins@torontobiennial.org>",
"Bonaventure Ndikung <ndikung@gmx.de>",
"Fatos Ustek <mail@fatosustek.com>",
"KM Temporaer <info@kmtemporaer.de>",
"Milda Batakyte <milda@rupert.lt>",
"Hanne Mugaas <hanne@kunsthallstavanger.no>",
"Samuel Leuenberger <samuel@salts.ch>",
"Ovul Durmusoglu <durmusoglu@adbk-nuernberg.de>",
"Krist Gruijthuijsen <hinnik50@hotmail.com>",
"Melissa Chiu <melissa.chiu1@gmail.com>",
"Julija Reklaite <julija@rupert.lt>",
}
var galleries = []string{
"exhibitions@whitecube.com",
"info@agora-gallery.com",
"berlin@blainsouthern.com",
"info@blainsouthern.com",
"info@bombonprojects.com",
"info@ermes-ermes.com",
"info@marfaprojects.com",
"info@bws.mx",
"office@berlinbiennale.de",
"info@cjch.cz",
}