contentLister/src/metadataStoreManager.c File Reference

metadataStoreManager - transfer for the meta data store (init and manage the metadata store) More...

#include <config.h>
#include <linux/limits.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <mntent.h>
#include <strings.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <liberregxml/erregapi.h>
#include <libermanifest/ermanifest.h>
#include "contentListerLog.h"
#include "lister.h"
#include "erConnect.h"
#include "system.h"
#include "gtkPincodeScreen.h"
#include "control.h"
#include "stack.h"
#include "metadataStoreManager.h"
#include "erMdsContent.h"
#include "regValue.h"
#include "languages.h"

Go to the source code of this file.

Functions

static void rootInfoInit (void)
static void rootInfoStore (st_ContentType_e type, regContentCategory_t *theContentCategory)
static void rootInfoDestroy (void)
static gboolean isRealPathSubFolder (const char *path, const char *basePath)
static void recreateArchives (st_ContentType_e storageType)
static char * getArchiveName (st_ContentType_e archiveType)
void mdsInit (void)
void mdsDestroy (void)
int mdsScanRoot (st_ContentType_e contentType)
int mdsScanCurrent (st_ContentType_e contentType)
int mdsScanNext (st_ContentType_e contentType, char *directory, unsigned int theIndex)
int mdsScanPrevious (st_ContentType_e contentType)
int mdsGetItemCount (void)
int mdsGetItemIndex (const gchar *szFilename)
gboolean mdsGetItemFilename (int index, gchar *szFilename, int len)
int mdsSetPageContent (clDisplayItem_t *displayItemArray, int nBegin, int *nChunk)
void mdsSetIndex (st_ContentType_e contentType, unsigned int index)
unsigned int mdsGetIndex (st_ContentType_e contentType)
mdsSortStruct_tmdsGetSortStructOfRootInfo (st_ContentType_e type)
void mdsSetSortStructOfRootInfo (st_ContentType_e type, const mdsSortStruct_t *sort)
char * getFieldString (mdsFieldType_e type)
mdsFieldType_e getFieldType (char *stringValue)
gchar * getContentCategoryID (st_ContentType_e type)
int mdsGetRootLocation (const st_ContentType_e contentType, char *location, const int length)
gboolean mdsArcLocIsChanged (st_ContentType_e archiveType, st_ContentType_e storageType)
void mdsRecreateArchives (st_ContentType_e storageType)
gboolean storageIsMounted (st_ContentType_e storageType)
void displayScanResult (void)

Variables

static GArray * g_contentArray = NULL
static stItem_tg_rootInfo [TOTAL_STACK_COUNT]


Detailed Description

metadataStoreManager - transfer for the meta data store (init and manage the metadata store)

<File description>="">

Definition in file metadataStoreManager.c.


Function Documentation

void displayScanResult ( void   ) 

Definition at line 1071 of file metadataStoreManager.c.

01072 {
01073     int     i;
01074     mdsFsItem_t *pFsItem;
01075 
01076     for (i = 0; i < g_contentArray->len; i++)
01077     {
01078         pFsItem = &g_array_index(g_contentArray, mdsFsItem_t, i);
01079         printf("%d. Name: %s", i, pFsItem->szFilename);
01080         printf("\ttype: %d\n", (int) pFsItem->fit);
01081     }
01082 }

static char * getArchiveName ( st_ContentType_e  archiveType  )  [static]

Definition at line 993 of file metadataStoreManager.c.

00994 {
00995     mdsDirectory_t *directory =  NULL;
00996     char* cp = NULL;
00997 
00998     if ((archiveType != st_ContentTypeNews) 
00999             && (archiveType != st_ContentTypeBooks)
01000             && (archiveType != st_ContentTypeDocs)
01001             && (archiveType != st_ContentTypeNotes))
01002     {
01003         CL_ERRORPRINTF("invalid archive type[%d]", archiveType);
01004         return NULL;
01005     }
01006 
01007     if ( g_rootInfo[archiveType] && g_rootInfo[archiveType]->dirArray)
01008     {
01009         directory = &g_array_index(g_rootInfo[archiveType]->dirArray,  mdsDirectory_t, 0);
01010         if (directory && directory->szFilename)
01011         {
01012             cp = strrchr(directory->szFilename, '/');
01013         }
01014     }
01015  
01016     CL_LOGPRINTF("%s", cp);
01017     return cp;
01018 }

gchar* getContentCategoryID ( st_ContentType_e  type  ) 

Definition at line 716 of file metadataStoreManager.c.

