00001 /* 00002 * This file is part of liberregxml. 00003 * 00004 * liberregxml is free software: you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation, either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * liberregxml is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 00029 #include <stdio.h> 00030 #include <stdlib.h> 00031 #include <string.h> 00032 #include <glib.h> 00033 00034 #include "erreglog.h" 00035 #include "erreg.h" 00036 #include "erregtoolbar.h" 00037 #include "erregtypes_f.h" 00038 #include "erregxml.h" 00039 00040 static void tbRegInitXpathList(regRegistry_t * pRegistry) 00041 { 00042 ERREG_TOOLBAR_LOGPRINTF("entry[%p]", pRegistry); 00043 g_assert(pRegistry); 00044 00045 xpathList_t *xpaths = g_new0(xpathList_t, 1); 00046 g_assert(xpaths); 00047 00048 xpaths->toolbarIcons = "/" EL_REGISTRY_ROOT "/" EL_TOOLBAR_ICONS; 00049 xpaths->toolbarIcon = "/" EL_REGISTRY_ROOT "/" EL_TOOLBAR_ICONS "/" EL_TOOLBAR_ICON; 00050 00051 pRegistry->xpaths = xpaths; 00052 } 00053 00054 static void tbRegDestroyXpathList(regRegistry_t * pRegistry) 00055 { 00056 ERREG_TOOLBAR_LOGPRINTF("entry[%p]", pRegistry); 00057 g_assert(pRegistry); 00058 00059 g_free(pRegistry->xpaths); 00060 pRegistry->xpaths = NULL; 00061 } 00062 00063 regLoad_t tbRegLoad(regRegistry_t** ppRegistry) 00064 { 00065 ERREG_TOOLBAR_LOGPRINTF("entry"); 00066 00067 regRegistry_t* pRegistry = NULL; 00068 regLoad_t ret; 00069 00070 pRegistry = regParseFiles(REG_TOOLBAR_XML_PATH, REG_TOOLBAR_XSD_PATH); 00071 if (pRegistry) 00072 { 00073 ERREG_TOOLBAR_LOGPRINTF("Loading toolbar registry succeeded."); 00074 ret = loadOk_t; 00075 } 00076 else 00077 { 00078 ERREG_TOOLBAR_ERRORPRINTF("Loading toolbar registry failed."); 00079 ret = loadError_t; 00080 } 00081 00082 if (pRegistry) 00083 { 00084 tbRegInitXpathList(pRegistry); 00085 } 00086 00087 *ppRegistry = pRegistry; 00088 return ret; 00089 } 00090 00091 void tbRegUnload(regRegistry_t* pRegistry) 00092 { 00093 ERREG_TOOLBAR_LOGPRINTF("entry[%p]", pRegistry); 00094 00095 if (pRegistry) 00096 { 00097 tbRegDestroyXpathList(pRegistry); 00098 regDestroy(pRegistry); 00099 } 00100 } 00101 00102 regIconSet_t* tbRegGetIconSet(regRegistry_t * pRegistry) 00103 { 00104 ERREG_TOOLBAR_LOGPRINTF("entry"); 00105 00106 regIconSet_t *theIconSet = NULL; 00107 00108 if (pRegistry) 00109 { 00110 theIconSet = regGetIconSet(pRegistry); 00111 } 00112 00113 return theIconSet; 00114 } 00115 00116 void tbRegFreeIconSet(regIconSet_t * theIconSet) 00117 { 00118 ERREG_TOOLBAR_LOGPRINTF("entry"); 00119 00120 if (theIconSet) 00121 { 00122 regFreeIconSet(theIconSet); 00123 } 00124 } 00125