Ticket #11386: services-api.v3.patch
File services-api.v3.patch, 18.1 KB (added by , 8 years ago) |
---|
-
new file mythtv/libs/libmythservicecontracts/datacontracts/backendInfo.h
diff --git a/mythtv/libs/libmythservicecontracts/datacontracts/backendInfo.h b/mythtv/libs/libmythservicecontracts/datacontracts/backendInfo.h new file mode 100644 index 0000000..8a65cd4
- + 1 ////////////////////////////////////////////////////////////////////////////// 2 // Program Name: backendInfo.h 3 // Created : Dec. 15, 2015 4 // 5 // Copyright (c) 2015 Bill Meek, from: 2010 David Blain <dblain@mythtv.org> 6 // 7 // Licensed under the GPL v2 or later, see COPYING for details 8 // 9 ////////////////////////////////////////////////////////////////////////////// 10 11 #ifndef BACKENDINFO_H_ 12 #define BACKENDINFO_H_ 13 14 #include "serviceexp.h" 15 #include "datacontracthelper.h" 16 17 #include "buildInfo.h" 18 #include "envInfo.h" 19 #include "logInfo.h" 20 21 namespace DTC 22 { 23 24 class SERVICE_PUBLIC BackendInfo : public QObject 25 { 26 Q_OBJECT 27 28 Q_CLASSINFO( "version" , "1.0" ); 29 30 Q_PROPERTY( QObject* Build READ Build ) 31 Q_PROPERTY( QObject* Env READ Env ) 32 Q_PROPERTY( QObject* Log READ Log ) 33 34 PROPERTYIMP_PTR( BuildInfo, Build ) 35 PROPERTYIMP_PTR( EnvInfo, Env ) 36 PROPERTYIMP_PTR( LogInfo, Log ) 37 38 public: 39 40 static inline void InitializeCustomTypes(); 41 42 public: 43 44 BackendInfo(QObject *parent = 0) 45 : QObject ( parent ), 46 m_Build ( NULL ), 47 m_Env ( NULL ), 48 m_Log ( NULL ) 49 { 50 } 51 52 BackendInfo( const BackendInfo &src ) 53 : m_Build ( NULL ), 54 m_Env ( NULL ), 55 m_Log ( NULL ) 56 { 57 Copy( src ); 58 } 59 60 void Copy( const BackendInfo &src ) 61 { 62 // We always need to make sure the child object is 63 // created with the correct parent * 64 65 if (src.m_Build) 66 Build()->Copy( src.m_Build ); 67 68 if (src.m_Env) 69 Env()->Copy( src.m_Env ); 70 71 if (src.m_Log) 72 Log()->Copy( src.m_Log ); 73 74 } 75 }; 76 77 typedef BackendInfo* BackendInfoPtr; 78 79 } // namespace DTC 80 81 Q_DECLARE_METATYPE( DTC::BackendInfo ) 82 Q_DECLARE_METATYPE( DTC::BackendInfo* ) 83 84 namespace DTC 85 { 86 inline void BackendInfo::InitializeCustomTypes() 87 { 88 qRegisterMetaType< BackendInfo >(); 89 qRegisterMetaType< BackendInfo* >(); 90 91 BuildInfo::InitializeCustomTypes(); 92 EnvInfo ::InitializeCustomTypes(); 93 LogInfo ::InitializeCustomTypes(); 94 } 95 } 96 97 #endif -
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..1bdbb29
- + 1 ////////////////////////////////////////////////////////////////////////////// 2 // Program Name: buildInfo.h 3 // Created : Dec. 15, 2015 4 // 5 // Copyright (c) 2015 Bill Meek, from: 2010 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 19 namespace DTC 20 { 21 22 class SERVICE_PUBLIC BuildInfo : public QObject 23 { 24 Q_OBJECT 25 26 Q_CLASSINFO( "version" , "1.0" ); 27 28 Q_PROPERTY( QString Version READ Version WRITE setVersion ) 29 Q_PROPERTY( bool LibX264 READ LibX264 WRITE setLibX264 ) 30 Q_PROPERTY( bool LibDNS_SD READ LibDNS_SD WRITE setLibDNS_SD ) 31 32 PROPERTYIMP( QString , Version ) 33 PROPERTYIMP( bool , LibX264 ) 34 PROPERTYIMP( bool , LibDNS_SD ) 35 36 public: 37 38 static inline void InitializeCustomTypes(); 39 40 public: 41 42 BuildInfo(QObject *parent = 0) 43 : QObject ( parent ), 44 m_Version ( "" ), 45 m_LibX264 ( false ), 46 m_LibDNS_SD( false ) 47 { 48 } 49 50 BuildInfo( const BuildInfo &src ) 51 { 52 Copy( src ); 53 } 54 55 void Copy( const BuildInfo &src ) 56 { 57 m_Version = src.m_Version ; 58 m_LibX264 = src.m_LibX264 ; 59 m_LibDNS_SD = src.m_LibDNS_SD; 60 } 61 }; 62 63 typedef BuildInfo* BuildInfoPtr; 64 65 } // namespace DTC 66 67 Q_DECLARE_METATYPE( DTC::BuildInfo ) 68 Q_DECLARE_METATYPE( DTC::BuildInfo* ) 69 70 namespace DTC 71 { 72 inline void BuildInfo::InitializeCustomTypes() 73 { 74 qRegisterMetaType< BuildInfo >(); 75 qRegisterMetaType< BuildInfo* >(); 76 } 77 } 78 79 #endif -
new file mythtv/libs/libmythservicecontracts/datacontracts/envInfo.h
diff --git a/mythtv/libs/libmythservicecontracts/datacontracts/envInfo.h b/mythtv/libs/libmythservicecontracts/datacontracts/envInfo.h new file mode 100644 index 0000000..804619c
- + 1 ////////////////////////////////////////////////////////////////////////////// 2 // Program Name: envInfo.h 3 // Created : Dec. 15, 2015 4 // 5 // Copyright (c) 2015 Bill Meek, from: 2010 David Blain <dblain@mythtv.org> 6 // 7 // Licensed under the GPL v2 or later, see COPYING for details 8 // 9 ////////////////////////////////////////////////////////////////////////////// 10 11 #ifndef ENVINFO_H_ 12 #define ENVINFO_H_ 13 14 #include <QString> 15 16 #include "serviceexp.h" 17 #include "datacontracthelper.h" 18 19 namespace DTC 20 { 21 22 class SERVICE_PUBLIC EnvInfo : public QObject 23 { 24 Q_OBJECT 25 26 Q_CLASSINFO( "version" , "1.0" ); 27 28 Q_PROPERTY( QString LANG READ LANG WRITE setLANG ) 29 Q_PROPERTY( QString LCALL READ LCALL WRITE setLCALL ) 30 Q_PROPERTY( QString LCCTYPE READ LCCTYPE WRITE setLCCTYPE ) 31 Q_PROPERTY( QString HOME READ HOME WRITE setHOME ) 32 Q_PROPERTY( QString MYTHCONFDIR READ MYTHCONFDIR WRITE setMYTHCONFDIR ) 33 34 PROPERTYIMP( QString, LANG ) 35 PROPERTYIMP( QString, LCALL ) 36 PROPERTYIMP( QString, LCCTYPE ) 37 PROPERTYIMP( QString, HOME ) 38 PROPERTYIMP( QString, MYTHCONFDIR ) 39 40 public: 41 42 static inline void InitializeCustomTypes(); 43 44 public: 45 46 EnvInfo(QObject *parent = 0) 47 : QObject ( parent ), 48 m_LANG ( "" ), 49 m_LCALL ( "" ), 50 m_LCCTYPE ( "" ), 51 m_HOME ( "" ), 52 m_MYTHCONFDIR ( "" ) 53 { 54 } 55 56 EnvInfo( const EnvInfo &src ) 57 { 58 Copy( src ); 59 } 60 61 void Copy( const EnvInfo &src ) 62 { 63 m_LANG = src.m_LANG; 64 m_LCALL = src.m_LCALL; 65 m_LCCTYPE = src.m_LCCTYPE; 66 m_HOME = src.m_HOME; 67 m_MYTHCONFDIR = src.m_MYTHCONFDIR; 68 } 69 }; 70 71 typedef EnvInfo* EnvInfoPtr; 72 73 } // namespace DTC 74 75 Q_DECLARE_METATYPE( DTC::EnvInfo ) 76 Q_DECLARE_METATYPE( DTC::EnvInfo* ) 77 78 namespace DTC 79 { 80 inline void EnvInfo::InitializeCustomTypes() 81 { 82 qRegisterMetaType< EnvInfo >(); 83 qRegisterMetaType< EnvInfo* >(); 84 } 85 } 86 87 #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..acf79e7
- + 1 ////////////////////////////////////////////////////////////////////////////// 2 // Program Name: logInfo.h 3 // Created : Dec. 15, 2015 4 // 5 // Copyright (c) 2015 Bill Meek, from: 2010 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 19 namespace DTC 20 { 21 22 class 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 inline void InitializeCustomTypes(); 36 37 public: 38 39 LogInfo(QObject *parent = 0) 40 : QObject ( parent ), 41 m_LogArgs ( "" ) 42 { 43 } 44 45 LogInfo( const LogInfo &src ) 46 { 47 Copy( src ); 48 } 49 50 void Copy( const LogInfo &src ) 51 { 52 m_LogArgs = src.m_LogArgs ; 53 } 54 }; 55 56 typedef LogInfo* LogInfoPtr; 57 58 } // namespace DTC 59 60 Q_DECLARE_METATYPE( DTC::LogInfo ) 61 Q_DECLARE_METATYPE( DTC::LogInfo* ) 62 63 namespace DTC 64 { 65 inline void LogInfo::InitializeCustomTypes() 66 { 67 qRegisterMetaType< LogInfo >(); 68 qRegisterMetaType< LogInfo* >(); 69 } 70 } 71 72 #endif -
mythtv/libs/libmythservicecontracts/datacontracts/storageGroupDir.h
diff --git a/mythtv/libs/libmythservicecontracts/datacontracts/storageGroupDir.h b/mythtv/libs/libmythservicecontracts/datacontracts/storageGroupDir.h index 8c38b1f..e917aeb 100644
a b namespace DTC 14 14 class SERVICE_PUBLIC StorageGroupDir : public QObject 15 15 { 16 16 Q_OBJECT 17 Q_CLASSINFO( "version" , "1. 0" );17 Q_CLASSINFO( "version" , "1.1" ); 18 18 19 19 Q_PROPERTY( int Id READ Id WRITE setId ) 20 20 Q_PROPERTY( QString GroupName READ GroupName WRITE setGroupName ) 21 21 Q_PROPERTY( QString HostName READ HostName WRITE setHostName ) 22 22 Q_PROPERTY( QString DirName READ DirName WRITE setDirName ) 23 Q_PROPERTY( bool DirRead READ DirRead WRITE setDirRead ) 24 Q_PROPERTY( bool DirWrite READ DirWrite WRITE setDirWrite ) 25 Q_PROPERTY( uint KiBFree READ KiBFree WRITE setKiBFree ) 23 26 24 27 PROPERTYIMP ( int , Id ) 25 28 PROPERTYIMP ( QString , GroupName ) 26 29 PROPERTYIMP ( QString , HostName ) 27 30 PROPERTYIMP ( QString , DirName ) 31 PROPERTYIMP ( bool , DirRead ) 32 PROPERTYIMP ( bool , DirWrite ) 33 PROPERTYIMP ( uint , KiBFree ) 28 34 29 35 public: 30 36 … … class SERVICE_PUBLIC StorageGroupDir : public QObject 49 55 m_GroupName = src.m_GroupName ; 50 56 m_HostName = src.m_HostName ; 51 57 m_DirName = src.m_DirName ; 58 m_DirRead = src.m_DirRead ; 59 m_DirWrite = src.m_DirWrite ; 60 m_KiBFree = src.m_KiBFree ; 52 61 } 53 62 }; 54 63 -
mythtv/libs/libmythservicecontracts/libmythservicecontracts.pro
diff --git a/mythtv/libs/libmythservicecontracts/libmythservicecontracts.pro b/mythtv/libs/libmythservicecontracts/libmythservicecontracts.pro index a5bcb3d..97cb08c 100644
a b HEADERS += datacontracts/recRuleFilter.h datacontracts/recRuleFilterList 58 58 HEADERS += datacontracts/castMember.h datacontracts/castMemberList.h 59 59 HEADERS += datacontracts/frontend.h datacontracts/frontendList.h 60 60 HEADERS += datacontracts/cutting.h datacontracts/cutList.h 61 HEADERS += datacontracts/backendInfo.h datacontracts/envInfo.h 62 HEADERS += datacontracts/buildInfo.h datacontracts/logInfo.h 61 63 62 64 SOURCES += service.cpp 63 65 … … incDatacontracts.files += datacontracts/recRuleFilter.h datacontracts/recR 111 113 incDatacontracts.files += datacontracts/castMember.h datacontracts/castMemberList.h 112 114 incDatacontracts.files += datacontracts/enum.h datacontracts/enumItem.h 113 115 incDatacontracts.files += datacontracts/cutting.h datacontracts/cutList.h 116 incDatacontracts.files += datacontracts/backendInfo.h datacontracts/envInfo.h 117 incDatacontracts.files += datacontracts/buildInfo.h datacontracts/logInfo.h 114 118 115 119 INSTALLS += inc incServices incDatacontracts 116 120 -
mythtv/libs/libmythservicecontracts/services/mythServices.h
diff --git a/mythtv/libs/libmythservicecontracts/services/mythServices.h b/mythtv/libs/libmythservicecontracts/services/mythServices.h index f47bef7..3bd7495 100644
a b 23 23 #include "datacontracts/logMessage.h" 24 24 #include "datacontracts/logMessageList.h" 25 25 #include <datacontracts/frontendList.h> 26 #include "datacontracts/backendInfo.h" 26 27 27 28 ///////////////////////////////////////////////////////////////////////////// 28 29 ///////////////////////////////////////////////////////////////////////////// … … class SERVICE_PUBLIC MythServices : public Service //, public QScriptable ??? 70 71 DTC::LogMessage ::InitializeCustomTypes(); 71 72 DTC::LogMessageList ::InitializeCustomTypes(); 72 73 DTC::FrontendList ::InitializeCustomTypes(); 74 DTC::BackendInfo ::InitializeCustomTypes(); 73 75 } 74 76 75 77 public slots: … … class SERVICE_PUBLIC MythServices : public Service //, public QScriptable ??? 169 171 virtual QString ProfileUpdated ( void ) = 0; 170 172 171 173 virtual QString ProfileText ( void ) = 0; 174 175 virtual DTC::BackendInfo* GetBackendInfo ( void ) = 0; 172 176 }; 173 177 174 178 #endif -
mythtv/programs/mythbackend/services/myth.cpp
diff --git a/mythtv/programs/mythbackend/services/myth.cpp b/mythtv/programs/mythbackend/services/myth.cpp index 459f8fb..8ba2637 100644
a b 27 27 #include <backendcontext.h> 28 28 29 29 #include <QDir> 30 #include <QFileInfo> 30 31 #include <QCryptographicHash> 31 32 #include <QHostAddress> 32 33 #include <QUdpSocket> 33 34 35 #include "config.h" 34 36 #include "version.h" 35 37 #include "mythversion.h" 36 38 #include "mythcorecontext.h" 39 #include "mythcoreutil.h" 37 40 #include "mythdbcon.h" 38 41 #include "mythlogging.h" 39 42 #include "storagegroup.h" … … 41 44 #include "hardwareprofile.h" 42 45 #include "mythtimezone.h" 43 46 #include "mythdate.h" 47 #include "mythversion.h" 44 48 45 49 ///////////////////////////////////////////////////////////////////////////// 46 50 // … … DTC::StorageGroupDirList *Myth::GetStorageGroupDirs( const QString &sGroupName, 242 246 } 243 247 244 248 // ---------------------------------------------------------------------- 245 // return the results of the query 249 // return the results of the query plus R/W and size information 246 250 // ---------------------------------------------------------------------- 247 251 248 252 DTC::StorageGroupDirList* pList = new DTC::StorageGroupDirList(); … … DTC::StorageGroupDirList *Myth::GetStorageGroupDirs( const QString &sGroupName, 250 254 while (query.next()) 251 255 { 252 256 DTC::StorageGroupDir *pStorageGroupDir = pList->AddNewStorageGroupDir(); 257 QFileInfo fi(query.value(3).toString()); 258 int64_t free, total, used; 259 260 free = getDiskSpace(query.value(3).toString(), total, used); 253 261 254 262 pStorageGroupDir->setId ( query.value(0).toInt() ); 255 263 pStorageGroupDir->setGroupName ( query.value(1).toString() ); 256 264 pStorageGroupDir->setHostName ( query.value(2).toString() ); 257 265 pStorageGroupDir->setDirName ( query.value(3).toString() ); 266 pStorageGroupDir->setDirRead ( fi.isReadable() ); 267 pStorageGroupDir->setDirWrite ( fi.isWritable() ); 268 pStorageGroupDir->setKiBFree ( free ); 258 269 } 259 270 260 271 return pList; … … QString Myth::ProfileText() 1023 1034 return sProfileText; 1024 1035 } 1025 1036 1037 ///////////////////////////////////////////////////////////////////////////// 1038 // 1039 ///////////////////////////////////////////////////////////////////////////// 1040 1041 DTC::BackendInfo* Myth::GetBackendInfo( void ) 1042 { 1043 1044 // ---------------------------------------------------------------------- 1045 // Create and populate a Configuration object 1046 // ---------------------------------------------------------------------- 1047 1048 DTC::BackendInfo *pInfo = new DTC::BackendInfo(); 1049 DTC::BuildInfo *pBuild = pInfo->Build(); 1050 DTC::EnvInfo *pEnv = pInfo->Env(); 1051 DTC::LogInfo *pLog = pInfo->Log(); 1052 1053 pBuild->setVersion ( MYTH_SOURCE_VERSION ); 1054 pBuild->setLibX264 ( CONFIG_LIBX264 ); 1055 pBuild->setLibDNS_SD ( CONFIG_LIBDNS_SD ); 1056 pEnv->setLANG ( getenv("LANG") ); 1057 pEnv->setLCALL ( getenv("LC_ALL") ); 1058 pEnv->setLCCTYPE ( getenv("LC_CTYPE") ); 1059 pEnv->setHOME ( getenv("HOME") ); 1060 pEnv->setMYTHCONFDIR ( getenv("MYTHCONFDIR") ); 1061 pLog->setLogArgs ( logPropagateArgs ); 1062 1063 // ---------------------------------------------------------------------- 1064 // Return the pointer... caller is responsible to delete it!!! 1065 // ---------------------------------------------------------------------- 1066 1067 return pInfo; 1068 1069 } -
mythtv/programs/mythbackend/services/myth.h
diff --git a/mythtv/programs/mythbackend/services/myth.h b/mythtv/programs/mythbackend/services/myth.h index 7bc0f5e..45f5ffc 100644
a b class Myth : public MythServices 138 138 QString ProfileUpdated ( void ); 139 139 140 140 QString ProfileText ( void ); 141 142 DTC::BackendInfo* GetBackendInfo ( void ); 141 143 }; 142 144 143 145 // -------------------------------------------------------------------------- … … class ScriptableMyth : public QObject 386 388 return m_obj.ProfileText(); 387 389 ) 388 390 } 391 392 QObject* GetBackendInfo( void ) 393 { 394 SCRIPT_CATCH_EXCEPTION( NULL, 395 return m_obj.GetBackendInfo(); 396 ) 397 } 389 398 }; 390 399 391 400 Q_SCRIPT_DECLARE_QMETAOBJECT_MYTHTV( ScriptableMyth, QObject*);