Merge remote branch 'origin/misi/ua-profile'
authorMészáros Mihály <misi@niif.hu>
Thu, 17 Nov 2011 13:02:56 +0000 (14:02 +0100)
committerMészáros Mihály <misi@niif.hu>
Thu, 17 Nov 2011 13:02:56 +0000 (14:02 +0100)
* origin/misi/ua-profile:
  modules_k/presence_profile: new modul for basic ua-profile event support
  parser: added ua-profile event type

13 files changed:
Makefile
modules_k/presence/event_list.c
modules_k/presence_profile/Makefile [new file with mode: 0644]
modules_k/presence_profile/README [new file with mode: 0644]
modules_k/presence_profile/add_events.c [new file with mode: 0644]
modules_k/presence_profile/add_events.h [new file with mode: 0644]
modules_k/presence_profile/doc/Makefile [new file with mode: 0644]
modules_k/presence_profile/doc/presence_profile.xml [new file with mode: 0644]
modules_k/presence_profile/doc/presence_profile_admin.xml [new file with mode: 0644]
modules_k/presence_profile/presence_profile.c [new file with mode: 0644]
modules_k/presence_profile/presence_profile.h [new file with mode: 0644]
parser/parse_event.c
parser/parse_event.h

index 88d3958..8606ab4 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -174,7 +174,7 @@ module_group_radius=acc_radius auth_radius misc_radius avp_radius uri_radius \
 
 # For presence
 # kamailio modules
-module_group_presence=presence presence_dialoginfo presence_mwi presence_xml \
+module_group_presence=presence presence_dialoginfo presence_mwi presence_xml presence_profile\
                                                pua pua_bla pua_dialoginfo pua_mi pua_usrloc pua_xmpp \
                                                rls xcap_client xcap_server presence_conference \
                                                presence_reginfo pua_reginfo
@@ -262,7 +262,7 @@ module_group_kmemcached=memcached
 module_group_ktls=tls
 
 # K presence modules
-module_group_kpresence=presence presence_dialoginfo presence_mwi presence_xml \
+module_group_kpresence=presence presence_dialoginfo presence_mwi presence_xml presence_profile\
                                                pua pua_bla pua_dialoginfo pua_mi pua_usrloc pua_xmpp \
                                                rls xcap_client xcap_server presence_conference \
                                                presence_reginfo pua_reginfo
