Index: cdr.c =================================================================== --- cdr.c (Revision 25591) +++ cdr.c (Arbeitskopie) @@ -819,11 +819,13 @@ else cdr->billsec = 0; ast_set_flag(cdr, AST_CDR_FLAG_POSTED); - AST_LIST_LOCK(&be_list); - AST_LIST_TRAVERSE(&be_list, i, list) { - i->be(cdr); + if (!ast_test_flag(cdr,AST_CDR_FLAG_POST_DISABLED)) { + AST_LIST_LOCK(&be_list); + AST_LIST_TRAVERSE(&be_list, i, list) { + i->be(cdr); + } + AST_LIST_UNLOCK(&be_list); } - AST_LIST_UNLOCK(&be_list); cdr = cdr->next; } } Index: apps/app_cdr.c =================================================================== --- apps/app_cdr.c (Revision 25591) +++ apps/app_cdr.c (Arbeitskopie) @@ -54,8 +54,9 @@ LOCAL_USER_ADD(u); if (chan->cdr) { - ast_cdr_free(chan->cdr); - chan->cdr = NULL; + ast_set_flag(chan->cdr,AST_CDR_FLAG_POST_DISABLED); + //ast_cdr_free(chan->cdr); + //chan->cdr = NULL; } LOCAL_USER_REMOVE(u); Index: apps/app_directed_pickup.c =================================================================== --- apps/app_directed_pickup.c (Revision 25591) +++ apps/app_directed_pickup.c (Arbeitskopie) @@ -3,7 +3,7 @@ * * Copyright (C) 2005, Joshua Colp * - * Joshua Colp + * Joshua Colp * * See http://www.asterisk.org for more information about * the Asterisk project. Please do not directly contact @@ -46,8 +46,10 @@ static const char *descrip = " Pickup(extension[@context]): This application can pickup any ringing channel\n" "that is calling the specified extension. If no context is specified, the current\n" -"context will be used.\n"; +"context will be used. If you use the special string \"PICKUPMARK\" for the context parameter, for example 10@PICKUPMARK, this applications tries to find \n" +"a channel which has defined a channel variable with the same content as \"extension\"."; + STANDARD_LOCAL_USER; LOCAL_USER_DECL; @@ -59,6 +61,7 @@ struct ast_channel *origin = NULL, *target = NULL; char *tmp = NULL, *exten = NULL, *context = NULL; char workspace[256] = ""; + char *pickupmark = "PICKUPMARK"; if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "Pickup requires an argument (extension) !\n"); @@ -73,15 +76,32 @@ if (context) { *context = '\0'; context++; + /* Find a special marked channel to pickup */ + if(!strcmp(context,pickupmark)) { + + while ((origin = ast_channel_walk_locked(origin))) { + if (origin) { + tmp=pbx_builtin_getvar_helper(origin, pickupmark); + if (tmp && !strcmp(tmp,exten)) { + ast_log(LOG_DEBUG, "Channel found for Pickup on Extension ['%s'] for channel [%s] State [%d]. Searching corrosponding channel.\n", exten,origin->name,origin->_state); + break; + } + ast_mutex_unlock(&origin->lock); + } + } + } } - + /* Find a channel to pickup */ - origin = ast_get_channel_by_exten_locked(exten, context); + if(!origin) + origin = ast_get_channel_by_exten_locked(exten, context); + if (origin && origin->cdr) { ast_cdr_getvar(origin->cdr, "dstchannel", &tmp, workspace, sizeof(workspace), 0); if (tmp) { /* We have a possible channel... now we need to find it! */ + ast_log(LOG_NOTICE,"Channel found [%s]\n",tmp); target = ast_get_channel_by_name_locked(tmp); } else { ast_log(LOG_DEBUG, "No target channel found.\n"); @@ -96,7 +116,7 @@ if (res) goto out; - + if (target && (!target->pbx) && ((target->_state == AST_STATE_RINGING) || (target->_state == AST_STATE_RING))) { ast_log(LOG_DEBUG, "Call pickup on chan '%s' by '%s'\n", target->name, chan->name);