* Reduced iconbar button size to 90% because it looked obtuse on a smaller screen
[citadel.git] / webcit / pushemail.c
blob5c55ddc390224c2ae53f7cf32b01acd04f28ab5e
1 /*
2 * Edits a users push email settings
3 * Author: Mathew McBride <matt@mcbridematt.dhs.org>
4 */
5 #include "webcit.h"
7 void display_pushemail(void) {
8 char buf[SIZ];
9 int is_none = 0;
10 int is_pager = 0;
11 int is_funambol = 0;
12 char mobnum[20];
14 /* Find any existing settings*/
15 if (goto_config_room() == 0) {
16 int msgnum = 0;
17 serv_puts("MSGS ALL|0|1");
18 serv_getln(buf, sizeof(buf));
19 if (buf[0] == '8') {
20 serv_puts("subj|__ Push email settings __");
21 serv_puts("000");
22 while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
23 msgnum = atol(buf);
27 if (msgnum > 0L) {
28 serv_printf("MSG0 %d", msgnum);
29 serv_getln(buf, sizeof buf);
30 if (buf[0] == '1') {
31 int i =0;
32 while (serv_getln(buf, sizeof buf),
33 (strcmp(buf, "text") && strcmp(buf, "000"))) {
35 if (!strcmp(buf, "text")) {
36 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
37 if (strncasecmp(buf, "none", 4) == 0) {
38 is_none = 1;
39 } else if (strncasecmp(buf, "textmessage", 11) == 0) {
40 is_pager = 1;
41 i++;
42 } else if (strncasecmp(buf, "funambol", 8) == 0) {
43 is_funambol = 1;
44 } else if (i == 1) {
45 strncpy(mobnum, buf, 20);
46 i++;
52 // TODO: do in a saner fashion.
53 svput("PUSH_NONE", WCS_STRING, " "); // defaults
54 svput("PUSH_TEXT", WCS_STRING, " ");
55 svput("PUSH_FNBL", WCS_STRING, " ");
56 svput("SMSNUM", WCS_STRING, " ");
57 if (is_none) {
58 svput("PUSH_NONE", WCS_STRING, "checked=\"checked\"");
59 } else if (is_pager) {
60 svput("PUSH_TEXT", WCS_STRING, "checked=\"checked\"");
61 svprintf(HKEY("SMSNUM"), WCS_STRING, "value=\"%s\"", mobnum);
62 } else if (is_funambol) {
63 svput("PUSH_FNBL", WCS_STRING, "checked=\"checked\"");
65 serv_printf("GOTO %s", ChrPtr(WC->wc_roomname));
66 serv_getln(buf, sizeof buf);
68 output_headers(1, 1, 2, 0, 0, 0);
69 do_template("pushemail", NULL);
70 /*do_template("endbox"); */
71 wDumpContent(1);
74 void save_pushemail(void) {
75 char buf[SIZ];
76 int msgnum = 0;
77 char *pushsetting = bstr("pushsetting");
78 char *sms = NULL;
79 if (strncasecmp(pushsetting, "textmessage", 11) == 0) {
80 sms = bstr("user_sms_number");
82 if (goto_config_room() != 0) return; /* oh well. */
83 serv_puts("MSGS ALL|0|1");
84 serv_getln(buf, sizeof buf);
85 if (buf[0] == '8') {
86 serv_puts("subj|__ Push email settings __");
87 serv_puts("000");
88 } else {
89 printf("Junk in save_pushemail buffer!: %s\n", buf);
90 return;
92 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
93 msgnum = atol(buf);
96 if (msgnum > 0L) {
97 serv_printf("DELE %d", msgnum);
98 serv_getln(buf, sizeof buf);
101 serv_printf("ENT0 1||0|1|__ Push email settings __|");
102 serv_getln(buf, sizeof buf);
103 if (buf[0] == '4') {
104 serv_puts(pushsetting);
105 if (sms != NULL) {
106 serv_puts(sms);
108 serv_puts("");
109 serv_puts("000");
112 /** Go back to the room we're supposed to be in */
113 serv_printf("GOTO %s", ChrPtr(WC->wc_roomname));
114 serv_getln(buf, sizeof buf);
115 http_redirect("display_pushemail");
118 void
119 InitModule_PUSHMAIL
120 (void)
122 WebcitAddUrlHandler(HKEY("display_pushemail"), display_pushemail, 0);
123 WebcitAddUrlHandler(HKEY("save_pushemail"), save_pushemail, 0);