コード例 #1
0
ファイル: xrdp_cache.c プロジェクト: authentic8/xrdp
/* not sure how to use a palette in rdp */
int APP_CC
xrdp_cache_add_palette(struct xrdp_cache *self, int *palette)
{
    int i;
    int oldest;
    int index;

    if (self == 0)
    {
        return 0;
    }

    if (palette == 0)
    {
        return 0;
    }

    if (self->wm->screen->bpp > 8)
    {
        return 0;
    }

    self->palette_stamp++;

    /* look for match */
    for (i = 0; i < 6; i++)
    {
        if (g_memcmp(palette, self->palette_items[i].palette,
                     256 * sizeof(int)) == 0)
        {
            self->palette_items[i].stamp = self->palette_stamp;
            return i;
        }
    }

    /* look for oldest */
    index = 0;
    oldest = 0x7fffffff;

    for (i = 0; i < 6; i++)
    {
        if (self->palette_items[i].stamp < oldest)
        {
            oldest = self->palette_items[i].stamp;
            index = i;
        }
    }

    /* set, send palette and return */
    g_memcpy(self->palette_items[index].palette, palette, 256 * sizeof(int));
    self->palette_items[index].stamp = self->palette_stamp;
    libxrdp_orders_send_palette(self->session, palette, index);
    return index;
}
コード例 #2
0
ファイル: libxrdp.c プロジェクト: radoslavv/xrdp
int EXPORT_CC
libxrdp_send_palette(struct xrdp_session *session, int *palette)
{
    int i = 0;
    int color = 0;
    struct stream *s = (struct stream *)NULL;

    if (session->client_info->bpp > 8)
    {
        return 0;
    }

    DEBUG(("libxrdp_send_palette sending palette"));
    /* clear orders */
    libxrdp_orders_force_send(session);
    make_stream(s);
    init_stream(s, 8192);
    xrdp_rdp_init_data((struct xrdp_rdp *)session->rdp, s);
    out_uint16_le(s, RDP_UPDATE_PALETTE);
    out_uint16_le(s, 0);
    out_uint16_le(s, 256); /* # of colors */
    out_uint16_le(s, 0);

    for (i = 0; i < 256; i++)
    {
        color = palette[i];
        out_uint8(s, color >> 16);
        out_uint8(s, color >> 8);
        out_uint8(s, color);
    }

    s_mark_end(s);
    xrdp_rdp_send_data((struct xrdp_rdp *)session->rdp, s, RDP_DATA_PDU_UPDATE);
    free_stream(s);
    /* send the orders palette too */
    libxrdp_orders_init(session);
    libxrdp_orders_send_palette(session, palette, 0);
    libxrdp_orders_send(session);
    return 0;
}
コード例 #3
0
ファイル: libxrdp.c プロジェクト: Osirium/xrdp
int EXPORT_CC
libxrdp_send_palette(struct xrdp_session *session, int *palette)
{
    int i = 0;
    int color = 0;
    struct stream *s = (struct stream *)NULL;

    if (session->client_info->bpp > 8)
    {
        return 0;
    }

    DEBUG(("libxrdp_send_palette sending palette"));

    /* clear orders */
    libxrdp_orders_force_send(session);
    make_stream(s);
    init_stream(s, 8192);

    if (session->client_info->use_fast_path & 1) /* fastpath output supported */
    {
        LLOGLN(10, ("libxrdp_send_palette: fastpath"));
        if (xrdp_rdp_init_fastpath((struct xrdp_rdp *)session->rdp, s) != 0)
        {
            free_stream(s);
            return 1;
        }
    }
    else {
        LLOGLN(10, ("libxrdp_send_palette: slowpath"));
        xrdp_rdp_init_data((struct xrdp_rdp *)session->rdp, s);
    }

    /* TS_UPDATE_PALETTE_DATA */
    out_uint16_le(s, RDP_UPDATE_PALETTE);
    out_uint16_le(s, 0);
    out_uint16_le(s, 256); /* # of colors */
    out_uint16_le(s, 0);

    for (i = 0; i < 256; i++)
    {
        color = palette[i];
        out_uint8(s, color >> 16);
        out_uint8(s, color >> 8);
        out_uint8(s, color);
    }

    s_mark_end(s);
    if (session->client_info->use_fast_path & 1) /* fastpath output supported */
    {
       if (xrdp_rdp_send_fastpath((struct xrdp_rdp *)session->rdp, s,
                                   FASTPATH_UPDATETYPE_PALETTE) != 0)
       {
           free_stream(s);
           return 1;
       }
    }
    else
    {
       xrdp_rdp_send_data((struct xrdp_rdp *)session->rdp, s,
                           RDP_DATA_PDU_UPDATE);
    }
    free_stream(s);

    /* send the orders palette too */
    libxrdp_orders_init(session);
    libxrdp_orders_send_palette(session, palette, 0);
    libxrdp_orders_send(session);
    return 0;
}