Ticket #11491: mythtv-0.27-serviceapi-recorded-markup.patch

File mythtv-0.27-serviceapi-recorded-markup.patch, 15.2 KB (added by dev-team@…, 7 years ago)

adds methods to query recordedmarkup data to services-api content endpoint for 0.27

  • new file mythtv/libs/libmythservicecontracts/datacontracts/recordedMarkup.h

    diff --git a/mythtv/libs/libmythservicecontracts/datacontracts/recordedMarkup.h b/mythtv/libs/libmythservicecontracts/datacontracts/recordedMarkup.h
    new file mode 100644
    index 0000000..1fa8b9f
    - +  
     1//////////////////////////////////////////////////////////////////////////////
     2// Program Name: recordedMarkup.h
     3// Created     : Apr. 17, 2013
     4//
     5// Copyright (c) 2013 Tikinou LLC <dev-team@tikinou.com>
     6//
     7// Licensed under the GPL v2 or later, see COPYING for details
     8//
     9//////////////////////////////////////////////////////////////////////////////
     10
     11#ifndef RECORDEDMARKUP_H_
     12#define RECORDEDMARKUP_H_
     13
     14#include <QVariantList>
     15#include <QDateTime>
     16
     17#include "serviceexp.h"
     18#include "datacontracthelper.h"
     19
     20#include "recordedMarkupItem.h"
     21
     22namespace DTC
     23{
     24
     25class SERVICE_PUBLIC RecordedMarkup : public QObject
     26{
     27    Q_OBJECT
     28    Q_CLASSINFO( "version", "1.0" );
     29
     30    // Q_CLASSINFO Used to augment Metadata for properties.
     31    // See datacontracthelper.h for details
     32
     33    Q_CLASSINFO( "Markups", "type=DTC::RecordedMarkupItem");
     34
     35    Q_PROPERTY( int          ChannelId      READ ChannelId       WRITE setChannelId      )
     36    Q_PROPERTY( QDateTime    StartTime      READ StartTime       WRITE setStartTime      )
     37
     38    Q_PROPERTY( QVariantList Markups READ Markups DESIGNABLE true )
     39
     40    PROPERTYIMP       ( int         , ChannelId       )
     41    PROPERTYIMP       ( QDateTime   , StartTime       )
     42
     43    PROPERTYIMP_RO_REF( QVariantList, Markups )
     44
     45    public:
     46
     47        static void InitializeCustomTypes()
     48        {
     49            qRegisterMetaType< RecordedMarkup   >();
     50            qRegisterMetaType< RecordedMarkup*  >();
     51
     52            RecordedMarkupItem::InitializeCustomTypes();
     53        }
     54
     55    public:
     56
     57        RecordedMarkup(QObject *parent = 0)
     58            : QObject( parent )
     59        {
     60        }
     61
     62        RecordedMarkup( const RecordedMarkup &src )
     63        {
     64            Copy( src );
     65        }
     66
     67        void Copy( const RecordedMarkup &src )
     68        {
     69            m_ChannelId     = src.m_ChannelId      ;
     70            m_StartTime     = src.m_StartTime      ;
     71
     72            CopyListContents< RecordedMarkupItem >( this, m_Markups, src.m_Markups );
     73        }
     74
     75        RecordedMarkupItem *AddNewMarkupItem()
     76        {
     77            // We must make sure the object added to the QVariantList has
     78            // a parent of 'this'
     79
     80                RecordedMarkupItem *pObject = new RecordedMarkupItem( this );
     81            m_Markups.append( QVariant::fromValue<QObject *>( pObject ));
     82
     83            return pObject;
     84        }
     85
     86};
     87
     88} // namespace DTC
     89
     90Q_DECLARE_METATYPE( DTC::RecordedMarkup  )
     91Q_DECLARE_METATYPE( DTC::RecordedMarkup* )
     92
     93#endif
  • new file mythtv/libs/libmythservicecontracts/datacontracts/recordedMarkupItem.h

    diff --git a/mythtv/libs/libmythservicecontracts/datacontracts/recordedMarkupItem.h b/mythtv/libs/libmythservicecontracts/datacontracts/recordedMarkupItem.h
    new file mode 100644
    index 0000000..c311665
    - +  
     1//////////////////////////////////////////////////////////////////////////////
     2// Program Name: recordedMarkupItem.h
     3// Created     : Apr. 17, 2013
     4//
     5// Copyright (c) 2013 Tikinou LLC <dev-team@tikinou.com>
     6//                                         
     7// Licensed under the GPL v2 or later, see COPYING for details
     8//
     9//////////////////////////////////////////////////////////////////////////////
     10
     11#ifndef RECORDEDMARKUPITEM_H_
     12#define RECORDEDMARKUPITEM_H_
     13
     14#include "serviceexp.h"
     15#include "datacontracthelper.h"
     16#include "programtypes.h"
     17
     18namespace DTC
     19{
     20
     21/////////////////////////////////////////////////////////////////////////////
     22
     23class SERVICE_PUBLIC RecordedMarkupItem : public QObject
     24{
     25    Q_OBJECT
     26    Q_CLASSINFO( "version"    , "1.0" );
     27
     28    Q_PROPERTY( int             Mark            READ Mark             WRITE setMark           )
     29    Q_PROPERTY( int             Data            READ Data             WRITE setData           )
     30    Q_PROPERTY( int             DataType        READ DataType         WRITE setDataType    DESIGNABLE SerializeDetails )
     31
     32    PROPERTYIMP         ( int        , Mark           )
     33    PROPERTYIMP         ( int        , Data           )
     34    PROPERTYIMP_ENUM    ( MarkTypes  , DataType       )
     35
     36    // Used only by Serializer
     37    PROPERTYIMP( bool, SerializeDetails )
     38
     39    public:
     40
     41        static void InitializeCustomTypes()
     42        {
     43            qRegisterMetaType< RecordedMarkupItem  >();
     44            qRegisterMetaType< RecordedMarkupItem* >();
     45        }
     46
     47    public:
     48
     49        RecordedMarkupItem(QObject *parent = 0)
     50            : QObject             ( parent ),
     51              m_Mark              ( 0             ),
     52              m_Data              ( 0             ),
     53              m_DataType          ( MARK_ALL      ),
     54              m_SerializeDetails  ( true          )
     55        {
     56        }
     57       
     58        RecordedMarkupItem( const RecordedMarkupItem &src )
     59        {
     60            Copy( src );
     61        }
     62
     63        void Copy( const RecordedMarkupItem &src )
     64        {
     65                m_Mark                = src.m_Mark                        ;
     66                m_Data                = src.m_Data                        ;
     67                m_DataType                = src.m_DataType                ;
     68                m_SerializeDetails    = src.m_SerializeDetails            ;
     69        }
     70};
     71
     72} // namespace DTC
     73
     74Q_DECLARE_METATYPE( DTC::RecordedMarkupItem  )
     75Q_DECLARE_METATYPE( DTC::RecordedMarkupItem* )
     76
     77#endif
  • new file mythtv/libs/libmythservicecontracts/datacontracts/recordedMarkupList.h

    diff --git a/mythtv/libs/libmythservicecontracts/datacontracts/recordedMarkupList.h b/mythtv/libs/libmythservicecontracts/datacontracts/recordedMarkupList.h
    new file mode 100644
    index 0000000..57374c0
    - +  
     1//////////////////////////////////////////////////////////////////////////////
     2// Program Name: recordedMarkupList.h
     3// Created     : Apr. 17, 2013
     4//
     5// Copyright (c) 2013 Tikinou LLC <dev-team@tikinou.com>
     6//                                         
     7// Licensed under the GPL v2 or later, see COPYING for details
     8//
     9//////////////////////////////////////////////////////////////////////////////
     10
     11#ifndef RECORDEDMARKUPLIST_H_
     12#define RECORDEDMARKUPLIST_H_
     13
     14#include <QDateTime>
     15#include <QVariantList>
     16
     17#include "serviceexp.h"
     18#include "datacontracthelper.h"
     19
     20#include "recordedMarkup.h"
     21
     22namespace DTC
     23{
     24
     25class SERVICE_PUBLIC RecordedMarkupList : public QObject
     26{
     27    Q_OBJECT
     28    Q_CLASSINFO( "version", "1.0" );
     29
     30    // Q_CLASSINFO Used to augment Metadata for properties.
     31    // See datacontracthelper.h for details
     32
     33    Q_CLASSINFO( "RecordingMarkups", "type=DTC::RecordedMarkup");
     34        Q_CLASSINFO( "AsOf"        , "transient=true"   );
     35
     36    Q_PROPERTY( QDateTime    AsOf                 READ AsOf                WRITE setAsOf           )
     37    Q_PROPERTY( QVariantList RecordingMarkups     READ RecordingMarkups    DESIGNABLE true         )
     38
     39    PROPERTYIMP       ( QDateTime   , AsOf            )
     40
     41    PROPERTYIMP_RO_REF( QVariantList, RecordingMarkups      )
     42
     43    public:
     44
     45        static void InitializeCustomTypes()
     46        {
     47            qRegisterMetaType< RecordedMarkupList  >();
     48            qRegisterMetaType< RecordedMarkupList* >();
     49
     50            RecordedMarkup::InitializeCustomTypes();
     51        }
     52
     53    public:
     54
     55        RecordedMarkupList(QObject *parent = 0)
     56            : QObject         ( parent )
     57        {
     58        }
     59       
     60        RecordedMarkupList( const RecordedMarkupList &src )
     61        {
     62            Copy( src );
     63        }
     64
     65        void Copy( const RecordedMarkupList &src )
     66        {
     67            m_AsOf          = src.m_AsOf           ;
     68
     69            CopyListContents< RecordedMarkup >( this, m_RecordingMarkups, src.m_RecordingMarkups );
     70        }
     71
     72        RecordedMarkup *AddNewRecordedMarkup()
     73        {
     74            // We must make sure the object added to the QVariantList has
     75            // a parent of 'this'
     76
     77            RecordedMarkup *pObject = new RecordedMarkup( this );
     78            m_RecordingMarkups.append( QVariant::fromValue<QObject *>( pObject ));
     79
     80            return pObject;
     81        }
     82
     83};
     84
     85} // namespace DTC
     86
     87Q_DECLARE_METATYPE( DTC::RecordedMarkupList  )
     88Q_DECLARE_METATYPE( DTC::RecordedMarkupList* )
     89
     90#endif
  • mythtv/libs/libmythservicecontracts/services/contentServices.h

    diff --git a/mythtv/libs/libmythservicecontracts/services/contentServices.h b/mythtv/libs/libmythservicecontracts/services/contentServices.h
    index cc851b0..1c33910 100644
    a b  
    1919#include "service.h"
    2020#include "datacontracts/artworkInfoList.h"
    2121#include "datacontracts/liveStreamInfoList.h"
     22#include "datacontracts/recordedMarkupList.h"
    2223
    2324/////////////////////////////////////////////////////////////////////////////
    2425/////////////////////////////////////////////////////////////////////////////
     
    3940class SERVICE_PUBLIC ContentServices : public Service  //, public QScriptable ???
    4041{
    4142    Q_OBJECT
    42     Q_CLASSINFO( "version"    , "1.32" );
     43    Q_CLASSINFO( "version"    , "1.33" );
    4344    Q_CLASSINFO( "DownloadFile_Method",            "POST" )
    4445
    4546    public:
     
    5152        {
    5253            DTC::ArtworkInfoList::InitializeCustomTypes();
    5354            DTC::LiveStreamInfoList::InitializeCustomTypes();
     55            DTC::RecordedMarkupList::InitializeCustomTypes();
    5456        }
    5557
    5658    public slots:
     
    102104        virtual bool                DownloadFile        ( const QString   &URL,
    103105                                                          const QString   &StorageGroup ) = 0;
    104106
     107        virtual DTC::RecordedMarkup     *GetRecordingMarkups    ( int              ChanId,
     108                                                                  const QDateTime &StartTime ) = 0;
     109
     110        virtual DTC::RecordedMarkupList *GetAllRecordingMarkups ( void ) = 0;
     111
    105112        virtual DTC::LiveStreamInfo     *AddLiveStream          ( const QString   &StorageGroup,
    106113                                                                  const QString   &FileName,
    107114                                                                  const QString   &HostName,
  • mythtv/programs/mythbackend/services/content.cpp

    diff --git a/mythtv/programs/mythbackend/services/content.cpp b/mythtv/programs/mythbackend/services/content.cpp
    index 97fabe0..b253beb 100644
    a b  
    632632/////////////////////////////////////////////////////////////////////////////
    633633//
    634634/////////////////////////////////////////////////////////////////////////////
     635DTC::RecordedMarkup *Content::GetRecordingMarkups ( int              chanId,
     636                                                    const QDateTime &startTime )
     637{
     638    MSqlQuery query(MSqlQuery::InitCon());
    635639
     640    if (!query.isConnected())
     641        throw( QString("Database not open while trying to get "
     642                       "Recording Markups."));
     643    query.prepare("SELECT chanid, starttime, mark, type, data "
     644                  " FROM recordedmarkup "
     645                  " WHERE chanid = :CHANID AND starttime = :STARTTIME "
     646                  " ORDER BY starttime");
     647
     648    query.bindValue( ":CHANID",     chanId    );
     649    query.bindValue( ":STARTTIME",  startTime );
     650
     651    if (!query.exec())
     652    {
     653        MythDB::DBError("MythAPI::GetRecordingMarkups()", query);
     654            throw( QString( "Database Error executing query." ));
     655    }
     656    // ----------------------------------------------------------------------
     657    // return the results of the query
     658    // ----------------------------------------------------------------------
     659
     660    DTC::RecordedMarkup *pRecordedMarkup = new DTC::RecordedMarkup();
     661
     662    while (query.next())
     663    {
     664        QDateTime dateTime = MythDate::as_utc(query.value(1).toDateTime());
     665        pRecordedMarkup->setChannelId    ( query.value(0).toInt()       );
     666        pRecordedMarkup->setStartTime    ( dateTime    );
     667
     668        DTC::RecordedMarkupItem *pItem = pRecordedMarkup->AddNewMarkupItem();
     669        pItem->setMark        ( query.value(2).toInt() );
     670        pItem->setDataType    ( query.value(3).toInt() );
     671        pItem->setData        ( query.value(4).toInt() );
     672    }
     673
     674    return pRecordedMarkup;
     675}
     676
     677/////////////////////////////////////////////////////////////////////////////
     678//
     679/////////////////////////////////////////////////////////////////////////////
     680DTC::RecordedMarkupList *Content::GetAllRecordingMarkups    ( void )
     681{
     682    MSqlQuery query(MSqlQuery::InitCon());
     683
     684    if (!query.isConnected())
     685        throw( QString("Database not open while trying to get "
     686                       "Recording Markups."));
     687    query.prepare("SELECT chanid, starttime, mark, type, data "
     688                  " FROM recordedmarkup "
     689                  " ORDER BY chanid, starttime" );
     690
     691    if (!query.exec())
     692    {
     693        MythDB::DBError("MythAPI::GetRecordingMarkups()", query);
     694            throw( QString( "Database Error executing query." ));
     695    }
     696    // ----------------------------------------------------------------------
     697    // return the results of the query
     698    // ----------------------------------------------------------------------
     699
     700    DTC::RecordedMarkupList* pList = new DTC::RecordedMarkupList();
     701
     702    int previousChanId = -1;
     703    QDateTime previousDateTime;
     704    DTC::RecordedMarkup *pRecordedMarkup = NULL;
     705    while (query.next())
     706    {
     707        QDateTime dateTime = MythDate::as_utc(query.value(1).toDateTime());
     708        if(dateTime != previousDateTime)
     709        {
     710             pRecordedMarkup = pList->AddNewRecordedMarkup();
     711             pRecordedMarkup->setChannelId    ( query.value(0).toInt()       );
     712             pRecordedMarkup->setStartTime    ( dateTime    );
     713             previousDateTime = dateTime;
     714        }
     715        DTC::RecordedMarkupItem *pItem = pRecordedMarkup->AddNewMarkupItem();
     716        pItem->setMark        ( query.value(2).toInt() );
     717        pItem->setDataType    ( query.value(3).toInt() );
     718        pItem->setData        ( query.value(4).toInt() );
     719    }
     720
     721    pList->setAsOf          ( MythDate::current() );
     722
     723    return pList;
     724}
     725
     726/////////////////////////////////////////////////////////////////////////////
     727//
     728/////////////////////////////////////////////////////////////////////////////
    636729QFileInfo Content::GetMusic( int nId )
    637730{
    638731    QString sBasePath = gCoreContext->GetSetting( "MusicLocation", "");
  • mythtv/programs/mythbackend/services/content.h

    diff --git a/mythtv/programs/mythbackend/services/content.h b/mythtv/programs/mythbackend/services/content.h
    index d76d086..251946d 100644
    a b  
    8585        bool                DownloadFile        ( const QString   &URL,
    8686                                                  const QString   &StorageGroup );
    8787
     88        DTC::RecordedMarkup     *GetRecordingMarkups        ( int              ChanId,
     89                                                              const QDateTime &StartTime );
     90
     91        DTC::RecordedMarkupList *GetAllRecordingMarkups    ( void );
     92
    8893        // HTTP Live Streaming
    8994        DTC::LiveStreamInfo     *AddLiveStream          ( const QString   &StorageGroup,
    9095                                                          const QString   &FileName,