Example #1
0
void hime_im_client_clear_flags(HIME_client_handle *handle, int flags, int *ret_flag)
{
  HIME_req req;

  if (!handle)
    return;

  if (is_special_user)
    return;

  if (!gen_req(handle, HIME_req_set_flags, &req))
    return;

  req.flag &= ~flags;

  flags_backup = req.flag;

  if (handle_write(handle, &req, sizeof(req)) <=0) {
    error_proc(handle,"hime_im_client_set_flags error");
  }

  if (handle_read(handle, ret_flag, sizeof(int)) <= 0) {
    error_proc(handle, "cannot read reply str from hime server");
  }
}
Example #2
0
static int hime_im_client_forward_key_event(HIME_client_handle *handle,
                                          HIME_req_t event_type,
                                          KeySym key, u_int state,
                                          char **rstr)
{
  HIME_reply reply;
  HIME_req req;

  *rstr = NULL;

  if (is_special_user) {
      return 0;
  }

  if (!gen_req(handle, event_type, &req))
    return 0;

  req.keyeve.key = key;
  to_hime_endian_4(&req.keyeve.key);
  req.keyeve.state = state;
  to_hime_endian_4(&req.keyeve.state);


  if (handle_write(handle, &req, sizeof(req)) <= 0) {
    error_proc(handle, "cannot write to hime server");
    return FALSE;
  }

  bzero(&reply, sizeof(reply));
  if (handle_read(handle, &reply, sizeof(reply)) <=0) {
    error_proc(handle, "cannot read reply from hime server");
    return FALSE;
  }

  to_hime_endian_4(&reply.datalen);
  to_hime_endian_4(&reply.flag);

  if (reply.datalen > 0) {
    *rstr = (char *)malloc(reply.datalen);
    if (handle_read(handle, *rstr, reply.datalen) <= 0) {
      free(*rstr); *rstr = NULL;
      error_proc(handle, "cannot read reply str from hime server");
      return FALSE;
    }
  }

//  dbg("hime_im_client_forward_key_event %x\n", reply.flag);

  return reply.flag;
}
Example #3
0
void hime_im_client_focus_out2(HIME_client_handle *handle, char **rstr)
{
  HIME_req req;
  HIME_reply reply;

  if (rstr)
    *rstr = NULL;

  if (!handle)
    return;

  if (is_special_user)
    return;

#if DBG
  dbg("hime_im_client_focus_out2\n");
#endif
  handle->flag &= ~FLAG_HIME_client_handle_has_focus;

  if (!gen_req(handle, HIME_req_focus_out2, &req))
    return;

  if (handle_write(handle, &req, sizeof(req)) <=0) {
    error_proc(handle,"hime_im_client_focus_out error");
  }

  bzero(&reply, sizeof(reply));
  if (handle_read(handle, &reply, sizeof(reply)) <=0) {
    error_proc(handle, "cannot read reply from hime server");
    return;
  }

  to_hime_endian_4(&reply.datalen);
  to_hime_endian_4(&reply.flag);

  if (reply.datalen > 0) {
    *rstr = (char *)malloc(reply.datalen);
    if (handle_read(handle, *rstr, reply.datalen) <= 0) {
      free(*rstr); *rstr = NULL;
      error_proc(handle, "cannot read reply str from hime server");
      return;
    }
  }

//  dbg("hime_im_client_forward_key_event %x\n", reply.flag);

  return;
}
Example #4
0
void hime_im_client_message(HIME_client_handle *handle, char *message)
{
  HIME_req req;
  short len;
#if DBG
  dbg("hime_im_client_message\n");
#endif
  if (!gen_req(handle, HIME_req_message, &req))
    return;

  if (handle_write(handle, &req, sizeof(req)) <=0) {
    error_proc(handle,"hime_im_client_message error 1");
  }

  len = strlen(message)+1;
  if (handle_write(handle, &len, sizeof(len)) <=0) {
    error_proc(handle,"hime_im_client_message error 2");
  }

  if (handle_write(handle, message, len) <=0) {
    error_proc(handle,"hime_im_client_message error 2");
  }
}
Example #5
0
void hime_im_client_focus_out(HIME_client_handle *handle)
{
  if (!handle)
    return;
  if (is_special_user)
    return;

  HIME_req req;
//  dbg("hime_im_client_focus_out\n");
  handle->flag &= ~FLAG_HIME_client_handle_has_focus;

  if (!gen_req(handle, HIME_req_focus_out, &req))
    return;

  if (handle_write(handle, &req, sizeof(req)) <=0) {
    error_proc(handle,"hime_im_client_focus_out error");
  }
}
Example #6
0
void hime_im_client_reset(HIME_client_handle *handle)
{
  if (!handle)
    return;

  if (is_special_user)
    return;

  HIME_req req;
#if DBG
  dbg("hime_im_client_reset\n");
#endif
  if (!gen_req(handle, HIME_req_reset, &req))
    return;

  if (handle_write(handle, &req, sizeof(req)) <=0) {
    error_proc(handle,"hime_im_client_reset error");
  }
}
Example #7
0
void hime_im_client_focus_in(HIME_client_handle *handle)
{
  if (!handle)
    return;
  if (is_special_user)
    return;

  HIME_req req;
//  dbg("hime_im_client_focus_in\n");
  handle->flag |= FLAG_HIME_client_handle_has_focus;

  if (!gen_req(handle, HIME_req_focus_in, &req))
    return;

  if (handle_write(handle, &req, sizeof(req)) <=0) {
    error_proc(handle,"hime_im_client_focus_in error");
  }

  hime_im_client_set_cursor_location(handle, handle->spot_location.x,
     handle->spot_location.y);
}
Example #8
0
void hime_im_client_set_cursor_location(HIME_client_handle *handle, int x, int y)
{
  if (!handle)
    return;
  if (is_special_user)
    return;

//  dbg("hime_im_client_set_cursor_location %d   %d,%d\n", handle->flag, x, y);

  HIME_req req;
  handle->spot_location.x = x;
  handle->spot_location.y = y;

  if (!BITON(handle->flag, FLAG_HIME_client_handle_has_focus))
    return;

  if (!gen_req(handle, HIME_req_set_cursor_location, &req))
    return;

  if (handle_write(handle, &req, sizeof(req)) <=0) {
    error_proc(handle,"hime_im_client_set_cursor_location error");
  }
}
Example #9
0
int hime_im_client_get_preedit(HIME_client_handle *handle, char **str, HIME_PREEDIT_ATTR att[], int *cursor ,int *sub_comp_len)
{
  *str=NULL;
  if (!handle)
    return 0;

  if (is_special_user)
    return 0;

  int attN, tcursor, str_len;
#if DBG
  dbg("hime_im_client_get_preedit\n");
#endif
  HIME_req req;
  if (!gen_req(handle, HIME_req_get_preedit, &req)) {
err_ret:
#if DBG
    dbg("aaaaaaaaaaaaa %x\n", str);
#endif
    if (cursor)
      *cursor=0;
    *str=strdup("");
    return 0;
  }

  if (handle_write(handle, &req, sizeof(req)) <=0) {
    error_proc(handle,"hime_im_client_get_preedit error");
    goto err_ret;
  }

  str_len=-1; // str_len includes \0
  if (handle_read(handle, &str_len, sizeof(str_len))<=0)
    goto err_ret; // including \0

  *str = (char *)malloc(str_len);

  if (handle_read(handle, *str, str_len)<=0)
    goto err_ret;
#if DBG
  dbg("hime_im_client_get_preedit len:%d '%s' \n", str_len, *str);
#endif
  attN = -1;
  if (handle_read(handle, &attN, sizeof(attN))<=0) {
    goto err_ret;
  }

//  dbg("attrN:%d\n", attN);

  if (attN>0 && handle_read(handle, att, sizeof(HIME_PREEDIT_ATTR)*attN)<=0) {
    goto err_ret;
  }


  tcursor=0;
  if (handle_read(handle, &tcursor, sizeof(tcursor))<=0) {
    goto err_ret;
  }

  if (cursor)
    *cursor = tcursor;

  int tsub_comp_len;
  tsub_comp_len=0;
  if (handle_read(handle, &tsub_comp_len, sizeof(tsub_comp_len))<=0) {
    goto err_ret;
  }
  if (sub_comp_len)
	*sub_comp_len = tsub_comp_len;

#if DBG
  dbg("jjjjjjjjj %d tcursor:%d\n", attN, tcursor);
#endif
  return attN;
}
Example #10
0
/*******************************************************************************
    Routine Name:   main
    Form:           int main( void )
    Parameters:     void
    Return value:   int
                        but not return...
    Description:    main
******************************************************************************/
int main( void )
{
	unsigned long write_addr;
	unsigned char status;

	//  LED ON, when enter to boot mode
	P51D = 1;			
	P56D = 1;			

	P56DIR = 0;
	P56C1 = 1;
	P56C0 = 1;
	P56MD0 = 0;
	P56MD1 = 0;
	P51DIR = 0;
	P51C1 = 1;
	P51C0 = 1;
	P51MD0 = 0;
	P51MD1 = 0;

	memset(XmodemBuf,0,sizeof(XmodemBuf));
	
	/* initialize variables */
#ifndef DEBUG
	write_addr = (unsigned long)USER_AREA_ADDR;
#else
	write_addr = (unsigned long)0x2000;
#endif
	/* initialize peripheral */
	initPeri();
	Xmodem_Init( XmodemBuf );
	__EI();
	//  LED ON, when enter to boot mode

	/* Display program */
	uart_send_sync((unsigned char*)msgIspProg, sizeof(msgIspProg));

	Xmodem_SendByte('C');

	P51D = 0;					// Orange LED ON
	
	/* main loop */	
	for(;;){
		/* clear WDT */
		wdt_clear();
		
		status = Xmodem_ReadStatus();
		
		switch(status){
			case RECV_END:
				P56D = 0;		// BLUE LED ON
				if(write_verify(&write_addr, XmodemBuf+3) != OK){
					error_proc();  /* endless loop in error_proc()*/
				}
				else{
					Xmodem_SendByte(ACK);
				}
				P56D = 1;		// BLUE LED OFF
				break;
			case EOT_END:	// original was remap.  change to infinity loop.
				end_of_update();
//				Remap((unsigned long)USER_AREA_ADDR);
				break;
			case TIMEOUT_ERR:
			case RETRY_ERR:
			case SEND_ERR:
#ifdef DEBUG
				XmodemBuf[2] = status;
#endif
				error_proc();  /* endless loop in error_proc()*/
				break;
			default:
				break;
		}
	}
}