pua_mi.c

Go to the documentation of this file.
00001 /*
00002  * $Id: pua_mi.c 5238 2008-11-21 10:18:15Z henningw $
00003  *
00004  * pua_mi module - MI pua module
00005  *
00006  * Copyright (C) 2006 Voice Sistem S.R.L.
00007  *
00008  * This file is part of Kamailio, a free SIP server.
00009  *
00010  * Kamailio is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version
00014  *
00015  * Kamailio is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License 
00021  * along with this program; if not, write to the Free Software 
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  *
00024  * History:
00025  * --------
00026  *  2006-11-29  initial version (anca)
00027  */
00028 
00029 #include <stdio.h>
00030 #include <stdlib.h>
00031 #include <string.h>
00032 #include <time.h>
00033 
00034 #include "../../sr_module.h"
00035 #include "../../parser/parse_expires.h"
00036 #include "../../dprint.h"
00037 #include "../../mem/shm_mem.h"
00038 #include "../../parser/msg_parser.h"
00039 #include "../../str.h"
00040 #include "../../mem/mem.h"
00041 #include "../../pt.h"
00042 #include "../tm/tm_load.h"
00043 #include "../pua/pua_bind.h"
00044 #include "mi_func.h"
00045 
00046 MODULE_VERSION
00047 
00048 pua_api_t pua;
00049 
00050 /** module functions */
00051 
00052 static int mod_init(void);
00053 
00054 send_publish_t pua_send_publish;
00055 send_subscribe_t pua_send_subscribe;
00056 
00057 /*
00058  * Exported MI functions
00059  */
00060 static mi_export_t mi_cmds[] = {
00061    { "pua_publish",     mi_pua_publish,     MI_ASYNC_RPL_FLAG,  0,  0},
00062    { "pua_subscribe",   mi_pua_subscribe,   0,                0,  0},
00063    { 0,            0,                0,                0,  0}
00064 };
00065 
00066 /** module exports */
00067 struct module_exports exports= {
00068    "pua_mi",               /* module name */
00069    DEFAULT_DLFLAGS,        /* dlopen flags */
00070    0,                   /* exported functions */
00071    0,                   /* exported parameters */
00072    0,                   /* exported statistics */
00073    mi_cmds,             /* exported MI functions */
00074    0,                   /* exported pseudo-variables */
00075    0,                   /* extra processes */
00076    mod_init,               /* module initialization function */
00077    0,                   /* response handling function */
00078    0,                   /* destroy function */
00079    0                    /* per-child init function */
00080 };
00081    
00082 /**
00083  * init module function
00084  */
00085 static int mod_init(void)
00086 {
00087    LM_DBG("...\n");
00088    bind_pua_t bind_pua;
00089    
00090    bind_pua= (bind_pua_t)find_export("bind_pua", 1,0);
00091    if (!bind_pua)
00092    {
00093       LM_ERR("Can't bind pua\n");
00094       return -1;
00095    }
00096    
00097    if (bind_pua(&pua) < 0)
00098    {
00099       LM_ERR("Can't bind pua\n");
00100       return -1;
00101    }
00102    if(pua.send_publish == NULL)
00103    {
00104       LM_ERR("Could not import send_publish\n");
00105       return -1;
00106    }
00107    pua_send_publish= pua.send_publish;
00108 
00109    if(pua.send_subscribe == NULL)
00110    {
00111       LM_ERR("Could not import send_subscribe\n");
00112       return -1;
00113    }
00114    pua_send_subscribe= pua.send_subscribe;
00115    
00116    if(pua.register_puacb(MI_ASYN_PUBLISH, mi_publ_rpl_cback, NULL)< 0)
00117    {
00118       LM_ERR("Could not register callback\n");
00119       return -1;
00120    }  
00121 
00122    return 0;
00123 }

Generated on Thu May 24 08:00:53 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6