return("Gizmo callin for $command->{did} appears to already exist at $command->{prefix}/conf/dialplan/public/01_gizmo-$command->{did}.xml")if(-e"$command->{prefix}/conf/dialplan/public/01_gizmo-$command->{did}.xml");
open(DEFAULT,">$command->{prefix}/conf/dialplan/public/01_gizmo-$command->{did}.xml")||return("Unable to open $command->{prefix}/conf/dialplan/public/01_gizmo-$command->{did}.xml");
return("Gizmo Default callout appears to already exist at $command->{prefix}/conf/dialplan/default/01_gizmo-$command->{username}.xml")if(-e"$command->{prefix}/conf/dialplan/default/01_gizmo-$command->{username}.xml");
open(DEFAULT,">$command->{prefix}/conf/dialplan/default/01_gizmo-$command->{username}.xml")||return("Unable to open $command->{prefix}/conf/dialplan/default/01_gizmo-$command->{username}.xml");
printDEFAULT$template;
close(DEFAULT);
$template=<<"END_O_FILE";
<!-- Gizmo5 default SIP Number -->
<!-- This allows you to route incoming calls from your Gizmo5 account -->
<!-- to extension SIP_LOCALUSER. -->
<!-- You can use more logic to route from here. -->
return("Gizmo Default callin appears to already exist at $command->{prefix}/conf/dialplan/public/01_gizmo-$command->{username}.xml")if(-e"$command->{prefix}/conf/dialplan/public/01_gizmo-$command->{username}.xml");
open(DEFAULT,">>$command->{prefix}/conf/dialplan/public/01_gizmo-$command->{username}.xml")||return("Unable to open $command->{prefix}/conf/dialplan/public/01_gizmo-$command->{username}.xml");
printDEFAULT$template;
close(DEFAULT);
return();
}
sub createGizmo5Gateway($){
my($command)=@_;
my$template=<<"END_O_FILE";
<!-- Gizmo5 SIP Registration -->
<!-- This is required for FreeSWITCH to work with Gizmo5 -->
return"Gizmo Gateway appears to already exist at $command->{prefix}/conf/directory/default/01_gizmo-$command->{username}.xml"if(-e"$command->{prefix}/conf/directory/default/01_gizmo-$command->{username}.xml");
open(GIZMO,">$command->{prefix}/conf/directory/default/01_gizmo-$command->{username}.xml")||return("Unable to open $command->{prefix}/conf/directory/default/01_gizmo-$command->{username}.xml to write");
return("No Local Extension Given")if($command->{action}&&$command->{action}=~/^add/i&&$command->{object}&&$command->{object}=~/^callin/i&&(!defined$command->{extension}||$command->{extension}eq''));
return("DID must be purely numeric")if($command->{action}&&$command->{action}=~/^add/i&&$command->{object}&&$command->{object}=~/^callin/i&&(!defined$command->{did}||$command->{did}!~/^\d+$/));
return("Cannot find FreeSWITCH install at $command->{prefix}")unless(-e"$command->{prefix}/conf"&&-d"$command->{prefix}/conf");
return("Cannot write to FreeSWITCH install at $command->{prefix}")unless(-w"$command->{prefix}/conf");