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 <anna@ocarinaproject.net>
This commit is contained in:
Anna Schumaker 2014-04-09 20:59:15 -04:00
parent 1c743239a0
commit 5ff68140b5
12 changed files with 4 additions and 209 deletions

25
DESIGN
View File

@ -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> artist_db;
Database<Album> 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.

View File

@ -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));

View File

@ -11,7 +11,6 @@
enum FileLocHint {
FILE_TYPE_DATA,
FILE_TYPE_LEGACY,
FILE_TYPE_INVALID,
};

View File

@ -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);

View File

@ -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);

View File

@ -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");

View File

@ -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);

View File

@ -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();

View File

@ -1242,51 +1242,6 @@ Manager</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="o_collection_import">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<child>
<object class="GtkBox" id="box14">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkImage" id="image11">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-convert</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label7">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Import</property>
<property name="justify">center</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">5</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>

View 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"

View File

@ -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]) {

View File

@ -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();