00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00023 #include <stdio.h>
00024 #include <stdlib.h>
00025 #include <glib.h>
00026 #include <string.h>
00027 #include <stdio.h>
00028 #include <ctype.h>
00029
00030 #include <gtk/gtk.h>
00031 #include <gdk/gdk.h>
00032
00033 #include <libermanifest/ermanifest.h>
00034
00035 #include "stack.h"
00036 #include "lister.h"
00037 #include "erConnect.h"
00038 #include "system.h"
00039 #include "gtkPincodeScreen.h"
00040 #include "control.h"
00041 #include "metadataStoreManager.h"
00042
00043 #define MAX_DESC 80
00044
00045 #define PREVIOUS 0x0001
00046 #define NEXT 0x0002
00047 #define CURRENT 0x0003
00048 #define DISPLAY_STACK 0x0004
00049 #define MENU_QUIT 0x0400
00050
00051 static int lastCmd = -1;
00052
00053 struct command
00054 {
00055 char key;
00056 char *desc;
00057 int code;
00058 };
00059
00060 struct command commands[] = {
00061 {'1', "Scan using the current content information", CURRENT},
00062 {'2', "Scan NEXT", NEXT},
00063 {'3', "Scan PREVIOUS", PREVIOUS},
00064 {'4', "Display Stack", DISPLAY_STACK},
00065 {0, NULL, 0},
00066 {'Q', "Quit", MENU_QUIT}
00067 };
00068
00069 int menu(char *mode);
00070
00071 int main(int argc, char *argv[])
00072 {
00073 int result;
00074 int command;
00075 char commandDesc[MAX_DESC];
00076 char mode[80];
00077 mdsDirectory_t dir_1;
00078
00079
00080
00081
00082 strcpy(commandDesc, "NO DESCRIPTION");
00083
00084 mdsInit();
00085
00086 do
00087 {
00088 command = menu(mode);
00089
00090 switch (command)
00091 {
00092 case CURRENT:
00093 result = mdsScanCurrent(st_ContentTypeBooks);
00094
00095 if (result != ERMDS_CONTENT_SCAN_OK)
00096 {
00097 printf("mdsScanCurrent returned %d\n", result);
00098 }
00099 else
00100 {
00101 displayScanResult();
00102 }
00103 break;
00104
00105 case PREVIOUS:
00106 result = mdsScanPrevious(st_ContentTypeBooks);
00107
00108 if (result != ERMDS_CONTENT_SCAN_OK)
00109 {
00110 printf("mdsScanPrevious returned %d\n", result);
00111 }
00112 else
00113 {
00114 displayScanResult();
00115 }
00116 break;
00117
00118 case NEXT:
00119 strcpy(dir_1.szFilename, "/home/ann/contentExample/test_root/dir_1");
00120
00121 printf("folder %s\n", dir_1.szFilename);
00122
00123 result = mdsScanNext(st_ContentTypeBooks, dir_1.szFilename, 0);
00124
00125 if (result != ERMDS_CONTENT_SCAN_OK)
00126 {
00127 printf("mdsScanPrevious returned %d\n", result);
00128 }
00129 else
00130 {
00131 displayScanResult();
00132 }
00133 break;
00134
00135 case DISPLAY_STACK:
00136 stackDisplay(st_ContentTypeBooks);
00137 break;
00138 }
00139
00140 }
00141 while (command != MENU_QUIT);
00142
00143 mdsDestroy();
00144
00145 exit(0);
00146 }
00147
00148 int menu(char *mode)
00149 {
00150 int i;
00151 char ch;
00152
00153 printf("\n\nMenu: \n");
00154
00155 if (lastCmd != -1)
00156 printf("Last selected command = '%s'\n\n", commands[lastCmd].desc);
00157 else
00158 printf("\n\n");
00159
00160 for (i = 0; i < sizeof(commands) / sizeof(*commands); i++)
00161 {
00162 if (commands[i].key == 0)
00163 printf("\n");
00164 else
00165 printf(" %c - %s\n", commands[i].key, commands[i].desc);
00166 }
00167
00168 printf("\nCommand: ");
00169 fflush(stdout);
00170
00171 while (1)
00172 {
00173 ch = toupper(getchar());
00174
00175 for (i = 0; i < sizeof(commands) / sizeof(*commands); i++)
00176 {
00177 if (ch && ch == commands[i].key)
00178 {
00179 printf("%c\n\n", ch);
00180 lastCmd = i;
00181 return commands[i].code;
00182 }
00183 }
00184 }
00185 }