Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
VideoLAN
medialibrary
Commits
724599b0
Commit
724599b0
authored
Nov 07, 2017
by
Hugo Beauzée-Luyssen
Browse files
Remove global DBConnection typedef
parent
911c31d9
Changes
38
Hide whitespace changes
Inline
Side-by-side
include/Types.h
View file @
724599b0
...
...
@@ -25,13 +25,7 @@
namespace
medialibrary
{
namespace
sqlite
{
class
Connection
;
}
class
MediaLibrary
;
using
DBConnection
=
sqlite
::
Connection
*
;
using
MediaLibraryPtr
=
const
MediaLibrary
*
;
}
src/Album.cpp
View file @
724599b0
...
...
@@ -331,7 +331,7 @@ bool Album::removeArtist(Artist* artist)
return
sqlite
::
Tools
::
executeDelete
(
m_ml
->
getConn
(),
req
,
m_id
,
artist
->
id
()
);
}
bool
Album
::
createTable
(
DB
Connection
dbConnection
)
bool
Album
::
createTable
(
sqlite
::
Connection
*
dbConnection
)
{
const
std
::
string
req
=
"CREATE TABLE IF NOT EXISTS "
+
policy
::
AlbumTable
::
Name
+
...
...
@@ -370,7 +370,7 @@ bool Album::createTable(DBConnection dbConnection )
sqlite
::
Tools
::
executeRequest
(
dbConnection
,
indexReq
);
}
bool
Album
::
createTriggers
(
DB
Connection
dbConnection
)
bool
Album
::
createTriggers
(
sqlite
::
Connection
*
dbConnection
)
{
static
const
std
::
string
triggerReq
=
"CREATE TRIGGER IF NOT EXISTS is_album_present AFTER UPDATE OF "
"is_present ON "
+
policy
::
AlbumTrackTable
::
Name
+
...
...
src/Album.h
View file @
724599b0
...
...
@@ -98,8 +98,8 @@ class Album : public IAlbum, public DatabaseHelpers<Album, policy::AlbumTable>
bool
addArtist
(
std
::
shared_ptr
<
Artist
>
artist
);
bool
removeArtist
(
Artist
*
artist
);
static
bool
createTable
(
DB
Connection
dbConnection
);
static
bool
createTriggers
(
DB
Connection
dbConnection
);
static
bool
createTable
(
sqlite
::
Connection
*
dbConnection
);
static
bool
createTriggers
(
sqlite
::
Connection
*
dbConnection
);
static
std
::
shared_ptr
<
Album
>
create
(
MediaLibraryPtr
ml
,
const
std
::
string
&
title
,
const
std
::
string
&
artworkMrl
);
static
std
::
shared_ptr
<
Album
>
createUnknownAlbum
(
MediaLibraryPtr
ml
,
const
Artist
*
artist
);
///
...
...
src/AlbumTrack.cpp
View file @
724599b0
...
...
@@ -98,7 +98,7 @@ bool AlbumTrack::setArtist( std::shared_ptr<Artist> artist )
return
true
;
}
bool
AlbumTrack
::
createTable
(
DB
Connection
dbConnection
)
bool
AlbumTrack
::
createTable
(
sqlite
::
Connection
*
dbConnection
)
{
const
std
::
string
req
=
"CREATE TABLE IF NOT EXISTS "
+
policy
::
AlbumTrackTable
::
Name
+
"("
"id_track INTEGER PRIMARY KEY AUTOINCREMENT,"
...
...
src/AlbumTrack.h
View file @
724599b0
...
...
@@ -68,14 +68,14 @@ class AlbumTrack : public IAlbumTrack, public DatabaseHelpers<AlbumTrack, policy
virtual
std
::
shared_ptr
<
IAlbum
>
album
()
override
;
virtual
std
::
shared_ptr
<
IMedia
>
media
()
override
;
static
bool
createTable
(
DB
Connection
dbConnection
);
static
bool
createTable
(
sqlite
::
Connection
*
dbConnection
);
static
std
::
shared_ptr
<
AlbumTrack
>
create
(
MediaLibraryPtr
ml
,
int64_t
albumId
,
std
::
shared_ptr
<
Media
>
media
,
unsigned
int
trackNb
,
unsigned
int
discNumber
,
int64_t
artistId
,
int64_t
genreId
,
int64_t
duration
);
static
AlbumTrackPtr
fromMedia
(
MediaLibraryPtr
ml
,
int64_t
mediaId
);
static
std
::
vector
<
MediaPtr
>
fromGenre
(
MediaLibraryPtr
ml
,
int64_t
genreId
,
SortingCriteria
sort
,
bool
desc
);
static
std
::
vector
<
MediaPtr
>
search
(
DB
Connection
dbConn
,
const
std
::
string
&
title
);
static
std
::
vector
<
MediaPtr
>
search
(
sqlite
::
Connection
*
dbConn
,
const
std
::
string
&
title
);
private:
MediaLibraryPtr
m_ml
;
...
...
src/Artist.cpp
View file @
724599b0
...
...
@@ -189,7 +189,7 @@ bool Artist::setMusicBrainzId( const std::string& mbId )
return
true
;
}
bool
Artist
::
createTable
(
DB
Connection
dbConnection
)
bool
Artist
::
createTable
(
sqlite
::
Connection
*
dbConnection
)
{
const
std
::
string
req
=
"CREATE TABLE IF NOT EXISTS "
+
policy
::
ArtistTable
::
Name
+
...
...
@@ -220,7 +220,7 @@ bool Artist::createTable( DBConnection dbConnection )
sqlite
::
Tools
::
executeRequest
(
dbConnection
,
reqFts
);
}
bool
Artist
::
createTriggers
(
DB
Connection
dbConnection
)
bool
Artist
::
createTriggers
(
sqlite
::
Connection
*
dbConnection
)
{
static
const
std
::
string
triggerReq
=
"CREATE TRIGGER IF NOT EXISTS has_album_present AFTER UPDATE OF "
"is_present ON "
+
policy
::
AlbumTable
::
Name
+
...
...
@@ -261,7 +261,7 @@ bool Artist::createTriggers(DBConnection dbConnection)
sqlite
::
Tools
::
executeRequest
(
dbConnection
,
ftsDeleteTrigger
);
}
bool
Artist
::
createDefaultArtists
(
DB
Connection
dbConnection
)
bool
Artist
::
createDefaultArtists
(
sqlite
::
Connection
*
dbConnection
)
{
// Don't rely on Artist::create, since we want to insert or do nothing here.
// This will skip the cache for those new entities, but they will be inserted soon enough anyway.
...
...
src/Artist.h
View file @
724599b0
...
...
@@ -63,9 +63,9 @@ public:
virtual
const
std
::
string
&
musicBrainzId
()
const
override
;
bool
setMusicBrainzId
(
const
std
::
string
&
musicBrainzId
);
static
bool
createTable
(
DB
Connection
dbConnection
);
static
bool
createTriggers
(
DB
Connection
dbConnection
);
static
bool
createDefaultArtists
(
DB
Connection
dbConnection
);
static
bool
createTable
(
sqlite
::
Connection
*
dbConnection
);
static
bool
createTriggers
(
sqlite
::
Connection
*
dbConnection
);
static
bool
createDefaultArtists
(
sqlite
::
Connection
*
dbConnection
);
static
std
::
shared_ptr
<
Artist
>
create
(
MediaLibraryPtr
ml
,
const
std
::
string
&
name
);
static
std
::
vector
<
ArtistPtr
>
search
(
MediaLibraryPtr
ml
,
const
std
::
string
&
name
);
static
std
::
vector
<
ArtistPtr
>
listAll
(
MediaLibraryPtr
ml
,
SortingCriteria
sort
,
bool
desc
);
...
...
src/AudioTrack.cpp
View file @
724599b0
...
...
@@ -97,7 +97,7 @@ const std::string& AudioTrack::description() const
return
m_description
;
}
bool
AudioTrack
::
createTable
(
DB
Connection
dbConnection
)
bool
AudioTrack
::
createTable
(
sqlite
::
Connection
*
dbConnection
)
{
//FIXME: Index on media_id ? Unless it's already implied by the foreign key
const
std
::
string
req
=
"CREATE TABLE IF NOT EXISTS "
+
policy
::
AudioTrackTable
::
Name
...
...
src/AudioTrack.h
View file @
724599b0
...
...
@@ -58,7 +58,7 @@ class AudioTrack : public IAudioTrack, public DatabaseHelpers<AudioTrack, policy
virtual
const
std
::
string
&
language
()
const
override
;
virtual
const
std
::
string
&
description
()
const
override
;
static
bool
createTable
(
DB
Connection
dbConnection
);
static
bool
createTable
(
sqlite
::
Connection
*
dbConnection
);
static
std
::
shared_ptr
<
AudioTrack
>
create
(
MediaLibraryPtr
ml
,
const
std
::
string
&
codec
,
unsigned
int
bitrate
,
unsigned
int
sampleRate
,
unsigned
int
nbChannels
,
const
std
::
string
&
language
,
const
std
::
string
&
desc
,
int64_t
mediaId
);
...
...
src/Device.cpp
View file @
724599b0
...
...
@@ -100,7 +100,7 @@ std::shared_ptr<Device> Device::create( MediaLibraryPtr ml, const std::string& u
return
self
;
}
bool
Device
::
createTable
(
DB
Connection
connection
)
bool
Device
::
createTable
(
sqlite
::
Connection
*
connection
)
{
const
std
::
string
req
=
"CREATE TABLE IF NOT EXISTS "
+
policy
::
DeviceTable
::
Name
+
"("
"id_device INTEGER PRIMARY KEY AUTOINCREMENT,"
...
...
src/Device.h
View file @
724599b0
...
...
@@ -59,7 +59,7 @@ public:
const
std
::
string
&
scheme
()
const
;
static
std
::
shared_ptr
<
Device
>
create
(
MediaLibraryPtr
ml
,
const
std
::
string
&
uuid
,
const
std
::
string
&
scheme
,
bool
isRemovable
);
static
bool
createTable
(
DB
Connection
connection
);
static
bool
createTable
(
sqlite
::
Connection
*
connection
);
static
std
::
shared_ptr
<
Device
>
fromUuid
(
MediaLibraryPtr
ml
,
const
std
::
string
&
uuid
);
private:
...
...
src/File.cpp
View file @
724599b0
...
...
@@ -190,7 +190,7 @@ int64_t File::folderId()
return
m_folderId
;
}
bool
File
::
createTable
(
DB
Connection
dbConnection
)
bool
File
::
createTable
(
sqlite
::
Connection
*
dbConnection
)
{
std
::
string
req
=
"CREATE TABLE IF NOT EXISTS "
+
policy
::
FileTable
::
Name
+
"("
"id_file INTEGER PRIMARY KEY AUTOINCREMENT,"
...
...
src/File.h
View file @
724599b0
...
...
@@ -77,7 +77,7 @@ public:
bool
destroy
();
int64_t
folderId
();
static
bool
createTable
(
DB
Connection
dbConnection
);
static
bool
createTable
(
sqlite
::
Connection
*
dbConnection
);
static
std
::
shared_ptr
<
File
>
createFromMedia
(
MediaLibraryPtr
ml
,
int64_t
mediaId
,
Type
type
,
const
fs
::
IFile
&
file
,
int64_t
folderId
,
bool
isRemovable
);
static
std
::
shared_ptr
<
File
>
createFromMedia
(
MediaLibraryPtr
ml
,
int64_t
mediaId
,
Type
type
,
...
...
src/Folder.cpp
View file @
724599b0
...
...
@@ -70,7 +70,7 @@ Folder::Folder(MediaLibraryPtr ml, const std::string& path, int64_t parent, int6
{
}
bool
Folder
::
createTable
(
DB
Connection
connection
)
bool
Folder
::
createTable
(
sqlite
::
Connection
*
connection
)
{
std
::
string
req
=
"CREATE TABLE IF NOT EXISTS "
+
policy
::
FolderTable
::
Name
+
"("
...
...
src/Folder.h
View file @
724599b0
...
...
@@ -60,7 +60,7 @@ public:
Folder
(
MediaLibraryPtr
ml
,
sqlite
::
Row
&
row
);
Folder
(
MediaLibraryPtr
ml
,
const
std
::
string
&
path
,
int64_t
parent
,
int64_t
deviceId
,
bool
isRemovable
);
static
bool
createTable
(
DB
Connection
connection
);
static
bool
createTable
(
sqlite
::
Connection
*
connection
);
static
std
::
shared_ptr
<
Folder
>
create
(
MediaLibraryPtr
ml
,
const
std
::
string
&
mrl
,
int64_t
parentId
,
Device
&
device
,
fs
::
IDevice
&
deviceFs
);
static
bool
blacklist
(
MediaLibraryPtr
ml
,
const
std
::
string
&
mrl
);
static
std
::
vector
<
std
::
shared_ptr
<
Folder
>>
fetchRootFolders
(
MediaLibraryPtr
ml
);
...
...
src/Genre.cpp
View file @
724599b0
...
...
@@ -97,7 +97,7 @@ std::vector<AlbumPtr> Genre::albums( SortingCriteria sort, bool desc ) const
return
Album
::
fromGenre
(
m_ml
,
m_id
,
sort
,
desc
);
}
bool
Genre
::
createTable
(
DB
Connection
dbConn
)
bool
Genre
::
createTable
(
sqlite
::
Connection
*
dbConn
)
{
const
std
::
string
req
=
"CREATE TABLE IF NOT EXISTS "
+
policy
::
GenreTable
::
Name
+
"("
...
...
@@ -126,7 +126,7 @@ bool Genre::createTable( DBConnection dbConn )
sqlite
::
Tools
::
executeRequest
(
dbConn
,
vtableDeleteTrigger
);
}
bool
Genre
::
createTriggers
(
DB
Connection
dbConn
)
bool
Genre
::
createTriggers
(
sqlite
::
Connection
*
dbConn
)
{
const
std
::
string
onGenreChanged
=
"CREATE TRIGGER IF NOT EXISTS on_track_genre_changed AFTER UPDATE OF "
" genre_id ON "
+
policy
::
AlbumTrackTable
::
Name
+
...
...
src/Genre.h
View file @
724599b0
...
...
@@ -54,8 +54,8 @@ public:
virtual
std
::
vector
<
MediaPtr
>
tracks
(
SortingCriteria
sort
,
bool
desc
)
const
override
;
virtual
std
::
vector
<
AlbumPtr
>
albums
(
SortingCriteria
sort
,
bool
desc
)
const
override
;
static
bool
createTable
(
DB
Connection
dbConn
);
static
bool
createTriggers
(
DB
Connection
dbConn
);
static
bool
createTable
(
sqlite
::
Connection
*
dbConn
);
static
bool
createTriggers
(
sqlite
::
Connection
*
dbConn
);
static
std
::
shared_ptr
<
Genre
>
create
(
MediaLibraryPtr
ml
,
const
std
::
string
&
name
);
static
std
::
shared_ptr
<
Genre
>
fromName
(
MediaLibraryPtr
ml
,
const
std
::
string
&
name
);
static
std
::
vector
<
GenrePtr
>
search
(
MediaLibraryPtr
ml
,
const
std
::
string
&
name
);
...
...
src/History.cpp
View file @
724599b0
...
...
@@ -49,7 +49,7 @@ History::History( MediaLibraryPtr ml, sqlite::Row& row )
row
>>
m_date
;
}
bool
History
::
createTable
(
DB
Connection
dbConnection
)
bool
History
::
createTable
(
sqlite
::
Connection
*
dbConnection
)
{
const
std
::
string
req
=
"CREATE TABLE IF NOT EXISTS "
+
policy
::
HistoryTable
::
Name
+
"("
...
...
@@ -70,7 +70,7 @@ bool History::createTable( DBConnection dbConnection )
sqlite
::
Tools
::
executeRequest
(
dbConnection
,
triggerReq
);
}
bool
History
::
insert
(
DB
Connection
dbConn
,
int64_t
mediaId
)
bool
History
::
insert
(
sqlite
::
Connection
*
dbConn
,
int64_t
mediaId
)
{
static
const
std
::
string
req
=
"INSERT OR REPLACE INTO "
+
policy
::
HistoryTable
::
Name
+
"(id_media, insertion_date) VALUES(?, strftime('%s', 'now'))"
;
...
...
src/History.h
View file @
724599b0
...
...
@@ -49,8 +49,8 @@ class History : public IHistoryEntry, public DatabaseHelpers<History, policy::Hi
{
public:
History
(
MediaLibraryPtr
ml
,
sqlite
::
Row
&
row
);
static
bool
createTable
(
DB
Connection
dbConnection
);
static
bool
insert
(
DB
Connection
dbConn
,
int64_t
mediaId
);
static
bool
createTable
(
sqlite
::
Connection
*
dbConnection
);
static
bool
insert
(
sqlite
::
Connection
*
dbConn
,
int64_t
mediaId
);
static
std
::
vector
<
HistoryPtr
>
fetch
(
MediaLibraryPtr
ml
);
static
bool
clearStreams
(
MediaLibraryPtr
ml
);
...
...
src/Label.cpp
View file @
724599b0
...
...
@@ -80,7 +80,7 @@ LabelPtr Label::create( MediaLibraryPtr ml, const std::string& name )
return
self
;
}
bool
Label
::
createTable
(
DB
Connection
dbConnection
)
bool
Label
::
createTable
(
sqlite
::
Connection
*
dbConnection
)
{
const
std
::
string
req
=
"CREATE TABLE IF NOT EXISTS "
+
policy
::
LabelTable
::
Name
+
"("
"id_label INTEGER PRIMARY KEY AUTOINCREMENT, "
...
...
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment