diff options
author | matteo <matteo@f38db490-d61c-443f-a65b-d21fe96a405b> | 2003-03-05 06:00:17 +0000 |
---|---|---|
committer | matteo <matteo@f38db490-d61c-443f-a65b-d21fe96a405b> | 2003-03-05 06:00:17 +0000 |
commit | bd3b51afcb0f8c24bd6ae75e54ed9d8256c54cc3 (patch) | |
tree | caaa4e4517c1c1071754a4afdabb3b1f7c3e9323 /apps | |
parent | 91371ff934f1b3a9bcc3b5a4555143faefa53a70 (diff) |
Wed Mar 5 07:00:00 CET 2003
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@632 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rwxr-xr-x | apps/app_dial.c | 2 | ||||
-rwxr-xr-x | apps/app_lookupblacklist.c | 92 | ||||
-rwxr-xr-x | apps/app_voicemail.c | 88 |
3 files changed, 128 insertions, 54 deletions
diff --git a/apps/app_dial.c b/apps/app_dial.c index 754895f4d..cd26974fd 100755 --- a/apps/app_dial.c +++ b/apps/app_dial.c @@ -120,7 +120,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu int ringind=0; struct ast_channel *winner; - single = (outgoing && !outgoing->next); + single = (outgoing && !outgoing->next && !outgoing->musiconhold && !outgoing->ringbackonly); if (single) { /* If we are calling a single channel, make them compatible for in-band tone purpose */ diff --git a/apps/app_lookupblacklist.c b/apps/app_lookupblacklist.c index d82a950f2..9cc9e1e64 100755 --- a/apps/app_lookupblacklist.c +++ b/apps/app_lookupblacklist.c @@ -38,7 +38,8 @@ static char *descrip = "where 'n' is the priority of the current instance, then the\n" "channel will be setup to continue at that priority level.\n" "Otherwise, it returns 0. Does nothing if no Caller*ID was received on the\n" - "channel.\n"; + "channel.\n" + "Example: database put blacklist <name/number> 1\n"; STANDARD_LOCAL_USER; @@ -47,66 +48,67 @@ LOCAL_USER_DECL; static int lookupblacklist_exec (struct ast_channel *chan, void *data) { - char old_cid[144] = "", *num, *name; - char blacklist[1]; - char shrunknum[64] = ""; - struct localuser *u; - int bl = 0; + char old_cid[144] = "", *num, *name; + char blacklist[1]; + char shrunknum[64] = ""; + struct localuser *u; + int bl = 0; - LOCAL_USER_ADD (u); - if (chan->callerid) - { - strncpy (old_cid, chan->callerid, sizeof (old_cid) - 1); - ast_callerid_parse (old_cid, &name, &num); /* this destroys the original string */ - if (num) /* It's possible to get an empty number */ - strncpy (shrunknum, num, sizeof (shrunknum) - 1); - else - num = shrunknum; - ast_shrink_phone_number (shrunknum); - if (!ast_db_get ("blacklist", shrunknum, blacklist, sizeof (blacklist))) + LOCAL_USER_ADD (u); + if (chan->callerid) { - if (option_verbose > 2) - ast_verbose (VERBOSE_PREFIX_3 "Blacklisted number %s found\n",shrunknum); - bl = 1; + strncpy (old_cid, chan->callerid, sizeof (old_cid) - 1); + ast_callerid_parse (old_cid, &name, &num); + if (num) + strncpy (shrunknum, num, sizeof (shrunknum) - 1); + else + num = shrunknum; + + ast_shrink_phone_number (shrunknum); + if (!ast_db_get ("blacklist", shrunknum, blacklist, sizeof (blacklist))) + { + if (option_verbose > 2) + ast_verbose (VERBOSE_PREFIX_3 "Blacklisted number %s found\n",shrunknum); + bl = 1; + } + else if (!ast_db_get ("blacklist", name, blacklist, sizeof (blacklist))) + { + if (option_verbose > 2) + ast_verbose (VERBOSE_PREFIX_3 "Blacklisted name \"%s\" found\n",name); + bl = 1; + } } - - } - if (bl && ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->callerid)) - chan->priority+=100; - LOCAL_USER_REMOVE (u); - return 0; + + if (bl && ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->callerid)) + chan->priority+=100; + LOCAL_USER_REMOVE (u); + return 0; } -int -unload_module (void) +int unload_module (void) { - STANDARD_HANGUP_LOCALUSERS; - return ast_unregister_application (app); + STANDARD_HANGUP_LOCALUSERS; + return ast_unregister_application (app); } -int -load_module (void) +int load_module (void) { - return ast_register_application (app, lookupblacklist_exec, synopsis, - descrip); + return ast_register_application (app, lookupblacklist_exec, synopsis,descrip); } -char * -description (void) +char *description (void) { - return tdesc; + return tdesc; } -int -usecount (void) +int usecount (void) { - int res; - STANDARD_USECOUNT (res); - return res; + int res; + STANDARD_USECOUNT (res); + return res; } -char * -key () +char *key () { - return ASTERISK_GPL_KEY; + return ASTERISK_GPL_KEY; } diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 3ea6cff46..4af888f1f 100755 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -564,9 +564,10 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, int silent, int get_date(date, sizeof(date)); time(&start); fprintf(txt, -"#\n" -"# Message Information file\n" -"#\n" +";\n" +"; Message Information file\n" +";\n" +"[message]\n" "origmailbox=%s\n" "context=%s\n" "exten=%s\n" @@ -992,6 +993,11 @@ static int adsi_load_vmail(struct ast_channel *chan, int *useadsi) static void adsi_begin(struct ast_channel *chan, int *useadsi) { int x; + if(!strcasecmp(chan->type, "sip")){ + *useadsi = 0; + return; + } + x = adsi_load_session(chan, adapp, adver, 1); if (x < 0) return; @@ -1303,6 +1309,9 @@ static void adsi_goodbye(struct ast_channel *chan) { char buf[256]; int bytes=0; + if(!strcasecmp(chan->type, "sip")){ + return; + } if (!adsi_available(chan)) return; bytes += adsi_logo(buf + bytes); @@ -1345,13 +1354,19 @@ static int get_folder(struct ast_channel *chan, int start) } static int -forward_message(struct ast_channel *chan, struct ast_config *cfg, char *dir, int curmsg) +forward_message(struct ast_channel *chan, struct ast_config *cfg, char *dir, int curmsg, char* myusername) { char username[70]; char sys[256]; char todir[256]; int todircount=0; - + struct ast_config *mif; + char miffile[256]; + char *copy, *name, *passwd, *email; + char *mycopy, *myname, *mypasswd, *myemail; + char fn[256]; + char callerid[512]; + while(1) { ast_streamfile(chan, "vm-extension", chan->language); @@ -1359,8 +1374,9 @@ forward_message(struct ast_channel *chan, struct ast_config *cfg, char *dir, int return 0; if (ast_variable_retrieve(cfg, NULL, username)) { printf("Got %d\n", atoi(username)); - if (play_and_wait(chan, "vm-savedto")) + /* if (play_and_wait(chan, "vm-savedto")) break; + */ snprintf(todir, sizeof(todir), "%s/%s/%s/INBOX", (char *)ast_config_AST_SPOOL_DIR,"vm", username); snprintf(sys, sizeof(sys), "mkdir -p %s\n", todir); @@ -1373,13 +1389,69 @@ forward_message(struct ast_channel *chan, struct ast_config *cfg, char *dir, int puts(sys); system(sys); + /* TODO: use config to determine what other formats to copy the message in */ + snprintf(sys, sizeof(sys), "cp %s/msg%04d.wav %s/msg%04d.wav\n", dir, curmsg, todir, todircount); + puts(sys); + system(sys); + + /* copy the message information file too */ + snprintf(sys, sizeof(sys), "cp %s/msg%04d.txt %s/msg%04d.txt\n", dir, curmsg, todir, todircount); + puts(sys); + system(sys); + + snprintf(fn, sizeof(fn), "%s/msg%04d", todir,todircount); + + /* load the information on the source message so we can send an e-mail like a new message */ + snprintf(miffile, sizeof(miffile), "%s/msg%04d.txt", dir, curmsg); + if ((mif=ast_load(miffile))) { + + /* send an e-mail like it was a new message if appropriate */ + if ((copy = ast_variable_retrieve(cfg, NULL, username))) { + char *stringp=NULL; + /* Make sure they have an entry in the config */ + copy = strdup(copy); + stringp=copy; + passwd = strsep(&stringp, ","); + name = strsep(&stringp, ","); + email = strsep(&stringp, ","); + } + + if ((mycopy = ast_variable_retrieve(cfg, NULL, myusername))) { + char *mystringp=NULL; + /* Make sure they have an entry in the config */ + mycopy = strdup(mycopy); + mystringp=mycopy; + mypasswd = strsep(&mystringp, ","); + myname = strsep(&mystringp, ","); + myemail = strsep(&mystringp, ","); + } + + if (email) { + snprintf(callerid, sizeof(callerid), "FWD from: %s from %s", myname, ast_variable_retrieve(mif, NULL, "callerid")); + sendmail(ast_variable_retrieve(cfg, "general", "serveremail"), + email, name, todircount, username, + callerid, + fn, + "wav", + atol(ast_variable_retrieve(mif, NULL, "duration")) + ); + } + + free(copy); /* no leaks here */ + free(mycopy); /* or here */ + ast_destroy(mif); /* or here */ + } + + /* give confirmatopm that the message was saved */ + if (play_and_wait(chan, "vm-message")) break; + if (play_and_wait(chan, "vm-saved")) break; + break; } else { if ( play_and_wait(chan, "pbx-invalid")) break; } } - return 0; } @@ -1920,7 +1992,7 @@ cmd: goto instructions; case '8': if(lastmsg > -1) - if(forward_message(chan, cfg, curdir, curmsg) < 0) + if(forward_message(chan, cfg, curdir, curmsg, username) < 0) goto out; goto instructions; case '9': |