00717 {
00718     static gchar szID[ERMDS_MAX_EXTENSION_ID_SIZE+1] = "";
00719 
00720     switch (type)
00721     {
00722         case st_ContentTypeBooks:
00723             strcpy(szID, BOOKS_CATEGORY);
00724             break;
00725         case st_ContentTypeNews:
00726             strcpy(szID, NEWSPAPERS_CATEGORY);
00727             break;
00728         case st_ContentTypeNotes:
00729             strcpy(szID, NOTES_CATEGORY);
00730             break;
00731         case st_ContentTypeDocs:
00732             strcpy(szID, DOCUMENTS_CATEGORY);
00733             break;
00734         case st_StorageTypeCF:
00735             strcpy(szID, CF_CATEGORY);
00736             break;
00737         case st_StorageTypeMain:
00738             strcpy(szID, MAIN_CATEGORY);
00739             break;
00740         case st_StorageTypeSD:
00741             strcpy(szID, SD_CATEGORY);
00742             break;
00743         case st_StorageTypeUSB:
00744             strcpy(szID, USB_CATEGORY);
00745             break;
00746         case st_MenuTypeMode:
00747             strcpy(szID, MODE_CATEGORY);
00748             break;
00749         case st_DownloadHistory:
00750             strcpy(szID, DOWNLOAD_HISTORY);
00751             break;
00752         case st_SearchResult:
00753             strcpy(szID, SEARCH_RESULT);
00754             break;
00755         case st_RecentDocuments:
00756             strcpy(szID, RECENTDOCUMENTS);
00757             break;
00758         case st_ContentTypeUndefined:
00759         default:
00760             szID[0] = '\0';
00761             break;
00762     }
00763     return szID;
00764 }

char* getFieldString ( mdsFieldType_e  type  ) 

Definition at line 629 of file metadataStoreManager.c.

00630 {
00631     static char string[ERCL_MAX_FIELDNAME_SIZE+1];
00632 
00633     switch (type)
00634     {
00635        case mdsFieldAuthor:
00636            strcpy(string, AUTHOR);
00637            break;
00638        case mdsFieldDate:
00639             strcpy(string, DATE);
00640            break;
00641        case mdsFieldDescription:
00642             strcpy(string, DESCRIPTION);
00643             break;
00644        case mdsFieldFile:
00645             strcpy(string, FIELDFILE);
00646            break;
00647        case mdsFieldTitle:
00648             strcpy(string, TITLE);
00649             break;
00650        case mdsFieldFsName:
00651             strcpy(string, FSNAME);
00652             break;
00653         case mdsFieldExtName:
00654             strcpy(string, EXTENSION);
00655             break; 
00656         case mdsFieldSize:
00657             strcpy(string, SIZE);
00658             break;
00659         case mdsFieldNone:
00660         default:
00661             string[0] = '\0';
00662             break;
00663     }
00664     return string;
00665 }

mdsFieldType_e getFieldType ( char *  stringValue  ) 

Definition at line 667 of file metadataStoreManager.c.

00668 {
00669     if (stringValue)
00670     {
00671         //author - date - description - file - fsname - title - none 
00672         if (strcmp(stringValue, AUTHOR) == 0)
00673         {
00674             return mdsFieldAuthor;
00675         }
00676         else if (strcmp(stringValue, DATE) == 0)
00677         {
00678             return mdsFieldDate;
00679         }
00680         else if (strcmp(stringValue, FIELDFILE) == 0)
00681         {
00682             return mdsFieldFile;
00683         }
00684         else if (strcmp(stringValue, FSNAME) == 0)
00685         {
00686             return mdsFieldFsName;
00687         }
00688         else if (strcmp(stringValue, TITLE) == 0)
00689         {
00690             return mdsFieldTitle;
00691         }
00692         else if (strcmp(stringValue, DESCRIPTION) == 0)
00693         {
00694             return mdsFieldDescription;
00695         }
00696         else if (strcmp(stringValue, EXTENSION) == 0)
00697         {
00698             return mdsFieldExtName;
00699         }
00700         else if (strcmp(stringValue, SIZE) == 0)
00701         {
00702             return mdsFieldSize;
00703         }
00704         else
00705         {
00706             return mdsFieldNone;
00707         }
00708     }
00709     else
00710     {
00711         return mdsFieldNone;
00712     }
00713 
00714 }

static gboolean isRealPathSubFolder ( const char *  path,
const char *  basePath 
) [static]

Definition at line 905 of file metadataStoreManager.c.

00906 {
00907     char *cp1 = NULL, *cp2 = NULL;
00908     char realPath[ERMDS_MAX_FILENAME_SIZE], realBasePath[ERMDS_MAX_FILENAME_SIZE];
00909     gboolean bRet = FALSE;
00910 
00911     cp1 = realpath(path, realPath);
00912     cp2 = realpath(basePath, realBasePath);
00913     
00914     CL_LOGPRINTF("%s,%s", path, realPath);
00915     CL_LOGPRINTF("cp1=%s, cp2=%s", cp1, cp2);
00916     CL_LOGPRINTF("%s,%s", realPath, realBasePath);
00917 
00918     if (/*cp1 && cp2 && */strstr(realPath, realBasePath) != NULL)
00919     {
00920         CL_LOGPRINTF("realpath of %s is subfolder of realpath of %s", path, basePath);
00921         bRet = TRUE;
00922     }
00923     else
00924     {
00925         CL_LOGPRINTF("realpath of %s is not subfolder of realpath of %s", path, basePath);
00926     }
00927 
00928     return bRet;
00929 }

