#ifndef UTILS_H
#define UTILS_H
#include <QtGlobal>
#include <QWebFrame>
#include <QFile>
#include "csconverter.h"
#include "encoding.h"
class QTemporaryFile;
class Utils
{
public:
static void showUsage();
static void messageHandler(QtMsgType type, const char *msg);
static bool exceptionHandler(const char* dump_path, const char* minidump_id, void* context, bool succeeded);
static QVariant coffee2js(const QString &script);
static bool injectJsInFrame(const QString &jsFilePath, const QString &libraryPath, QWebFrame *targetFrame, const bool startingScript = false);
static bool injectJsInFrame(const QString &jsFilePath, const Encoding &jsFileEnc, const QString &libraryPath, QWebFrame *targetFrame, const bool startingScript = false);
static QString readResourceFileUtf8(const QString &resourceFilePath);
static bool loadJSForDebug(const QString &jsFilePath, const Encoding &jsFileEnc, const QString &libraryPath, QWebFrame *targetFrame, const bool autorun = false);
static bool loadJSForDebug(const QString &jsFilePath, const QString &libraryPath, QWebFrame *targetFrame, const bool autorun = false);
static void cleanupFromDebug();
private:
static QString findScript(const QString &jsFilePath, const QString& libraryPath);
static QString jsFromScriptFile(const QString& scriptPath, const Encoding& enc);
Utils();
static QTemporaryFile* m_tempHarness; static QTemporaryFile* m_tempWrapper;
};
#endif