Back to index

im-sdk  12.3.91
le_desktop.c
Go to the documentation of this file.
00001 #include <stdio.h>
00002 
00003 #include "wtt_isc.h"
00004 #include "le_desktop.h"
00005 
00006 extern LeInfoRec *le_info;
00007 
00008 /****************************************************************************/
00009 /*                         LE Desktop Context                               */
00010 /****************************************************************************/
00011 LeDesktopContextRec *le_desktop_context_new()
00012 {
00013     LeDesktopContextRec *le_desktop_context = NULL;
00014 
00015     le_desktop_context =
00016        (LeDesktopContextRec *) calloc(1, sizeof(LeDesktopContextRec));
00017     if (le_desktop_context == NULL)
00018        return (NULL);
00019 
00020     le_desktop_context->locale = NULL;
00021 
00022     le_desktop_context->default_conversion_status = 0;
00023     le_desktop_context->default_input_mode_id = 0;
00024     le_desktop_context->default_keyboard_id = 0;
00025 
00026     le_desktop_context->current_session = NULL;
00027 
00028     return (le_desktop_context);
00029 }
00030 
00031 LeResult le_desktop_context_destroy(LeDesktopContextRec *le_desktop_context)
00032 {
00033     if (le_desktop_context == NULL)
00034        return (LE_FAIL);
00035 
00036     if (le_desktop_context->locale)
00037        free((char *) le_desktop_context->locale);
00038 
00039     free((char *) le_desktop_context);
00040 
00041     return (LE_OK);
00042 }
00043 
00044 LeResult le_desktop_context_print(LeDesktopContextRec * le_desktop_context)
00045 {
00046     DEBUG_printf("le_desktop_context_print ==========\n");
00047 
00048     if (le_desktop_context == NULL)
00049        return (LE_FAIL);
00050 
00051     return (LE_OK);
00052 }
00053 
00054 LeResult le_desktop_context_set_current_session(LeDesktopContextRec *
00055                                           le_desktop_context,
00056                                           iml_session_t * s)
00057 {
00058     if (le_desktop_context == NULL)
00059        return (LE_FAIL);
00060 
00061     le_desktop_context->current_session = s;
00062     return (LE_OK);
00063 }
00064 
00065 iml_session_t *le_desktop_context_get_current_session(LeDesktopContextRec *
00066                                                 le_desktop_context)
00067 {
00068     if (le_desktop_context == NULL)
00069        return (NULL);
00070 
00071     return (le_desktop_context->current_session);
00072 }
00073 
00074 LeResult le_desktop_context_set_default_input_mode_id(LeDesktopContextRec *
00075                                               le_desktop_context,
00076                                               int default_input_mode_id)
00077 {
00078     if (le_desktop_context == NULL)
00079        return (LE_FAIL);
00080 
00081     if (default_input_mode_id < 0 || default_input_mode_id >= WTT_ISC_MODES_NUM)
00082        default_input_mode_id = WTT_ISC0;
00083 
00084     le_desktop_context->default_input_mode_id = default_input_mode_id;
00085     return (LE_OK);
00086 }
00087 
00088 int le_desktop_context_get_default_input_mode_id(LeDesktopContextRec *
00089                                            le_desktop_context)
00090 {
00091     if (le_desktop_context == NULL)
00092        return (0);
00093 
00094     return (le_desktop_context->default_input_mode_id);
00095 }
00096 
00097 int le_desktop_context_get_default_keyboard_id(LeDesktopContextRec *
00098                                           le_desktop_context)
00099 {
00100     if (le_desktop_context == NULL)
00101        return (0);
00102 
00103     return (le_desktop_context->default_keyboard_id);
00104 }
00105 
00106 int
00107 le_desktop_context_get_default_conversion_status(LeDesktopContextRec *
00108                                            le_desktop_context)
00109 {
00110     if (le_desktop_context == NULL)
00111        return (0);
00112 
00113     return (le_desktop_context->default_conversion_status);
00114 }
00115 
00116 LeResult le_desktop_context_set_locale(LeDesktopContextRec *
00117                                    le_desktop_context, char *locale)
00118 {
00119     if (le_desktop_context == NULL || locale == NULL)
00120        return (LE_FAIL);
00121 
00122     if (le_desktop_context->locale)
00123        free ((char *)le_desktop_context->locale);
00124 
00125     le_desktop_context->locale = (char *) strdup(locale);
00126     return (LE_OK);
00127 }
00128 
00129 char *le_desktop_context_get_locale(LeDesktopContextRec *
00130                                 le_desktop_context)
00131 {
00132     if (le_desktop_context == NULL)
00133        return (NULL);
00134 
00135     return (le_desktop_context->locale);
00136 }
00137 
00138 /****************************************************************************/
00139 /*                         LE Desktop                                       */
00140 /****************************************************************************/
00141 LeDesktopContextRec *le_desktop_create(iml_desktop_t * desktop)
00142 {
00143     LeDesktopContextRec *le_desktop_context = NULL;
00144 
00145     le_desktop_context = (LeDesktopContextRec *) le_desktop_context_new();
00146     DEBUG_printf("le_desktop_create ===== %p\n", le_desktop_context);
00147 
00148     le_desktop_context_print(le_desktop_context);
00149 
00150     desktop->specific_data = (void *) le_desktop_context;
00151 
00152     return (le_desktop_context);
00153 }
00154 
00155 LeResult le_desktop_destroy(iml_desktop_t * desktop)
00156 {
00157     LeDesktopContextRec *le_desktop_context =
00158        (LeDesktopContextRec *) desktop->specific_data;
00159 
00160     return (le_desktop_context_destroy(le_desktop_context));
00161 }