Skip to content

Commit

Permalink
Back port of sendRedirectedUpdate. references #18.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.code.sf.net/p/chan-sccp-b/code/trunk@4209 43c1dc8c-776e-4df2-8ef1-6e829299be21
  • Loading branch information
ddegroot committed Feb 7, 2013
1 parent 20b9717 commit 91ea171
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 16 deletions.
80 changes: 69 additions & 11 deletions src/pbx_impl/ast/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -682,17 +682,17 @@ void sccp_asterisk_redirectedUpdate(sccp_channel_t * channel, const void *data,
{
PBX_CHANNEL_TYPE *ast = channel->owner;

#if ASTERISK_VERSION_GROUP >106
struct ast_party_id redirecting_from = pbx_channel_redirecting_effective_from(ast);
struct ast_party_id redirecting_to = pbx_channel_redirecting_effective_to(ast);

struct ast_party_id redirecting_from = ast_channel_redirecting_effective_from(ast);
struct ast_party_id redirecting_to = ast_channel_redirecting_effective_to(ast);


sccp_log((DEBUGCAT_PBX)) (VERBOSE_PREFIX_3 "%s: Got redirecting update. From %s<%s>; To %s<%s>\n", pbx_channel_name(ast),
redirecting_from.name.valid ? redirecting_from.name.str : "",
redirecting_from.number.valid ? redirecting_from.number.str : "",
redirecting_to.name.valid ? redirecting_to.name.str : "",
redirecting_to.number.valid ? redirecting_to.number.str : ""
);
sccp_log((DEBUGCAT_PBX)) (VERBOSE_PREFIX_3 "%s: Got redirecting update. From %s<%s>; To %s<%s>\n",
pbx_channel_name(ast),
redirecting_from.name.valid ? redirecting_from.name.str : "",
redirecting_from.number.valid ? redirecting_from.number.str : "",
redirecting_to.name.valid ? redirecting_to.name.str : "",
redirecting_to.number.valid ? redirecting_to.number.str : ""
);



Expand All @@ -702,9 +702,67 @@ void sccp_asterisk_redirectedUpdate(sccp_channel_t * channel, const void *data,

sccp_copy_string(channel->callInfo.lastRedirectingPartyNumber, redirecting_from.number.valid ? redirecting_from.number.str : "", sizeof(channel->callInfo.lastRedirectingPartyNumber));
channel->callInfo.lastRedirectingParty_valid = 1;

#else
sccp_copy_string(channel->callInfo.lastRedirectingPartyNumber, ast->cid.cid_rdnis ? ast->cid.cid_rdnis : "", sizeof(channel->callInfo.lastRedirectingPartyNumber));
channel->callInfo.lastRedirectingParty_valid = 1;
#endif

sccp_channel_send_callinfo2(channel);
}

void sccp_wrapper_sendRedirectedUpdate(const sccp_channel_t * channel, const char *fromNumber, const char *fromName, const char *toNumber, const char *toName, uint8_t reason)
{
#if ASTERISK_VERSION_GROUP >106
struct ast_party_redirecting redirecting;
struct ast_set_party_redirecting update_redirecting;

ast_party_redirecting_init(&redirecting);
memset(&update_redirecting, 0, sizeof(update_redirecting));


/* update redirecting info line for source part */
if(fromNumber){
update_redirecting.from.number = 1;
redirecting.from.number.valid = 1;
redirecting.from.number.str = strdupa(fromNumber);
}

if(fromName){
update_redirecting.from.name = 1;
redirecting.from.name.valid = 1;
redirecting.from.name.str = strdupa(fromName);
}

if(toNumber){
update_redirecting.to.number = 1;
redirecting.to.number.valid = 1;
redirecting.to.number.str = strdupa(toNumber);
}

if(toName){
update_redirecting.to.name = 1;
redirecting.to.name.valid = 1;
redirecting.to.name.str = strdupa(toName);
}

ast_channel_queue_redirecting_update(channel->owner, &redirecting, &update_redirecting);
#else
// set redirecting party (forwarder)
if (fromNumber) {
if (channel->owner->cid.cid_rdnis) {
ast_free(channel->owner->cid.cid_rdnis);
}
channel->owner->cid.cid_rdnis = ast_strdup(fromNumber);
}

// where is the call going to now
if (toNumber) {
if (channel->owner->cid.cid_dnid) {
ast_free(channel->owner->cid.cid_dnid);
}
channel->owner->cid.cid_dnid = ast_strdup(toNumber);
}
#endif
}

// kate: indent-width 4; replace-tabs off; indent-mode cstyle; auto-insert-doxygen on; line-numbers on; tab-indents on; keep-extra-spaces off;
1 change: 1 addition & 0 deletions src/pbx_impl/ast/ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,5 +357,6 @@ boolean_t sccp_asterisk_removeTreeFromDatabase(const char *family, const char *k
int sccp_asterisk_moh_start(PBX_CHANNEL_TYPE * pbx_channel, const char *mclass, const char* interpclass);
void sccp_asterisk_moh_stop(PBX_CHANNEL_TYPE * pbx_channel);
void sccp_asterisk_redirectedUpdate(sccp_channel_t * channel, const void *data, size_t datalen);
void sccp_wrapper_sendRedirectedUpdate(const sccp_channel_t * channel, const char *fromNumber, const char *fromName, const char *toNumber, const char *toName, uint8_t reason);

This comment has been minimized.

Copy link
@marcelloceschia

marcelloceschia Feb 7, 2013

Collaborator

kannst du die Funktion bitte sccp_asterisk_sendRedirectedUpdate nennen?

#endif

3 changes: 2 additions & 1 deletion src/pbx_impl/ast/ast106.c
Original file line number Diff line number Diff line change
Expand Up @@ -2655,6 +2655,7 @@ sccp_pbx_cb sccp_pbx = {
set_callerid_redirectedParty: sccp_wrapper_asterisk16_setRedirectedParty,
set_callerid_presence: sccp_wrapper_asterisk16_setCalleridPresence,
set_connected_line: sccp_wrapper_asterisk16_updateConnectedLine,
sendRedirectedUpdate: sccp_wrapper_sendRedirectedUpdate,

/* feature section */
feature_park: sccp_wrapper_asterisk16_park,
Expand Down Expand Up @@ -2771,7 +2772,7 @@ struct sccp_pbx_cb sccp_pbx = {
.set_callerid_redirectedParty = sccp_wrapper_asterisk16_setRedirectedParty,
.set_callerid_presence = sccp_wrapper_asterisk16_setCalleridPresence,
.set_connected_line = sccp_wrapper_asterisk16_updateConnectedLine,

.sendRedirectedUpdate = sccp_wrapper_sendRedirectedUpdate,

/* database */
.feature_addToDatabase = sccp_asterisk_addToDatabase,
Expand Down
2 changes: 2 additions & 0 deletions src/pbx_impl/ast/ast108.c
Original file line number Diff line number Diff line change
Expand Up @@ -2988,6 +2988,7 @@ sccp_pbx_cb sccp_pbx = {
set_callerid_redirectedParty: sccp_wrapper_asterisk18_setRedirectedParty,
set_callerid_presence: sccp_wrapper_asterisk18_setCalleridPresence,
set_connected_line: sccp_wrapper_asterisk18_updateConnectedLine,
sendRedirectedUpdate: sccp_wrapper_sendRedirectedUpdate,

/* feature section */
feature_park: sccp_wrapper_asterisk18_park,
Expand Down Expand Up @@ -3101,6 +3102,7 @@ struct sccp_pbx_cb sccp_pbx = {
.set_callerid_redirectedParty = sccp_wrapper_asterisk18_setRedirectedParty,
.set_callerid_presence = sccp_wrapper_asterisk18_setCalleridPresence,
.set_connected_line = sccp_wrapper_asterisk18_updateConnectedLine,
.sendRedirectedUpdate = sccp_wrapper_sendRedirectedUpdate,


/* database */
Expand Down
3 changes: 2 additions & 1 deletion src/pbx_impl/ast/ast110.c
Original file line number Diff line number Diff line change
Expand Up @@ -2687,6 +2687,7 @@ sccp_pbx_cb sccp_pbx = {
set_callerid_redirectedParty: sccp_wrapper_asterisk110_setRedirectedParty,
set_callerid_presence: sccp_wrapper_asterisk110_setCalleridPresence,
set_connected_line: sccp_wrapper_asterisk110_updateConnectedLine,
sendRedirectedUpdate: sccp_wrapper_sendRedirectedUpdate,

/* feature section */
feature_park: sccp_wrapper_asterisk110_park,
Expand Down Expand Up @@ -2802,7 +2803,7 @@ struct sccp_pbx_cb sccp_pbx = {
.set_callerid_redirectedParty = sccp_wrapper_asterisk110_setRedirectedParty,
.set_callerid_presence = sccp_wrapper_asterisk110_setCalleridPresence,
.set_connected_line = sccp_wrapper_asterisk110_updateConnectedLine,

.sendRedirectedUpdate = sccp_wrapper_sendRedirectedUpdate,

/* database */
.feature_addToDatabase = sccp_asterisk_addToDatabase,
Expand Down
10 changes: 7 additions & 3 deletions src/pbx_impl/ast/astTrunk.c
Original file line number Diff line number Diff line change
Expand Up @@ -2035,6 +2035,7 @@ static void sccp_wrapper_asterisk111_updateConnectedLine(const sccp_channel_t *
sccp_log((DEBUGCAT_PBX)) (VERBOSE_PREFIX_3 "SCCP: do connected line for line '%s', name: %s ,num: %s\n", pbx_channel_name(channel->owner), name ? name : "(NULL)", number ? number : "(NULL)");
}

/* // moved to ast.c
static void sccp_wrapper_asterisk111_sendRedirectedUpdate(const sccp_channel_t * channel, const char *fromNumber, const char *fromName, const char *toNumber, const char *toName, uint8_t reason){
struct ast_party_redirecting redirecting;
Expand All @@ -2045,7 +2046,7 @@ static void sccp_wrapper_asterisk111_sendRedirectedUpdate(const sccp_channel_t *
/* update redirecting info line for source part */

This comment has been minimized.

Copy link
@marcelloceschia

marcelloceschia Feb 7, 2013

Collaborator

/* */ ist schon richtig,
// ist zum auskommentieren

// update redirecting info line for source part
if(fromNumber){
update_redirecting.from.number = 1;
redirecting.from.number.valid = 1;
Expand Down Expand Up @@ -2074,6 +2075,7 @@ static void sccp_wrapper_asterisk111_sendRedirectedUpdate(const sccp_channel_t *
ast_channel_queue_redirecting_update(channel->owner, &redirecting, &update_redirecting);
}
*/

static int sccp_wrapper_asterisk111_sched_add(int when, sccp_sched_cb callback, const void *data)
{
Expand Down Expand Up @@ -2696,7 +2698,8 @@ sccp_pbx_cb sccp_pbx = {
set_callerid_redirectedParty: sccp_wrapper_asterisk111_setRedirectedParty,
set_callerid_presence: sccp_wrapper_asterisk111_setCalleridPresence,
set_connected_line: sccp_wrapper_asterisk111_updateConnectedLine,
sendRedirectedUpdate: sccp_wrapper_asterisk111_sendRedirectedUpdate,
// sendRedirectedUpdate: sccp_wrapper_asterisk111_sendRedirectedUpdate,
sendRedirectedUpdate: sccp_wrapper_sendRedirectedUpdate,

/* feature section */
feature_park: sccp_wrapper_asterisk111_park,
Expand Down Expand Up @@ -2812,7 +2815,8 @@ struct sccp_pbx_cb sccp_pbx = {
.set_callerid_redirectedParty = sccp_wrapper_asterisk111_setRedirectedParty,
.set_callerid_presence = sccp_wrapper_asterisk111_setCalleridPresence,
.set_connected_line = sccp_wrapper_asterisk111_updateConnectedLine,
.sendRedirectedUpdate = sccp_wrapper_asterisk111_sendRedirectedUpdate,
// .sendRedirectedUpdate = sccp_wrapper_asterisk111_sendRedirectedUpdate,
.sendRedirectedUpdate = sccp_wrapper_sendRedirectedUpdate,

/* database */
.feature_addToDatabase = sccp_asterisk_addToDatabase,
Expand Down
4 changes: 4 additions & 0 deletions src/pbx_impl/ast/astTrunk.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ char *pbx_getformatname_multiple(char *buf, size_t size, struct ast_format_cap *
# undef pbx_channel_cdr
# undef pbx_channel_call_forward_set
# undef pbx_channel_varshead
# undef pbx_channel_redirecting_effective_from
# undef pbx_channel_redirecting_effective_to

# define pbx_channel_uniqueid(_a) ast_channel_uniqueid(_a)
# define pbx_channel_flags(_a) ast_channel_flags(_a)
Expand Down Expand Up @@ -91,6 +93,8 @@ char *pbx_getformatname_multiple(char *buf, size_t size, struct ast_format_cap *
# define pbx_channel_cdr(_a) ast_channel_cdr(_a)
# define pbx_channel_call_forward_set ast_channel_call_forward_set
# define pbx_channel_varshead(_a) ast_channel_varshead(_a)
# define pbx_channel_redirecting_effective_from(_a) ast_channel_redirecting_effective_from(_a)
# define pbx_channel_redirecting_effective_to(_a) ast_channel_redirecting_effective_to(_a)

int pbx_manager_register(const char *action, int authority, int (*func)(struct mansession *s, const struct message *m), const char *synopsis, const char *description);

Expand Down
4 changes: 4 additions & 0 deletions src/pbx_impl/ast/define.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,5 +316,9 @@ typedef struct ast_event pbx_event_t;
# define pbx_pickup_call ast_pickup_call

# define pbx_bridge_change_state ast_bridge_change_state
#if ASTERISK_VERSION_GROUP > 106
# define pbx_channel_redirecting_effective_from(_a) (_a)->redirecting.from
# define pbx_channel_redirecting_effective_to(_a) (_a)->redirecting.to
#endif

#endif

0 comments on commit 91ea171

Please sign in to comment.