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 "le_desktop.h"
00004 
00005 /****************************************************************************/
00006 /*                         LE Desktop Context                               */
00007 /****************************************************************************/
00008 LeDesktopContextRec *le_desktop_context_new()
00009 {
00010     LeDesktopContextRec *le_desktop_context = NULL;
00011 
00012     le_desktop_context =
00013        (LeDesktopContextRec *) calloc(1, sizeof(LeDesktopContextRec));
00014     if (le_desktop_context == NULL)
00015        return NULL;
00016 
00017     le_desktop_context->locale = NULL;
00018 
00019     le_desktop_context->current_session = NULL;
00020 
00021     return le_desktop_context;
00022 }
00023 
00024 LeResult le_desktop_context_destroy(LeDesktopContextRec *le_desktop_context)
00025 {
00026     if (le_desktop_context == NULL)
00027        return LE_FAIL;
00028 
00029     if (le_desktop_context->locale)
00030        free((char *) le_desktop_context->locale);
00031 
00032     free((char *) le_desktop_context);
00033 
00034     return LE_OK;
00035 }
00036 
00037 LeResult le_desktop_context_print(LeDesktopContextRec * le_desktop_context)
00038 {
00039     DEBUG_printf("le_desktop_context_print ==========\n");
00040 
00041     if (le_desktop_context == NULL)
00042        return LE_FAIL;
00043 
00044     return LE_OK;
00045 }
00046 
00047 LeResult le_desktop_context_set_current_session(LeDesktopContextRec *
00048                                           le_desktop_context,
00049                                           iml_session_t * s)
00050 {
00051     if (le_desktop_context == NULL)
00052        return LE_FAIL;
00053 
00054     le_desktop_context->current_session = s;
00055     return LE_OK;
00056 }
00057 
00058 iml_session_t *le_desktop_context_get_current_session(LeDesktopContextRec *
00059                                                 le_desktop_context)
00060 {
00061     if (le_desktop_context == NULL)
00062        return NULL;
00063 
00064     return (le_desktop_context->current_session);
00065 }
00066 
00067 LeResult le_desktop_context_set_locale(LeDesktopContextRec *
00068                                    le_desktop_context,
00069                                    char *locale)
00070 {
00071     if (le_desktop_context == NULL || locale == NULL)
00072        return LE_FAIL;
00073 
00074     le_desktop_context->locale = (char *)strdup(locale);
00075     return LE_OK;
00076 }
00077 
00078 char *le_desktop_context_get_locale(LeDesktopContextRec *
00079                                 le_desktop_context)
00080 {
00081     if (le_desktop_context == NULL)
00082        return NULL;
00083 
00084     return (le_desktop_context->locale);
00085 }
00086 
00087 /****************************************************************************/
00088 /*                         LE Desktop                                       */
00089 /****************************************************************************/
00090 LeResult le_desktop_create(iml_desktop_t * desktop)
00091 {
00092     LeDesktopContextRec *le_desktop_context = NULL;
00093 
00094     le_desktop_context = (LeDesktopContextRec *) le_desktop_context_new();
00095     DEBUG_printf("le_desktop_create ===== %p\n", le_desktop_context);
00096 
00097     le_desktop_context_print(le_desktop_context);
00098 
00099     desktop->specific_data = (void *) le_desktop_context;
00100 
00101     return LE_OK;
00102 }
00103 
00104 LeResult le_desktop_destroy(iml_desktop_t * desktop)
00105 {
00106     LeDesktopContextRec *le_desktop_context =
00107        (LeDesktopContextRec *) desktop->specific_data;
00108 
00109     le_desktop_context_destroy(le_desktop_context);
00110 
00111     desktop->specific_data = NULL;
00112 
00113     return LE_OK;
00114 }