Zap carriers, EXTERNAL extensions and directory cmd

Discussions about development of VICIDIAL and astGUIclient

Moderators: gerski, enjay, williamconley, Op3r, Staydog, gardo, mflorell, MJCoate, mcargile, Kumba, Michael_N

Zap carriers, EXTERNAL extensions and directory cmd

Postby bobchaos » Fri Jul 12, 2013 4:33 pm

A few months back I posted a patch that made the directory command work when Vicidial is also being used as a primary PBX. Following up on client requests, I have added the ability to dial EXTERNAL phones directly from the directory (or anywhere really) even if you are not logged into Vicidial. I corrected a glitch that caused EXTERNAL phones to generate voicemail entries with the wrong $fullname (it was being loaded from the SIP phone array instead of being reloaded for other phones). Incidentally I also added support for ZAP carrier entries, they now write to extensions-vicidial.conf.

That being said it all feels a bit limited as it was designed in a specific context (getting the directory to dial EXTERNAL phone entries) and (I may have said this before XD ) I'm not much of a programmer. It's tested and functional but I was still hoping some of you could look at this code and see if it's worth integrating to the trunk.

--- /usr/src/astguiclient/trunk/bin/ADMIN_keepalive_ALL.pl 2013-05-06 12:50:22.044552366 -0400
+++ ADMIN_keepalive_ALL.pl.latest 2013-07-12 16:57:40.306410509 -0400
@@ -1857,7 +1857,38 @@

$i++;
}
- ##### BEGIN Generate the SIP carriers for this server_ip #####
+ ##### END Generate the SIP carriers for this server_ip #####
+
+ ##### BEGIN Generate the ZAP/DAHDI carriers for this server_ip #####
+ $stmtA = "SELECT carrier_id,carrier_name,globals_string,dialplan_entry,carrier_description FROM vicidial_server_carriers where server_ip='$server_ip' and active='Y' and protocol='Zap' order by carrier_id;";
+ $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
+ $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
+ $sthArows=$sthA->rows;
+ $i=0;
+ while ($sthArows > $i)
+ {
+ @aryA = $sthA->fetchrow_array;
+ $carrier_id[$i] = $aryA[0];
+ $carrier_name[$i] = $aryA[1];
+ $globals_string[$i] = $aryA[2];
+ $dialplan_entry[$i] = $aryA[3];
+ $carrier_description[$i] = $aryA[4];
+ $i++;
+ }
+ $sthA->finish();
+
+ $i=0;
+ while ($sthArows > $i)
+ {
+ $ext .= "$globals_string[$i]\n";
+
+ $Lext .= "; VICIDIAL Carrier: $carrier_id[$i] - $carrier_name[$i]\n";
+ if (length($carrier_description[$i]) > 0) {$Lext .= "; $carrier_description[$i]\n";}
+ $Lext .= "$dialplan_entry[$i]\n";
+
+ $i++;
+ }
+ ##### END Generate the ZAP/DAHDI carriers for this server_ip #####


$Pext .= "\n";
@@ -1987,9 +2018,9 @@
}

if ($delete_vm_after_email[$i] =~ /Y/)
- {$vm .= "$voicemail[$i] => $pass[$i],$extension[$i] Mailbox,$email[$i],,|delete=yes|tz=$voicemail_timezone[$i]|$voicemail_options[$i]\n";}
+ {$vm .= "$voicemail[$i] => $pass[$i],$fullname[$i],$email[$i],,|delete=yes|tz=$voicemail_timezone[$i]|$voicemail_options[$i]\n";}
else
- {$vm .= "$voicemail[$i] => $pass[$i],$extension[$i] Mailbox,$email[$i],,|delete=no|tz=$voicemail_timezone[$i]|$voicemail_options[$i]\n";}
+ {$vm .= "$voicemail[$i] => $pass[$i],$fullname[$i],$email[$i],,|delete=no|tz=$voicemail_timezone[$i]|$voicemail_options[$i]\n";}

$i++;
}
@@ -2118,15 +2149,63 @@
}

if ($delete_vm_after_email[$i] =~ /Y/)
- {$vm .= "$voicemail[$i] => $pass[$i],$extension[$i] Mailbox,$email[$i],,|delete=yes|tz=$voicemail_timezone[$i]|$voicemail_options[$i]\n";}
+ {$vm .= "$voicemail[$i] => $pass[$i],$fullname[$i],$email[$i],,|delete=yes|tz=$voicemail_timezone[$i]|$voicemail_options[$i]\n";}
else
- {$vm .= "$voicemail[$i] => $pass[$i],$extension[$i] Mailbox,$email[$i],,|delete=no|tz=$voicemail_timezone[$i]|$voicemail_options[$i]\n";}
+ {$vm .= "$voicemail[$i] => $pass[$i],$fullname[$i],$email[$i],,|delete=no|tz=$voicemail_timezone[$i]|$voicemail_options[$i]\n";}

$i++;
}
##### END Generate the SIP phone entries #####

