Skip to content

Commit

Permalink
WindowsStore/WindowsPhone: MPfm.Library is partially working; SQLite …
Browse files Browse the repository at this point in the history
…references have been added in both cases (requires the use of a NuGet package + C++ wrapper in case of WP8). SQLiteGateway will need to be reimplemented for WindowsStore/WindowsPhone because DbConnection isn't available.

Related to issue #423 and issue #424.
  • Loading branch information
ycastonguay committed Sep 2, 2013
1 parent 6496173 commit 4532ad8
Show file tree
Hide file tree
Showing 19 changed files with 2,855 additions and 2,286 deletions.
94 changes: 46 additions & 48 deletions MPfm/MPfm.Library/Database/Interfaces/ISQLiteGateway.cs
@@ -1,48 +1,46 @@
// Copyright © 2011-2013 Yanick Castonguay
//
// This file is part of MPfm.
//
// MPfm is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// MPfm is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with MPfm. If not, see <http://www.gnu.org/licenses/>.

using System;
using System.Collections.Generic;
using System.Data.Common;

//using System.Data.Linq;

namespace MPfm.Library.Database.Interfaces
{
/// <summary>
/// Interface for the SQLiteGateway class.
/// </summary>
public interface ISQLiteGateway
{
DbConnection GenerateConnection();
Dictionary<string, string> GetMap<T>();
string FormatSQLValue(object value);
int Execute(string sql);
object ExecuteScalar(string sql);
void CompactDatabase();
IEnumerable<object> SelectList(string sql);
List<Tuple<object, object>> SelectTuple(string sql);
T SelectOne<T>(string sql) where T : new();
List<T> Select<T>(string sql) where T : new();
int Update<T>(T obj, string tableName, string whereFieldName, object whereValue);
int Update<T>(T obj, string tableName, Dictionary<string, object> where);
int Insert<T>(T obj, string tableName);
void Delete(string tableName, string idFieldName, Guid id);
void Delete(string tableName);
void Delete(string tableName, string where);
}
}
// Copyright © 2011-2013 Yanick Castonguay
//
// This file is part of MPfm.
//
// MPfm is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// MPfm is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with MPfm. If not, see <http://www.gnu.org/licenses/>.

using System;
using System.Collections.Generic;
using System.Data.Common;

namespace MPfm.Library.Database.Interfaces
{
/// <summary>
/// Interface for the SQLiteGateway class.
/// </summary>
public interface ISQLiteGateway
{
DbConnection GenerateConnection();
Dictionary<string, string> GetMap<T>();
string FormatSQLValue(object value);
int Execute(string sql);
object ExecuteScalar(string sql);
void CompactDatabase();
IEnumerable<object> SelectList(string sql);
List<Tuple<object, object>> SelectTuple(string sql);
T SelectOne<T>(string sql) where T : new();
List<T> Select<T>(string sql) where T : new();
int Update<T>(T obj, string tableName, string whereFieldName, object whereValue);
int Update<T>(T obj, string tableName, Dictionary<string, object> where);
int Insert<T>(T obj, string tableName);
void Delete(string tableName, string idFieldName, Guid id);
void Delete(string tableName);
void Delete(string tableName, string where);
}
}
13 changes: 9 additions & 4 deletions MPfm/MPfm.Library/Database/SQLiteGateway.cs
Expand Up @@ -18,9 +18,6 @@
#if !IOS && !ANDROID && !MACOSX && !LINUX
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Data.SQLite;
using System.Linq;
using System.Reflection;
using System.Text;
Expand All @@ -29,6 +26,14 @@
using MPfm.Core.Extensions;
using MPfm.Library.Database.Interfaces;

#if !PCL && !WINDOWSSTORE && !WINDOWS_PHONE
using System.Data;
using System.Data.Common;
using System.Data.SQLite;
#else
using SQLite;
#endif

