From 5ff68140b55f530a11b1aecec27bb30fb5f1b88c Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Wed, 9 Apr 2014 20:59:15 -0400 Subject: [PATCH] Rip out import stuff I only needed this to make the jump from Ocarina 5.10 -> Ocarina 6.0. It's not needed anymore, now that 6.0 is out. Signed-off-by: Anna Schumaker --- DESIGN | 25 ++--------- gui/collection_mgr.cpp | 7 ---- include/file.h | 1 - include/library.h | 1 - include/tags.h | 9 ---- lib/file.cpp | 5 --- lib/library.cpp | 81 ------------------------------------ lib/tags.cpp | 13 ------ share/ocarina/ocarina6.glade | 45 -------------------- tests/file | 5 --- tests/src/file.cpp | 5 +-- tests/src/tagdb.cpp | 16 ------- 12 files changed, 4 insertions(+), 209 deletions(-) diff --git a/DESIGN b/DESIGN index 17ea7dbd..613979db 100644 --- a/DESIGN +++ b/DESIGN @@ -87,9 +87,7 @@ On-disk files: in a subdirectory of $XDG_DATA_HOME. The filse class will support reading and writing files in the users - $XDG_CONFIG_HOME/ocarina{-debug|test}. In addition, Ocarina 6.0 will - support reading library files from the Ocarina 5.10 directory: - $HOME/.ocarina{-debug}. + $XDG_CONFIG_HOME/ocarina{-debug|test}. Items should be written to a file with either a space or new line separating multiple values. @@ -103,7 +101,6 @@ On-disk files: - Hint where the file is located: enum FileLocHint { FILE_TYPE_DATA, - FILE_TYPE_LEGACY, FILE_TYPE_INVALID, } @@ -117,9 +114,11 @@ On-disk files: - File: class File : public std::fstream { private: + - Return false if the file has FILE_TYPE_LEGACY set unsigned int version; OpenMode mode; FileLocHint hint; + - Return false if the file has FILE_TYPE_LEGACY set string filepath; public: @@ -143,9 +142,6 @@ On-disk files: XDG_DATA_HOME/ocarina/filepath XDG_DATA_HOME/ocarina-debug/filepath XDG_DATA_HOME/ocarina-test/filepath - $HOME/.ocarina/ - $HOME/.ocarina-debug/ - $HOME/.ocarina-test/ If filepath is an empty string, set the file hint to FILE_TYPE_INVALID and do not set the filepath field. @@ -175,7 +171,6 @@ On-disk files: - Read in version from the start of the file When opening a file for writing (mode == OPEN_WRITE), - - Return false if the file has FILE_TYPE_LEGACY set - Create missing directories as needed - Write version information to the start of the file @@ -538,14 +533,6 @@ Tag Database: Tags are defined in the sections below. -- Import data: - struct ImportData { - unsigned int last_year; - unsigned int last_month; - unsigned int last_day; - unsigned int play_count; - }; - - Databases: Database artist_db; Database album_db; @@ -567,12 +554,6 @@ Tag Database: Check the database size both before and after to see if a new track has been added. - Track *tagdb :: import_track(const std::string &filepath, - Library *library, ImportData *import); - Use add_track() to add a new track to the database. If the - return values != NULL, then use the import information to set - last played variables. - Library *tagdb :: add_library(const std::string &filepath); Add a new path to library_db. Return a pointer to the new path or return NULL if the path is already in the database. diff --git a/gui/collection_mgr.cpp b/gui/collection_mgr.cpp index cd17724f..e2d11f16 100644 --- a/gui/collection_mgr.cpp +++ b/gui/collection_mgr.cpp @@ -39,12 +39,6 @@ static void on_collection_update() enable_idle(); } -static void on_collection_import() -{ - library :: import(); - enable_idle(); -} - static void on_collection_row_activated(const Gtk::TreePath &path, Gtk::TreeViewColumn *col) { @@ -137,7 +131,6 @@ void collection_mgr_init() connect_button("o_collection_ok", on_collection_ok); connect_button("o_collection_update", on_collection_update); - connect_button("o_collection_import", on_collection_import); list->set_sort_column(collection_cols.c_col_path, Gtk::SORT_ASCENDING); treeview->signal_row_activated().connect(sigc::ptr_fun(on_collection_row_activated)); diff --git a/include/file.h b/include/file.h index ecd7a68e..a88db254 100644 --- a/include/file.h +++ b/include/file.h @@ -11,7 +11,6 @@ enum FileLocHint { FILE_TYPE_DATA, - FILE_TYPE_LEGACY, FILE_TYPE_INVALID, }; diff --git a/include/library.h b/include/library.h index de7aded8..21bdee13 100644 --- a/include/library.h +++ b/include/library.h @@ -25,7 +25,6 @@ namespace library void update_path(unsigned int); void update_all(); void set_enabled(unsigned int, bool); - void import(); void track_played(unsigned int); #ifdef CONFIG_TEST void print_db(DB_Type); diff --git a/include/tags.h b/include/tags.h index 64ea6f27..6cc3ca89 100644 --- a/include/tags.h +++ b/include/tags.h @@ -20,14 +20,6 @@ enum sort_t { }; -struct ImportData { - unsigned int last_year; - unsigned int last_month; - unsigned int last_day; - unsigned int play_count; -}; - - class Artist : public DatabaseEntry { public: std::string name; @@ -124,7 +116,6 @@ namespace tagdb void commit_library(); Track *add_track(const std::string &, Library *); - Track *import_track(const std::string &, Library *, const ImportData &); Library *add_library(const std::string &); void remove_track(unsigned int); void remove_library(unsigned int); diff --git a/lib/file.cpp b/lib/file.cpp index 02497518..025bdbdc 100644 --- a/lib/file.cpp +++ b/lib/file.cpp @@ -86,11 +86,6 @@ bool File :: open_read() bool File :: open_write() { - if (hint == FILE_TYPE_LEGACY) { - dprint("ERROR: Cannot write to legacy files\n"); - return false; - } - std::string dir = find_dir(); if (g_mkdir_with_parents(dir.c_str(), 0755) != 0) { dprint("ERROR: Could not make directory\n"); diff --git a/lib/library.cpp b/lib/library.cpp index 1cb0bb1f..044808e1 100644 --- a/lib/library.cpp +++ b/lib/library.cpp @@ -88,66 +88,6 @@ static void do_update_library(unsigned int lib_id) idle :: schedule(do_scan_path, scan); } -static void do_import_track(File &f, Library *library) -{ - struct ImportData data; - unsigned int year, banned, tmp; - - std::string filepath = f.getline(); - std::string title = f.getline(); - std::string artist = f.getline(); - std::string album = f.getline(); - std::string comment = f.getline(); - std::string genre = f.getline(); - std::string lenstr = f.getline(); - - f >> tmp /* id */ >> year >> tmp >> data.play_count; - f >> data.last_day >> data.last_month >> data.last_year >> tmp; - f >> tmp >> tmp >>tmp >> banned; /* bitrate, sample, channels, banned */ - f.getline(); /* get rest of line */ - - Track *track = tagdb :: import_track(filepath, library, data); - get_callbacks()->on_library_track_add(track->id); - - if (banned == true) - get_callbacks()->on_library_import_ban(track->id); -} - -static void do_import_library(std::string &s) -{ - unsigned int id, next_id, size; - std::string path; - bool enabled; - File f(s, FILE_TYPE_LEGACY); - - print("Importing: %s\n", f.get_filepath()); - f.open(OPEN_READ); - - if (f.get_version() != 2) { - print("Version mismatch: %u != 2\n", f.get_version()); - return; - } - - path = f.getline(); - f >> id >> enabled >> next_id >> size; - - Library *library = tagdb :: add_library(path); - if (library == NULL) { - print("Library already contains path: %s, skipping\n", path.c_str()); - return; - } - print("Adding path: %s\n", path.c_str()); - get_callbacks()->on_library_add(library->id, library); - - f.getline(); /* Get rest of line */ - for (unsigned int i = 0; i < size; i++) - do_import_track(f, library); - tagdb :: commit(); - get_callbacks()->on_library_update(library->id, library); - - library :: update_path(id); -} - /* @@ -236,27 +176,6 @@ void library :: set_enabled(unsigned int id, bool enabled) } } -void library :: import() -{ - unsigned int i = 0; - std::string name; - - do { - std::stringstream ss; - ss << i; - - name = ss.str(); - File f(name, FILE_TYPE_LEGACY); - - if (f.exists() == false) - break; - - idle :: schedule(do_import_library, name); - ss.clear(); - i++; - } while (true); -} - void library :: track_played(unsigned int id) { time_t the_time = time(NULL); diff --git a/lib/tags.cpp b/lib/tags.cpp index c3f8ec1f..8dc7949a 100644 --- a/lib/tags.cpp +++ b/lib/tags.cpp @@ -339,19 +339,6 @@ Track *tagdb :: add_track(const std::string &filepath, Library *library) return track; } -Track *tagdb :: import_track(const std::string &filepath, Library *library, - const ImportData &import) -{ - Track *track = add_track(filepath, library); - if (track) { - track->last_year = import.last_year; - track->last_month = import.last_month; - track->last_day = import.last_day; - track->play_count = import.play_count; - } - return track; -} - Library *tagdb :: add_library(const std::string &filepath) { unsigned int size = library_db.size(); diff --git a/share/ocarina/ocarina6.glade b/share/ocarina/ocarina6.glade index 272b5ea3..6e30b166 100644 --- a/share/ocarina/ocarina6.glade +++ b/share/ocarina/ocarina6.glade @@ -1242,51 +1242,6 @@ Manager 1 - - - True - True - True - - - True - False - True - - - True - False - gtk-convert - - - False - True - 0 - - - - - True - False - Import - center - - - False - True - 1 - - - - - - - False - True - 5 - 2 - - False diff --git a/tests/file b/tests/file index c23da453..acd65686 100755 --- a/tests/file +++ b/tests/file @@ -24,12 +24,9 @@ function test_chmod new_test "Filepath Test" test_file -D INVALID -test_file -L INVALID test_file "-D file.txt" "$DATA_DIR/file.txt" -test_file "-L file.txt" "$LEGACY_DIR/file.txt" test_file "file.txt" INVALID test_file "-D -v file.txt" "0" -test_file "-L -v file.txt" "0" if [ -d $DATA_DIR ]; then echo "ERROR: $DATA_DIR should not exist!" @@ -61,8 +58,6 @@ test_file "-D -o R file.txt" "ERROR: File could not be opened for reading" rm -r $DATA_DIR # Test opening for write -test_file "-L -o W file.txt" "ERROR: Cannot write to legacy files" - touch $DATA_DIR test_file "-D -o W file.txt" "ERROR: Could not make directory" diff --git a/tests/src/file.cpp b/tests/src/file.cpp index df651726..64a11dcd 100644 --- a/tests/src/file.cpp +++ b/tests/src/file.cpp @@ -53,7 +53,7 @@ int main(int argc, char **argv) std::string file; std::string data; - while ((c = getopt(argc, argv, "cDgLo:Orvw")) != -1) { + while ((c = getopt(argc, argv, "cDgo:Orvw")) != -1) { switch (c) { case 'c': action = CLOSE; @@ -64,9 +64,6 @@ int main(int argc, char **argv) case 'g': getline = true; break; - case 'L': - hint = FILE_TYPE_LEGACY; - break; case 'o': action = OPEN; switch (optarg[0]) { diff --git a/tests/src/tagdb.cpp b/tests/src/tagdb.cpp index 8097e173..5a97351c 100644 --- a/tests/src/tagdb.cpp +++ b/tests/src/tagdb.cpp @@ -124,22 +124,6 @@ test_tracks: test_track_size(0, __LINE__); - /** - * Test importing a track - */ - ImportData import; - import.last_year = 2014; - import.last_month = 4; - import.last_day = 1; - import.play_count = 7; - - library = tagdb :: add_library("Music"); - track = tagdb :: import_track("Music/1.ogg", library, import); - test_results(track->last_year == 2014, __LINE__); - test_results(track->last_month == 4, __LINE__); - test_results(track->last_day == 1, __LINE__); - test_results(track->play_count == 7, __LINE__); - if (init_called == true) tagdb :: commit();