Applied matt's latest patch set
authorArt Cancro <ajc@citadel.org>
Sat, 19 Jan 2008 05:35:02 +0000 (05:35 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 19 Jan 2008 05:35:02 +0000 (05:35 +0000)
citadel/citadel_dirs.c
citadel/citadel_dirs.h
citadel/modules/funambol/serv_funambol.h
citadel/modules/pager/serv_pager.c
citadel/modules/upgrade/serv_upgrade.c
webcit/configure.ac

index 54da76ff3425087b9b51f332ae328900fcec3ab5..bade7734acf9f0060f1c62a2d59458f678a82226 100644 (file)
@@ -66,6 +66,7 @@ char file_crpt_file_csr[PATH_MAX]="";
 char file_crpt_file_cer[PATH_MAX]="";
 char file_chkpwd[PATH_MAX]="";
 char file_base64[PATH_MAX]="";
+char file_funambol_msg[PATH_MAX] = "";
 
 int home_specified = 0;
 
@@ -245,7 +246,12 @@ void calc_dirs_n_files(int relh, int home, const char *relhome, const char  *ctd
                 ctdl_spool_dir
 #endif
                );
-
+                
+        snprintf(file_funambol_msg,
+                sizeof file_funambol_msg,
+                "%sfunambol_newmail_soap.xml",
+                ctdl_spool_dir);
+        
        DBG_PRINT(ctdl_bio_dir);
        DBG_PRINT(ctdl_bb_dir);
        DBG_PRINT(ctdl_data_dir);
@@ -282,6 +288,7 @@ void calc_dirs_n_files(int relh, int home, const char *relhome, const char  *ctd
        DBG_PRINT(file_crpt_file_cer);
        DBG_PRINT(file_chkpwd);
        DBG_PRINT(file_base64);
+       DBG_PRINT(file_funambol_msg);
 }
 
 
index 8a9e280f9062cb5eadcb50af29f0dbe4557c8fcb..490884efb8f03c6e30cad5646ac3b80d771bdb9c 100644 (file)
@@ -50,6 +50,8 @@ extern char file_crpt_file_cer[PATH_MAX];
 extern char file_chkpwd[PATH_MAX];
 extern char file_base64[PATH_MAX];
 
+extern char file_funambol_msg[PATH_MAX];
+
 extern void calc_dirs_n_files(int relh, int home, const char *relhome,const char  *ctdldir, int dbg);
 
 
index 209fb9b390d572b9a1214749faa419629f0f0fd7..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1 +0,0 @@
-void notify_funambol(long msgnum, void *userdata);
index 3570856e435d27d5b7f45faa1376c0d18b10572f..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,239 +0,0 @@
-/*
- * \file serv_pager.c
- * @author Mathew McBride
- * 
- * This module implements an external pager hook for when notifcation
- * of a new email is wanted.
- * Based on bits of serv_funambol
- * Contact: <matt@mcbridematt.dhs.org> / <matt@comalies>
- */
-
-#include "sysdep.h"
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <pwd.h>
-#include <errno.h>
-#include <sys/types.h>
-
-#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
-#endif
-
-#include <sys/wait.h>
-#include <string.h>
-#include <limits.h>
-#include <sys/socket.h>
-#include <libcitadel.h>
-#include "citadel.h"
-#include "server.h"
-#include "citserver.h"
-#include "support.h"
-#include "config.h"
-#include "control.h"
-#include "room_ops.h"
-#include "user_ops.h"
-#include "policy.h"
-#include "database.h"
-#include "msgbase.h"
-#include "internet_addressing.h"
-#include "domain.h"
-#include "clientsocket.h"
-#include "serv_pager.h"
-
-#include "ctdl_module.h"
-
-#define PAGER_CONFIG_MESSAGE "__ Push email settings __"
-#define PAGER_CONFIG_TEXT  "textmessage"
-
-/*! \brief Create the notify message queue. We use the exact same room 
- *                     as the Funambol module. 
- *
- *     Run at server startup, creates FNBL_QUEUE_ROOM if it doesn't exist
- *     and sets as system room. 
- */
-void create_pager_queue(void) {
-       struct ctdlroom qrbuf;
-
-       create_room(FNBL_QUEUE_ROOM, 3, "", 0, 1, 0, VIEW_MAILBOX);
-
-       /*
-        * Make sure it's set to be a "system room" so it doesn't show up
-        * in the <K>nown rooms list for Aides.
-        */
-       if (lgetroom(&qrbuf, FNBL_QUEUE_ROOM) == 0) {
-               qrbuf.QRflags2 |= QR2_SYSTEM;
-               lputroom(&qrbuf);
-       }
-}
-/*! 
- * \brief Run through the pager room queue
- */
-void do_pager_queue(void) {
-       static int doing_queue = 0;
-
-       /*
-        * This is a simple concurrency check to make sure only one queue run
-        * is done at a time.  We could do this with a mutex, but since we
-        * don't really require extremely fine granularity here, we'll do it
-        * with a static variable instead.
-        */
-       if (doing_queue) return;
-       doing_queue = 1;
-
-       /* 
-        * Go ahead and run the queue
-        */
-       lprintf(CTDL_DEBUG, "serv_pager: processing notify queue\n");
-
-       if (getroom(&CC->room, FNBL_QUEUE_ROOM) != 0) {
-               lprintf(CTDL_ERR, "Cannot find room <%s>\n", FNBL_QUEUE_ROOM);
-               return;
-       }
-       CtdlForEachMessage(MSGS_ALL, 0L, NULL,
-               SPOOLMIME, NULL, notify_pager, NULL);
-
-       lprintf(CTDL_DEBUG, "serv_pager: queue run completed\n");
-       doing_queue = 0;
-}
-
-/*!
- * \brief Call the external pager tool as set by the administrator
- * @param msgnum The message number of the 'hint' message passed from do_pager_queue
- * @param userdata userdata struct as passed by CtdlForEachMessage
- *
- */
-void notify_pager(long msgnum, void *userdata) {
-       struct CtdlMessage *msg;
-       
-       /* W means 'wireless', which contains the unix name */
-       msg = CtdlFetchMessage(msgnum, 1);
-       if ( msg->cm_fields['W'] == NULL) {
-               goto nuke;
-       }
-       /* Are we allowed to push? */
-       if (IsEmptyStr(config.c_pager_program)) {
-               return;
-       } else if (IsEmptyStr(config.c_pager_program) && IsEmptyStr(config.c_funambol_host)) {
-               goto nuke;
-       } else {
-               lprintf(CTDL_INFO, "Pager alerter enabled\n");  
-       }
-
-       /* Get the configuration. We might be allowed system wide but the user
-               may have configured otherwise */
-       long configMsgNum = pager_getConfigMessage(msg->cm_fields['W']);
-       int allowed = pager_isPagerAllowedByPrefs(configMsgNum);
-       if (allowed != 0 && pager_doesUserWant(configMsgNum) == 0) {
-               goto nuke;
-       } else if (allowed != 0) {
-               return;
-       }
-       char *num = pager_getUserPhoneNumber(configMsgNum);
-       char command[SIZ];
-       snprintf(command, sizeof command, "%s %s -u %s", config.c_pager_program, num, msg->cm_fields['W']);
-       system(command);
-       
-       nuke:
-       CtdlFreeMessage(msg);
-       long todelete[1];
-       todelete[0] = msgnum;
-       CtdlDeleteMessages(FNBL_QUEUE_ROOM, todelete, 1, "");
-}
-/*! \brief Get configuration message for pager/funambol system from the 
- *                     users "My Citadel Config" room
- */
-long pager_getConfigMessage(char *username) {
-       struct ctdlroom qrbuf; // scratch for room
-       struct ctdluser user; // ctdl user instance
-       char configRoomName[ROOMNAMELEN];
-       struct CtdlMessage *msg;
-       struct cdbdata *cdbfr;
-       long *msglist = NULL;
-       int num_msgs = 0;
-       long confMsgNum = -1;
-       // Get the user
-       getuser(&user, username);
-       
-       MailboxName(configRoomName, sizeof configRoomName, &user, USERCONFIGROOM);
-       // Fill qrbuf
-       getroom(&qrbuf, configRoomName);
-       /* Do something really, really stoopid here. Raid the room on ourselves,
-               loop through the messages manually and find it. I don't want 
-               to use a CtdlForEachMessage callback here, as we would be 
-               already in one */
-       cdbfr = cdb_fetch(CDB_MSGLISTS, &qrbuf.QRnumber, sizeof(long));
-       if (cdbfr != NULL) {
-               msglist = (long *) cdbfr->ptr;
-               cdbfr->ptr = NULL;      /* CtdlForEachMessage() now owns this memory */
-               num_msgs = cdbfr->len / sizeof(long);
-               cdb_free(cdbfr);
-       } else {
-               lprintf(CTDL_DEBUG, "pager_getConfigMessage: No config messages found\n");
-               return -1;      /* No messages at all?  No further action. */
-       }
-       int a;
-       for (a = 0; a < num_msgs; ++a) {
-                               msg = CtdlFetchMessage(msglist[a], 1);
-                               if (msg != NULL) {
-                                       if (msg->cm_fields['U'] != NULL && strncasecmp(msg->cm_fields['U'], PAGER_CONFIG_MESSAGE, 
-                                               strlen(PAGER_CONFIG_MESSAGE)) == 0) {
-                                               confMsgNum = msglist[a];
-                                       }
-                                       CtdlFreeMessage(msg);
-                               }
-       }
-       return confMsgNum;
-
-}
-int pager_isPagerAllowedByPrefs(long configMsgNum) {
-       // Do a simple string search to see if 'textmessage' 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, PAGER_CONFIG_TEXT, strlen(PAGER_CONFIG_TEXT));
-}
-int pager_doesUserWant(long configMsgNum) {
-       if (configMsgNum == -1) {
-               return -1;
-       }
-       struct CtdlMessage *prefMsg;
-       prefMsg = CtdlFetchMessage(configMsgNum, 1);
-       char *msgContents = prefMsg->cm_fields['M'];
-       return strncasecmp(msgContents, "none", 4);
-}
-       /* warning: fetching twice gravely inefficient, will fix some time */
-char *pager_getUserPhoneNumber(long configMsgNum) {
-       if (configMsgNum == -1) {
-               return NULL;
-       }
-       struct CtdlMessage *prefMsg;
-       prefMsg = CtdlFetchMessage(configMsgNum, 1);
-       char *msgContents = prefMsg->cm_fields['M'];
-       char *lines = strtok(msgContents, "textmessage\n");
-       return lines;
-}
-CTDL_MODULE_INIT(pager)
-{
-       if (!threading)
-       {
-               create_pager_queue();
-               CtdlRegisterSessionHook(do_pager_queue, EVT_TIMER);
-       }
-       
-       /* return our Subversion id for the Log */
-        return "$Id: serv_pager.c $";
-}
index 2646009c3dcefe0da675005529f15cdf54ae39c5..2158897ae40dc112fabe564dd7521e5b42a0a969 100644 (file)
@@ -184,8 +184,10 @@ void update_config(void) {
        if (CitControl.version < 725) {
                config.c_xmpp_c2s_port = 5222;
                config.c_xmpp_s2s_port = 5269;
+               /* Wipe config.c_funambol_auth as support for previous
+                * module is deprecated */
+                strcpy(config.c_funambol_auth, " ");
        }
-
        put_config();
 }
 
index 4c3902984cb2d6db7d1fa9f3351665b240107252..80ff049fe53d0e97fbebf65c2933efda254f46d9 100644 (file)
@@ -336,7 +336,8 @@ if test "$ok_iconv" = "no"; then
                        ok_iconv=no
                )
                if test "$ok_iconv" != "no"; then
-                  LDFLAGS=$LD_FLAGS_BEFORE
+                  LDFLAGS=$LD_FLAGS_BEFORE 
+                  LIBS="$LIBS -liconv"
                fi
 fi