X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fpushemail.c;h=92fd026b13d5f45fb9975252db923598f4f428d8;hb=HEAD;hp=bc6a340dfc5a596102bf0a4b591fa108b9c11dd1;hpb=c434c19f8cf9e3e1a5b74d259881757ef6b51726;p=citadel.git diff --git a/webcit/pushemail.c b/webcit/pushemail.c index bc6a340df..92fd026b1 100644 --- a/webcit/pushemail.c +++ b/webcit/pushemail.c @@ -6,16 +6,20 @@ void display_pushemail(void) { + folder Room; int Done = 0; StrBuf *Buf; - int is_none = 0; - int is_pager = 0; - int is_funambol = 0; + long vector[8] = {8, 0, 0, 1, 2, 3, 4, 5}; + WCTemplputParams SubTP; char mobnum[20]; + StackContext(NULL, &SubTP, &vector, CTX_LONGVECTOR, 0, NULL); + vector[0] = 16; + /* Find any existing settings*/ Buf = NewStrBuf(); - if (goto_config_room(Buf) == 0) { + memset(&Room, 0, sizeof(folder)); + if (goto_config_room(Buf, &Room) == 0) { int msgnum = 0; serv_puts("MSGS ALL|0|1"); StrBuf_ServGetln(Buf); @@ -23,7 +27,7 @@ void display_pushemail(void) serv_puts("subj|__ Push email settings __"); serv_puts("000"); while (!Done && - StrBuf_ServGetln(Buf)) { + StrBuf_ServGetln(Buf) >= 0) { if ( (StrLength(Buf)==3) && !strcmp(ChrPtr(Buf), "000")) { Done = 1; @@ -39,7 +43,7 @@ void display_pushemail(void) int i =0; Done = 0; while (!Done && - StrBuf_ServGetln(Buf)) { + StrBuf_ServGetln(Buf) >= 0) { if (( (StrLength(Buf)==3) && !strcmp(ChrPtr(Buf), "000"))|| ((StrLength(Buf)==4) && @@ -52,19 +56,21 @@ void display_pushemail(void) if (!strcmp(ChrPtr(Buf), "text")) { Done = 0; while (!Done && - StrBuf_ServGetln(Buf)) { + StrBuf_ServGetln(Buf) >= 0) { if ( (StrLength(Buf)==3) && !strcmp(ChrPtr(Buf), "000")) { Done = 1; break; } if (strncasecmp(ChrPtr(Buf), "none", 4) == 0) { - is_none = 1; + vector[1] = 0; } else if (strncasecmp(ChrPtr(Buf), "textmessage", 11) == 0) { - is_pager = 1; + vector[1] = 1; i++; } else if (strncasecmp(ChrPtr(Buf), "funambol", 8) == 0) { - is_funambol = 1; + vector[1] = 2; + } else if (strncasecmp(ChrPtr(Buf), "httpmessage", 12) == 0) { + vector[1] = 3; } else if (i == 1) { strncpy(mobnum, ChrPtr(Buf), 20); i++; @@ -73,32 +79,21 @@ void display_pushemail(void) } } } - /* TODO: do in a saner fashion. */ - svput("PUSH_NONE", WCS_STRING, " "); /* defaults */ - svput("PUSH_TEXT", WCS_STRING, " "); - svput("PUSH_FNBL", WCS_STRING, " "); - svput("SMSNUM", WCS_STRING, " "); - if (is_none) { - svput("PUSH_NONE", WCS_STRING, "checked=\"checked\""); - } else if (is_pager) { - svput("PUSH_TEXT", WCS_STRING, "checked=\"checked\""); - svprintf(HKEY("SMSNUM"), WCS_STRING, "value=\"%s\"", mobnum); - } else if (is_funambol) { - svput("PUSH_FNBL", WCS_STRING, "checked=\"checked\""); - } - serv_printf("GOTO %s", ChrPtr(WC->wc_roomname)); + serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name)); StrBuf_ServGetln(Buf); GetServerStatus(Buf, NULL); } - output_headers(1, 1, 2, 0, 0, 0); - do_template("pushemail", NULL); -/*do_template("endbox"); */ + FlushFolder(&Room); + output_headers(1, 1, 1, 0, 0, 0); + DoTemplate(HKEY("prefs_pushemail"), NULL, &SubTP); wDumpContent(1); + UnStackContext(&SubTP); FreeStrBuf(&Buf); } void save_pushemail(void) { + folder Room; int Done = 0; StrBuf *Buf; char buf[SIZ]; @@ -110,10 +105,14 @@ void save_pushemail(void) sms = bstr("user_sms_number"); } Buf = NewStrBuf(); - if (goto_config_room(Buf) != 0) { + memset(&Room, 0, sizeof(folder)); + if (goto_config_room(Buf, &Room) != 0) { FreeStrBuf(&Buf); + FlushFolder(&Room); return; /* oh well. */ } + FlushFolder(&Room); + serv_puts("MSGS ALL|0|1"); StrBuf_ServGetln(Buf); if (GetServerStatus(Buf, NULL) == 8) { @@ -121,11 +120,12 @@ void save_pushemail(void) serv_puts("000"); } else { printf("Junk in save_pushemail buffer!: %s\n", buf); + FreeStrBuf(&Buf); return; } while (!Done && - StrBuf_ServGetln(Buf)) { + StrBuf_ServGetln(Buf) >= 0) { if ( (StrLength(Buf)==3) && !strcmp(ChrPtr(Buf), "000")) { Done = 1; @@ -152,16 +152,17 @@ void save_pushemail(void) } /** Go back to the room we're supposed to be in */ - serv_printf("GOTO %s", ChrPtr(WC->wc_roomname)); + serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name)); StrBuf_ServGetln(Buf); GetServerStatus(Buf, NULL); http_redirect("display_pushemail"); + FreeStrBuf(&Buf); } void InitModule_PUSHMAIL (void) { - WebcitAddUrlHandler(HKEY("display_pushemail"), display_pushemail, 0); - WebcitAddUrlHandler(HKEY("save_pushemail"), save_pushemail, 0); + WebcitAddUrlHandler(HKEY("display_pushemail"), "", 0, display_pushemail, 0); + WebcitAddUrlHandler(HKEY("save_pushemail"), "", 0, save_pushemail, 0); }