From 7d80a99b4726a73745bffb4d7932b84523d94cda Mon Sep 17 00:00:00 2001 From: Robert McNamara Date: Sun, 18 Sep 2011 21:42:25 -0700 Subject: [PATCH] Serices: Add a method to query Schedules Direct lineups. Adds "GetDDLineups" to the Channel service. Usage: http://BackendServerIP:6544/Channel/GetDDLineups?UserId=abcd&Password=1234 Returns all configured lineups from Schedules Direct as a LineupList data contract. Gives ZIP code, name, displayname, lineupID, etc. This will need a distclean, most likely. --- .../datacontracts/lineup.h | 149 ++++++++++++++++++ .../libmythservicecontracts.pro | 3 +- .../services/channelServices.h | 7 + .../programs/mythbackend/services/channel.cpp | 42 +++++ .../programs/mythbackend/services/channel.h | 4 + 5 files changed, 204 insertions(+), 1 deletion(-) create mode 100644 mythtv/libs/libmythservicecontracts/datacontracts/lineup.h diff --git a/mythtv/libs/libmythservicecontracts/datacontracts/lineup.h b/mythtv/libs/libmythservicecontracts/datacontracts/lineup.h new file mode 100644 index 00000000000..ec8ee700306 --- /dev/null +++ b/mythtv/libs/libmythservicecontracts/datacontracts/lineup.h @@ -0,0 +1,149 @@ +////////////////////////////////////////////////////////////////////////////// +// Program Name: lineup.h +// Created : Sep. 18, 2011 +// +// Copyright (c) 2011 Robert McNamara +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or at your option any later version of the LGPL. +// +// This library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library. If not, see . +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef LINEUP_H_ +#define LINEUP_H_ + +#include + +#include "serviceexp.h" +#include "datacontracthelper.h" + +namespace DTC +{ + +///////////////////////////////////////////////////////////////////////////// + +class SERVICE_PUBLIC Lineup : public QObject +{ + Q_OBJECT + Q_CLASSINFO( "version" , "1.0" ); + + Q_PROPERTY( QString LineupId READ LineupId WRITE setLineupId ) + Q_PROPERTY( QString Name READ Name WRITE setName ) + Q_PROPERTY( QString DisplayName READ DisplayName WRITE setDisplayName ) + Q_PROPERTY( QString Type READ Type WRITE setType ) + Q_PROPERTY( QString Postal READ Postal WRITE setPostal ) + Q_PROPERTY( QString Device READ Device WRITE setDevice ) + + PROPERTYIMP ( QString , LineupId ) + PROPERTYIMP ( QString , Name ) + PROPERTYIMP ( QString , DisplayName ) + PROPERTYIMP ( QString , Type ) + PROPERTYIMP ( QString , Postal ) + PROPERTYIMP ( QString , Device ) + + public: + + static void InitializeCustomTypes() + { + qRegisterMetaType< Lineup >(); + qRegisterMetaType< Lineup* >(); + } + + public: + + Lineup(QObject *parent = 0) + : QObject ( parent ) + { + } + + Lineup( const Lineup &src ) + { + Copy( src ); + } + + void Copy( const Lineup &src ) + { + m_LineupId = src.m_LineupId ; + m_Name = src.m_Name ; + m_DisplayName = src.m_DisplayName ; + m_Type = src.m_Type ; + m_Postal = src.m_Postal ; + m_Device = src.m_Device ; + } +}; + +class SERVICE_PUBLIC LineupList : public QObject +{ + Q_OBJECT + Q_CLASSINFO( "version", "1.0" ); + + // We need to know the type that will ultimately be contained in + // any QVariantList or QVariantMap. We do his by specifying + // A Q_CLASSINFO entry with "_type" as the key + // and the type name as the value + + Q_CLASSINFO( "Lineups_type", "DTC::Lineup"); + + Q_PROPERTY( QVariantList Lineups READ Lineups DESIGNABLE true ) + + PROPERTYIMP_RO_REF( QVariantList, Lineups ) + + public: + + static void InitializeCustomTypes() + { + qRegisterMetaType< LineupList >(); + qRegisterMetaType< LineupList* >(); + + Lineup::InitializeCustomTypes(); + } + + public: + + LineupList(QObject *parent = 0) + : QObject( parent ) + { + } + + LineupList( const LineupList &src ) + { + Copy( src ); + } + + void Copy( const LineupList &src ) + { + CopyListContents< Lineup >( this, m_Lineups, src.m_Lineups ); + } + + Lineup *AddNewLineup() + { + // We must make sure the object added to the QVariantList has + // a parent of 'this' + + Lineup *pObject = new Lineup( this ); + m_Lineups.append( QVariant::fromValue( pObject )); + + return pObject; + } + +}; + +} // namespace DTC + +Q_DECLARE_METATYPE( DTC::LineupList ) +Q_DECLARE_METATYPE( DTC::LineupList* ) + +Q_DECLARE_METATYPE( DTC::Lineup ) +Q_DECLARE_METATYPE( DTC::Lineup* ) + +#endif diff --git a/mythtv/libs/libmythservicecontracts/libmythservicecontracts.pro b/mythtv/libs/libmythservicecontracts/libmythservicecontracts.pro index dddf7c15401..eb67554b959 100644 --- a/mythtv/libs/libmythservicecontracts/libmythservicecontracts.pro +++ b/mythtv/libs/libmythservicecontracts/libmythservicecontracts.pro @@ -30,6 +30,7 @@ HEADERS += datacontracts/videoMultiplexList.h datacontracts/videoMetadataInfo HEADERS += datacontracts/videoMetadataInfoList.h datacontracts/blurayInfo.h HEADERS += datacontracts/timeZoneInfo.h datacontracts/videoLookupInfo.h HEADERS += datacontracts/videoLookupInfoList.h datacontracts/versionInfo.h +HEADERS += datacontracts/lineup.h SOURCES += service.cpp @@ -59,7 +60,7 @@ incDatacontracts.files += datacontracts/videoMultiplex.h datacontracts/vide incDatacontracts.files += datacontracts/videoMetadataInfo.h datacontracts/videoMetadataInfoList.h incDatacontracts.files += datacontracts/blurayInfo.h datacontracts/videoLookupInfo.h incDatacontracts.files += datacontracts/timeZoneInfo.h datacontracts/videoLookupInfoList.h -incDatacontracts.files += datacontracts/versionInfo.h +incDatacontracts.files += datacontracts/versionInfo.h datacontracts/lineup.h INSTALLS += inc incServices incDatacontracts diff --git a/mythtv/libs/libmythservicecontracts/services/channelServices.h b/mythtv/libs/libmythservicecontracts/services/channelServices.h index 230ab5a41c0..76310fcb005 100644 --- a/mythtv/libs/libmythservicecontracts/services/channelServices.h +++ b/mythtv/libs/libmythservicecontracts/services/channelServices.h @@ -31,6 +31,7 @@ #include "datacontracts/videoSourceList.h" #include "datacontracts/videoMultiplex.h" #include "datacontracts/videoMultiplexList.h" +#include "datacontracts/lineup.h" ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// @@ -71,6 +72,8 @@ class SERVICE_PUBLIC ChannelServices : public Service DTC::VideoSourceList::InitializeCustomTypes(); DTC::VideoMultiplex::InitializeCustomTypes(); DTC::VideoMultiplexList::InitializeCustomTypes(); + DTC::Lineup::InitializeCustomTypes(); + DTC::LineupList::InitializeCustomTypes(); } public slots: @@ -148,6 +151,10 @@ class SERVICE_PUBLIC ChannelServices : public Service virtual bool DeleteVideoSource ( uint SourceID ) = 0; + virtual DTC::LineupList* GetDDLineups ( const QString &Source, + const QString &UserId, + const QString &Password ) = 0; + /* Multiplex Methods */ virtual DTC::VideoMultiplexList* GetVideoMultiplexList ( int SourceID, diff --git a/mythtv/programs/mythbackend/services/channel.cpp b/mythtv/programs/mythbackend/services/channel.cpp index 78ff853cf1a..4734eb3afc9 100644 --- a/mythtv/programs/mythbackend/services/channel.cpp +++ b/mythtv/programs/mythbackend/services/channel.cpp @@ -32,6 +32,7 @@ #include "mythcorecontext.h" #include "channelutil.h" #include "sourceutil.h" +#include "datadirect.h" #include "serviceUtil.h" @@ -422,6 +423,47 @@ bool Channel::DeleteVideoSource( uint nSourceID ) // ///////////////////////////////////////////////////////////////////////////// +DTC::LineupList* Channel::GetDDLineups( const QString &sSource, + const QString &sUserId, + const QString &sPassword ) +{ + int source = 0; + + DTC::LineupList *pLineups = new DTC::LineupList(); + + if (sSource.toLower() == "schedulesdirect1" || + sSource.toLower() == "schedulesdirect" || + sSource.isEmpty()) + { + source = 1; + DataDirectProcessor ddp(source, sUserId, sPassword); + if (!ddp.GrabLineupsOnly()) + { + throw( QString("Unable to grab lineups. Check info.")); + } + const DDLineupList lineups = ddp.GetLineups(); + + DDLineupList::const_iterator it; + for (it = lineups.begin(); it != lineups.end(); ++it) + { + DTC::Lineup *pLineup = pLineups->AddNewLineup(); + + pLineup->setLineupId((*it).lineupid); + pLineup->setName((*it).name); + pLineup->setDisplayName((*it).displayname); + pLineup->setType((*it).type); + pLineup->setPostal((*it).postal); + pLineup->setDevice((*it).device); + } + } + + return pLineups; +} + +///////////////////////////////////////////////////////////////////////////// +// +///////////////////////////////////////////////////////////////////////////// + DTC::VideoMultiplexList* Channel::GetVideoMultiplexList( int nSourceID, int nStartIndex, int nCount ) diff --git a/mythtv/programs/mythbackend/services/channel.h b/mythtv/programs/mythbackend/services/channel.h index 59d92e953ee..df824c77fc7 100644 --- a/mythtv/programs/mythbackend/services/channel.h +++ b/mythtv/programs/mythbackend/services/channel.h @@ -109,6 +109,10 @@ class Channel : public ChannelServices bool DeleteVideoSource ( uint SourceID ); + DTC::LineupList* GetDDLineups ( const QString &Source, + const QString &UserId, + const QString &Password ); + /* Multiplex Methods */ DTC::VideoMultiplexList* GetVideoMultiplexList ( int SourceID,