gboolean mdsArcLocIsChanged ( st_ContentType_e  archiveType,
st_ContentType_e  storageType 
)

Definition at line 825 of file metadataStoreManager.c.

00826 {
00827     char archiveDirName[ERMDS_MAX_FILENAME_SIZE], storageDirName[ERMDS_MAX_FILENAME_SIZE];
00828     gboolean bRet = FALSE;
00829     
00830     if ((archiveType != st_ContentTypeNews) 
00831             && (archiveType != st_ContentTypeBooks)
00832             && (archiveType != st_ContentTypeDocs)
00833             && (archiveType != st_ContentTypeNotes))
00834     {
00835         CL_ERRORPRINTF("invalid archive type[%d]", archiveType);
00836         return bRet;
00837     }
00838     if ((storageType != st_StorageTypeCF)
00839             && (storageType != st_StorageTypeSD)
00840             && (storageType != st_StorageTypeUSB)
00841             && (storageType != st_StorageTypeMain))
00842     {
00843         CL_ERRORPRINTF("invalid storage type[%d]", storageType);
00844         return bRet;
00845     }
00846               
00847     if ( mdsGetRootLocation(archiveType, archiveDirName, sizeof(archiveDirName)) > 0 )
00848     {
00849         if ( mdsGetRootLocation(storageType, storageDirName, sizeof(storageDirName)) > 0 )
00850         {
00851            CL_LOGPRINTF("%s,%s", archiveDirName, storageDirName);
00852            if (isRealPathSubFolder(archiveDirName, storageDirName))
00853            {
00854               bRet = TRUE;
00855            }
00856         }
00857         else
00858         {
00859             CL_ERRORPRINTF("error");
00860         }
00861     }
00862     else
00863     {
00864         CL_ERRORPRINTF("error");
00865     }
00866     return bRet;
00867 }

Here is the call graph for this function:

void mdsDestroy ( void   ) 

Destroy memory allocated by this module

Parameters:
- 
Returns:
-

Definition at line 93 of file metadataStoreManager.c.

00094 {
00095     rootInfoDestroy();
00096     stackDestroyAll();
00097 
00098     if (g_contentArray)
00099     {
00100         g_array_free(g_contentArray, TRUE);
00101         g_contentArray = NULL;
00102     }
00103 }

Here is the call graph for this function:

unsigned int mdsGetIndex ( st_ContentType_e  contentType  ) 

Retrieve the index field of the current top stack item

Definition at line 369 of file metadataStoreManager.c.

00370 {
00371     unsigned int returnValue = 0;
00372     stItem_t *theItem;
00373 
00374     theItem = stackPeek(contentType);
00375 
00376     if (NULL != theItem)
00377     {
00378         returnValue = theItem->index;
00379     }
00380     else
00381     {
00382         if (NULL != g_rootInfo[contentType])
00383         {
00384             returnValue = g_rootInfo[contentType]->index;
00385         }
00386     }
00387     return returnValue;
00388 }

Here is the call graph for this function:

int mdsGetItemCount ( void   ) 

Definition at line 258 of file metadataStoreManager.c.

00259 {
00260 
00261     if (g_contentArray)
00262     {
00263         CL_STACKPRINTF("%d", g_contentArray->len);
00264         return g_contentArray->len;
00265     }
00266     else
00267     {
00268         CL_STACKPRINTF("0");
00269         return 0;
00270     }
00271 }

gboolean mdsGetItemFilename ( int  index,
gchar *  szFilename,
int  len 
)

Definition at line 305 of file metadataStoreManager.c.

00306 {
00307     mdsFsItem_t *pFsItem = NULL;
00308 
00309     g_return_val_if_fail((g_contentArray != NULL), FALSE);
00310     g_return_val_if_fail( ((index >= 0) && (index < g_contentArray->len)) , FALSE);
00311     g_return_val_if_fail((szFilename != NULL), FALSE);
00312    
00313     pFsItem = &g_array_index(g_contentArray, mdsFsItem_t, index);
00314     g_return_val_if_fail((pFsItem != NULL), FALSE);
00315     snprintf(szFilename, len, "%s", pFsItem->szFilename);
00316 
00317     return TRUE;
00318 }

int mdsGetItemIndex ( const gchar *  szFilename  ) 

Definition at line 274 of file metadataStoreManager.c.

00275 {
00276     int         i;
00277     int         index = -1;
00278     gboolean    found;
00279     mdsFsItem_t *pFsItem;
00280     char        *cp;
00281     char        szRealpath[PATH_MAX];
00282 
00283     g_return_val_if_fail((g_contentArray != NULL), -1);
00284     
00285     for ( i = 0, found = FALSE ;
00286           i < g_contentArray->len  &&  !found ;
00287           i++ )
00288     {
00289         pFsItem = &g_array_index(g_contentArray, mdsFsItem_t, i);
00290         cp = realpath(pFsItem->szFilename, szRealpath);
00291         if (cp != NULL)
00292         {
00293             if (strcmp(szFilename, szRealpath) == 0 )
00294             {
00295                 found = TRUE;
00296                 index = i;
00297             }
00298         }
00299     }
00300 
00301     return index;
00302 }

