1 /* Connector.h */
2 
3 /* Copyright (C) 2011-2020 Michael Lugmair (Lucio Carreras)
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef DatabaseConnector_H
22 #define DatabaseConnector_H
23 
24 #include "Database/Base.h"
25 
26 #include "Utils/Singleton.h"
27 #include "Utils/Pimpl.h"
28 
29 #define INDEX_SIZE 3
30 
31 namespace DB
32 {
33 	class LibraryDatabase;
34 	class Bookmarks;
35 	class Equalizer;
36 	class Playlist;
37 	class LibraryDatabase;
38 	class Podcasts;
39 	class Streams;
40 	class VisualStyles;
41 	class Settings;
42 	class Library;
43 	class Shortcuts;
44 	class Covers;
45 	class Session;
46 
47 	using LibraryDatabases=QList<LibraryDatabase*>;
48 
49 	class Connector :
50 			public Base
51 	{
52 		PIMPL(Connector)
53 
54 		protected:
55 			bool updateAlbumCissearchFix();
56 			bool updateArtistCissearchFix();
57 			bool updateTrackCissearchFix();
58 			bool updateLostArtists();
59 			bool updateLostAlbums();
60 
61 			virtual bool applyFixes() override;
62 
63 		public:
64 			Connector(const QString& sourceDirectory, const QString& targetDirectory, const QString& databseFilename);
65 			~Connector() override;
66 
67 			static Connector*		instance();
68 			static Connector*		instance_custom(QString sourceDirectory, QString targetDirectory, QString databseFilename);
69 
70 			LibraryDatabases		libraryDatabases() const;
71 			DB::LibraryDatabase*	libraryDatabase(LibraryId libraryId, DbId databaseId);
72 			DB::LibraryDatabase*	registerLibraryDatabase(LibraryId libraryId);
73 			void					deleteLibraryDatabase(LibraryId libraryId);
74 
75 			DB::Bookmarks*			bookmarkConnector();
76 			DB::Equalizer*          equalizerConnector();
77 			DB::Playlist*			playlistConnector();
78 			DB::Podcasts*			podcastConnector();
79 			DB::Streams*			streamConnector();
80 			DB::VisualStyles*		visualStyleConnector();
81 			DB::Settings*			settingsConnector();
82 			DB::Shortcuts*			shortcutConnector();
83 			DB::Covers*				coverConnector();
84 			DB::Library*			libraryConnector();
85 			DB::Session*			sessionConnector();
86 
87 			static int				highestDatabaseVersion();
88 			int						oldDatabaseVersion() const;
89 	};
90 }
91 #endif // DatabaseConnector_H
92