Enlightenment CVS committal Author : titan Project : e17 Module : proto
Dir : e17/proto/ephoto/src/bin Modified Files: ephoto.c ephoto_database.c ephoto_gui.c Log Message: Add some command line parsing for album work. =================================================================== RCS file: /cvs/e/e17/proto/ephoto/src/bin/ephoto.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -3 -r1.8 -r1.9 --- ephoto.c 26 Jan 2007 05:16:54 -0000 1.8 +++ ephoto.c 28 Jan 2007 13:37:18 -0000 1.9 @@ -2,12 +2,177 @@ int main(int argc, char **argv) { + char *album, *name, *description, *path, input[2]; + int i; + sqlite3 *db; + /*Check to make sure EWL is accessible*/ if (!ewl_init(&argc, argv)) { printf("Ewl is not usable, please check your installation!\n"); return 1; } + + for(i = 0; i < argc; i++) + { + if(!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h")) + { + printf("Ephoto Version %s Help Page\n", VERSION); + printf("Long Commands: \n" + " --help - This Screen\n" + " --add-album %%s %%s - Adds Album\n" + " arg1 = name of album\n" + " arg2 = description of album\n" + " --add-image %%s %%s %%s - Adds Image\n" + " arg1 = name of album to add image to\n" + " arg2 = descriptive name for image\n" + " arg3 = path to the image\n" + " --remove-album %%s - Removes Album\n" + " arg1 = name of album\n" + " --remove-image %%s %%s - Removes Image\n" + " arg1 = name of album to remove image from\n" + " arg2 = path of the image to be removed\n"); + printf("Short Commands: \n" + " -h - This Screen\n" + " -a %%s %%s - Adds Album\n" + " -i %%s %%s %%s - Adds Image\n" + " -ra %%s - Removes Album\n" + " -ri %%s %%s - Removes Image\n"); + return 0; + } + if(!strcmp(argv[i], "--add-album") || !strcmp(argv[i], "-a")) + { + i++; + if(argv[i]) name = argv[i]; + else + { + printf("Please specify a name for the album\n"); + return 1; + } + + i++; + if(argv[i]) description = argv[i]; + else + { + printf("Please specify a description for the album\n"); + return 1; + } + + printf("Are you sure you want to create an album with " + "the name %s and the description %s? ", + name, description); + scanf("%c", &input); + if(!strncasecmp(input, "y", 1)) + { + db = ephoto_db_init(); + ephoto_db_add_album(db, name, description); + ephoto_db_close(db); + printf("Album was created\n"); + } + else printf("Album was not created\n"); + + return 0; + } + if(!strcmp(argv[i], "--add-image") || !strcmp(argv[i], "-i")) + { + i++; + if(argv[i]) album = argv[i]; + else + { + printf("Please specify the album you wish to add to\n"); + return 1; + } + + i++; + if(argv[i]) name = argv[i]; + else + { + printf("Please specify a descriptive name for the image\n"); + return 1; + } + + i++; + if(argv[i]) path = argv[i]; + else + { + printf("Please specify the path to the image\n"); + return 1; + } + + printf("Are you sure you want to add an image " + "to album %s with a name %s and path %s? ", + album, name, path); + scanf("%c", &input); + if(!strncasecmp(input, "y", 1)) + { + db = ephoto_db_init(); + ephoto_db_add_image(db, album, name, path); + ephoto_db_close(db); + printf("Image was added\n"); + } + else printf("Image was not added\n"); + + return 0; + } + if(!strcmp(argv[i], "--remove-album") || !strcmp(argv[i], "-ra")) + { + i++; + if(argv[i]) name = argv[i]; + else + { + printf("Please specify the name of the album\n"); + return 1; + } + + printf("Are you sure you want to remove the album %s? ", + name); + scanf("%c", &input); + if(!strncasecmp(input, "y", 1)) + { + db = ephoto_db_init(); + ephoto_db_delete_album(db, name); + ephoto_db_close(db); + printf("Album was removed\n"); + } + else printf("Album was not removed\n"); + + return 0; + } + if(!strcmp(argv[i], "--remove-image") || !strcmp(argv[i], "-ri")) + { + i++; + if(argv[i]) album = argv[i]; + else + { + printf("Please specify the name of the album " + "the image belongs to.\n"); + return 1; + } + + i++; + if(argv[i]) path = argv[i]; + else + { + printf("Please specify the path of the image\n"); + return 1; + } + + printf("Are you sure you want to remove the image %s " + "from the album %s? ", + path, album); + scanf("%c", &input); + if(!strncasecmp(input, "y", 1)) + { + db = ephoto_db_init(); + ephoto_db_delete_image(db, album, path); + ephoto_db_close(db); + printf("Image was removed\n"); + } + else printf("Image was not removed\n"); + + return 0; + } + } /* NLS */ #ifdef ENABLE_NLS =================================================================== RCS file: /cvs/e/e17/proto/ephoto/src/bin/ephoto_database.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- ephoto_database.c 27 Jan 2007 02:28:07 -0000 1.3 +++ ephoto_database.c 28 Jan 2007 13:37:18 -0000 1.4 @@ -130,7 +130,8 @@ snprintf(command, PATH_MAX, "SELECT id FROM images WHERE path = '%s';", path); sqlite3_exec(db, command, get_image_id, 0, 0); snprintf(command, PATH_MAX, "DELETE FROM album_images WHERE " - "album_id = '%s' AND image_id = '%s';", album_id, image_id); + "image_id = '%s' AND album_id = '%s';", image_id, album_id); + sqlite3_exec(db, command, 0, 0, 0); return; } =================================================================== RCS file: /cvs/e/e17/proto/ephoto/src/bin/ephoto_gui.c,v retrieving revision 1.28 retrieving revision 1.29 diff -u -3 -r1.28 -r1.29 --- ephoto_gui.c 27 Jan 2007 06:30:29 -0000 1.28 +++ ephoto_gui.c 28 Jan 2007 13:37:18 -0000 1.29 @@ -413,11 +413,11 @@ static void about_clicked(Ewl_Widget *w, void *event, void *data) { Ewl_Widget *text; - char *txt; + char txt[PATH_MAX]; - txt = "Ephoto Version 2.15.0\n" - "Lead Developer - Stephen Houston\n" - "Contributors - Tokyo.\n"; + snprintf(txt, PATH_MAX, "Ephoto Version %s\n" + "Lead Developer - Stephen Houston\n" + "Contributors - Tokyo.\n", VERSION); text = ewl_text_new(); ewl_text_text_set(EWL_TEXT(text), txt); ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs