[svn-commits] marquis: branch group/pinana-publish-1.4 r296531 - in /team/group/pinana-publ...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sun Nov 28 16:06:45 CST 2010


Author: marquis
Date: Sun Nov 28 16:06:41 2010
New Revision: 296531

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=296531
Log:
Backport some minor changes to devicestate.[h|c] in order to make forward porting this easier.  Wrap up most of the initial epa_entry creation.

Modified:
    team/group/pinana-publish-1.4/channels/chan_sip.c
    team/group/pinana-publish-1.4/include/asterisk/devicestate.h
    team/group/pinana-publish-1.4/main/devicestate.c

Modified: team/group/pinana-publish-1.4/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pinana-publish-1.4/channels/chan_sip.c?view=diff&rev=296531&r1=296530&r2=296531
==============================================================================
--- team/group/pinana-publish-1.4/channels/chan_sip.c (original)
+++ team/group/pinana-publish-1.4/channels/chan_sip.c Sun Nov 28 16:06:41 2010
@@ -9926,6 +9926,9 @@
 	/* At this point we have a device state change to publish to one presence server. */
 	if (!found) {
 		char uri[SIPBUFSIZE];
+		char body[SIPBUFSIZE * 2];
+		char dlg_id[20];
+		size_t maxbytes = sizeof(body);
 
 		ast_log(LOG_DEBUG, "*** Creating new publish device for %s\n", sc->dev);
 		snprintf(uri, sizeof(uri), "sip:%s@%s", sc->dev, pres_server->domain);
@@ -9937,10 +9940,15 @@
 		ast_copy_string(device->pubname, pres_server->name, sizeof(device->pubname));
 		/* Initiate stuff */
 		ao2_link(pub_dev, device);
-		/* Do stuff here */
 		publish_type = SIP_PUBLISH_INITIAL;
-		device->epa = ast_calloc(1, sizeof(struct sip_epa_entry));
-		ast_copy_string(device->epa->body, "FNULHAKE\nGNURP", sizeof(device->epa->body));
+		if (!(device->epa = ast_calloc(1, sizeof(struct sip_epa_entry)))) {
+			ast_log(LOG_ERROR, "Cannot allocate sip_epa_entry!\n");
+			return -1;
+		}
+		generate_random_string(dlg_id, sizeof(dlg_id));
+		/*Assuming for now that we're sending a full update when we initially create the epa_entry and send the PUBLISH*/
+		presence_build_dialoginfo_xml(body, &maxbytes, 1, ast_devstate_str(sc->state), dlg_id, 1, uri, 0);
+		ast_copy_string(device->epa->body, body, sizeof(device->epa->body));
 		ast_copy_string(device->epa->destination, pres_server->host, sizeof(device->epa->destination));
 		device->epa->publish_type = publish_type;
 		ast_copy_string(device->epa->entity_tag, create_new_etag(), sizeof(device->epa->entity_tag));

Modified: team/group/pinana-publish-1.4/include/asterisk/devicestate.h
URL: http://svnview.digium.com/svn/asterisk/team/group/pinana-publish-1.4/include/asterisk/devicestate.h?view=diff&rev=296531&r1=296530&r2=296531
==============================================================================
--- team/group/pinana-publish-1.4/include/asterisk/devicestate.h (original)
+++ team/group/pinana-publish-1.4/include/asterisk/devicestate.h Sun Nov 28 16:06:41 2010
@@ -46,6 +46,13 @@
 
 /*!  \brief Devicestate provider call back */
 typedef int (*ast_devstate_prov_cb_type)(const char *data);
+
+/*!
+ * \brief Convert device state to text string that is easier to parse
+ *
+ * \param devstate Current device state
+ */
+const char *ast_devstate_str(enum ast_device_state devstate);
 
 /*! \brief Convert device state to text string for output 
  * \param devstate Current device state 

Modified: team/group/pinana-publish-1.4/main/devicestate.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pinana-publish-1.4/main/devicestate.c?view=diff&rev=296531&r1=296530&r2=296531
==============================================================================
--- team/group/pinana-publish-1.4/main/devicestate.c (original)
+++ team/group/pinana-publish-1.4/main/devicestate.c Sun Nov 28 16:06:41 2010
@@ -44,19 +44,17 @@
 #include "asterisk/options.h"
 
 /*! \brief Device state strings for printing */
-static const char *devstatestring[] = {
-	/* 0 AST_DEVICE_PROV_NOT_FOUND */    "Provider not found",    /*!< Provider not found */
-	/* 0 AST_DEVICE_UNKNOWN */    "Unknown",    /*!< Valid, but unknown state */
-	/* 1 AST_DEVICE_NOT_INUSE */  "Not in use", /*!< Not used */
-	/* 2 AST_DEVICE IN USE */     "In use",     /*!< In use */
-	/* 3 AST_DEVICE_BUSY */	      "Busy",       /*!< Busy */
-	/* 4 AST_DEVICE_INVALID */    "Invalid",    /*!< Invalid - not known to Asterisk */
-	/* 5 AST_DEVICE_UNAVAILABLE */"Unavailable",/*!< Unavailable (not registered) */
-	/* 6 AST_DEVICE_RINGING */    "Ringing",    /*!< Ring, ring, ring */
-	/* 7 AST_DEVICE_RINGINUSE */  "Ring+Inuse", /*!< Ring and in use */
-	/* 8 AST_DEVICE_ONHOLD */     "On Hold"     /*!< On Hold */
+static const char * const devstatestring[][2] = {
+	{ /* 0 AST_DEVICE_UNKNOWN */     "Unknown",     "UNKNOWN"     }, /*!< Valid, but unknown state */
+	{ /* 1 AST_DEVICE_NOT_INUSE */   "Not in use",  "NOT_INUSE"   }, /*!< Not used */
+	{ /* 2 AST_DEVICE IN USE */      "In use",      "INUSE"       }, /*!< In use */
+	{ /* 3 AST_DEVICE_BUSY */        "Busy",        "BUSY"        }, /*!< Busy */
+	{ /* 4 AST_DEVICE_INVALID */     "Invalid",     "INVALID"     }, /*!< Invalid - not known to Asterisk */
+	{ /* 5 AST_DEVICE_UNAVAILABLE */ "Unavailable", "UNAVAILABLE" }, /*!< Unavailable (not registered) */
+	{ /* 6 AST_DEVICE_RINGING */     "Ringing",     "RINGING"     }, /*!< Ring, ring, ring */
+	{ /* 7 AST_DEVICE_RINGINUSE */   "Ring+Inuse",  "RINGINUSE"   }, /*!< Ring and in use */
+	{ /* 8 AST_DEVICE_ONHOLD */      "On Hold",      "ONHOLD"      }, /*!< On Hold */
 };
-
 /*! \brief  A device state provider (not a channel) */
 struct devstate_prov {
 	char label[40];
@@ -98,9 +96,14 @@
 /*! \brief Find devicestate as text message for output */
 const char *devstate2str(enum ast_device_state devstate) 
 {
-	return devstatestring[devstate];
-}
-
+	return devstatestring[devstate][0];
+}
+
+/* Parseable */
+const char *ast_devstate_str(enum ast_device_state state)
+{
+        return devstatestring[state][1];
+}
 /*! \brief Find out if device is active in a call or not 
 	\note find channels with the device's name in it
 	This function is only used for channels that does not implement 




More information about the svn-commits mailing list