Added missing files to webcit build
authorArt Cancro <ajc@citadel.org>
Sat, 6 Oct 2007 04:06:03 +0000 (04:06 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 6 Oct 2007 04:06:03 +0000 (04:06 +0000)
webcit/pushemail.c [new file with mode: 0644]
webcit/static/pushemail.html [new file with mode: 0644]

diff --git a/webcit/pushemail.c b/webcit/pushemail.c
new file mode 100644 (file)
index 0000000..019e0fa
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ * Edits a users push email settings 
+ * Author: Mathew McBride <matt@mcbridematt.dhs.org>
+ */
+#include "webcit.h"
+
+void display_pushemail(void) {
+       char buf[SIZ];
+       int is_none = 0;
+       int is_pager = 0;
+       int is_funambol = 0;
+       char mobnum[20];
+       svprintf("BOXTITLE", WCS_STRING, _("Push email and SMS settings"));
+       
+       /* Find any existing settings*/
+       if (goto_config_room() == 0) {
+               int msgnum = 0;
+               serv_puts("MSGS ALL|0|1");
+               serv_getln(buf, sizeof(buf));
+               if (buf[0] == '8') {
+                       serv_puts("subj|__ Push email settings __");
+                       serv_puts("000");
+                       while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
+                               msgnum = atol(buf);
+                       }
+                       
+               }
+               if (msgnum > 0L) {
+               serv_printf("MSG0 %ld", msgnum);
+               serv_getln(buf, sizeof buf);
+               if (buf[0] == '1') {
+                       while (serv_getln(buf, sizeof buf),
+                               (strcmp(buf, "text") && strcmp(buf, "000"))) {
+                       }
+                       int i =0;
+                       if (!strcmp(buf, "text")) {
+                               while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { 
+                                       if (strncasecmp(buf, "none", 4) == 0) {
+                                               is_none = 1;
+                                       } else if (strncasecmp(buf, "textmessage", 11) == 0) {
+                                               is_pager = 1;
+                                               i++;
+                                       } else if (strncasecmp(buf, "funambol", 8) == 0) {
+                                               is_funambol = 1;
+                                       } else if (i == 1) {
+                                               strncpy(mobnum, buf, 20);
+                                               i++;
+                                       }
+                               }       
+                       }
+               }
+               }
+       if (is_none) {
+               svprintf("PUSH_NONE", WCS_STRING, "checked=\"checked\"");
+       } else if (is_pager) {
+               svprintf("PUSH_TEXT", WCS_STRING, "checked=\"checked\"");
+               svprintf("SMSNUM", WCS_STRING, "value=\"%s\"", mobnum);
+       } else if (is_funambol) {
+               svprintf("PUSH_FNBL", WCS_STRING, "checked=\"checked\"");
+       }
+       serv_printf("GOTO %s", WC->wc_roomname);
+       serv_getln(buf, sizeof  buf);
+       }
+output_headers(1, 1, 2, 0, 0, 0);
+do_template("pushemail");
+//do_template("endbox");
+wDumpContent(1);
+}
+
+void save_pushemail(void) {
+       char buf[SIZ];
+       int msgnum = 0;
+       char *pushsetting = bstr("pushsetting");
+       char *sms = NULL;
+       if (strncasecmp(pushsetting, "textmessage", 11) == 0) {
+               sms = bstr("user_sms_number");
+       }
+       if (goto_config_room() != 0) return;    /* oh well. */
+       serv_puts("MSGS ALL|0|1");
+       serv_getln(buf, sizeof buf);
+       if (buf[0] == '8') {
+               serv_puts("subj|__ Push email settings __");
+               serv_puts("000");
+       } else {
+               printf("Junk in save_pushemail buffer!: %s\n", buf);
+               return;
+       }
+       while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
+               msgnum = atol(buf);
+       }
+
+       if (msgnum > 0L) {
+               serv_printf("DELE %ld", msgnum);
+               serv_getln(buf, sizeof buf);
+       }
+
+       serv_printf("ENT0 1||0|1|__ Push email settings __|");
+       serv_getln(buf, sizeof buf);
+       if (buf[0] == '4') {
+               serv_puts(pushsetting);
+               if (sms != NULL) {
+               serv_puts(sms);
+               } 
+               serv_puts("");
+               serv_puts("000");
+       }
+
+       /** Go back to the room we're supposed to be in */
+       serv_printf("GOTO %s", WC->wc_roomname);
+       serv_getln(buf, sizeof buf);
+       http_redirect("display_pushemail");
+}
diff --git a/webcit/static/pushemail.html b/webcit/static/pushemail.html
new file mode 100644 (file)
index 0000000..bf9213b
--- /dev/null
@@ -0,0 +1,41 @@
+    <div id="banner">
+      <h1>Configure Push Email</h1>
+    </div>
+
+    <div id="content" class="config_service">
+    <!-- NOT beginbox -->
+    <div class="box">
+    <div class="boxlabel"><?BOXTITLE></div>
+    <div class="boxcontent">
+       <!-- still not begin box -->
+    <!-- Begin Push email configure -->
+
+      <div id="pushemail">
+        <div class="instructions">
+          <p>If your administrator has enabled the functionality, Citadel can notify a
+          Funambol server that you haved recieved new email and automatically syncronize
+          any devices you have with the Funambol client installed.</p>
+
+          <p>Alternatively, if the administrator has configured it, Citadel can send a
+          text message to you when new mail arrives.</p>
+        </div>
+
+        <form id="pushconfig" method="post" action="save_pushemail">
+          <p class="option"><input type="radio" name="pushsetting" value=
+          "funambol" <?PUSH_FNBL>><strong>Notify Funambol server</strong></p>
+
+          <p class="option"><input type="radio" name="pushsetting" value=
+          "textmessage" <?PUSH_TEXT>><strong>Send a text message</strong> to... <input type="text"
+          name="user_sms_number" size="20" <?SMSNUM> > (Use international format, without any
+          leading zeros, spaces or hypens, like +61415011501)</p>
+
+          <p class="option"><input type="radio" name="pushsetting" value=
+          "none" <?PUSH_NONE>><strong>Don't send any notifications</strong></p>
+
+          <p><input type="submit" name="submit" value="Save settings"></p>
+        </form>
+        <br>
+        <br>
+      </div>
+      </div>
+      </div>