~ubuntu-branches/ubuntu/karmic/asterisk/karmic

« back to all changes in this revision

Viewing changes to apps/app_voicemail.c

  • Committer: Bazaar Package Importer
  • Author(s): Faidon Liambotis, Tzafrir Cohen, Faidon Liambotis
  • Date: 2007-12-06 17:20:21 UTC
  • mfrom: (1.1.19 upstream)
  • Revision ID: james.westby@ubuntu.com-20071206172021-pd0wrjirz3os7hia
Tags: 1:1.4.15~dfsg-1
* New upstream release (Closes: #452054)
  - Fix a potential corrupt of voicemail.conf on simultaneous PIN updates
    (Closes: #353227)

[ Tzafrir Cohen ]
* Add some sample/reference config files as documentation.
* Provide asterisk-bristuff for upgrading from Etch.
* Move libc-client to not be last, so debian/backports/xorcom.etch would
  still work.

[ Faidon Liambotis ]
* Really enable the libcap/ToS functionality; the previous patch didn't
  enable the functionality, even though the code and the libcap.so
  dependency were there. (Closes: #454342)
* Fix a minor issue with init script's stop target when running with
  safe_asterisk.
* Add chan_vpb, adding support for VoiceTronix OpenSwitch and OpenLine
  cards. (Closes: #396499)
* Fix debian/watch by using a pkg-voip wrapper to avoid upstream's silly
  redirections. (Closes: #449706)
* Use DEBVERSION as asterisk's version string.
* Disable the MD5 build sum that breaks all out-of-tree plugins (duh!).
* Create /usr/local/share/asterisk/sounds to put all site-specific
  non-modifiable sounds.
* Add a note about bugs.debian.org to the banner.
* Add noload for res_config_* since loading them results in errors and
  doesn't provide any functionality.
* News entries were added but we never shipped the file; ship NEWS.Debian.
* Add an entry to NEWS.Debian warning users about app_voicemail_*.so
  (Closes: #452596)
* Provide options in /etc/default/asterisk for configuring safe_asterisk.
  (Closes: #381786)

[ Tzafrir Cohen ]
* Provide a custom sounds directory under /var/lib - user-modifieble at
  runtime and hence not under /usr. (Closes: #337209)

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
 
53
53
#include "asterisk.h"
54
54
 
55
 
ASTERISK_FILE_VERSION(__FILE__, "$Revision: 85276 $")
 
55
ASTERISK_FILE_VERSION(__FILE__, "$Revision: 89999 $")
56
56
 
57
57
#include <stdlib.h>
58
58
#include <errno.h>
108
108
static char authpassword[42];
109
109
 
110
110
static int expungeonhangup = 1;
111
 
AST_MUTEX_DEFINE_STATIC(delimiter_lock);
112
111
static char delimiter = '\0';
113
112
 
114
113
struct vm_state;
2309
2308
        char tmp[80] = "/tmp/astmail-XXXXXX";
2310
2309
        long len;
2311
2310
        void *buf;
 
2311
        int tempcopy = 0;
2312
2312
        STRING str;
 
2313
 
 
2314
        /*Greetings are not retrieved from IMAP, so there is no reason to attempt storing them there either*/
 
2315
        if(msgnum < 0)
 
2316
                return 0;
2313
2317
        
2314
2318
        /* Attach only the first format */
2315
2319
        fmt = ast_strdupa(fmt);
2321
2325
 
2322
2326
        make_file(fn, sizeof(fn), dir, msgnum);
2323
2327
 
2324
 
        if (ast_strlen_zero(vmu->email))
 
2328
        if (ast_strlen_zero(vmu->email)) {
 
2329
                /*we need the vmu->email to be set when we call make_email_file, but if we keep it set,
 
2330
                 * a duplicate e-mail will be created. So at the end of this function, we will revert back to an empty
 
2331
                 * string if tempcopy is 1
 
2332
                 */
2325
2333
                ast_copy_string(vmu->email, vmu->imapuser, sizeof(vmu->email));
 
2334
                tempcopy = 1;
 
2335
        }
2326
2336
 
2327
2337
        if (!strcmp(fmt, "wav49"))
2328
2338
                fmt = "WAV";
2332
2342
           command hangs */
2333
2343
        if ((p = vm_mkftemp(tmp)) == NULL) {
2334
2344
                ast_log(LOG_WARNING, "Unable to store '%s' (can't create temporary file)\n", fn);
 
2345
                if(tempcopy)
 
2346
                        *(vmu->email) = '\0';
2335
2347
                return -1;
2336
2348
        } else {
2337
2349
                make_email_file(p, myserveremail, vmu, msgnum, vmu->context, vmu->mailbox, S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL), fn, fmt, duration, 1, chan, NULL, 1);
2355
2367
                if(option_debug > 2)
2356
2368
                        ast_log(LOG_DEBUG, "%s stored\n", fn);
2357
2369
        }
 
2370
        if(tempcopy)
 
2371
                *(vmu->email) = '\0';
2358
2372
        return 0;
2359
2373
 
2360
2374
}
4612
4626
        if (!res) {
4613
4627
                make_file(vms->fn, sizeof(vms->fn), vms->curdir, vms->curmsg);
4614
4628
                vms->heard[vms->curmsg] = 1;
4615
 
                res = wait_file(chan, vms, vms->fn);
 
4629
                if ((res = wait_file(chan, vms, vms->fn)) < 0) {
 
4630
                        ast_log(LOG_WARNING, "Playback of message %s failed\n", vms->fn);
 
4631
                        res = 0;
 
4632
                }
4616
4633
        }
4617
4634
        DISPOSE(vms->curdir, vms->curmsg);
4618
4635
        return res;
4678
4695
                char *cp;
4679
4696
#include "linkage.c"
4680
4697
                /* Connect to INBOX first to get folders delimiter */
4681
 
                imap_mailbox_name(tmp, sizeof(tmp), vms, 0, 0);
 
4698
                imap_mailbox_name(tmp, sizeof(tmp), vms, 0, 1);
4682
4699
                stream = mail_open (stream, tmp, debug ? OP_DEBUG : NIL);
4683
4700
                if (stream == NIL) {
4684
4701
                        ast_log (LOG_ERROR, "Can't connect to imap server %s\n", tmp);
4718
4735
                return -1;
4719
4736
        }
4720
4737
 
4721
 
        /* Check Quota (here for now to test) */
4722
 
        mail_parameters(NULL, SET_QUOTA, (void *) mm_parsequota);
4723
 
        imap_mailbox_name(dbox, sizeof(dbox), vms, box, 1);
4724
 
        imap_getquotaroot(vms->mailstream, dbox);
4725
 
 
4726
4738
        pgm = mail_newsearchpgm();
4727
4739
 
4728
4740
        /* Check IMAP folder for Asterisk messages only... */
8549
8561
void mm_list(MAILSTREAM * stream, int delim, char *mailbox, long attributes)
8550
8562
{
8551
8563
        if (delimiter == '\0') {
8552
 
                ast_mutex_lock(&delimiter_lock);
8553
8564
                delimiter = delim;
8554
 
                ast_mutex_unlock(&delimiter_lock);
8555
8565
        }
8556
8566
        if (option_debug > 4) {
8557
8567
                ast_log(LOG_DEBUG, "Delimiter set to %c and mailbox %s\n",delim, mailbox);
8723
8733
        ast_mutex_lock(&imaptemp_lock);
8724
8734
        ast_copy_string(imaptemp, start+taglen, sizeof(imaptemp));
8725
8735
        ast_mutex_unlock(&imaptemp_lock);
8726
 
        eol_pnt = strchr(imaptemp,'\n');
8727
 
        *eol_pnt = '\0';
 
8736
        if ((eol_pnt = strchr(imaptemp,'\r')) || (eol_pnt = strchr(imaptemp,'\n')))
 
8737
                *eol_pnt = '\0';
8728
8738
        return imaptemp;
8729
8739
}
8730
8740