3 * Edits a users push email settings
4 * Author: Mathew McBride <matt@mcbridematt.dhs.org>
8 void display_pushemail(void) {
12 long vector[8] = { 8, 0, 0, 1, 2, 3, 4, 5 };
13 WCTemplputParams SubTP;
16 StackContext(NULL, &SubTP, &vector, CTX_LONGVECTOR, 0, NULL);
19 /* Find any existing settings */
21 memset(&Room, 0, sizeof(folder));
22 if (goto_config_room(Buf, &Room) == 0) {
24 serv_puts("MSGS ALL|0|1");
25 StrBuf_ServGetln(Buf);
26 if (GetServerStatus(Buf, NULL) == 8) {
27 serv_puts("subj|__ Push email settings __");
29 while (!Done && StrBuf_ServGetln(Buf) >= 0) {
30 if ((StrLength(Buf) == 3) && !strcmp(ChrPtr(Buf), "000")) {
38 serv_printf("MSG0 %d", msgnum);
39 StrBuf_ServGetln(Buf);
40 if (GetServerStatus(Buf, NULL) == 1) {
43 while (!Done && StrBuf_ServGetln(Buf) >= 0) {
44 if (((StrLength(Buf) == 3) &&
45 !strcmp(ChrPtr(Buf), "000")) ||
46 ((StrLength(Buf) == 4) && !strcmp(ChrPtr(Buf), "text"))) {
51 if (!strcmp(ChrPtr(Buf), "text")) {
53 while (!Done && StrBuf_ServGetln(Buf) >= 0) {
54 if ((StrLength(Buf) == 3) && !strcmp(ChrPtr(Buf), "000")) {
58 if (strncasecmp(ChrPtr(Buf), "none", 4) == 0) {
61 else if (strncasecmp(ChrPtr(Buf), "textmessage", 11) == 0) {
65 else if (strncasecmp(ChrPtr(Buf), "funambol", 8) == 0) {
68 else if (strncasecmp(ChrPtr(Buf), "httpmessage", 12) == 0) {
72 strncpy(mobnum, ChrPtr(Buf), 20);
79 serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
80 StrBuf_ServGetln(Buf);
81 GetServerStatus(Buf, NULL);
84 output_headers(1, 1, 1, 0, 0, 0);
85 DoTemplate(HKEY("prefs_pushemail"), NULL, &SubTP);
87 UnStackContext(&SubTP);
91 void save_pushemail(void) {
97 char *pushsetting = bstr("pushsetting");
100 if (strncasecmp(pushsetting, "textmessage", 11) == 0) {
101 sms = bstr("user_sms_number");
104 memset(&Room, 0, sizeof(folder));
105 if (goto_config_room(Buf, &Room) != 0) {
108 return; /* oh well. */
112 serv_puts("MSGS ALL|0|1");
113 StrBuf_ServGetln(Buf);
114 if (GetServerStatus(Buf, NULL) == 8) {
115 serv_puts("subj|__ Push email settings __");
119 printf("Junk in save_pushemail buffer!: %s\n", buf);
124 while (!Done && StrBuf_ServGetln(Buf) >= 0) {
125 if ((StrLength(Buf) == 3) && !strcmp(ChrPtr(Buf), "000")) {
129 msgnum = StrTol(Buf);
133 serv_printf("DELE %d", msgnum);
134 StrBuf_ServGetln(Buf);
135 GetServerStatus(Buf, NULL);
138 serv_printf("ENT0 1||0|1|__ Push email settings __|");
139 StrBuf_ServGetln(Buf);
140 if (GetServerStatus(Buf, NULL) == 4) {
141 serv_puts(pushsetting);
149 /** Go back to the room we're supposed to be in */
150 serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
151 StrBuf_ServGetln(Buf);
152 GetServerStatus(Buf, NULL);
153 http_redirect("display_pushemail");
157 void InitModule_PUSHMAIL(void) {
158 WebcitAddUrlHandler(HKEY("display_pushemail"), "", 0, display_pushemail, 0);
159 WebcitAddUrlHandler(HKEY("save_pushemail"), "", 0, save_pushemail, 0);