Skip to content
Browse files

Framework API - Initial commit (Breaks MythXML support!)

This commit adds the base code needed for the new API Framework support.

I don't know all locations that use the MythXML methods, so please let me
know if this breaks any code.

I will be updating the wiki to have details of these changes.

The following services replaced existing MythXML methods
( NOTE: response data format has changed for most methods )

Base URL - http://mythbackend:6544/Myth/

  Methods -

     GetConnectionInfo
     GetHosts
     GetKeys
     GetSetting
     PutSetting

    *GetInternetSearch
    *GetInternetSources
    *GetInternetContent

  * These methods are still implemented in MythXml using legacy approach.

Base URL - http://mythbackend:6544/Guide/

  Methods -

     GetProgramGuide
     GetProgramDetails
     GetChannelIcon

Base URL - http://mythbackend:6544/Dvr/

  Methods -

     GetExpiring
     GetRecorded
     Encoders

Base URL - http://mythbackend:6544/Content/

  Methods -

     GetFile
     GetFileList
     GetVideoArt
     GetAlbumArt
     GetPreviewImage
     GetRecording
     GetMusic
     GetVideo
  • Loading branch information...
1 parent ae3dccf commit 856b61b5378c4b6d8bd60638f86606e7603654ef @dblain dblain committed Mar 8, 2011
Showing with 6,354 additions and 1,854 deletions.
  1. +1 −0 mythplugins/programs-libs.pro
  2. +1 −0 mythtv/libs/libmythbase/compat.h
  3. +159 −0 mythtv/libs/libmythservicecontracts/datacontracthelper.h
  4. +80 −0 mythtv/libs/libmythservicecontracts/datacontracts/connectionInfo.h
  5. +95 −0 mythtv/libs/libmythservicecontracts/datacontracts/databaseInfo.h
  6. +102 −0 mythtv/libs/libmythservicecontracts/datacontracts/encoder.h
  7. +78 −0 mythtv/libs/libmythservicecontracts/datacontracts/encoderList.h
  8. +219 −0 mythtv/libs/libmythservicecontracts/datacontracts/programAndChannel.h
  9. +135 −0 mythtv/libs/libmythservicecontracts/datacontracts/programGuide.h
  10. +104 −0 mythtv/libs/libmythservicecontracts/datacontracts/programList.h
  11. +122 −0 mythtv/libs/libmythservicecontracts/datacontracts/recording.h
  12. +63 −0 mythtv/libs/libmythservicecontracts/datacontracts/settingList.h
  13. +59 −0 mythtv/libs/libmythservicecontracts/datacontracts/stringList.h
  14. +59 −0 mythtv/libs/libmythservicecontracts/datacontracts/successFail.h
  15. +80 −0 mythtv/libs/libmythservicecontracts/datacontracts/wolInfo.h
  16. +65 −0 mythtv/libs/libmythservicecontracts/libmythservicecontracts.pro
  17. +97 −0 mythtv/libs/libmythservicecontracts/service.cpp
  18. +79 −0 mythtv/libs/libmythservicecontracts/service.h
  19. +22 −0 mythtv/libs/libmythservicecontracts/serviceexp.h
  20. +77 −0 mythtv/libs/libmythservicecontracts/services/contentServices.h
  21. +66 −0 mythtv/libs/libmythservicecontracts/services/dvrServices.h
  22. +70 −0 mythtv/libs/libmythservicecontracts/services/guideServices.h
  23. +73 −0 mythtv/libs/libmythservicecontracts/services/mythServices.h
  24. +2 −0 mythtv/libs/libmythtv/libmythtv.pro
  25. +127 −74 mythtv/libs/libmythupnp/httprequest.cpp
  26. +8 −6 mythtv/libs/libmythupnp/httprequest.h
  27. +15 −1 mythtv/libs/libmythupnp/libmythupnp.pro
  28. +239 −0 mythtv/libs/libmythupnp/serializers/jsonSerializer.cpp
  29. +73 −0 mythtv/libs/libmythupnp/serializers/jsonSerializer.h
  30. +123 −0 mythtv/libs/libmythupnp/serializers/serializer.cpp
  31. +79 −0 mythtv/libs/libmythupnp/serializers/serializer.h
  32. +87 −0 mythtv/libs/libmythupnp/serializers/soapSerializer.h
  33. +246 −0 mythtv/libs/libmythupnp/serializers/xmlSerializer.cpp
  34. +79 −0 mythtv/libs/libmythupnp/serializers/xmlSerializer.h
  35. +343 −0 mythtv/libs/libmythupnp/servicehost.cpp
  36. +103 −0 mythtv/libs/libmythupnp/servicehost.h
  37. +3 −2 mythtv/libs/libmythupnp/ssdp.cpp
  38. +456 −0 mythtv/libs/libmythupnp/wsdl.cpp
  39. +84 −0 mythtv/libs/libmythupnp/wsdl.h
  40. +2 −0 mythtv/libs/libs.pro
  41. +5 −2 mythtv/programs/mythbackend/httpstatus.cpp
  42. +10 −0 mythtv/programs/mythbackend/mediaserver.cpp
  43. +10 −0 mythtv/programs/mythbackend/mythbackend.pro
  44. +65 −1,694 mythtv/programs/mythbackend/mythxml.cpp
  45. +0 −58 mythtv/programs/mythbackend/mythxml.h
  46. +55 −0 mythtv/programs/mythbackend/serviceHosts/contentServiceHost.h
  47. +55 −0 mythtv/programs/mythbackend/serviceHosts/dvrServiceHost.h
  48. +55 −0 mythtv/programs/mythbackend/serviceHosts/guideServiceHost.h
  49. +55 −0 mythtv/programs/mythbackend/serviceHosts/mythServiceHost.h
  50. +544 −0 mythtv/programs/mythbackend/services/content.cpp
  51. +62 −0 mythtv/programs/mythbackend/services/content.h
  52. +498 −0 mythtv/programs/mythbackend/services/dvr.cpp
  53. +47 −0 mythtv/programs/mythbackend/services/dvr.h
  54. +308 −0 mythtv/programs/mythbackend/services/guide.cpp
  55. +57 −0 mythtv/programs/mythbackend/services/guide.h
  56. +293 −0 mythtv/programs/mythbackend/services/myth.cpp
  57. +52 −0 mythtv/programs/mythbackend/services/myth.h
  58. +138 −0 mythtv/programs/mythbackend/services/serviceUtil.cpp
  59. +37 −0 mythtv/programs/mythbackend/services/serviceUtil.h
  60. +10 −6 mythtv/programs/mythfrontend/mediarenderer.cpp
  61. +18 −11 mythtv/programs/mythfrontend/mythfexml.cpp
  62. +5 −0 mythtv/programs/programs-libs.pro
