modules_k/presence_mwi/presence_mwi.c
3895d1c1
 /*
  * presence_mwi module - Presence Handling of message-summary events
  *
  * Copyright (C) 2007 Juha Heinanen
  *
27642a08
  * This file is part of Kamailio, a free SIP server.
3895d1c1
  *
27642a08
  * Kamailio is free software; you can redistribute it and/or modify
3895d1c1
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version
  *
27642a08
  * Kamailio is distributed in the hope that it will be useful,
3895d1c1
  * 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
  *
  * History:
  * --------
  *  2007-05-1  initial version (jih)
  */
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
85de52fc
 #include <sys/types.h>
 #include <unistd.h>
3895d1c1
 
 #include "../../sr_module.h"
 #include "../../dprint.h"
 #include "../../str.h"
 #include "../../parser/msg_parser.h"
 #include "../../mem/mem.h"
 #include "../presence/bind_presence.h"
 #include "add_events.h"
 #include "presence_mwi.h"
 
 MODULE_VERSION
 
 /* module functions */
 static int mod_init(void);
 
 /* module variables */
 add_event_t pres_add_event;
 
 /* module exported commands */
 static cmd_export_t cmds[] =
 {
80998a7f
     {0,	0, 0, 0, 0, 0}
3895d1c1
 };
 
 /* module exported paramaters */
 static param_export_t params[] = {
     {0, 0, 0}
 };
 
 /* module exports */
 struct module_exports exports= {
3ed44241
     "presence_mwi",				/* module name */
3895d1c1
     DEFAULT_DLFLAGS,            /* dlopen flags */
3ed44241
     cmds,						/* exported functions */
     params,						/* exported parameters */
     0,							/* exported statistics */
     0,							/* exported MI functions */
     0,							/* exported pseudo-variables */
 	0,							/* extra processes */
     mod_init,					/* module initialization function */
     0,							/* response handling function */
     0,							/* destroy function */
     0							/* per-child init function */
3895d1c1
 };
 	
 /*
  * init module function
  */
 static int mod_init(void)
 {
7532087a
 	presence_api_t pres;
3895d1c1
     bind_presence_t bind_presence;
 
     bind_presence= (bind_presence_t)find_export("bind_presence", 1,0);
     if (!bind_presence) {
387847d7
 	LM_ERR("can't bind presence\n");
3895d1c1
 	return -1;
     }
     if (bind_presence(&pres) < 0) {
387847d7
 	LM_ERR("can't bind pua\n");
3895d1c1
 	return -1;
     }
 
     pres_add_event = pres.add_event;
     if (add_event == NULL) {
387847d7
 	LM_ERR("could not import add_event\n");
3895d1c1
 	return -1;
     }
     if(mwi_add_events() < 0) {
387847d7
 	LM_ERR("failed to add mwi events\n");
3895d1c1
 	return -1;		
     }	
     
     return 0;
 }