Permalink
Browse files

Add a Dvr GetTitleInfoList Services API endpoint

Currently this returns a list of unique titles/InetRef combinations,
but it could be extended to include other info later.
  • Loading branch information...
cpinkham committed Jun 14, 2013
1 parent aad0c37 commit c8cd017a65c63da4e75005621e32f756dc4a36d2
@@ -0,0 +1,67 @@
+////////////////////////////////////////////////////////////////////////////
+// Program Name: titleInfo.h
+// Created : June 14, 2013
+//
+// Copyright (c) 2013 Chris Pinkham <cpinkham@mythtv.org>
+//
+// Licensed under the GPL v2 or later, see COPYING for details
+//
+////////////////////////////////////////////////////////////////////////////
+
+#ifndef TITLEINFO_H_
+#define TITLEINFO_H_
+
+#include <QString>
+
+#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
@@ -0,0 +1,83 @@
+////////////////////////////////////////////////////////////////////////////
+// Program Name: titleInfoList.h
+// Created : June 14, 2013
+//
+// Copyright (c) 2013 Chris Pinkham <cpinkham@mythtv.org>
+//
+// Licensed under the GPL v2 or later, see COPYING for details
+//
+////////////////////////////////////////////////////////////////////////////
+
+#ifndef TITLEINFOLIST_H_
+#define TITLEINFOLIST_H_
+
+#include <QVariantList>
+
+#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<QObject *>( pObject ));
+
+ return pObject;
+ }
+
+};
+
+} // namespace DTC
+
+Q_DECLARE_METATYPE( DTC::TitleInfoList )
+Q_DECLARE_METATYPE( DTC::TitleInfoList* )
+
+#endif
@@ -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
@@ -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,
@@ -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 )
@@ -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*);

0 comments on commit c8cd017

Please sign in to comment.