Ticket #11386: services-api.v1.patch

File services-api.v1.patch, 13.4 KB (added by Bill Meek <keemllib@…>, 7 years ago)
  • new file mythtv/libs/libmythservicecontracts/datacontracts/buildInfo.h

    diff --git a/mythtv/libs/libmythservicecontracts/datacontracts/buildInfo.h b/mythtv/libs/libmythservicecontracts/datacontracts/buildInfo.h
    new file mode 100644
    index 0000000..c359d71
    - +  
     1//////////////////////////////////////////////////////////////////////////////
     2// Program Name: buildInfo.h
     3// Created     : Jan. 16, 2013
     4//
     5// Copyright (c) 2013 David Blain <dblain@mythtv.org>
     6//
     7// Licensed under the GPL v2 or later, see COPYING for details
     8//
     9//////////////////////////////////////////////////////////////////////////////
     10
     11#ifndef BUILDINFO_H_
     12#define BUILDINFO_H_
     13
     14#include <QString>
     15
     16#include "serviceexp.h"
     17#include "datacontracthelper.h"
     18
     19namespace DTC
     20{
     21
     22class SERVICE_PUBLIC BuildInfo : public QObject
     23{
     24    Q_OBJECT
     25
     26    Q_CLASSINFO( "version"    , "1.0" );
     27
     28    Q_PROPERTY( bool     LibX264      READ LibX264   WRITE setLibX264   )
     29    Q_PROPERTY( bool     LibDNS_SD    READ LibX264   WRITE setLibDNS_SD )
     30
     31    PROPERTYIMP( bool    , LibX264   )
     32    PROPERTYIMP( bool    , LibDNS_SD )
     33
     34    public:
     35
     36        static void InitializeCustomTypes()
     37        {
     38            qRegisterMetaType< BuildInfo   >();
     39            qRegisterMetaType< BuildInfo*  >();
     40        }
     41
     42    public:
     43
     44        BuildInfo(QObject *parent = 0)
     45            : QObject    ( parent ),
     46              m_LibX264  ( false  ),
     47              m_LibDNS_SD( false  )
     48        {
     49        }
     50
     51        BuildInfo( const BuildInfo &src )
     52        {
     53            Copy( src );
     54        }
     55
     56        void Copy( const BuildInfo &src )
     57        {
     58            m_LibX264   = src.m_LibX264  ;
     59            m_LibDNS_SD = src.m_LibDNS_SD;
     60        }
     61};
     62
     63typedef BuildInfo* BuildInfoPtr;
     64
     65} // namespace DTC
     66
     67Q_DECLARE_METATYPE( DTC::BuildInfo  )
     68Q_DECLARE_METATYPE( DTC::BuildInfo* )
     69
     70
     71#endif
  • new file mythtv/libs/libmythservicecontracts/datacontracts/configurationInfo.h

    diff --git a/mythtv/libs/libmythservicecontracts/datacontracts/configurationInfo.h b/mythtv/libs/libmythservicecontracts/datacontracts/configurationInfo.h
    new file mode 100644
    index 0000000..41a7f5d
    - +  
     1//////////////////////////////////////////////////////////////////////////////
     2// Program Name: configurationInfo.h
     3// Created     : Jan. 16, 2013
     4//
     5// Copyright (c) 2010 David Blain <dblain@mythtv.org>
     6//
     7// Licensed under the GPL v2 or later, see COPYING for details
     8//
     9//////////////////////////////////////////////////////////////////////////////
     10
     11#ifndef CONFIGURATIONINFO_H_
     12#define CONFIGURATIONINFO_H_
     13
     14#include "serviceexp.h"
     15#include "datacontracthelper.h"
     16
     17#include "buildInfo.h"
     18#include "logInfo.h"
     19
     20namespace DTC
     21{
     22
     23class SERVICE_PUBLIC ConfigurationInfo : public QObject
     24{
     25    Q_OBJECT
     26
     27    Q_CLASSINFO( "version"    , "1.0" );
     28
     29    Q_PROPERTY( QObject*    Build   READ Build )
     30    Q_PROPERTY( QObject*    Log     READ Log   )
     31
     32    PROPERTYIMP_PTR( BuildInfo, Build )
     33    PROPERTYIMP_PTR( LogInfo,   Log   )
     34
     35    public:
     36
     37        static void InitializeCustomTypes()
     38        {
     39            qRegisterMetaType< ConfigurationInfo   >();
     40            qRegisterMetaType< ConfigurationInfo*  >();
     41
     42            BuildInfo::InitializeCustomTypes();
     43            LogInfo  ::InitializeCustomTypes();
     44        }
     45
     46    public:
     47
     48        ConfigurationInfo(QObject *parent = 0)
     49            : QObject   ( parent ),
     50              m_Build   ( NULL   ),
     51              m_Log     ( NULL   )
     52        {
     53        }
     54
     55        ConfigurationInfo( const ConfigurationInfo &src )
     56            : m_Build  ( NULL ),
     57              m_Log    ( NULL )
     58        {
     59            Copy( src );
     60        }
     61
     62        void Copy( const ConfigurationInfo &src )
     63        {
     64            // We always need to make sure the child object is
     65            // created with the correct parent *
     66
     67            if (src.m_Build)
     68                Build()->Copy( src.m_Build );
     69
     70            if (src.m_Log)
     71                Log()->Copy( src.m_Log  );
     72
     73        }
     74};
     75
     76typedef ConfigurationInfo* ConfigurationInfoPtr;
     77
     78} // namespace DTC
     79
     80Q_DECLARE_METATYPE( DTC::ConfigurationInfo  )
     81Q_DECLARE_METATYPE( DTC::ConfigurationInfo* )
     82
     83#endif
  • new file mythtv/libs/libmythservicecontracts/datacontracts/logInfo.h

    diff --git a/mythtv/libs/libmythservicecontracts/datacontracts/logInfo.h b/mythtv/libs/libmythservicecontracts/datacontracts/logInfo.h
    new file mode 100644
    index 0000000..1569d58
    - +  
     1//////////////////////////////////////////////////////////////////////////////
     2// Program Name: logInfo.h
     3// Created     : Jan. 16, 2013
     4//
     5// Copyright (c) 2013 David Blain <dblain@mythtv.org>
     6//
     7// Licensed under the GPL v2 or later, see COPYING for details
     8//
     9//////////////////////////////////////////////////////////////////////////////
     10
     11#ifndef LOGINFO_H_
     12#define LOGINFO_H_
     13
     14#include <QString>
     15
     16#include "serviceexp.h"
     17#include "datacontracthelper.h"
     18
     19namespace DTC
     20{
     21
     22class SERVICE_PUBLIC LogInfo : public QObject
     23{
     24    Q_OBJECT
     25
     26    Q_CLASSINFO( "version"    , "1.0" );
     27    Q_CLASSINFO( "defaultProp", "LogArgs" );
     28
     29    Q_PROPERTY( QString  LogArgs      READ LogArgs   WRITE setLogArgs   )
     30
     31    PROPERTYIMP( QString,  LogArgs   )
     32
     33    public:
     34
     35        static void InitializeCustomTypes()
     36        {
     37            qRegisterMetaType< LogInfo   >();
     38            qRegisterMetaType< LogInfo*  >();
     39        }
     40
     41    public:
     42
     43        LogInfo(QObject *parent = 0)
     44            : QObject    ( parent ),
     45              m_LogArgs  ( ""     )
     46        {
     47        }
     48
     49        LogInfo( const LogInfo &src )
     50        {
     51            Copy( src );
     52        }
     53
     54        void Copy( const LogInfo &src )
     55        {
     56            m_LogArgs   = src.m_LogArgs  ;
     57        }
     58};
     59
     60typedef LogInfo* LogInfoPtr;
     61
     62} // namespace DTC
     63
     64Q_DECLARE_METATYPE( DTC::LogInfo  )
     65Q_DECLARE_METATYPE( DTC::LogInfo* )
     66
     67
     68#endif
  • mythtv/libs/libmythservicecontracts/datacontracts/storageGroupDir.h

    diff --git a/mythtv/libs/libmythservicecontracts/datacontracts/storageGroupDir.h b/mythtv/libs/libmythservicecontracts/datacontracts/storageGroupDir.h
    index 6693551..fd88653 100644
    a b namespace DTC 
    1414class SERVICE_PUBLIC StorageGroupDir : public QObject
    1515{
    1616    Q_OBJECT
    17     Q_CLASSINFO( "version"    , "1.0" );
     17    Q_CLASSINFO( "version"    , "1.1" );
    1818
    1919    Q_PROPERTY( int             Id              READ Id               WRITE setId             )
    2020    Q_PROPERTY( QString         GroupName       READ GroupName        WRITE setGroupName      )
    2121    Q_PROPERTY( QString         HostName        READ HostName         WRITE setHostName       )
    2222    Q_PROPERTY( QString         DirName         READ DirName          WRITE setDirName        )
     23    Q_PROPERTY( bool            DirPerms        READ DirPerms         WRITE setDirPerms       )
    2324
    2425    PROPERTYIMP    ( int        , Id             )
    2526    PROPERTYIMP    ( QString    , GroupName      )
    2627    PROPERTYIMP    ( QString    , HostName       )
    2728    PROPERTYIMP    ( QString    , DirName        )
     29    PROPERTYIMP    ( bool       , DirPerms       )
    2830
    2931    public:
    3032
    class SERVICE_PUBLIC StorageGroupDir : public QObject 
    5355            m_GroupName     = src.m_GroupName     ;
    5456            m_HostName      = src.m_HostName      ;
    5557            m_DirName       = src.m_DirName       ;
     58            m_DirPerms      = src.m_DirPerms      ;
    5659        }
    5760};
    5861
  • mythtv/libs/libmythservicecontracts/libmythservicecontracts.pro

    diff --git a/mythtv/libs/libmythservicecontracts/libmythservicecontracts.pro b/mythtv/libs/libmythservicecontracts/libmythservicecontracts.pro
    index 638aa94..9bf3564 100644
    a b HEADERS += datacontracts/frontendActionList.h 
    4040HEADERS += datacontracts/liveStreamInfo.h        datacontracts/liveStreamInfoList.h
    4141HEADERS += datacontracts/labelValue.h
    4242HEADERS += datacontracts/logMessage.h            datacontracts/logMessageList.h
     43HEADERS += datacontracts/buildInfo.h             datacontracts/logInfo.h
     44HEADERS += datacontracts/configurationInfo.h
    4345
    4446SOURCES += service.cpp
    4547
    incDatacontracts.files += datacontracts/frontendStatus.h datacontracts/fron 
    8082incDatacontracts.files += datacontracts/liveStreamInfo.h      datacontracts/liveStreamInfoList.h
    8183incDatacontracts.files += datacontracts/labelValue.h
    8284incDatacontracts.files += datacontracts/logMessage.h          datacontracts/logMessageList.h
     85incDatacontracts.files += datacontracts/buildInfo.h           datacontracts/logInfo.h
     86incDatacontracts.files += datacontracts/configurationInfo.h
    8387
    8488INSTALLS += inc incServices incDatacontracts
    8589
  • mythtv/libs/libmythservicecontracts/services/mythServices.h

    diff --git a/mythtv/libs/libmythservicecontracts/services/mythServices.h b/mythtv/libs/libmythservicecontracts/services/mythServices.h
    index c2450ef..1d21dce 100644
    a b  
    2222#include "datacontracts/timeZoneInfo.h"
    2323#include "datacontracts/logMessage.h"
    2424#include "datacontracts/logMessageList.h"
     25#include "datacontracts/configurationInfo.h"
    2526
    2627/////////////////////////////////////////////////////////////////////////////
    2728/////////////////////////////////////////////////////////////////////////////
     
    4243class SERVICE_PUBLIC MythServices : public Service  //, public QScriptable ???
    4344{
    4445    Q_OBJECT
    45     Q_CLASSINFO( "version"    , "2.0" );
     46    Q_CLASSINFO( "version"    , "2.1" );
    4647    Q_CLASSINFO( "PutSetting_Method",            "POST" )
    4748    Q_CLASSINFO( "AddStorageGroupDir_Method",    "POST" )
    4849    Q_CLASSINFO( "RemoveStorageGroupDir_Method", "POST" )
    class SERVICE_PUBLIC MythServices : public Service //, public QScriptable ??? 
    6667            DTC::TimeZoneInfo       ::InitializeCustomTypes();
    6768            DTC::LogMessage         ::InitializeCustomTypes();
    6869            DTC::LogMessageList     ::InitializeCustomTypes();
     70            DTC::ConfigurationInfo  ::InitializeCustomTypes();
    6971        }
    7072
    7173    public slots:
    class SERVICE_PUBLIC MythServices : public Service //, public QScriptable ??? 
    138140        virtual QString             ProfileUpdated      ( void ) = 0;
    139141
    140142        virtual QString             ProfileText         ( void ) = 0;
     143
     144        virtual DTC::ConfigurationInfo* GetConfigurationInfo  ( void ) = 0;
    141145};
    142146
    143147#endif
  • mythtv/programs/mythbackend/services/myth.cpp

    diff --git a/mythtv/programs/mythbackend/services/myth.cpp b/mythtv/programs/mythbackend/services/myth.cpp
    index a0f449f..2175ee5 100644
    a b  
    2626#include "myth.h"
    2727
    2828#include <QDir>
     29#include <QFileInfo>
    2930#include <QCryptographicHash>
    3031#include <QHostAddress>
    3132#include <QUdpSocket>
    3233
     34#include "config.h"
    3335#include "version.h"
    3436#include "mythversion.h"
    3537#include "mythcorecontext.h"
    DTC::StorageGroupDirList *Myth::GetStorageGroupDirs( const QString &sGroupName, 
    249251    while (query.next())
    250252    {
    251253        DTC::StorageGroupDir *pStorageGroupDir = pList->AddNewStorageGroupDir();
     254        QFileInfo fi(query.value(3).toString());
    252255           
    253256        pStorageGroupDir->setId            ( query.value(0).toInt()       );
    254257        pStorageGroupDir->setGroupName     ( query.value(1).toString()    );
    255258        pStorageGroupDir->setHostName      ( query.value(2).toString()    );
    256259        pStorageGroupDir->setDirName       ( query.value(3).toString()    );
     260        pStorageGroupDir->setDirPerms    ( fi.isReadable() && fi.isWritable() );
    257261    }
    258262
    259263    return pList;
    QString Myth::ProfileText() 
    928932    return sProfileText;
    929933}
    930934
     935/////////////////////////////////////////////////////////////////////////////
     936//
     937/////////////////////////////////////////////////////////////////////////////
     938
     939DTC::ConfigurationInfo* Myth::GetConfigurationInfo( void )
     940{
     941
     942    // ----------------------------------------------------------------------
     943    // Create and populate a Configuration object
     944    // ----------------------------------------------------------------------
     945
     946    DTC::ConfigurationInfo *pInfo      = new DTC::ConfigurationInfo();
     947    DTC::BuildInfo         *pBuild     = pInfo->Build();
     948    DTC::LogInfo           *pLog       = pInfo->Log();
     949
     950    pBuild->setLibX264     ( CONFIG_LIBX264   );
     951    pBuild->setLibDNS_SD   ( CONFIG_LIBDNS_SD );
     952    pLog->setLogArgs       ( logPropagateArgs );
     953
     954    // ----------------------------------------------------------------------
     955    // Return the pointer... caller is responsible to delete it!!!
     956    // ----------------------------------------------------------------------
     957
     958    return pInfo;
     959
     960}
  • mythtv/programs/mythbackend/services/myth.h

    diff --git a/mythtv/programs/mythbackend/services/myth.h b/mythtv/programs/mythbackend/services/myth.h
    index f6b99a2..d112259 100644
    a b class Myth : public MythServices 
    109109        QString             ProfileUpdated      ( void );
    110110
    111111        QString             ProfileText         ( void );
     112
     113        DTC::ConfigurationInfo*   GetConfigurationInfo  ( void );
    112114};
    113115
    114116// --------------------------------------------------------------------------
    class ScriptableMyth : public QObject 
    255257        {
    256258            return m_obj.ProfileText();
    257259        }
     260
     261        QObject* GetConfigurationInfo  ( void )
     262        {
     263            return m_obj.GetConfigurationInfo();
     264        }
    258265};
    259266
    260267