[Uim] Please review Uim Developer's Document

Kazuki Ohta mover at hct.zaq.ne.jp
Mon Jun 28 10:22:24 EEST 2004


Hi.

Now, I propose these helper API instead of current API.
The only idea is that all functions use static fd and 
buffer, and create the function to get the value of static 
fd to be able to get the value from the user side.

#in gtk-im-uim.c, fd is stored in static in im_uim_fd. I 
think this is avoidable.

/**/
//This function initialize fd if static client fd.
void uim_helper_init_client_fd(void (*disconnect_cb)(void));

//Returns the current value of static fd.
int uim_helper_get_client_fd(void);

//Finalizing static fd
void uim_helper_close_client_fd(void);

/**/
void uim_helper_read_proc(void);
char *uim_helper_get_message(void);

/**/
void uim_helper_send_message(const char *message);

In future, helper system will be used for customizing of 
committing string from another app (input palette) or so.
Therefore, we need to prepere flexible API for it.

How do you think about this, Yamaken?

regards.

> > Would you point at the concreate weird points of helper
> > related functions? I'll change the API according to
> > your advice.
>
> ] /* API for input method user side */
> ] int  uim_helper_init_client_fd(void
> (*disconnect_cb)(void)); ] void
> uim_helper_close_client_fd(int );
> ] void uim_helper_read_proc(int fd);
> ] char *uim_helper_send_message(int fd, const char
> *message);
>
> These four functions work with fd stored on the user
> side. init and close also keep the static uim_fd up to
> date.
>
> ] void uim_helper_client_focus_in(uim_context uc);
> ] void uim_helper_client_focus_out(uim_context uc);
>
> These two are only used by the input method clients, and
> the helpers _receive_ the messages. They send over the
> static uim_fd.
>
> ] void uim_helper_client_get_prop_list(void);
>
> This call sends a message to get the useful data for the
> display... Using the static uim_fd.
>
> ] char *uim_helper_get_message(void);
>
> This uses a static buffer, filled by
> uim_helper_read_proc.
>
> To my mind, it should be consitently either the static fd
> in uim-helper-client.c, or a user-kept fd (which makes
> more sense so it can be 'selected' on.)
>
> Also, uim_helper_read_proc seems unneccessary as a
> function compared to uim_helper_get_message(int fd);
>
> In fact, given that the messages appear to be fairly
> discrete and well deliminated, I would expect the read
> routine could just pull data until it sees two \n's, and
> block otherwise.
>
> (I could be wrong about this last bit, I've not delved
> too deeply into the IPC stuff. :-)
>
> Just in case I'm doing it wrong, here's the stub helper I
> knocked up last night so I could see what was coming out,
> based on looking at helper-toolbar-common-gtk. As it
> happens, the hard part looks like the blackbox slit
> thingy.
>
> #include <uim/uim.h>
> #include <uim/uim-helper.h>
>
> int main (void)
> {
> 	int uim_fd = -1;
> 	char *tmp;
> 	uim_fd = uim_helper_init_client_fd(NULL);
> 	if (uim_fd < 0) {
> 		printf("Barf\n");
> 		return -1;
> 	}
> 	uim_helper_client_get_prop_list();
> 	while (1) {
> 		uim_helper_read_proc(uim_fd);
> 		while ((tmp = uim_helper_get_message())) {
> 			printf("%s\n", tmp);
> 			free(tmp);
> 		}
> 	}
> 	uim_helper_close_client_fd(uim_fd);
> }

-- 
Move the worl:-D!

Kazuki Ohta : mover at hct.zaq.ne.jp




More information about the uim mailing list