[asterisk-commits] wedhorn: trunk r378624 - /trunk/channels/chan_skinny.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Jan 6 15:09:47 CST 2013


Author: wedhorn
Date: Sun Jan  6 15:09:43 2013
New Revision: 378624

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=378624
Log:
Add group and namedgroup pickup to skinny

Above says it all. Code by snuff, cleaned up by me. 

Review: https://reviewboard.asterisk.org/r/2246/

Modified:
    trunk/channels/chan_skinny.c

Modified: trunk/channels/chan_skinny.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_skinny.c?view=diff&rev=378624&r1=378623&r2=378624
==============================================================================
--- trunk/channels/chan_skinny.c (original)
+++ trunk/channels/chan_skinny.c Sun Jan  6 15:09:43 2013
@@ -888,8 +888,8 @@
 	SOFTKEY_CFWDALL,
 	SOFTKEY_CFWDBUSY,
 	SOFTKEY_DND,
-	/*SOFTKEY_GPICKUP,
-	SOFTKEY_CONFRN,*/
+	SOFTKEY_GPICKUP,
+	/*SOFTKEY_CONFRN,*/
 };
 
 static const uint8_t soft_key_default_connected[] = {
@@ -919,7 +919,7 @@
 	SOFTKEY_ENDCALL,
 	SOFTKEY_CFWDALL,
 	SOFTKEY_CFWDBUSY,
-	/*SOFTKEY_GPICKUP,*/
+	SOFTKEY_GPICKUP,
 };
 
 static const uint8_t soft_key_default_connwithtrans[] = {
@@ -1325,6 +1325,8 @@
 	char dialoutcontext[AST_MAX_CONTEXT];		\
 	ast_group_t callgroup;				\
 	ast_group_t pickupgroup;			\
+	struct ast_namedgroups *named_callgroups;	\
+	struct ast_namedgroups *named_pickupgroups;	\
 	int callwaiting;				\
 	int transfer;					\
 	int threewaycalling;				\
@@ -1559,6 +1561,8 @@
 {
 	l->cap = ast_format_cap_destroy(l->cap);
 	l->confcap = ast_format_cap_destroy(l->confcap);
+	l->named_callgroups = ast_unref_namedgroups(l->named_callgroups);
+	l->named_pickupgroups = ast_unref_namedgroups(l->named_pickupgroups);
 	ast_free(l->container);
 	ast_free(l);
 	return NULL;
@@ -4029,6 +4033,8 @@
 			continue;
 		}
 		AST_LIST_TRAVERSE(&d->lines, l, list) {
+			struct ast_str *tmp_str = ast_str_alloca(512);
+
 			if (strcasecmp(argv[3], l->name)) {
 				continue;
 			}
@@ -4040,6 +4046,10 @@
 				ast_cli(fd, "Context:          %s\n", l->context);
 				ast_cli(fd, "CallGroup:        %s\n", ast_print_group(group_buf, sizeof(group_buf), l->callgroup));
 				ast_cli(fd, "PickupGroup:      %s\n", ast_print_group(group_buf, sizeof(group_buf), l->pickupgroup));
+				ast_cli(fd, "NamedCallGroup:   %s\n", ast_print_namedgroups(&tmp_str, l->named_callgroups));
+				ast_str_reset(tmp_str);
+				ast_cli(fd, "NamedPickupGroup: %s\n", ast_print_namedgroups(&tmp_str, l->named_pickupgroups));
+				ast_str_reset(tmp_str);
 				ast_cli(fd, "Language:         %s\n", S_OR(l->language, "<not set>"));
 				ast_cli(fd, "Accountcode:      %s\n", S_OR(l->accountcode, "<not set>"));
 				ast_cli(fd, "AmaFlag:          %s\n", ast_cdr_flags2str(l->amaflags));
@@ -4093,6 +4103,10 @@
 				astman_append(s, "Context: %s\r\n", l->context);
 				astman_append(s, "CallGroup: %s\r\n", ast_print_group(group_buf, sizeof(group_buf), l->callgroup));
 				astman_append(s, "PickupGroup: %s\r\n", ast_print_group(group_buf, sizeof(group_buf), l->pickupgroup));
+				astman_append(s, "NamedCallGroup: %s\r\n", ast_print_namedgroups(&tmp_str, l->named_callgroups));
+				ast_str_reset(tmp_str);
+				astman_append(s, "NamedPickupGroup: %s\r\n", ast_print_namedgroups(&tmp_str, l->named_pickupgroups));
+				ast_str_reset(tmp_str);
 				astman_append(s, "Language: %s\r\n", S_OR(l->language, "<not set>"));
 				astman_append(s, "Accountcode: %s\r\n", S_OR(l->accountcode, "<not set>"));
 				astman_append(s, "AMAflags: %s\r\n", ast_cdr_flags2str(l->amaflags));
@@ -4915,6 +4929,9 @@
 		ast_channel_callgroup_set(tmp, l->callgroup);
 		ast_channel_pickupgroup_set(tmp, l->pickupgroup);
 
+		ast_channel_named_callgroups_set(tmp, l->named_callgroups);
+		ast_channel_named_pickupgroups_set(tmp, l->named_pickupgroups);
+
 		/* XXX Need to figure out how to handle CFwdNoAnswer */
 		if (l->cfwdtype & SKINNY_CFWD_ALL) {
 			ast_channel_call_forward_set(tmp, l->call_forward_all);
@@ -6682,6 +6699,22 @@
 	case SOFTKEY_GPICKUP:
 		SKINNY_DEBUG(DEBUG_PACKET, 3, "Received SOFTKEY_GPICKUP from %s, inst %d, callref %d\n",
 			d->name, instance, callreference);
+		if (!sub || !sub->owner) {
+			c = skinny_new(l, NULL, AST_STATE_DOWN, NULL, SKINNY_INCOMING);
+		} else {
+			c = sub->owner;
+		}
+
+		if (!c) {
+			ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name);
+		} else {
+			ast_channel_ref(c);
+			sub = ast_channel_tech_pvt(c);
+			ast_pickup_call(c);
+			ast_hangup(c);
+			setsubstate(sub, SUBSTATE_CONNECTED);
+			ast_channel_unref(c);
+		}
 		break;
 	default:
 		SKINNY_DEBUG(DEBUG_PACKET, 3, "Received SOFTKEY_UNKNOWN(%d) from %s, inst %d, callref %d\n",
@@ -7344,6 +7377,16 @@
  				CLINE_OPTS->pickupgroup = ast_get_group(v->value);
  				continue;
  			}
+		} else if (!strcasecmp(v->name, "namedcallgroup")) {
+			if (type & (TYPE_DEF_LINE | TYPE_LINE)) {
+				CLINE_OPTS->named_callgroups = ast_get_namedgroups(v->value);
+				continue;
+			}
+		} else if (!strcasecmp(v->name, "namedpickupgroup")) {
+			if (type & (TYPE_DEF_LINE | TYPE_LINE)) {
+				CLINE_OPTS->named_pickupgroups = ast_get_namedgroups(v->value);
+				continue;
+			}
  		} else if (!strcasecmp(v->name, "immediate")) {
  			if (type & (TYPE_DEF_DEVICE | TYPE_DEVICE | TYPE_DEF_LINE | TYPE_LINE)) {
  				CLINE_OPTS->immediate = ast_true(v->value);




More information about the asterisk-commits mailing list