int mdsGetRootLocation ( const st_ContentType_e  contentType,
char *  location,
const int  length 
)

Retrieve the root location of specified content type

Definition at line 780 of file metadataStoreManager.c.

00781 {
00782     int     nRet = 0;
00783     char*   cp;
00784     char    szRealpath[PATH_MAX];
00785     
00786     if (NULL == location || 0 >= length) 
00787     {
00788         CL_ERRORPRINTF("Invalid buffer pointer or length!");
00789         return nRet;
00790     }
00791     
00792     if ((NULL == g_rootInfo[contentType]) || (NULL == g_rootInfo[contentType]->dirArray))
00793     {
00794         if (contentType == st_MenuTypeMode)
00795         {
00796             CL_ERRORPRINTF("No root dir specified for st_MenuTypeMode!");
00797             return nRet;
00798         }
00799         else
00800         {
00801             CL_ERRORPRINTF("No root dir for contentType [%d], fallback to MODE menu", contentType);
00802             return mdsGetRootLocation(st_MenuTypeMode, location, length);
00803         }
00804     }
00805     
00806     mdsDirectory_t *directory =  &g_array_index(g_rootInfo[contentType]->dirArray,  mdsDirectory_t, 0);
00807     if (directory)
00808     {
00809         cp = realpath(directory->szFilename, szRealpath);
00810         if (cp == NULL)
00811         {
00812             // no realpath found -> report original path
00813             cp = directory->szFilename;
00814         }
00815         nRet = snprintf(location, length, "%s", cp);
00816     }
00817     else
00818     {
00819         CL_ERRORPRINTF("Invalid directory pointer!");
00820     }
00821     return nRet;
00822 }

Here is the call graph for this function:

mdsSortStruct_t* mdsGetSortStructOfRootInfo ( st_ContentType_e  type  ) 

Definition at line 582 of file metadataStoreManager.c.

00583 {
00584    stItem_t *rootItem = NULL;
00585 
00586    if (type < st_ContentTypeBooks || type >= st_ContentTypeUndefined || type >= TOTAL_STACK_COUNT)
00587    {
00588        CL_ERRORPRINTF("Invalid arguments");
00589        return NULL;
00590    }
00591 
00592    rootItem =  g_rootInfo[type];
00593    if (rootItem)
00594    {
00595         return &(rootItem->sort); 
00596    }
00597    else
00598    {
00599        CL_WARNPRINTF("Can't find the rootItem of type%d", type);
00600        return NULL;
00601    }
00602 }

void mdsInit ( void   ) 

Init stack (for every content key) Init storage used for content history

Parameters:
- 
Returns:
-

Definition at line 79 of file metadataStoreManager.c.

00080 {
00081     // destory the old ones
00082     mdsDestroy();   
00083 
00084     rootInfoInit();
00085     stackInitAll();
00086 
00087     mdsRecreateArchives(st_StorageTypeMain);
00088     mdsRecreateArchives(st_StorageTypeCF);
00089     mdsRecreateArchives(st_StorageTypeSD);
00090     mdsRecreateArchives(st_StorageTypeUSB);
00091 }

Here is the call graph for this function:

void mdsRecreateArchives ( st_ContentType_e  storageType  ) 

Definition at line 873 of file metadataStoreManager.c.

00874 {
00875     CL_LOGPRINTF("entry");
00876 
00877     // check the argument is valid or not
00878     if ( (storageType != st_StorageTypeCF) && (storageType != st_StorageTypeSD)
00879           && (storageType != st_StorageTypeUSB) && (storageType != st_StorageTypeMain) )
00880     {
00881         CL_ERRORPRINTF("invalid storage type[%d]", storageType);
00882         return;
00883     }
00884 
00885     if (st_StorageTypeMain == storageType)
00886     {
00887         // if it's internal memory, 
00888         // always recreate the archive folders if they don't exist  
00889         recreateArchives(st_StorageTypeMain);
00890     }
00891     else
00892     {
00893         // if one of the archives points to the storage, 
00894         // recreate the archive folders if they don't exsit on storage
00895         if ( mdsArcLocIsChanged(st_ContentTypeNews, storageType)
00896              || mdsArcLocIsChanged(st_ContentTypeBooks, storageType)
00897              || mdsArcLocIsChanged(st_ContentTypeDocs, storageType)
00898              || mdsArcLocIsChanged(st_ContentTypeNotes, storageType) )
00899         {
00900             recreateArchives(storageType);
00901         }
00902     }
00903 }

Here is the call graph for this function:

int mdsScanCurrent ( st_ContentType_e  contentType  ) 

Scan using the current "content details" information if not available use the "root" values

Parameters:
contentType indication of the content category
Returns:
error code in case of failure

Definition at line 140 of file metadataStoreManager.c.

