Skip to content

Instantly share code, notes, and snippets.

@mattvv
Created October 11, 2012 00:04
Show Gist options
  • Save mattvv/3869317 to your computer and use it in GitHub Desktop.
Save mattvv/3869317 to your computer and use it in GitHub Desktop.

Revisions

  1. Matt Van revised this gist Oct 11, 2012. 3 changed files with 71 additions and 35 deletions.
    70 changes: 70 additions & 0 deletions Provisioning\Voip.pm
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,70 @@
    =item B<check_live> { $username, $domain, \%data }
    =back
    =over
    Checks if a certain subscriber is on a call. Returns true if they are and false if they are not.
    =back
    =cut

    sub check_live {
    my $self = shift;
    my $data = shift;

    $self->_require_userdom($data);
    $self->_check_subscriber_data($$data{data});

    my $dispatcher = Sipwise::Provisioning::XMLDispatcher->new;
    my @results = $dispatcher->dispatch("proxy-ng", 1, 1, <<EOF);
    <?xml version="1.0" ?>
    <methodCall>
    <methodName>dlg.list</methodName>
    <params/>
    </methodCall>
    EOF
    my $result = @results[0]->[2];

    my $substring = "$$data{username}\@$$data{domain}";
    if (index($result, $substring) != -1) {
    return "true";
    }
    return "false";
    }



    ... later on

    elsif($function eq 'check_bool'
    or $function eq 'check_username'
    or $function eq 'check_ip'
    or $function eq 'check_ip4'
    or $function eq 'check_ip6'
    or $function eq 'check_ip6_brackets'
    or $function eq 'check_ipnet'
    or $function eq 'check_domain'
    or $function eq 'check_sip_uri'
    or $function eq 'check_sip_uri_pattern'
    or $function eq 'check_sip_uri_prefix'
    or $function eq 'check_sip_username'
    or $function eq 'check_email'
    or $function eq 'check_cc'
    or $function eq 'check_ac'
    or $function eq 'check_sn'
    or $function eq 'check_E164_number'
    or $function eq 'check_E164_shell_pattern'
    or $function eq 'check_sip_username_shell_pattern'
    or $function eq 'check_vsc_format'
    or $function eq 'check_date'
    or $function eq 'check_time'
    or $function eq 'check_timestamp'
    or $function eq 'check_sip_transport_protocol'
    or $function eq 'get_localized_string'
    or $function eq 'check_selected_enum'
    or $function eq 'check_regex_syntax'
    or $function eq 'check_localpart'
    or $function eq 'check_live'
    )
    1 change: 1 addition & 0 deletions XMLRPCVoip.inc.pm
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    sub check_live { typed $Voip->handle_request('check_live', pop) }
    35 changes: 0 additions & 35 deletions gistfile1.pl
    Original file line number Diff line number Diff line change
    @@ -1,35 +0,0 @@
    =item B<check_live> { $username, $domain, \%data }
    =back
    =over
    Checks if a certain subscriber is on a call. Returns true if they are and false if they are not.
    =back
    =cut

    sub check_live {
    my $self = shift;
    my $data = shift;

    $self->_require_userdom($data);
    $self->_check_subscriber_data($$data{data});

    my $dispatcher = Sipwise::Provisioning::XMLDispatcher->new;
    my @results = $dispatcher->dispatch("proxy-ng", 1, 1, <<EOF);
    <?xml version="1.0" ?>
    <methodCall>
    <methodName>dlg.list</methodName>
    <params/>
    </methodCall>
    EOF
    my $result = @results[0]->[2];

    my $substring = "$$data{username}\@$$data{domain}";
    if (index($result, $substring) != -1) {
    return "true";
    }
    return "false";
    }
  2. Matt Van renamed this gist Oct 11, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. Matt Van created this gist Oct 11, 2012.
    35 changes: 35 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    =item B<check_live> { $username, $domain, \%data }

    =back

    =over

    Checks if a certain subscriber is on a call. Returns true if they are and false if they are not.

    =back

    =cut

    sub check_live {
    my $self = shift;
    my $data = shift;

    $self->_require_userdom($data);
    $self->_check_subscriber_data($$data{data});

    my $dispatcher = Sipwise::Provisioning::XMLDispatcher->new;
    my @results = $dispatcher->dispatch("proxy-ng", 1, 1, <<EOF);
    <?xml version="1.0" ?>
    <methodCall>
    <methodName>dlg.list</methodName>
    <params/>
    </methodCall>
    EOF
    my $result = @results[0]->[2];

    my $substring = "$$data{username}\@$$data{domain}";
    if (index($result, $substring) != -1) {
    return "true";
    }
    return "false";
    }