X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fmodules%2Fextnotify%2Fextnotify_main.c;h=3029322950dc79f66fdd7a2909d8911cf31c8c44;hb=c855d497545dad80942a194624c111a54cd1fdc7;hp=dafe4ae5cd755d4d49f41d5c4a359f455ac458e2;hpb=d04e1208cf6c71816adb600c6493c48c7b9610f1;p=citadel.git diff --git a/citadel/modules/extnotify/extnotify_main.c b/citadel/modules/extnotify/extnotify_main.c index dafe4ae5c..302932295 100644 --- a/citadel/modules/extnotify/extnotify_main.c +++ b/citadel/modules/extnotify/extnotify_main.c @@ -8,23 +8,24 @@ * Based on bits of serv_funambol * Contact: / * - * 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 #include @@ -65,7 +66,6 @@ #include "clientsocket.h" #include "event_client.h" #include "extnotify.h" - #include "ctdl_module.h" struct CitContext extnotify_queue_CC; @@ -120,8 +120,8 @@ int GetNotifyHosts(NotifyContext *Ctx) 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); @@ -133,6 +133,7 @@ int GetNotifyHosts(NotifyContext *Ctx) } + /*! \brief Get configuration message for pager/funambol system from the * users "My Citadel Config" room */ @@ -266,9 +267,9 @@ void process_notify(long NotifyMsgnum, void *usrdata) 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) @@ -283,13 +284,10 @@ void process_notify(long NotifyMsgnum, void *usrdata) 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); @@ -318,12 +316,10 @@ void process_notify(long NotifyMsgnum, void *usrdata) 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); @@ -336,9 +332,9 @@ void process_notify(long NotifyMsgnum, void *usrdata) 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); } @@ -354,13 +350,9 @@ void process_notify(long NotifyMsgnum, void *usrdata) 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) { @@ -374,7 +366,6 @@ 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)) { @@ -385,6 +376,8 @@ void do_extnotify_queue(void) if (doing_queue) return; doing_queue = 1; + become_session(&extnotify_queue_CC); + pthread_setspecific(MyConKey, (void *)&extnotify_queue_CC); /* @@ -397,7 +390,6 @@ void do_extnotify_queue(void) (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++) @@ -443,6 +435,7 @@ void create_extnotify_queue(void) { } } + CTDL_MODULE_INIT(extnotify) { if (!threading) @@ -450,6 +443,6 @@ CTDL_MODULE_INIT(extnotify) 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"; }