diff --git a/XBMC-ATV2.xcodeproj/project.pbxproj b/XBMC-ATV2.xcodeproj/project.pbxproj index c189a56ed5..855b1fe35f 100644 --- a/XBMC-ATV2.xcodeproj/project.pbxproj +++ b/XBMC-ATV2.xcodeproj/project.pbxproj @@ -694,7 +694,6 @@ F56C7AEC131EC155000AD0F6 /* PowerManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56C76B2131EC153000AD0F6 /* PowerManager.cpp */; }; F56C7AED131EC155000AD0F6 /* GUIViewStatePrograms.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56C76B5131EC153000AD0F6 /* GUIViewStatePrograms.cpp */; }; F56C7AEE131EC155000AD0F6 /* GUIWindowPrograms.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56C76B7131EC153000AD0F6 /* GUIWindowPrograms.cpp */; }; - F56C7AEF131EC155000AD0F6 /* ProgramDatabase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56C76B9131EC153000AD0F6 /* ProgramDatabase.cpp */; }; F56C7AF3131EC155000AD0F6 /* RenderSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56C76C3131EC153000AD0F6 /* RenderSystem.cpp */; }; F56C7AF4131EC155000AD0F6 /* GUIDialogContentSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56C76C7131EC153000AD0F6 /* GUIDialogContentSettings.cpp */; }; F56C7AF5131EC155000AD0F6 /* GUIDialogLockSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56C76C9131EC153000AD0F6 /* GUIDialogLockSettings.cpp */; }; @@ -2478,8 +2477,6 @@ F56C76B6131EC153000AD0F6 /* GUIViewStatePrograms.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GUIViewStatePrograms.h; sourceTree = ""; }; F56C76B7131EC153000AD0F6 /* GUIWindowPrograms.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GUIWindowPrograms.cpp; sourceTree = ""; }; F56C76B8131EC153000AD0F6 /* GUIWindowPrograms.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GUIWindowPrograms.h; sourceTree = ""; }; - F56C76B9131EC153000AD0F6 /* ProgramDatabase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProgramDatabase.cpp; sourceTree = ""; }; - F56C76BA131EC153000AD0F6 /* ProgramDatabase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProgramDatabase.h; sourceTree = ""; }; F56C76C3131EC153000AD0F6 /* RenderSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSystem.cpp; sourceTree = ""; }; F56C76C4131EC153000AD0F6 /* RenderSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSystem.h; sourceTree = ""; }; F56C76C7131EC153000AD0F6 /* GUIDialogContentSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GUIDialogContentSettings.cpp; sourceTree = ""; }; @@ -5240,8 +5237,6 @@ F56C76B6131EC153000AD0F6 /* GUIViewStatePrograms.h */, F56C76B7131EC153000AD0F6 /* GUIWindowPrograms.cpp */, F56C76B8131EC153000AD0F6 /* GUIWindowPrograms.h */, - F56C76B9131EC153000AD0F6 /* ProgramDatabase.cpp */, - F56C76BA131EC153000AD0F6 /* ProgramDatabase.h */, ); path = programs; sourceTree = ""; @@ -6851,7 +6846,6 @@ F56C7AEC131EC155000AD0F6 /* PowerManager.cpp in Sources */, F56C7AED131EC155000AD0F6 /* GUIViewStatePrograms.cpp in Sources */, F56C7AEE131EC155000AD0F6 /* GUIWindowPrograms.cpp in Sources */, - F56C7AEF131EC155000AD0F6 /* ProgramDatabase.cpp in Sources */, F56C7AF3131EC155000AD0F6 /* RenderSystem.cpp in Sources */, F56C7AF4131EC155000AD0F6 /* GUIDialogContentSettings.cpp in Sources */, F56C7AF5131EC155000AD0F6 /* GUIDialogLockSettings.cpp in Sources */, diff --git a/XBMC-IOS.xcodeproj/project.pbxproj b/XBMC-IOS.xcodeproj/project.pbxproj index 98512460ae..e3fccaa3ac 100644 --- a/XBMC-IOS.xcodeproj/project.pbxproj +++ b/XBMC-IOS.xcodeproj/project.pbxproj @@ -785,7 +785,6 @@ F56C8ADA131F42ED000AD0F6 /* PowerManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56C869F131F42EB000AD0F6 /* PowerManager.cpp */; }; F56C8ADB131F42ED000AD0F6 /* GUIViewStatePrograms.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56C86A2131F42EB000AD0F6 /* GUIViewStatePrograms.cpp */; }; F56C8ADC131F42ED000AD0F6 /* GUIWindowPrograms.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56C86A4131F42EB000AD0F6 /* GUIWindowPrograms.cpp */; }; - F56C8ADD131F42ED000AD0F6 /* ProgramDatabase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56C86A6131F42EB000AD0F6 /* ProgramDatabase.cpp */; }; F56C8ADE131F42ED000AD0F6 /* Shortcut.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56C86A8131F42EB000AD0F6 /* Shortcut.cpp */; }; F56C8ADF131F42ED000AD0F6 /* RenderSystemGLES.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56C86AC131F42EB000AD0F6 /* RenderSystemGLES.cpp */; }; F56C8AE0131F42ED000AD0F6 /* RenderSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56C86AE131F42EB000AD0F6 /* RenderSystem.cpp */; }; @@ -2677,8 +2676,6 @@ F56C86A3131F42EB000AD0F6 /* GUIViewStatePrograms.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GUIViewStatePrograms.h; sourceTree = ""; }; F56C86A4131F42EB000AD0F6 /* GUIWindowPrograms.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GUIWindowPrograms.cpp; sourceTree = ""; }; F56C86A5131F42EB000AD0F6 /* GUIWindowPrograms.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GUIWindowPrograms.h; sourceTree = ""; }; - F56C86A6131F42EB000AD0F6 /* ProgramDatabase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProgramDatabase.cpp; sourceTree = ""; }; - F56C86A7131F42EB000AD0F6 /* ProgramDatabase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProgramDatabase.h; sourceTree = ""; }; F56C86AC131F42EB000AD0F6 /* RenderSystemGLES.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSystemGLES.cpp; sourceTree = ""; }; F56C86AD131F42EB000AD0F6 /* RenderSystemGLES.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSystemGLES.h; sourceTree = ""; }; F56C86AE131F42EB000AD0F6 /* RenderSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSystem.cpp; sourceTree = ""; }; @@ -5597,8 +5594,6 @@ F56C86A3131F42EB000AD0F6 /* GUIViewStatePrograms.h */, F56C86A4131F42EB000AD0F6 /* GUIWindowPrograms.cpp */, F56C86A5131F42EB000AD0F6 /* GUIWindowPrograms.h */, - F56C86A6131F42EB000AD0F6 /* ProgramDatabase.cpp */, - F56C86A7131F42EB000AD0F6 /* ProgramDatabase.h */, ); path = programs; sourceTree = ""; @@ -6955,7 +6950,6 @@ F56C8ADA131F42ED000AD0F6 /* PowerManager.cpp in Sources */, F56C8ADB131F42ED000AD0F6 /* GUIViewStatePrograms.cpp in Sources */, F56C8ADC131F42ED000AD0F6 /* GUIWindowPrograms.cpp in Sources */, - F56C8ADD131F42ED000AD0F6 /* ProgramDatabase.cpp in Sources */, F56C8ADE131F42ED000AD0F6 /* Shortcut.cpp in Sources */, F56C8ADF131F42ED000AD0F6 /* RenderSystemGLES.cpp in Sources */, F56C8AE0131F42ED000AD0F6 /* RenderSystem.cpp in Sources */, diff --git a/XBMC.xcodeproj/project.pbxproj b/XBMC.xcodeproj/project.pbxproj index 7e07ec38e2..8583997311 100644 --- a/XBMC.xcodeproj/project.pbxproj +++ b/XBMC.xcodeproj/project.pbxproj @@ -752,7 +752,6 @@ E38E22A40D25F9FE00618676 /* PictureThumbLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1DDD0D25F9FD00618676 /* PictureThumbLoader.cpp */; }; E38E22AA0D25F9FE00618676 /* PlayListPlayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1DE90D25F9FD00618676 /* PlayListPlayer.cpp */; }; E38E22AE0D25F9FE00618676 /* Profile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1DF10D25F9FD00618676 /* Profile.cpp */; }; - E38E22AF0D25F9FE00618676 /* ProgramDatabase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1DF30D25F9FD00618676 /* ProgramDatabase.cpp */; }; E38E22B30D25F9FE00618676 /* SectionLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1DFE0D25F9FD00618676 /* SectionLoader.cpp */; }; E38E22B40D25F9FE00618676 /* VideoSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E010D25F9FD00618676 /* VideoSettings.cpp */; }; E38E22B70D25F9FE00618676 /* Shortcut.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E070D25F9FD00618676 /* Shortcut.cpp */; }; @@ -2666,8 +2665,6 @@ E38E1DEA0D25F9FD00618676 /* PlayListPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlayListPlayer.h; sourceTree = ""; }; E38E1DF10D25F9FD00618676 /* Profile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Profile.cpp; sourceTree = ""; }; E38E1DF20D25F9FD00618676 /* Profile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Profile.h; sourceTree = ""; }; - E38E1DF30D25F9FD00618676 /* ProgramDatabase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProgramDatabase.cpp; sourceTree = ""; }; - E38E1DF40D25F9FD00618676 /* ProgramDatabase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProgramDatabase.h; sourceTree = ""; }; E38E1DFE0D25F9FD00618676 /* SectionLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SectionLoader.cpp; sourceTree = ""; }; E38E1DFF0D25F9FD00618676 /* SectionLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SectionLoader.h; sourceTree = ""; }; E38E1E010D25F9FD00618676 /* VideoSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VideoSettings.cpp; sourceTree = ""; }; @@ -3667,8 +3664,6 @@ 8863281A0E07B37200BB3DAB /* GUIViewStatePrograms.h */, E38E18230D25F9FA00618676 /* GUIWindowPrograms.cpp */, E38E18240D25F9FA00618676 /* GUIWindowPrograms.h */, - E38E1DF30D25F9FD00618676 /* ProgramDatabase.cpp */, - E38E1DF40D25F9FD00618676 /* ProgramDatabase.h */, ); path = programs; sourceTree = ""; @@ -6711,7 +6706,6 @@ E38E22A40D25F9FE00618676 /* PictureThumbLoader.cpp in Sources */, E38E22AA0D25F9FE00618676 /* PlayListPlayer.cpp in Sources */, E38E22AE0D25F9FE00618676 /* Profile.cpp in Sources */, - E38E22AF0D25F9FE00618676 /* ProgramDatabase.cpp in Sources */, E38E22B30D25F9FE00618676 /* SectionLoader.cpp in Sources */, E38E22B40D25F9FE00618676 /* VideoSettings.cpp in Sources */, E38E22B70D25F9FE00618676 /* Shortcut.cpp in Sources */, diff --git a/project/VS2010Express/XBMC.vcxproj b/project/VS2010Express/XBMC.vcxproj index f07e528e11..0fa3608dc2 100644 --- a/project/VS2010Express/XBMC.vcxproj +++ b/project/VS2010Express/XBMC.vcxproj @@ -853,7 +853,6 @@ - @@ -1806,7 +1805,6 @@ - @@ -2286,4 +2284,4 @@ - \ No newline at end of file + diff --git a/project/VS2010Express/XBMC.vcxproj.filters b/project/VS2010Express/XBMC.vcxproj.filters index e40ca7ed7e..23f18eba2d 100644 --- a/project/VS2010Express/XBMC.vcxproj.filters +++ b/project/VS2010Express/XBMC.vcxproj.filters @@ -2505,9 +2505,6 @@ music - - programs - video @@ -5130,9 +5127,6 @@ music - - programs - video diff --git a/xbmc/DatabaseManager.cpp b/xbmc/DatabaseManager.cpp index 9c5bd12860..a23ce08bd3 100644 --- a/xbmc/DatabaseManager.cpp +++ b/xbmc/DatabaseManager.cpp @@ -24,7 +24,6 @@ #include "addons/AddonDatabase.h" #include "ViewDatabase.h" #include "TextureDatabase.h" -#include "programs/ProgramDatabase.h" #include "music/MusicDatabase.h" #include "video/VideoDatabase.h" #include "settings/AdvancedSettings.h" @@ -54,7 +53,6 @@ void CDatabaseManager::Initialize(bool addonsOnly) CLog::Log(LOGDEBUG, "%s, updating databases...", __FUNCTION__); { CViewDatabase db; UpdateDatabase(db); } { CTextureDatabase db; UpdateDatabase(db); } - { CProgramDatabase db; UpdateDatabase(db); } { CMusicDatabase db; UpdateDatabase(db, &g_advancedSettings.m_databaseMusic); } { CVideoDatabase db; UpdateDatabase(db, &g_advancedSettings.m_databaseVideo); } CLog::Log(LOGDEBUG, "%s, updating databases... DONE", __FUNCTION__); diff --git a/xbmc/programs/GUIWindowPrograms.cpp b/xbmc/programs/GUIWindowPrograms.cpp index 91418d37a4..f2ffdeae18 100644 --- a/xbmc/programs/GUIWindowPrograms.cpp +++ b/xbmc/programs/GUIWindowPrograms.cpp @@ -67,7 +67,6 @@ bool CGUIWindowPrograms::OnMessage(CGUIMessage& message) { if (m_thumbLoader.IsLoading()) m_thumbLoader.StopThread(); - m_database.Close(); } break; @@ -80,8 +79,6 @@ bool CGUIWindowPrograms::OnMessage(CGUIMessage& message) if (m_vecItems->GetPath() == "?" && message.GetStringParam().IsEmpty()) message.SetStringParam(g_settings.m_defaultProgramSource); - m_database.Open(); - return CGUIMediaWindow::OnMessage(message); } break; diff --git a/xbmc/programs/GUIWindowPrograms.h b/xbmc/programs/GUIWindowPrograms.h index 177d358407..a1bbd87b73 100644 --- a/xbmc/programs/GUIWindowPrograms.h +++ b/xbmc/programs/GUIWindowPrograms.h @@ -22,7 +22,6 @@ */ #include "windows/GUIMediaWindow.h" -#include "ProgramDatabase.h" #include "dialogs/GUIDialogProgress.h" #include "ThumbLoader.h" @@ -47,8 +46,6 @@ class CGUIWindowPrograms : CGUIDialogProgress* m_dlgProgress; - CProgramDatabase m_database; - int m_iRegionSet; // for cd stuff CProgramThumbLoader m_thumbLoader; diff --git a/xbmc/programs/Makefile b/xbmc/programs/Makefile index f9f7dfa030..5ad35a346c 100644 --- a/xbmc/programs/Makefile +++ b/xbmc/programs/Makefile @@ -1,6 +1,5 @@ SRCS=GUIViewStatePrograms.cpp \ GUIWindowPrograms.cpp \ - ProgramDatabase.cpp \ LIB=programs.a diff --git a/xbmc/programs/ProgramDatabase.cpp b/xbmc/programs/ProgramDatabase.cpp deleted file mode 100644 index 99efdbd25b..0000000000 --- a/xbmc/programs/ProgramDatabase.cpp +++ /dev/null @@ -1,327 +0,0 @@ -/* - * Copyright (C) 2005-2008 Team XBMC - * http://www.xbmc.org - * - * This Program 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 2, or (at your option) - * any later version. - * - * This Program 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 XBMC; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * http://www.gnu.org/copyleft/gpl.html - * - */ - -#include "ProgramDatabase.h" -#include "Util.h" -#include "windows/GUIWindowFileManager.h" -#include "FileItem.h" -#include "settings/GUISettings.h" -#include "settings/Settings.h" -#include "utils/log.h" -#include "utils/URIUtils.h" -#include "dbwrappers/dataset.h" - -using namespace XFILE; - -//******************************************************************************************************************************** -CProgramDatabase::CProgramDatabase(void) -{ -} - -//******************************************************************************************************************************** -CProgramDatabase::~CProgramDatabase(void) -{ - -} - -//******************************************************************************************************************************** -bool CProgramDatabase::Open() -{ - return CDatabase::Open(); -} - -bool CProgramDatabase::CreateTables() -{ - - try - { - CDatabase::CreateTables(); - - CLog::Log(LOGINFO, "create files table"); - m_pDS->exec("CREATE TABLE files ( idFile integer primary key, strFilename text, titleId integer, xbedescription text, iTimesPlayed integer, lastAccessed integer, iRegion integer, iSize integer)\n"); - CLog::Log(LOGINFO, "create files index"); - m_pDS->exec("CREATE INDEX idxFiles ON files(strFilename)"); - CLog::Log(LOGINFO, "create files - titleid index"); - m_pDS->exec("CREATE INDEX idxTitleIdFiles ON files(titleId)"); - } - catch (...) - { - CLog::Log(LOGERROR, "programdatabase::unable to create tables:%u", - GetLastError()); - return false; - } - - return true; -} - -bool CProgramDatabase::UpdateOldVersion(int version) -{ - return true; -} - -uint32_t CProgramDatabase::GetTitleId(const CStdString& strFilenameAndPath) -{ - if (NULL == m_pDB.get()) return 0; - if (NULL == m_pDS.get()) return 0; - - try - { - CStdString strSQL = PrepareSQL("select * from files where files.strFileName like '%s'", strFilenameAndPath.c_str()); - if (!m_pDS->query(strSQL.c_str())) - return 0; - - int iRowsFound = m_pDS->num_rows(); - if (iRowsFound == 0) - { - m_pDS->close(); - return 0; - } - uint32_t dwTitleId = m_pDS->fv("files.TitleId").get_asInt(); - m_pDS->close(); - return dwTitleId; - } - catch (...) - { - CLog::Log(LOGERROR, "CProgramDatabase:GetTitleId(%s) failed", strFilenameAndPath.c_str()); - } - return 0; -} - -bool CProgramDatabase::SetTitleId(const CStdString& strFileName, uint32_t dwTitleId) -{ - try - { - if (NULL == m_pDB.get()) return false; - if (NULL == m_pDS.get()) return false; - - CStdString strSQL = PrepareSQL("select * from files where files.strFileName like '%s'", strFileName.c_str()); - if (!m_pDS->query(strSQL.c_str())) return false; - int iRowsFound = m_pDS->num_rows(); - if (iRowsFound == 0) - { - m_pDS->close(); - return false; - } - int idFile = m_pDS->fv("files.idFile").get_asInt(); - m_pDS->close(); - - CLog::Log(LOGDEBUG, "CProgramDatabase::SetTitle(%s), idFile=%i, region=%u", - strFileName.c_str(), idFile,dwTitleId); - - strSQL=PrepareSQL("update files set titleId=%u where idFile=%i", - dwTitleId, idFile); - m_pDS->exec(strSQL.c_str()); - return true; - } - catch (...) - { - CLog::Log(LOGERROR, "CProgramDatabase:SetDescription(%s) failed", strFileName.c_str()); - } - - return false; -} - -bool CProgramDatabase::GetXBEPathByTitleId(const uint32_t titleId, CStdString& strPathAndFilename) -{ - try - { - if (NULL == m_pDB.get()) return false; - if (NULL == m_pDS.get()) return false; - - CStdString strSQL=PrepareSQL("select files.strFilename from files where files.titleId=%u", titleId); - m_pDS->query(strSQL.c_str()); - if (m_pDS->num_rows() > 0) - { - strPathAndFilename = m_pDS->fv("files.strFilename").get_asString(); - strPathAndFilename.Replace('/', '\\'); - m_pDS->close(); - return true; - } - m_pDS->close(); - return false; - } - catch (...) - { - CLog::Log(LOGERROR, "CProgramDatabase::GetXBEPathByTitleId(%u) failed", - titleId); - } - return false; -} - -uint32_t CProgramDatabase::GetProgramInfo(CFileItem *item) -{ - uint32_t titleID = 0; - try - { - if (NULL == m_pDB.get()) return false; - if (NULL == m_pDS.get()) return false; - - CStdString strSQL = PrepareSQL("select xbedescription,iTimesPlayed,lastAccessed,titleId,iSize from files where strFileName like '%s'", item->GetPath().c_str()); - m_pDS->query(strSQL.c_str()); - if (!m_pDS->eof()) - { // get info - only set the label if not preformatted - if (!item->IsLabelPreformated()) - item->SetLabel(m_pDS->fv("xbedescription").get_asString()); - item->m_iprogramCount = m_pDS->fv("iTimesPlayed").get_asInt(); - item->m_strTitle = item->GetLabel(); // is this needed? - item->m_dateTime = TimeStampToLocalTime(_atoi64(m_pDS->fv("lastAccessed").get_asString().c_str())); - item->m_dwSize = _atoi64(m_pDS->fv("iSize").get_asString().c_str()); - titleID = m_pDS->fv("titleId").get_asInt(); - if (item->m_dwSize == -1) - { - CStdString strPath; - URIUtils::GetDirectory(item->GetPath(),strPath); - int64_t iSize = CGUIWindowFileManager::CalculateFolderSize(strPath); - CStdString strSQL=PrepareSQL("update files set iSize=%I64u where strFileName like '%s'",iSize,item->GetPath().c_str()); - m_pDS->exec(strSQL.c_str()); - } - } - m_pDS->close(); - } - catch (...) - { - CLog::Log(LOGERROR, "CProgramDatabase::GetProgramInfo(%s) failed", item->GetPath().c_str()); - } - return titleID; -} - -bool CProgramDatabase::AddProgramInfo(CFileItem *item, unsigned int titleID) -{ - try - { - if (NULL == m_pDB.get()) return false; - if (NULL == m_pDS.get()) return false; - - int iRegion = -1; - if (g_guiSettings.GetBool("myprograms.gameautoregion")) - { - iRegion = 0; - } - FILETIME time; - item->m_dateTime=CDateTime::GetCurrentDateTime(); - item->m_dateTime.GetAsTimeStamp(time); - - ULARGE_INTEGER lastAccessed; - lastAccessed.u.LowPart = time.dwLowDateTime; - lastAccessed.u.HighPart = time.dwHighDateTime; - - CStdString strPath; - URIUtils::GetDirectory(item->GetPath(),strPath); - // special case - programs in root of sources - bool bIsShare=false; - CUtil::GetMatchingSource(strPath,g_settings.m_programSources,bIsShare); - int64_t iSize=0; - if (bIsShare) - { - struct __stat64 stat; - if (CFile::Stat(item->GetPath(),&stat) == 0) - iSize = stat.st_size; - } - else - iSize = CGUIWindowFileManager::CalculateFolderSize(strPath); - if (titleID == 0) - titleID = (unsigned int) -1; - CStdString strSQL=PrepareSQL("insert into files (idFile, strFileName, titleId, xbedescription, iTimesPlayed, lastAccessed, iRegion, iSize) values(NULL, '%s', %u, '%s', %i, %I64u, %i, %I64u)", item->GetPath().c_str(), titleID, item->GetLabel().c_str(), 0, lastAccessed.QuadPart, iRegion, iSize); - m_pDS->exec(strSQL.c_str()); - item->m_dwSize = iSize; - } - catch (...) - { - CLog::Log(LOGERROR, "CProgramDatabase::AddProgramInfo(%s) failed", item->GetPath().c_str()); - } - return true; -} - -FILETIME CProgramDatabase::TimeStampToLocalTime(uint64_t timeStamp ) -{ - FILETIME fileTime; - ::FileTimeToLocalFileTime( (const FILETIME *)&timeStamp, &fileTime); - return fileTime; -} - -bool CProgramDatabase::IncTimesPlayed(const CStdString& strFileName) -{ - try - { - if (NULL == m_pDB.get()) return false; - if (NULL == m_pDS.get()) return false; - - CStdString strSQL = PrepareSQL("select * from files where files.strFileName like '%s'", strFileName.c_str()); - if (!m_pDS->query(strSQL.c_str())) return false; - int iRowsFound = m_pDS->num_rows(); - if (iRowsFound == 0) - { - m_pDS->close(); - return false; - } - int idFile = m_pDS->fv("files.idFile").get_asInt(); - int iTimesPlayed = m_pDS->fv("files.iTimesPlayed").get_asInt(); - m_pDS->close(); - - CLog::Log(LOGDEBUG, "CProgramDatabase::IncTimesPlayed(%s), idFile=%i, iTimesPlayed=%i", - strFileName.c_str(), idFile, iTimesPlayed); - - strSQL=PrepareSQL("update files set iTimesPlayed=%i where idFile=%i", - ++iTimesPlayed, idFile); - m_pDS->exec(strSQL.c_str()); - return true; - } - catch (...) - { - CLog::Log(LOGERROR, "CProgramDatabase:IncTimesPlayed(%s) failed", strFileName.c_str()); - } - - return false; -} - -bool CProgramDatabase::SetDescription(const CStdString& strFileName, const CStdString& strDescription) -{ - try - { - if (NULL == m_pDB.get()) return false; - if (NULL == m_pDS.get()) return false; - - CStdString strSQL = PrepareSQL("select * from files where files.strFileName like '%s'", strFileName.c_str()); - if (!m_pDS->query(strSQL.c_str())) return false; - int iRowsFound = m_pDS->num_rows(); - if (iRowsFound == 0) - { - m_pDS->close(); - return false; - } - int idFile = m_pDS->fv("files.idFile").get_asInt(); - m_pDS->close(); - - CLog::Log(LOGDEBUG, "CProgramDatabase::SetDescription(%s), idFile=%i, description=%s", - strFileName.c_str(), idFile,strDescription.c_str()); - - strSQL=PrepareSQL("update files set xbedescription='%s' where idFile=%i", - strDescription.c_str(), idFile); - m_pDS->exec(strSQL.c_str()); - return true; - } - catch (...) - { - CLog::Log(LOGERROR, "CProgramDatabase:SetDescription(%s) failed", strFileName.c_str()); - } - - return false; -} diff --git a/xbmc/programs/ProgramDatabase.h b/xbmc/programs/ProgramDatabase.h deleted file mode 100644 index 4f63216241..0000000000 --- a/xbmc/programs/ProgramDatabase.h +++ /dev/null @@ -1,72 +0,0 @@ -#pragma once -/* - * Copyright (C) 2005-2008 Team XBMC - * http://www.xbmc.org - * - * This Program 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 2, or (at your option) - * any later version. - * - * This Program 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 XBMC; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * http://www.gnu.org/copyleft/gpl.html - * - */ -#include "dbwrappers/Database.h" - -#ifdef _LINUX -#include "PlatformDefs.h" // FILETIME -#endif - -typedef std::vector VECPROGRAMPATHS; - -#define COMPARE_PERCENTAGE 0.90f // 90% -#define COMPARE_PERCENTAGE_MIN 0.50f // 50% - -class CFileItem; - -class CProgramDatabase : public CDatabase -{ -public: - CProgramDatabase(void); - virtual ~CProgramDatabase(void); - virtual bool Open(); - - bool AddTrainer(int iTitleId, const CStdString& strText); - bool RemoveTrainer(const CStdString& strText); - bool GetTrainers(unsigned int iTitleId, std::vector& vecTrainers); - bool GetAllTrainers(std::vector& vecTrainers); - bool SetTrainerOptions(const CStdString& strTrainerPath, unsigned int iTitleId, unsigned char* data, int numOptions); - bool GetTrainerOptions(const CStdString& strTrainerPath, unsigned int iTitleId, unsigned char* data, int numOptions); - void SetTrainerActive(const CStdString& strTrainerPath, unsigned int iTitleId, bool bActive); - CStdString GetActiveTrainer(unsigned int iTitleId); - bool HasTrainer(const CStdString& strTrainerPath); - bool ItemHasTrainer(unsigned int iTitleId); - - int GetRegion(const CStdString& strFilenameAndPath); - bool SetRegion(const CStdString& strFilenameAndPath, int iRegion=-1); - - uint32_t GetTitleId(const CStdString& strFilenameAndPath); - bool SetTitleId(const CStdString& strFilenameAndPath, uint32_t dwTitleId); - bool IncTimesPlayed(const CStdString& strFileName1); - bool SetDescription(const CStdString& strFileName1, const CStdString& strDescription); - bool GetXBEPathByTitleId(const uint32_t titleId, CStdString& strPathAndFilename); - - uint32_t GetProgramInfo(CFileItem *item); - bool AddProgramInfo(CFileItem *item, unsigned int titleID); - -protected: - virtual bool CreateTables(); - virtual bool UpdateOldVersion(int version); - virtual int GetMinVersion() const { return 3; }; - const char *GetBaseDBName() const { return "MyPrograms"; }; - - FILETIME TimeStampToLocalTime( uint64_t timeStamp ); -};