namespace MPfm.Library.Database
{
/// <summary>
Expand All @@ -43,7 +48,7 @@ public class SQLiteGateway : ISQLiteGateway
{
// Private variables
private DbProviderFactory factory = null;
private SQLiteConnection connection = null;
private SQLiteConnection connection = null;

/// <summary>
/// Private value for the DatabaseFilePath property.
Expand Down
149 changes: 76 additions & 73 deletions MPfm/MPfm.Library/ILibrary.cs
@@ -1,73 +1,76 @@
// Copyright © 2011-2013 Yanick Castonguay
//
// This file is part of MPfm.
//
// MPfm is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// MPfm is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with MPfm. If not, see <http://www.gnu.org/licenses/>.

using System;
using System.Collections.Generic;
using MPfm.Library.Database;
using MPfm.Library.UpdateLibrary;
using MPfm.Sound.AudioFiles;

namespace MPfm.Library
{
/// <summary>
/// Interface for the Library class.
/// </summary>
interface ILibrary
{
event Library.UpdateLibraryFinished OnUpdateLibraryFinished;
event Library.UpdateLibraryProgress OnUpdateLibraryProgress;

void AddAudioFilesToLibrary(List<string> filePaths);
void RefreshCache();
void RemoveAudioFilesWithBrokenFilePaths();
void RemoveSongsFromLibrary(string folderPath);

List<string> SearchMediaFilesInFolders();
List<string> SearchMediaFilesInFolders(string folderPath, bool recursive);

Dictionary<string, List<string>> SelectAlbumTitles();
Dictionary<string, List<string>> SelectAlbumTitles(AudioFileFormat audioFileFormat);

List<string> SelectArtistAlbumTitles(string artistName);
List<string> SelectArtistAlbumTitles(string artistName, AudioFileFormat audioFileFormat);

List<string> SelectArtistNames();
List<string> SelectArtistNames(AudioFileFormat audioFileFormat);

AudioFile SelectAudioFile(Guid audioFileId);
List<AudioFile> SelectAudioFiles();
List<AudioFile> SelectAudioFiles(AudioFileFormat audioFileFormat);
List<AudioFile> SelectAudioFiles(AudioFileFormat audioFileFormat, string orderBy, bool orderByAscending);
List<AudioFile> SelectAudioFiles(AudioFileFormat audioFileFormat, string orderBy, bool orderByAscending, string artistName);
List<AudioFile> SelectAudioFiles(AudioFileFormat audioFileFormat, string orderBy, bool orderByAscending, string artistName, string albumTitle);
List<AudioFile> SelectAudioFiles(AudioFileFormat audioFileFormat, string orderBy, bool orderByAscending, string artistName, string albumTitle, string searchTerms);

void UpdateAudioFilePlayCount(Guid audioFileId);

void ResetLibrary();
void UpdateLibrary();
void UpdateLibrary(UpdateLibraryMode mode, List<string> filePaths, string folderPath);
void UpdateLibraryReportProgress(string title, string message);
void UpdateLibraryReportProgress(string title, string message, double percentage);
void UpdateLibraryReportProgress(string title, string message, double percentage, int totalNumberOfFiles, int currentFilePosition);
void UpdateLibraryReportProgress(string title, string message, double percentage, int totalNumberOfFiles, int currentFilePosition, string logEntry);
void UpdateLibraryReportProgress(string title, string message, double percentage, int totalNumberOfFiles, int currentFilePosition, string logEntry, string filePath);
void UpdateLibraryReportProgress(string title, string message, double percentage, int totalNumberOfFiles, int currentFilePosition, string logEntry, string filePath, UpdateLibraryProgressDataSong song);
void UpdateLibraryReportProgress(string title, string message, double percentage, int totalNumberOfFiles, int currentFilePosition, string logEntry, string filePath, UpdateLibraryProgressDataSong song, Exception ex);
void UpdateLibraryReportProgress(string title, string message, double percentage, string logEntry);
}
}
// Copyright © 2011-2013 Yanick Castonguay
//
// This file is part of MPfm.
//
// MPfm is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// MPfm is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with MPfm. If not, see <http://www.gnu.org/licenses/>.

#if !PCL && !WINDOWSSTORE && !WINDOWS_PHONE

using System;
using System.Collections.Generic;
using MPfm.Library.Database;
using MPfm.Library.UpdateLibrary;
using MPfm.Sound.AudioFiles;

namespace MPfm.Library
{
/// <summary>
/// Interface for the Library class.
/// </summary>
interface ILibrary
{
event Library.UpdateLibraryFinished OnUpdateLibraryFinished;
event Library.UpdateLibraryProgress OnUpdateLibraryProgress;

void AddAudioFilesToLibrary(List<string> filePaths);
void RefreshCache();
void RemoveAudioFilesWithBrokenFilePaths();
void RemoveSongsFromLibrary(string folderPath);

List<string> SearchMediaFilesInFolders();
List<string> SearchMediaFilesInFolders(string folderPath, bool recursive);

Dictionary<string, List<string>> SelectAlbumTitles();
Dictionary<string, List<string>> SelectAlbumTitles(AudioFileFormat audioFileFormat);

List<string> SelectArtistAlbumTitles(string artistName);
List<string> SelectArtistAlbumTitles(string artistName, AudioFileFormat audioFileFormat);

List<string> SelectArtistNames();
List<string> SelectArtistNames(AudioFileFormat audioFileFormat);

AudioFile SelectAudioFile(Guid audioFileId);
List<AudioFile> SelectAudioFiles();
List<AudioFile> SelectAudioFiles(AudioFileFormat audioFileFormat);
List<AudioFile> SelectAudioFiles(AudioFileFormat audioFileFormat, string orderBy, bool orderByAscending);
List<AudioFile> SelectAudioFiles(AudioFileFormat audioFileFormat, string orderBy, bool orderByAscending, string artistName);
List<AudioFile> SelectAudioFiles(AudioFileFormat audioFileFormat, string orderBy, bool orderByAscending, string artistName, string albumTitle);
List<AudioFile> SelectAudioFiles(AudioFileFormat audioFileFormat, string orderBy, bool orderByAscending, string artistName, string albumTitle, string searchTerms);

void UpdateAudioFilePlayCount(Guid audioFileId);

void ResetLibrary();
void UpdateLibrary();
void UpdateLibrary(UpdateLibraryMode mode, List<string> filePaths, string folderPath);
void UpdateLibraryReportProgress(string title, string message);
void UpdateLibraryReportProgress(string title, string message, double percentage);
void UpdateLibraryReportProgress(string title, string message, double percentage, int totalNumberOfFiles, int currentFilePosition);
void UpdateLibraryReportProgress(string title, string message, double percentage, int totalNumberOfFiles, int currentFilePosition, string logEntry);
void UpdateLibraryReportProgress(string title, string message, double percentage, int totalNumberOfFiles, int currentFilePosition, string logEntry, string filePath);
void UpdateLibraryReportProgress(string title, string message, double percentage, int totalNumberOfFiles, int currentFilePosition, string logEntry, string filePath, UpdateLibraryProgressDataSong song);
void UpdateLibraryReportProgress(string title, string message, double percentage, int totalNumberOfFiles, int currentFilePosition, string logEntry, string filePath, UpdateLibraryProgressDataSong song, Exception ex);
void UpdateLibraryReportProgress(string title, string message, double percentage, string logEntry);
}
}
#endif
Binary file added MPfm/MPfm.Library/Lib/taglib-sharp.dll
Binary file not shown.

0 comments on commit 4532ad8

Please sign in to comment.