Example #1
0
File: user.cpp Project: aox/aox
Address * User::address()
{
    if ( !d->address ) {
        // XXX: This does not match the documentation above.
        EString dom = Configuration::hostname();
        uint i = dom.find( '.' );
        if ( i > 0 )
            dom = dom.mid( i+1 );
        AsciiCodec a;
        d->address = new Address( UString(), d->login, a.toUnicode( dom ) );
    }
    return d->address;
}
Example #2
0
UString Command::mailboxName()
{
    EString n = astring();
    if ( n.endsWith( "/" ) )
        n = n.mid( 0, n.length() - 1 );

    User * u = imap()->user();
    if ( u && n.lower() == "inbox" ) {
        return u->inbox()->name();
    }

    MUtf7Codec m;
    UString un( m.toUnicode( n ) );
    UString r;
    if ( !m.wellformed() ) {
        AsciiCodec a;
        un = a.toUnicode( n );
        if ( !a.valid() ) {
            error( Bad,
                   "Mailbox name misparsed both as ASCII and mUTF-7: " +
                   m.error() + " (mUTF7) + " + a.error() + " (ASCII)" );
            return r;
        }
    }
    if ( un.startsWith( "/" ) ) {
        if ( u &&
             un[u->home()->name().length()] == '/' &&
             un.startsWith( u->home()->name() ) )
            d->usesAbsoluteMailbox = true;
    }
    else if ( !u ) {
        error( Bad, "Relative mailbox name is invalid before login" );
        return r;
    }
    else {
        d->usesRelativeMailbox = true;
        r.append( u->home()->name() );
        r.append( "/" );
    }
    r.append( un );
    if ( !Mailbox::validName( r ) ) {
        error( Bad, "Syntax error in mailbox name: " + n );
        return r;
    }
    return r;
}
Example #3
0
UString Command::listMailbox()
{
    EString r( d->args->listMailbox() );
    if ( !d->args->ok() )
        error( Bad, d->args->error() );

    MUtf7Codec m;
    UString u( m.toUnicode( r ) );
    if ( !m.wellformed() ) {
        AsciiCodec a;
        u = a.toUnicode( r );
        if ( !a.valid() )
            error( Bad,
                   "List-mailbox misparsed both as ASCII and mUTF-7: " +
                   m.error() + " (mUTF7) + " + a.error() + " (ASCII)" );
    }
    return u;
}
Example #4
0
UString SmtpParser::domain()
{
    UString r;
    if ( nextChar() == '[' ) {
        uint start = pos();
        while ( !atEnd() && nextChar() != ']' )
            step();
        require( "]" );
        AsciiCodec a;
        r = a.toUnicode( input().mid( start, pos() - start ) );
    }
    else {
        r = subDomain();
        while ( nextChar() == '.' ) {
            step();
            if ( nextChar() != '>' ) {
                r.append( "." );
                r.append( subDomain() );
            }
        }
    }
    return r;
}