Applied Matt's patch for pager config -- NOT TESTED
authorArt Cancro <ajc@citadel.org>
Thu, 4 Oct 2007 02:14:21 +0000 (02:14 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 4 Oct 2007 02:14:21 +0000 (02:14 +0000)
citadel/Makefile.in
citadel/control.c
citadel/include/dtds/config-defs.h
citadel/modules/funambol/serv_funambol.c
citadel/msgbase.c
citadel/sysconfig.h

index 41149ed4e20ae27b3a6c795b90951dcd9117e2ca..19c73ffe03ff6224af9481957003bdc54ad99cb8 100644 (file)
@@ -70,6 +70,7 @@ SERV_MODULES=modules/chat/serv_chat.o \
        modules/ldap/serv_ldap.o \
        modules/autocompletion/serv_autocompletion.o \
        modules/funambol/serv_funambol.o \
+       modules/pager/serv_pager.o \
        modules/test/serv_test.o
 
 UTIL_TARGETS=aidepost msgform \
index d378f8e15f9a6902ef79df9ed7e42db21aad161e..75d15143cc3866560767f2ee5fdbe00a12f4434b 100644 (file)
@@ -274,6 +274,7 @@ void cmd_conf(char *argbuf)
                cprintf("%d\n", config.c_rbl_at_greeting);
                cprintf("%s\n", config.c_master_user);
                cprintf("%s\n", config.c_master_pass);
+               cprintf("%s\n", config.c_pager_program);
                cprintf("000\n");
        }
 
@@ -507,6 +508,11 @@ void cmd_conf(char *argbuf)
                        case 59:
                                safestrncpy(config.c_master_pass, buf, sizeof config.c_master_pass);
                                break;
+                       case 60:
+                               safestrncpy(config.c_pager_program,
+                                       buf,
+                                       sizeof config.c_pager_program);
+                               break;
                        }
                        ++a;
                }
index d95d454fbc03ff4eccf8f2acce1ac9d0013f01c9..d804fca20c59910495b92ef82abd2443af744dfb 100644 (file)
@@ -82,3 +82,4 @@ CFG_VALUE(STRING_BUF(c_funambol_auth, 256),   " Funambol auth details ");
 CFG_VALUE(CHAR(c_rbl_at_greeting),             " Check RBL's at connect instead of after RCPT ");
 CFG_VALUE(STRING_BUF(c_master_user, 32),       " Master user name ");
 CFG_VALUE(STRING_BUF(c_master_pass, 32),       " Master user password ");
+CFG_VALUE(STRING_BUF(c_pager_program, 256),    " External pager program (blank to disable)");
index 309e33464c57180b3388b1bf781e13f1c6191776..231480ee264a27202febba2ae32c17740123a131 100644 (file)
 #include "control.h"
 #include "room_ops.h"
 #include "user_ops.h"
-#include "policy.h"
 #include "database.h"
 #include "msgbase.h"
 #include "tools.h"
 #include "internet_addressing.h"
 #include "domain.h"
 #include "clientsocket.h"
-#include "serv_funambol.h"
 
+#include "serv_funambol.h"
+#include "serv_pager.h"
 
 
 #include "ctdl_module.h"
 
+#define FUNAMBOL_CONFIG_TEXT "funambol"
 
 /*
  * Create the notify message queue
@@ -111,13 +112,18 @@ void notify_funambol(long msgnum, void *userdata) {
        if ( msg->cm_fields['W'] == NULL) {
                goto nuke;
        }
+       long configMsgNum = pager_getConfigMessage(msg->cm_fields['W']);
+       int allowed = funambol_isAllowedByPrefs(configMsgNum);
+       if (allowed != 0) {
+               return;
+       }
        /* Are we allowed to push? */
        if (IsEmptyStr(config.c_funambol_host)) {
-               goto nuke;
+               return;
        } else {
                lprintf(CTDL_INFO, "Push enabled\n");
        }
-       
+       // Does the user want it?
        sprintf(port, "%d", config.c_funambol_port);
                 lprintf(CTDL_INFO, "Connecting to Funambol at <%s>\n", config.c_funambol_host);
                 sock = sock_connect(config.c_funambol_host, port, "tcp");
@@ -125,7 +131,7 @@ void notify_funambol(long msgnum, void *userdata) {
 
        if (sock < 0) {
                /* If the service isn't running, pass for now */
-               return;
+               goto nuke;
        }
        
        /* Build a SOAP message, delicately, by hand */
@@ -221,7 +227,17 @@ void notify_funambol(long msgnum, void *userdata) {
        CtdlDeleteMessages(FNBL_QUEUE_ROOM, todelete, 1, "");
 }
 
-
+int funambol_isAllowedByPrefs(long configMsgNum) {
+       // Do a simple string search to see if 'funambol' is selected as the 
+       // type. This string would be at the very top of the message contents.
+       if (configMsgNum == -1) {
+               return -1;
+       }
+       struct CtdlMessage *prefMsg;
+       prefMsg = CtdlFetchMessage(configMsgNum, 1);
+       char *msgContents = prefMsg->cm_fields['M'];
+       return strncasecmp(msgContents, FUNAMBOL_CONFIG_TEXT, strlen(FUNAMBOL_CONFIG_TEXT));
+}
 
 CTDL_MODULE_INIT(funambol)
 {
index e4326851bd5b904cd02c57a4834f658f797e49b0..f6d7018b2279cdd0a7fa37625287122281949aea 100644 (file)
@@ -2582,7 +2582,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
                        MailboxName(actual_rm, sizeof actual_rm, &userbuf, MAILROOM);
                        CtdlSaveMsgPointerInRoom(actual_rm, newmsgid, 0, msg);
                        BumpNewMailCounter(userbuf.usernum);
-                       if (!IsEmptyStr(config.c_funambol_host)) {
+                       if (!IsEmptyStr(config.c_funambol_host) || !IsEmptyStr(config.c_pager_program)) {
                        /* Generate a instruction message for the Funambol notification
                         * server, in the same style as the SMTP queue
                         */
index 1be1aa59640715fed20e71f7662af7975e6656d9..62a16757064b374a7fb14a5c79c4edff546a0f57 100644 (file)
@@ -97,7 +97,7 @@
 #define SYSCONFIGROOM          "Local System Configuration"
 #define SMTP_SPOOLOUT_ROOM     "__CitadelSMTPspoolout__"
 #define FNBL_QUEUE_ROOM                "__CitadelFNBLqueue__"
-
+#define PAGER_QUEUE_ROOM       "__CitadelPagerQueue__"
 /*
  * Where we keep messages containing the vCards that source our directory.  It
  * makes no sense to change this, because you'd have to change it on every