]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/extnotify/extnotify_main.c
Work on integrating libcurl <-> libev
[citadel.git] / citadel / modules / extnotify / extnotify_main.c
index 387b138c8969c31223387fb356cdde288737ca1d..31f2f0932617e02de577be0f705bb4f8d348f065 100644 (file)
@@ -1,11 +1,28 @@
 /*
- * \file extnotify_main.c
- * @author Mathew McBride
+ * extnotify_main.c
+ * 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>
+ *
+ * Copyright (c) 2008-2009
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #include "sysdep.h"
@@ -40,9 +57,7 @@
 #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"
@@ -121,24 +136,24 @@ StrBuf** GetNotifyHosts(void)
 }
 
 
-/*! \brief Create the notify message queue. We use the exact same room
- *                     as the Funambol module.
+/* 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.
+ * Run at server startup, creates FNBL_QUEUE_ROOM if it doesn't exist
+ * and sets as system room.
  */
 void create_extnotify_queue(void) {
        struct ctdlroom qrbuf;
     
-       create_room(FNBL_QUEUE_ROOM, 3, "", 0, 1, 0, VIEW_MAILBOX);
+       CtdlCreateRoom(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) {
+       if (CtdlGetRoomLock(&qrbuf, FNBL_QUEUE_ROOM) == 0) {
                qrbuf.QRflags2 |= QR2_SYSTEM;
-               lputroom(&qrbuf);
+               CtdlPutRoomLock(&qrbuf);
        }
 }
 /*!
@@ -146,9 +161,10 @@ void create_extnotify_queue(void) {
  */
 void do_extnotify_queue(void) 
 {
+
        NotifyContext Ctx;
        static int doing_queue = 0;
-       int i = 0;
+       //int i = 0;
     
        /*
         * This is a simple concurrency check to make sure only one queue run
@@ -158,7 +174,7 @@ void do_extnotify_queue(void)
         */
        if (doing_queue) return;
        doing_queue = 1;
-    
+
        /*
         * Go ahead and run the queue
         */
@@ -166,13 +182,14 @@ void do_extnotify_queue(void)
     
        memset(&Ctx, 0, sizeof(NotifyContext));
        Ctx.NotifyHostList = GetNotifyHosts();
-       if (getroom(&CC->room, FNBL_QUEUE_ROOM) != 0) {
+       if (CtdlGetRoom(&CC->room, FNBL_QUEUE_ROOM) != 0) {
                CtdlLogPrintf(CTDL_ERR, "Cannot find room <%s>\n", FNBL_QUEUE_ROOM);
+               CtdlClearSystemContext();
                return;
        }
        CtdlForEachMessage(MSGS_ALL, 0L, NULL,
                           SPOOLMIME, NULL, process_notify, &Ctx);
-
+/*
        while ((Ctx.NotifyHostList != NULL) && (Ctx.NotifyHostList[i] != NULL))
                FreeStrBuf(&Ctx.NotifyHostList[i]);
 
@@ -195,17 +212,18 @@ void do_extnotify_queue(void)
                DeleteHashPos(&It);
                DeleteHash(&Ctx.NotifyErrors);
        }
-
+*/
        CtdlLogPrintf(CTDL_DEBUG, "serv_extnotify: queue run completed\n");
        doing_queue = 0;
 }
-/*!
- * \brief Process messages in the external notification queue
+
+/*
+ * Process messages in the external notification queue
  */
 void process_notify(long NotifyMsgnum, void *usrdata) 
 {
        NotifyContext *Ctx;
-       long msgnum;
+       long msgnum = 0;
        long todelete[1];
        int fnblAllowed;
        int extPagerAllowedHttp;
@@ -349,11 +367,11 @@ long extNotify_getConfigMessage(char *username) {
        int a;
 
        // Get the user
-       getuser(&user, username);
+       CtdlGetUser(&user, username);
     
-       MailboxName(configRoomName, sizeof configRoomName, &user, USERCONFIGROOM);
+       CtdlMailboxName(configRoomName, sizeof configRoomName, &user, USERCONFIGROOM);
        // Fill qrbuf
-       getroom(&qrbuf, configRoomName);
+       CtdlGetRoom(&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
@@ -391,5 +409,5 @@ CTDL_MODULE_INIT(extnotify)
                CtdlRegisterSessionHook(do_extnotify_queue, EVT_TIMER);
        }
        /* return our Subversion id for the Log */
-        return "$Id$";
+        return "extnotify";
 }