Review Board 1.7.16


Who Hung Up Support for chan_motif

Review Request #2208 - Created Nov. 26, 2012 and submitted

Joshua Colp
Reviewers
asterisk-dev
Asterisk
This patch adds support for who hung up to chan_motif. The Jingle specific reason is made available, not just the cause code.
Tested various session termination errors to make sure the reason is put in.

Changes between revision 1 and 2

1 2
1 2

  1. /branches/11/channels/chan_motif.c: Loading...
/branches/11/channels/chan_motif.c
Diff Revision 1 Diff Revision 2
[20] 423 lines
[+20] [+] static void jingle_session_destructor(void *obj)
424
	if (session->connection) {
424
	if (session->connection) {
425
		ast_xmpp_client_unref(session->connection);
425
		ast_xmpp_client_unref(session->connection);
426
	}
426
	}
427

    
   
427

   
428
	if (session->rtp) {
428
	if (session->rtp) {

    
   
429
		ast_rtp_instance_stop(session->rtp);
429
		ast_rtp_instance_destroy(session->rtp);
430
		ast_rtp_instance_destroy(session->rtp);
430
	}
431
	}
431

    
   
432

   
432
	if (session->vrtp) {
433
	if (session->vrtp) {

    
   
434
		ast_rtp_instance_stop(session->vrtp);
433
		ast_rtp_instance_destroy(session->vrtp);
435
		ast_rtp_instance_destroy(session->vrtp);
434
	}
436
	}
435

    
   
437

   
436
	ast_format_cap_destroy(session->cap);
438
	ast_format_cap_destroy(session->cap);
437
	ast_format_cap_destroy(session->jointcap);
439
	ast_format_cap_destroy(session->jointcap);
[+20] [20] 238 lines
[+20] [+] static struct ast_channel *jingle_new(struct jingle_endpoint *endpoint, struct jingle_session *session, int state, const char *title, const char *linkedid, const char *cid_name)
676
	if (!ast_strlen_zero(endpoint->musicclass)) {
678
	if (!ast_strlen_zero(endpoint->musicclass)) {
677
		ast_channel_musicclass_set(chan, endpoint->musicclass);
679
		ast_channel_musicclass_set(chan, endpoint->musicclass);
678
	}
680
	}
679

    
   
681

   
680
	ast_channel_context_set(chan, endpoint->context);
682
	ast_channel_context_set(chan, endpoint->context);

    
   
683
	if (ast_exists_extension(NULL, endpoint->context, endpoint->name, 1, NULL)) {

    
   
684
		ast_channel_exten_set(chan, endpoint->name);

    
   
685
	} else {
681
	ast_channel_exten_set(chan, "s");
686
		ast_channel_exten_set(chan, "s");

    
   
687
	}
682
	ast_channel_priority_set(chan, 1);
688
	ast_channel_priority_set(chan, 1);
683

    
   
689

   
684
	ao2_unlock(endpoint);
690
	ao2_unlock(endpoint);
685

    
   
691

   
686
	return chan;
692
	return chan;
