1
0
mirror of https://github.com/clementine-player/Clementine synced 2025-01-31 11:35:24 +01:00

Add some more python bindings

This commit is contained in:
David Sansome 2011-05-19 23:02:15 +00:00
parent 8422b844b1
commit 147bbb9928
13 changed files with 3142 additions and 10 deletions

View File

@ -822,12 +822,14 @@ endif(APPLE)
if(HAVE_SCRIPTING_PYTHON)
list(APPEND SOURCES
scripting/python/objectdecorators.cpp
scripting/python/pythonconsole.cpp
scripting/python/pythonengine.cpp
scripting/python/pythonscript.cpp
)
list(APPEND HEADERS
scripting/python/objectdecorators.h
scripting/python/pythonconsole.h
scripting/python/pythonengine.h
)

View File

@ -1,6 +1,9 @@
include_directories(
${CMAKE_SOURCE_DIR}/src/core
${CMAKE_SOURCE_DIR}/src/covers
${CMAKE_SOURCE_DIR}/src/engines
${CMAKE_SOURCE_DIR}/src/library
${CMAKE_SOURCE_DIR}/src/playlistparsers
${CMAKE_SOURCE_DIR}/src/radio
${CMAKE_CURRENT_SOURCE_DIR}/clementine
${PYTHON_INCLUDE_DIRS}

File diff suppressed because it is too large Load Diff

View File

@ -6,12 +6,18 @@
#include <coverprovider.h>
#include <coverproviderfactory.h>
#include <coverproviders.h>
#include <directory.h>
#include <librarybackend.h>
#include <libraryquery.h>
#include <network.h>
#include <player.h>
#include <playlistparser.h>
#include <qabstractitemmodel.h>
#include <qabstractnetworkcache.h>
#include <qbytearray.h>
#include <qcoreevent.h>
#include <qdatastream.h>
#include <qdir.h>
#include <qimage.h>
#include <qiodevice.h>
#include <qlist.h>
@ -25,6 +31,8 @@
#include <qwidget.h>
#include <radiomodel.h>
#include <radioservice.h>
#include <song.h>
#include <taskmanager.h>
#include <urlhandler.h>
@ -156,6 +164,248 @@ void delete_CoverSearchResults(CoverSearchResults* obj) { delete obj; }
class PythonQtShell_Directory : public Directory
{
public:
PythonQtShell_Directory():Directory(),_wrapper(NULL) {};
PythonQtInstanceWrapper* _wrapper;
};
class PythonQtWrapper_Directory : public QObject
{ Q_OBJECT
public:
public slots:
Directory* new_Directory();
Directory* new_Directory(const Directory& other) {
PythonQtShell_Directory* a = new PythonQtShell_Directory();
*((Directory*)a) = other;
return a; }
void delete_Directory(Directory* obj) { delete obj; }
void py_set_path(Directory* theWrappedObject, QString path){ theWrappedObject->path = path; }
QString py_get_path(Directory* theWrappedObject){ return theWrappedObject->path; }
void py_set_id(Directory* theWrappedObject, int id){ theWrappedObject->id = id; }
int py_get_id(Directory* theWrappedObject){ return theWrappedObject->id; }
};
class PythonQtShell_LibraryBackend : public LibraryBackend
{
public:
PythonQtShell_LibraryBackend(QObject* parent = 0):LibraryBackend(parent),_wrapper(NULL) {};
virtual void AddDirectory(const QString& path);
virtual void ChangeDirPath(int id, const QString& old_path, const QString& new_path);
virtual bool ExecQuery(LibraryQuery* q);
virtual QList<Song > FindSongsInDirectory(int id);
virtual LibraryBackendInterface::Album GetAlbumArt(const QString& artist, const QString& album);
virtual QList<LibraryBackendInterface::Album > GetAlbumsByArtist(const QString& artist, const QueryOptions& opt = QueryOptions());
virtual QList<LibraryBackendInterface::Album > GetAllAlbums(const QueryOptions& opt = QueryOptions());
virtual QStringList GetAllArtists(const QueryOptions& opt = QueryOptions());
virtual QStringList GetAllArtistsWithAlbums(const QueryOptions& opt = QueryOptions());
virtual QList<Directory > GetAllDirectories();
virtual QList<LibraryBackendInterface::Album > GetCompilationAlbums(const QueryOptions& opt = QueryOptions());
virtual QList<Song > GetCompilationSongs(const QString& album, const QueryOptions& opt = QueryOptions());
virtual Song GetSongById(int id);
virtual Song GetSongByUrl(const QUrl& url, qint64 beginning = 0);
virtual QList<Song > GetSongs(const QString& artist, const QString& album, const QueryOptions& opt = QueryOptions());
virtual QList<Song > GetSongsByUrl(const QUrl& url);
virtual bool HasCompilations(const QueryOptions& opt = QueryOptions());
virtual void LoadDirectoriesAsync();
virtual void RemoveDirectory(const Directory& dir);
virtual QList<Subdirectory > SubdirsInDirectory(int id);
virtual void UpdateManualAlbumArtAsync(const QString& artist, const QString& album, const QString& art);
virtual void UpdateTotalSongCountAsync();
virtual void childEvent(QChildEvent* arg__1);
virtual void customEvent(QEvent* arg__1);
virtual bool event(QEvent* arg__1);
virtual bool eventFilter(QObject* arg__1, QEvent* arg__2);
virtual void timerEvent(QTimerEvent* arg__1);
PythonQtInstanceWrapper* _wrapper;
};
class PythonQtPublicPromoter_LibraryBackend : public LibraryBackend
{ public:
inline void promoted_AddDirectory(const QString& path) { LibraryBackend::AddDirectory(path); }
inline void promoted_ChangeDirPath(int id, const QString& old_path, const QString& new_path) { LibraryBackend::ChangeDirPath(id, old_path, new_path); }
inline bool promoted_ExecQuery(LibraryQuery* q) { return LibraryBackend::ExecQuery(q); }
inline QList<Song > promoted_FindSongsInDirectory(int id) { return LibraryBackend::FindSongsInDirectory(id); }
inline LibraryBackendInterface::Album promoted_GetAlbumArt(const QString& artist, const QString& album) { return LibraryBackend::GetAlbumArt(artist, album); }
inline QList<LibraryBackendInterface::Album > promoted_GetAlbumsByArtist(const QString& artist, const QueryOptions& opt = QueryOptions()) { return LibraryBackend::GetAlbumsByArtist(artist, opt); }
inline QList<LibraryBackendInterface::Album > promoted_GetAllAlbums(const QueryOptions& opt = QueryOptions()) { return LibraryBackend::GetAllAlbums(opt); }
inline QStringList promoted_GetAllArtists(const QueryOptions& opt = QueryOptions()) { return LibraryBackend::GetAllArtists(opt); }
inline QStringList promoted_GetAllArtistsWithAlbums(const QueryOptions& opt = QueryOptions()) { return LibraryBackend::GetAllArtistsWithAlbums(opt); }
inline QList<Directory > promoted_GetAllDirectories() { return LibraryBackend::GetAllDirectories(); }
inline QList<LibraryBackendInterface::Album > promoted_GetCompilationAlbums(const QueryOptions& opt = QueryOptions()) { return LibraryBackend::GetCompilationAlbums(opt); }
inline QList<Song > promoted_GetCompilationSongs(const QString& album, const QueryOptions& opt = QueryOptions()) { return LibraryBackend::GetCompilationSongs(album, opt); }
inline Song promoted_GetSongById(int id) { return LibraryBackend::GetSongById(id); }
inline Song promoted_GetSongByUrl(const QUrl& url, qint64 beginning = 0) { return LibraryBackend::GetSongByUrl(url, beginning); }
inline QList<Song > promoted_GetSongs(const QString& artist, const QString& album, const QueryOptions& opt = QueryOptions()) { return LibraryBackend::GetSongs(artist, album, opt); }
inline QList<Song > promoted_GetSongsByUrl(const QUrl& url) { return LibraryBackend::GetSongsByUrl(url); }
inline bool promoted_HasCompilations(const QueryOptions& opt = QueryOptions()) { return LibraryBackend::HasCompilations(opt); }
inline void promoted_LoadDirectoriesAsync() { LibraryBackend::LoadDirectoriesAsync(); }
inline void promoted_RemoveDirectory(const Directory& dir) { LibraryBackend::RemoveDirectory(dir); }
inline QList<Subdirectory > promoted_SubdirsInDirectory(int id) { return LibraryBackend::SubdirsInDirectory(id); }
inline void promoted_UpdateManualAlbumArtAsync(const QString& artist, const QString& album, const QString& art) { LibraryBackend::UpdateManualAlbumArtAsync(artist, album, art); }
inline void promoted_UpdateTotalSongCountAsync() { LibraryBackend::UpdateTotalSongCountAsync(); }
};
class PythonQtWrapper_LibraryBackend : public QObject
{ Q_OBJECT
public:
public slots:
LibraryBackend* new_LibraryBackend(QObject* parent = 0);
void delete_LibraryBackend(LibraryBackend* obj) { delete obj; }
void AddDirectory(LibraryBackend* theWrappedObject, const QString& path);
void ChangeDirPath(LibraryBackend* theWrappedObject, int id, const QString& old_path, const QString& new_path);
void DeleteAll(LibraryBackend* theWrappedObject);
bool ExecQuery(LibraryBackend* theWrappedObject, LibraryQuery* q);
QList<Song > FindSongsInDirectory(LibraryBackend* theWrappedObject, int id);
LibraryBackendInterface::Album GetAlbumArt(LibraryBackend* theWrappedObject, const QString& artist, const QString& album);
QList<LibraryBackendInterface::Album > GetAlbumsByArtist(LibraryBackend* theWrappedObject, const QString& artist, const QueryOptions& opt = QueryOptions());
QStringList GetAll(LibraryBackend* theWrappedObject, const QString& column, const QueryOptions& opt = QueryOptions());
QList<LibraryBackendInterface::Album > GetAllAlbums(LibraryBackend* theWrappedObject, const QueryOptions& opt = QueryOptions());
QStringList GetAllArtists(LibraryBackend* theWrappedObject, const QueryOptions& opt = QueryOptions());
QStringList GetAllArtistsWithAlbums(LibraryBackend* theWrappedObject, const QueryOptions& opt = QueryOptions());
QList<Directory > GetAllDirectories(LibraryBackend* theWrappedObject);
QList<LibraryBackendInterface::Album > GetCompilationAlbums(LibraryBackend* theWrappedObject, const QueryOptions& opt = QueryOptions());
QList<Song > GetCompilationSongs(LibraryBackend* theWrappedObject, const QString& album, const QueryOptions& opt = QueryOptions());
Song GetSongById(LibraryBackend* theWrappedObject, int id);
Song GetSongByUrl(LibraryBackend* theWrappedObject, const QUrl& url, qint64 beginning = 0);
QList<Song > GetSongs(LibraryBackend* theWrappedObject, const QString& artist, const QString& album, const QueryOptions& opt = QueryOptions());
QList<Song > GetSongsByForeignId(LibraryBackend* theWrappedObject, const QStringList& ids, const QString& table, const QString& column);
QList<Song > GetSongsById(LibraryBackend* theWrappedObject, const QList<int >& ids);
QList<Song > GetSongsById(LibraryBackend* theWrappedObject, const QStringList& ids);
QList<Song > GetSongsByUrl(LibraryBackend* theWrappedObject, const QUrl& url);
bool HasCompilations(LibraryBackend* theWrappedObject, const QueryOptions& opt = QueryOptions());
void IncrementPlayCountAsync(LibraryBackend* theWrappedObject, int id);
void IncrementSkipCountAsync(LibraryBackend* theWrappedObject, int id, float progress);
void LoadDirectoriesAsync(LibraryBackend* theWrappedObject);
void RemoveDirectory(LibraryBackend* theWrappedObject, const Directory& dir);
void ResetStatisticsAsync(LibraryBackend* theWrappedObject, int id);
QList<Subdirectory > SubdirsInDirectory(LibraryBackend* theWrappedObject, int id);
void UpdateManualAlbumArtAsync(LibraryBackend* theWrappedObject, const QString& artist, const QString& album, const QString& art);
void UpdateSongRatingAsync(LibraryBackend* theWrappedObject, int id, float rating);
void UpdateTotalSongCountAsync(LibraryBackend* theWrappedObject);
QString dirs_table(LibraryBackend* theWrappedObject) const;
QString songs_table(LibraryBackend* theWrappedObject) const;
QString subdirs_table(LibraryBackend* theWrappedObject) const;
};
class PythonQtShell_LibraryBackendInterface : public LibraryBackendInterface
{
public:
PythonQtShell_LibraryBackendInterface(QObject* parent = 0):LibraryBackendInterface(parent),_wrapper(NULL) {};
virtual void AddDirectory(const QString& path);
virtual void ChangeDirPath(int id, const QString& old_path, const QString& new_path);
virtual bool ExecQuery(LibraryQuery* q);
virtual QList<Song > FindSongsInDirectory(int id);
virtual LibraryBackendInterface::Album GetAlbumArt(const QString& artist, const QString& album);
virtual QList<LibraryBackendInterface::Album > GetAlbumsByArtist(const QString& artist, const QueryOptions& opt = QueryOptions());
virtual QList<LibraryBackendInterface::Album > GetAllAlbums(const QueryOptions& opt = QueryOptions());
virtual QStringList GetAllArtists(const QueryOptions& opt = QueryOptions());
virtual QStringList GetAllArtistsWithAlbums(const QueryOptions& opt = QueryOptions());
virtual QList<Directory > GetAllDirectories();
virtual QList<LibraryBackendInterface::Album > GetCompilationAlbums(const QueryOptions& opt = QueryOptions());
virtual QList<Song > GetCompilationSongs(const QString& album, const QueryOptions& opt = QueryOptions());
virtual Song GetSongById(int id);
virtual Song GetSongByUrl(const QUrl& url, qint64 beginning = 0);
virtual QList<Song > GetSongs(const QString& artist, const QString& album, const QueryOptions& opt = QueryOptions());
virtual QList<Song > GetSongsByUrl(const QUrl& url);
virtual bool HasCompilations(const QueryOptions& opt = QueryOptions());
virtual void LoadDirectoriesAsync();
virtual void RemoveDirectory(const Directory& dir);
virtual QList<Subdirectory > SubdirsInDirectory(int id);
virtual void UpdateManualAlbumArtAsync(const QString& artist, const QString& album, const QString& art);
virtual void UpdateTotalSongCountAsync();
virtual void childEvent(QChildEvent* arg__1);
virtual void customEvent(QEvent* arg__1);
virtual bool event(QEvent* arg__1);
virtual bool eventFilter(QObject* arg__1, QEvent* arg__2);
virtual void timerEvent(QTimerEvent* arg__1);
PythonQtInstanceWrapper* _wrapper;
};
class PythonQtWrapper_LibraryBackendInterface : public QObject
{ Q_OBJECT
public:
public slots:
LibraryBackendInterface* new_LibraryBackendInterface(QObject* parent = 0);
void delete_LibraryBackendInterface(LibraryBackendInterface* obj) { delete obj; }
};
class PythonQtShell_LibraryBackendInterface_Album : public LibraryBackendInterface::Album
{
public:
PythonQtShell_LibraryBackendInterface_Album():LibraryBackendInterface::Album(),_wrapper(NULL) {};
PythonQtShell_LibraryBackendInterface_Album(const QString& _artist, const QString& _album_name, const QString& _art_automatic, const QString& _art_manual, const QUrl& _first_url):LibraryBackendInterface::Album(_artist, _album_name, _art_automatic, _art_manual, _first_url),_wrapper(NULL) {};
PythonQtInstanceWrapper* _wrapper;
};
class PythonQtWrapper_LibraryBackendInterface_Album : public QObject
{ Q_OBJECT
public:
public slots:
LibraryBackendInterface::Album* new_LibraryBackendInterface_Album();
LibraryBackendInterface::Album* new_LibraryBackendInterface_Album(const QString& _artist, const QString& _album_name, const QString& _art_automatic, const QString& _art_manual, const QUrl& _first_url);
LibraryBackendInterface::Album* new_LibraryBackendInterface_Album(const LibraryBackendInterface::Album& other) {
PythonQtShell_LibraryBackendInterface_Album* a = new PythonQtShell_LibraryBackendInterface_Album();
*((LibraryBackendInterface::Album*)a) = other;
return a; }
void delete_LibraryBackendInterface_Album(LibraryBackendInterface::Album* obj) { delete obj; }
void py_set_art_automatic(LibraryBackendInterface::Album* theWrappedObject, QString art_automatic){ theWrappedObject->art_automatic = art_automatic; }
QString py_get_art_automatic(LibraryBackendInterface::Album* theWrappedObject){ return theWrappedObject->art_automatic; }
void py_set_artist(LibraryBackendInterface::Album* theWrappedObject, QString artist){ theWrappedObject->artist = artist; }
QString py_get_artist(LibraryBackendInterface::Album* theWrappedObject){ return theWrappedObject->artist; }
void py_set_album_name(LibraryBackendInterface::Album* theWrappedObject, QString album_name){ theWrappedObject->album_name = album_name; }
QString py_get_album_name(LibraryBackendInterface::Album* theWrappedObject){ return theWrappedObject->album_name; }
void py_set_first_url(LibraryBackendInterface::Album* theWrappedObject, QUrl first_url){ theWrappedObject->first_url = first_url; }
QUrl py_get_first_url(LibraryBackendInterface::Album* theWrappedObject){ return theWrappedObject->first_url; }
void py_set_art_manual(LibraryBackendInterface::Album* theWrappedObject, QString art_manual){ theWrappedObject->art_manual = art_manual; }
QString py_get_art_manual(LibraryBackendInterface::Album* theWrappedObject){ return theWrappedObject->art_manual; }
};
class PythonQtWrapper_LibraryQuery : public QObject
{ Q_OBJECT
public:
public slots:
LibraryQuery* new_LibraryQuery(const QueryOptions& options = QueryOptions());
void delete_LibraryQuery(LibraryQuery* obj) { delete obj; }
void AddCompilationRequirement(LibraryQuery* theWrappedObject, bool compilation);
void AddWhere(LibraryQuery* theWrappedObject, const QString& column, const QVariant& value, const QString& op = "=");
bool Next(LibraryQuery* theWrappedObject);
void SetColumnSpec(LibraryQuery* theWrappedObject, const QString& spec);
void SetIncludeUnavailable(LibraryQuery* theWrappedObject, bool include_unavailable);
void SetLimit(LibraryQuery* theWrappedObject, int limit);
void SetOrderBy(LibraryQuery* theWrappedObject, const QString& order_by);
QVariant Value(LibraryQuery* theWrappedObject, int column) const;
};
class PythonQtShell_NetworkAccessManager : public NetworkAccessManager
{
public:
@ -217,6 +467,82 @@ void delete_NetworkTimeouts(NetworkTimeouts* obj) { delete obj; }
class PythonQtWrapper_Player : public QObject
{ Q_OBJECT
public:
public slots:
void delete_Player(Player* obj) { delete obj; }
Engine::State GetState(Player* theWrappedObject) const;
int GetVolume(Player* theWrappedObject) const;
void Init(Player* theWrappedObject);
void RegisterUrlHandler(Player* theWrappedObject, UrlHandler* handler);
void UnregisterUrlHandler(Player* theWrappedObject, UrlHandler* handler);
Engine::Base* engine(Player* theWrappedObject) const;
};
class PythonQtShell_PlaylistParser : public PlaylistParser
{
public:
PythonQtShell_PlaylistParser(LibraryBackendInterface* library, QObject* parent = 0):PlaylistParser(library, parent),_wrapper(NULL) {};
virtual void childEvent(QChildEvent* arg__1);
virtual void customEvent(QEvent* arg__1);
virtual bool event(QEvent* arg__1);
virtual bool eventFilter(QObject* arg__1, QEvent* arg__2);
virtual void timerEvent(QTimerEvent* arg__1);
PythonQtInstanceWrapper* _wrapper;
};
class PythonQtWrapper_PlaylistParser : public QObject
{ Q_OBJECT
public:
public slots:
PlaylistParser* new_PlaylistParser(LibraryBackendInterface* library, QObject* parent = 0);
void delete_PlaylistParser(PlaylistParser* obj) { delete obj; }
QList<Song > LoadFromDevice(PlaylistParser* theWrappedObject, QIODevice* device, const QString& path_hint = QString(), const QDir& dir_hint = QDir()) const;
QList<Song > LoadFromFile(PlaylistParser* theWrappedObject, const QString& filename) const;
void Save(PlaylistParser* theWrappedObject, const QList<Song >& songs, const QString& filename) const;
QString default_extension(PlaylistParser* theWrappedObject) const;
QString default_filter(PlaylistParser* theWrappedObject) const;
QStringList file_extensions(PlaylistParser* theWrappedObject) const;
QString filters(PlaylistParser* theWrappedObject) const;
};
class PythonQtWrapper_QueryOptions : public QObject
{ Q_OBJECT
public:
Q_ENUMS(QueryMode )
enum QueryMode{
QueryMode_All = QueryOptions::QueryMode_All, QueryMode_Duplicates = QueryOptions::QueryMode_Duplicates, QueryMode_Untagged = QueryOptions::QueryMode_Untagged};
public slots:
QueryOptions* new_QueryOptions();
QueryOptions* new_QueryOptions(const QueryOptions& other) {
QueryOptions* a = new QueryOptions();
*((QueryOptions*)a) = other;
return a; }
void delete_QueryOptions(QueryOptions* obj) { delete obj; }
bool Matches(QueryOptions* theWrappedObject, const Song& song) const;
QString filter(QueryOptions* theWrappedObject) const;
int max_age(QueryOptions* theWrappedObject) const;
QueryOptions::QueryMode query_mode(QueryOptions* theWrappedObject) const;
void set_filter(QueryOptions* theWrappedObject, const QString& filter);
void set_max_age(QueryOptions* theWrappedObject, int max_age);
void set_query_mode(QueryOptions* theWrappedObject, QueryOptions::QueryMode query_mode);
};
class PythonQtPublicPromoter_RadioModel : public RadioModel
{ public:
inline Qt::ItemFlags promoted_flags(const QModelIndex& index) const { return RadioModel::flags(index); }
@ -251,6 +577,7 @@ void delete_RadioModel(RadioModel* obj) { delete obj; }
QMimeData* mimeData(RadioModel* theWrappedObject, const QList<QModelIndex >& indexes) const;
QStringList mimeTypes(RadioModel* theWrappedObject) const;
int rowCount(RadioModel* theWrappedObject, const QModelIndex& parent) const;
TaskManager* task_manager(RadioModel* theWrappedObject) const;
};
@ -307,6 +634,231 @@ void delete_RadioService(RadioService* obj) { delete obj; }
class PythonQtShell_Song : public Song
{
public:
PythonQtShell_Song():Song(),_wrapper(NULL) {};
PythonQtShell_Song(const Song& other):Song(other),_wrapper(NULL) {};
PythonQtInstanceWrapper* _wrapper;
};
class PythonQtWrapper_Song : public QObject
{ Q_OBJECT
public:
Q_ENUMS(FileType )
enum FileType{
Type_Unknown = Song::Type_Unknown, Type_Asf = Song::Type_Asf, Type_Flac = Song::Type_Flac, Type_Mp4 = Song::Type_Mp4, Type_Mpc = Song::Type_Mpc, Type_Mpeg = Song::Type_Mpeg, Type_OggFlac = Song::Type_OggFlac, Type_OggSpeex = Song::Type_OggSpeex, Type_OggVorbis = Song::Type_OggVorbis, Type_Aiff = Song::Type_Aiff, Type_Wav = Song::Type_Wav, Type_TrueAudio = Song::Type_TrueAudio, Type_Stream = Song::Type_Stream};
public slots:
Song* new_Song();
Song* new_Song(const Song& other);
void delete_Song(Song* obj) { delete obj; }
QString static_Song_Decode(const QString& tag, const QTextCodec* codec = NULL);
bool HasProperMediaFile(Song* theWrappedObject) const;
void Init(Song* theWrappedObject, const QString& title, const QString& artist, const QString& album, qint64 beginning, qint64 end);
void Init(Song* theWrappedObject, const QString& title, const QString& artist, const QString& album, qint64 length_nanosec);
void InitFromFile(Song* theWrappedObject, const QString& filename, int directory_id);
void InitFromFilePartial(Song* theWrappedObject, const QString& filename);
bool IsEditable(Song* theWrappedObject) const;
bool IsMetadataEqual(Song* theWrappedObject, const Song& other) const;
bool IsOnSameAlbum(Song* theWrappedObject, const Song& other) const;
QString static_Song_JoinSpec(const QString& table);
QImage static_Song_LoadEmbeddedArt(const QString& filename);
QString PrettyLength(Song* theWrappedObject) const;
QString PrettyTitle(Song* theWrappedObject) const;
QString PrettyTitleWithArtist(Song* theWrappedObject) const;
QString PrettyYear(Song* theWrappedObject) const;
bool Save(Song* theWrappedObject) const;
QString TextForFiletype(Song* theWrappedObject) const;
QString static_Song_TextForFiletype(Song::FileType type);
QString TitleWithCompilationArtist(Song* theWrappedObject) const;
const QString* album(Song* theWrappedObject) const;
const QString* albumartist(Song* theWrappedObject) const;
const QString* art_automatic(Song* theWrappedObject) const;
const QString* art_manual(Song* theWrappedObject) const;
const QString* artist(Song* theWrappedObject) const;
const QString* basefilename(Song* theWrappedObject) const;
qint64 beginning_nanosec(Song* theWrappedObject) const;
int bitrate(Song* theWrappedObject) const;
float bpm(Song* theWrappedObject) const;
const QString* comment(Song* theWrappedObject) const;
const QString* composer(Song* theWrappedObject) const;
uint ctime(Song* theWrappedObject) const;
const QString* cue_path(Song* theWrappedObject) const;
int directory_id(Song* theWrappedObject) const;
int disc(Song* theWrappedObject) const;
qint64 end_nanosec(Song* theWrappedObject) const;
int filesize(Song* theWrappedObject) const;
Song::FileType filetype(Song* theWrappedObject) const;
const QString* genre(Song* theWrappedObject) const;
bool has_cue(Song* theWrappedObject) const;
bool has_embedded_cover(Song* theWrappedObject) const;
bool has_manually_unset_cover(Song* theWrappedObject) const;
int id(Song* theWrappedObject) const;
const QImage* image(Song* theWrappedObject) const;
bool is_compilation(Song* theWrappedObject) const;
bool is_stream(Song* theWrappedObject) const;
bool is_unavailable(Song* theWrappedObject) const;
bool is_valid(Song* theWrappedObject) const;
int lastplayed(Song* theWrappedObject) const;
qint64 length_nanosec(Song* theWrappedObject) const;
void manually_unset_cover(Song* theWrappedObject);
uint mtime(Song* theWrappedObject) const;
bool __eq__(Song* theWrappedObject, const Song& other) const;
int playcount(Song* theWrappedObject) const;
float rating(Song* theWrappedObject) const;
int samplerate(Song* theWrappedObject) const;
int score(Song* theWrappedObject) const;
void set_album(Song* theWrappedObject, const QString& v);
void set_albumartist(Song* theWrappedObject, const QString& v);
void set_art_automatic(Song* theWrappedObject, const QString& v);
void set_art_manual(Song* theWrappedObject, const QString& v);
void set_artist(Song* theWrappedObject, const QString& v);
void set_basefilename(Song* theWrappedObject, const QString& v);
void set_beginning_nanosec(Song* theWrappedObject, qint64 v);
void set_bitrate(Song* theWrappedObject, int v);
void set_bpm(Song* theWrappedObject, float v);
void set_comment(Song* theWrappedObject, const QString& v);
void set_compilation(Song* theWrappedObject, bool v);
void set_composer(Song* theWrappedObject, const QString& v);
void set_ctime(Song* theWrappedObject, int v);
void set_cue_path(Song* theWrappedObject, const QString& v);
void set_directory_id(Song* theWrappedObject, int v);
void set_disc(Song* theWrappedObject, int v);
void set_embedded_cover(Song* theWrappedObject);
void set_end_nanosec(Song* theWrappedObject, qint64 v);
void set_filesize(Song* theWrappedObject, int v);
void set_filetype(Song* theWrappedObject, Song::FileType v);
void set_forced_compilation_off(Song* theWrappedObject, bool v);
void set_forced_compilation_on(Song* theWrappedObject, bool v);
void set_genre(Song* theWrappedObject, const QString& v);
void set_genre_id3(Song* theWrappedObject, int id);
void set_id(Song* theWrappedObject, int id);
void set_image(Song* theWrappedObject, const QImage& i);
void set_lastplayed(Song* theWrappedObject, int v);
void set_length_nanosec(Song* theWrappedObject, qint64 v);
void set_mtime(Song* theWrappedObject, int v);
void set_playcount(Song* theWrappedObject, int v);
void set_rating(Song* theWrappedObject, float v);
void set_sampler(Song* theWrappedObject, bool v);
void set_samplerate(Song* theWrappedObject, int v);
void set_score(Song* theWrappedObject, int v);
void set_skipcount(Song* theWrappedObject, int v);
void set_title(Song* theWrappedObject, const QString& v);
void set_track(Song* theWrappedObject, int v);
void set_unavailable(Song* theWrappedObject, bool v);
void set_url(Song* theWrappedObject, const QUrl& v);
void set_valid(Song* theWrappedObject, bool v);
void set_year(Song* theWrappedObject, int v);
int skipcount(Song* theWrappedObject) const;
const QString* title(Song* theWrappedObject) const;
int track(Song* theWrappedObject) const;
const QUrl* url(Song* theWrappedObject) const;
int year(Song* theWrappedObject) const;
};
class PythonQtShell_Subdirectory : public Subdirectory
{
public:
PythonQtShell_Subdirectory():Subdirectory(),_wrapper(NULL) {};
PythonQtInstanceWrapper* _wrapper;
};
class PythonQtWrapper_Subdirectory : public QObject
{ Q_OBJECT
public:
public slots:
Subdirectory* new_Subdirectory();
Subdirectory* new_Subdirectory(const Subdirectory& other) {
PythonQtShell_Subdirectory* a = new PythonQtShell_Subdirectory();
*((Subdirectory*)a) = other;
return a; }
void delete_Subdirectory(Subdirectory* obj) { delete obj; }
void py_set_mtime(Subdirectory* theWrappedObject, uint mtime){ theWrappedObject->mtime = mtime; }
uint py_get_mtime(Subdirectory* theWrappedObject){ return theWrappedObject->mtime; }
void py_set_path(Subdirectory* theWrappedObject, QString path){ theWrappedObject->path = path; }
QString py_get_path(Subdirectory* theWrappedObject){ return theWrappedObject->path; }
void py_set_directory_id(Subdirectory* theWrappedObject, int directory_id){ theWrappedObject->directory_id = directory_id; }
int py_get_directory_id(Subdirectory* theWrappedObject){ return theWrappedObject->directory_id; }
};
class PythonQtShell_TaskManager : public TaskManager
{
public:
PythonQtShell_TaskManager(QObject* parent = 0):TaskManager(parent),_wrapper(NULL) {};
virtual void childEvent(QChildEvent* arg__1);
virtual void customEvent(QEvent* arg__1);
virtual bool event(QEvent* arg__1);
virtual bool eventFilter(QObject* arg__1, QEvent* arg__2);
virtual void timerEvent(QTimerEvent* arg__1);
PythonQtInstanceWrapper* _wrapper;
};
class PythonQtWrapper_TaskManager : public QObject
{ Q_OBJECT
public:
public slots:
TaskManager* new_TaskManager(QObject* parent = 0);
void delete_TaskManager(TaskManager* obj) { delete obj; }
QList<TaskManager::Task > GetTasks(TaskManager* theWrappedObject);
void SetTaskBlocksLibraryScans(TaskManager* theWrappedObject, int id);
void SetTaskFinished(TaskManager* theWrappedObject, int id);
void SetTaskProgress(TaskManager* theWrappedObject, int id, int progress, int max = 0);
int StartTask(TaskManager* theWrappedObject, const QString& name);
};
class PythonQtShell_TaskManager_Task : public TaskManager::Task
{
public:
PythonQtShell_TaskManager_Task():TaskManager::Task(),_wrapper(NULL) {};
PythonQtInstanceWrapper* _wrapper;
};
class PythonQtWrapper_TaskManager_Task : public QObject
{ Q_OBJECT
public:
public slots:
TaskManager::Task* new_TaskManager_Task();
TaskManager::Task* new_TaskManager_Task(const TaskManager::Task& other) {
PythonQtShell_TaskManager_Task* a = new PythonQtShell_TaskManager_Task();
*((TaskManager::Task*)a) = other;
return a; }
void delete_TaskManager_Task(TaskManager::Task* obj) { delete obj; }
void py_set_progress_max(TaskManager::Task* theWrappedObject, int progress_max){ theWrappedObject->progress_max = progress_max; }
int py_get_progress_max(TaskManager::Task* theWrappedObject){ return theWrappedObject->progress_max; }
void py_set_progress(TaskManager::Task* theWrappedObject, int progress){ theWrappedObject->progress = progress; }
int py_get_progress(TaskManager::Task* theWrappedObject){ return theWrappedObject->progress; }
void py_set_id(TaskManager::Task* theWrappedObject, int id){ theWrappedObject->id = id; }
int py_get_id(TaskManager::Task* theWrappedObject){ return theWrappedObject->id; }
void py_set_name(TaskManager::Task* theWrappedObject, QString name){ theWrappedObject->name = name; }
QString py_get_name(TaskManager::Task* theWrappedObject){ return theWrappedObject->name; }
void py_set_blocks_library_scans(TaskManager::Task* theWrappedObject, bool blocks_library_scans){ theWrappedObject->blocks_library_scans = blocks_library_scans; }
bool py_get_blocks_library_scans(TaskManager::Task* theWrappedObject){ return theWrappedObject->blocks_library_scans; }
};
class PythonQtShell_ThreadSafeNetworkDiskCache : public ThreadSafeNetworkDiskCache
{
public:

View File

@ -8,10 +8,22 @@ PythonQt::priv()->registerClass(&CoverProvider::staticMetaObject, "Clementine",
PythonQt::priv()->registerClass(&CoverProviderFactory::staticMetaObject, "Clementine", PythonQtCreateObject<PythonQtWrapper_CoverProviderFactory>, PythonQtSetInstanceWrapperOnShell<PythonQtShell_CoverProviderFactory>, module, 0);
PythonQt::priv()->registerClass(&CoverProviders::staticMetaObject, "Clementine", PythonQtCreateObject<PythonQtWrapper_CoverProviders>, NULL, module, 0);
PythonQt::priv()->registerCPPClass("CoverSearchResults", "", "Clementine", PythonQtCreateObject<PythonQtWrapper_CoverSearchResults>, NULL, module, 0);
PythonQt::priv()->registerCPPClass("Directory", "", "Clementine", PythonQtCreateObject<PythonQtWrapper_Directory>, PythonQtSetInstanceWrapperOnShell<PythonQtShell_Directory>, module, 0);
PythonQt::priv()->registerClass(&LibraryBackend::staticMetaObject, "Clementine", PythonQtCreateObject<PythonQtWrapper_LibraryBackend>, PythonQtSetInstanceWrapperOnShell<PythonQtShell_LibraryBackend>, module, 0);
PythonQt::priv()->registerClass(&LibraryBackendInterface::staticMetaObject, "Clementine", PythonQtCreateObject<PythonQtWrapper_LibraryBackendInterface>, PythonQtSetInstanceWrapperOnShell<PythonQtShell_LibraryBackendInterface>, module, 0);
PythonQt::priv()->registerCPPClass("LibraryBackendInterface::Album", "", "Clementine", PythonQtCreateObject<PythonQtWrapper_LibraryBackendInterface_Album>, PythonQtSetInstanceWrapperOnShell<PythonQtShell_LibraryBackendInterface_Album>, module, 0);
PythonQt::priv()->registerCPPClass("LibraryQuery", "", "Clementine", PythonQtCreateObject<PythonQtWrapper_LibraryQuery>, NULL, module, 0);
PythonQt::priv()->registerClass(&NetworkAccessManager::staticMetaObject, "Clementine", PythonQtCreateObject<PythonQtWrapper_NetworkAccessManager>, PythonQtSetInstanceWrapperOnShell<PythonQtShell_NetworkAccessManager>, module, 0);
PythonQt::priv()->registerClass(&NetworkTimeouts::staticMetaObject, "Clementine", PythonQtCreateObject<PythonQtWrapper_NetworkTimeouts>, PythonQtSetInstanceWrapperOnShell<PythonQtShell_NetworkTimeouts>, module, 0);
PythonQt::priv()->registerClass(&Player::staticMetaObject, "Clementine", PythonQtCreateObject<PythonQtWrapper_Player>, NULL, module, 0);
PythonQt::priv()->registerClass(&PlaylistParser::staticMetaObject, "Clementine", PythonQtCreateObject<PythonQtWrapper_PlaylistParser>, PythonQtSetInstanceWrapperOnShell<PythonQtShell_PlaylistParser>, module, 0);
PythonQt::priv()->registerCPPClass("QueryOptions", "", "Clementine", PythonQtCreateObject<PythonQtWrapper_QueryOptions>, NULL, module, 0);
PythonQt::priv()->registerClass(&RadioModel::staticMetaObject, "Clementine", PythonQtCreateObject<PythonQtWrapper_RadioModel>, NULL, module, 0);
PythonQt::priv()->registerClass(&RadioService::staticMetaObject, "Clementine", PythonQtCreateObject<PythonQtWrapper_RadioService>, PythonQtSetInstanceWrapperOnShell<PythonQtShell_RadioService>, module, 0);
PythonQt::priv()->registerCPPClass("Song", "", "Clementine", PythonQtCreateObject<PythonQtWrapper_Song>, PythonQtSetInstanceWrapperOnShell<PythonQtShell_Song>, module, PythonQt::Type_RichCompare);
PythonQt::priv()->registerCPPClass("Subdirectory", "", "Clementine", PythonQtCreateObject<PythonQtWrapper_Subdirectory>, PythonQtSetInstanceWrapperOnShell<PythonQtShell_Subdirectory>, module, 0);
PythonQt::priv()->registerClass(&TaskManager::staticMetaObject, "Clementine", PythonQtCreateObject<PythonQtWrapper_TaskManager>, PythonQtSetInstanceWrapperOnShell<PythonQtShell_TaskManager>, module, 0);
PythonQt::priv()->registerCPPClass("TaskManager::Task", "", "Clementine", PythonQtCreateObject<PythonQtWrapper_TaskManager_Task>, PythonQtSetInstanceWrapperOnShell<PythonQtShell_TaskManager_Task>, module, 0);
PythonQt::priv()->registerClass(&ThreadSafeNetworkDiskCache::staticMetaObject, "Clementine", PythonQtCreateObject<PythonQtWrapper_ThreadSafeNetworkDiskCache>, PythonQtSetInstanceWrapperOnShell<PythonQtShell_ThreadSafeNetworkDiskCache>, module, 0);
PythonQt::priv()->registerClass(&UrlHandler::staticMetaObject, "Clementine", PythonQtCreateObject<PythonQtWrapper_UrlHandler>, PythonQtSetInstanceWrapperOnShell<PythonQtShell_UrlHandler>, module, 0);
PythonQt::priv()->registerCPPClass("UrlHandler::LoadResult", "", "Clementine", PythonQtCreateObject<PythonQtWrapper_UrlHandler_LoadResult>, PythonQtSetInstanceWrapperOnShell<PythonQtShell_UrlHandler_LoadResult>, module, 0);

View File

@ -32,7 +32,9 @@ class Database;
namespace smart_playlists { class Search; }
class LibraryBackendInterface : public QObject {
public:
Q_OBJECT
public:
LibraryBackendInterface(QObject* parent = 0) : QObject(parent) {}
virtual ~LibraryBackendInterface() {}

View File

@ -194,6 +194,7 @@ int main(int argc, char *argv[]) {
qRegisterMetaType<SubdirectoryList>("SubdirectoryList");
qRegisterMetaType<Song>("Song");
qRegisterMetaType<SongList>("SongList");
qRegisterMetaType<QList<Song> >("QList<Song>");
qRegisterMetaType<PlaylistItemList>("PlaylistItemList");
qRegisterMetaType<Engine::State>("Engine::State");
qRegisterMetaType<Engine::SimpleMetaBundle>("Engine::SimpleMetaBundle");

View File

@ -18,13 +18,20 @@
#ifndef BINDINGS_INCLUDES_H
#define BINDINGS_INCLUDES_H
#include "core/player.h"
#include "core/network.h"
#include "core/song.h"
#include "core/taskmanager.h"
#include "core/urlhandler.h"
#include "covers/albumcoverfetcher.h"
#include "covers/albumcoverfetchersearch.h"
#include "covers/coverprovider.h"
#include "covers/coverproviderfactory.h"
#include "covers/coverproviders.h"
#include "engines/enginebase.h"
#include "library/librarybackend.h"
#include "library/libraryquery.h"
#include "playlistparsers/playlistparser.h"
#include "radio/radiomodel.h"
#include "radio/radioservice.h"

View File

@ -0,0 +1,22 @@
/* This file is part of Clementine.
Copyright 2010, David Sansome <me@davidsansome.com>
Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Clementine 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "objectdecorators.h"
void ObjectDecorators::deleteLater(QObject* self) {
self->deleteLater();
}

View File

@ -0,0 +1,30 @@
/* This file is part of Clementine.
Copyright 2010, David Sansome <me@davidsansome.com>
Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Clementine 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OBJECTDECORATORS_H
#define OBJECTDECORATORS_H
#include <QObject>
class ObjectDecorators : public QObject {
Q_OBJECT
public slots:
void deleteLater(QObject* self);
};
#endif // OBJECTDECORATORS_H

View File

@ -21,6 +21,7 @@
#include <com_trolltech_qt_network/com_trolltech_qt_network_init.h>
#include <com_trolltech_qt_uitools/com_trolltech_qt_uitools_init.h>
#include "objectdecorators.h"
#include "pythonengine.h"
#include "pythonscript.h"
#include "core/logging.h"
@ -83,6 +84,7 @@ bool PythonEngine::EnsureInitialised() {
PythonQt* python_qt = PythonQt::self();
python_qt->installDefaultImporter();
python_qt->addDecorators(new ObjectDecorators);
connect(python_qt, SIGNAL(pythonStdOut(QString)), SLOT(PythonStdOut(QString)));
connect(python_qt, SIGNAL(pythonStdErr(QString)), SLOT(PythonStdErr(QString)));

View File

@ -38,16 +38,36 @@ bool PythonScript::Init() {
engine_->manager()->AddLogLine("Python",
"Loading script file \"" + info().script_file() + "\"", false);
// Load the script
module_ = PythonQt::self()->createModuleFromFile(module_name_, info().script_file());
if (!module_) {
engine_->manager()->AddLogLine("Python", "Failed to create module for script", true);
return false;
}
PythonQt* python_qt = PythonQt::self();
// Create a module for the script
module_ = python_qt->createModuleFromScript(module_name_);
// Set __path__ - don't use PythonQtObjectPtr::addVariable because it sets
// it as a tuple instead of a list.
PyObject* __path__ = PyList_New(1);
PyList_SetItem(__path__, 0, PyString_FromString(info().path().toLocal8Bit().constData()));
PyModule_AddObject(module_, "__path__", __path__);
// Set script object
module_.addObject("script", interface());
// Eval the script
PythonQtObjectPtr code = python_qt->parseFile(info().script_file());
if (code) {
PyObject* dict = PyModule_GetDict(module_);
PyObject* r = PyEval_EvalCode((PyCodeObject*)code.object(), dict, dict);
if (r) {
Py_DECREF(r);
}
}
if (PyErr_Occurred()) {
PythonQt::self()->handleError();
engine_->manager()->AddLogLine("Python", "Failed to create module for script", true);
return false;
}
return true;
}

View File

@ -3,13 +3,25 @@
<load-typesystem name="typesystem_gui.xml" generate="no" />
<load-typesystem name="typesystem_network.xml" generate="no" />
<enum-type name="Engine::State" />
<enum-type name="QueryOptions::QueryMode" />
<enum-type name="RadioModel::PlayBehaviour" />
<enum-type name="RadioModel::Role" />
<enum-type name="RadioModel::Type" />
<enum-type name="RadioService::AddMode" />
<enum-type name="Song::FileType" />
<enum-type name="UrlHandler::LoadResult::Type" />
<value-type name="CoverSearchResults" />
<value-type name="Directory" />
<value-type name="LibraryBackendInterface::Album" />
<value-type name="QueryOptions" />
<value-type name="Song">
<modify-function signature="BackgroundSave()const" remove="all" />
</value-type>
<value-type name="Subdirectory" />
<value-type name="TaskManager::Task" />
<value-type name="UrlHandler::LoadResult" />
<object-type name="AlbumCoverFetcherSearch">
@ -20,14 +32,21 @@
<object-type name="CoverProvider" />
<object-type name="CoverProviderFactory" />
<object-type name="CoverProviders" />
<object-type name="Engine::Base" />
<object-type name="LibraryBackend" />
<object-type name="LibraryBackendInterface" />
<object-type name="LibraryQuery">
<modify-function signature="operator const QSqlQuery&amp;()const" remove="all" />
</object-type>
<object-type name="NetworkAccessManager" />
<object-type name="NetworkTimeouts">
<modify-function signature="timerEvent(QTimerEvent*)">
<remove/>
</modify-function>
<modify-function signature="timerEvent(QTimerEvent*)" remove="all" />
</object-type>
<object-type name="Player" />
<object-type name="PlaylistParser" />
<object-type name="RadioModel" />
<object-type name="RadioService" />
<object-type name="TaskManager" />
<object-type name="ThreadSafeNetworkDiskCache" />
<object-type name="UrlHandler" />
</typesystem>