[libpri-commits] rmudgett: branch rmudgett/mwi2 r2197 - /team/rmudgett/mwi2/

SVN commits to the libpri project libpri-commits at lists.digium.com
Tue Feb 8 15:11:25 CST 2011


Author: rmudgett
Date: Tue Feb  8 15:11:20 2011
New Revision: 2197

URL: http://svnview.digium.com/svn/libpri?view=rev&rev=2197
Log:
Initial attempt to fix MWI indicate missing the voicemail controlling number.

Since more information was needed to properly send the MWIIndicate
message, I needed to add a new API call to replace the insufficient call.

Modified:
    team/rmudgett/mwi2/libpri.h
    team/rmudgett/mwi2/pri_facility.c
    team/rmudgett/mwi2/pri_internal.h
    team/rmudgett/mwi2/q931.c

Modified: team/rmudgett/mwi2/libpri.h
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/mwi2/libpri.h?view=diff&rev=2197&r1=2196&r2=2197
==============================================================================
--- team/rmudgett/mwi2/libpri.h (original)
+++ team/rmudgett/mwi2/libpri.h Tue Feb  8 15:11:20 2011
@@ -1621,11 +1621,11 @@
  * \brief Send a MWI indication on the specified D channel.
  *
  * \param ctrl D channel controller.
- * \param mailbox Controlling party number (NULL if not present).
+ * \param mailbox Party receiving notification.
  * \param basic_service Basic service enum (-1 if not present).
  * \param num_messages NumberOfMessages (-1 if not present).
- * \param caller_id Controlling party privided number (NULL if not present).
- * \param timestamp Generalized Time format (NULL if not present).
+ * \param caller_id Party leaving message (NULL if not present).
+ * \param timestamp When message left. (Generalized Time format, NULL if not present)
  * \param message_reference Message reference number (-1 if not present).
  * \param message_status Message status: added(0), removed(1).
  *
@@ -1635,6 +1635,27 @@
 int pri_mwi_indicate(struct pri *ctrl, const struct pri_party_id *mailbox,
 	int basic_service, int num_messages, const struct pri_party_id *caller_id,
 	const char *timestamp, int message_reference, int message_status);
+
+/*!
+ * \brief Send a MWI indication on the specified D channel. (Take two)
+ *
+ * \param ctrl D channel controller.
+ * \param mailbox Party receiving notification.
+ * \param vm_id Voicemail system number (NULL if not present).
+ * \param basic_service Basic service enum (-1 if not present).
+ * \param num_messages NumberOfMessages (-1 if not present).
+ * \param caller_id Party leaving message (NULL if not present).
+ * \param timestamp When message left. (Generalized Time format, NULL if not present)
+ * \param message_reference Message reference number (-1 if not present).
+ * \param message_status Message status: added(0), removed(1).
+ *
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+int pri_mwi_indicate_v2(struct pri *ctrl, const struct pri_party_id *mailbox,
+	const struct pri_party_id *vm_id, int basic_service, int num_messages,
+	const struct pri_party_id *caller_id, const char *timestamp, int message_reference,
+	int message_status);
 
 /* Set service message support flag */
 int pri_set_service_message_support(struct pri *pri, int supportflag);

Modified: team/rmudgett/mwi2/pri_facility.c
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/mwi2/pri_facility.c?view=diff&rev=2197&r1=2196&r2=2197
==============================================================================
--- team/rmudgett/mwi2/pri_facility.c (original)
+++ team/rmudgett/mwi2/pri_facility.c Tue Feb  8 15:11:20 2011
@@ -1746,11 +1746,11 @@
  * \param ctrl D channel controller for diagnostic messages or global options.
  * \param pos Starting position to encode the facility ie contents.
  * \param end End of facility ie contents encoding data buffer.
- * \param mailbox Controlling party number (NULL if not present).
+ * \param vm_id Controlling party number (NULL if not present).
  * \param basic_service Basic service enum (-1 if not present).
  * \param num_messages NumberOfMessages (-1 if not present).
  * \param caller_id Controlling party privided number (NULL if not present).
- * \param timestamp Generalized Time format (NULL if not present).
+ * \param timestamp When message left. (Generalized Time format, NULL if not present)
  * \param message_reference Message reference number (-1 if not present).
  * \param message_status Message status: added(0), removed(1).
  *
