2 * Edits a users push email settings
3 * Author: Mathew McBride <matt@mcbridematt.dhs.org>
7 void display_pushemail(void) {
14 /* Find any existing settings*/
15 if (goto_config_room() == 0) {
17 serv_puts("MSGS ALL|0|1");
18 serv_getln(buf
, sizeof(buf
));
20 serv_puts("subj|__ Push email settings __");
22 while(serv_getln(buf
, sizeof buf
), strcmp(buf
, "000")) {
28 serv_printf("MSG0 %d", msgnum
);
29 serv_getln(buf
, sizeof buf
);
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) {
39 } else if (strncasecmp(buf
, "textmessage", 11) == 0) {
42 } else if (strncasecmp(buf
, "funambol", 8) == 0) {
45 strncpy(mobnum
, buf
, 20);
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
, " ");
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"); */
74 void save_pushemail(void) {
77 char *pushsetting
= bstr("pushsetting");
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
);
86 serv_puts("subj|__ Push email settings __");
89 printf("Junk in save_pushemail buffer!: %s\n", buf
);
92 while (serv_getln(buf
, sizeof buf
), strcmp(buf
, "000")) {
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
);
104 serv_puts(pushsetting
);
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");
122 WebcitAddUrlHandler(HKEY("display_pushemail"), display_pushemail
, 0);
123 WebcitAddUrlHandler(HKEY("save_pushemail"), save_pushemail
, 0);