[+20] [20] 1657 lines
[+20] [+] static void jingle_action_session_info(struct jingle_endpoint *endpoint, struct jingle_session *session, ikspak *pak)
2344
static void jingle_action_session_terminate(struct jingle_endpoint *endpoint, struct jingle_session *session, ikspak *pak)
2350
static void jingle_action_session_terminate(struct jingle_endpoint *endpoint, struct jingle_session *session, ikspak *pak)
2345
{
2351
{
2346
	struct ast_channel *chan;
2352
	struct ast_channel *chan;
2347
	iks *reason, *text;
2353
	iks *reason, *text;
2348
	int cause = AST_CAUSE_NORMAL;
2354
	int cause = AST_CAUSE_NORMAL;
Moved from 2365

    
   
2355
	struct ast_control_pvt_cause_code *cause_code;
Moved from 2366

    
   
2356
	int data_size = sizeof(*cause_code);
2349

    
   
2357

   
2350
	if (!session) {
2358
	if (!session) {
2351
		jingle_send_error_response(endpoint->connection, pak, "cancel", "item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'",
2359
		jingle_send_error_response(endpoint->connection, pak, "cancel", "item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'",
2352
					   "unknown-session xmlns='urn:xmpp:jingle:errors:1'");
2360
					   "unknown-session xmlns='urn:xmpp:jingle:errors:1'");
2353
		return;
2361
		return;
[+20] [20] 6 lines
[+20] static void jingle_action_session_terminate(struct jingle_endpoint *endpoint, struct jingle_session *session, ikspak *pak)
2360
	}
2368
	}
2361

    
   
2369

   
2362
	/* Pull the reason text from the session-terminate message and translate it into a cause code */
2370
	/* Pull the reason text from the session-terminate message and translate it into a cause code */
2363
	if ((reason = iks_find(pak->query, "reason")) && (text = iks_child(reason))) {
2371
	if ((reason = iks_find(pak->query, "reason")) && (text = iks_child(reason))) {
2364
		int i;
2372
		int i;
2365
		struct ast_control_pvt_cause_code *cause_code;
Moved to 2355

   
2366
		int data_size = sizeof(*cause_code);
Moved to 2356

   
2367

    
   
2373

   
2368
		/* Size of the string making up the cause code is "Motif " + text */
2374
		/* Size of the string making up the cause code is "Motif " + text */
2369
		data_size += 6 + strlen(iks_name(text));
2375
		data_size += 6 + strlen(iks_name(text));
2370
		cause_code = ast_malloc(data_size);
2376
		cause_code = ast_malloc(data_size);
2371

    
   
2377

   
[+20] [20] 4 lines
[+20] static void jingle_action_session_terminate(struct jingle_endpoint *endpoint, struct jingle_session *session, ikspak *pak)
2376
				break;
2382
				break;
2377
			}
2383
			}
2378
		}
2384
		}
2379

    
   
2385

   
2380
		/* Store the technology specific information */
2386
		/* Store the technology specific information */
2381
		ast_copy_string(cause_code->chan_name, ast_channel_name(chan), AST_CHANNEL_NAME);

   
2382
		snprintf(cause_code->code, data_size - sizeof(*cause_code) + 1, "Motif %s", iks_name(text));
2387
		snprintf(cause_code->code, data_size - sizeof(*cause_code) + 1, "Motif %s", iks_name(text));
2383
		cause_code->ast_cause = cause;
2388
	} else {

    
   
2389
		/* No technology specific information is available */

    
   
2390
		cause_code = ast_malloc(data_size);

    
   
2391
	}
2384

    
   
2392

   

    
   
2393
	ast_copy_string(cause_code->chan_name, ast_channel_name(chan), AST_CHANNEL_NAME);

    
   
2394
	cause_code->ast_cause = cause;
2385
		ast_queue_control_data(chan, AST_CONTROL_PVT_CAUSE_CODE, cause_code, data_size);
2395
	ast_queue_control_data(chan, AST_CONTROL_PVT_CAUSE_CODE, cause_code, data_size);
2386
		ast_channel_hangupcause_hash_set(chan, cause_code, data_size);
2396
	ast_channel_hangupcause_hash_set(chan, cause_code, data_size);
2387

    
   
2397

   
2388
		ast_free(cause_code);
2398
	ast_free(cause_code);
2389
	}

   
2390

    
   
2399

   
2391
	ast_debug(3, "Hanging up channel '%s' due to session terminate message with cause '%d'\n", ast_channel_name(chan), cause);
2400
	ast_debug(3, "Hanging up channel '%s' due to session terminate message with cause '%d'\n", ast_channel_name(chan), cause);
2392
	ast_queue_hangup_with_cause(chan, cause);
2401
	ast_queue_hangup_with_cause(chan, cause);
2393
	session->gone = 1;
2402
	session->gone = 1;
2394

    
   
2403

   
[+20] [20] 221 lines
  1. /branches/11/channels/chan_motif.c: Loading...

https://reviewboard.asterisk.org/ runs on a server provided by Digium, Inc. and uses bandwidth donated to the open source Asterisk community by API Digital Communications in Huntsville, AL USA.
Please report problems with this site to asteriskteam@digium.com.