Skip to content

Commit

Permalink
Serices: Add a method to query Schedules Direct lineups.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Robert McNamara committed Sep 19, 2011
1 parent eed7862 commit 7d80a99
Show file tree
Hide file tree
Showing 5 changed files with 204 additions and 1 deletion.
149 changes: 149 additions & 0 deletions mythtv/libs/libmythservicecontracts/datacontracts/lineup.h
@@ -0,0 +1,149 @@
//////////////////////////////////////////////////////////////////////////////
// Program Name: lineup.h
// Created : Sep. 18, 2011
//
// Copyright (c) 2011 Robert McNamara <rmcnamara@mythtv.org>
//
// 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 <http://www.gnu.org/licenses/>.
//
//////////////////////////////////////////////////////////////////////////////

#ifndef LINEUP_H_
#define LINEUP_H_

#include <QString>

#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 "<PropName>_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<QObject *>( 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
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
Expand Up @@ -31,6 +31,7 @@
#include "datacontracts/videoSourceList.h"
#include "datacontracts/videoMultiplex.h"
#include "datacontracts/videoMultiplexList.h"
#include "datacontracts/lineup.h"

/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down
42 changes: 42 additions & 0 deletions mythtv/programs/mythbackend/services/channel.cpp
Expand Up @@ -32,6 +32,7 @@
#include "mythcorecontext.h"
#include "channelutil.h"
#include "sourceutil.h"
#include "datadirect.h"

#include "serviceUtil.h"

Expand Down Expand Up @@ -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 )
Expand Down
4 changes: 4 additions & 0 deletions mythtv/programs/mythbackend/services/channel.h
Expand Up @@ -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,
Expand Down

0 comments on commit 7d80a99

Please sign in to comment.