View
1 mythplugins/programs-libs.pro
@@ -6,6 +6,7 @@ DEPENDPATH *= $${INCLUDEPATH}
LIBS += -L$${LIBDIR} $$EXTRA_LIBS -lmythbase-$$LIBVERSION
LIBS += -lmyth-$$LIBVERSION -lmythui-$$LIBVERSION -lmythupnp-$$LIBVERSION
+LIBS += -lmythservicecontracts-$$LIBVERSION
LIBS += -lmythavcodec
LIBS += -lmythavcore
LIBS += -lmythavutil
View
1 mythtv/libs/libmythbase/compat.h
@@ -25,6 +25,7 @@
# undef CreateFont
# undef DeleteFile
# undef GetCurrentTime
+# undef SetJob
#ifndef _MSC_VER
# include <winsock2.h>
View
159 mythtv/libs/libmythservicecontracts/datacontracthelper.h
@@ -0,0 +1,159 @@
+//////////////////////////////////////////////////////////////////////////////
+// Program Name: datacontracthelper.h
+// Created : Jan. 15, 2010
+//
+// Copyright (c) 2010 David Blain <dblain@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/>.
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+// * Copy Constructors (needed for Q_PROPERTY) don't do Deep Copies yet.
+// * DECLARE_METATYPE not working if this header is not included... need
+// to find solution since Serializer classes doesn't include this header.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef DATACONTRACTHELPER_H_
+#define DATACONTRACTHELPER_H_
+
+#include <QList>
+#include <QStringList>
+#include <QVariantMap>
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#define PROPERTYIMP( type, name ) \
+ private: type m_##name; \
+ public: \
+ type name() const \
+ { \
+ return m_##name; \
+ } \
+ void set##name(const type val) \
+ { \
+ m_##name = val; \
+ }
+
+//////////////////////////////////////////////////////////////////////////////
+
+#define PROPERTYIMP_ENUM( type, name ) \
+ private: type m_##name; \
+ public: \
+ type name() const \
+ { \
+ return m_##name; \
+ } \
+ void set##name(const type val) \
+ { \
+ m_##name = val; \
+ } \
+ void set##name( int val) \
+ { \
+ m_##name = (type)val; \
+ }
+
+//////////////////////////////////////////////////////////////////////////////
+
+#define PROPERTYIMP_PTR( type, name ) \
+ private: type* m_##name; \
+ public: \
+ type* name() \
+ { \
+ if (m_##name == NULL) \
+ m_##name = new type( this );\
+ return m_##name; \
+ }
+
+//////////////////////////////////////////////////////////////////////////////
+
+#define PROPERTYIMP_PTR_Old( type, name ) \
+ private: type* m_##name; \
+ public: \
+ type* name() \
+ { \
+ return m_##name; \
+ } \
+ void set##name( QObject* val) \
+ { \
+ m_##name = qobject_cast< type* >( val ); \
+ } \
+ void set##name( type* val) \
+ { \
+ m_##name = val; \
+ }
+
+//////////////////////////////////////////////////////////////////////////////
+
+#define PROPERTYIMP_RO_REF( type, name ) \
+ private: type m_##name; \
+ public: \
+ type &name() \
+ { \
+ return m_##name; \
+ }
+
+
+namespace DTC
+{
+
+/////////////////////////////////////////////////////////////////////////////
+//
+/////////////////////////////////////////////////////////////////////////////
+
+inline void DeleteListContents( QVariantList &list )
+{
+ while( !list.isEmpty() )
+ {
+ QVariant vValue = list.takeFirst();
+
+ const QObject *pObject = vValue.value< QObject* >();
+
+ if (pObject != NULL)
+ delete pObject;
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+
+template< class T >
+void CopyListContents( QObject *pParent, QVariantList &dst, const QVariantList &src )
+{
+ for( int nIdx = 0; nIdx < src.size(); nIdx++ )
+ {
+ QVariant vValue = src[ nIdx ];
+
+ if ( vValue.canConvert< QObject* >())
+ {
+ const QObject *pObject = vValue.value< QObject* >();
+
+ if (pObject != NULL)
+ {
+ QObject *pNew = new T( pParent );
+
+ ((T *)pNew)->Copy( (const T &)(*pObject) );
+
+ dst.append( QVariant::fromValue<QObject *>( pNew ));
+ }
+ }
+ }
+}
+
+} // namespace DTC
+
+#endif
+
+
View
80 mythtv/libs/libmythservicecontracts/datacontracts/connectionInfo.h
@@ -0,0 +1,80 @@
+//////////////////////////////////////////////////////////////////////////////
+// Program Name: connectionInfo.h
+// Created : Jan. 15, 2010
+//
+// Copyright (c) 2010 David Blain <dblain@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 CONNECTIONINFO_H_
+#define CONNECTIONINFO_H_
+
+#include "serviceexp.h"
+#include "datacontracthelper.h"
+
+#include "databaseInfo.h"
+#include "wolInfo.h"
+
+namespace DTC
+{
+
+class SERVICE_PUBLIC ConnectionInfo : public QObject
+{
+ Q_OBJECT
+ Q_CLASSINFO( "version" , "1.0" );
+
+ Q_PROPERTY( QObject* Database READ Database )
+ Q_PROPERTY( QObject* WOL READ WOL )
+
+ PROPERTYIMP_PTR( DatabaseInfo, Database )
+ PROPERTYIMP_PTR( WOLInfo , WOL )
+
+ public:
+
+ ConnectionInfo(QObject *parent = 0)
+ : QObject ( parent ),
+ m_Database ( NULL ),
+ m_WOL ( NULL )
+ {
+ }
+
+ ConnectionInfo( const ConnectionInfo &src )
+ : m_Database ( NULL ),
+ m_WOL ( NULL )
+ {
+ Copy( src );
+ }
+
+ void Copy( const ConnectionInfo &src )
+ {
+ // We always need to make sure the child object is
+ // created with the correct parent *
+
+ if (src.m_Database)
+ Database()->Copy( src.m_Database );
+
+ if (src.m_WOL)
+ WOL ()->Copy( src.m_WOL );
+ }
+};
+
+typedef ConnectionInfo* ConnectionInfoPtr;
+
+} // namespace DTC
+
+Q_DECLARE_METATYPE( DTC::ConnectionInfo )
+
+#endif
View
95 mythtv/libs/libmythservicecontracts/datacontracts/databaseInfo.h
@@ -0,0 +1,95 @@
+//////////////////////////////////////////////////////////////////////////////
+// Program Name: databaseInfo.h
+// Created : Jan. 15, 2010
+//
+// Copyright (c) 2010 David Blain <dblain@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 DATABASEINFO_H_
+#define DATABASEINFO_H_
+
+#include <QString>
+
+#include "serviceexp.h"
+#include "datacontracthelper.h"
+
+namespace DTC
+{
+
+class SERVICE_PUBLIC DatabaseInfo : public QObject
+{
+ Q_OBJECT
+ Q_CLASSINFO( "version", "1.0" );
+
+ Q_PROPERTY( QString Host READ Host WRITE setHost )
+ Q_PROPERTY( bool Ping READ Ping WRITE setPing )
+ Q_PROPERTY( int Port READ Port WRITE setPort )
+ Q_PROPERTY( QString UserName READ UserName WRITE setUserName )
+ Q_PROPERTY( QString Password READ Password WRITE setPassword )
+ Q_PROPERTY( QString Name READ Name WRITE setName )
+ Q_PROPERTY( QString Type READ Type WRITE setType )
+ Q_PROPERTY( bool LocalEnabled READ LocalEnabled WRITE setLocalEnabled )
+ Q_PROPERTY( QString LocalHostName READ LocalHostName WRITE setLocalHostName )
+
+ PROPERTYIMP( QString, Host )
+ PROPERTYIMP( bool , Ping )
+ PROPERTYIMP( int , Port )
+ PROPERTYIMP( QString, UserName )
+ PROPERTYIMP( QString, Password )
+ PROPERTYIMP( QString, Name )
+ PROPERTYIMP( QString, Type )
+ PROPERTYIMP( bool , LocalEnabled )
+ PROPERTYIMP( QString, LocalHostName )
+
+ public:
+
+ DatabaseInfo(QObject *parent = 0)
+ : QObject ( parent ),
+ m_Ping ( false ),
+ m_Port ( 0 ),
+ m_LocalEnabled( false )
+ {
+ }
+
+ DatabaseInfo( const DatabaseInfo &src )
+ {
+ Copy( src );
+ }
+
+ void Copy( const DatabaseInfo &src )
+ {
+ m_Host = src.m_Host ;
+ m_Ping = src.m_Ping ;
+ m_Port = src.m_Port ;
+ m_UserName = src.m_UserName ;
+ m_Password = src.m_Password ;
+ m_Name = src.m_Name ;
+ m_Type = src.m_Type ;
+ m_LocalEnabled = src.m_LocalEnabled ;
+ m_LocalHostName= src.m_LocalHostName;
+ }
+
+};
+
+typedef DatabaseInfo * DatabaseInfoPtr;
+
+} // namespace DTC
+
+Q_DECLARE_METATYPE( DTC::DatabaseInfo )
+
+
+#endif
View
102 mythtv/libs/libmythservicecontracts/datacontracts/encoder.h
@@ -0,0 +1,102 @@
+//////////////////////////////////////////////////////////////////////////////
+// Program Name: encoder.h
+// Created : Jan. 15, 2010
+//
+// Copyright (c) 2010 David Blain <dblain@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 ENCODER_H_
+#define ENCODER_H_
+
+#include <QString>
+
+#include "serviceexp.h"
+#include "datacontracthelper.h"
+
+#include "programAndChannel.h"
+
+namespace DTC
+{
+
+/////////////////////////////////////////////////////////////////////////////
+
+class SERVICE_PUBLIC Encoder : public QObject
+{
+ Q_OBJECT
+ Q_CLASSINFO( "version" , "1.0" );
+
+ Q_PROPERTY( int Id READ Id WRITE setId )
+ Q_PROPERTY( QString HostName READ HostName WRITE setHostName )
+ Q_PROPERTY( bool Local READ Local WRITE setLocal )
+ Q_PROPERTY( bool Connected READ Connected WRITE setConnected )
+ Q_PROPERTY( int State READ State WRITE setState )
+ Q_PROPERTY( int SleepStatus READ SleepStatus WRITE setSleepStatus )
+ Q_PROPERTY( bool LowOnFreeSpace READ LowOnFreeSpace WRITE setLowOnFreeSpace )
+
+ Q_PROPERTY( QObject* Recording READ Recording )
+
+ PROPERTYIMP ( int , Id )
+ PROPERTYIMP ( QString , HostName )
+ PROPERTYIMP ( bool , Local )
+ PROPERTYIMP ( bool , Connected )
+ PROPERTYIMP ( int , State )
+ PROPERTYIMP ( int , SleepStatus )
+ PROPERTYIMP ( bool , LowOnFreeSpace )
+
+ PROPERTYIMP_PTR( Program , Recording )
+
+ public:
+
+ Encoder(QObject *parent = 0)
+ : QObject ( parent ),
+ m_Id ( 0 ),
+ m_Local ( true ),
+ m_Connected ( false ),
+ m_State ( 0 ),
+ m_SleepStatus ( 0 ),
+ m_LowOnFreeSpace( false ),
+ m_Recording ( NULL )
+ {
+ }
+
+ Encoder( const Encoder &src )
+ {
+ Copy( src );
+ }
+
+ void Copy( const Encoder &src )
+ {
+ m_Id = src.m_Id ;
+ m_HostName = src.m_HostName ;
+ m_Local = src.m_Local ;
+ m_Connected = src.m_Connected ;
+ m_State = src.m_State ;
+ m_SleepStatus = src.m_SleepStatus ;
+ m_LowOnFreeSpace= src.m_LowOnFreeSpace;
+ m_Recording = NULL ;
+
+ if ( src.m_Recording != NULL)
+ Recording()->Copy( *(src.m_Recording) );
+
+ }
+};
+
+} // namespace DTC
+
+Q_DECLARE_METATYPE( DTC::Encoder )
+
+#endif
View
78 mythtv/libs/libmythservicecontracts/datacontracts/encoderList.h
@@ -0,0 +1,78 @@
+//////////////////////////////////////////////////////////////////////////////
+// Program Name: encoderList.h
+// Created : Jan. 15, 2010
+//
+// Copyright (c) 2010 David Blain <dblain@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 ENCODERLIST_H_
+#define ENCODERLIST_H_
+
+#include <QVariantList>
+
+#include "serviceexp.h"
+#include "datacontracthelper.h"
+
+#include "encoder.h"
+
+namespace DTC
+{
+
+class SERVICE_PUBLIC EncoderList : public QObject
+{
+ Q_OBJECT
+ Q_CLASSINFO( "version", "1.0" );
+
+ Q_PROPERTY( QVariantList Encoders READ Encoders DESIGNABLE true )
+
+ PROPERTYIMP_RO_REF( QVariantList, Encoders )
+
+ public:
+
+ EncoderList(QObject *parent = 0)
+ : QObject( parent )
+ {
+ }
+
+ EncoderList( const EncoderList &src )
+ {
+ Copy( src );
+ }
+
+ void Copy( const EncoderList &src )
+ {
+ CopyListContents< Encoder >( this, m_Encoders, src.m_Encoders );
+ }
+
+ Encoder *AddNewEncoder()
+ {
+ // We must make sure the object added to the QVariantList has
+ // a parent of 'this'
+
+ Encoder *pObject = new Encoder( this );
+ m_Encoders.append( QVariant::fromValue<QObject *>( pObject ));
+
+ return pObject;
+ }
+
+};
+
+} // namespace DTC
+
+Q_DECLARE_METATYPE( DTC::EncoderList )
+
+#endif
View
219 mythtv/libs/libmythservicecontracts/datacontracts/programAndChannel.h
@@ -0,0 +1,219 @@
+//////////////////////////////////////////////////////////////////////////////
+// Program Name: program.h
+// Created : Jan. 15, 2010
+//
+// Copyright (c) 2010 David Blain <dblain@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 PROGRAM_H_
+#define PROGRAM_H_
+
+#include <QDateTime>
+#include <QString>
+
+#include "serviceexp.h"
+#include "datacontracthelper.h"
+
+#include "recording.h"
+
+namespace DTC
+{
+
+class Program;
+
+
+class SERVICE_PUBLIC ChannelInfo : public QObject
+{
+ Q_OBJECT
+ Q_CLASSINFO( "version", "1.0" );
+
+ Q_PROPERTY( uint ChanId READ ChanId WRITE setChanId )
+ Q_PROPERTY( QString ChanNum READ ChanNum WRITE setChanNum )
+ Q_PROPERTY( QString CallSign READ CallSign WRITE setCallSign )
+ Q_PROPERTY( QString IconURL READ IconURL WRITE setIconURL )
+ Q_PROPERTY( QString ChannelName READ ChannelName WRITE setChannelName )
+
+ Q_PROPERTY( QString ChanFilters READ ChanFilters WRITE setChanFilters DESIGNABLE SerializeDetails )
+ Q_PROPERTY( int SourceId READ SourceId WRITE setSourceId DESIGNABLE SerializeDetails )
+ Q_PROPERTY( int InputId READ InputId WRITE setInputId DESIGNABLE SerializeDetails )
+ Q_PROPERTY( int CommFree READ CommFree WRITE setCommFree DESIGNABLE SerializeDetails )
+
+ Q_PROPERTY( QVariantList Programs READ Programs DESIGNABLE true )
+
+ PROPERTYIMP ( uint , ChanId )
+ PROPERTYIMP ( QString , ChanNum )
+ PROPERTYIMP ( QString , CallSign )
+ PROPERTYIMP ( QString , IconURL )
+ PROPERTYIMP ( QString , ChannelName )
+ PROPERTYIMP ( QString , ChanFilters )
+ PROPERTYIMP ( int , SourceId )
+ PROPERTYIMP ( int , InputId )
+ PROPERTYIMP ( int , CommFree )
+
+ PROPERTYIMP_RO_REF( QVariantList, Programs )
+
+ // Used only by Serializer
+ PROPERTYIMP( bool, SerializeDetails )
+
+ public:
+
+ ChannelInfo(QObject *parent = 0)
+ : QObject ( parent ),
+ m_SourceId( 0 ),
+ m_InputId ( 0 ),
+ m_CommFree( 0 )
+ {
+ }
+
+ ChannelInfo( const ChannelInfo &src )
+ {
+ Copy( src );
+ }
+
+ void Copy( const ChannelInfo &src )
+ {
+ m_ChanId = src.m_ChanId ;
+ m_ChanNum = src.m_ChanNum ;
+ m_CallSign = src.m_CallSign ;
+ m_IconURL = src.m_IconURL ;
+ m_ChannelName = src.m_ChannelName ;
+ m_ChanFilters = src.m_ChanFilters ;
+ m_SourceId = src.m_SourceId ;
+ m_InputId = src.m_InputId ;
+ m_CommFree = src.m_CommFree ;
+
+ CopyListContents< Program >( this, m_Programs, src.m_Programs );
+ }
+
+ Program *AddNewProgram();
+
+};
+
+class SERVICE_PUBLIC Program : public QObject
+{
+ Q_OBJECT
+ Q_CLASSINFO( "version" , "1.0" );
+ Q_CLASSINFO( "defaultProp", "Description" );
+
+ Q_PROPERTY( QDateTime StartTime READ StartTime WRITE setStartTime )
+ Q_PROPERTY( QDateTime EndTime READ EndTime WRITE setEndTime )
+ Q_PROPERTY( QString Title READ Title WRITE setTitle )
+ Q_PROPERTY( QString SubTitle READ SubTitle WRITE setSubTitle )
+ Q_PROPERTY( QString Category READ Category WRITE setCategory )
+ Q_PROPERTY( QString CatType READ CatType WRITE setCatType )
+ Q_PROPERTY( bool Repeat READ Repeat WRITE setRepeat )
+
+ Q_PROPERTY( QString SeriesId READ SeriesId WRITE setSeriesId DESIGNABLE SerializeDetails )
+ Q_PROPERTY( QString ProgramId READ ProgramId WRITE setProgramId DESIGNABLE SerializeDetails )
+ Q_PROPERTY( double Stars READ Stars WRITE setStars DESIGNABLE SerializeDetails )
+ Q_PROPERTY( qlonglong FileSize READ FileSize WRITE setFileSize DESIGNABLE SerializeDetails )
+ Q_PROPERTY( QDateTime LastModified READ LastModified WRITE setLastModified DESIGNABLE SerializeDetails )
+ Q_PROPERTY( int ProgramFlags READ ProgramFlags WRITE setProgramFlags DESIGNABLE SerializeDetails )
+ Q_PROPERTY( QString Hostname READ Hostname WRITE setHostname DESIGNABLE SerializeDetails )
+ Q_PROPERTY( QDate Airdate READ Airdate WRITE setAirdate DESIGNABLE SerializeDetails )
+ Q_PROPERTY( QString Description READ Description WRITE setDescription DESIGNABLE SerializeDetails )
+
+ Q_PROPERTY( QObject* Channel READ Channel )
+ Q_PROPERTY( QObject* Recording READ Recording )
+
+ PROPERTYIMP ( QDateTime , StartTime )
+ PROPERTYIMP ( QDateTime , EndTime )
+ PROPERTYIMP ( QString , Title )
+ PROPERTYIMP ( QString , SubTitle )
+ PROPERTYIMP ( QString , Category )
+ PROPERTYIMP ( QString , CatType )
+ PROPERTYIMP ( bool , Repeat )
+
+ PROPERTYIMP ( QString , SeriesId )
+ PROPERTYIMP ( QString , ProgramId )
+ PROPERTYIMP ( double , Stars )
+ PROPERTYIMP ( qlonglong , FileSize )
+ PROPERTYIMP ( QDateTime , LastModified )
+ PROPERTYIMP ( int , ProgramFlags )
+ PROPERTYIMP ( QString , Hostname )
+ PROPERTYIMP ( QDate , Airdate )
+ PROPERTYIMP ( QString , Description )
+
+ PROPERTYIMP_PTR( ChannelInfo , Channel )
+ PROPERTYIMP_PTR( RecordingInfo, Recording )
+
+ // Used only by Serializer
+ PROPERTYIMP( bool, SerializeDetails )
+
+ public:
+
+ Program(QObject *parent = 0)
+ : QObject ( parent ),
+ m_Repeat ( false ),
+ m_Stars ( 0 ),
+ m_FileSize ( 0 ),
+ m_ProgramFlags ( 0 ),
+ m_Channel ( NULL ),
+ m_Recording ( NULL )
+ {
+ }
+
+ Program( const Program &src )
+ {
+ Copy( src );
+ }
+
+ void Copy( const Program &src )
+ {
+ m_StartTime = src.m_StartTime ;
+ m_EndTime = src.m_EndTime ;
+ m_Title = src.m_Title ;
+ m_SubTitle = src.m_SubTitle ;
+ m_Category = src.m_Category ;
+ m_CatType = src.m_CatType ;
+ m_Repeat = src.m_Repeat ;
+ m_SeriesId = src.m_SeriesId ;
+ m_ProgramId = src.m_ProgramId ;
+ m_Stars = src.m_Stars ;
+ m_FileSize = src.m_FileSize ;
+ m_LastModified = src.m_LastModified ;
+ m_ProgramFlags = src.m_ProgramFlags ;
+ m_Hostname = src.m_Hostname ;
+ m_Airdate = src.m_Airdate ;
+ m_Description = src.m_Description ;
+
+ if ( src.m_Channel != NULL)
+ Channel()->Copy( src.m_Channel );
+
+ if ( src.m_Recording != NULL)
+ Recording()->Copy( src.m_Recording );
+ }
+
+};
+
+inline Program *ChannelInfo::AddNewProgram()
+{
+ // We must make sure the object added to the QVariantList has
+ // a parent of 'this'
+
+ Program *pObject = new Program( this );
+ m_Programs.append( QVariant::fromValue<QObject *>( pObject ));
+
+ return pObject;
+}
+
+} // namespace DTC
+
+Q_DECLARE_METATYPE( DTC::Program )
+Q_DECLARE_METATYPE( DTC::ChannelInfo )
+
+#endif
View
135 mythtv/libs/libmythservicecontracts/datacontracts/programGuide.h
@@ -0,0 +1,135 @@
+//////////////////////////////////////////////////////////////////////////////
+// Program Name: programGuide.h
+// Created : Jan. 15, 2010
+//
+// Purpose :
+//
+// Copyright (c) 2010 David Blain <dblain@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 PROGRAMGUIDE_H_
+#define PROGRAMGUIDE_H_
+
+#include <QDateTime>
+#include <QString>
+
+#include "serviceexp.h"
+#include "datacontracthelper.h"
+
+#include "programAndChannel.h"
+
+namespace DTC
+{
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+//
+// -=>NOTE: DESIGNABLE - is used to indicate if should be Serialized
+// (can specify a propery to support runtime logic)
+//
+//
+// Q_CLASSINFO( "defaultProp", "<propname>" ) -
+// is used to indicate the default property
+// (used for node text in XML)
+//
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+class SERVICE_PUBLIC ProgramGuide : public QObject
+{
+ Q_OBJECT
+ Q_CLASSINFO( "version", "1.0" );
+
+ Q_PROPERTY( QDateTime StartTime READ StartTime WRITE setStartTime )
+ Q_PROPERTY( QDateTime EndTime READ EndTime WRITE setEndTime )
+ Q_PROPERTY( int StartChanId READ StartChanId WRITE setStartChanId )
+ Q_PROPERTY( int EndChanId READ EndChanId WRITE setEndChanId )
+ Q_PROPERTY( int NumOfChannels READ NumOfChannels WRITE setNumOfChannels )
+
+ Q_PROPERTY( bool Details READ Details WRITE setDetails )
+ Q_PROPERTY( int Count READ Count WRITE setCount )
+ Q_PROPERTY( QDateTime AsOf READ AsOf WRITE setAsOf )
+ Q_PROPERTY( QString Version READ Version WRITE setVersion )
+ Q_PROPERTY( QString ProtoVer READ ProtoVer WRITE setProtoVer )
+
+ Q_PROPERTY( QVariantList Channels READ Channels DESIGNABLE true )
+
+ PROPERTYIMP ( QDateTime , StartTime )
+ PROPERTYIMP ( QDateTime , EndTime )
+ PROPERTYIMP ( int , StartChanId )
+ PROPERTYIMP ( int , EndChanId )
+ PROPERTYIMP ( int , NumOfChannels )
+
+ PROPERTYIMP ( bool , Details )
+ PROPERTYIMP ( int , Count )
+ PROPERTYIMP ( QDateTime , AsOf )
+ PROPERTYIMP ( QString , Version )
+ PROPERTYIMP ( QString , ProtoVer )
+
+ PROPERTYIMP_RO_REF( QVariantList, Channels )
+
+ public:
+
+ ProgramGuide(QObject *parent = 0)
+ : QObject ( parent ),
+ m_StartChanId ( 0 ),
+ m_EndChanId ( 0 ),
+ m_NumOfChannels ( 0 ),
+ m_Details ( false ),
+ m_Count ( 0 )
+ {
+ }
+
+ ProgramGuide( const ProgramGuide &src )
+ {
+ Copy( src );
+ }
+
+ void Copy( const ProgramGuide &src )
+ {
+ m_StartTime = src.m_StartTime ;
+ m_EndTime = src.m_EndTime ;
+ m_StartChanId = src.m_StartChanId ;
+ m_EndChanId = src.m_EndChanId ;
+ m_NumOfChannels= src.m_NumOfChannels;
+ m_Details = src.m_Details ;
+ m_Count = src.m_Count ;
+ m_AsOf = src.m_AsOf ;
+ m_Version = src.m_Version ;
+ m_ProtoVer = src.m_ProtoVer ;
+
+ CopyListContents< ChannelInfo >( this, m_Channels, src.m_Channels );
+ }
+
+ ChannelInfo *AddNewChannel()
+ {
+ // We must make sure the object added to the QVariantList has
+ // a parent of 'this'
+
+ ChannelInfo *pObject = new ChannelInfo( this );
+ Channels().append( QVariant::fromValue<QObject *>( pObject ));
+
+ return pObject;
+ }
+
+};
+
+} // namespace DTC
+
+Q_DECLARE_METATYPE( DTC::ProgramGuide )
+
+#endif
View
104 mythtv/libs/libmythservicecontracts/datacontracts/programList.h
@@ -0,0 +1,104 @@
+//////////////////////////////////////////////////////////////////////////////
+// Program Name: programs.h
+// Created : Jan. 15, 2010
+//
+// Copyright (c) 2010 David Blain <dblain@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 PROGRAMS_H_
+#define PROGRAMS_H_
+
+#include <QDateTime>
+#include <QString>
+#include <QVariantList>
+
+#include "serviceexp.h"
+#include "datacontracthelper.h"
+
+#include "programAndChannel.h"
+
+namespace DTC
+{
+
+class SERVICE_PUBLIC ProgramList : public QObject
+{
+ Q_OBJECT
+ Q_CLASSINFO( "version", "1.0" );
+
+ Q_PROPERTY( int StartIndex READ StartIndex WRITE setStartIndex )
+ Q_PROPERTY( int Count READ Count WRITE setCount )
+ Q_PROPERTY( int TotalAvailable READ TotalAvailable WRITE setTotalAvailable )
+ Q_PROPERTY( QDateTime AsOf READ AsOf WRITE setAsOf )
+ Q_PROPERTY( QString Version READ Version WRITE setVersion )
+ Q_PROPERTY( QString ProtoVer READ ProtoVer WRITE setProtoVer )
+
+ Q_PROPERTY( QVariantList Programs READ Programs DESIGNABLE true )
+
+ PROPERTYIMP ( int , StartIndex )
+ PROPERTYIMP ( int , Count )
+ PROPERTYIMP ( int , TotalAvailable )
+ PROPERTYIMP ( QDateTime , AsOf )
+ PROPERTYIMP ( QString , Version )
+ PROPERTYIMP ( QString , ProtoVer )
+
+ PROPERTYIMP_RO_REF( QVariantList, Programs )
+
+ public:
+
+ ProgramList(QObject *parent = 0)
+ : QObject ( parent ),
+ m_StartIndex ( 0 ),
+ m_Count ( 0 ),
+ m_TotalAvailable( 0 )
+ {
+ }
+
+ ProgramList( const ProgramList &src )
+ {
+ Copy( src );
+ }
+
+ void Copy( const ProgramList &src )
+ {
+ m_StartIndex = src.m_StartIndex ;
+ m_Count = src.m_Count ;
+ m_TotalAvailable= src.m_TotalAvailable ;
+ m_AsOf = src.m_AsOf ;
+ m_Version = src.m_Version ;
+ m_ProtoVer = src.m_ProtoVer ;
+
+ CopyListContents< Program >( this, m_Programs, src.m_Programs );
+ }
+
+ Program *AddNewProgram()
+ {
+ // We must make sure the object added to the QVariantList has
+ // a parent of 'this'
+
+ Program *pObject = new Program( this );
+ m_Programs.append( QVariant::fromValue<QObject *>( pObject ));
+
+ return pObject;
+ }
+
+};
+
+} // namespace DTC
+
+Q_DECLARE_METATYPE( DTC::ProgramList )
+
+#endif
View
122 mythtv/libs/libmythservicecontracts/datacontracts/recording.h
@@ -0,0 +1,122 @@
+//////////////////////////////////////////////////////////////////////////////
+// Program Name: recording.h
+// Created : Jan. 15, 2010
+//
+// Copyright (c) 2010 David Blain <dblain@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 RECORDING_H_
+#define RECORDING_H_
+
+#include <QDateTime>
+#include <QString>
+
+#include "serviceexp.h"
+#include "datacontracthelper.h"
+#include "programtypes.h"
+
+namespace DTC
+{
+
+class SERVICE_PUBLIC RecordingInfo : public QObject
+{
+ Q_OBJECT
+ Q_CLASSINFO( "version", "1.0" );
+
+ Q_PROPERTY( int Status READ Status WRITE setStatus )
+ Q_PROPERTY( int Priority READ Priority WRITE setPriority )
+ Q_PROPERTY( QDateTime StartTs READ StartTs WRITE setStartTs )
+ Q_PROPERTY( QDateTime EndTs READ EndTs WRITE setEndTs )
+
+ Q_PROPERTY( int RecordId READ RecordId WRITE setRecordId DESIGNABLE SerializeDetails )
+ Q_PROPERTY( QString RecGroup READ RecGroup WRITE setRecGroup DESIGNABLE SerializeDetails )
+ Q_PROPERTY( QString PlayGroup READ PlayGroup WRITE setPlayGroup DESIGNABLE SerializeDetails )
+ Q_PROPERTY( int RecType READ RecType WRITE setRecType DESIGNABLE SerializeDetails )
+ Q_PROPERTY( int DupInType READ DupInType WRITE setDupInType DESIGNABLE SerializeDetails )
+ Q_PROPERTY( int DupMethod READ DupMethod WRITE setDupMethod DESIGNABLE SerializeDetails )
+ Q_PROPERTY( int EncoderId READ EncoderId WRITE setEncoderId DESIGNABLE SerializeDetails )
+ Q_PROPERTY( QString Profile READ Profile WRITE setProfile DESIGNABLE SerializeDetails )
+
+ /*
+ Not using since Q_ENUMS seem to require the enum be defined in this class
+
+ Q_ENUMS( RecStatusType )
+ Q_ENUMS( RecordingType )
+ Q_ENUMS( RecordingDupInType )
+ Q_ENUMS( RecordingDupMethodType )
+ */
+
+ PROPERTYIMP_ENUM( RecStatusType , Status )
+ PROPERTYIMP ( int , Priority )
+ PROPERTYIMP ( QDateTime , StartTs )
+ PROPERTYIMP ( QDateTime , EndTs )
+
+ PROPERTYIMP ( int , RecordId )
+ PROPERTYIMP ( QString , RecGroup )
+ PROPERTYIMP ( QString , PlayGroup )
+ PROPERTYIMP_ENUM( RecordingType , RecType )
+ PROPERTYIMP_ENUM( RecordingDupInType , DupInType )
+ PROPERTYIMP_ENUM( RecordingDupMethodType , DupMethod )
+ PROPERTYIMP ( int , EncoderId )
+ PROPERTYIMP ( QString , Profile )
+
+ // Used only by Serializer
+ PROPERTYIMP( bool, SerializeDetails )
+
+ public:
+
+ RecordingInfo(QObject *parent = 0)
+ : QObject ( parent ),
+ m_Status ( rsUnknown ),
+ m_Priority ( 0 ),
+ m_RecordId ( 0 ),
+ m_RecType ( kNotRecording ),
+ m_DupInType ( kDupsInRecorded ),
+ m_DupMethod ( kDupCheckNone ),
+ m_EncoderId ( 0 ),
+ m_SerializeDetails( true )
+ {
+ }
+
+ RecordingInfo( const RecordingInfo &src )
+ {
+ Copy( src );
+ }
+
+ void Copy( const RecordingInfo &src )
+ {
+ m_Status = src.m_Status ;
+ m_Priority = src.m_Priority ;
+ m_StartTs = src.m_StartTs ;
+ m_EndTs = src.m_EndTs ;
+ m_RecordId = src.m_RecordId ;
+ m_RecGroup = src.m_RecGroup ;
+ m_PlayGroup = src.m_PlayGroup ;
+ m_RecType = src.m_RecType ;
+ m_DupInType = src.m_DupInType ;
+ m_DupMethod = src.m_DupMethod ;
+ m_EncoderId = src.m_EncoderId ;
+ m_Profile = src.m_Profile ;
+ m_SerializeDetails= src.m_SerializeDetails ;
+ }
+};
+
+} // namespace DTC
+
+Q_DECLARE_METATYPE( DTC::RecordingInfo )
+
+#endif
View
63 mythtv/libs/libmythservicecontracts/datacontracts/settingList.h
@@ -0,0 +1,63 @@
+//////////////////////////////////////////////////////////////////////////////
+// Program Name: settingList.h
+// Created : Jan. 15, 2010
+//
+// Copyright (c) 2010 David Blain <dblain@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 SETTINGLIST_H_
+#define SETTINGLIST_H_
+
+#include <QString>
+#include <QVariantMap>
+
+#include "serviceexp.h"
+#include "datacontracthelper.h"
+
+namespace DTC
+{
+
+class SERVICE_PUBLIC SettingList : public QObject
+{
+ Q_OBJECT
+ Q_CLASSINFO( "version", "1.0" );
+
+ Q_PROPERTY( QString HostName READ HostName WRITE setHostName )
+ Q_PROPERTY( QVariantMap Settings READ Settings DESIGNABLE true )
+
+ PROPERTYIMP ( QString , HostName )
+ PROPERTYIMP_RO_REF( QVariantMap, Settings )
+
+ public:
+
+ SettingList(QObject *parent = 0)
+ : QObject( parent )
+ {
+ }
+
+ SettingList( const SettingList &src )
+ : m_HostName( src.m_HostName ),
+ m_Settings( src.m_Settings )
+ {
+ }
+};
+
+} // namespace DTC
+
+Q_DECLARE_METATYPE( DTC::SettingList )
+
+#endif
View
59 mythtv/libs/libmythservicecontracts/datacontracts/stringList.h
@@ -0,0 +1,59 @@
+//////////////////////////////////////////////////////////////////////////////
+// Program Name: stringList.h
+// Created : Jan. 15, 2010
+//
+// Copyright (c) 2010 David Blain <dblain@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 STRINGLIST_H_
+#define STRINGLIST_H_
+
+#include <QStringList>
+
+#include "serviceexp.h"
+#include "datacontracthelper.h"
+
+namespace DTC
+{
+
+class SERVICE_PUBLIC StringList : public QObject
+{
+ Q_OBJECT
+ Q_CLASSINFO( "version", "1.0" );
+
+ Q_PROPERTY( QStringList Values READ Values DESIGNABLE true )
+
+ PROPERTYIMP_RO_REF( QStringList, Values )
+
+ public:
+
+ StringList(QObject *parent = 0)
+ : QObject( parent )
+ {
+ }
+
+ StringList( const StringList &src )
+ : m_Values( src.m_Values )
+ {
+ }
+};
+
+} // namespace DTC
+
+Q_DECLARE_METATYPE( DTC::StringList )
+
+#endif
View
59 mythtv/libs/libmythservicecontracts/datacontracts/successFail.h
@@ -0,0 +1,59 @@
+//////////////////////////////////////////////////////////////////////////////
+// Program Name: successFail.h
+// Created : Jan. 15, 2010
+//
+// Copyright (c) 2010 David Blain <dblain@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 SUCCESSFAIL_H_
+#define SUCCESSFAIL_H_
+
+#include <QObject>
+
+#include "serviceexp.h"
+#include "datacontracthelper.h"
+
+namespace DTC
+{
+
+class SERVICE_PUBLIC SuccessFail : public QObject
+{
+ Q_OBJECT
+ Q_CLASSINFO( "version", "1.0" );
+
+ Q_PROPERTY ( bool Result READ Result WRITE setResult )
+
+ PROPERTYIMP( bool, Result )
+
+ public:
+
+ SuccessFail(QObject *parent = 0)
+ : QObject( parent )
+ {
+ }
+
+ SuccessFail( const SuccessFail &src )
+ : m_Result( src.m_Result )
+ {
+ }
+};
+
+} // namespace DTC
+
+Q_DECLARE_METATYPE( DTC::SuccessFail )
+
+#endif
View
80 mythtv/libs/libmythservicecontracts/datacontracts/wolInfo.h
@@ -0,0 +1,80 @@
+//////////////////////////////////////////////////////////////////////////////
+// Program Name: wolInfo.h
+// Created : Jan. 15, 2010
+//
+// Copyright (c) 2010 David Blain <dblain@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 WOLINFO_H_
+#define WOLINFO_H_
+
+#include <QString>
+
+#include "serviceexp.h"
+#include "datacontracthelper.h"
+
+namespace DTC
+{
+
+class SERVICE_PUBLIC WOLInfo : public QObject
+{
+ Q_OBJECT
+
+ Q_CLASSINFO( "version" , "1.0" );
+ Q_CLASSINFO( "defaultProp", "Command" );
+
+ Q_PROPERTY( bool Enabled READ Enabled WRITE setEnabled )
+ Q_PROPERTY( int Reconnect READ Reconnect WRITE setReconnect )
+ Q_PROPERTY( int Retry READ Retry WRITE setRetry )
+ Q_PROPERTY( QString Command READ Command WRITE setCommand )
+
+ PROPERTYIMP( bool , Enabled )
+ PROPERTYIMP( int , Reconnect )
+ PROPERTYIMP( int , Retry )
+ PROPERTYIMP( QString, Command )
+
+ public:
+
+ WOLInfo(QObject *parent = 0)
+ : QObject ( parent ),
+ m_Enabled ( false ),
+ m_Reconnect( 0 ),
+ m_Retry ( 0 )
+ {
+ }
+
+ WOLInfo( const WOLInfo &src )
+ {
+ Copy( src );
+ }
+
+ void Copy( const WOLInfo &src )
+ {
+ m_Enabled = src.m_Enabled ;
+ m_Reconnect= src.m_Reconnect;
+ m_Retry = src.m_Retry ;
+ m_Command = src.m_Command ;
+ }
+};
+
+typedef WOLInfo* WOLInfoPtr;
+
+} // namespace DTC
+
+Q_DECLARE_METATYPE( DTC::WOLInfo )
+
+#endif
View
65 mythtv/libs/libmythservicecontracts/libmythservicecontracts.pro
@@ -0,0 +1,65 @@
+include ( ../../settings.pro )
+
+TEMPLATE = lib
+TARGET = mythservicecontracts-$$LIBVERSION
+CONFIG += thread dll
+target.path = $${LIBDIR}
+INSTALLS = target
+DEFINES += SERVICE_API
+
+QMAKE_CLEAN += $(TARGET) $(TARGETA) $(TARGETD) $(TARGET0) $(TARGET1) $(TARGET2)
+QMAKE_CLEAN += version.cpp
+
+# Input
+
+HEADERS += serviceexp.h service.h datacontracthelper.h
+
+HEADERS += services/mythServices.h services/guideServices.h
+HEADERS += services/contentServices.h services/dvrServices.h
+
+HEADERS += datacontracts/connectionInfo.h datacontracts/databaseInfo.h
+HEADERS += datacontracts/programAndChannel.h datacontracts/programGuide.h
+HEADERS += datacontracts/recording.h datacontracts/settingList.h
+HEADERS += datacontracts/stringList.h datacontracts/successFail.h
+HEADERS += datacontracts/wolInfo.h datacontracts/programList.h
+HEADERS += datacontracts/encoder.h datacontracts/encoderList.h
+
+SOURCES += service.cpp
+
+INCLUDEPATH += ./datacontracts
+INCLUDEPATH += ./services
+
+# needed only for enums
+INCLUDEPATH += ../libmyth
+
+LIBS += $$EXTRA_LIBS
+
+inc.path = $${PREFIX}/include/mythtv/libmythservicecontracts/
+inc.files = serviceexp.h service.h datacontracthelper.h
+
+incServices.path = $${PREFIX}/include/mythtv/libmythservicecontracts/services/
+incServices.files = services/mythServices.h services/guideServices.h
+incServices.files += services/contentServices.h services/dvrServices.h
+
+
+incDatacontracts.path = $${PREFIX}/include/mythtv/libmythservicecontracts/datacontracts/
+incDatacontracts.files = datacontracts/connectionInfo.h datacontracts/databaseInfo.h
+incDatacontracts.files += datacontracts/programAndChannel.h datacontracts/programGuide.h
+incDatacontracts.files += datacontracts/recording.h datacontracts/settingList.h
+incDatacontracts.files += datacontracts/stringList.h datacontracts/successFail.h
+incDatacontracts.files += datacontracts/wolInfo.h
+
+INSTALLS += inc incServices incDatacontracts
+
+macx {
+
+ QMAKE_LFLAGS_SHLIB += -flat_namespace
+}
+
+use_hidesyms {
+ QMAKE_CXXFLAGS += -fvisibility=hidden
+}
+
+include ( ../libs-targetfix.pro )
+
+LIBS += $$LATE_LIBS
View
97 mythtv/libs/libmythservicecontracts/service.cpp
@@ -0,0 +1,97 @@
+//////////////////////////////////////////////////////////////////////////////
+// Program Name: service.cpp
+// Created : Jan. 19, 2010
+//
+// Purpose : Base class for all Web Services
+//
+// Copyright (c) 2010 David Blain <dblain@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/>.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include "service.h"
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//////////////////////////////////////////////////////////////////////////////
+
+QVariant Service::ConvertToVariant( const QString &sTypeName, void *pValue )
+{
+ // -=>NOTE: Only intrinsic or Qt type conversions should be here
+ // All others should be added to overridden implementation.
+
+
+ if ( sTypeName.compare( "QFileInfo*", Qt::CaseInsensitive ) == 0 )
+ {
+ QFileInfo *pInfo = reinterpret_cast< QFileInfo *>( pValue );
+
+ return QVariant::fromValue<QFileInfo*>( pInfo );
+ }
+
+ // -=>NOTE: Default to being a QObject or derivative...
+ // Will CRASH if NOT derived from QObject!!!
+
+ QObject *pObjResult = reinterpret_cast< QObject *>( pValue );
+
+ return QVariant::fromValue<QObject*>( pObjResult );
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//////////////////////////////////////////////////////////////////////////////
+
+void* Service::ConvertToParameterPtr( const QString &sParamType,
+ const QString &sValue )
+{
+ // -=>NOTE: Only intrinsic or Qt type conversions should be here
+ // All others should be added to overridden implementation.
+
+ if (sParamType == "QString")
+ return new QString( sValue );
+
+ if (sParamType == "QDateTime")
+ {
+ if ( sValue.isEmpty())
+ return new QDateTime();
+
+ return new QDateTime( QDateTime::fromString( sValue, Qt::ISODate ));
+ }
+
+ if (sParamType == "int")
+ return new int( sValue.toInt() );
+
+ if (sParamType == "bool")
+ return new bool( ToBool( sValue ));
+
+ return NULL;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//////////////////////////////////////////////////////////////////////////////
+
+bool Service::ToBool( const QString &sVal )
+{
+ if (sVal.compare( "1", Qt::CaseInsensitive ) == 0)
+ return true;
+
+ if (sVal.compare( "y", Qt::CaseInsensitive ) == 0)
+ return true;
+
+ if (sVal.compare( "true", Qt::CaseInsensitive ) == 0)
+ return true;
+
+ return false;
+}
View
79 mythtv/libs/libmythservicecontracts/service.h
@@ -0,0 +1,79 @@
+//////////////////////////////////////////////////////////////////////////////
+// Program Name: service.h
+// Created : Jan. 19, 2010
+//
+// Purpose : Base class for all Web Services
+//
+// Copyright (c) 2010 David Blain <dblain@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 SERVICE_H_
+#define SERVICE_H_
+
+#include <QObject>
+#include <QMetaType>
+#include <QVariant>
+#include <QFileInfo>
+#include <QDateTime>
+#include <QString>
+
+#include "serviceexp.h"
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+//
+// Notes for derived classes -
+//
+// * This implementation can't handle declared default parameters
+//
+// * When called, any missing params are sent default values for its datatype
+//
+// * Q_CLASSINFO( "<methodName>_Method", "BOTH" )
+// is used to determine HTTP method type.
+// Defaults to "BOTH", available values:
+// "GET", "POST" or "BOTH"
+//
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+class SERVICE_PUBLIC Service : public QObject
+{
+ Q_OBJECT
+
+ public:
+
+ /////////////////////////////////////////////////////////////////////
+ // This method should be overridden to handle non-QObject based custom types
+ /////////////////////////////////////////////////////////////////////
+
+ virtual QVariant ConvertToVariant ( const QString &sTypeName,
+ void *pValue );
+
+ virtual void* ConvertToParameterPtr( const QString &sParamType,
+ const QString &sValue );
+
+ static bool ToBool( const QString &sVal );
+};
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//////////////////////////////////////////////////////////////////////////////
+
+Q_DECLARE_METATYPE( QFileInfo )
+Q_DECLARE_METATYPE( QFileInfo* )
+
+#endif
View
22 mythtv/libs/libmythservicecontracts/serviceexp.h
@@ -0,0 +1,22 @@
+#ifndef SERVICEEXP_H_
+#define SERVICEEXP_H_
+
+#include <QtCore/qglobal.h>
+
+#ifdef SERVICE_API
+# define SERVICE_PUBLIC Q_DECL_EXPORT
+#else
+# define SERVICE_PUBLIC Q_DECL_IMPORT
+#endif
+
+#if ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2)))
+# define MHIDDEN __attribute__((visibility("hidden")))
+# define MUNUSED __attribute__((unused))
+# define MDEPRECATED __attribute__((deprecated))
+#else
+# define MHIDDEN
+# define MUNUSED
+# define MDEPRECATED
+#endif
+
+#endif // SERVICEEXP_H_
View
77 mythtv/libs/libmythservicecontracts/services/contentServices.h
@@ -0,0 +1,77 @@
+//////////////////////////////////////////////////////////////////////////////
+// Program Name: contentServices.h
+// Created : Mar. 7, 2011
+//
+// Purpose - Content Services API Interface definition
+//
+// Copyright (c) 2010 David Blain <dblain@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 CONTENTSERVICES_H_
+#define CONTENTSERVICES_H_
+
+#include <QFileInfo>
+
+#include "service.h"
+#include "datacontracts/stringList.h"
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+//
+// Notes -
+//
+// * This implementation can't handle declared default parameters
+//
+// * When called, any missing params are sent default values for its datatype
+//
+// * Q_CLASSINFO( "<methodName>_Method", ...) is used to determine HTTP method
+// type. Defaults to "BOTH", available values:
+// "GET", "POST" or "BOTH"
+//
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+class SERVICE_PUBLIC ContentServices : public Service //, public QScriptable ???
+{
+ Q_OBJECT
+
+ public slots:
+
+ virtual QFileInfo* GetFile ( const QString &StorageGroup,
+ const QString &FileName ) = 0;
+
+ virtual DTC::StringList* GetFileList ( const QString &StorageGroup ) = 0;
+
+ virtual QFileInfo* GetVideoArt ( int Id ) = 0;
+
+ virtual QFileInfo* GetAlbumArt ( int Id, int Width, int Height ) = 0;
+
+ virtual QFileInfo* GetPreviewImage ( int ChanId,
+ const QDateTime &tStartTime,
+ int Width,
+ int Height,
+ int SecsIn ) = 0;
+
+ virtual QFileInfo* GetRecording ( int ChanId,
+ const QDateTime &StartTime ) = 0;
+
+ virtual QFileInfo* GetMusic ( int Id ) = 0;
+ virtual QFileInfo* GetVideo ( int Id ) = 0;
+};
+
+#endif
+
View
66 mythtv/libs/libmythservicecontracts/services/dvrServices.h
@@ -0,0 +1,66 @@
+//////////////////////////////////////////////////////////////////////////////
+// Program Name: dvrServices.h
+// Created : Mar. 7, 2011
+//
+// Purpose - DVR Services API Interface definition
+//
+// Copyright (c) 2010 David Blain <dblain@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 DVRSERVICES_H_
+#define DVRSERVICES_H_
+
+#include "service.h"
+
+#include "datacontracts/programList.h"
+#include "datacontracts/encoderList.h"
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+//
+// Notes -
+//
+// * This implementation can't handle declared default parameters
+//
+// * When called, any missing params are sent default values for its datatype
+//
+// * Q_CLASSINFO( "<methodName>_Method", ...) is used to determine HTTP method
+// type. Defaults to "BOTH", available values:
+// "GET", "POST" or "BOTH"
+//
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+class SERVICE_PUBLIC DvrServices : public Service //, public QScriptable ???
+{
+ Q_OBJECT
+
+ public slots:
+
+ virtual DTC::ProgramList* GetExpiring ( int StartIndex,
+ int Count ) = 0;
+
+ virtual DTC::ProgramList* GetRecorded ( bool Descending,
+ int StartIndex,
+ int Count ) = 0;
+
+ virtual DTC::EncoderList* Encoders ( ) = 0;
+
+};
+
+#endif
+
View
70 mythtv/libs/libmythservicecontracts/services/guideServices.h
@@ -0,0 +1,70 @@
+//////////////////////////////////////////////////////////////////////////////
+// Program Name: guideservices.h
+// Created : Mar. 7, 2011
+//
+// Purpose - Program Guide Services API Interface definition
+//
+// Copyright (c) 2010 David Blain <dblain@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 GUIDESERVICES_H_
+#define GUIDESERVICES_H_
+
+#include <QFileInfo>
+
+#include "service.h"
+#include "datacontracts/programGuide.h"
+#include "datacontracts/programAndChannel.h"
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+//
+// Notes -
+//
+// * This implementation can't handle declared default parameters
+//
+// * When called, any missing params are sent default values for its datatype
+//
+// * Q_CLASSINFO( "<methodName>_Method", ...) is used to determine HTTP method
+// type. Defaults to "BOTH", available values:
+// "GET", "POST" or "BOTH"
+//
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+class SERVICE_PUBLIC GuideServices : public Service //, public QScriptable ???
+{
+ Q_OBJECT
+
+ public slots:
+
+ virtual DTC::ProgramGuide* GetProgramGuide ( const QDateTime &StartTime ,
+ const QDateTime &EndTime ,
+ int StartChanId,
+ int NumChannels,
+ bool Details ) = 0;
+
+ virtual DTC::Program* GetProgramDetails ( int ChanId,
+ const QDateTime &StartTime ) = 0;
+
+ virtual QFileInfo* GetChannelIcon ( int ChanId,
+ int Width ,
+ int Height ) = 0;
+};
+
+#endif
+
View
73 mythtv/libs/libmythservicecontracts/services/mythServices.h
@@ -0,0 +1,73 @@
+//////////////////////////////////////////////////////////////////////////////
+// Program Name: mythservices.h
+// Created : Jan. 19, 2010
+//
+// Purpose - Myth Services API Interface definition
+//
+// Copyright (c) 2010 David Blain <dblain@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 MYTHSERVICES_H_
+#define MYTHSERVICES_H_
+
+#include <QFileInfo>
+
+#include "service.h"
+#include "datacontracts/connectionInfo.h"
+#include "datacontracts/stringList.h"
+#include "datacontracts/settingList.h"
+#include "datacontracts/successFail.h"
+
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+//
+// Notes -
+//
+// * This implementation can't handle declared default parameters
+//
+// * When called, any missing params are sent default values for its datatype
+//
+// * Q_CLASSINFO( "<methodName>_Method", ...) is used to determine HTTP method
+// type. Defaults to "BOTH", available values:
+// "GET", "POST" or "BOTH"
+//
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+class SERVICE_PUBLIC MythServices : public Service //, public QScriptable ???
+{
+ Q_OBJECT
+ Q_CLASSINFO( "PutSetting_Method", "POST" )
+
+ public slots:
+
+ virtual DTC::ConnectionInfo* GetConnectionInfo ( const QString &Pin ) = 0;
+
+ virtual DTC::StringList* GetHosts ( ) = 0;
+ virtual DTC::StringList* GetKeys ( ) = 0;
+
+ virtual DTC::SettingList* GetSetting ( const QString &HostName,
+ const QString &Key,
+ const QString &Default ) = 0;
+
+ virtual DTC::SuccessFail* PutSetting ( const QString &HostName,
+ const QString &Key,
+ const QString &Value ) = 0;
+};
+
+#endif
+
View
2 mythtv/libs/libmythtv/libmythtv.pro
@@ -34,6 +34,8 @@ DEPENDPATH += ../libmythlivemedia/liveMedia
DEPENDPATH += ../libmythlivemedia/UsageEnvironment/include
DEPENDPATH += ../libmythlivemedia/UsageEnvironment
DEPENDPATH += ../libmythbase ../libmythui
+DEPENDPATH += ../libmythupnp
+
INCLUDEPATH += .. ../.. # for avlib headers
INCLUDEPATH += ../../external/FFmpeg
View
201 mythtv/libs/libmythupnp/httprequest.cpp
@@ -4,7 +4,7 @@
//
// Purpose : Http Request/Response
//
-// Copyright (c) 2005 David Blain <mythtv@theblains.net>
+// Copyright (c) 2005 David Blain <dblain@mythtv.org>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@@ -48,6 +48,10 @@
#include "compat.h"
#include "mythverbose.h"
+#include "serializers/xmlSerializer.h"
+#include "serializers/soapSerializer.h"
+#include "serializers/jsonSerializer.h"
+
#ifndef O_LARGEFILE
#define O_LARGEFILE 0
#endif
@@ -118,46 +122,9 @@ HTTPRequest::HTTPRequest() : m_procReqLineExp ( "[ \r\n][ \r\n]*" ),
m_bSOAPRequest ( false ),
m_eResponseType ( ResponseTypeUnknown),
m_nResponseStatus( 200 ),
- m_response ( &m_aBuffer,
- QIODevice::WriteOnly ),
m_pPostProcess ( NULL )
{
- m_response.setCodec(QTextCodec::codecForName("UTF-8"));
-}
-
-/////////////////////////////////////////////////////////////////////////////
-//
-/////////////////////////////////////////////////////////////////////////////
-
-void HTTPRequest::Reset()
-{
- m_eType = RequestTypeUnknown;
- m_eContentType = ContentType_Unknown;
- m_nMajor = 0;
- m_nMinor = 0;
- m_bSOAPRequest = false;
- m_eResponseType = ResponseTypeUnknown;
- m_nResponseStatus= 200;
- m_pPostProcess = NULL;
-
- m_response << flush;
- m_aBuffer.truncate( 0 );
-
- m_sRawRequest.clear();
- m_sBaseUrl.clear();
- m_sMethod.clear();
-
- m_mapParams.clear();
- m_mapHeaders.clear();
-
- m_sPayload.clear();
-
- m_sProtocol.clear();
- m_sNameSpace.clear();
-
- m_mapRespHeaders.clear();
-
- m_sFileName.clear();
+ m_response.open( QIODevice::ReadWrite );
}
/////////////////////////////////////////////////////////////////////////////
@@ -278,17 +245,17 @@ long HTTPRequest::SendResponse( void )
// ----------------------------------------------------------------------
// Write out Header.
// ----------------------------------------------------------------------
+ const QByteArray &buffer = m_response.buffer();
- m_response << flush;
- QString rHeader = BuildHeader( m_aBuffer.size() );
+ QString rHeader = BuildHeader( buffer.length() );
QByteArray sHeader = rHeader.toUtf8();
nBytes = WriteBlockDirect( sHeader.constData(), sHeader.length() );
// ----------------------------------------------------------------------
// Write out Response buffer.
// ----------------------------------------------------------------------
- if (( m_eType != RequestTypeHead ) && ( m_aBuffer.size() > 0 ))
+ if (( m_eType != RequestTypeHead ) && ( buffer.length() > 0 ))
{
#if 0
VERBOSE(VB_UPNP, QString("HTTPRequest::SendResponse : DATA : %1 : ")
@@ -298,7 +265,7 @@ long HTTPRequest::SendResponse( void )
cout << endl;
#endif
- nBytes += WriteBlockDirect( m_aBuffer.constData(), m_aBuffer.size() );
+ nBytes += SendData( &m_response, 0, m_response.size() );
}
// ----------------------------------------------------------------------
@@ -471,17 +438,15 @@ long HTTPRequest::SendResponseFile( QString sFileName )
#define SENDFILE_BUFFER_SIZE 65536
-qint64 HTTPRequest::SendFile( QFile &file, qint64 llStart, qint64 llBytes )
+qint64 HTTPRequest::SendData( QIODevice *pDevice, qint64 llStart, qint64 llBytes )
{
qint64 sent = 0;
-#if CONFIG_DARWIN || CONFIG_CYGWIN || defined(__FreeBSD__) || defined(USING_MINGW)
-
// ----------------------------------------------------------------------
// Set out file position to requested start location.
// ----------------------------------------------------------------------
- if ( file.seek( llStart ) == false)
+ if ( pDevice->seek( llStart ) == false)
return -1;
char aBuffer[ SENDFILE_BUFFER_SIZE ];
@@ -491,11 +456,11 @@ qint64 HTTPRequest::SendFile( QFile &file, qint64 llStart, qint64 llBytes )
qint64 llBytesRead = 0;
qint64 llBytesWritten = 0;
- while ((sent < llBytes) && !file.atEnd())
+ while ((sent < llBytes) && !pDevice->atEnd())
{
llBytesToRead = std::min( (qint64)SENDFILE_BUFFER_SIZE, llBytesRemaining );
- if (( llBytesRead = file.read( aBuffer, llBytesToRead )) != -1 )
+ if (( llBytesRead = pDevice->read( aBuffer, llBytesToRead )) != -1 )
{
if (( llBytesWritten = WriteBlockDirect( aBuffer, llBytesRead )) == -1)
return -1;
@@ -507,6 +472,21 @@ qint64 HTTPRequest::SendFile( QFile &file, qint64 llStart, qint64 llBytes )
}
}
+ return sent;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+//
+/////////////////////////////////////////////////////////////////////////////
+
+qint64 HTTPRequest::SendFile( QFile &file, qint64 llStart, qint64 llBytes )
+{
+ qint64 sent = 0;
+
+#if CONFIG_DARWIN || CONFIG_CYGWIN || defined(__FreeBSD__) || defined(USING_MINGW)
+
+ sent = SendData( (QIODevice *)(&file), llStart, llBytes );
+
#else
__off64_t offset = llStart;
@@ -565,27 +545,46 @@ void HTTPRequest::FormatErrorResponse( bool bServerError,
m_eResponseType = ResponseTypeXML;
m_nResponseStatus = 500;
- m_response << "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
+ QTextStream stream( &m_response );
+
+ stream << "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
QString sWhere = ( bServerError ) ? "s:Server" : "s:Client";
if (m_bSOAPRequest)
{
m_mapRespHeaders[ "EXT" ] = "";
- m_response << SOAP_ENVELOPE_BEGIN
- << "<s:Fault>"
- << "<faultcode>" << sWhere << "</faultcode>"
- << "<faultstring>" << sFaultString << "</faultstring>";
+ stream << SOAP_ENVELOPE_BEGIN
+ << "<s:Fault>"
+ << "<faultcode>" << sWhere << "</faultcode>"
+ << "<faultstring>" << sFaultString << "</faultstring>";
}
if (sDetails.length() > 0)
{
- m_response << "<detail>" << sDetails << "</detail>";
+ stream << "<detail>" << sDetails << "</detail>";
}
if (m_bSOAPRequest)
- m_response << "</s:Fault>" << SOAP_ENVELOPE_END;
+ stream << "</s:Fault>" << SOAP_ENVELOPE_END;
+
+ stream.flush();
+}
+
+/////////////////////////////////////////////////////////////////////////////
+//
+/////////////////////////////////////////////////////////////////////////////
+
+void HTTPRequest::FormatActionResponse( Serializer *pSer )
+{
+ m_eResponseType = ResponseTypeOther;
+ m_sResponseTypeText = pSer->GetContentType();
+ m_nResponseStatus = 200;
+
+ pSer->AddHeaders( m_mapRespHeaders );
+
+ //m_response << pFormatter->ToString();
}
/////////////////////////////////////////////////////////////////////////////
@@ -597,51 +596,55 @@ void HTTPRequest::FormatActionResponse(const NameValues &args)
m_eResponseType = ResponseTypeXML;
m_nResponseStatus = 200;
- m_response << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n";
+ QTextStream stream( &m_response );
+
+ stream << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n";
if (m_bSOAPRequest)
{
m_mapRespHeaders[ "EXT" ] = "";
- m_response << SOAP_ENVELOPE_BEGIN
- << "<u:" << m_sMethod << "Response xmlns:u=\""
- << m_sNameSpace << "\">\r\n";
+ stream << SOAP_ENVELOPE_BEGIN
+ << "<u:" << m_sMethod << "Response xmlns:u=\""
+ << m_sNameSpace << "\">\r\n";
}
else
- m_response << "<" << m_sMethod << "Response>\r\n";
+ stream << "<" << m_sMethod << "Response>\r\n";
NameValues::const_iterator nit = args.begin();
for (; nit != args.end(); ++nit)
{
- m_response << "<" << (*nit).sName;
+ stream << "<" << (*nit).sName;
if ((*nit).pAttributes)
{
NameValues::const_iterator nit2 = (*nit).pAttributes->begin();
for (; nit2 != (*nit).pAttributes->end(); ++nit2)
{
- m_response << " " << (*nit2).sName << "='"
- << Encode( (*nit2).sValue ) << "'";
+ stream << " " << (*nit2).sName << "='"
+ << Encode( (*nit2).sValue ) << "'";
}
}
- m_response << ">";
+ stream << ">";
if (m_bSOAPRequest)
- m_response << Encode( (*nit).sValue );
+ stream << Encode( (*nit).sValue );
else
- m_response << (*nit).sValue;
+ stream << (*nit).sValue;
- m_response << "</" << (*nit).sName << ">\r\n";
+ stream << "</" << (*nit).sName << ">\r\n";
}
if (m_bSOAPRequest)
{
- m_response << "</u:" << m_sMethod << "Response>\r\n"
+ stream << "</u:" << m_sMethod << "Response>\r\n"
<< SOAP_ENVELOPE_END;
}
else
- m_response << "</" << m_sMethod << "Response>\r\n";
+ stream << "</" << m_sMethod << "Response>\r\n";
+
+ stream.flush();
}
/////////////////////////////////////////////////////////////////////////////
@@ -653,7 +656,11 @@ void HTTPRequest::FormatRawResponse(const QString &sXML)
m_eResponseType = ResponseTypeXML;
m_nResponseStatus = 200;
- m_response << sXML;
+ QTextStream stream( &m_response );
+
+ stream << sXML;
+
+ stream.flush();
}
/////////////////////////////////////////////////////////////////////////////
//
@@ -1282,12 +1289,30 @@ bool HTTPRequest::ProcessSOAPPayload( const QString &sSOAPAction )
// XML Document Loaded... now parse it
// --------------------------------------------------------------
- m_sNameSpace = sSOAPAction.section( '#', 0, 0).remove( 0, 1);
- m_sMethod = sSOAPAction.section( '#', 1 );
- m_sMethod.remove( m_sMethod.length()-1, 1 );
+ if (sSOAPAction.contains( '#' ))
+ {
+ m_sNameSpace = sSOAPAction.section( '#', 0, 0).remove( 0, 1);
+ m_sMethod = sSOAPAction.section( '#', 1 );
+ m_sMethod.remove( m_sMethod.length()-1, 1 );
+ }
+ if (sSOAPAction.contains( '/' ))
+ {
+ int nPos = sSOAPAction.lastIndexOf( '/' );
+ m_sNameSpace = sSOAPAction.mid( 1, nPos );
+ m_sMethod = sSOAPAction.mid( nPos + 1, sSOAPAction.length() - nPos - 2 );
+ }
+ else
+ {
+ m_sNameSpace = QString::null;
+ m_sMethod = sSOAPAction;
+ m_sMethod.remove( QChar( '\"' ) );
+ }
QDomNodeList oNodeList = doc.elementsByTagNameNS( m_sNameSpace, m_sMethod );
+ if (oNodeList.count() == 0)
+ oNodeList = doc.elementsByTagNameNS( "http://schemas.xmlsoap.org/soap/envelope/", "Body" );
+