2008-08-31 09:08:24 +00:00
|
|
|
#ifndef MIRC_H
|
|
|
|
#define MIRC_H
|
|
|
|
|
|
|
|
#include <QObject>
|
2009-04-22 18:24:39 +00:00
|
|
|
#include <QDebug>
|
2008-08-31 09:08:24 +00:00
|
|
|
#include <QString>
|
2009-04-17 02:45:22 +00:00
|
|
|
#include <QStringList>
|
2008-08-31 09:08:24 +00:00
|
|
|
#include <QMap>
|
2008-08-31 09:50:57 +00:00
|
|
|
#include <QVector>
|
2009-04-17 02:45:22 +00:00
|
|
|
#include <QTextStream>
|
2008-08-31 09:08:24 +00:00
|
|
|
#include "script.h"
|
2009-04-17 02:45:22 +00:00
|
|
|
#include "parser.h"
|
2008-08-31 09:08:24 +00:00
|
|
|
|
2009-04-22 18:24:39 +00:00
|
|
|
#define MIRC_VERSION "0.1"
|
|
|
|
|
2008-08-31 09:50:57 +00:00
|
|
|
class MIRCScript;
|
|
|
|
|
2009-05-05 21:10:34 +00:00
|
|
|
typedef function< void(QStringList) > _MIRCAliasHandler;
|
|
|
|
|
2008-08-31 09:08:24 +00:00
|
|
|
class MIRCScriptManager : public QObject {
|
|
|
|
Q_OBJECT
|
2008-08-31 09:50:57 +00:00
|
|
|
private:
|
|
|
|
QObject *parent;
|
2009-04-23 15:29:37 +00:00
|
|
|
QVector<MIRCScript*> scripts;
|
2008-08-31 09:50:57 +00:00
|
|
|
QMap<QString, QString> _variables;
|
2009-05-05 21:10:34 +00:00
|
|
|
QMap<QString,_MIRCAliasHandler> internal_aliases;
|
2009-04-22 18:24:39 +00:00
|
|
|
QString _return_value;
|
2009-04-17 02:45:22 +00:00
|
|
|
QTextStream *output;
|
2009-05-05 18:14:05 +00:00
|
|
|
MIRCScript* current_script;
|
|
|
|
int line_offset;
|
|
|
|
|
2008-08-31 09:08:24 +00:00
|
|
|
public:
|
2008-08-31 09:50:57 +00:00
|
|
|
MIRCScriptManager(QObject *parent = 0);
|
2009-04-23 15:29:37 +00:00
|
|
|
|
2008-08-31 09:50:57 +00:00
|
|
|
bool load(QString filename);
|
2009-04-23 15:29:37 +00:00
|
|
|
/*
|
2008-08-31 09:50:57 +00:00
|
|
|
bool unload(QString filename);
|
|
|
|
*/
|
2009-04-17 02:45:22 +00:00
|
|
|
void call_alias(QString alias, QStringList arguments);
|
2009-05-05 21:10:34 +00:00
|
|
|
bool register_alias(QString alias, _MIRCAliasHandler fn);
|
2009-04-17 02:45:22 +00:00
|
|
|
|
2008-08-31 17:00:39 +00:00
|
|
|
bool hasVariable(QString variable);
|
|
|
|
QString variable(QString variable);
|
|
|
|
void variable(QString variable, QString value);
|
|
|
|
QMap<QString, QString> variables();
|
2009-04-22 18:24:39 +00:00
|
|
|
QString return_value();
|
2009-05-05 21:10:34 +00:00
|
|
|
|
|
|
|
// Builtin aliases
|
|
|
|
void _alias_line(QStringList);
|
|
|
|
void _alias_lower(QStringList arguments);
|
|
|
|
void _alias_return(QStringList arguments);
|
|
|
|
void _alias_version(QStringList);
|
2009-04-22 18:24:39 +00:00
|
|
|
public slots:
|
|
|
|
void return_value(QString value);
|
2009-04-17 05:05:43 +00:00
|
|
|
signals:
|
|
|
|
void unknown_alias(QString alias, QStringList arguments);
|
2008-08-31 09:08:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|