2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 1999 - 2005, Digium, Inc.
6 * Mark Spencer <markster@digium.com>
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
21 * \brief App to set callerid name from database, based on directory number
23 * \author Mark Spencer <markster@digium.com>
25 * \ingroup applications
30 ASTERISK_FILE_VERSION(__FILE__
, "$Revision$")
36 #include "asterisk/lock.h"
37 #include "asterisk/file.h"
38 #include "asterisk/logger.h"
39 #include "asterisk/options.h"
40 #include "asterisk/channel.h"
41 #include "asterisk/pbx.h"
42 #include "asterisk/module.h"
43 #include "asterisk/translate.h"
44 #include "asterisk/image.h"
45 #include "asterisk/callerid.h"
46 #include "asterisk/astdb.h"
48 static char *app
= "LookupCIDName";
50 static char *synopsis
= "Look up CallerID Name from local database";
52 static char *descrip
=
53 " LookupCIDName: Looks up the Caller*ID number on the active\n"
54 "channel in the Asterisk database (family 'cidname') and sets the\n"
55 "Caller*ID name. Does nothing if no Caller*ID was received on the\n"
56 "channel. This is useful if you do not subscribe to Caller*ID\n"
57 "name delivery, or if you want to change the names on some incoming\n"
59 "LookupCIDName is deprecated. Please use ${DB(cidname/${CALLERID(num)})}\n"
63 static int lookupcidname_exec (struct ast_channel
*chan
, void *data
)
66 struct ast_module_user
*u
;
67 static int dep_warning
= 0;
69 u
= ast_module_user_add(chan
);
72 ast_log(LOG_WARNING
, "LookupCIDName is deprecated. Please use ${DB(cidname/${CALLERID(num)})} instead.\n");
74 if (chan
->cid
.cid_num
) {
75 if (!ast_db_get ("cidname", chan
->cid
.cid_num
, dbname
, sizeof (dbname
))) {
76 ast_set_callerid (chan
, NULL
, dbname
, NULL
);
77 if (option_verbose
> 2)
78 ast_verbose (VERBOSE_PREFIX_3
"Changed Caller*ID name to %s\n",
82 ast_module_user_remove(u
);
87 static int unload_module(void)
91 res
= ast_unregister_application (app
);
93 ast_module_user_hangup_all();
98 static int load_module(void)
100 return ast_register_application (app
, lookupcidname_exec
, synopsis
, descrip
);
103 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY
, "Look up CallerID Name from local database");