aboutsummaryrefslogtreecommitdiff
path: root/qmidiplayer-desktop
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2016-04-23 23:50:31 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2016-04-23 23:50:31 +0800
commitaa8af83ff8889aa136e9152b2cca9a88d99c5f47 (patch)
tree54af0c407c08d86c1fbf5e5856ee66c4f80e1b0b /qmidiplayer-desktop
parent446263beafeafa831530a6f9711aa891955b7db3 (diff)
downloadQMidiPlayer-aa8af83ff8889aa136e9152b2cca9a88d99c5f47.tar.xz
Add stubs for plugin support.
Diffstat (limited to 'qmidiplayer-desktop')
-rw-r--r--qmidiplayer-desktop/qmidiplayer-desktop.pro9
-rw-r--r--qmidiplayer-desktop/qmpchannelswindow.hpp4
-rw-r--r--qmidiplayer-desktop/qmphelpwindow.hpp2
-rw-r--r--qmidiplayer-desktop/qmpmainwindow.cpp4
-rw-r--r--qmidiplayer-desktop/qmpmainwindow.hpp3
-rw-r--r--qmidiplayer-desktop/qmpplugin.cpp58
-rw-r--r--qmidiplayer-desktop/qmpplugin.hpp26
-rw-r--r--qmidiplayer-desktop/qmpsettingswindow.hpp2
8 files changed, 99 insertions, 9 deletions
diff --git a/qmidiplayer-desktop/qmidiplayer-desktop.pro b/qmidiplayer-desktop/qmidiplayer-desktop.pro
index 4eaf3dd..9e169e6 100644
--- a/qmidiplayer-desktop/qmidiplayer-desktop.pro
+++ b/qmidiplayer-desktop/qmidiplayer-desktop.pro
@@ -26,7 +26,8 @@ SOURCES += main.cpp\
qmpsettingswindow.cpp \
qmphelpwindow.cpp \
qdialskulpturestyle.cpp \
- ../core/qmpmidimapperrtmidi.cpp
+ ../core/qmpmidimapperrtmidi.cpp \
+ qmpplugin.cpp
HEADERS += qmpmainwindow.hpp \
../core/qmpmidiplay.hpp \
@@ -39,7 +40,9 @@ HEADERS += qmpmainwindow.hpp \
qmpsettingswindow.hpp \
qmphelpwindow.hpp \
qdialskulpturestyle.hpp \
- ../core/qmpmidimappers.hpp
+ ../core/qmpmidimappers.hpp \
+ ../include/qmpcorepublic.hpp \
+ qmpplugin.hpp
FORMS += qmpmainwindow.ui \
qmpplistwindow.ui \
@@ -78,7 +81,7 @@ unix{
menu.path = $${DATADIR}/menu
menu.files += ./menu/$${TARGET}
QMAKE_CXXFLAGS += -Wall
- LIBS += -lfluidsynth -lrtmidi
+ LIBS += -lfluidsynth -lrtmidi -ldl
}
win32{
#change these before building...
diff --git a/qmidiplayer-desktop/qmpchannelswindow.hpp b/qmidiplayer-desktop/qmpchannelswindow.hpp
index fef6ab7..15a53d6 100644
--- a/qmidiplayer-desktop/qmpchannelswindow.hpp
+++ b/qmidiplayer-desktop/qmpchannelswindow.hpp
@@ -59,11 +59,11 @@ class QDCComboBox:public QComboBox
void indexChangedSlot(int idx){emit(onChange(id,idx));}
};
-class qmpCWNoteOnCB:public QObject,public CMidiCallBack
+class qmpCWNoteOnCB:public QObject,public IMidiCallBack
{
Q_OBJECT
public:
- void callBack(void *data){if(data)data=NULL;emit(onNoteOn());}
+ void callBack(void*,void*){emit onNoteOn();}
signals:
void onNoteOn();
};
diff --git a/qmidiplayer-desktop/qmphelpwindow.hpp b/qmidiplayer-desktop/qmphelpwindow.hpp
index 8264fcd..209a753 100644
--- a/qmidiplayer-desktop/qmphelpwindow.hpp
+++ b/qmidiplayer-desktop/qmphelpwindow.hpp
@@ -2,7 +2,7 @@
#define QMPHELPWINDOW_H
#include <QDialog>
-#define APP_VERSION "0.7.2"
+#define APP_VERSION "0.7.8"
namespace Ui {
class qmpHelpWindow;
diff --git a/qmidiplayer-desktop/qmpmainwindow.cpp b/qmidiplayer-desktop/qmpmainwindow.cpp
index 73c2895..84697a4 100644
--- a/qmidiplayer-desktop/qmpmainwindow.cpp
+++ b/qmidiplayer-desktop/qmpmainwindow.cpp
@@ -49,7 +49,7 @@ qmpMainWindow::qmpMainWindow(QWidget *parent) :
ui->lnPolyphone->display("00000-00000");
ui->lbFileName->setText("");ref=this;
playing=false;stopped=true;dragging=false;
- settingsw=new qmpSettingsWindow(this);
+ settingsw=new qmpSettingsWindow(this);pmgr=new qmpPluginManager();
plistw=new qmpPlistWindow(this);player=NULL;timer=NULL;
singleFS=qmpSettingsWindow::getSettingsIntf()->value("Behavior/SingleInstance",0).toInt();
}
@@ -58,7 +58,7 @@ qmpMainWindow::~qmpMainWindow()
{
if(player)delete player;
if(timer)delete timer;
- delete ui;
+ delete pmgr;delete ui;
}
void qmpMainWindow::init()
diff --git a/qmidiplayer-desktop/qmpmainwindow.hpp b/qmidiplayer-desktop/qmpmainwindow.hpp
index 2f3876d..b88169b 100644
--- a/qmidiplayer-desktop/qmpmainwindow.hpp
+++ b/qmidiplayer-desktop/qmpmainwindow.hpp
@@ -15,6 +15,7 @@
#include <thread>
#include <chrono>
#include "../core/qmpmidiplay.hpp"
+#include "qmpplugin.hpp"
#include "qmpplistwindow.hpp"
#include "qmpchannelswindow.hpp"
#include "qmpefxwindow.hpp"
@@ -57,6 +58,7 @@ class qmpMainWindow:public QMainWindow
void dragEnterEvent(QDragEnterEvent *event);
~qmpMainWindow();
CMidiPlayer* getPlayer(){return player;}
+ qmpSettingsWindow* getSettingsWindow(){return settingsw;}
QTimer* getTimer(){return timer;}
bool isFinalizing(){return fin;}
QString getFileName();
@@ -95,6 +97,7 @@ class qmpMainWindow:public QMainWindow
std::chrono::steady_clock::time_point st;
double offset;
CMidiPlayer *player;
+ qmpPluginManager *pmgr;
qmpPlistWindow *plistw;
qmpChannelsWindow *chnlw;
qmpEfxWindow *efxw;
diff --git a/qmidiplayer-desktop/qmpplugin.cpp b/qmidiplayer-desktop/qmpplugin.cpp
new file mode 100644
index 0000000..4da1698
--- /dev/null
+++ b/qmidiplayer-desktop/qmpplugin.cpp
@@ -0,0 +1,58 @@
+#ifdef _WIN32
+#include <windows.h>
+#else
+#include <dlfcn.h>
+#include <dirent.h>
+#endif
+#include <cstring>
+#include "qmpplugin.hpp"
+#include "qmpmainwindow.hpp"
+#include "qmpsettingswindow.hpp"
+qmpPluginAPI pluginAPI;
+qmpMainWindow* qmw;
+qmpSettingsWindow* qsw;
+#ifdef _WIN32
+#else
+void qmpPluginManager::scanPlugins()
+{
+ DIR *dir;
+ struct dirent *file;
+ std::vector<std::string> cpluginpaths;
+ if((dir=opendir("/usr/lib/qmidiplayer/")))
+ {
+ while((file=readdir(dir)))
+ if(strcmp(file->d_name+strlen(file->d_name)-3,".so")==0)
+ cpluginpaths.push_back(std::string("/usr/lib/qmidiplayer/")+std::string(file->d_name));
+ closedir(dir);
+ }
+ if((dir=opendir("./")))
+ {
+ while((file=readdir(dir)))
+ if(strcmp(file->d_name+strlen(file->d_name)-3,".so")==0)
+ cpluginpaths.push_back(std::string("./")+std::string(file->d_name));
+ closedir(dir);
+ }
+ for(unsigned i=0;i<cpluginpaths.size();++i)
+ {
+ void* hso=dlopen(cpluginpaths[i].c_str(),RTLD_LAZY);
+ if(!hso){fprintf(stderr,"%s\n",dlerror());continue;}
+ void* hndi=dlsym(hso,"qmpPluginGetInterface");
+ if(!hndi)continue;
+ qmpPluginEntry e=(qmpPluginEntry)hndi;
+ qmpPluginIntf* intf=e(&pluginAPI);
+ plugins.push_back(qmpPlugin(std::string(intf->pluginGetName()),std::string(intf->pluginGetVersion()),std::string(cpluginpaths[i]),intf));
+ }
+}
+#endif
+qmpPluginManager::qmpPluginManager()
+{
+ qmw=qmpMainWindow::getInstance();
+ qsw=qmw->getSettingsWindow();
+}
+qmpPluginManager::~qmpPluginManager()
+{
+ qmw=NULL;qsw=NULL;
+}
+
+uint32_t qmpPluginAPI::getDivision()
+{return qmw->getPlayer()->getDivision();}
diff --git a/qmidiplayer-desktop/qmpplugin.hpp b/qmidiplayer-desktop/qmpplugin.hpp
new file mode 100644
index 0000000..8d14596
--- /dev/null
+++ b/qmidiplayer-desktop/qmpplugin.hpp
@@ -0,0 +1,26 @@
+#ifndef QMPPLUGIN_H
+#define QMPPLUGIN_H
+#include <string>
+#include <vector>
+#include "../include/qmpcorepublic.hpp"
+struct qmpPlugin
+{
+ std::string name,version,path;
+ qmpPluginIntf* interface;
+ bool enabled;
+ qmpPlugin(std::string _n,std::string _v,std::string _p,qmpPluginIntf* _i)
+ {name=_n;version=_v;path=_p;interface=_i;enabled=false;}
+};
+class qmpPluginManager
+{
+ private:
+ std::vector<qmpPlugin> plugins;
+ public:
+ qmpPluginManager();
+ ~qmpPluginManager();
+ std::vector<qmpPlugin> getPlugins() const;
+ void scanPlugins();
+ void initPlugins();
+ void deinitPlugins();
+};
+#endif // QMPPLUGIN_H
diff --git a/qmidiplayer-desktop/qmpsettingswindow.hpp b/qmidiplayer-desktop/qmpsettingswindow.hpp
index cac691e..6c95663 100644
--- a/qmidiplayer-desktop/qmpsettingswindow.hpp
+++ b/qmidiplayer-desktop/qmpsettingswindow.hpp
@@ -38,7 +38,7 @@ class qmpSettingsWindow:public QDialog
void on_cbAutoBS_stateChanged();
- private:
+ private:
Ui::qmpSettingsWindow *ui;
void settingsUpdate();
static QSettings *settings;