Debian Codegraph @

src/modules/app_perl/lib/perl/Kamailio/VDB/Adapter/Speeddial.pm

raw
1 #
2 # $Id: Speeddial.pm 757 2007-01-05 10:56:28Z bastian $
3 #
4 # Perl module for Kamailio
5 #
6 # Copyright (C) 2007 Collax GmbH
7 # (Bastian Friedrich <[email protected]>)
8 #
9 # This file is part of Kamailio, a free SIP server.
10 #
11 # Kamailio is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version
15 #
16 # Kamailio is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 #
25
26 =head1 Kamailio::VDB::Adapter::Speeddial
27
28 This adapter can be used with the speeddial module.
29
30 =cut
31
32 package Kamailio::VDB::Adapter::Speeddial;
33
34 use Kamailio::Constants;
35 use Kamailio qw ( log );
36
37 use Kamailio::VDB;
38 use Kamailio::VDB::Column;
39 use Kamailio::VDB::Result;
40
41 our @ISA = qw ( Kamailio::VDB );
42
43 sub query {
44 my $self = shift;
45
46 my $conds = shift;
47 my $retkeys = shift; # Unused value here.
48 my $order = shift; # Unused value here.
49
50 my @cols;
51
52 my $requested_username;
53 my $requested_sd_username;
54
55 for my $c (@$conds) {
56 if (($c->key() eq "username") && ($c->op() eq "=")) {
57 $requested_username = $c->data();
58 }
59 if (($c->key() eq "sd_username") && ($c->op() eq "=")) {
60 $requested_sd_username = $c->data();
61 }
62 }
63
64 my $vtab = $self->{vtabs}->{$self->{tablename}};
65 $newaddr = $vtab->call("query", $requested_username, $requested_sd_username);
66
67 my $result;
68
69 push @cols, new Kamailio::VDB::Column(DB_STRING, "uid_name");
70
71 if ($newaddr) {
72 my $resval = new Kamailio::VDB::Value(DB_STRING, $newaddr );
73 push my @row, $resval;
74 $result = new Kamailio::VDB::Result(\@cols, (bless \@row, "Kamailio::Utils::Debug"));
75 } else {
76 $result = new Kamailio::VDB::Result(\@cols);
77 }
78
79 return $result;
80 }
81
82 1;