-
+ ##### BEGIN Generate the EXTERNAL phone entries #####
+ $stmtA = "SELECT extension,dialplan_number,voicemail_id,pass,email,outbound_cid,fullname,phone_ring_timeout,delete_vm_after_email,voicemail_timezone,voicemail_options FROM phones where server_ip='$server_ip' and protocol='EXTERNAL' and active='Y' order by extension;";
+ # print "$stmtA\n";
+ $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
+ $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
+ $sthArows=$sthA->rows;
+ $i=0;
+ while ($sthArows > $i)
+ {
+ @aryA = $sthA->fetchrow_array;
+ $extension[$i] = $aryA[0];
+ $dialplan[$i] = $aryA[1];
+ $voicemail[$i] = $aryA[2];
+ $pass[$i] = $aryA[3];
+ $email[$i] = $aryA[4];
+ $outbound_cid[$i] = $aryA[5];
+ $fullname[$i] = $aryA[6];
+ $phone_ring_timeout[$i] = $aryA[7];
+ $delete_vm_after_email[$i] = $aryA[8];
+ $codecs_list[$i] = $aryA[9];
+ $voicemail_timezone[$i] = $aryA[10];
+ $voicemail_options[$i] = $aryA[11];
+ $active_dialplan_numbers .= "'$aryA[1]',";
+
+ $i++;
+ }
+ $sthA->finish();
+
+ $i=0;
+ while ($sthArows > $i)
+ {
+ %ast_ver_str = parse_asterisk_version($asterisk_version);
+ if (( $ast_ver_str{major} = 1 ) && ($ast_ver_str{minor} < 6))
+ {
+ $Pext .= "exten => $extension[$i],1,Goto(default|$dialplan[$i]|1)\n";
+ }
+ else
+ {
+ $Pext .= "exten => $extension[$i],1,Goto(default,$dialplan[$i],1)\n";
+ }
+ $Pext .= "exten => $extension[$i],2,Goto(default,85026666666666$voicemail[$i],1)\n";
+ if (!(( $ast_ver_str{major} = 1 ) && ($ast_ver_str{minor} < 6)))
+ {
+ $Pext .= "exten => $extension[$i],3,Hangup()\n";
+ }
+
+ $i++;
+ }
+ ##### END Generate the EXTERNAL phone entries #####

if ( ($SSgenerate_cross_server_exten > 0) and (length($active_server_ips) > 7) )
{
@@ -2672,7 +2751,7 @@
while ($sthArows > $i)
{
##### Get the distinct phone entries #####
- $stmtA = "SELECT extension,pass,email,delete_vm_after_email,voicemail_timezone,voicemail_options FROM phones where active='Y' and voicemail_id='$voicemail[$i]';";
+ $stmtA = "SELECT extension,pass,fullname,email,delete_vm_after_email,voicemail_timezone,voicemail_options FROM phones where active='Y' and voicemail_id='$voicemail[$i]';";
# print "$stmtA\n";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
@@ -2682,15 +2761,16 @@
@aryA = $sthA->fetchrow_array;
$extension[$i] = $aryA[0];
$pass[$i] = $aryA[1];
- $email[$i] = $aryA[2];
- $delete_vm_after_email[$i] = $aryA[3];
- $voicemail_timezone[$i] = $aryA[4];
- $voicemail_options[$i] = $aryA[5];
+ $fullname[$i] = $aryA[2];
+ $email[$i] = $aryA[3];
+ $delete_vm_after_email[$i] = $aryA[4];
+ $voicemail_timezone[$i] = $aryA[5];
+ $voicemail_options[$i] = $aryA[6];

if ($delete_vm_after_email[$i] =~ /Y/)
- {$vm .= "$voicemail[$i] => $pass[$i],$extension[$i] Mailbox,$email[$i],,|delete=yes|tz=$voicemail_timezone[$i]|$voicemail_options[$i]\n";}
+ {$vm .= "$voicemail[$i] => $pass[$i],$fullname[$i],$email[$i],,|delete=yes|tz=$voicemail_timezone[$i]|$voicemail_options[$i]\n";}
else
- {$vm .= "$voicemail[$i] => $pass[$i],$extension[$i] Mailbox,$email[$i],,|delete=no|tz=$voicemail_timezone[$i]|$voicemail_options[$i]\n";}
+ {$vm .= "$voicemail[$i] => $pass[$i],$fullname[$i],$email[$i],,|delete=no|tz=$voicemail_timezone[$i]|$voicemail_options[$i]\n";}
}
$sthA->finish();
bobchaos
 
Posts: 171
Joined: Fri Jan 06, 2012 12:46 pm

Re: Zap carriers, EXTERNAL extensions and directory cmd

Postby mflorell » Sun Jul 14, 2013 6:45 am

Please post a "diff -u" file to the Issue Tracker under a new ticket and post a link to the ticket here.
mflorell
Site Admin
 
Posts: 18386
Joined: Wed Jun 07, 2006 2:45 pm
Location: Florida

Re: Zap carriers, EXTERNAL extensions and directory cmd

Postby bobchaos » Mon Jul 15, 2013 1:03 am

Will do, once I fix an issue I found with my code: Any new contexts created in ZAP Carrier entries do not work as they are not linked to the default context. It's an easy manual fix but I'll try to work in an automated one and the post the code.
bobchaos
 
Posts: 171
Joined: Fri Jan 06, 2012 12:46 pm


Return to Development

Who is online

Users browsing this forum: No registered users and 21 guests