2 * Edits a users push email settings
3 * Author: Mathew McBride <matt@mcbridematt.dhs.org>
7 void display_pushemail(void)
12 long vector[8] = {8, 0, 0, 1, 2, 3, 4, 5};
13 WCTemplputParams SubTP;
16 memset(&SubTP, 0, sizeof(WCTemplputParams));
17 SubTP.Filter.ContextType = CTX_LONGVECTOR;
18 SubTP.Context = &vector;
21 /* Find any existing settings*/
23 memset(&Room, 0, sizeof(folder));
24 if (goto_config_room(Buf, &Room) == 0) {
26 serv_puts("MSGS ALL|0|1");
27 StrBuf_ServGetln(Buf);
28 if (GetServerStatus(Buf, NULL) == 8) {
29 serv_puts("subj|__ Push email settings __");
32 StrBuf_ServGetln(Buf) >= 0) {
33 if ( (StrLength(Buf)==3) &&
34 !strcmp(ChrPtr(Buf), "000")) {
42 serv_printf("MSG0 %d", msgnum);
43 StrBuf_ServGetln(Buf);
44 if (GetServerStatus(Buf, NULL) == 1) {
48 StrBuf_ServGetln(Buf) >= 0) {
49 if (( (StrLength(Buf)==3) &&
50 !strcmp(ChrPtr(Buf), "000"))||
51 ((StrLength(Buf)==4) &&
52 !strcmp(ChrPtr(Buf), "text")))
58 if (!strcmp(ChrPtr(Buf), "text")) {
61 StrBuf_ServGetln(Buf) >= 0) {
62 if ( (StrLength(Buf)==3) &&
63 !strcmp(ChrPtr(Buf), "000")) {
67 if (strncasecmp(ChrPtr(Buf), "none", 4) == 0) {
69 } else if (strncasecmp(ChrPtr(Buf), "textmessage", 11) == 0) {
72 } else if (strncasecmp(ChrPtr(Buf), "funambol", 8) == 0) {
74 } else if (strncasecmp(ChrPtr(Buf), "httpmessage", 12) == 0) {
77 strncpy(mobnum, ChrPtr(Buf), 20);
84 serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
85 StrBuf_ServGetln(Buf);
86 GetServerStatus(Buf, NULL);
89 output_headers(1, 1, 1, 0, 0, 0);
90 DoTemplate(HKEY("prefs_pushemail"), NULL, &SubTP);
95 void save_pushemail(void)
102 char *pushsetting = bstr("pushsetting");
105 if (strncasecmp(pushsetting, "textmessage", 11) == 0) {
106 sms = bstr("user_sms_number");
109 memset(&Room, 0, sizeof(folder));
110 if (goto_config_room(Buf, &Room) != 0) {
113 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);
129 StrBuf_ServGetln(Buf) >= 0) {
130 if ( (StrLength(Buf)==3) &&
131 !strcmp(ChrPtr(Buf), "000")) {
135 msgnum = StrTol(Buf);
139 serv_printf("DELE %d", msgnum);
140 StrBuf_ServGetln(Buf);
141 GetServerStatus(Buf, NULL);
144 serv_printf("ENT0 1||0|1|__ Push email settings __|");
145 StrBuf_ServGetln(Buf);
146 if (GetServerStatus(Buf, NULL) == 4) {
147 serv_puts(pushsetting);
155 /** Go back to the room we're supposed to be in */
156 serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
157 StrBuf_ServGetln(Buf);
158 GetServerStatus(Buf, NULL);
159 http_redirect("display_pushemail");
167 WebcitAddUrlHandler(HKEY("display_pushemail"), "", 0, display_pushemail, 0);
168 WebcitAddUrlHandler(HKEY("save_pushemail"), "", 0, save_pushemail, 0);