@@ -1758,7 +1758,7 @@
  * \retval NULL on error.
  */
 static unsigned char *enc_etsi_mwi_indicate_message(struct pri *ctrl, unsigned char *pos,
-	unsigned char *end, const struct pri_party_id *mailbox, int basic_service,
+	unsigned char *end, const struct pri_party_id *vm_id, int basic_service,
 	int num_messages, const struct pri_party_id *caller_id, const char *timestamp,
 	int message_reference, int message_status)
 {
@@ -1774,8 +1774,8 @@
 	msg.operation = ROSE_ETSI_MWIIndicate;
 	msg.invoke_id = get_invokeid(ctrl);
 
-	if (mailbox && mailbox->number.valid) {
-		pri_copy_party_number_to_q931(&number, &mailbox->number);
+	if (vm_id && vm_id->number.valid) {
+		pri_copy_party_number_to_q931(&number, &vm_id->number);
 		q931_copy_number_to_rose(ctrl, &msg.args.etsi.MWIIndicate.controlling_user_number,
 			&number);
 	}
@@ -1814,11 +1814,11 @@
  *
  * \param ctrl D channel controller.
  * \param call Call leg to queue message.
- * \param mailbox Controlling party number (NULL if not present).
+ * \param vm_id Voicemail system number (NULL if not present).
  * \param basic_service Basic service enum (-1 if not present).
  * \param num_messages NumberOfMessages (-1 if not present).
- * \param caller_id Controlling party privided number (NULL if not present).
- * \param timestamp Generalized Time format (NULL if not present).
+ * \param caller_id Party leaving message (NULL if not present).
+ * \param timestamp When message left. (Generalized Time format, NULL if not present)
  * \param message_reference Message reference number (-1 if not present).
  * \param message_status Message status: added(0), removed(1).
  *
@@ -1826,14 +1826,14 @@
  * \retval -1 on error.
  */
 static int rose_mwi_indicate_encode(struct pri *ctrl, struct q931_call *call,
-	const struct pri_party_id *mailbox, int basic_service, int num_messages,
+	const struct pri_party_id *vm_id, int basic_service, int num_messages,
 	const struct pri_party_id *caller_id, const char *timestamp, int message_reference,
 	int message_status)
 {
 	unsigned char buffer[255];
 	unsigned char *end;
 
-	end = enc_etsi_mwi_indicate_message(ctrl, buffer, buffer + sizeof(buffer), mailbox,
+	end = enc_etsi_mwi_indicate_message(ctrl, buffer, buffer + sizeof(buffer), vm_id,
 		basic_service, num_messages, caller_id, timestamp, message_reference,
 		message_status);
 	if (!end) {
@@ -1843,11 +1843,13 @@
 	return pri_call_apdu_queue(call, Q931_FACILITY, buffer, end - buffer, NULL);
 }
 
-int pri_mwi_indicate(struct pri *ctrl, const struct pri_party_id *mailbox,
-	int basic_service, int num_messages, const struct pri_party_id *caller_id,
-	const char *timestamp, int message_reference, int message_status)
+int pri_mwi_indicate_v2(struct pri *ctrl, const struct pri_party_id *mailbox,
+	const struct pri_party_id *vm_id, int basic_service, int num_messages,
+	const struct pri_party_id *caller_id, const char *timestamp, int message_reference,
+	int message_status)
 {
 	struct q931_call *call;
+	struct q931_party_id called;
 
 	if (!ctrl) {
 		return -1;
@@ -1868,15 +1870,24 @@
 		return -1;
 	}
 
-	if (rose_mwi_indicate_encode(ctrl, call, mailbox, basic_service, num_messages,
+	pri_copy_party_id_to_q931(&called, mailbox);
+	if (rose_mwi_indicate_encode(ctrl, call, vm_id, basic_service, num_messages,
 		caller_id, timestamp, message_reference, message_status)
-		|| q931_facility(ctrl, call)) {
+		|| q931_facility_called(ctrl, call, &called)) {
 		pri_message(ctrl,
 			"Could not schedule facility message for MWI indicate message.\n");
 		return -1;
 	}
 
 	return 0;
+}
+
+int pri_mwi_indicate(struct pri *ctrl, const struct pri_party_id *mailbox,
+	int basic_service, int num_messages, const struct pri_party_id *caller_id,
+	const char *timestamp, int message_reference, int message_status)
+{
+	return pri_mwi_indicate_v2(ctrl, mailbox, mailbox, basic_service, num_messages,
+	caller_id, timestamp, message_reference, message_status);
 }
 /* End MWI */
 

Modified: team/rmudgett/mwi2/pri_internal.h
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/mwi2/pri_internal.h?view=diff&rev=2197&r1=2196&r2=2197
==============================================================================
--- team/rmudgett/mwi2/pri_internal.h (original)
+++ team/rmudgett/mwi2/pri_internal.h Tue Feb  8 15:11:20 2011
@@ -975,6 +975,7 @@
 int q931_display_text(struct pri *ctrl, struct q931_call *call, const struct pri_subcmd_display_txt *display);
 
 int q931_facility_display_name(struct pri *ctrl, struct q931_call *call, const struct q931_party_name *name);
+int q931_facility_called(struct pri *ctrl, struct q931_call *call, const struct q931_party_id *called);
 
 const char *q931_call_state_str(enum Q931_CALL_STATE callstate);
 const char *msg2str(int msg);

Modified: team/rmudgett/mwi2/q931.c
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/mwi2/q931.c?view=diff&rev=2197&r1=2196&r2=2197
==============================================================================
--- team/rmudgett/mwi2/q931.c (original)
+++ team/rmudgett/mwi2/q931.c Tue Feb  8 15:11:20 2011
@@ -4990,6 +4990,33 @@
 	return send_message(ctrl, call, Q931_FACILITY, facility_ies);
 }
 
+/*!
+ * \brief Send a FACILITY message with the called party number and subaddress ies.
+ *
+ * \param ctrl D channel controller.
+ * \param call Call leg to send message over.
+ * \param called Called party information to send.
+ *
+ * \note
+ * This function can only be used by the dummy call because the call's called
+ * structure is used by normal calls to contain persistent information.
+ *
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+int q931_facility_called(struct pri *ctrl, struct q931_call *call, const struct q931_party_id *called)
+{
+	static int facility_called_ies[] = {
+		Q931_IE_FACILITY,
+		Q931_CALLED_PARTY_NUMBER,
+		Q931_CALLED_PARTY_SUBADDR,
+		-1
+	};
+
+	q931_party_id_copy_to_address(&call->called, called);
+	return send_message(ctrl, call, Q931_FACILITY, facility_called_ies);
+}
+
 int q931_facility_display_name(struct pri *ctrl, struct q931_call *call, const struct q931_party_name *name)
 {
 	int status;




More information about the libpri-commits mailing list