settings/src/iLiadArcLocData.h File Reference

settings - Archive Location Data More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  arcLocData_t
struct  mediaPath_t
struct  arcPath_t

Enumerations

enum  arcType_e {
  arcNews = 0, arcBooks, arcDocs, arcNotes,
  arcTypeUndefined
}
enum  arcLocType_e {
  arcLocMain = 0, arcLocCard, arcLocUSB, arcLocCF,
  arcLocUndefined
}

Functions

void iLiad_archive_location_data_init (void)
void iLiad_archive_location_data_destroy (void)
void iLiad_archive_location_data_store (void)
void iLiad_archive_location_data_set (arcType_e arc, arcLocType_e location)
void iLiad_export_location_data_set (arcLocType_e location)
arcLocType_e iLiad_archive_location_data_get (arcType_e arc)
arcLocType_e iLiad_export_location_data_get ()


Detailed Description

settings - Archive Location Data

Copyright (C) 2005-2008 iRex Technologies B.V. All rights reserved.

Providing archive location data functions.

Definition in file iLiadArcLocData.h.


Enumeration Type Documentation

Enumerator:
arcLocMain 
arcLocCard 
arcLocUSB 
arcLocCF 
arcLocUndefined 

Definition at line 48 of file iLiadArcLocData.h.

00049 {
00050     arcLocMain = 0,
00051     arcLocCard,
00052     arcLocUSB,
00053     arcLocCF,
00054     arcLocUndefined
00055 } arcLocType_e;

enum arcType_e

Enumerator:
arcNews 
arcBooks 
arcDocs 
arcNotes 
arcTypeUndefined 

Definition at line 39 of file iLiadArcLocData.h.

00040 {
00041     arcNews = 0,
00042     arcBooks,
00043     arcDocs,
00044     arcNotes,
00045     arcTypeUndefined
00046 } arcType_e;


Function Documentation

void iLiad_archive_location_data_destroy ( void   ) 

Definition at line 102 of file iLiadArcLocData.c.

00103 {
00104     ST_LOGPRINTF("entry");
00105 
00106     if (g_cur_settings)
00107     {
00108         g_free(g_cur_settings);
00109         g_cur_settings = NULL;
00110     }
00111 
00112     if (g_stored_settings)
00113     {
00114         g_free(g_stored_settings);
00115         g_stored_settings = NULL;
00116     }
00117 
00118     if (g_arc_paths)
00119     {
00120         freeArcPaths(g_arc_paths);
00121         g_arc_paths = NULL;
00122     }
00123 
00124     if (g_media_paths)
00125     {
00126         freeMediaPaths(g_media_paths);
00127         g_media_paths = NULL;
00128     }
00129 
00130     if (g_cur_export_settings)
00131     {
00132         erRegFreeExportMemType(g_cur_export_settings);
00133         g_cur_export_settings = NULL;
00134     }
00135 
00136     if (g_stored_export_settings)
00137     {
00138         erRegFreeExportMemType(g_stored_export_settings);
00139         g_stored_export_settings = NULL;
00140     }
00141 }

Here is the call graph for this function:

arcLocType_e iLiad_archive_location_data_get ( arcType_e  arc  ) 

Definition at line 335 of file iLiadArcLocData.c.

00336 {
00337     ST_LOGPRINTF("arc=%d", arc);
00338 
00339     arcLocType_e location = arcLocMain;
00340 
00341     if (g_cur_settings)
00342     {
00343         switch (arc)
00344         {
00345             case arcNews:
00346                 location = g_cur_settings->newsLoc;
00347                 break;
00348             case arcBooks:
00349                 location = g_cur_settings->booksLoc;
00350                 break;
00351             case arcDocs:
00352                 location = g_cur_settings->docsLoc;
00353                 break;
00354             case arcNotes:
00355                 location = g_cur_settings->notesLoc;
00356                 break;
00357             default:
00358                 ST_ERRORPRINTF("error:arc=%d", arc);
00359         }
00360     }
00361     else
00362     {
00363         ST_WARNPRINTF("g_cur_settings == NULL");
00364     }
00365 
00366     return location;
00367 }

void iLiad_archive_location_data_init ( void   ) 

Definition at line 69 of file iLiadArcLocData.c.

