2 * Edits a users push email settings
3 * Author: Mathew McBride <matt@mcbridematt.dhs.org>
7 void display_pushemail(void)
16 /* Find any existing settings*/
18 if (goto_config_room(Buf) == 0) {
20 serv_puts("MSGS ALL|0|1");
21 StrBuf_ServGetln(Buf);
22 if (GetServerStatus(Buf, NULL) == 8) {
23 serv_puts("subj|__ Push email settings __");
26 StrBuf_ServGetln(Buf)) {
27 if ( (StrLength(Buf)==3) &&
28 !strcmp(ChrPtr(Buf), "000")) {
36 serv_printf("MSG0 %d", msgnum);
37 StrBuf_ServGetln(Buf);
38 if (GetServerStatus(Buf, NULL) == 1) {
42 StrBuf_ServGetln(Buf)) {
43 if (( (StrLength(Buf)==3) &&
44 !strcmp(ChrPtr(Buf), "000"))||
45 ((StrLength(Buf)==4) &&
46 !strcmp(ChrPtr(Buf), "text")))
52 if (!strcmp(ChrPtr(Buf), "text")) {
55 StrBuf_ServGetln(Buf)) {
56 if ( (StrLength(Buf)==3) &&
57 !strcmp(ChrPtr(Buf), "000")) {
61 if (strncasecmp(ChrPtr(Buf), "none", 4) == 0) {
63 } else if (strncasecmp(ChrPtr(Buf), "textmessage", 11) == 0) {
66 } else if (strncasecmp(ChrPtr(Buf), "funambol", 8) == 0) {
69 strncpy(mobnum, ChrPtr(Buf), 20);
76 /* TODO: do in a saner fashion. */
77 svput("PUSH_NONE", WCS_STRING, " "); /* defaults */
78 svput("PUSH_TEXT", WCS_STRING, " ");
79 svput("PUSH_FNBL", WCS_STRING, " ");
80 svput("SMSNUM", WCS_STRING, " ");
82 svput("PUSH_NONE", WCS_STRING, "checked=\"checked\"");
83 } else if (is_pager) {
84 svput("PUSH_TEXT", WCS_STRING, "checked=\"checked\"");
85 svprintf(HKEY("SMSNUM"), WCS_STRING, "value=\"%s\"", mobnum);
86 } else if (is_funambol) {
87 svput("PUSH_FNBL", WCS_STRING, "checked=\"checked\"");
89 serv_printf("GOTO %s", ChrPtr(WC->wc_roomname));
90 StrBuf_ServGetln(Buf);
91 GetServerStatus(Buf, NULL);
93 output_headers(1, 1, 2, 0, 0, 0);
94 do_template("pushemail", NULL);
95 /*do_template("endbox"); */
100 void save_pushemail(void)
106 char *pushsetting = bstr("pushsetting");
109 if (strncasecmp(pushsetting, "textmessage", 11) == 0) {
110 sms = bstr("user_sms_number");
113 if (goto_config_room(Buf) != 0) {
115 return; /* oh well. */
117 serv_puts("MSGS ALL|0|1");
118 StrBuf_ServGetln(Buf);
119 if (GetServerStatus(Buf, NULL) == 8) {
120 serv_puts("subj|__ Push email settings __");
123 printf("Junk in save_pushemail buffer!: %s\n", buf);
128 StrBuf_ServGetln(Buf)) {
129 if ( (StrLength(Buf)==3) &&
130 !strcmp(ChrPtr(Buf), "000")) {
134 msgnum = StrTol(Buf);
138 serv_printf("DELE %d", msgnum);
139 StrBuf_ServGetln(Buf);
140 GetServerStatus(Buf, NULL);
143 serv_printf("ENT0 1||0|1|__ Push email settings __|");
144 StrBuf_ServGetln(Buf);
145 if (GetServerStatus(Buf, NULL) == 4) {
146 serv_puts(pushsetting);
154 /** Go back to the room we're supposed to be in */
155 serv_printf("GOTO %s", ChrPtr(WC->wc_roomname));
156 StrBuf_ServGetln(Buf);
157 GetServerStatus(Buf, NULL);
158 http_redirect("display_pushemail");
165 WebcitAddUrlHandler(HKEY("display_pushemail"), display_pushemail, 0);
166 WebcitAddUrlHandler(HKEY("save_pushemail"), save_pushemail, 0);