1
/* Copyright 2011-2012 Yorba Foundation
3
* This software is licensed under the GNU Lesser General Public License
4
* (version 2.1 or later). See the COPYING file in this distribution.
8
* A StringParameter that holds a mailbox reference (can be wildcarded). Used
9
* to juggle between our internal UTF-8 representation of mailboxes and IMAP's
10
* odd "modified UTF-7" representation. The value is stored in IMAP's encoded
11
* format since that's how it comes across the wire.
13
public class Geary.Imap.MailboxParameter : StringParameter {
14
private static string utf8_to_imap_utf7(string utf8) {
16
return Geary.ImapUtf7.utf8_to_imap_utf7(utf8);
17
} catch (ConvertError e) {
18
debug("Error encoding mailbox name '%s': %s", utf8, e.message);
23
private static string imap_utf7_to_utf8(string imap_utf7) {
25
return Geary.ImapUtf7.imap_utf7_to_utf8(imap_utf7);
26
} catch (ConvertError e) {
27
debug("Invalid mailbox name '%s': %s", imap_utf7, e.message);
32
public MailboxParameter(string mailbox) {
33
base (utf8_to_imap_utf7(mailbox));
36
public MailboxParameter.from_string_parameter(StringParameter string_parameter) {
37
base (string_parameter.value);
40
public string decode() {
41
return imap_utf7_to_utf8(value);