2021-03-02 19:12:12 +02:00
|
|
|
/* structs.h
|
|
|
|
*
|
|
|
|
* Copyright 2021 Joshua Strobl
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#include <glib-2.0/glib-object.h>
|
|
|
|
#include <magic.h>
|
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Type Definition
|
2021-05-11 20:05:04 +03:00
|
|
|
**/
|
2021-03-02 19:12:12 +02:00
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
#define KOTO_TYPE_LIBRARY koto_library_get_type()
|
|
|
|
G_DECLARE_FINAL_TYPE(KotoLibrary, koto_library, KOTO, LIBRARY, GObject);
|
|
|
|
#define KOTO_IS_LIBRARY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), KOTO_TYPE_LIBRARY))
|
2021-03-02 19:12:12 +02:00
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
#define KOTO_TYPE_ARTIST koto_artist_get_type()
|
|
|
|
G_DECLARE_FINAL_TYPE(KotoArtist, koto_artist, KOTO, ARTIST, GObject);
|
|
|
|
#define KOTO_IS_ARTIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), KOTO_TYPE_ARTIST))
|
2021-03-02 19:12:12 +02:00
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
#define KOTO_TYPE_ALBUM koto_album_get_type()
|
|
|
|
G_DECLARE_FINAL_TYPE(KotoAlbum, koto_album, KOTO, ALBUM, GObject);
|
|
|
|
#define KOTO_IS_ALBUM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), KOTO_TYPE_ALBUM))
|
2021-03-02 19:12:12 +02:00
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
#define KOTO_TYPE_TRACK koto_track_get_type()
|
|
|
|
G_DECLARE_FINAL_TYPE(KotoTrack, koto_track, KOTO, TRACK, GObject);
|
|
|
|
#define KOTO_IS_TRACK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), KOTO_TYPE_TRACK))
|
2021-03-02 19:12:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Library Functions
|
2021-05-11 20:05:04 +03:00
|
|
|
**/
|
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
KotoLibrary * koto_library_new(const gchar * path);
|
2021-05-11 20:05:04 +03:00
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
void koto_library_add_artist(
|
|
|
|
KotoLibrary * self,
|
|
|
|
KotoArtist * artist
|
2021-05-11 20:05:04 +03:00
|
|
|
);
|
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
KotoArtist * koto_library_get_artist(
|
|
|
|
KotoLibrary * self,
|
2021-05-11 20:05:04 +03:00
|
|
|
gchar* artist_name
|
|
|
|
);
|
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
GHashTable * koto_library_get_artists(KotoLibrary * self);
|
2021-05-11 20:05:04 +03:00
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
void koto_library_remove_artist(
|
|
|
|
KotoLibrary * self,
|
|
|
|
KotoArtist * artist
|
2021-05-11 20:05:04 +03:00
|
|
|
);
|
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
void koto_library_set_path(
|
|
|
|
KotoLibrary * self,
|
2021-05-11 20:05:04 +03:00
|
|
|
gchar * path
|
|
|
|
);
|
|
|
|
|
|
|
|
int process_artists(
|
|
|
|
void * data,
|
|
|
|
int num_columns,
|
|
|
|
char ** fields,
|
|
|
|
char ** column_names
|
|
|
|
);
|
|
|
|
|
|
|
|
int process_albums(
|
|
|
|
void * data,
|
|
|
|
int num_columns,
|
|
|
|
char ** fields,
|
|
|
|
char ** column_names
|
|
|
|
);
|
|
|
|
|
|
|
|
int process_playlists(
|
|
|
|
void * data,
|
|
|
|
int num_columns,
|
|
|
|
char ** fields,
|
|
|
|
char ** column_names
|
|
|
|
);
|
|
|
|
|
|
|
|
int process_playlists_tracks(
|
|
|
|
void * data,
|
|
|
|
int num_columns,
|
|
|
|
char ** fields,
|
|
|
|
char ** column_names
|
|
|
|
);
|
|
|
|
|
|
|
|
int process_tracks(
|
|
|
|
void * data,
|
|
|
|
int num_columns,
|
|
|
|
char ** fields,
|
|
|
|
char ** column_names
|
|
|
|
);
|
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
void read_from_db(KotoLibrary * self);
|
2021-05-11 20:05:04 +03:00
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
void start_indexing(KotoLibrary * self);
|
2021-05-11 20:05:04 +03:00
|
|
|
|
|
|
|
void index_folder(
|
2021-05-11 20:08:39 +03:00
|
|
|
KotoLibrary * self,
|
2021-05-11 20:05:04 +03:00
|
|
|
gchar * path,
|
|
|
|
guint depth
|
|
|
|
);
|
|
|
|
|
|
|
|
void output_track(
|
|
|
|
gpointer data,
|
|
|
|
gpointer user_data
|
|
|
|
);
|
2021-03-02 19:12:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Artist Functions
|
2021-05-11 20:05:04 +03:00
|
|
|
**/
|
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
KotoArtist * koto_artist_new(gchar * path);
|
2021-05-11 20:05:04 +03:00
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
KotoArtist * koto_artist_new_with_uuid(const gchar * uuid);
|
2021-05-11 20:05:04 +03:00
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
void koto_artist_add_album(
|
|
|
|
KotoArtist * self,
|
2021-05-11 20:05:04 +03:00
|
|
|
gchar * album_uuid
|
|
|
|
);
|
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
void koto_artist_commit(KotoArtist * self);
|
2021-05-11 20:05:04 +03:00
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
guint koto_artist_find_album_with_name(
|
2021-05-11 20:05:04 +03:00
|
|
|
gconstpointer * album_data,
|
|
|
|
gconstpointer * album_name_data
|
|
|
|
);
|
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
GList * koto_artist_get_albums(KotoArtist * self);
|
2021-05-11 20:05:04 +03:00
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
gchar * koto_artist_get_name(KotoArtist * self);
|
2021-05-11 20:05:04 +03:00
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
void koto_artist_remove_album(
|
|
|
|
KotoArtist * self,
|
|
|
|
KotoAlbum * album
|
2021-05-11 20:05:04 +03:00
|
|
|
);
|
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
void koto_artist_remove_album_by_name(
|
|
|
|
KotoArtist * self,
|
2021-05-11 20:05:04 +03:00
|
|
|
gchar * album_name
|
|
|
|
);
|
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
void koto_artist_set_artist_name(
|
|
|
|
KotoArtist * self,
|
2021-05-11 20:05:04 +03:00
|
|
|
gchar * artist_name
|
|
|
|
);
|
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
void koto_artist_update_path(
|
|
|
|
KotoArtist * self,
|
2021-05-11 20:05:04 +03:00
|
|
|
gchar * new_path
|
|
|
|
);
|
|
|
|
|
|
|
|
void output_artists(
|
|
|
|
gpointer artist_key,
|
|
|
|
gpointer artist_ptr,
|
|
|
|
gpointer data
|
|
|
|
);
|
2021-03-02 19:12:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Album Functions
|
2021-05-11 20:05:04 +03:00
|
|
|
**/
|
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
KotoAlbum * koto_album_new(
|
|
|
|
KotoArtist * artist,
|
2021-05-11 20:05:04 +03:00
|
|
|
const gchar * path
|
|
|
|
);
|
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
KotoAlbum * koto_album_new_with_uuid(
|
|
|
|
KotoArtist * artist,
|
2021-05-11 20:05:04 +03:00
|
|
|
const gchar * uuid
|
|
|
|
);
|
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
void koto_album_add_track(
|
|
|
|
KotoAlbum * self,
|
|
|
|
KotoTrack * track
|
2021-05-11 20:05:04 +03:00
|
|
|
);
|
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
void koto_album_commit(KotoAlbum * self);
|
2021-05-11 20:05:04 +03:00
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
void koto_album_find_album_art(KotoAlbum * self);
|
2021-05-11 20:05:04 +03:00
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
void koto_album_find_tracks(
|
|
|
|
KotoAlbum * self,
|
2021-05-11 20:05:04 +03:00
|
|
|
magic_t magic_cookie,
|
|
|
|
const gchar * path
|
|
|
|
);
|
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
gchar * koto_album_get_album_art(KotoAlbum * self);
|
2021-05-11 20:05:04 +03:00
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
gchar * koto_album_get_album_name(KotoAlbum * self);
|
2021-05-11 20:05:04 +03:00
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
gchar * koto_album_get_album_uuid(KotoAlbum * self);
|
2021-05-11 20:05:04 +03:00
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
GList * koto_album_get_tracks(KotoAlbum * self);
|
2021-05-11 20:05:04 +03:00
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
void koto_album_remove_file(
|
|
|
|
KotoAlbum * self,
|
|
|
|
KotoTrack * track
|
2021-05-11 20:05:04 +03:00
|
|
|
);
|
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
void koto_album_set_album_art(
|
|
|
|
KotoAlbum * self,
|
2021-05-11 20:05:04 +03:00
|
|
|
const gchar * album_art
|
|
|
|
);
|
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
void koto_album_set_album_name(
|
|
|
|
KotoAlbum * self,
|
2021-05-11 20:05:04 +03:00
|
|
|
const gchar * album_name
|
|
|
|
);
|
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
void koto_album_set_artist_uuid(
|
|
|
|
KotoAlbum * self,
|
2021-05-11 20:05:04 +03:00
|
|
|
const gchar * artist_uuid
|
|
|
|
);
|
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
void koto_album_set_as_current_playlist(KotoAlbum * self);
|
2021-05-11 20:05:04 +03:00
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
void koto_album_update_path(
|
|
|
|
KotoAlbum * self,
|
2021-05-11 20:05:04 +03:00
|
|
|
gchar * path
|
|
|
|
);
|
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
gint koto_album_sort_tracks(
|
2021-05-11 20:05:04 +03:00
|
|
|
gconstpointer track1_uuid,
|
|
|
|
gconstpointer track2_uuid,
|
|
|
|
gpointer user_data
|
|
|
|
);
|
2021-03-02 19:12:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* File / Track Functions
|
2021-05-11 20:05:04 +03:00
|
|
|
**/
|
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
KotoTrack * koto_track_new(
|
|
|
|
KotoAlbum * album,
|
2021-05-11 20:05:04 +03:00
|
|
|
const gchar * path,
|
|
|
|
guint * cd
|
|
|
|
);
|
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
KotoTrack * koto_track_new_with_uuid(const gchar * uuid);
|
2021-05-11 20:05:04 +03:00
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
void koto_track_commit(KotoTrack * self);
|
2021-05-11 20:05:04 +03:00
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
GVariant * koto_track_get_metadata_vardict(KotoTrack * self);
|
2021-05-11 20:05:04 +03:00
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
gchar * koto_track_get_uuid(KotoTrack * self);
|
2021-05-11 20:05:04 +03:00
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
void koto_track_parse_name(KotoTrack * self);
|
2021-05-11 20:05:04 +03:00
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
void koto_track_remove_from_playlist(
|
|
|
|
KotoTrack * self,
|
2021-05-11 20:05:04 +03:00
|
|
|
gchar * playlist_uuid
|
|
|
|
);
|
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
void koto_track_save_to_playlist(
|
|
|
|
KotoTrack * self,
|
2021-05-11 20:05:04 +03:00
|
|
|
gchar * playlist_uuid,
|
|
|
|
gint current
|
|
|
|
);
|
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
void koto_track_set_file_name(
|
|
|
|
KotoTrack * self,
|
2021-05-11 20:05:04 +03:00
|
|
|
gchar * new_file_name
|
|
|
|
);
|
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
void koto_track_set_cd(
|
|
|
|
KotoTrack * self,
|
2021-05-11 20:05:04 +03:00
|
|
|
guint cd
|
|
|
|
);
|
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
void koto_track_set_parsed_name(
|
|
|
|
KotoTrack * self,
|
2021-05-11 20:05:04 +03:00
|
|
|
gchar * new_parsed_name
|
|
|
|
);
|
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
void koto_track_set_position(
|
|
|
|
KotoTrack * self,
|
2021-05-11 20:05:04 +03:00
|
|
|
guint pos
|
|
|
|
);
|
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
void koto_track_update_metadata(KotoTrack * self);
|
2021-05-11 20:05:04 +03:00
|
|
|
|
2021-05-11 20:08:39 +03:00
|
|
|
void koto_track_update_path(
|
|
|
|
KotoTrack * self,
|
2021-05-11 20:05:04 +03:00
|
|
|
const gchar * new_path
|
|
|
|
);
|
2021-03-02 19:12:12 +02:00
|
|
|
|
|
|
|
G_END_DECLS
|