Track tags need to add themselves to the filter index and update the
library track count once added to the database.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
The Track tag needs to do some cleanup when removed from a database, so
we need to use this op when removing items.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
For allocating new database items from a given key. Tracks do not need
this function since we have special handling for creation and insertion.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
I replace the standard and copy constructors with one that tags a track
during construction. This lets me clean up a lot of code, and keep
tagging functions internal to the track class.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
We want to loop over the track database in several places, so let's make
this easier by just returning the database itself.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
It's easier to just pass off the library database rather than forcing
higher layers to iterate over the entire thing (including possible
invalid entries).
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
I also have to replace the "library" namespace with the "collection"
namespace to avoid naming collisions.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This function is similar to Linux's list_for_each_safe(), and lets you
iterate over a database even if the current item is removed.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
I also take the chance to modify this function slightly. Now, if a
matching item could not be found a new item will be allocated.
I added the new function db_get() if callers just want to get an item
without allocating.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
I noticed that tracks beginning with a number were getting combined with
the seconds field, creating an inaccurate seconds count and modifying
the title at the same time.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
I also introduced a file_readf() function to make it easier to read a
formatted string from the file.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
I also introduced a file_writef() function to make it easier to write a
formatted string to the file.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
I replace it with calls to g_strdup_printf(). This has the additional
benefit that I can do uint conversions at the same time as other
formatting options, so this seems like a win. The only downside is that
I have to manually free the memory that glib allocates, but that's easy
enough.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This patch fixes up formatting a little bit and removes the Track
section of the DESIGN document.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This has been disabled for some time. I added a test for adding track
indexes to the filter upon creation, but it doesn't properly test adding
to the filter when reading from disk.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This code is really testing date and locale handling, so this patch
renames the function to match what it actually does. While I'm at it, I
also introduce some cleanups.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This returns the actual size of the database, so be careful when using
it! The intent of this function is to allow some kind of iteration when
loading databases.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
The track_db doesn't have autosaving enabled for performance reasons.
This lets us add several tracks to the database between saves, but it
also means we need to provide a commit() function.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
I'm going to need to split this value earlier to do a unique lookup when
inserting, so the constructor can take the relative path to make things
easier.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
I don't want to expose the date structure outside of the track class, so
I'll provide a comparison function instead.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
The new constructor covers these cases without needing to do taglib
stuff inside the Track class.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This patch creates a new structure to track the last played date, which
can be expanded into a class at some future point. Additionally, I use
strftime() to calculate the current date based on the user's current
locale settings.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
I don't want anybody outside of this class changing the value, so it
shouldn't be public. I also change the primary key to use library index
instead of the full filepath while I'm at it.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
I don't think this value needs to be stored anywhere in the Track class
since it's fairly easy to calculate. Let's convert it into a function
for now and reevaluate later!
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
I provide an accessor function to keep this value from ever getting
changed outside of the Track class.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
We want to make sure that the _library size is decremented whenever a
track is removed or destroyed.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
I want to provide the Library, Artist, Album, and Genre tags to the
Track on construction to (hopefully) eliminate the Track::tag()
function.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
I also use this opportunity to create a new default constructor test for
the Track tag. This patch also disables the tags test since the tagdb
will be going away soon.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
I was only ever comparing the lowercase version of the name, so this
should be done in a single place (the GenericTag) to make maintenance
easier.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This patch moves the library_db into tags/library.cpp, where it can be
effectively managed by the Library tag. For this to work, I need to add
some extra functions to the tags namespace to:
- Create new Library tags,
- Find tags by index,
- Remove the Library at a specific index, and
- Find the actual size of the library_db.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
The genre_db should really be controlled from within the Genre tag,
so this patch adds functions to find or create Genre tags to the tags
namespace.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
The album_db should really be controlled from within the Album tag, so
this patch adds functions to find or create Album tags to the tags
namespace.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
The artist_db should really be controlled from within the Artist tag, so
this patch creates a new tags namespace containing functions that will
find or create tags as they are requested.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
- This tag now inherits from GenericTag.
- Add a Genre-specific unit test.
- Remove the genre tag section of the DESIGN file.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
Also make it inherit from the GenericTag base class. Also also, add a
unit test specific to Album tags. Finally, I remove the corresponding
section of the DESIGN file since it is no longer needed.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
core/tags.cpp was WAY too big, so I moved this code into a new file in
its own directory. I also created a new unit test just for testing the
Artist tag.
This patch disables the "tags" test since it conflicts with the
tests/core/tags/ directory. This is okay because the tagdb is gradually
being phased out!
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>