* Based on bits of serv_funambol
* Contact: <matt@mcbridematt.dhs.org> / <matt@comalies>
*
- * Copyright (c) 2008-2009
+ * Copyright (c) 2008-2011
*
- * 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 open source 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.
+ * 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
+ * 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"
#include <stdlib.h>
#include <unistd.h>
#include "clientsocket.h"
#include "event_client.h"
#include "extnotify.h"
-
#include "ctdl_module.h"
struct CitContext extnotify_queue_CC;
pche = strchr(pchs, ':');
if (pche == NULL) {
syslog(LOG_ERR,
- "extnotify: filename of notification template not found in %s.\n",
- pchs);
+ "extnotify: filename of notification template not found in %s.\n",
+ pchs);
continue;
}
File = GetNHBuf(notify * 2 + 1, 1, Ctx->NotifyHostList);
}
+
/*! \brief Get configuration message for pager/funambol system from the
* users "My Citadel Config" room
*/
Ctx = (NotifyContext*) usrdata;
msg = CtdlFetchMessage(NotifyMsgnum, 1);
- if ( msg->cm_fields['W'] != NULL)
+ if ( msg->cm_fields['2'] != NULL)
{
- Type = extNotify_getConfigMessage(msg->cm_fields['W'], &PagerNo, &FreeMe);
+ Type = extNotify_getConfigMessage(msg->cm_fields['2'], &PagerNo, &FreeMe);
pch = strstr(msg->cm_fields['M'], "msgid|");
if (pch != NULL)
config.c_funambol_port,
FUNAMBOL_WS);
- SubC = CloneContext (CC);
- SubC->session_specific_data = NULL;// (char*) DupNotifyContext(Ctx);
-
notify_http_server(remoteurl,
file_funambol_msg,
strlen(file_funambol_msg),/*GNA*/
- msg->cm_fields['W'],
+ msg->cm_fields['2'],
msg->cm_fields['I'],
msgnum,
NULL);
FlushStrBuf(FileBuf);
memcpy(URLBuf, ChrPtr(URL), StrLength(URL) + 1);
- SubC = CloneContext (CC);
- SubC->session_specific_data = NULL;// (char*) DupNotifyContext(Ctx);
notify_http_server(URLBuf,
ChrPtr(FileBuf),
StrLength(FileBuf),
- msg->cm_fields['W'],
+ msg->cm_fields['2'],
msg->cm_fields['I'],
msgnum,
NULL);
int commandSiz;
char *command;
- commandSiz = sizeof(config.c_pager_program) + strlen(PagerNo) + strlen(msg->cm_fields['W']) + 5;
+ commandSiz = sizeof(config.c_pager_program) + strlen(PagerNo) + strlen(msg->cm_fields['2']) + 5;
command = malloc(commandSiz);
- snprintf(command, commandSiz, "%s %s -u %s", config.c_pager_program, PagerNo, msg->cm_fields['W']);
+ snprintf(command, commandSiz, "%s %s -u %s", config.c_pager_program, PagerNo, msg->cm_fields['2']);
system(command);
free(command);
}
CtdlDeleteMessages(FNBL_QUEUE_ROOM, todelete, 1, "");
}
-
-
-
-
-
/*!
* \brief Run through the pager room queue
+ * Checks to see what notification option the user has set
*/
void do_extnotify_queue(void)
{
* don't really require extremely fine granularity here, we'll do it
* with a static variable instead.
*/
-
if (IsEmptyStr(config.c_pager_program) &&
IsEmptyStr(config.c_funambol_host))
{
if (doing_queue) return;
doing_queue = 1;
+ become_session(&extnotify_queue_CC);
+
pthread_setspecific(MyConKey, (void *)&extnotify_queue_CC);
/*
(CtdlGetRoom(&CC->room, FNBL_QUEUE_ROOM) != 0))
{
syslog(LOG_ERR, "Cannot find room <%s>\n", FNBL_QUEUE_ROOM);
- CtdlClearSystemContext();
if (Ctx.nNotifyHosts > 0)
{
for (i = 0; i < Ctx.nNotifyHosts * 2; i++)
}
}
+
CTDL_MODULE_INIT(extnotify)
{
if (!threading)
create_extnotify_queue();
CtdlRegisterSessionHook(do_extnotify_queue, EVT_TIMER);
}
- /* return our Subversion id for the Log */
+ /* return our module name for the log */
return "extnotify";
}