|
MythTV
0.26-pre
|
00001 00002 // Program Name: video.h 00003 // Created : Apr. 21, 2011 00004 // 00005 // Copyright (c) 2011 Robert McNamara <rmcnamara@mythtv.org> 00006 // 00007 // This library is free software; you can redistribute it and/or 00008 // modify it under the terms of the GNU Lesser General Public 00009 // License as published by the Free Software Foundation; either 00010 // version 2.1 of the License, or at your option any later version of the LGPL. 00011 // 00012 // This library is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 // Lesser General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU Lesser General Public 00018 // License along with this library. If not, see <http://www.gnu.org/licenses/>. 00019 // 00021 00022 #ifndef VIDEO_H 00023 #define VIDEO_H 00024 00025 #include <QScriptEngine> 00026 #include <QDateTime> 00027 00028 #include "videometadatalistmanager.h" 00029 00030 #include "services/videoServices.h" 00031 00032 class Video : public VideoServices 00033 { 00034 Q_OBJECT 00035 00036 public: 00037 00038 Q_INVOKABLE Video( QObject *parent = 0 ) {} 00039 00040 public: 00041 00042 /* Video Metadata Methods */ 00043 00044 DTC::VideoMetadataInfoList* GetVideoList ( bool Descending, 00045 int StartIndex, 00046 int Count ); 00047 00048 DTC::VideoMetadataInfo* GetVideo ( int Id ); 00049 00050 DTC::VideoMetadataInfo* GetVideoByFileName ( const QString &FileName ); 00051 00052 DTC::VideoLookupList* LookupVideo ( const QString &Title, 00053 const QString &Subtitle, 00054 const QString &Inetref, 00055 int Season, 00056 int Episode, 00057 const QString &GrabberType, 00058 bool AllowGeneric ); 00059 00060 bool RemoveVideoFromDB ( int Id ); 00061 00062 bool AddVideo ( const QString &FileName, 00063 const QString &HostName ); 00064 00065 /* Bluray Methods */ 00066 00067 DTC::BlurayInfo* GetBluray ( const QString &Path ); 00068 00069 }; 00070 00071 // -------------------------------------------------------------------------- 00072 // The following class wrapper is due to a limitation in Qt Script Engine. It 00073 // requires all methods that return pointers to user classes that are derived from 00074 // QObject actually return QObject* (not the user class *). If the user class pointer 00075 // is returned, the script engine treats it as a QVariant and doesn't create a 00076 // javascript prototype wrapper for it. 00077 // 00078 // This class allows us to keep the rich return types in the main API class while 00079 // offering the script engine a class it can work with. 00080 // 00081 // Only API Classes that return custom classes needs to implement these wrappers. 00082 // 00083 // We should continue to look for a cleaning solution to this problem. 00084 // -------------------------------------------------------------------------- 00085 00086 class ScriptableVideo : public QObject 00087 { 00088 Q_OBJECT 00089 00090 private: 00091 00092 Video m_obj; 00093 00094 public: 00095 00096 Q_INVOKABLE ScriptableVideo( QObject *parent = 0 ) : QObject( parent ) {} 00097 00098 public slots: 00099 00100 QObject* GetVideoList( bool Descending, 00101 int StartIndex, 00102 int Count ) 00103 { 00104 return m_obj.GetVideoList( Descending, StartIndex, Count ); 00105 } 00106 00107 QObject* GetVideo( int Id ) 00108 { 00109 return m_obj.GetVideo( Id ); 00110 } 00111 00112 QObject* GetVideoByFileName( const QString &FileName ) 00113 { 00114 return m_obj.GetVideoByFileName( FileName ); 00115 } 00116 00117 QObject* LookupVideo( const QString &Title, 00118 const QString &Subtitle, 00119 const QString &Inetref, 00120 int Season, 00121 int Episode, 00122 const QString &GrabberType, 00123 bool AllowGeneric ) 00124 { 00125 return m_obj.LookupVideo( Title, Subtitle, Inetref, 00126 Season, Episode, GrabberType, 00127 AllowGeneric ); 00128 } 00129 00130 bool RemoveVideoFromDB( int Id ) 00131 { 00132 return m_obj.RemoveVideoFromDB( Id ); 00133 } 00134 00135 bool AddVideo( const QString &FileName, 00136 const QString &HostName ) 00137 { 00138 return m_obj.AddVideo( FileName, HostName ); 00139 } 00140 }; 00141 00142 00143 Q_SCRIPT_DECLARE_QMETAOBJECT( ScriptableVideo, QObject*); 00144 00145 #endif
1.7.6.1