Back to index

im-sdk  12.3.91
fop_test_client.c
Go to the documentation of this file.
00001 /*
00002  * fop_test_client.c: client to test iml_fop
00003  */
00004 
00005 
00006 #include <stdio.h>
00007 #include <stdlib.h>
00008 #include <time.h>
00009 #include <locale.h>
00010 
00011 #include <iiimcf.h>
00012 
00013 
00014 void
00015 status_verify(const char * name, IIIMF_status st)
00016 {
00017     if (IIIMF_STATUS_SUCCESS == st) {
00018        printf("%s: %d: success\n", name, st);
00019        return;
00020     } else {
00021        printf("%s: %d: fail\n", name, st);
00022        exit(1);
00023     }
00024 }
00025 
00026 
00027 int
00028 main(int argc, char ** argv)
00029 {
00030     IIIMCF_handle    handle;
00031     IIIMCF_attr             attr;
00032     IIIMCF_attr             attr1;
00033     IIIMF_status     st;
00034     IIIMCF_context   context;
00035     IIIMCF_event     ev;
00036     IIIMCF_keyevent  kev;
00037     char *           addr;
00038 
00039     setlocale(LC_ALL, "");
00040 
00041     addr = getenv("IIIMD_OPTION_UDSFILE");
00042 
00043     st = iiimcf_initialize(IIIMCF_ATTR_NULL);
00044     status_verify("iiimcf_initialize", st);
00045 
00046     st = iiimcf_create_attr(&attr);
00047     status_verify("iiimcf_create_attr", st);
00048     st = iiimcf_attr_put_string_value(attr, IIIMCF_ATTR_CLIENT_TYPE,
00049                                   "fop test");
00050     status_verify("iiimcf_attr_put_string_value", st);
00051     st = iiimcf_attr_put_string_value(attr, IIIMCF_ATTR_SERVER_ADDRESS,
00052                                   addr);
00053     status_verify("iiimcf_attr_put_string_value", st);
00054     st = iiimcf_attr_put_string_value(attr, IIIMCF_ATTR_SERVER_SERVICE,
00055                                   "");
00056     status_verify("iiimcf_attr_put_string_value", st);
00057 
00058     st = iiimcf_create_handle(attr, &handle);
00059     status_verify("iiimcf_create_handle", st);
00060 
00061     st = iiimcf_create_context(handle, IIIMCF_ATTR_NULL, &context);
00062     status_verify("iiimcf_create_context", st);
00063 
00064     st = iiimcf_create_attr(&attr1);
00065     status_verify("iiimcf_create_attr", st);
00066 
00067 
00068     st = iiimcf_attr_put_string_value(attr1, IIIMCF_ATTR_INPUT_LANGUAGE,
00069                                   "ja");
00070     status_verify("iiimcf_attr_put_string_value", st);
00071     st = iiimcf_attr_put_string_value(attr1, IIIMCF_ATTR_INPUT_METHOD,
00072                                   "fop_test");
00073     status_verify("iiimcf_attr_put_string_value", st);
00074 
00075     iiimcf_context_set_attr(context, attr1);
00076     status_verify("iiimcf_context_set_attr", st);
00077 
00078     st = iiimcf_create_seticfocus_event(&ev);
00079     status_verify("iiimcf_create_seticfocus_event", st);
00080 
00081     st = iiimcf_forward_event(context, ev);
00082     status_verify("iiimcf_forward_event", st);
00083 
00084     kev.keycode = 0;
00085     kev.keychar = 0;
00086     kev.modifier = 0;
00087     kev.time_stamp = time(NULL);
00088     st = iiimcf_create_keyevent(&kev, &ev);
00089     status_verify("iiimcf_create_keyevent", st);
00090 
00091 #if 0
00092     st = iiimcf_forward_event(context, ev);
00093     status_verify("iiimcf_forward_event", st);
00094 #endif
00095     st = iiimcf_destroy_context(context);
00096     status_verify("iiimcf_destroy_context", st);
00097 
00098     return 0;
00099 }
00100 
00101 /* Local Variables: */
00102 /* c-file-style: "iiim-project" */
00103 /* End: */
00104