00070 {
00071     ST_LOGPRINTF("entry");
00072 
00073     iLiad_archive_location_data_destroy();
00074 
00075     g_cur_settings = g_new0(arcLocData_t, 1);
00076     if (g_cur_settings != NULL)
00077     {
00078         g_arc_paths = getArcPaths();
00079         g_media_paths = getMediaPaths();
00080         
00081         arcPathToArcLocData(g_arc_paths, g_cur_settings);
00082         g_stored_settings = arcLocDataDup(g_cur_settings);
00083     }
00084     else
00085     {
00086         ST_ERRORPRINTF("memory allocation error");
00087     }
00088 
00089     g_cur_export_settings = erRegGetExportMemType();
00090     if (g_cur_export_settings == NULL)
00091     {
00092         g_cur_export_settings = g_new0(regExportMemType_t, 1);
00093         g_assert(NULL != g_cur_export_settings);
00094 
00095         // Use internal memory as default
00096         g_cur_export_settings->location = g_strdup(MAIN_CATEGORY);
00097     }
00098 
00099     g_stored_export_settings = export_settings_dup(g_cur_export_settings);
00100 }

Here is the call graph for this function:

void iLiad_archive_location_data_set ( arcType_e  arc,
arcLocType_e  location 
)

Definition at line 304 of file iLiadArcLocData.c.

00305 {
00306     ST_LOGPRINTF("arc=%d, location=%d", arc, location);
00307 
00308     g_return_if_fail(g_cur_settings != NULL);
00309 
00310     if ((location < arcLocMain) || (location >= arcLocUndefined))
00311     {
00312         ST_WARNPRINTF("invalid location value and use the default value(%d)", arcLocMain);
00313         location = arcLocMain;
00314     }
00315 
00316     switch (arc)
00317     {
00318         case arcNews:
00319             g_cur_settings->newsLoc = location;
00320             break;
00321         case arcBooks:
00322             g_cur_settings->booksLoc = location;
00323             break;
00324         case arcDocs:
00325             g_cur_settings->docsLoc = location;
00326             break;
00327         case arcNotes:
00328             g_cur_settings->notesLoc = location;
00329             break;
00330         default:
00331             ST_ERRORPRINTF("error:arc=%d", arc);
00332     }
00333 }

void iLiad_archive_location_data_store ( void   ) 

Definition at line 143 of file iLiadArcLocData.c.

00144 {
00145     gboolean bSaveNews=FALSE, bSaveBooks=FALSE, bSaveDocs=FALSE, bSaveNotes=FALSE, bSaveExport=FALSE;
00146 
00147     ST_LOGPRINTF("entry");
00148     
00149     g_return_if_fail(NULL != g_cur_settings);
00150     g_return_if_fail(NULL != g_stored_settings);
00151    
00152     // need to save changes or not? 
00153     if (g_cur_settings->newsLoc != g_stored_settings->newsLoc)
00154     {
00155         bSaveNews = TRUE;
00156     }
00157    
00158     if (g_cur_settings->booksLoc != g_stored_settings->booksLoc)
00159     {
00160         bSaveBooks = TRUE;
00161     }
00162 
00163     if (g_cur_settings->docsLoc != g_stored_settings->docsLoc)
00164     {
00165         bSaveDocs = TRUE;
00166     }
00167 
00168     if (g_cur_settings->notesLoc != g_stored_settings->notesLoc)
00169     {
00170         bSaveNotes = TRUE;
00171     }
00172 
00173     if (strcmp(g_cur_export_settings->location, g_stored_export_settings->location) != 0)
00174     {
00175         bSaveExport = TRUE;
00176     }
00177     
00178     if (bSaveNews || bSaveBooks || bSaveDocs || bSaveNotes || bSaveExport)
00179     {
00180         ST_LOGPRINTF("entry %d %d %d %d %d", bSaveNews, bSaveBooks, bSaveDocs, bSaveNotes, bSaveExport);
00181         
00182         // save changes to registry
00183         prepare_registry_write();
00184 
00185         regContentCategory_t* category = NULL;
00186         arcPath_t* arcPaths= g_new0(arcPath_t, 1);
00187         arcLocDataToArcPath(g_cur_settings, arcPaths);
00188         
00189         if (bSaveNews)
00190         {
00191             // save the location of newspapers
00192             category = erRegGetContentCategory(NEWSPAPERS_CATEGORY);
00193             if (category && category->location)
00194             {
00195                 g_free(category->location);
00196                 category->location = g_strdup(arcPaths->newsPath);
00197                 erRegSetContentCategory(NEWSPAPERS_CATEGORY, category);
00198             }
00199             erRegFreeContentCategory(category);
00200             category = NULL;
00201         }
00202 
00203         if (bSaveBooks)
00204         {
00205             // save the location of books
00206             category = erRegGetContentCategory(BOOKS_CATEGORY);
00207             if (category && category->location)
00208             {
00209                 g_free(category->location);
00210                 category->location = g_strdup(arcPaths->booksPath);
00211                 erRegSetContentCategory(BOOKS_CATEGORY, category);
00212             }
00213             erRegFreeContentCategory(category);
00214             category = NULL;
00215         }
00216 
00217         if (bSaveDocs)
00218         {
00219             // save the location of docs
00220             category = erRegGetContentCategory(DOCUMENTS_CATEGORY);
00221             if (category && category->location)
00222             {
00223                 g_free(category->location);
00224                 category->location = g_strdup(arcPaths->docsPath);
00225                 erRegSetContentCategory(DOCUMENTS_CATEGORY, category);
00226             }
00227             erRegFreeContentCategory(category);
00228             category = NULL;
00229         }
00230 
00231         if (bSaveNotes)
00232         {
00233             // save the location of notes
00234             category = erRegGetContentCategory(NOTES_CATEGORY);
00235             if (category && category->location)
00236             {
00237                 g_free(category->location);
00238                 category->location = g_strdup(arcPaths->notesPath);
00239                 erRegSetContentCategory(NOTES_CATEGORY, category);
00240             }
00241             erRegFreeContentCategory(category);
00242             category = NULL;
00243         }
00244 
00245         if (bSaveExport)
00246         {
00247             if (!erRegSetExportMemType(g_cur_export_settings))
00248             {
00249                 ST_ERRORPRINTF("Error storing export settings");
00250             }
00251             else
00252             {
00253                 // success
00254                 erRegFreeExportMemType(g_stored_export_settings);
00255                 g_stored_export_settings = export_settings_dup(g_cur_export_settings);
00256             }
00257         }
00258        
00259         // free the memory 
00260         freeArcPaths(arcPaths);
00261         arcPaths = NULL; 
00262       
00263         // also update the g_stored_settings
00264         g_free(g_stored_settings);
00265         g_stored_settings = arcLocDataDup(g_cur_settings);
00266 
00267         do_registry_write();
00268     }
00269 }