00141 {
00142     stItem_t *contentInfo;
00143     int     result = 0;
00144     mdsSortStruct_t *sort = NULL;
00145     int     sortResult;
00146 
00147     CL_STACKPRINTF("entry: contentType [%d]", contentType);
00148 
00149     if (NULL == g_rootInfo[contentType])
00150     {
00151         CL_ERRORPRINTF("No g_rootInfo for contentType [%d], fallback to MODE menu", contentType);
00152         contentType = st_MenuTypeMode;
00153     }
00154     g_return_val_if_fail( (NULL != g_rootInfo[contentType]), result);
00155 
00156     // clear the previous retrieved content information
00157     if (g_contentArray)
00158     {
00159         CL_STACKPRINTF("g_array_free");
00160         g_array_free(g_contentArray, TRUE);
00161         g_contentArray = NULL;
00162     }
00163 
00164     contentInfo = stackPeek(contentType);
00165 
00166     CL_TIMEDISPLAY("before scan");
00167 
00168     if (NULL == contentInfo)
00169     {
00170         CL_STACKPRINTF("=> root content");
00171         result = erMdsContentScan(g_rootInfo[contentType]->dirArray, &g_contentArray);
00172     }
00173     else
00174     {
00175         //retrieve new content
00176         stackItemDisplay(contentInfo);
00177         result = erMdsContentScan(contentInfo->dirArray, &g_contentArray);
00178     }
00179     
00180     CL_TIMEDISPLAY("after scan");
00181 
00182     if ((ERMDS_CONTENT_SCAN_FAILED != result) && (NULL != g_contentArray))
00183     {
00184         // we always take the sort settings from the rootInfo
00185         sort = &g_rootInfo[contentType]->sort;
00186         sortResult = erMdsContentSort(g_contentArray, sort);
00187 
00188         CL_LOGPRINTF("erMdsContentSort returned %d", sortResult);
00189     }
00190     return result;
00191 }

Here is the call graph for this function:

int mdsScanNext ( st_ContentType_e  contentType,
char *  directory,
unsigned int  theIndex 
)

Scan using the current "content details" information but with this new directory data. And store these new "content details" for this contentType on the stack.

Also up

Definition at line 200 of file metadataStoreManager.c.

00201 {
00202     stItem_t *newItem;
00203     stItem_t *currentItem;
00204     int     result = 0;
00205     mdsDirectory_t folder;
00206 
00207     strcpy(folder.szFilename, directory);
00208 
00209     CL_STACKPRINTF("%s", folder.szFilename);
00210 
00211     newItem = g_new0(stItem_t, 1);
00212     currentItem = stackPeek(contentType);
00213 
00214     if (NULL == currentItem)
00215     {
00216         CL_STACKPRINTF("=> root content");
00217         currentItem = g_rootInfo[contentType];
00218     }
00219 
00220     // create a new array to store the directory info
00221     newItem->dirArray = g_array_sized_new(FALSE, TRUE, ERMDS_MAX_FILENAME_SIZE, INITIAL_DIR_COUNT_ARRAY_SIZE);
00222     CL_STACKPRINTF("newItem->dirArray 0x%x", (unsigned int) newItem->dirArray);
00223     g_array_append_val(newItem->dirArray, folder);
00224 
00225     // copy the rest of the content from the "current" content details
00226 
00227     // we needn't copy the sort settings because we always use them from the rootInfo.
00228     // newItem->sort.ascending = currentItem->sort.ascending;
00229     // newItem->sort.ft = currentItem->sort.ft;
00230     newItem->index = 0;
00231 
00232     // put the new item on the stack
00233     stackPush(contentType, newItem);
00234 
00235     //copy of new item (not of the referenced data!) was made on the stack
00236     g_free(newItem);
00237 
00238     result = mdsScanCurrent(contentType);
00239     return result;
00240 }

Here is the call graph for this function:

int mdsScanPrevious ( st_ContentType_e  contentType  ) 

Remove the current "content details" from the stack and scan using the new current "content details" information.

Definition at line 246 of file metadataStoreManager.c.

00247 {
00248     int     result = 0;
00249 
00250     CL_STACKPRINTF("");
00251 
00252     stackPop(contentType);
00253     result = mdsScanCurrent(contentType);
00254     return result;
00255 }

Here is the call graph for this function:

int mdsScanRoot ( st_ContentType_e  contentType  ) 

Scan the root directory

Parameters:
contentType indication of the content category
Returns:
error code in case of failure

Definition at line 105 of file metadataStoreManager.c.

00106 {
00107     int     result = 0;
00108     mdsSortStruct_t *sort = NULL;
00109     int     sortResult;
00110 
00111     CL_STACKPRINTF("");
00112 
00113     // clear the previous retrieved content information
00114     if (g_contentArray)
00115     {
00116         CL_STACKPRINTF("g_array_free");
00117         g_array_free(g_contentArray, TRUE);
00118         g_contentArray = NULL;
00119     }
00120 
00121     CL_TIMEDISPLAY("before scan");
00122 
00123     if (NULL != g_rootInfo[contentType])
00124     {
00125         result = erMdsContentScan(g_rootInfo[contentType]->dirArray, &g_contentArray);
00126         sort = &g_rootInfo[contentType]->sort;
00127     }
00128 
00129     CL_TIMEDISPLAY("after scan");
00130 
00131     if ((ERMDS_CONTENT_SCAN_FAILED != result) && (NULL != g_contentArray))
00132     {
00133         sortResult = erMdsContentSort(g_contentArray, sort);
00134 
00135         CL_LOGPRINTF("erMdsContentSort returned %d", sortResult);
00136     }
00137     return result;
00138 }

