Permalink
Browse files

Services: Add GetChannelGroupList method to Guide service

  • Loading branch information...
1 parent c06c191 commit f1600e0ad2eb18d34a540765b97f24f9acd6c3bb @stuartm stuartm committed Nov 15, 2013
@@ -0,0 +1,77 @@
+//////////////////////////////////////////////////////////////////////////////
+// Program Name: program.h
+// Created : Nov. 15, 2013
+//
+// Copyright (c) 2013 Stuart Morgan <smorgan@mythtv.org>
+//
+// Licensed under the GPL v2 or later, see COPYING for details
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef DTCCHANNELGROUP_H_
+#define DTCCHANNELGROUP_H_
+
+#include <QObject>
+#include <QString>
+
+#include "serviceexp.h"
+#include "datacontracthelper.h"
+
+namespace DTC
+{
+
+class SERVICE_PUBLIC ChannelGroup : public QObject
+{
+ Q_OBJECT
+ Q_CLASSINFO( "version", "0.99" );
+
+ // Q_CLASSINFO Used to augment Metadata for properties.
+ // See datacontracthelper.h for details
+
+ Q_PROPERTY( uint GroupId READ GroupId WRITE setGroupId )
+ Q_PROPERTY( QString Name READ Name WRITE setName )
+ Q_PROPERTY( QString Password READ Password WRITE setPassword )
+
+ PROPERTYIMP ( uint , GroupId )
+ PROPERTYIMP ( QString , Name )
+ PROPERTYIMP ( QString , Password )
+
+ public:
+
+ static void InitializeCustomTypes();
+
+ ChannelGroup(QObject *parent = 0)
+ : QObject ( parent ),
+ m_GroupId ( 0 )
+ {
+ }
+
+ ChannelGroup( const ChannelGroup &src )
+ {
+ Copy( src );
+ }
+
+ void Copy( const ChannelGroup &src )
+ {
+ m_GroupId = src.m_GroupId ;
+ m_Name = src.m_Name ;
+ m_Password = src.m_Password ;
+ }
+
+};
+
+}
+
+Q_DECLARE_METATYPE( DTC::ChannelGroup )
+Q_DECLARE_METATYPE( DTC::ChannelGroup* )
+
+namespace DTC
+{
+inline void ChannelGroup::InitializeCustomTypes()
+{
+ qRegisterMetaType< ChannelGroup >();
+ qRegisterMetaType< ChannelGroup* >();
+}
+}
+
+#endif
@@ -0,0 +1,78 @@
+#ifndef CHANNELGROUPLIST_H_
+#define CHANNELGROUPLIST_H_
+
+#include <QVariantList>
+#include <QString>
+#include <QDateTime>
+
+#include "serviceexp.h"
+#include "datacontracthelper.h"
+
+#include "channelGroup.h"
+
+namespace DTC
+{
+
+class SERVICE_PUBLIC ChannelGroupList : public QObject
+{
+ Q_OBJECT
+ Q_CLASSINFO( "version", "1.0" );
+
+ // Q_CLASSINFO Used to augment Metadata for properties.
+ // See datacontracthelper.h for details
+
+ Q_CLASSINFO( "ChannelGroups", "type=DTC::ChannelGroup");
+
+ Q_PROPERTY( QVariantList ChannelGroups READ ChannelGroups DESIGNABLE true )
+
+ PROPERTYIMP_RO_REF( QVariantList, ChannelGroups )
+
+ public:
+
+ static inline void InitializeCustomTypes();
+
+ ChannelGroupList(QObject *parent = 0)
+ : QObject( parent )
+ {
+ }
+
+ ChannelGroupList( const ChannelGroupList &src )
+ {
+ Copy( src );
+ }
+
+ void Copy( const ChannelGroupList &src )
+ {
+ CopyListContents< ChannelGroup >( this, m_ChannelGroups, src.m_ChannelGroups );
+ }
+
+ ChannelGroup *AddNewChannelGroup()
+ {
+ // We must make sure the object added to the QVariantList has
+ // a parent of 'this'
+
+ ChannelGroup *pObject = new ChannelGroup( this );
+ m_ChannelGroups.append( QVariant::fromValue<QObject *>( pObject ));
+
+ return pObject;
+ }
+
+};
+
+} // namespace DTC
+
+Q_DECLARE_METATYPE( DTC::ChannelGroupList )
+Q_DECLARE_METATYPE( DTC::ChannelGroupList* )
+
+namespace DTC
+{
+inline void ChannelGroupList::InitializeCustomTypes()
+{
+ qRegisterMetaType< ChannelGroupList >();
+ qRegisterMetaType< ChannelGroupList* >();
+
+ ChannelGroup::InitializeCustomTypes();
+}
+}
+
+#endif
@@ -45,7 +45,8 @@ HEADERS += datacontracts/titleInfo.h datacontracts/titleInfoList.h
HEADERS += datacontracts/labelValue.h
HEADERS += datacontracts/logMessage.h datacontracts/logMessageList.h
HEADERS += datacontracts/imageMetadataInfoList.h datacontracts/imageMetadataInfo.h
-HEADERS += datacontracts/imageSyncInfo.h
+HEADERS += datacontracts/imageSyncInfo.h datacontracts/channelGroup.h
+HEADERS += datacontracts/channelGroupList.h
SOURCES += service.cpp
@@ -87,7 +88,8 @@ incDatacontracts.files += datacontracts/titleInfo.h datacontracts/titl
incDatacontracts.files += datacontracts/labelValue.h
incDatacontracts.files += datacontracts/logMessage.h datacontracts/logMessageList.h
incDatacontracts.files += datacontracts/imageMetadataInfoList.h datacontracts/imageMetadataInfo.h
-incDatacontracts.files += datacontracts/imageSyncInfo.h
+incDatacontracts.files += datacontracts/imageSyncInfo.h datacontracts/channelGroup.h
+incDatacontracts.files += datacontracts/channelGroupList.h
INSTALLS += inc incServices incDatacontracts
@@ -18,6 +18,7 @@
#include "service.h"
#include "datacontracts/programGuide.h"
#include "datacontracts/programAndChannel.h"
+#include "datacontracts/channelGroupList.h"
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
@@ -38,7 +39,7 @@
class SERVICE_PUBLIC GuideServices : public Service //, public QScriptable ???
{
Q_OBJECT
- Q_CLASSINFO( "version" , "1.0" );
+ Q_CLASSINFO( "version" , "2.0" );
public:
@@ -49,6 +50,8 @@ class SERVICE_PUBLIC GuideServices : public Service //, public QScriptable ???
{
DTC::ProgramGuide::InitializeCustomTypes();
DTC::Program ::InitializeCustomTypes();
+ DTC::ChannelGroup::InitializeCustomTypes();
+ DTC::ChannelGroupList::InitializeCustomTypes();
}
public slots:
@@ -65,6 +68,7 @@ class SERVICE_PUBLIC GuideServices : public Service //, public QScriptable ???
virtual QFileInfo GetChannelIcon ( int ChanId,
int Width ,
int Height ) = 0;
+ virtual DTC::ChannelGroupList* GetChannelGroupList ( bool IncludeEmpty ) = 0;
};
#endif
@@ -33,6 +33,9 @@
#include "scheduler.h"
#include "autoexpire.h"
#include "channelutil.h"
+#include "channelgroup.h"
+
+#include "logging.h"
extern AutoExpire *expirer;
extern Scheduler *sched;
@@ -305,3 +308,17 @@ QFileInfo Guide::GetChannelIcon( int nChanId,
return QFileInfo( sNewFileName );
}
+DTC::ChannelGroupList* Guide::GetChannelGroupList( bool IncludeEmpty )
+{
+ ChannelGroupList list = ChannelGroup::GetChannelGroups(IncludeEmpty);
+ DTC::ChannelGroupList *pGroupList = new DTC::ChannelGroupList();
+
+ ChannelGroupList::iterator it;
+ for (it = list.begin(); it < list.end(); ++it)
+ {
+ DTC::ChannelGroup *pGroup = pGroupList->AddNewChannelGroup();
+ FillChannelGroup(pGroup, (*it));
+ }
+
+ return pGroupList;
+}
@@ -33,6 +33,7 @@
#include "services/guideServices.h"
#include "datacontracts/programAndChannel.h"
+#include "datacontracts/channelGroupList.h"
#include "programinfo.h"
class Guide : public GuideServices
@@ -58,6 +59,8 @@ class Guide : public GuideServices
QFileInfo GetChannelIcon ( int ChanId,
int Width ,
int Height );
+
+ DTC::ChannelGroupList* GetChannelGroupList ( bool IncludeEmpty );
};
// --------------------------------------------------------------------------
@@ -107,6 +110,11 @@ class ScriptableGuide : public QObject
{
return m_obj.GetChannelIcon( ChanId, Width, Height );
}
+
+ DTC::ChannelGroupList* GetChannelGroupList( bool IncludeEmpty )
+ {
+ return m_obj.GetChannelGroupList( IncludeEmpty );
+ }
};
Q_SCRIPT_DECLARE_QMETAOBJECT( ScriptableGuide, QObject*);
@@ -34,7 +34,7 @@
#include "channelinfo.h"
#include "videoutils.h"
#include "metadataimagehelper.h"
-#include <cardutil.h>
+#include "cardutil.h"
/////////////////////////////////////////////////////////////////////////////
//
@@ -213,6 +213,19 @@ bool FillChannelInfo( DTC::ChannelInfo *pChannel,
return false;
}
+/////////////////////////////////////////////////////////////////////////////
+//
+/////////////////////////////////////////////////////////////////////////////
+
+void FillChannelGroup(DTC::ChannelGroup* pGroup, ChannelGroupItem pGroupItem)
+{
+ if (!pGroup)
+ return;
+
+ pGroup->setGroupId(pGroupItem.grpid);
+ pGroup->setName(pGroupItem.name);
+ pGroup->setPassword(""); // Not currently supported
+}
/////////////////////////////////////////////////////////////////////////////
//
@@ -30,10 +30,12 @@
#include "datacontracts/recRule.h"
#include "datacontracts/artworkInfoList.h"
#include "datacontracts/videoMetadataInfo.h"
+#include "datacontracts/channelGroup.h"
#include "programinfo.h"
#include "recordingrule.h"
#include "videometadatalistmanager.h"
+#include "channelgroup.h"
void FillProgramInfo( DTC::Program *pProgram,
ProgramInfo *pInfo,
@@ -44,6 +46,8 @@ bool FillChannelInfo( DTC::ChannelInfo *pChannel,
uint nChanID,
bool bDetails = true );
+void FillChannelGroup( DTC::ChannelGroup *pGroup, ChannelGroupItem pGroupItem);
+
void FillRecRuleInfo( DTC::RecRule *pRecRule,
RecordingRule *pRule );
@@ -55,4 +59,5 @@ void FillVideoMetadataInfo (
DTC::VideoMetadataInfo *pVideoMetadataInfo,
VideoMetadataListManager::VideoMetadataPtr pMetadata,
bool bDetails);
+
#endif

0 comments on commit f1600e0

Please sign in to comment.