~ubuntu-branches/ubuntu/raring/lurker/raring

« back to all changes in this revision

Viewing changes to render/mbox.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Meurer
  • Date: 2006-12-20 05:05:31 UTC
  • mfrom: (3.1.6 feisty)
  • Revision ID: james.westby@ubuntu.com-20061220050531-79inzy7o6uu95qx7
Tags: 2.1-7
* updated vi debconf translations, thanks to Clytie Siddall
  <clytie@riverland.net.au>
* fixed typo in one template (that you would like, not that
  would you like), thanks as well to Clytie Siddall
  - unfuzzied all translations

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*  $Id: mbox.cpp,v 1.9 2004/08/24 16:16:35 terpstra Exp $
 
1
/*  $Id: mbox.cpp,v 1.13 2006/03/01 14:55:45 terpstra Exp $
2
2
 *  
3
3
 *  mbox.cpp - Handle a mbox/ command
4
4
 *  
22
22
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
23
 */
24
24
 
25
 
#define _XOPEN_SOURCE 500
26
25
#define _FILE_OFFSET_BITS 64
27
26
 
28
27
#include <mimelib/message.h>
36
35
        Request req = parse_request(param);
37
36
        
38
37
        if (!MessageId::is_full(req.options.c_str()))
39
 
        {
40
 
                cout << "Status: 200 OK\r\n";
41
 
                cout << "Content-Type: text/html\r\n\r\n";
42
 
                cout << error(_("Bad request"), param,
43
 
                        _("The given parameter was not of the correct format. "
44
 
                          "A mbox request must be formatted like: "
45
 
                          "mbox/YYYYMMDD.HHMMSS.hashcode.txt"));
46
 
                return 1;
47
 
        }
 
38
                error(_("Bad request"), param,
 
39
                      _("The given parameter was not of the correct format. "
 
40
                        "A mbox request must be formatted like: "
 
41
                        "mbox/YYYYMMDD.HHMMSS.hashcode.txt"));
48
42
        
49
43
        if (!cfg.raw_email)
50
 
        {
51
 
                cout << "Status: 200 OK\r\n";
52
 
                cout << "Content-Type: text/html\r\n\r\n";
53
 
                cout << error(_("Permission Denied"), param,
54
 
                        _("Access to raw email text has been disabled. "
55
 
                          "Contact the site administrator if this is a problem."));
56
 
                return 1;
57
 
        }
 
44
                error(_("Permission Denied"), param,
 
45
                      _("Access to raw email text has been disabled. "
 
46
                        "Contact the site administrator if this is a problem."));
58
47
        
59
48
        MessageId id(req.options.c_str());
60
49
        string ok;
61
50
        
62
51
        Summary source(id);
63
 
        if ((ok = source.load(db, cfg)) != "")
 
52
        // Identical error if missing or not allowed (security)
 
53
        if ((ok = source.load(db, cfg)) != "" || !source.allowed())
64
54
        {
65
 
                cout << "Status: 200 OK\r\n";
66
 
                cout << "Content-Type: text/html\r\n\r\n";
67
 
                cout << error(_("Database mbox source pull failure"), ok,
68
 
                        _("The specified message does not exist."));
69
 
                return 1;
 
55
                if (ok == "") ok = "not in a mailbox"; // fake
 
56
                error(_("Database mbox source pull failure"), ok,
 
57
                      _("The specified message does not exist."));
70
58
        }
71
59
        
 
60
        if (source.deleted())
 
61
                error(_("Database mbox source pull failure"), "not found",
 
62
                      _("The specified message has been deleted."));
 
63
        
72
64
        DwMessage message;
73
65
        if ((ok = source.message(cfg.dbdir, message)) != "")
74
 
        {
75
 
                cout << "Status: 200 OK\r\n";
76
 
                cout << "Content-Type: text/html\r\n\r\n";
77
 
                cout << error(_("MBox read failure"), ok,
78
 
                        _("Unable to open message in the mailbox. "
79
 
                          "Perhaps it has been deleted or moved?"));
80
 
                return 1;
81
 
        }
 
66
                error(_("MBox read failure"), ok,
 
67
                      _("Unable to open message in the mailbox. "
 
68
                        "Perhaps it has been deleted or moved?"));
82
69
        
83
70
        Cache cache(cfg, "mbox", param, req.ext);
84
71
        cache.o << message.AsString().c_str();