From 07f9de6655fff874dfd1ccbc882e121dca6957ad Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Thu, 4 Oct 2007 02:14:21 +0000 Subject: [PATCH] Applied Matt's patch for pager config -- NOT TESTED --- citadel/Makefile.in | 1 + citadel/control.c | 6 +++++ citadel/include/dtds/config-defs.h | 1 + citadel/modules/funambol/serv_funambol.c | 28 +++++++++++++++++++----- citadel/msgbase.c | 2 +- citadel/sysconfig.h | 2 +- 6 files changed, 32 insertions(+), 8 deletions(-) diff --git a/citadel/Makefile.in b/citadel/Makefile.in index 41149ed4e..19c73ffe0 100644 --- a/citadel/Makefile.in +++ b/citadel/Makefile.in @@ -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 \ diff --git a/citadel/control.c b/citadel/control.c index d378f8e15..75d15143c 100644 --- a/citadel/control.c +++ b/citadel/control.c @@ -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; } diff --git a/citadel/include/dtds/config-defs.h b/citadel/include/dtds/config-defs.h index d95d454fb..d804fca20 100644 --- a/citadel/include/dtds/config-defs.h +++ b/citadel/include/dtds/config-defs.h @@ -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)"); diff --git a/citadel/modules/funambol/serv_funambol.c b/citadel/modules/funambol/serv_funambol.c index 309e33464..231480ee2 100644 --- a/citadel/modules/funambol/serv_funambol.c +++ b/citadel/modules/funambol/serv_funambol.c @@ -37,19 +37,20 @@ #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) { diff --git a/citadel/msgbase.c b/citadel/msgbase.c index e4326851b..f6d7018b2 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -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 */ diff --git a/citadel/sysconfig.h b/citadel/sysconfig.h index 1be1aa596..62a167570 100644 --- a/citadel/sysconfig.h +++ b/citadel/sysconfig.h @@ -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 -- 2.30.2