// ---------------------------------------------------------------------------
// RPeninputServerImpl::UiLayoutPos
// get ui layout position
// ---------------------------------------------------------------------------
//
void RPeninputServerImpl::GetUiLayoutPosAndSize()
    {
    TPckg<TPoint> msgPos(iPosition);
    TPckg<TSize> msgSize(iSize);
    
    TIpcArgs arg;
    arg.Set(KMsgSlot0,&msgPos);
    arg.Set(KMsgSlot1,&msgSize);
    SendReceive(EPeninputRequestUiGetUiPos,arg);
    }
Exemple #2
0
//-----------------------------------------------------------------------------
void KMMsgInfo::setMsgSize(size_t sz)
{
    if (sz == msgSize())
        return;

    if(!kd)
        kd = new KMMsgInfoPrivate;
    kd->modifiers |= KMMsgInfoPrivate::SIZE_SET;
    kd->msgSize = sz;
    mDirty = true;
}
Exemple #3
0
/*
 * fetch messages
 *
 * imap4 body[] requestes get translated to upas/fs files as follows
 *	body[id.header] == id/rawheader file + extra \r\n
 *	body[id.text] == id/rawbody
 *	body[id.mime] == id/mimeheader + extra \r\n
 *	body[id] === body[id.header] + body[id.text]
*/
int
fetchMsg(Box *, Msg *m, int uids, void *vf)
{
    Tm tm;
    Fetch *f;
    char *sep;
    int todo;

    if(m->expunged)
        return uids;

    todo = 0;
    for(f = vf; f != nil; f = f->next) {
        switch(f->op) {
        case FFlags:
            todo = 1;
            break;
        case FUid:
            todo = 1;
            break;
        case FInternalDate:
        case FEnvelope:
        case FRfc822:
        case FRfc822Head:
        case FRfc822Size:
        case FRfc822Text:
        case FBodySect:
        case FBodyPeek:
        case FBody:
        case FBodyStruct:
            todo = 1;
            if(!msgStruct(m, 1)) {
                msgDead(m);
                return uids;
            }
            break;
        default:
            bye("bad implementation of fetch");
            return 0;
        }
    }

    if(m->expunged)
        return uids;
    if(!todo)
        return 1;

    /*
     * note: it is allowed to send back the responses one at a time
     * rather than all together.  this is exploited to send flags elsewhere.
     */
    Bprint(&bout, "* %lud FETCH (", m->seq);
    sep = "";
    if(uids) {
        Bprint(&bout, "UID %lud", m->uid);
        sep = " ";
    }
    for(f = vf; f != nil; f = f->next) {
        switch(f->op) {
        default:
            bye("bad implementation of fetch");
            break;
        case FFlags:
            Bprint(&bout, "%sFLAGS (", sep);
            writeFlags(&bout, m, 1);
            Bprint(&bout, ")");
            break;
        case FUid:
            if(uids)
                continue;
            Bprint(&bout, "%sUID %lud", sep, m->uid);
            break;
        case FEnvelope:
            Bprint(&bout, "%sENVELOPE ", sep);
            fetchEnvelope(m);
            break;
        case FInternalDate:
            Bprint(&bout, "%sINTERNALDATE ", sep);
            Bimapdate(&bout, date2tm(&tm, m->unixDate));
            break;
        case FBody:
            Bprint(&bout, "%sBODY ", sep);
            fetchBodyStruct(m, &m->head, 0);
            break;
        case FBodyStruct:
            Bprint(&bout, "%sBODYSTRUCTURE ", sep);
            fetchBodyStruct(m, &m->head, 1);
            break;
        case FRfc822Size:
            Bprint(&bout, "%sRFC822.SIZE %lud", sep, msgSize(m));
            break;
        case FRfc822:
            f->part = FPAll;
            Bprint(&bout, "%sRFC822", sep);
            fetchBody(m, f);
            break;
        case FRfc822Head:
            f->part = FPHead;
            Bprint(&bout, "%sRFC822.HEADER", sep);
            fetchBody(m, f);
            break;
        case FRfc822Text:
            f->part = FPText;
            Bprint(&bout, "%sRFC822.TEXT", sep);
            fetchBody(m, f);
            break;
        case FBodySect:
        case FBodyPeek:
            Bprint(&bout, "%sBODY", sep);
            fetchBody(fetchSect(m, f), f);
            break;
        }
        sep = " ";
    }
    Bprint(&bout, ")\r\n");

    return 1;
}
Exemple #4
0
/*
 * actually return the body pieces
 */
void
fetchBody(Msg *m, Fetch *f)
{
    Pair p;
    char *s, *t, *e, buf[BufSize + 2];
    ulong n, start, stop, pos;
    int fd, nn;

    if(m == nil) {
        fetchBodyStr(f, "", 0);
        return;
    }
    switch(f->part) {
    case FPHeadFields:
    case FPHeadFieldsNot:
        n = m->head.size + 3;
        s = emalloc(n);
        n = selectFields(s, n, m->head.buf, f->hdrs, f->part == FPHeadFields);
        fetchBodyStr(f, s, n);
        free(s);
        return;
    case FPHead:
        fetchBodyStr(f, m->head.buf, m->head.size);
        return;
    case FPMime:
        fetchBodyStr(f, m->mime.buf, m->mime.size);
        return;
    case FPAll:
        fd = msgFile(m, "rawbody");
        if(fd < 0) {
            msgDead(m);
            fetchBodyStr(f, "", 0);
            return;
        }
        p = fetchBodyPart(f, msgSize(m));
        start = p.start;
        if(start < m->head.size) {
            stop = p.stop;
            if(stop > m->head.size)
                stop = m->head.size;
            Bwrite(&bout, &m->head.buf[start], stop - start);
            start = 0;
            stop = p.stop;
            if(stop <= m->head.size) {
                close(fd);
                return;
            }
        } else
            start -= m->head.size;
        stop = p.stop - m->head.size;
        break;
    case FPText:
        fd = msgFile(m, "rawbody");
        if(fd < 0) {
            msgDead(m);
            fetchBodyStr(f, "", 0);
            return;
        }
        p = fetchBodyPart(f, m->size);
        start = p.start;
        stop = p.stop;
        break;
    default:
        fetchBodyStr(f, "", 0);
        return;
    }

    /*
     * read in each block, convert \n without \r to \r\n.
     * this means partial fetch requires fetching everything
     * through stop, since we don't know how many \r's will be added
     */
    buf[0] = ' ';
    for(pos = 0; pos < stop; ) {
        n = BufSize;
        if(n > stop - pos)
            n = stop - pos;
        n = read(fd, &buf[1], n);
        if(n <= 0) {
            fetchBodyFill(stop - pos);
            break;
        }
        e = &buf[n + 1];
        *e = '\0';
        for(s = &buf[1]; s < e && pos < stop; s = t + 1) {
            t = memchr(s, '\n', e - s);
            if(t == nil)
                t = e;
            n = t - s;
            if(pos < start) {
                if(pos + n <= start) {
                    s = t;
                    pos += n;
                } else {
                    s += start - pos;
                    pos = start;
                }
                n = t - s;
            }
            nn = n;
            if(pos + nn > stop)
                nn = stop - pos;
            if(Bwrite(&bout, s, nn) != nn)
                writeErr();
            pos += n;
            if(*t == '\n') {
                if(t[-1] != '\r') {
                    if(pos >= start && pos < stop)
                        Bputc(&bout, '\r');
                    pos++;
                }
                if(pos >= start && pos < stop)
                    Bputc(&bout, '\n');
                pos++;
            }
        }
        buf[0] = e[-1];
    }
    close(fd);
}