[asterisk-commits] jpeeler: trunk r217954 - /trunk/channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Sep 10 18:29:19 CDT 2009


Author: jpeeler
Date: Thu Sep 10 18:29:14 2009
New Revision: 217954

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=217954
Log:
Allow do not disturb to be set on analog channels via the CLI and AMI.

Modified:
    trunk/channels/chan_dahdi.c
    trunk/channels/sig_analog.c
    trunk/channels/sig_analog.h

Modified: trunk/channels/chan_dahdi.c
URL: http://svn.asterisk.org/svn-view/asterisk/trunk/channels/chan_dahdi.c?view=diff&rev=217954&r1=217953&r2=217954
==============================================================================
--- trunk/channels/chan_dahdi.c (original)
+++ trunk/channels/chan_dahdi.c Thu Sep 10 18:29:14 2009
@@ -784,7 +784,7 @@
 	unsigned int dialing:1;
 	/*! \brief TRUE if the transfer capability of the call is digital. */
 	unsigned int digital:1;
-	/*! \brief TRUE if Do-Not-Disturb is enabled. */
+	/*! \brief TRUE if Do-Not-Disturb is enabled, present only for non sig_analog */
 	unsigned int dnd:1;
 	/*! \brief XXX BOOLEAN Purpose??? */
 	unsigned int echobreak:1;
@@ -8399,24 +8399,34 @@
 
 /*! \brief enable or disable the chan_dahdi Do-Not-Disturb mode for a DAHDI channel
  * \param dahdichan "Physical" DAHDI channel (e.g: DAHDI/5)
- * \param on 1 to enable, 0 to disable
+ * \param on 1 to enable, 0 to disable, -1 return dnd value
  *
  * chan_dahdi has a DND (Do Not Disturb) mode for each dahdichan (physical
  * DAHDI channel). Use this to enable or disable it.
  *
  * \bug the use of the word "channel" for those dahdichans is really confusing.
  */
-static void dahdi_dnd(struct dahdi_pvt *dahdichan, int on)
-{
+static int dahdi_dnd(struct dahdi_pvt *dahdichan, int flag)
+{
+	if (analog_lib_handles(dahdichan->sig, dahdichan->radio, dahdichan->oprmode)) {
+		return analog_dnd(dahdichan->sig_pvt, flag);
+	}
+
+	if (flag == -1) {
+		return dahdichan->dnd;
+	}
+
 	/* Do not disturb */
-	dahdichan->dnd = on;
+	dahdichan->dnd = flag;
 	ast_verb(3, "%s DND on channel %d\n",
-			on? "Enabled" : "Disabled",
+			flag? "Enabled" : "Disabled",
 			dahdichan->channel);
 	manager_event(EVENT_FLAG_SYSTEM, "DNDState",
 			"Channel: DAHDI/%d\r\n"
 			"Status: %s\r\n", dahdichan->channel,
-			on? "enabled" : "disabled");
+			flag? "enabled" : "disabled");
+
+	return 0;
 }
 
 static void *analog_ss_thread(void *data)
@@ -13864,7 +13874,7 @@
 			ast_cli(a->fd, "Default law: %s\n", tmp->law == DAHDI_LAW_MULAW ? "ulaw" : tmp->law == DAHDI_LAW_ALAW ? "alaw" : "unknown");
 			ast_cli(a->fd, "Fax Handled: %s\n", tmp->faxhandled ? "yes" : "no");
 			ast_cli(a->fd, "Pulse phone: %s\n", tmp->pulsedial ? "yes" : "no");
-			ast_cli(a->fd, "DND: %s\n", tmp->dnd ? "yes" : "no");
+			ast_cli(a->fd, "DND: %s\n", dahdi_dnd(tmp, -1) ? "yes" : "no");
 			ast_cli(a->fd, "Echo Cancellation:\n");
 
 			if (tmp->echocancel.head.tap_length) {
@@ -14370,7 +14380,7 @@
 		astman_send_error(s, m, "No such channel");
 		return 0;
 	}
-	p->dnd = 1;
+	dahdi_dnd(p, 1);
 	astman_send_ack(s, m, "DND Enabled");
 	return 0;
 }
@@ -14389,7 +14399,7 @@
 		astman_send_error(s, m, "No such channel");
 		return 0;
 	}
-	p->dnd = 0;
+	dahdi_dnd(p, 0);
 	astman_send_ack(s, m, "DND Disabled");
 	return 0;
 }
@@ -14514,7 +14524,7 @@
 					sig2str(tmp->sig),
 					tmp->sig,
 					tmp->context,
-					tmp->dnd ? "Enabled" : "Disabled",
+					dahdi_dnd(tmp, -1) ? "Enabled" : "Disabled",
 					alarm2str(alm), idText);
 			} else {
 				astman_append(s,
@@ -14529,7 +14539,7 @@
 					"\r\n",
 					tmp->channel, sig2str(tmp->sig), tmp->sig,
 					tmp->context,
-					tmp->dnd ? "Enabled" : "Disabled",
+					dahdi_dnd(tmp, -1) ? "Enabled" : "Disabled",
 					alarm2str(alm), idText);
 			}
 		}

Modified: trunk/channels/sig_analog.c
URL: http://svn.asterisk.org/svn-view/asterisk/trunk/channels/sig_analog.c?view=diff&rev=217954&r1=217953&r2=217954
==============================================================================
--- trunk/channels/sig_analog.c (original)
+++ trunk/channels/sig_analog.c Thu Sep 10 18:29:14 2009
@@ -3477,3 +3477,22 @@
 	analog_update_conf(new_pvt);
 	return 0;
 }
+
+int analog_dnd(struct analog_pvt *p, int flag)
+{
+	if (flag == -1) {
+		return p->dnd;
+	}
+
+	p->dnd = flag;
+
+	ast_verb(3, "%s DND on channel %d\n",
+			flag? "Enabled" : "Disabled",
+			p->channel);
+	manager_event(EVENT_FLAG_SYSTEM, "DNDState",
+			"Channel: DAHDI/%d\r\n"
+			"Status: %s\r\n", p->channel,
+			flag? "enabled" : "disabled");
+
+	return 0;
+}

Modified: trunk/channels/sig_analog.h
URL: http://svn.asterisk.org/svn-view/asterisk/trunk/channels/sig_analog.h?view=diff&rev=217954&r1=217953&r2=217954
==============================================================================
--- trunk/channels/sig_analog.h (original)
+++ trunk/channels/sig_analog.h Thu Sep 10 18:29:14 2009
@@ -274,7 +274,7 @@
 	unsigned int callwaiting:1;
 	unsigned int dialednone:1;
 	unsigned int dialing:1;			/*!< TRUE if in the process of dialing digits or sending something */
-	unsigned int dnd:1;
+	unsigned int dnd:1;				/*!< TRUE if Do-Not-Disturb is enabled. */
 	unsigned int echobreak:1;
 	unsigned int hidecallerid:1;
 	unsigned int outgoing:1;
@@ -350,4 +350,6 @@
 
 int analog_fixup(struct ast_channel *oldchan, struct ast_channel *newchan, void *newp);
 
+int analog_dnd(struct analog_pvt *p, int flag);
+
 #endif /* _SIG_ANSLOG_H */




More information about the asterisk-commits mailing list