presence_profile.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2011 Mészáros Mihály
00003  *
00004  * This file is part of Kamailio, a free SIP server.
00005  *
00006  * Kamailio is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version
00010  *
00011  * Kamailio is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License 
00017  * along with this program; if not, write to the Free Software 
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  * History:
00021  * --------
00022  *  2011-09-22  initial version (misi)
00023  */
00024 
00025 
00038 #include <stdio.h>
00039 #include <stdlib.h>
00040 #include <string.h>
00041 #include <time.h>
00042 #include <sys/types.h>
00043 #include <unistd.h>
00044 
00045 #include "../../sr_module.h"
00046 #include "../../dprint.h"
00047 #include "../../str.h"
00048 #include "../../parser/msg_parser.h"
00049 #include "../../mem/mem.h"
00050 #include "../presence/bind_presence.h"
00051 #include "add_events.h"
00052 #include "presence_profile.h"
00053 
00054 MODULE_VERSION
00055 
00056 /* module functions */
00057 static int mod_init(void);
00058 
00059 /* module variables */
00060 add_event_t pres_add_event;
00061 
00062 /* module exported commands */
00063 static cmd_export_t cmds[] =
00064 {
00065     {0, 0, 0, 0, 0, 0}
00066 };
00067 
00068 /* module exported paramaters */
00069 static param_export_t params[] = {
00070     {0, 0, 0}
00071 };
00072 
00073 /* module exports */
00074 struct module_exports exports= {
00075     "presence_profile",                         /* module name */
00076     DEFAULT_DLFLAGS,            /* dlopen flags */
00077     cmds,                                               /* exported functions */
00078     params,                                             /* exported parameters */
00079     0,                                                  /* exported statistics */
00080     0,                                                  /* exported MI functions */
00081     0,                                                  /* exported pseudo-variables */
00082         0,                                                      /* extra processes */
00083     mod_init,                                   /* module initialization function */
00084     0,                                                  /* response handling function */
00085     0,                                                  /* destroy function */
00086     0                                                   /* per-child init function */
00087 };
00088         
00089 /*
00090  * init module function
00091  */
00092 static int mod_init(void)
00093 {
00094         presence_api_t pres;
00095     bind_presence_t bind_presence;
00096 
00097     bind_presence= (bind_presence_t)find_export("bind_presence", 1,0);
00098     if (!bind_presence) {
00099         LM_ERR("can't bind presence\n");
00100         return -1;
00101     }
00102     if (bind_presence(&pres) < 0) {
00103         LM_ERR("can't bind pua\n");
00104         return -1;
00105     }
00106 
00107     pres_add_event = pres.add_event;
00108     if (pres_add_event == NULL) {
00109         LM_ERR("could not import add_event\n");
00110         return -1;
00111     }
00112     if(profile_add_events() < 0) {
00113         LM_ERR("failed to add profile events\n");
00114         return -1;              
00115     }   
00116     
00117     return 0;
00118 }