2 * Edits a users push email settings
3 * Author: Mathew McBride <matt@mcbridematt.dhs.org>
7 void display_pushemail(void)
11 long vector[8] = {8, 0, 0, 1, 2, 3, 4, 5};
12 WCTemplputParams SubTP;
15 memset(&SubTP, 0, sizeof(WCTemplputParams));
16 SubTP.Filter.ContextType = CTX_LONGVECTOR;
17 SubTP.Context = &vector;
20 /* Find any existing settings*/
22 memset(&Room, 0, sizeof(folder));
23 if (goto_config_room(Buf, &Room) == 0) {
25 serv_puts("MSGS ALL|0|1");
26 StrBuf_ServGetln(Buf);
27 if (GetServerStatus(Buf, NULL) == 8) {
28 serv_puts("subj|__ Push email settings __");
30 while (StrBuf_ServGetln(Buf) >= 0) {
31 if ( (StrLength(Buf)==3) &&
32 !strcmp(ChrPtr(Buf), "000")) {
39 serv_printf("MSG0 %d", msgnum);
40 StrBuf_ServGetln(Buf);
41 if (GetServerStatus(Buf, NULL) == 1) {
43 while (StrBuf_ServGetln(Buf) >= 0) {
44 if (( (StrLength(Buf)==3) &&
45 !strcmp(ChrPtr(Buf), "000"))||
46 ((StrLength(Buf)==4) &&
47 !strcmp(ChrPtr(Buf), "text")))
52 if (!strcmp(ChrPtr(Buf), "text")) {
53 while (StrBuf_ServGetln(Buf) >= 0) {
54 if ( (StrLength(Buf)==3) &&
55 !strcmp(ChrPtr(Buf), "000")) {
58 if (strncasecmp(ChrPtr(Buf), "none", 4) == 0) {
60 } else if (strncasecmp(ChrPtr(Buf), "textmessage", 11) == 0) {
63 } else if (strncasecmp(ChrPtr(Buf), "funambol", 8) == 0) {
65 } else if (strncasecmp(ChrPtr(Buf), "httpmessage", 12) == 0) {
68 strncpy(mobnum, ChrPtr(Buf), 20);
75 svput("SMSNUM", WCS_STRING, " ");
76 serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
77 StrBuf_ServGetln(Buf);
78 GetServerStatus(Buf, NULL);
81 output_headers(1, 1, 2, 0, 0, 0);
82 DoTemplate(HKEY("prefs_pushemail"), NULL, &SubTP);
87 void save_pushemail(void)
93 char *pushsetting = bstr("pushsetting");
96 if (strncasecmp(pushsetting, "textmessage", 11) == 0) {
97 sms = bstr("user_sms_number");
100 if (goto_config_room(Buf, &Room) != 0) {
103 return; /* oh well. */
107 serv_puts("MSGS ALL|0|1");
108 StrBuf_ServGetln(Buf);
109 if (GetServerStatus(Buf, NULL) == 8) {
110 serv_puts("subj|__ Push email settings __");
113 printf("Junk in save_pushemail buffer!: %s\n", buf);
118 while (StrBuf_ServGetln(Buf) >= 0) {
119 if ( (StrLength(Buf)==3) &&
120 !strcmp(ChrPtr(Buf), "000")) {
123 msgnum = StrTol(Buf);
127 serv_printf("DELE %d", msgnum);
128 StrBuf_ServGetln(Buf);
129 GetServerStatus(Buf, NULL);
132 serv_printf("ENT0 1||0|1|__ Push email settings __|");
133 StrBuf_ServGetln(Buf);
134 if (GetServerStatus(Buf, NULL) == 4) {
135 serv_puts(pushsetting);
143 /** Go back to the room we're supposed to be in */
144 serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
145 StrBuf_ServGetln(Buf);
146 GetServerStatus(Buf, NULL);
147 http_redirect("display_pushemail");
155 WebcitAddUrlHandler(HKEY("display_pushemail"), "", 0, display_pushemail, 0);
156 WebcitAddUrlHandler(HKEY("save_pushemail"), "", 0, save_pushemail, 0);