00001 /***************************************************************************** 00002 * extensions_manager.hpp: Extensions manager for Qt 00003 **************************************************************************** 00004 * Copyright (C) 2009-2010 VideoLAN and authors 00005 * $Id: 17f5af95727cdc3a9121ef2bf9715990c5b2f67b $ 00006 * 00007 * Authors: Jean-Philippe André < jpeg # videolan.org > 00008 * 00009 * This program is free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * This program is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License 00020 * along with this program; if not, write to the Free Software 00021 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 00022 *****************************************************************************/ 00023 00024 #ifndef EXTENSIONS_MANAGER_HPP 00025 #define EXTENSIONS_MANAGER_HPP 00026 00027 #ifdef HAVE_CONFIG_H 00028 # include "config.h" 00029 #endif 00030 00031 #include <vlc_extensions.h> 00032 00033 #include "qt4.hpp" 00034 00035 #include <QObject> 00036 #include <QMenu> 00037 #include <QSignalMapper> 00038 00039 class ExtensionsDialogProvider; 00040 00041 class ExtensionsManager : public QObject 00042 { 00043 Q_OBJECT 00044 public: 00045 static ExtensionsManager *getInstance( intf_thread_t *_p_intf, 00046 QObject *_parent = 0 ) 00047 { 00048 if( !instance ) 00049 instance = new ExtensionsManager( _p_intf, _parent ); 00050 return instance; 00051 } 00052 static void killInstance() 00053 { 00054 delete instance; 00055 instance = NULL; 00056 } 00057 00058 ExtensionsManager( intf_thread_t *p_intf, QObject *parent ); 00059 virtual ~ExtensionsManager(); 00060 00061 inline bool isLoaded() { return p_extensions_manager != NULL; } 00062 inline bool cannotLoad() { return b_unloading || b_failed; } 00063 inline bool isUnloading() { return b_unloading; } 00064 void menu( QMenu *current ); 00065 00066 /** Get the extensions_manager_t if it is loaded and hold the object */ 00067 extensions_manager_t* getManager() 00068 { 00069 if( !p_extensions_manager ) return NULL; 00070 vlc_object_hold( p_extensions_manager ); 00071 return p_extensions_manager; 00072 } 00073 00074 public slots: 00075 bool loadExtensions(); 00076 void unloadExtensions(); 00077 void reloadExtensions(); 00078 00079 private slots: 00080 void triggerMenu( int id ); 00081 void inputChanged( input_thread_t *p_input ); 00082 void playingChanged( int ); 00083 00084 private: 00085 static ExtensionsManager* instance; 00086 intf_thread_t *p_intf; 00087 extensions_manager_t *p_extensions_manager; 00088 ExtensionsDialogProvider *p_edp; 00089 00090 QSignalMapper *menuMapper; 00091 bool b_unloading; ///< Work around threads + emit issues, see isUnloading 00092 bool b_failed; ///< Flag set to true if we could not load the module 00093 00094 signals: 00095 void extensionsUpdated(); 00096 }; 00097 00098 #endif // EXTENSIONS_MANAGER_HPP
1.5.6