diff --git a/mythtv/libs/libmythservicecontracts/datacontracts/titleInfo.h b/mythtv/libs/libmythservicecontracts/datacontracts/titleInfo.h new file mode 100644 index 00000000000..eabf31de838 --- /dev/null +++ b/mythtv/libs/libmythservicecontracts/datacontracts/titleInfo.h @@ -0,0 +1,67 @@ +//////////////////////////////////////////////////////////////////////////// +// Program Name: titleInfo.h +// Created : June 14, 2013 +// +// Copyright (c) 2013 Chris Pinkham +// +// Licensed under the GPL v2 or later, see COPYING for details +// +//////////////////////////////////////////////////////////////////////////// + +#ifndef TITLEINFO_H_ +#define TITLEINFO_H_ + +#include + +#include "serviceexp.h" +#include "datacontracthelper.h" + +namespace DTC +{ + +///////////////////////////////////////////////////////////////////////////// + +class SERVICE_PUBLIC TitleInfo : public QObject +{ + Q_OBJECT + Q_CLASSINFO( "version" , "1.0" ); + + Q_PROPERTY( QString Title READ Title WRITE setTitle ) + Q_PROPERTY( QString Inetref READ Inetref WRITE setInetref ) + + PROPERTYIMP ( QString , Title ) + PROPERTYIMP ( QString , Inetref ) + + public: + + static void InitializeCustomTypes() + { + qRegisterMetaType< TitleInfo >(); + qRegisterMetaType< TitleInfo* >(); + } + + public: + + TitleInfo(QObject *parent = 0) + : QObject ( parent ) + { + } + + TitleInfo( const TitleInfo &src ) + { + Copy( src ); + } + + void Copy( const TitleInfo &src ) + { + m_Title = src.m_Title ; + m_Inetref = src.m_Inetref ; + } +}; + +} // namespace DTC + +Q_DECLARE_METATYPE( DTC::TitleInfo ) +Q_DECLARE_METATYPE( DTC::TitleInfo* ) + +#endif diff --git a/mythtv/libs/libmythservicecontracts/datacontracts/titleInfoList.h b/mythtv/libs/libmythservicecontracts/datacontracts/titleInfoList.h new file mode 100644 index 00000000000..f27e08c626c --- /dev/null +++ b/mythtv/libs/libmythservicecontracts/datacontracts/titleInfoList.h @@ -0,0 +1,83 @@ +//////////////////////////////////////////////////////////////////////////// +// Program Name: titleInfoList.h +// Created : June 14, 2013 +// +// Copyright (c) 2013 Chris Pinkham +// +// Licensed under the GPL v2 or later, see COPYING for details +// +//////////////////////////////////////////////////////////////////////////// + +#ifndef TITLEINFOLIST_H_ +#define TITLEINFOLIST_H_ + +#include + +#include "serviceexp.h" +#include "datacontracthelper.h" + +#include "titleInfo.h" + +namespace DTC +{ + +class SERVICE_PUBLIC TitleInfoList : public QObject +{ + Q_OBJECT + Q_CLASSINFO( "version", "1.0" ); + + // Q_CLASSINFO Used to augment Metadata for properties. + // See datacontracthelper.h for details + + Q_CLASSINFO( "TitleInfos", "type=DTC::TitleInfo"); + + Q_PROPERTY( QVariantList TitleInfos READ TitleInfos DESIGNABLE true ) + + PROPERTYIMP_RO_REF( QVariantList, TitleInfos ) + + public: + + static void InitializeCustomTypes() + { + qRegisterMetaType< TitleInfoList >(); + qRegisterMetaType< TitleInfoList* >(); + + TitleInfo::InitializeCustomTypes(); + } + + public: + + TitleInfoList(QObject *parent = 0) + : QObject( parent ) + { + } + + TitleInfoList( const TitleInfoList &src ) + { + Copy( src ); + } + + void Copy( const TitleInfoList &src ) + { + CopyListContents< TitleInfo >( this, m_TitleInfos, src.m_TitleInfos ); + } + + TitleInfo *AddNewTitleInfo() + { + // We must make sure the object added to the QVariantList has + // a parent of 'this' + + TitleInfo *pObject = new TitleInfo( this ); + m_TitleInfos.append( QVariant::fromValue( pObject )); + + return pObject; + } + +}; + +} // namespace DTC + +Q_DECLARE_METATYPE( DTC::TitleInfoList ) +Q_DECLARE_METATYPE( DTC::TitleInfoList* ) + +#endif diff --git a/mythtv/libs/libmythservicecontracts/libmythservicecontracts.pro b/mythtv/libs/libmythservicecontracts/libmythservicecontracts.pro index 73730984158..d9725158ef8 100644 --- a/mythtv/libs/libmythservicecontracts/libmythservicecontracts.pro +++ b/mythtv/libs/libmythservicecontracts/libmythservicecontracts.pro @@ -40,6 +40,7 @@ HEADERS += datacontracts/recRuleList.h datacontracts/artworkInfo.h HEADERS += datacontracts/artworkInfoList.h datacontracts/frontendStatus.h HEADERS += datacontracts/frontendActionList.h HEADERS += datacontracts/liveStreamInfo.h datacontracts/liveStreamInfoList.h +HEADERS += datacontracts/titleInfo.h datacontracts/titleInfoList.h HEADERS += datacontracts/labelValue.h HEADERS += datacontracts/logMessage.h datacontracts/logMessageList.h @@ -80,6 +81,7 @@ incDatacontracts.files += datacontracts/recRule.h datacontracts/recR incDatacontracts.files += datacontracts/artworkInfo.h datacontracts/artworkInfoList.h incDatacontracts.files += datacontracts/frontendStatus.h datacontracts/frontendActionList.h incDatacontracts.files += datacontracts/liveStreamInfo.h datacontracts/liveStreamInfoList.h +incDatacontracts.files += datacontracts/titleInfo.h datacontracts/titleInfoList.h incDatacontracts.files += datacontracts/labelValue.h incDatacontracts.files += datacontracts/logMessage.h datacontracts/logMessageList.h diff --git a/mythtv/libs/libmythservicecontracts/services/dvrServices.h b/mythtv/libs/libmythservicecontracts/services/dvrServices.h index e97cb88f0af..514592ce140 100644 --- a/mythtv/libs/libmythservicecontracts/services/dvrServices.h +++ b/mythtv/libs/libmythservicecontracts/services/dvrServices.h @@ -18,6 +18,7 @@ #include "datacontracts/programList.h" #include "datacontracts/encoderList.h" #include "datacontracts/recRuleList.h" +#include "datacontracts/titleInfoList.h" ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// @@ -56,6 +57,7 @@ class SERVICE_PUBLIC DvrServices : public Service //, public QScriptable ??? DTC::ProgramList::InitializeCustomTypes(); DTC::EncoderList::InitializeCustomTypes(); DTC::RecRuleList::InitializeCustomTypes(); + DTC::TitleInfoList::InitializeCustomTypes(); } public slots: @@ -93,6 +95,8 @@ class SERVICE_PUBLIC DvrServices : public Service //, public QScriptable ??? virtual QStringList GetTitleList ( ) = 0; + virtual DTC::TitleInfoList* GetTitleInfoList ( ) = 0; + // Recording Rules virtual int AddRecordSchedule ( QString Title, diff --git a/mythtv/programs/mythbackend/services/dvr.cpp b/mythtv/programs/mythbackend/services/dvr.cpp index 8d0bc5dddd7..920a60762f2 100644 --- a/mythtv/programs/mythbackend/services/dvr.cpp +++ b/mythtv/programs/mythbackend/services/dvr.cpp @@ -382,6 +382,40 @@ QStringList Dvr::GetTitleList() // ///////////////////////////////////////////////////////////////////////////// +DTC::TitleInfoList* Dvr::GetTitleInfoList() +{ + MSqlQuery query(MSqlQuery::InitCon()); + + QString querystr = QString( + "SELECT DISTINCT title, inetref " + " FROM recorded " + " WHERE inetref <> '' " + " ORDER BY title"); + + query.prepare(querystr); + + DTC::TitleInfoList *pTitleInfos = new DTC::TitleInfoList(); + if (!query.exec()) + { + MythDB::DBError("GetTitleList recorded", query); + return pTitleInfos; + } + + while (query.next()) + { + DTC::TitleInfo *pTitleInfo = pTitleInfos->AddNewTitleInfo(); + + pTitleInfo->setTitle(query.value(0).toString()); + pTitleInfo->setInetref(query.value(1).toString()); + } + + return pTitleInfos; +} + +///////////////////////////////////////////////////////////////////////////// +// +///////////////////////////////////////////////////////////////////////////// + DTC::ProgramList* Dvr::GetUpcomingList( int nStartIndex, int nCount, bool bShowAll ) diff --git a/mythtv/programs/mythbackend/services/dvr.h b/mythtv/programs/mythbackend/services/dvr.h index 42a172b5575..646669f75e3 100644 --- a/mythtv/programs/mythbackend/services/dvr.h +++ b/mythtv/programs/mythbackend/services/dvr.h @@ -73,6 +73,7 @@ class Dvr : public DvrServices QStringList GetTitleList ( ); + DTC::TitleInfoList* GetTitleInfoList ( ); // Recording Rules @@ -248,6 +249,8 @@ class ScriptableDvr : public QObject QStringList GetTitleList () { return m_obj.GetTitleList(); } + QObject* GetTitleInfoList () { return m_obj.GetTitleInfoList(); } + }; Q_SCRIPT_DECLARE_QMETAOBJECT( ScriptableDvr, QObject*);