Here is the call graph for this function:

void mdsSetIndex ( st_ContentType_e  contentType,
unsigned int  index 
)

Update the index field of the current top stack item

Definition at line 345 of file metadataStoreManager.c.

00346 {
00347     stItem_t *theItem;
00348 
00349     theItem = stackPeek(contentType);
00350 
00351     if (NULL != theItem)
00352     {
00353         //update the index value
00354         theItem->index = index;
00355     }
00356     else
00357     {
00358         //update the root index
00359         if (NULL != g_rootInfo[contentType])
00360         {
00361             g_rootInfo[contentType]->index = index;
00362         }
00363     }
00364     return;
00365 }

Here is the call graph for this function:

int mdsSetPageContent ( clDisplayItem_t displayItemArray,
int  nBegin,
int *  nChunk 
)

Definition at line 321 of file metadataStoreManager.c.

00322 {
00323     int     returnValue;
00324 
00325     if (g_contentArray)
00326     {
00327         CL_TIMEDISPLAY("before erClGetDisplayItems");
00328 
00329         returnValue = erClGetDisplayItems(g_contentArray, nBegin, nChunk, displayItemArray);
00330 
00331         CL_TIMEDISPLAY("after erClGetDisplayItems");
00332 
00333     }
00334     else
00335     {
00336         CL_ERRORPRINTF("g_contentArray == NULL");
00337         returnValue = (-1);
00338     }
00339 
00340     return returnValue;
00341 }

Here is the call graph for this function:

void mdsSetSortStructOfRootInfo ( st_ContentType_e  type,
const mdsSortStruct_t sort 
)

Definition at line 604 of file metadataStoreManager.c.

00605 {
00606    stItem_t *rootItem = NULL;
00607    mdsSortStruct_t *localSort = NULL;
00608 
00609    if (type < st_ContentTypeBooks || type >= st_ContentTypeUndefined || type >= TOTAL_STACK_COUNT || NULL == sort)
00610    {
00611        CL_ERRORPRINTF("Invalid arguments");
00612        return;
00613    }
00614 
00615    rootItem =  g_rootInfo[type];
00616    if (rootItem)
00617    {
00618         localSort = &(rootItem->sort);
00619         localSort->ascending = sort->ascending;
00620         localSort->ft = sort->ft;
00621    }
00622    else
00623    {
00624        CL_WARNPRINTF("Can't find the rootItem of type%d", type);
00625        return;
00626    }
00627 }

static void recreateArchives ( st_ContentType_e  storageType  )  [static]

Definition at line 931 of file metadataStoreManager.c.

00932 {
00933     char storageDirName[ERMDS_MAX_FILENAME_SIZE];
00934     char newDir[ERMDS_MAX_FILENAME_SIZE];
00935     char *cp = NULL;
00936 
00937     if (!storageIsMounted(storageType))
00938     {
00939         CL_ERRORPRINTF("storage not mounted, storage type[%d]", storageType);
00940         return;
00941     }
00942  
00943     if ( mdsGetRootLocation(storageType, storageDirName, sizeof(storageDirName)) > 0 )
00944     {
00945         CL_LOGPRINTF("recreate archives on %s", storageDirName);
00946         
00947         // newspapers
00948         cp = getArchiveName(st_ContentTypeNews);
00949         if (cp)
00950         {
00951             snprintf(newDir, ERMDS_MAX_FILENAME_SIZE, "%s%s", storageDirName, cp);
00952             if (0 != mkdir(newDir, 0755))
00953             {
00954                 CL_ERRORPRINTF("Can not create directory %s!", newDir);             
00955             }
00956         }
00957 
00958         // books
00959         cp = getArchiveName(st_ContentTypeBooks);
00960         if (cp)
00961         {
00962             snprintf(newDir, ERMDS_MAX_FILENAME_SIZE, "%s%s", storageDirName, cp);
00963             if (0 != mkdir(newDir, 0755))
00964             {
00965                 CL_ERRORPRINTF("Can not create directory %s!", newDir);             
00966             }
00967         }
00968 
00969         // documents
00970         cp = getArchiveName(st_ContentTypeDocs);
00971         if (cp)
00972         {
00973             snprintf(newDir, ERMDS_MAX_FILENAME_SIZE, "%s%s", storageDirName, cp);
00974             if (0 != mkdir(newDir, 0755))
00975             {
00976                 CL_ERRORPRINTF("Can not create directory %s!", newDir);             
00977             }
00978         }
00979 
00980         // notes 
00981         cp = getArchiveName(st_ContentTypeNotes);
00982         if (cp)
00983         {
00984             snprintf(newDir, ERMDS_MAX_FILENAME_SIZE, "%s%s", storageDirName, cp);
00985             if (0 != mkdir(newDir, 0755))
00986             {
00987                 CL_ERRORPRINTF("Can not create directory %s!", newDir);             
00988             }
00989         }
00990     }
00991 }

