Beispiel #1
0
void XimIM_impl::send_sync(C16 icid)
{
    TxPacket *t = createTxPacket(XIM_SYNC, 0);
    t->pushC16(mID);
    t->pushC16(icid);
    mConn->push_packet(t);
}
Beispiel #2
0
void XimIM_impl::set_ic_values(RxPacket *p)
{
    C16 imid, icid;
    XimIC *ic;
    p->rewind();
    imid = p->getC16();
    icid = p->getC16();
    ic = get_ic_by_id(icid);

    int atr_len;
    atr_len = p->getC16();
    p->getC16();

    unsigned char *v;
    v = (unsigned char *)alloca(atr_len);

    int i;
    for (i = 0; i < atr_len; i++) {
	v[i] = p->getC8();
    }

    ic->setICAttrs((void *)v, atr_len);

    TxPacket *t = createTxPacket(XIM_SET_IC_VALUES_REPLY, 0);
    t->pushC16(imid);
    t->pushC16(icid);
    mConn->push_packet(t);
}
Beispiel #3
0
void Connection::xim_open(RxPacket *p)
{
    char buf[16];
    int l;
    for (l = 0; l < 16; l++) {
	buf[l] = 0;
    }
    l = p->getStr8Len();
    if (l > 15) {
	printf("too long locale name.\n");
	return;
    }
    p->getStr8(buf);

    TxPacket *t;
    C16 imid;
    XimIM *im;
    imid = unused_im_id();
    mCreatedIm.push_back(imid); // had to be deleted by the creator Connection
    im = create_im(this, imid);
    im->set_lang_region(buf);
    t = createTxPacket(XIM_OPEN_REPLY, 0);
    t->pushC16(imid);
    XIMATTRIBUTE::write_imattr_to_packet(t);
    XICATTRIBUTE::write_icattr_to_packet(t);
  
    push_packet(t);

    // EventMask selection

    t = createTxPacket(XIM_SET_EVENT_MASK, 0);
    t->pushC16(imid);
    t->pushC16(0);
    if (g_option_mask & OPT_ON_DEMAND_SYNC) {
	t->pushC32(KeyPressMask|KeyReleaseMask);
	t->pushC32((unsigned int)~(KeyPressMask|KeyReleaseMask)); // no need to send
						    // XIM_SYNC_REPLY from
						    // XIM server
    } else {
	t->pushC32(KeyPressMask);
	t->pushC32(KeyPressMask); // need to send XIM_SYNC_REPLY from XIM server
    }

    push_packet(t);
}
Beispiel #4
0
void Connection::xim_disconnect()
{
    TxPacket *t;
    t = createTxPacket(XIM_DISCONNECT_REPLY, 0);
    push_packet(t);

    terminate();
    if (g_option_mask & OPT_TRACE)
	printf("disconnect xim connection.\n");
}
Beispiel #5
0
void Connection::xim_query_extension(RxPacket *p)
{
    C16 imid;
    imid = p->getC16();

    TxPacket *t;
    t = createTxPacket(XIM_QUERY_EXTENSION_REPLY, 0);
    t->pushC16(imid);
    t->pushC16(0);
  
    push_packet(t);
}
Beispiel #6
0
void XimIM_impl::destroy_ic(C16 icid)
{
    TxPacket *t;
    t = createTxPacket(XIM_DESTROY_IC_REPLY, 0);
    t->pushC16(mID);
    t->pushC16(icid);
    mConn->push_packet(t);
    // destruct IC
    XimIC *ic;
    ic = get_ic_by_id(icid);
    delete_ic(ic);
}
Beispiel #7
0
void Connection::xim_close(RxPacket *p)
{
    C16 imid;
    imid = p->getC16();
    TxPacket *t;
    t = createTxPacket(XIM_CLOSE_REPLY, 0);
    t->pushC16(imid);
    t->pushC16(0);
    push_packet(t);
    close_im(imid);
    std::list<C16>::iterator i;
    for (i = mCreatedIm.begin(); i != mCreatedIm.end(); ++i) {
	if (*i == imid) {
	    mCreatedIm.erase(i);
	    return;
	}
    }
}
Beispiel #8
0
//
// Packet handlers
//
void Connection::xim_connect(RxPacket *p)
{
    TxPacket *t;
    
    p->rewind();
    p->getC8();
    p->getC8(); // discard
    if (p->isOverRun()) {
	push_error_packet(0, 0, 0, "Invalid Packet");
	terminate();
	return;
    }

    t = createTxPacket(XIM_CONNECT_REPLY, 0);
    t->pushC16(1);
    t->pushC16(0);
    push_packet(t);
    if (g_option_mask & OPT_TRACE)
	printf("accept xim connection.\n");
}
Beispiel #9
0
void Connection::push_error_packet(C16 imid, C16 icid, C16 er, const char *str)
{
    TxPacket *t;
    t = createTxPacket(XIM_ERROR, 0);
    t->pushC16(imid);
    t->pushC16(icid);
    int m = 0;
    if (imid)
	m += 1;
    if (icid)
	m += 2;

    t->pushC16((C16)m);
    t->pushC16(er);
    int l = static_cast<int>(strlen(str));
    char tmp[4];
    t->pushC16((C16)l);
    t->pushC16(0);
    t->pushBytes(str, l);
    t->pushBytes(tmp, pad4(l));
    push_packet(t);
}
Beispiel #10
0
void XimIM_impl::get_ic_values(RxPacket *p)
{
    C16 icid;
    XimIC *ic;
    p->rewind();
    p->getC16();
    icid = p->getC16();
    ic = get_ic_by_id(icid);

    int len;
    len = p->getC16();

    TxPacket *t = createTxPacket(XIM_GET_IC_VALUES_REPLY, 0);
    t->pushC16(mID);
    t->pushC16(icid);
    int i, l;
    C16 id;
    l = 0;
    for (i = 0; i < len / 2; i++) {
	id = p->getC16();
	l += ic->get_ic_atr(id, 0);
	l += 4;
    }
    t->pushC16((C16)l);
    t->pushC16(0);

    p->rewind();
    p->getC16(); // imid
    p->getC16(); // icid
    p->getC16(); // n

    for (i = 0; i < len / 2; i++) {
	id = p->getC16();
	t->pushC16(id);
	t->pushC16(ic->get_ic_atr(id, 0));
	l += ic->get_ic_atr(id, t);
    }
    mConn->push_packet(t);
}
Beispiel #11
0
void Connection::xim_get_im_values(RxPacket *p)
{
    int l, i;
    C16 imid;
    TxPacket *t;
    t = createTxPacket(XIM_GET_IM_VALUES_REPLY, 0);
    imid = p->getC16(); // input-method id
    l = p->getC16() / 2; // number

    int *ra = (int *)alloca(sizeof(int) * l);
    int rlen = 0;
    for (i = 0; i < l; i++) {
	ra[i] = p->getC16();
	rlen += 4;
    }

    // XIMATTRIBUTE
    C16 nr_style;
    struct input_style *is = get_im_by_id(imid)->getInputStyles();
    for (nr_style = 0; is[nr_style].style; nr_style++) {
	;
    }

    // since only one IMAttribute...
    t->pushC16(imid);
    t->pushC16((C16)(8 + nr_style * 4));

    t->pushC16(0); // attribute id
    t->pushC16((C16)(4 + nr_style * 4)); // length

    t->pushC16(nr_style); // number
    t->pushC16(0);
    for (i = 0; i < nr_style; i++) {
	t->pushC32(is[i].x_style);
    }

    push_packet(t);
}
Beispiel #12
0
void Connection::xim_encoding_negotiation(RxPacket *p)
{
    TxPacket *t;
    t = createTxPacket(XIM_ENCODING_NEGOTIATION_REPLY, 0);
    C16 l, index;
    int i, m, s;
    C16 imid, idx;
    char buf[32];
    XimIM *im;

    imid = p->getC16(); // m_imid
    l = p->getC16();
    im = get_im_by_id(imid);
  
    index = 0;
    for (m = 0, s = 0, idx = 0; m < l; m += (s + 1), idx++) {
	s = p->getStr8Len();

	for (i= 0; i < 32; i++) {
	    buf[i] = 0;
	}
	p->getStr8(buf);

	// use COMPOUND_TEXT
	if (!strcmp("COMPOUND_TEXT", buf))
	    index = idx;
	else {
	    if (im)
		im->set_encoding(buf);
	}
    }

    t->pushC16(imid);
    t->pushC16(0);
    t->pushC16(index);
    t->pushC16(0);
    push_packet(t);
}
Beispiel #13
0
void XimIM_impl::create_ic(RxPacket *p)
{
    XimIC *ic;
    C16 icid= unused_ic_id();

    // create compose table with the first ic
    if (icid == 1)
	create_compose_tree();

    ic = ::create_ic(mConn, p, mID, icid, mEngineName);
    if (!ic) {
	mConn->push_error_packet(mID, icid,
				 ERR_Style, "invalid im style");
	return;
    }
    std::pair<C16, XimIC *> n(ic->get_icid(), ic);
    m_ics.insert(n);

    TxPacket *t;
    t = createTxPacket(XIM_CREATE_IC_REPLY, 0);
    t->pushC16(mID);
    t->pushC16(ic->get_icid());
    mConn->push_packet(t);
}