Here is the call graph for this function:

arcLocType_e iLiad_export_location_data_get (  ) 

Definition at line 369 of file iLiadArcLocData.c.

00370 {
00371     ST_LOGPRINTF("entry");
00372 
00373     if (strcmp(g_cur_export_settings->location, MAIN_CATEGORY) == 0)
00374     {
00375         return arcLocMain;
00376     }
00377     else if (strcmp(g_cur_export_settings->location, SD_CATEGORY) == 0)
00378     {
00379         return arcLocCard;
00380     }
00381     else if (strcmp(g_cur_export_settings->location, USB_CATEGORY) == 0)
00382     {
00383         return arcLocUSB;
00384     }
00385     else if (strcmp(g_cur_export_settings->location, CF_CATEGORY) == 0)
00386     {
00387         return arcLocCF;
00388     }
00389     else
00390     {
00391         ST_ERRORPRINTF("Invalid location: %s", g_cur_export_settings->location);
00392 
00393         // Use internal memory as default
00394         return arcLocMain;
00395     }
00396 }

void iLiad_export_location_data_set ( arcLocType_e  location  ) 

Definition at line 271 of file iLiadArcLocData.c.

00272 {
00273     ST_LOGPRINTF("Set export memory types: location=%d", location);
00274 
00275     g_return_if_fail(g_cur_export_settings != NULL);
00276 
00277     if ((location < arcLocMain) || (location >= arcLocUndefined))
00278     {
00279         ST_WARNPRINTF("invalid location value and use the default value(%d)", arcLocMain);
00280         location = arcLocMain;
00281     }
00282 
00283     g_free(g_cur_export_settings->location);
00284     switch (location)
00285     {
00286         case arcLocMain:
00287             g_cur_export_settings->location = g_strdup(MAIN_CATEGORY);
00288             break;
00289         case arcLocCard:
00290             g_cur_export_settings->location = g_strdup(SD_CATEGORY);
00291             break;
00292         case arcLocUSB:
00293             g_cur_export_settings->location = g_strdup(USB_CATEGORY);
00294             break;
00295         case arcLocCF:
00296             g_cur_export_settings->location = g_strdup(CF_CATEGORY);
00297             break;
00298         default:
00299             g_assert_not_reached();
00300             break;
00301     }
00302 }


Generated on Sun Dec 14 17:17:00 2008 by  doxygen 1.5.6