#include "erregtypes.h"
#include "erregxml.h"
#include "erreg.h"
Go to the source code of this file.
Copyright (C) 2007 iRex Technologies B.V. All rights reserved.
Definition in file erregbasis.h.
#define DEFAULT_STARTUP_BEHAVIOUR recentDocuments_t |
Definition at line 42 of file erregbasis.h.
#define REG_BASIS_XML_FILE "registry.xml" |
Definition at line 39 of file erregbasis.h.
#define REG_BASIS_XSD_PATH TEMPLATE_DIR "/registry.xsd" |
Definition at line 40 of file erregbasis.h.
void basisRegAddPCProfileToList | ( | regPCConfig_t ** | pPCConfig, | |
regPCProfile_t *** | pPCs, | |||
regPCProfile_t * | pNewPCProfile | |||
) |
Definition at line 378 of file erregbasis.c.
00380 { 00381 ERREG_BASIS_LOGPRINTF("entry"); 00382 00383 regPCConfig_t *pNewPCConfig = NULL, *pOldPCConfig = NULL; 00384 regPCProfile_t **pNewPCs = NULL, **pOldPCs = NULL; 00385 int i; 00386 00387 pOldPCConfig = *pPCConfig; 00388 pOldPCs = *pPCs; 00389 00390 // update the pNewPCConfig 00391 pNewPCConfig = basisRegNewPCConfig(pOldPCConfig->size+1); 00392 00393 // update the pNewPCs 00394 pNewPCs = g_new0(regPCProfile_t *, pNewPCConfig->size); 00395 for (i = 0; i < pOldPCConfig->size; i++) 00396 { 00397 pNewPCs[i] = pOldPCs[i]; 00398 } 00399 pNewPCs[pNewPCConfig->size - 1] = pNewPCProfile; 00400 00401 // free the memory 00402 regFreePCConfig(pOldPCConfig); 00403 g_free(pOldPCs); 00404 00405 // return 00406 *pPCConfig = pNewPCConfig; 00407 *pPCs = pNewPCs; 00408 }
void basisRegDeletePCProfileFromList | ( | regPCConfig_t ** | pPCConfig, | |
regPCProfile_t *** | pPCs, | |||
const char * | ID | |||
) |
Definition at line 414 of file erregbasis.c.
00416 { 00417 ERREG_BASIS_LOGPRINTF("entry"); 00418 00419 regPCConfig_t *pNewPCConfig = NULL, *pOldPCConfig = NULL; 00420 regPCProfile_t **pNewPCs = NULL, **pOldPCs = NULL; 00421 int i, index; 00422 00423 pOldPCConfig = *pPCConfig; 00424 pOldPCs = *pPCs; 00425 00426 // update the pNewPCConfig 00427 pNewPCConfig = basisRegNewPCConfig(pOldPCConfig->size-1); 00428 00429 // update the pNewPCs 00430 pNewPCs = g_new0(regPCProfile_t *, pNewPCConfig->size); 00431 00432 regPCProfile_t *pPCProfile = basisRegGetPCProfileFromList(pOldPCConfig, pOldPCs, ID, &index); 00433 00434 for (i = 0; i < index; i++) 00435 { 00436 pNewPCs[i] = pOldPCs[i]; 00437 } 00438 00439 for (i = index + 1; i < pOldPCConfig->size; i++) 00440 { 00441 pPCProfile = pOldPCs[i]; 00442 pNewPCs[i - 1] = pPCProfile; 00443 } 00444 00445 // free the memory 00446 regFreePCConfig(pOldPCConfig); 00447 regFreePCProfile(pOldPCs[index]); 00448 g_free(pOldPCs); 00449 00450 // return 00451 *pPCConfig = pNewPCConfig; 00452 *pPCs = pNewPCs; 00453 }
void basisRegDestroyXpathList | ( | regRegistry_t * | pRegistry | ) |
Definition at line 165 of file erregbasis.c.
00166 { 00167 ERREG_BASIS_LOGPRINTF("entry"); 00168 g_assert(pRegistry); 00169 00170 g_free(pRegistry->xpaths); 00171 pRegistry->xpaths = NULL; 00172 }
regPCProfile_t* basisRegGetPCProfileFromList | ( | regPCConfig_t * | pPCConfig, | |
regPCProfile_t ** | pPCs, | |||
const char * | ID, | |||
int * | index | |||
) |
Definition at line 346 of file erregbasis.c.
00348 { 00349 ERREG_BASIS_LOGPRINTF("entry"); 00350 00351 int i; 00352 gboolean bExist = FALSE; 00353 regPCProfile_t *thePCProfile = NULL; 00354 00355 // get the index by walking through the pcList 00356 for (i = 0; i < pPCConfig->size; i++) 00357 { 00358 if (!strcmp(pPCConfig->pcList[i], ID)) 00359 { 00360 bExist = TRUE; 00361 *index = i; 00362 break; 00363 } 00364 } 00365 00366 if (bExist) 00367 { 00368 thePCProfile = pPCs[*index]; 00369 } 00370 00371 return thePCProfile; 00372 }
void basisRegInitXpathList | ( | regRegistry_t * | pRegistry | ) |
Definition at line 140 of file erregbasis.c.
00141 { 00142 ERREG_BASIS_LOGPRINTF("entry"); 00143 g_assert(pRegistry); 00144 00145 xpathList_t *xpaths = g_new0(xpathList_t, 1); 00146 g_assert(xpaths); 00147 00148 xpaths->version = "/" EL_REGISTRY_ROOT "/" EL_VERSION; 00149 xpaths->userProfile = "/" EL_REGISTRY_ROOT "/" EL_USER_PROFILE; 00150 xpaths->userSetting = "/" EL_REGISTRY_ROOT "/" EL_USER_SETTING; 00151 xpaths->pcProfiles = "/" EL_REGISTRY_ROOT "/" EL_PC_PROFILES; 00152 xpaths->pcProfile = "/" EL_REGISTRY_ROOT "/" EL_PC_PROFILES "/" EL_PC_PROFILE; 00153 xpaths->autoConnect = "/" EL_REGISTRY_ROOT "/" EL_AUTO_CONNECT; 00154 xpaths->category = "/" EL_REGISTRY_ROOT "/" EL_CATEGORIES "/" EL_CATEGORY; 00155 xpaths->usbExport = "/" EL_REGISTRY_ROOT "/" EL_EXPORT_MEMORYTYPE; 00156 xpaths->lastRead = "/" EL_REGISTRY_ROOT "/" EL_LASTREADS "/" EL_LASTREAD; 00157 xpaths->application = "/" EL_REGISTRY_ROOT "/" EL_APPLICATIONS "/" EL_APPLICATION; 00158 xpaths->extensionInfos = "/" EL_REGISTRY_ROOT "/" EL_EXTENSION_INFOS; 00159 xpaths->extensionInfo = "/" EL_REGISTRY_ROOT "/" EL_EXTENSION_INFOS "/" EL_EXTENSION_INFO; 00160 xpaths->startup = "/" EL_REGISTRY_ROOT "/" EL_START_UP; 00161 00162 pRegistry->xpaths = xpaths; 00163 }
regLoad_t basisRegLoad | ( | regRegistry_t ** | ppRegistry | ) |
Definition at line 250 of file erregbasis.c.
00251 { 00252 ERREG_BASIS_LOGPRINTF("entry"); 00253 00254 const char* path_registry = REG_DIR "/" REG_BASIS_XML_FILE; 00255 const char* path_template = TEMPLATE_DIR "/" REG_BASIS_XML_FILE; 00256 const char* path_xsd = REG_BASIS_XSD_PATH; 00257 00258 regRegistry_t* pRegistry = NULL; 00259 int ret = loadOk_t; 00260 00261 // load normal registry file 00262 pRegistry = regParseFiles(path_registry, path_xsd); 00263 if (pRegistry) 00264 { 00265 ERREG_BASIS_LOGPRINTF("Loading basis registry succeeded."); 00266 ret = loadOk_t; 00267 } 00268 else 00269 { 00270 // open failed: try template registry 00271 pRegistry = regParseFiles(path_template, path_xsd); 00272 if (pRegistry) 00273 { 00274 ERREG_BASIS_WARNPRINTF("Loading basis registry failed, " 00275 "but loading template registry succeeded."); 00276 ret = loadTemplate_t; 00277 } 00278 else 00279 { 00280 // open failed: try minimum set 00281 ERREG_BASIS_ERRORPRINTF("Loading basis registry failed " 00282 "and loading template failed."); 00283 pRegistry = basisRegLoadFromMinSet(); 00284 if (pRegistry) 00285 { 00286 ret = loadMinSet_t; 00287 } 00288 else 00289 { 00290 ERREG_BASIS_ERRORPRINTF("Loading basis registry " 00291 "and template and minset failed."); 00292 ret = loadError_t; 00293 } 00294 } 00295 00296 // store the recovered registry values 00297 if (pRegistry) 00298 { 00299 pRegistry->changed = TRUE; 00300 if (erRegGetLockState() == lock_write) 00301 { 00302 regStore(pRegistry, path_registry); 00303 } 00304 } 00305 } 00306 00307 // add frequently used xpaths 00308 if (pRegistry) 00309 { 00310 basisRegInitXpathList(pRegistry); 00311 } 00312 00313 *ppRegistry = pRegistry; 00314 return ret; 00315 }
regPCConfig_t* basisRegNewPCConfig | ( | int | size | ) |
Definition at line 214 of file erregbasis.c.
00215 { 00216 ERREG_BASIS_LOGPRINTF("entry"); 00217 00218 regPCConfig_t *thePCConfig = NULL; 00219 00220 thePCConfig = g_new0(regPCConfig_t, 1); 00221 if (thePCConfig) 00222 { 00223 int i = 0; 00224 00225 thePCConfig->size = size; 00226 thePCConfig->pcList = g_new0(char *, thePCConfig->size + 1); 00227 for (i = 0; i < size; i++) 00228 { 00229 thePCConfig->pcList[i] = g_strdup_printf("PC_%d", i); 00230 } 00231 thePCConfig->pcList[size] = NULL; 00232 } 00233 else 00234 { 00235 ERREG_BASIS_ERRORPRINTF("memory allocation error"); 00236 } 00237 00238 regDumpPCConfig(thePCConfig); 00239 00240 return thePCConfig; 00241 }
regUserProfile_t* basisRegNewUserProfile | ( | void | ) |
void basisRegRecover | ( | regLoad_t | source | ) |
void basisRegSetPCProfileDefault | ( | regPCConfig_t ** | pPCConfig, | |
regPCProfile_t *** | pPCs, | |||
const char * | ID | |||
) |
Definition at line 457 of file erregbasis.c.
00459 { 00460 ERREG_BASIS_LOGPRINTF("entry"); 00461 00462 regPCConfig_t *pOldPCConfig = NULL; 00463 regPCProfile_t **pNewPCs = NULL, **pOldPCs = NULL; 00464 int i, index; 00465 00466 pOldPCConfig = *pPCConfig; 00467 pOldPCs = *pPCs; 00468 00469 // update the pNewPCs 00470 pNewPCs = g_new0(regPCProfile_t *, pOldPCConfig->size); 00471 00472 regPCProfile_t *pPCProfile = basisRegGetPCProfileFromList(pOldPCConfig, pOldPCs, ID, &index); 00473 for (i = 0; i < pOldPCConfig->size; i++) 00474 { 00475 pPCProfile = pOldPCs[i]; 00476 00477 if (i < index) 00478 { 00479 pNewPCs[i + 1] = pOldPCs[i]; 00480 } 00481 else if (i == index) 00482 { 00483 pNewPCs[0] = pPCProfile; 00484 } 00485 else // if (i > index) 00486 { 00487 pNewPCs[i] = pOldPCs[i]; 00488 } 00489 } 00490 00491 // free the memory 00492 g_free(pOldPCs); 00493 00494 // return 00495 *pPCs = pNewPCs; 00496 }
gboolean basisRegStore | ( | regRegistry_t * | pRegistry | ) |
Definition at line 330 of file erregbasis.c.
00331 { 00332 g_assert(pRegistry); 00333 00334 return regStore(pRegistry, REG_DIR "/" REG_BASIS_XML_FILE); 00335 }
void basisRegUnload | ( | regRegistry_t * | pRegistry | ) |
Definition at line 318 of file erregbasis.c.
00319 { 00320 ERREG_BASIS_LOGPRINTF("entry"); 00321 00322 if (pRegistry) 00323 { 00324 basisRegDestroyXpathList(pRegistry); 00325 regDestroy(pRegistry); 00326 } 00327 }