41 #include "ctk/ctk-textentry-multiline.h"
46 #ifdef EMAIL_CONF_WIDTH
47 #define MAIL_WIDTH EMAIL_CONF_WIDTH
52 #ifdef EMAIL_CONF_HEIGHT
53 #define MAIL_HEIGHT EMAIL_CONF_HEIGHT
55 #define MAIL_HEIGHT 17
58 #ifdef EMAIL_CONF_ERASE
59 #define MAIL_ERASE EMAIL_CONF_ERASE
64 #if (MAIL_WIDTH - 9) < 39
65 #define TEXTENTRY_WIDTH (MAIL_WIDTH - 9)
67 #define TEXTENTRY_WIDTH 39
71 unsigned char menuitem_compose, menuitem_setup, menuitem_quit;
76 static struct ctk_separator sep1 =
78 static struct ctk_label statuslabel =
79 {
CTK_LABEL(7, MAIL_HEIGHT + 4, MAIL_WIDTH - 14, 1,
"")};
82 static struct ctk_label tolabel =
85 static struct ctk_textentry totextentry =
88 static struct ctk_label cclabel =
91 static struct ctk_textentry cctextentry =
94 static struct ctk_label subjectlabel =
96 static char subject[40];
97 static struct ctk_textentry subjecttextentry =
100 static char mail[MAIL_WIDTH * MAIL_HEIGHT];
101 struct ctk_textentry mailtextentry =
102 {CTK_TEXTENTRY_INPUT(0, 3, MAIL_WIDTH - 1, MAIL_HEIGHT, mail, MAIL_WIDTH - 1, \
103 ctk_textentry_multiline_input)};
105 static struct ctk_button sendbutton =
109 static struct ctk_button erasebutton =
110 {
CTK_BUTTON(MAIL_WIDTH - 6, MAIL_HEIGHT + 4, 5,
"Erase")};
114 static struct ctk_label erasedialoglabel1 =
115 {
CTK_LABEL(2, 1, 22, 1,
"Really erase message?")};
116 static struct ctk_label erasedialoglabel2 =
117 {
CTK_LABEL(0, 2, 26, 1,
"All contents will be lost.")};
118 static struct ctk_button eraseyesbutton =
120 static struct ctk_button erasenobutton =
126 static struct ctk_label fromaddresslabel =
127 {
CTK_LABEL(0, 0, 25, 1,
"Name and e-mail address")};
128 static char fromaddress[40];
129 static struct ctk_textentry fromaddresstextentry =
132 static struct ctk_label smtpserverlabel =
133 {
CTK_LABEL(0, 3, 20, 1,
"Outgoing mailserver")};
134 static char smtpserver[40];
135 static struct ctk_textentry smtpservertextentry =
162 static struct ctk_button setupokbutton =
166 PROCESS(email_process,
"E-mail client");
168 AUTOSTART_PROCESSES(&email_process);
185 uip_ipaddr_t *addrptr;
188 for(cptr = smtpserver; *cptr !=
' ' && *cptr != 0; ++cptr);
195 resolv_query(smtpserver);
203 smtp_configure(
"contiki", addrptr);
205 petsciiconv_toascii(fromaddress,
sizeof(fromaddress));
209 prepare_message(
void)
212 petsciiconv_toascii(to,
sizeof(to));
213 petsciiconv_toascii(cc,
sizeof(cc));
214 petsciiconv_toascii(subject,
sizeof(subject));
215 petsciiconv_toascii(mail,
sizeof(mail));
235 ctk_dialog_new(&erasedialog, 26, 6);
263 ctk_window_new(&composewindow, MAIL_WIDTH + 1, MAIL_HEIGHT + 5,
"Compose e-mail");
306 smtp_send(to, cc, fromaddress, subject, mail, MAIL_WIDTH, MAIL_HEIGHT);
310 }
else if(w == (
struct ctk_widget *)&erasebutton) {
311 ctk_dialog_open(&erasedialog);
312 }
else if(w == (
struct ctk_widget *)&eraseyesbutton) {
315 }
else if(w == (
struct ctk_widget *)&erasenobutton) {
318 }
else if(w == (
struct ctk_widget *)&setupokbutton) {
324 if((
struct ctk_menu *)data == &menu) {
325 if(menu.
active == menuitem_compose) {
327 }
else if(menu.
active == menuitem_setup) {
329 }
else if(menu.
active == menuitem_quit) {
335 if(strcmp(data, smtpserver) == 0) {
345 }
else if(ev == PROCESS_EVENT_EXIT) {
353 smtp_done(
unsigned char error)
355 if(error == SMTP_ERR_OK) {
#define CTK_WIDGET_ADD(win, widg)
Add a widget to a window.
#define CTK_SEPARATOR(x, y, w)
Instantiating macro for the ctk_separator widget.
#define CTK_TEXTENTRY_CLEAR(e)
Clears a text entry widget and sets the cursor to the start of the text line.
unsigned char ctk_menuitem_add(CC_REGISTER_ARG struct ctk_menu *menu, char *name)
Adds a menu item to a menu.
Hostname is fresh and usable.
void ctk_window_open(CC_REGISTER_ARG struct ctk_window *w)
Open a window, or bring window to front if already open.
#define CTK_WIDGET_FOCUS(win, widg)
Set focus to a widget.
void ctk_window_close(struct ctk_window *w)
Close a window if it is open.
unsigned char active
The currently active menu item.
#define PROCESS_BEGIN()
Define the beginning of a process.
void ctk_menu_add(struct ctk_menu *menu)
Add a menu to the menu bar.
#define CTK_TEXTENTRY(x, y, w, h, text, len)
Instantiating macro for the ctk_textentry widget.
#define ctk_label_set_text(l, t)
Set the text of a label.
#define NULL
The null pointer.
process_event_t ctk_signal_menu_activate
Emitted when a menu item is activated.
#define uiplib_ipaddrconv
Convert a textual representation of an IP address to a numerical representation.
#define CTK_LABEL(x, y, w, h, text)
Instantiating macro for the ctk_label widget.
#define PROCESS_THREAD(name, ev, data)
Define the body of a process.
#define PROCESS_END()
Define the end of a process.
void ctk_window_new(struct ctk_window *window, unsigned char w, unsigned char h, char *title)
Create a new window.
CCIF process_event_t resolv_event_found
Event that is broadcasted when a DNS name has been resolved.
PETSCII/ASCII conversion functions.
#define LOADER_UNLOAD()
Unload a program from memory.
void ctk_menu_new(CC_REGISTER_ARG struct ctk_menu *menu, char *title)
Creates a new menu.
void ctk_menu_remove(struct ctk_menu *menu)
Remove a menu from the menu bar.
#define PROCESS_WAIT_EVENT()
Wait for an event to be posted to the process.
#define PROCESS(name, strname)
Declare a process.
process_event_t ctk_signal_widget_activate
Emitted when a widget is activated (pressed).
process_event_t tcpip_event
The uIP event.
Representation of an individual menu.
#define CTK_BUTTON(x, y, w, text)
Instantiating macro for the ctk_button widget.
Representation of a CTK window.
The generic CTK widget structure that contains all other widget structures.
#define CTK_WIDGET_REDRAW(widg)
Add a widget to the redraw queue.
unsigned char w
The width of the widget in character coordinates.
void process_exit(struct process *p)
Cause a process to exit.