00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include "asterisk.h"
00029
00030 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 56922 $")
00031
00032 #include <stdlib.h>
00033 #include <stdio.h>
00034 #include <string.h>
00035
00036 #include "asterisk/lock.h"
00037 #include "asterisk/file.h"
00038 #include "asterisk/logger.h"
00039 #include "asterisk/options.h"
00040 #include "asterisk/channel.h"
00041 #include "asterisk/pbx.h"
00042 #include "asterisk/module.h"
00043 #include "asterisk/translate.h"
00044 #include "asterisk/image.h"
00045 #include "asterisk/callerid.h"
00046 #include "asterisk/astdb.h"
00047
00048 static char *app = "LookupCIDName";
00049
00050 static char *synopsis = "Look up CallerID Name from local database";
00051
00052 static char *descrip =
00053 " LookupCIDName: Looks up the Caller*ID number on the active\n"
00054 "channel in the Asterisk database (family 'cidname') and sets the\n"
00055 "Caller*ID name. Does nothing if no Caller*ID was received on the\n"
00056 "channel. This is useful if you do not subscribe to Caller*ID\n"
00057 "name delivery, or if you want to change the names on some incoming\n"
00058 "calls.\n\n"
00059 "LookupCIDName is deprecated. Please use ${DB(cidname/${CALLERID(num)})}\n"
00060 "instead.\n";
00061
00062
00063 static int lookupcidname_exec (struct ast_channel *chan, void *data)
00064 {
00065 char dbname[64];
00066 struct ast_module_user *u;
00067 static int dep_warning = 0;
00068
00069 u = ast_module_user_add(chan);
00070 if (!dep_warning) {
00071 dep_warning = 1;
00072 ast_log(LOG_WARNING, "LookupCIDName is deprecated. Please use ${DB(cidname/${CALLERID(num)})} instead.\n");
00073 }
00074 if (chan->cid.cid_num) {
00075 if (!ast_db_get ("cidname", chan->cid.cid_num, dbname, sizeof (dbname))) {
00076 ast_set_callerid (chan, NULL, dbname, NULL);
00077 if (option_verbose > 2)
00078 ast_verbose (VERBOSE_PREFIX_3 "Changed Caller*ID name to %s\n",
00079 dbname);
00080 }
00081 }
00082 ast_module_user_remove(u);
00083
00084 return 0;
00085 }
00086
00087 static int unload_module(void)
00088 {
00089 int res;
00090
00091 res = ast_unregister_application (app);
00092
00093 ast_module_user_hangup_all();
00094
00095 return res;
00096 }
00097
00098 static int load_module(void)
00099 {
00100 return ast_register_application (app, lookupcidname_exec, synopsis, descrip);
00101 }
00102
00103 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Look up CallerID Name from local database");