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 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 __");
30 StrBuf_ServGetln(Buf) >= 0) {
31 if ( (StrLength(Buf)==3) &&
32 !strcmp(ChrPtr(Buf), "000")) {
40 serv_printf("MSG0 %d", msgnum);
41 StrBuf_ServGetln(Buf);
42 if (GetServerStatus(Buf, NULL) == 1) {
46 StrBuf_ServGetln(Buf) >= 0) {
47 if (( (StrLength(Buf)==3) &&
48 !strcmp(ChrPtr(Buf), "000"))||
49 ((StrLength(Buf)==4) &&
50 !strcmp(ChrPtr(Buf), "text")))
56 if (!strcmp(ChrPtr(Buf), "text")) {
59 StrBuf_ServGetln(Buf) >= 0) {
60 if ( (StrLength(Buf)==3) &&
61 !strcmp(ChrPtr(Buf), "000")) {
65 if (strncasecmp(ChrPtr(Buf), "none", 4) == 0) {
67 } else if (strncasecmp(ChrPtr(Buf), "textmessage", 11) == 0) {
70 } else if (strncasecmp(ChrPtr(Buf), "funambol", 8) == 0) {
72 } else if (strncasecmp(ChrPtr(Buf), "httpmessage", 12) == 0) {
75 strncpy(mobnum, ChrPtr(Buf), 20);
82 serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
83 StrBuf_ServGetln(Buf);
84 GetServerStatus(Buf, NULL);
87 output_headers(1, 1, 1, 0, 0, 0);
88 DoTemplate(HKEY("prefs_pushemail"), NULL, &SubTP);
90 UnStackContext(&SubTP);
94 void save_pushemail(void)
101 char *pushsetting = bstr("pushsetting");
104 if (strncasecmp(pushsetting, "textmessage", 11) == 0) {
105 sms = bstr("user_sms_number");
108 memset(&Room, 0, sizeof(folder));
109 if (goto_config_room(Buf, &Room) != 0) {
112 return; /* oh well. */
116 serv_puts("MSGS ALL|0|1");
117 StrBuf_ServGetln(Buf);
118 if (GetServerStatus(Buf, NULL) == 8) {
119 serv_puts("subj|__ Push email settings __");
122 printf("Junk in save_pushemail buffer!: %s\n", buf);
128 StrBuf_ServGetln(Buf) >= 0) {
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->CurRoom.name));
156 StrBuf_ServGetln(Buf);
157 GetServerStatus(Buf, NULL);
158 http_redirect("display_pushemail");
166 WebcitAddUrlHandler(HKEY("display_pushemail"), "", 0, display_pushemail, 0);
167 WebcitAddUrlHandler(HKEY("save_pushemail"), "", 0, save_pushemail, 0);