Back to index

im-sdk  12.3.91
xaux_object_interface.c
Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include "xaux_object.h"
00003 
00004 static int xaux_so_Create(aux_t *);
00005 static int xaux_so_Start(aux_t *, const unsigned char *, int size);
00006 static int xaux_so_Draw(aux_t *, const unsigned char *, int size);
00007 static int xaux_so_Done(aux_t *, const unsigned char *, int size);
00008 static int xaux_so_Switched(aux_t *, int im_id, int on_off);
00009 static int xaux_so_Destroy(aux_t *);
00010 static int xaux_so_GetValuesReply(aux_t *, const unsigned char *, int);
00011 static int xaux_so_DestroyIC(aux_t *);
00012 static int xaux_so_SetICForcus(aux_t *);
00013 static int xaux_so_UnsetICForcus(aux_t *);
00014 
00015 aux_method_t xaux_so_methods = {
00016        xaux_so_Create,
00017        xaux_so_Start,
00018        xaux_so_Draw,
00019        xaux_so_Done,
00020        xaux_so_Switched,
00021        xaux_so_Destroy,
00022        xaux_so_GetValuesReply,
00023        xaux_so_DestroyIC,
00024        xaux_so_SetICForcus,
00025        xaux_so_UnsetICForcus
00026 };
00027 
00028 #ifdef USE_AUX_IF_VERSION_2 
00029 
00030 static Bool register_aux_modules(unsigned int if_version, aux_service_t *service);
00031 
00032 aux_info_t aux_info = { 
00033        AUX_IF_VERSION_2,    /* if_version       */
00034        register_aux_modules,       /* register_service */
00035        NULL                 /* aux_dir          */
00036 };
00037 
00038 extern aux_dir_t *aux_dir_init();
00039 
00040 static Bool register_aux_modules(unsigned int if_version, aux_service_t *service)
00041 {
00042        DEBUG_printf("register_service =========================\n");
00043 
00044        /* get aux_object module informations */
00045        aux_info.dir = (aux_dir_t *)aux_dir_init();
00046        return (True);
00047 }
00048 
00049 #endif
00050 
00051 extern xaux_class_t xaux_classes[];
00052 
00053 static xaux_object_t *xaux_object_inst = NULL;
00054 
00055 /* to avoid memory leak problem since xaux_so_Destroy is not called */
00056 #ifndef USE_XAUX_OBJECT_MALLOC
00057 static xaux_object_t xaux_object_real;
00058 #endif
00059 
00060 static int xaux_so_Create(aux_t *aux)
00061 {
00062        DEBUG_printf("xaux_so_Create aux: 0x%x======================\n", aux);
00063 
00064        /* initialize some communication atoms and start aux manager */
00065        if (xaux_object_inst != NULL)
00066               return (True);
00067 
00068 #ifdef USE_XAUX_OBJECT_MALLOC
00069        xaux_object_inst = (xaux_object_t *)xaux_object_new();
00070        if (xaux_object_inst == NULL)
00071               return (False);
00072 #else
00073        xaux_object_inst = &xaux_object_real;
00074        memset(xaux_object_inst, 0, sizeof (xaux_object_t));
00075 #endif
00076 
00077        return (xaux_object_init(xaux_object_inst, aux, XAUX_OBJECT_CLASS_NAME, xaux_classes));
00078 }
00079 
00080 static int xaux_so_Start(aux_t *aux, const unsigned char *p, int size)
00081 {
00082        aux_data_t *aux_data;
00083        char *classname;
00084 
00085        DEBUG_printf("xaux_so_Start aux: 0x%x======================\n", aux);
00086 
00087        aux_data = aux->service->decompose(AUX_DATA_START, p);
00088        if (aux_data == NULL) return(False);
00089 
00090        /* get aux classname */
00091         classname = (char *)xaux_object_get_classname_from_utfname((const CARD16 *)aux_data->aux_name,
00092                                                            aux_data->aux_name_length);
00093 
00094        DEBUG_printf("so_Start[%s] im:0x%x ic:0x%x\n",
00095               classname, aux_data->im, aux_data->ic);
00096 
00097        xaux_object_draw_aux_module(xaux_object_inst, aux, classname, aux_data, AUX_DATA_START);
00098 
00099        aux->service->decompose_free(aux_data);
00100         if (classname) free((char *)classname);
00101 
00102        return (True);
00103 }
00104 
00105 static int xaux_so_Draw(aux_t *aux, const unsigned char *p, int size)
00106 {
00107        aux_data_t *aux_data;
00108        char *classname;
00109 
00110        DEBUG_printf("xaux_so_Draw aux: 0x%x======================\n", aux);
00111 
00112        aux_data = aux->service->decompose(AUX_DATA_DRAW, p);
00113        if (aux_data == NULL) return(False);
00114 
00115        /* get aux classname */
00116         classname = (char *)xaux_object_get_classname_from_utfname((const CARD16 *)aux_data->aux_name,
00117                                                            aux_data->aux_name_length);
00118 
00119        DEBUG_printf("so_Draw: integer_count:%d, string_count:%d\n",
00120                      aux_data->integer_count,aux_data->string_count);
00121 
00122        xaux_object_draw_aux_module(xaux_object_inst, aux, classname, aux_data, AUX_DATA_DRAW);
00123 
00124        aux->service->decompose_free(aux_data);
00125         if (classname) free((char *)classname);
00126 
00127        return (True);
00128 }
00129 
00130 static int xaux_so_Done(aux_t* aux, const unsigned char *p, int size)
00131 {
00132        aux_data_t    * aux_data;
00133        char *classname;
00134 
00135        DEBUG_printf("xaux_so_Done aux: 0x%x======================\n", aux);
00136 
00137        aux_data = aux->service->decompose(AUX_DATA_DONE, p);
00138        if (aux_data == NULL) return(False);
00139 
00140        /* get aux classname */
00141         classname = (char *)xaux_object_get_classname_from_utfname((const CARD16 *)aux_data->aux_name,
00142                                                            aux_data->aux_name_length);
00143 
00144        DEBUG_printf("so_Done[%s] im:0x%x ic:0x%x\n",
00145               classname, aux_data->im, aux_data->ic);
00146 
00147        xaux_object_draw_aux_module(xaux_object_inst, aux, classname, aux_data, AUX_DATA_DONE);
00148 
00149        aux->service->decompose_free(aux_data);
00150         if (classname) free((char *)classname);
00151 
00152        return (True);
00153 }
00154 
00155 static int xaux_so_Switched(aux_t* aux, int im_id, int on_off)
00156 {
00157        return (True);
00158 }
00159 
00160 static int xaux_so_Destroy(aux_t* aux)
00161 {
00162        DEBUG_printf("xaux_so_Destroy ====== \n");
00163        xaux_object_destroy(xaux_object_inst);
00164 
00165 #ifdef USE_XAUX_OBJECT_MALLOC
00166        free ((char *)xaux_object_inst);
00167 #endif
00168        xaux_object_inst = NULL;
00169        return (True);
00170 }
00171 
00172 static int xaux_so_GetValuesReply(aux_t *aux, const unsigned char *p, int size)
00173 {
00174        return (True);
00175 }
00176 
00177 static int xaux_so_DestroyIC(aux_t *aux)
00178 {
00179        DEBUG_printf("xaux_so_DestroyIC ====== \n");
00180        return (True);
00181 }
00182 
00183 static int xaux_so_SetICForcus(aux_t *aux)
00184 {
00185        return (True);
00186 }
00187 
00188 static int xaux_so_UnsetICForcus(aux_t *aux)
00189 {
00190        return (True);
00191 }