2 # $Id: Alias.pm 757 2007-01-05 10:56:28Z bastian $
4 # Perl module for Kamailio
6 # Copyright (C) 2007 Collax GmbH
7 # (Bastian Friedrich <bastian.friedrich@collax.com>)
9 # This file is part of Kamailio, a free SIP server.
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
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.
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
26 =head1 Kamailio::VDB::Adapter::Alias
28 This package is intended for usage with the alias_db module. The query VTab
29 has to take two arguments and return an array of two arguments (user name/domain).
33 package Kamailio::VDB::Adapter::Alias;
35 use Kamailio::Constants;
36 use Kamailio qw ( log );
39 use Kamailio::VDB::Column;
40 use Kamailio::VDB::Result;
44 our @ISA = qw ( Kamailio::VDB );
46 =head2 query(conds,retkeys,order)
48 Queries the vtab with the given arguments for
49 request conditions, keys to return and sort order column name.
57 my $retkeys = shift; # Unused value here.
58 my $order = shift; # Unused value here.
62 my $alias_username = undef;
63 my $alias_domain = undef;
68 if (($c->key() eq "alias_username") && ($c->op() eq "=")) {
69 $alias_username = $c->data();
71 if (($c->key() eq "alias_domain") && ($c->op() eq "=")) {
72 $alias_domain = $c->data();
76 my $vtab = $self->{vtabs}->{$self->{tablename}};
77 $newaddr = $vtab->call("query", $alias_username, $alias_domain);
81 push @cols, new Kamailio::VDB::Column(DB_STRING, "username");
82 push @cols, new Kamailio::VDB::Column(DB_STRING, "domain");
86 my $resval1 = new Kamailio::VDB::Value(DB_STRING, $newaddr->{username} );
88 my $resval2 = new Kamailio::VDB::Value(DB_STRING, $newaddr->{domain} );
90 $result = new Kamailio::VDB::Result(\@cols, (bless \@row, "Kamailio::Utils::Debug"));
92 $result = new Kamailio::VDB::Result(\@cols);