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 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 __");
31 StrBuf_ServGetln(Buf)) {
32 if ( (StrLength(Buf)==3) &&
33 !strcmp(ChrPtr(Buf), "000")) {
41 serv_printf("MSG0 %d", msgnum);
42 StrBuf_ServGetln(Buf);
43 if (GetServerStatus(Buf, NULL) == 1) {
47 StrBuf_ServGetln(Buf)) {
48 if (( (StrLength(Buf)==3) &&
49 !strcmp(ChrPtr(Buf), "000"))||
50 ((StrLength(Buf)==4) &&
51 !strcmp(ChrPtr(Buf), "text")))
57 if (!strcmp(ChrPtr(Buf), "text")) {
60 StrBuf_ServGetln(Buf)) {
61 if ( (StrLength(Buf)==3) &&
62 !strcmp(ChrPtr(Buf), "000")) {
66 if (strncasecmp(ChrPtr(Buf), "none", 4) == 0) {
68 } else if (strncasecmp(ChrPtr(Buf), "textmessage", 11) == 0) {
71 } else if (strncasecmp(ChrPtr(Buf), "funambol", 8) == 0) {
73 } else if (strncasecmp(ChrPtr(Buf), "httpmessage", 12) == 0) {
76 strncpy(mobnum, ChrPtr(Buf), 20);
83 svput("SMSNUM", WCS_STRING, " ");
84 serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
85 StrBuf_ServGetln(Buf);
86 GetServerStatus(Buf, NULL);
89 output_headers(1, 1, 2, 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 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)) {
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);