Here is the call graph for this function:

static void rootInfoDestroy ( void   )  [static]

Definition at line 766 of file metadataStoreManager.c.

00767 {
00768     int     index;
00769 
00770     for (index = 0; index < TOTAL_STACK_COUNT; index++)
00771     {
00772         if (g_rootInfo[index])
00773         {
00774             stackItemDestroy(g_rootInfo[index]);
00775             g_rootInfo[index] = NULL;
00776         }
00777     }
00778 }

Here is the call graph for this function:

static void rootInfoInit ( void   )  [static]

Definition at line 390 of file metadataStoreManager.c.

00391 {
00392     regContentCategory_t *theBooks = NULL, *theNews = NULL, *theDocs = NULL, *theNotes = NULL;
00393     regContentCategory_t *theMain = NULL, *theCF = NULL, *theSD = NULL, *theUSB = NULL;
00394     regContentCategory_t *theRecent = NULL, *theDownload = NULL, *theSearch = NULL, *theMode = NULL;
00395     
00396     gchar                *cp;
00397     struct stat          statbuf;
00398     
00399     // reading sections from registry
00400     theBooks = erRegGetContentCategory(BOOKS_CATEGORY);
00401     theNews = erRegGetContentCategory(NEWSPAPERS_CATEGORY);
00402     theDocs = erRegGetContentCategory(DOCUMENTS_CATEGORY);
00403     theNotes = erRegGetContentCategory(NOTES_CATEGORY);
00404 
00405     theMode = erRegGetContentCategory(MODE_CATEGORY);
00406 
00407     theCF = erRegGetContentCategory(CF_CATEGORY);
00408     theSD = erRegGetContentCategory(SD_CATEGORY);
00409     theUSB = erRegGetContentCategory(USB_CATEGORY);
00410     theMain = erRegGetContentCategory(MAIN_CATEGORY);
00411 
00412     theDownload = erRegGetContentCategory(DOWNLOAD_HISTORY);
00413     theSearch = erRegGetContentCategory(SEARCH_RESULT);
00414     theRecent = erRegGetContentCategory(RECENTDOCUMENTS);
00415 
00416     if (theBooks)
00417     {
00418         rootInfoStore(st_ContentTypeBooks, theBooks);
00419         erRegFreeContentCategory(theBooks);
00420     }
00421     else
00422     {
00423         CL_ERRORPRINTF("BOOKS_CATEGORY registry info missing");
00424     }
00425 
00426     if (theNews)
00427     {
00428         rootInfoStore(st_ContentTypeNews, theNews);
00429         erRegFreeContentCategory(theNews);
00430     }
00431     else
00432     {
00433         CL_ERRORPRINTF("NEWSPAPERS_CATEGORY registry info missing");
00434     }
00435 
00436     if (theDocs)
00437     {
00438         rootInfoStore(st_ContentTypeDocs, theDocs);
00439         erRegFreeContentCategory(theDocs);
00440     }
00441     else
00442     {
00443         CL_ERRORPRINTF("DOCUMENTS_CATEGORY registry info missing");
00444     }
00445 
00446     if (theNotes)
00447     {
00448         rootInfoStore(st_ContentTypeNotes, theNotes);
00449         erRegFreeContentCategory(theNotes);
00450     }
00451     else
00452     {
00453         CL_ERRORPRINTF("NOTES_CATEGORY registry info missing");
00454     }
00455 
00456     if (theMode)
00457     {
00458         if (theMode->location)
00459         {
00460             cp = g_strconcat(theMode->location, "/", languagesGetCountry(), NULL);
00461             if (stat(cp, &statbuf) != 0)
00462             {
00463                 g_free(cp);
00464                 cp = g_strconcat(theMode->location, "/", languagesGetDefaultCountry(), NULL);
00465             }
00466             g_free(theMode->location);
00467             theMode->location = cp;
00468             CL_STACKPRINTF("MODE_CATEGORY location changed: %s", theMode->location);
00469         }
00470 
00471         rootInfoStore(st_MenuTypeMode, theMode);
00472         erRegFreeContentCategory(theMode);
00473     }
00474     else
00475     {
00476         CL_ERRORPRINTF("MODE_CATEGORY registry info missing");
00477     }
00478 
00479     if (theCF)
00480     {
00481         rootInfoStore(st_StorageTypeCF, theCF);
00482         erRegFreeContentCategory(theCF);
00483     }
00484     else
00485     {
00486         CL_ERRORPRINTF("CF_CATEGORY registry info missing");
00487     }
00488 
00489     if (theSD)
00490     {
00491         rootInfoStore(st_StorageTypeSD, theSD);
00492         erRegFreeContentCategory(theSD);
00493     }
00494     else
00495     {
00496         CL_ERRORPRINTF("SD_CATEGORY registry info missing");
00497     }
00498 
00499     if (theUSB)
00500     {
00501         rootInfoStore(st_StorageTypeUSB, theUSB);
00502         erRegFreeContentCategory(theUSB);
00503     }
00504     else
00505     {
00506         CL_ERRORPRINTF("USB_CATEGORY registry info missing");
00507     }
00508 
00509     if (theMain)
00510     {
00511         rootInfoStore(st_StorageTypeMain, theMain);
00512         erRegFreeContentCategory(theMain);
00513     }
00514     else
00515     {
00516         CL_ERRORPRINTF("MAIN_CATEGORY registry info missing");
00517     }
00518 
00519     if (theDownload)
00520     {
00521         rootInfoStore(st_DownloadHistory, theDownload);
00522         erRegFreeContentCategory(theDownload);
00523     }
00524     else
00525     {
00526         CL_ERRORPRINTF("DOWNLOAD_HISTORY registry info missing");
00527     }
00528 
00529     if (theSearch)
00530     {
00531         rootInfoStore(st_SearchResult, theSearch);
00532         erRegFreeContentCategory(theSearch);
00533     }
00534     else
00535     {
00536         CL_ERRORPRINTF("SEARCH_RESULT registry info missing");
00537     }
00538 
00539     if (theRecent)
00540     {
00541         rootInfoStore(st_RecentDocuments, theRecent);
00542         erRegFreeContentCategory(theRecent);
00543     }
00544     else
00545     {
00546         CL_ERRORPRINTF("RECENTDOCUMENTS registry info missing");
00547     }
00548 }

