#include <glib.h>
#include "erMdsContent.h"
Go to the source code of this file.
For every content key (which is associated with a ContentType) a stack is kept to keep track of the browsing through the content for the different content types
<File description>="">
Definition in file stack.h.
enum st_ContentType_e |
Definition at line 46 of file stack.h.
00047 { 00048 // Content types linked to the iLiad archive keys, these need a history stack 00049 st_ContentTypeBooks = 0, 00050 st_ContentTypeNews, 00051 st_ContentTypeDocs, 00052 st_ContentTypeNotes, 00053 st_ARCHIVES_COUNT, 00054 // Storage types which do not require a history stack 00055 st_StorageTypeCF = st_ARCHIVES_COUNT, 00056 // compact-flash card 00057 st_StorageTypeSD, // SD card / MMC card 00058 st_StorageTypeUSB, // USB stick or USB hard-disk 00059 st_StorageTypeMain, // main memory 00060 st_MenuTypeMode, // MODE menu/directory (doesn't need a stack for the moment, but does have a root directory) 00061 st_DownloadHistory, // The download history directory (doesn't need a stack for the moment, but does have a root directory) 00062 st_SearchResult, // The result of search 00063 st_RecentDocuments, // The recent documents directory (doesn't need a stack for the moment, but does have a root directory) 00064 st_ContentTypeUndefined 00065 } st_ContentType_e;
void stackClear | ( | st_ContentType_e | contentType | ) |
Clear the stack, by removing all items and freeing the referenced dirArray and searchArray data used by every item.
Definition at line 133 of file stack.c.
00134 { 00135 int index; 00136 stItem_t *theItem = NULL; 00137 00138 CL_STACKPRINTF("type %d - length %d", contentType, g_stacks[contentType]->len); 00139 00140 // clear all reference values 00141 if (g_stacks[contentType]->len > 0) 00142 { 00143 for (index = 0; index < g_stacks[contentType]->len; index++) 00144 { 00145 theItem = &g_array_index(g_stacks[contentType], stItem_t, index); 00146 00147 if (theItem->dirArray) 00148 { 00149 CL_STACKPRINTF("dirArray - 0x%x", (unsigned int) theItem->dirArray); 00150 g_array_free(theItem->dirArray, TRUE); 00151 theItem->dirArray = NULL; 00152 } 00153 } 00154 00155 // clear the rest of the array 00156 g_array_remove_range(g_stacks[contentType], 0, g_stacks[contentType]->len); 00157 } 00158 }
void stackDestroyAll | ( | void | ) |
Destroy the stack of every content key
Definition at line 56 of file stack.c.
00057 { 00058 int index; 00059 00060 CL_STACKPRINTF("entry"); 00061 00062 for (index = 0; index < TOTAL_STACK_COUNT; index++) 00063 { 00064 if (g_stacks[index]) 00065 { 00066 stackClear(index); 00067 g_array_free(g_stacks[index], TRUE); 00068 g_stacks[index] = NULL; 00069 } 00070 } 00071 }
void stackDisplay | ( | st_ContentType_e | contentType | ) |
Display stack
Definition at line 207 of file stack.c.
00208 { 00209 int index; 00210 stItem_t *theItem = NULL; 00211 00212 // clear all reference values 00213 if (g_stacks[contentType]->len > 0) 00214 { 00215 for (index = 0; index < g_stacks[contentType]->len; index++) 00216 { 00217 theItem = &g_array_index(g_stacks[contentType], stItem_t, (g_stacks[contentType]->len - 1)); 00218 CL_STACKPRINTF("\n*****************[%d]**********************", index); 00219 stackItemDisplay(theItem); 00220 CL_STACKPRINTF("\n*******************************************\n"); 00221 } 00222 } 00223 }
int stackHeight | ( | st_ContentType_e | contentType | ) |
Returns # items on the stack
Definition at line 126 of file stack.c.
00127 { 00128 CL_STACKPRINTF("%d-%d", contentType, g_stacks[contentType]->len); 00129 00130 return g_stacks[contentType]->len; 00131 }
void stackInitAll | ( | void | ) |
Create an empty stack for every content key (=st_ContentType_e)
Definition at line 44 of file stack.c.
00045 { 00046 int index; 00047 00048 CL_STACKPRINTF("entry"); 00049 00050 for (index = 0; index < TOTAL_STACK_COUNT; index++) 00051 { 00052 g_stacks[index] = g_array_sized_new(FALSE, TRUE, sizeof(stItem_t), INITIAL_STACK_ARRAY_SIZE); 00053 } 00054 }
gboolean stackIsArchive | ( | st_ContentType_e | contentType | ) |
Definition at line 241 of file stack.c.
00242 { 00243 if ( (contentType == st_ContentTypeBooks) 00244 || (contentType == st_ContentTypeNews) 00245 || (contentType == st_ContentTypeDocs) 00246 || (contentType == st_ContentTypeNotes) ) 00247 { 00248 return TRUE; 00249 } 00250 else 00251 { 00252 return FALSE; 00253 } 00254 }
gboolean stackIsStorage | ( | st_ContentType_e | contentType | ) |
Definition at line 226 of file stack.c.
00227 { 00228 if ( (contentType >= st_StorageTypeCF) 00229 || (contentType <= st_StorageTypeSD) 00230 || (contentType <= st_StorageTypeUSB) 00231 || (contentType <= st_StorageTypeMain) ) 00232 { 00233 return TRUE; 00234 } 00235 else 00236 { 00237 return FALSE; 00238 } 00239 }
void stackItemDestroy | ( | stItem_t * | stackItem | ) |
Free the referenced dirArray and searchArray data and the rest of the item.
Definition at line 160 of file stack.c.
00161 { 00162 CL_STACKPRINTF("0x%x", (unsigned int) stackItem); 00163 00164 if (stackItem) 00165 { 00166 if (stackItem->dirArray) 00167 { 00168 CL_STACKPRINTF("dirArray - 0x%x", (unsigned int) stackItem->dirArray); 00169 g_array_free(stackItem->dirArray, TRUE); 00170 } 00171 00172 g_free(stackItem); 00173 stackItem = NULL; 00174 } 00175 else 00176 { 00177 CL_STACKPRINTF("stackItem == NULL"); 00178 } 00179 }
void stackItemDisplay | ( | stItem_t * | stackItem | ) |
Display item content and referenced content including address information
Definition at line 181 of file stack.c.
00182 { 00183 int index; 00184 mdsDirectory_t *directory; 00185 00186 CL_STACKPRINTF("0x%x", (unsigned int) stackItem); 00187 00188 if (stackItem) 00189 { 00190 if (stackItem->dirArray) 00191 { 00192 CL_STACKPRINTF("dirArray - 0x%x", (unsigned int) stackItem->dirArray); 00193 00194 for (index = 0; index < stackItem->dirArray->len; index++) 00195 { 00196 directory = &g_array_index(stackItem->dirArray, mdsDirectory_t, index); 00197 CL_STACKPRINTF("dir : %s", directory->szFilename); 00198 } 00199 } 00200 00201 CL_STACKPRINTF("sort fieldType %d", stackItem->sort.ft); 00202 CL_STACKPRINTF("sort ascending %d", stackItem->sort.ascending); 00203 CL_STACKPRINTF("index %d", stackItem->index); 00204 } 00205 }
stItem_t* stackPeek | ( | st_ContentType_e | contentType | ) |
Returns reference to top stack item or NULL when not available
Definition at line 110 of file stack.c.
00111 { 00112 stItem_t *theItem = NULL; 00113 00114 if (g_stacks[contentType]->len > 0) 00115 { 00116 CL_STACKPRINTF("%d-0x%x", contentType, 00117 (unsigned int) &g_array_index(g_stacks[contentType], stItem_t, 00118 (g_stacks[contentType]->len - 1))); 00119 00120 theItem = &g_array_index(g_stacks[contentType], stItem_t, (g_stacks[contentType]->len - 1)); 00121 } 00122 00123 return theItem; 00124 }
void stackPop | ( | st_ContentType_e | contentType | ) |
Removes the last added item from the stack
Definition at line 82 of file stack.c.
00083 { 00084 stItem_t *theItem = NULL; 00085 00086 if (g_stacks[contentType]->len > 0) 00087 { 00088 CL_STACKPRINTF("%d-0x%x", contentType, 00089 (unsigned int) &g_array_index(g_stacks[contentType], stItem_t, 00090 (g_stacks[contentType]->len - 1))); 00091 00092 theItem = &g_array_index(g_stacks[contentType], stItem_t, (g_stacks[contentType]->len - 1)); 00093 00094 // free the memory referenced by this item 00095 if (theItem) 00096 { 00097 if (theItem->dirArray) 00098 { 00099 CL_STACKPRINTF("dirArray - 0x%x", (unsigned int) theItem->dirArray); 00100 g_array_free(theItem->dirArray, TRUE); 00101 theItem->dirArray = NULL; 00102 } 00103 } 00104 00105 g_array_remove_index(g_stacks[contentType], (g_stacks[contentType]->len - 1)); 00106 } 00107 return; 00108 }
void stackPush | ( | st_ContentType_e | contentType, | |
stItem_t * | stackItem | |||
) |
Creates a copy of the stackItem and puts this on the stack The referenced dirArray and searchArray data is not copied, only the reference is. So DO NOT use "stackItemDestroy" on an item of which the referenced data is still valid on the stack !!
Definition at line 73 of file stack.c.
00074 { 00075 if (stackItem) 00076 { 00077 CL_STACKPRINTF("%d-0x%x", contentType, (unsigned int) stackItem); 00078 g_array_append_val(g_stacks[contentType], *stackItem); 00079 } 00080 }