[Asterisk-code-review] pbx: Update device and presence state when changing a hint e... (asterisk[master])

Joshua Colp asteriskteam at digium.com
Wed Sep 16 10:07:10 CDT 2015


Joshua Colp has uploaded a new change for review.

  https://gerrit.asterisk.org/1264

Change subject: pbx: Update device and presence state when changing a hint extension.
......................................................................

pbx: Update device and presence state when changing a hint extension.

When changing a hint extension without removing the hint first the
device state and presence state is not updated. This causes the state
of the hint to be that of the previous extension and not the current
one. This state is kept until a state change occurs as a result of
something (presence state change, device state change).

This change updates the hint with the current device and presence
state of the new extension when it is changed.

ASTERISK-25394 #close

Change-Id: If268f1110290e502c73dd289c9e7e7b27bc8432f
---
M main/pbx.c
1 file changed, 17 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/64/1264/1

diff --git a/main/pbx.c b/main/pbx.c
index 5e4f0a4..9a939c2 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -5927,6 +5927,8 @@
 static int ast_change_hint(struct ast_exten *oe, struct ast_exten *ne)
 {
 	struct ast_hint *hint;
+	char *message = NULL, *subtype = NULL;
+	int presence_state;
 
 	if (!oe || !ne) {
 		return -1;
@@ -5949,6 +5951,21 @@
 	/* Update the hint and put it back in the hints container. */
 	ao2_lock(hint);
 	hint->exten = ne;
+
+	/* Update the saved device and presence state with the new extension */
+	hint->laststate = ast_extension_state2(ne, NULL);
+	hint->last_presence_state = AST_PRESENCE_INVALID;
+	ast_free(hint->last_presence_subtype);
+	hint->last_presence_subtype = NULL;
+	ast_free(hint->last_presence_message);
+	hint->last_presence_message = NULL;
+
+	if ((presence_state = extension_presence_state_helper(ne, &subtype, &message)) > 0) {
+		hint->last_presence_state = presence_state;
+		hint->last_presence_subtype = subtype;
+		hint->last_presence_message = message;
+	}
+
 	ao2_unlock(hint);
 	ao2_link(hints, hint);
 	if (add_hintdevice(hint, ast_get_extension_app(ne))) {

-- 
To view, visit https://gerrit.asterisk.org/1264
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If268f1110290e502c73dd289c9e7e7b27bc8432f
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Joshua Colp <jcolp at digium.com>



More information about the asterisk-code-review mailing list