index 0d628b6..eb83d6b 100644 (file)
@@ -356,7 +356,7 @@ pres_ev_t* search_event(event_t* event)
                                strncasecmp(pres_ev->evp->name.s,event->name.s,
                                        pres_ev->evp->name.len)== 0))
                {
-                       if(event->params.list== NULL && pres_ev->evp->params.list== NULL)
+                       if((event->params.list== NULL && pres_ev->evp->params.list== NULL) || event->type==EVENT_UA_PROFILE)
                        {
                                return pres_ev;
                        }
diff --git a/modules_k/presence_profile/Makefile b/modules_k/presence_profile/Makefile
new file mode 100644 (file)
index 0000000..addf9e2
--- /dev/null
@@ -0,0 +1,11 @@
+# 
+# WARNING: do not run this directly, it should be run by the master Makefile
+
+include ../../Makefile.defs
+auto_gen=
+NAME=presence_profile.so
+LIBS=
+
+DEFS+=-DOPENSER_MOD_INTERFACE
+
+include ../../Makefile.modules
diff --git a/modules_k/presence_profile/README b/modules_k/presence_profile/README
new file mode 100644 (file)
index 0000000..1d59539
--- /dev/null
@@ -0,0 +1,77 @@
+Presence_Profile Module
+
+Mihály Mészáros
+
+   <misi@niif.hu>
+
+Edited by
+
+Mészáros Mihály
+
+   <misi@niif.hu>
+
+   Copyright © 2011 Mészáros Mihály
+     __________________________________________________________________
+
+   Table of Contents
+
+   1. Admin Guide
+
+        1. Overview
+        2. Dependencies
+
+              2.1. Kamailio Modules
+              2.2. External Libraries or Applications
+
+        3. Exported Parameters
+        4. Exported Functions
+
+Chapter 1. Admin Guide
+
+   Table of Contents
+
+   1. Overview
+   2. Dependencies
+
+        2.1. Kamailio Modules
+        2.2. External Libraries or Applications
+
+   3. Exported Parameters
+   4. Exported Functions
+
+1. Overview
+
+   The module does a very basic handling for ua-profile. You can subscribe
+   to ua-profile provisioning information if you add a provisioning
+   document to presentity table.
+
+   Warning: When you add provisioning config to presentity table, then you
+   must make sure that you set the presentity table expires field to a
+   time value in long future
+
+   If your user agent is subscribing to AoR and if the subscription event
+   is ua-profile, then it will receive provisioning data in the
+   notification body. Read more about sip user agent configuration
+   framework in RFC6080. http://tools.ietf.org/html/rfc6080
+
+2. Dependencies
+
+   2.1. Kamailio Modules
+   2.2. External Libraries or Applications
+
+2.1. Kamailio Modules
+
+   The following modules must be loaded before this module:
+     * presence.
+
+2.2. External Libraries or Applications
+
+   None.
+
+3. Exported Parameters
+
+   None.
+
+4. Exported Functions
+
+   None to be used in configuration file.
diff --git a/modules_k/presence_profile/add_events.c b/modules_k/presence_profile/add_events.c
new file mode 100644 (file)
index 0000000..d4ee90c
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ *
+ * Copyright (C) 2011 Mészáros Mihály
+ *
+ * This file is part of Kamailio, a free SIP server.
+ *
+ * Kamailio 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 2 of the License, or
+ * (at your option) any later version
+ *
+ * Kamailio 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
+ *
+ * History:
+ * --------
+ *  2011-09-22  initial version (misi)
+ */
+
+/*!
+ * \file
+ * \brief SIP-router Presence :: ua-profile provisioning support
+ * \ingroup presence
+ * Module: \ref presence
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "../../parser/parse_content.h"
+#include "../presence/event_list.h"
+#include "presence_profile.h"
+
+
+int profile_add_events(void)
+{
+    pres_ev_t event;
+       
+    /* constructing profile event */
+    memset(&event, 0, sizeof(pres_ev_t));
+    event.name.s = "ua-profile";
+    event.name.len = 10;
+
+
+    event.content_type.s = "text/xml";
+    event.content_type.len = 8;
+
+    event.default_expires= 3600;
+    event.type = PUBL_TYPE;
+    event.req_auth = 0;
+    event.evs_publ_handl = 0;
+    
+    if (pres_add_event(&event) < 0) {
+       LM_ERR("failed to add event \"ua-profile\"\n");
+       return -1;
+    }          
+       
+    return 0;
+}
diff --git a/modules_k/presence_profile/add_events.h b/modules_k/presence_profile/add_events.h
new file mode 100644 (file)
index 0000000..6d9498f
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * presence_profile module - add_event header file
+ *
+ * Copyright (C) 2011 Mészáros Mihály
+ *
+ * This file is part of Kamailio, a free SIP server.
+ *
+ * Kamailio 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 2 of the License, or
+ * (at your option) any later version
+ *
+ * Kamailio 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
+ *
+ * History:
+ * --------
+ *  2011-11-22  initial version (misi)
+ */
+
+/*!
+ * \file
+ * \brief SIP-router Presence :: ua-profile provisioning support
+ * \ingroup presence
+ * Module: \ref presence
+ */
+
+
+#ifndef _PROFILE_ADD_EV_H_
+#define _PROFILE_ADD_EV_H_
+
+int profile_add_events(void);
+
+#endif
diff --git a/modules_k/presence_profile/doc/Makefile b/modules_k/presence_profile/doc/Makefile
new file mode 100644 (file)
index 0000000..3c6a162
--- /dev/null
@@ -0,0 +1,4 @@
+docs = presence_profile.xml
+
+docbook_dir = ../../../docbook
+include $(docbook_dir)/Makefile.module
diff --git a/modules_k/presence_profile/doc/presence_profile.xml b/modules_k/presence_profile/doc/presence_profile.xml
new file mode 100644 (file)
index 0000000..9478a57
--- /dev/null
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding='ISO-8859-1'?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
+"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
+
+<!-- Include general documentation entities -->
+<!ENTITY % docentities SYSTEM "../../../docbook/entities.xml">
+%docentities;
+
+]>
+
+<book xmlns:xi="http://www.w3.org/2001/XInclude">
+    <bookinfo>
+       <title>Presence_Profile Module</title>
+       <productname class="trade">&kamailioname;</productname>
+       <authorgroup>
+           <author>
+               <firstname>Mihály</firstname>
+               <surname>Mészáros</surname>
+               <email>misi@niif.hu</email>
+           </author>
+           <editor>
+               <firstname>Mészáros</firstname>
+               <surname>Mihály</surname>
+               <email>misi@niif.hu</email>
+           </editor>
+       </authorgroup>
+       <copyright>
+           <year>2011</year>
+           <holder>Mészáros Mihály</holder>
+       </copyright>
+  </bookinfo>
+    <toc></toc>
+    
+    <xi:include href="presence_profile_admin.xml"/>
+    
+    
+</book>
+
+
diff --git a/modules_k/presence_profile/doc/presence_profile_admin.xml b/modules_k/presence_profile/doc/presence_profile_admin.xml
new file mode 100644 (file)
index 0000000..e1c026f
--- /dev/null
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding='ISO-8859-1'?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
+"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
+
+<!-- Include general documentation entities -->
+<!ENTITY % docentities SYSTEM "../../../docbook/entities.xml">
+%docentities;
+
+]>
+<!-- Module User's Guide -->
+
+<chapter>
+       
+
+       <title>&adminguide;</title>
+       
+       <section>
+         <title>Overview</title>
+           <para> 
+             The module does a very basic handling for ua-profile.
+             You can subscribe to ua-profile provisioning information if you add a provisioning document to presentity table.
+           </para>
+           <para>
+             Warning: When you add provisioning config to presentity table, then you must make sure 
+             that you set the presentity table expires field to a time value in long future
+           </para>
+           <para>
+             If your user agent is subscribing to AoR and if the subscription event is ua-profile, then it will receive provisioning data in the notification body.
+             Read more about sip user agent configuration framework in RFC6080. http://tools.ietf.org/html/rfc6080
+           </para>
+       </section>
+
+       <section>
+         <title>Dependencies</title>
+         <section>
+               <title>&kamailio; Modules</title>
+               <para>
+               The following modules must be loaded before this module:
+                       <itemizedlist>
+                       <listitem>
+                       <para>
+                               <emphasis>presence</emphasis>.
+                       </para>
+                       </listitem>
+                       </itemizedlist>
+               </para>
+         </section>
+
+         <section>
+               <title>External Libraries or Applications</title>
+               <para>
+               None.
+               </para>
+         </section>
+       </section>
+       
+       <section>
+         <title>Exported Parameters</title>
+               <para>
+                 None.
+               </para>
+        </section>
+
+        <section>
+         <title>Exported Functions</title>
+             <para>
+               None to be used in configuration file.
+             </para>
+       </section>
+
+</chapter>
+
diff --git a/modules_k/presence_profile/presence_profile.c b/modules_k/presence_profile/presence_profile.c
new file mode 100644 (file)
index 0000000..686dbd5
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2011 Mészáros Mihály
+ *
+ * This file is part of Kamailio, a free SIP server.
+ *
+ * Kamailio 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 2 of the License, or
+ * (at your option) any later version
+ *
+ * Kamailio 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
+ *
+ * History:
+ * --------
+ *  2011-09-22  initial version (misi)
+ */
+
+
+/*!
+ * \defgroup presence_profile Presence_profile :: Presence Handling of ua-profile events
+ */
+
+/*!
+ * \file
+ * \brief SIP-router Presence :: ua-profile provisioning support
+ * \ingroup presence
+ * Module: \ref presence
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#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_profile.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[] =
+{
+    {0,        0, 0, 0, 0, 0}
+};
+
+/* module exported paramaters */
+static param_export_t params[] = {
+    {0, 0, 0}
+};
+
+/* module exports */
+struct module_exports exports= {
+    "presence_profile",                                /* module name */
+    DEFAULT_DLFLAGS,            /* dlopen flags */
+    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 */
+};
+       
+/*
+ * init module function
+ */
+static int mod_init(void)
+{
+       presence_api_t pres;
+    bind_presence_t bind_presence;
+
+    bind_presence= (bind_presence_t)find_export("bind_presence", 1,0);
+    if (!bind_presence) {
+       LM_ERR("can't bind presence\n");
+       return -1;
+    }
+    if (bind_presence(&pres) < 0) {
+       LM_ERR("can't bind pua\n");
+       return -1;
+    }
+
+    pres_add_event = pres.add_event;
+    if (add_event == NULL) {
+       LM_ERR("could not import add_event\n");
+       return -1;
+    }
+    if(profile_add_events() < 0) {
+       LM_ERR("failed to add profile events\n");
+       return -1;              
+    }  
+    
+    return 0;
+}
diff --git a/modules_k/presence_profile/presence_profile.h b/modules_k/presence_profile/presence_profile.h
new file mode 100644 (file)
index 0000000..2b17fea
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2011 Mészáros Mihály
+ *
+ * This file is part of Kamailio, a free SIP server.
+ *
+ * Kamailio 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 2 of the License, or
+ * (at your option) any later version
+ *
+ * Kamailio 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
+ *
+ * History:
+ * --------
+ *  2011-09-22  initial version (misi)
+ */
+
+/*!
+ * \file
+ * \brief SIP-router Presence :: ua-profile provisioning support
+ * \ingroup presence
+ * Module: \ref presence
+ */
+
+
+#ifndef _PRES_PROFILE_H_
+#define _PRES_PROFILE_H_
+
+extern add_event_t pres_add_event;
+
+#endif
index 4211da2..8d30d71 100644 (file)
@@ -56,6 +56,7 @@ static struct {
        {STR_STATIC_INIT("sip-profile"),     EVENT_SIP_PROFILE},
        {STR_STATIC_INIT("message-summary"), EVENT_MESSAGE_SUMMARY},
        {STR_STATIC_INIT("dialog"),          EVENT_DIALOG},
+       {STR_STATIC_INIT("ua-profile"),      EVENT_UA_PROFILE},
        /* The following must be the last element in the array */
        {STR_NULL,                           EVENT_OTHER}
 };
index ab51b79..1f23728 100644 (file)
@@ -43,7 +43,8 @@ enum event_type {
        EVENT_SIP_PROFILE,
        EVENT_XCAP_CHANGE,
        EVENT_DIALOG,
-       EVENT_MESSAGE_SUMMARY
+       EVENT_MESSAGE_SUMMARY,
+       EVENT_UA_PROFILE
 };