Here is the call graph for this function:

static void rootInfoStore ( st_ContentType_e  type,
regContentCategory_t theContentCategory 
) [static]

Definition at line 550 of file metadataStoreManager.c.

00551 {
00552     unsigned int index;
00553     mdsDirectory_t dir;
00554     stItem_t *rootItem;
00555 
00556     // create a stack item  
00557     rootItem = g_new0(stItem_t, 1);
00558 
00559     if (theContentCategory->location)
00560     {
00561         rootItem->dirArray = g_array_sized_new(FALSE, TRUE, sizeof(mdsDirectory_t), 1);
00562 
00563         for (index = 0; index < 1; index++)
00564         {
00565             strncpy(dir.szFilename, theContentCategory->location, ERMDS_MAX_FILENAME_SIZE);
00566             g_array_append_val(rootItem->dirArray, dir);
00567             CL_STACKPRINTF("root dir %s", dir.szFilename);
00568         }
00569     }
00570 
00571     rootItem->sort.ascending = theContentCategory->sortAscending;
00572     rootItem->sort.ft = getFieldType(theContentCategory->sortFieldType);
00573 
00574     rootItem->index = 0;
00575 
00576     stackItemDisplay(rootItem);
00577 
00578     g_rootInfo[type] = rootItem;
00579 }

Here is the call graph for this function:

gboolean storageIsMounted ( st_ContentType_e  storageType  ) 

Definition at line 1021 of file metadataStoreManager.c.

01022 {
01023     CL_LOGPRINTF("entry");
01024 
01025     gboolean found = FALSE;
01026 
01027     char storageDirName[ERMDS_MAX_FILENAME_SIZE];
01028 
01029     if ( mdsGetRootLocation(storageType, storageDirName, sizeof(storageDirName)) > 0 )
01030     {
01031         char *cp = NULL;
01032         char realPath[ERMDS_MAX_FILENAME_SIZE];
01033         
01034         cp = realpath(storageDirName, realPath);
01035         CL_LOGPRINTF("%s,%s", storageDirName, realPath);
01036 
01037         FILE *fp = setmntent("/proc/mounts", "r");
01038         struct mntent* mt = NULL;
01039 
01040          while ((mt = getmntent(fp)))
01041          {
01042             CL_LOGPRINTF("Partition: %s: %s %s", mt->mnt_fsname, mt->mnt_dir, mt->mnt_type);
01043 
01044             if (strcasecmp(mt->mnt_dir, realPath) == 0)
01045             {
01046                 if ( strcasecmp(mt->mnt_type, "vfat") == 0 )
01047                 {
01048                     found = TRUE;
01049                     break;
01050                 }
01051                 else
01052                 {
01053                     found = FALSE;
01054                 }
01055             }
01056          }
01057         
01058          endmntent(fp);
01059     }
01060     else
01061     {
01062         CL_ERRORPRINTF("can't get the path of storageType[%d]", storageType);
01063     }
01064 
01065     CL_LOGPRINTF("found[%d]", found); 
01066     return found;
01067 }

Here is the call graph for this function:


Variable Documentation

GArray* g_contentArray = NULL [static]

Definition at line 67 of file metadataStoreManager.c.

stItem_t* g_rootInfo[TOTAL_STACK_COUNT] [static]

Definition at line 68 of file metadataStoreManager.c.


Generated on Sun Dec 14 17:13:38 2008 by  doxygen 1.5.6