Version 0.1.8 from FTP
[asterisk/asterisk.git] / apps / app_directory.c
index f7ec414..551f61f 100755 (executable)
@@ -3,7 +3,7 @@
  *
  * Provide a directory of extensions
  * 
- * Copyright (C) 1999, Adtran Inc. and Linux Support Services, LLC
+ * Copyright (C) 1999, Mark Spencer
  *
  * Mark Spencer <markster@linux-support.net>
  *
 static char *tdesc = "Extension Directory";
 static char *app = "Directory";
 
+static char *synopsis = "Provide directory of voicemail extensions";
+static char *descrip =
+"  Directory(context): Presents the user with a directory of extensions from which\n"
+"  they may select by name.  The list of names and extensions is discovered from\n"
+"  voicemail.conf.  The context argument is required, and specifies the context\n"
+"  in which to interpret the extensions\n.  Returns 0 unless the user hangs up.  It\n"
+"  also sets up the channel on exit to enter the extension the user selected.\n";
+
 /* For simplicity, I'm keeping the format compatible with the voicemail config,
    but i'm open to suggestions for isolating it */
 
@@ -156,17 +164,17 @@ static int do_directory(struct ast_channel *chan, struct ast_config *cfg, char *
                        if (v) {
                                /* We have a match -- play a greeting if they have it */
                                snprintf(fn, sizeof(fn), "%s/vm/%s/greet", AST_SPOOL_DIR, v->name);
-                               if (ast_fileexists(fn, NULL)) {
-                                       res = ast_streamfile(chan, fn);
+                               if (ast_fileexists(fn, NULL, chan->language)) {
+                                       res = ast_streamfile(chan, fn, chan->language);
                                        if (!res)
                                                res = ast_waitstream(chan, AST_DIGIT_ANY);
                                        ast_stopstream(chan);
                                } else {
-                                       res = ast_say_digit_str(chan, v->name);
+                                       res = ast_say_digit_str(chan, v->name, chan->language);
                                }
 ahem:
                                if (!res)
-                                       res = ast_streamfile(chan, "dir-instr");
+                                       res = ast_streamfile(chan, "dir-instr", chan->language);
                                if (!res)
                                        res = ast_waitstream(chan, AST_DIGIT_ANY);
                                if (!res)
@@ -189,9 +197,9 @@ ahem:
                                }
                        } else {
                                if (found) 
-                                       res = ast_streamfile(chan, "dir-nomore");
+                                       res = ast_streamfile(chan, "dir-nomore", chan->language);
                                else
-                                       res = ast_streamfile(chan, "dir-nomatch");
+                                       res = ast_streamfile(chan, "dir-nomatch", chan->language);
                                if (!res)
                                        res = 1;
                                return res;
@@ -219,7 +227,7 @@ static int directory_exec(struct ast_channel *chan, void *data)
        LOCAL_USER_ADD(u);
 top:
        if (!res)
-               res = ast_streamfile(chan, "dir-intro");
+               res = ast_streamfile(chan, "dir-intro", chan->language);
        if (!res)
                res = ast_waitstream(chan, AST_DIGIT_ANY);
        ast_stopstream(chan);
@@ -248,7 +256,7 @@ int unload_module(void)
 
 int load_module(void)
 {
-       return ast_register_application(app, directory_exec);
+       return ast_register_application(app, directory_exec, synopsis, descrip);
 }
 
 char *description(void)
@@ -262,3 +270,8 @@ int usecount(void)
        STANDARD_USECOUNT(res);
        return res;
 }
+
+char *key()
+{
+       return ASTERISK_GPL_KEY;
+}