예제 #1
0
DatabaseData::DatabaseData(QCA::SecureArray pwOffice) : QObject() {

	this->pwOffice = pwOffice;

	allErr = new Errors;

	cr = new Cryptor(pwOffice);

	reconnectDb = new QTimer;
	reconnectDb->setSingleShot(true);
	connect(reconnectDb, SIGNAL(timeout()), this, SLOT(reconnectDbConnection()));
	dbFileLastMod = 0;

	checkForUpdates = new QTimer;

	checkForUpdates->setInterval(60*1000);
	connect(checkForUpdates, SIGNAL(timeout()), this, SLOT(timerTimeout()));
	checkForUpdates->start();

	// if we don't create a random (and unique) connection name for the database, there will be plenty of error messages lateron
	QCryptographicHash md5(QCryptographicHash::Md5);
	md5.addData(QString("%1").arg(rand()).toLatin1());
	QString u = QString::fromLatin1(md5.result());

	// Set up database connection
	db = QSqlDatabase::addDatabase("QMYSQL",u);
	// GET INITIAL LOGIN DETAILS
	checkDbLogin();

	// and get all initial data
	timerTimeout(true);

}
예제 #2
0
CANCom::CANCom(PRIUSReader& device, double pollingTime) :
    mDevice(device),
    mPollingTime(pollingTime) {
  connect(&mTimer, SIGNAL(timeout()), this, SLOT(timerTimeout()));
  mTimer.setInterval(pollingTime);
  mTimer.start();
}
SensorBrowseControl::SensorBrowseControl(bool showPoints) :
    mUi(new Ui_SensorBrowseControl()),
    mLogFilesize(0),
    mLogFilepos(0),
    mMinDistance(Converter::mMinDistance),
    mMaxDistance(Converter::mMaxDistance) {
  mUi->setupUi(this);
  mLogMenu = mMenu.addMenu("Log");
  mLogStartAction = mLogMenu->addAction("Seek start", this,
    SLOT(logStartClicked()));
  mLogStartAction->setShortcut(Qt::Key_Home);
  mLogPlayAction = mLogMenu->addAction("Play", this,
    SLOT(logPlayTriggered()));
  mLogPlayAction->setCheckable(true);
  mLogPlayAction->setShortcut(Qt::Key_Space);
  mLogSkipAction = mLogMenu->addAction("Skip scan", this,
    SLOT(logSkipClicked()));
  mLogSkipAction->setShortcut(Qt::Key_PageDown);
  mTimer.setSingleShot(true);
  connect(&mTimer, SIGNAL(timeout()), this, SLOT(timerTimeout()));
  mUi->colorChooser->setPalette(&mPalette);
  connect(&mPalette, SIGNAL(colorChanged(const QString&, const QColor&)),
    this, SLOT(colorChanged(const QString&, const QColor&)));
  connect(&View3d::getInstance().getScene(), SIGNAL(render(View3d&, Scene3d&)),
    this, SLOT(render(View3d&, Scene3d&)));
  setPointColor(Qt::gray);
  setPointSize(1.0);
  setShowPoints(showPoints);
  setSmoothPoints(true);
  setCalibrationFilename(mUi->calibrationEdit->text());
  setLogFilename(QDir::current().path());
  setMinDistance(mMinDistance);
  setMaxDistance(mMaxDistance);
}
예제 #4
0
CImageReceiverWorker::CImageReceiverWorker(
        const std::string& prefix,
        size_t bufferId,
        const std::string& url)
//    : mImageBuffer(CImageBuffer::getBufferInstance())
    : mAlert(*CConfig::getInstance().mAlertNotificationConfig, prefix, url)
    , mErrorNumber(0)
    , mBufferId(bufferId)
    , mUrl(url)
{
    mTimer.setInterval(CConfig::getInstance().mConnectionSettings->mTimeOut * MS_IN_SECOND);
    connect(&mTimer, SIGNAL(timeout()), this, SLOT(timerTimeout()));

    mErrorTimer.setInterval(CConfig::getInstance().mInputConfig->mInputList[mBufferId].mTimeOut * MS_IN_SECOND);
    connect(&mErrorTimer, SIGNAL(timeout()), this, SLOT(timerErorTimeout()));

    mRequestTimer.setInterval(CMainFunctions::getSleepTime(mBufferId) * MS_IN_SECOND);
    connect(&mRequestTimer, SIGNAL(timeout()), this, SLOT(timerRequestTimeout()));

    mIncreaseErrorCountTimer.setInterval(CMainFunctions::getSleepTime(mBufferId) * MS_IN_SECOND * 2);
    connect(&mIncreaseErrorCountTimer, SIGNAL(timeout()), this, SLOT(increaseErrorCount()));

    CMainFunctions::addAlgorithm(mAlgorithms);

    mLastId = static_cast<NTypes::tMatIdType>(-1);
}
예제 #5
0
ProgressTree2::ProgressTree2(QWidget *parent) :
    QTreeWidget(parent)
{
    this->autoExpandNodes = false;
    setColumnCount(5);

    timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(timerTimeout()));
    timer->start(1000);

    this->monitoredJobLastChanged = 0;

    setColumnWidth(0, 500);
    setColumnWidth(1, 100);
    setColumnWidth(2, 100);
    setColumnWidth(3, 200);
    setColumnWidth(4, 100);
    header()->setStretchLastSection(false);

    QStringList hls;
    hls.append(QObject::tr("Task / Step"));
    hls.append(QObject::tr("Elapsed time"));
    hls.append(QObject::tr("Remaining time"));
    hls.append(QObject::tr("Progress"));
    hls.append(QObject::tr(""));
    setHeaderLabels(hls);
}
예제 #6
0
MiniPlayer::MiniPlayer(MythScreenStack *parent)
          : MusicCommon(parent, "music_miniplayer")
{
    m_displayTimer = new QTimer(this);
    m_displayTimer->setSingleShot(true);
    connect(m_displayTimer, SIGNAL(timeout()), this, SLOT(timerTimeout()));
}
예제 #7
0
void MyTimer::onTimeout()
{
#if MYTIMER_DEBUG
    qDebug()<<"MyTimer:";
    qDebug()<<"接收到超时信号!";
#endif
    emit timerTimeout(myName);
}
예제 #8
0
ZMMiniPlayer::ZMMiniPlayer(MythScreenStack *parent)
          : ZMLivePlayer(parent, true),
              m_displayTimer(new QTimer(this))
{
    m_displayTimer->setSingleShot(true);
    connect(m_displayTimer, SIGNAL(timeout()), this, SLOT(timerTimeout()));

}
예제 #9
0
MarbleClock::MarbleClock( QObject* parent )
    : QObject( parent ), d( new MarbleClockPrivate( this ) )

{
    connect( &d->m_timer, SIGNAL(timeout()),
             this,    SLOT(timerTimeout()) );
    d->timerTimeout();
}
예제 #10
0
MarkdownHighlighter::MarkdownHighlighter(QTextDocument *_document, int waitInterval) : document(_document)
{
	timer.setSingleShot(true);
	timer.setInterval(waitInterval);
	connect(&timer, SIGNAL(timeout()), this, SLOT(timerTimeout()));
	connect(document, SIGNAL(contentsChange(int,int,int)), this, SLOT(handleContentsChange(int,int,int)));
	this->parse();
}
예제 #11
0
DataReader::DataReader(int t):timerCount(0)
{
	samples = t * SAMPLE_RATE;

	timer = new QTimer(this);
	timer->setInterval(200);
	connect(timer, SIGNAL(timeout()), this, SLOT(timerTimeout()));
}
예제 #12
0
ZMMiniPlayer::ZMMiniPlayer(MythScreenStack *parent)
          : ZMLivePlayer(parent, true),
              m_displayTimer(new QTimer(this)), m_monitorText(nullptr),
              m_statusText(nullptr), m_image(nullptr)
{
    m_displayTimer->setSingleShot(true);
    connect(m_displayTimer, SIGNAL(timeout()), this, SLOT(timerTimeout()));

}
예제 #13
0
UdpSocket::UdpSocket(QObject *parent)
    : QObject(parent)
{
    connect(&socket, SIGNAL(readyRead()), this, SLOT(processPendingData()));

    timer.setInterval(3000);
    timer.start();
    connect(&timer, SIGNAL(timeout()), this, SLOT(timerTimeout()));

}
예제 #14
0
Download::Download(const QString &url, int attempts, QObject *parent) :
    QObject(parent)
{
    downloadUrl = url;
    attemptsTotal = (attempts > 1) ? attempts : 1;
    attemptsUsed = 0;
    networkReply = 0;
    downloadState = !downloadUrl.isEmpty() ? InitialState : FailedState;
    timer.setInterval(REPLY_TIMEOUT);
    connect( &timer, SIGNAL( timeout() ), this, SLOT( timerTimeout() ) );
}
예제 #15
0
DlgCdgPreview::DlgCdgPreview(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::DlgCdgPreview)
{
    ui->setupUi(this);
    cdg = new CDG();
    timer = new QTimer(this);
    timer->stop();
    connect(timer, SIGNAL(timeout()), this, SLOT(timerTimeout()));
    cdgPosition = 0;
    cdgTempDir = NULL;
}
예제 #16
0
void Download::downloadProgress(qint64 bytesRecieved, qint64 bytesTotal)
{
    if ( (bytesRecieved == bytesTotal) && (bytesTotal == 0) )
    {
        timerTimeout();
    }
    else
    {
        timer.stop();
        timer.start();
    }
}
예제 #17
0
void KTimerDialog::slotInternalTimeout()
{
    emit timerTimeout();
    switch ( buttonOnTimeout ) {
        case Help:
            slotButtonClicked(KDialog::Help);
            break;
        case Default:
            slotButtonClicked(KDialog::Default);
            break;
        case Ok:
            slotButtonClicked(KDialog::Ok);
            break;
        case Apply:
            slotButtonClicked(KDialog::Apply);
            break;
        case Try:
            slotButtonClicked(KDialog::Try);
            break;
        case Cancel:
            slotButtonClicked(KDialog::Cancel);
            break;
        case Close:
            slotButtonClicked(KDialog::Close);
            break;
        case User1:
            slotButtonClicked(KDialog::User1);
            break;
        case User2:
            slotButtonClicked(KDialog::User2);
            break;
        case User3:
            slotButtonClicked(KDialog::User3);
            break;
        case No:
            slotButtonClicked(KDialog::No);
            break;
        case Yes:
            slotButtonClicked(KDialog::Cancel);
            break;
        case Details:
            slotButtonClicked(KDialog::Details);
            break;
        case None:
            slotButtonClicked(KDialog::None);
            break;
        case NoDefault:
            slotButtonClicked(KDialog::NoDefault);
            break;     
    }
}
예제 #18
0
void KTimerDialog::slotInternalTimeout()
{
    emit timerTimeout();
    switch(buttonOnTimeout)
    {
        case Help:
            slotHelp();
            break;
        case Default:
            slotDefault();
            break;
        case Ok:
            slotOk();
            break;
        case Apply:
            applyPressed();
            break;
        case Try:
            slotTry();
            break;
        case Cancel:
            slotCancel();
            break;
        case Close:
            slotClose();
            break;
        /*case User1:
            slotUser1();
            break;
        case User2:
            slotUser2();
            break;*/
        case User3:
            slotUser3();
            break;
        case No:
            slotNo();
            break;
        case Yes:
            slotCancel();
            break;
        case Details:
            slotDetails();
            break;
        case Filler:
        case Stretch:
            kdDebug() << "Cannot execute button code " << buttonOnTimeout << endl;
            break;
    }
}
QGCSkyeTestTimerWidget::QGCSkyeTestTimerWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::QGCSkyeTestTimerWidget),
	currentState(QGCSkyeTestTimerWidget::StateContinous)
{
    ui->setupUi(this);

    /* Create timer. Iteratively tell parent to emit signals */
    timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(timerTimeout()));

    /* Connect Widgets */
    connect(ui->checkBoxUseTimer, SIGNAL(toggled(bool)), this, SLOT(toggledCheckBoxUseTimer(bool)));
    connect(ui->pushButtonStart, SIGNAL(clicked()), this, SLOT(clickedPushButtonStart()));
}
예제 #20
0
SessionData::SessionData(QLocalSocket* socket, QObject* parent) : QObject(parent),
                                                                  socket(socket),
                                                                  interval(-1),
                                                                  buffer(0),
                                                                  size(0),
                                                                  count(0),
                                                                  bufferSize(1),
                                                                  bufferInterval(0),
                                                                  downsampling(false)
{
    lastWrite.tv_sec = 0;
    lastWrite.tv_usec = 0;
    timer.setSingleShot(true);
    connect(&timer, SIGNAL(timeout()), this, SLOT(timerTimeout()));
}
예제 #21
0
파일: sis3350ui.cpp 프로젝트: mojca/gecko
Sis3350UI::Sis3350UI(Sis3350Module* _module)
: module (_module)
, name (_module->getName ())
{
    createUI();

    freeRunnerTimer = new QTimer();
    connect(freeRunnerTimer,SIGNAL(timeout()),this,SLOT(timerTimeout()));
    freeRunnerTimer->setInterval(50);

    timerArmMutex.lock();
    timerArmed = false;
    timerArmMutex.unlock();

    std::cout << "Instantiated Sis3350 UI" << std::endl;
}
예제 #22
0
GameEngine::GameEngine(MainWindow *mainWindow)
    : m_mainWindow(mainWindow), randomCounter(0)
{
    m_gameTimer.setInterval(REPAINT_INTERVAL);
    connect(&m_gameTimer, SIGNAL(timeout()), SLOT(timerTimeout()));
    
    m_elapsedTimeTimer.setInterval(1000);
    connect(&m_elapsedTimeTimer, SIGNAL(timeout()), SLOT(increaseElapsedTime()));

    m_cheatsEnabled = !qgetenv("KDE_DEBUG").isEmpty();

    m_bar_ptr = &m_bar;

    qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
    m_levelLoader = new LevelLoader( this );
}
HGMarkdownHighlighter::HGMarkdownHighlighter(QTextDocument *parent,
                                             int aWaitInterval) : QObject(parent)
{
    highlightingStyles = NULL;
    workerThread = NULL;
    cached_elements = NULL;
    waitInterval = aWaitInterval;
    timer = new QTimer(this);
    timer->setSingleShot(true);
    timer->setInterval(aWaitInterval);
    connect(timer, SIGNAL(timeout()), this, SLOT(timerTimeout()));
    document = parent;
    connect(document, SIGNAL(contentsChange(int,int,int)),
            this, SLOT(handleContentsChange(int,int,int)));

    this->parse();
}
예제 #24
0
파일: z.c 프로젝트: zhangjinde/z
const char* zTimeoutCmd(struct context* ctx, const char* cmd, const char* param) {

	size_t sz = strlen(param);
	char tmp[sz+1];
	strcpy(tmp, param);
	char* args = tmp;
	char* timeStr = strsep(&args, " \t\r\n");
	char* noMoreStr = strsep(&args, " \t\r\n");

	int time = strtol(param, &timeStr, 10);
	int noMore = strtol(timeStr, &noMoreStr, 10);

	int session = contextNewsession(ctx);
	int sn = timerTimeout(ctx->id, time, session, noMore);
	snprintf(ctx->result, 32, "%d %d", session, sn);
	return ctx->result;
}
예제 #25
0
파일: Player.cpp 프로젝트: nuchticha/animik
Player::Player(QWidget *parent) : QWidget(parent), ui(new Ui::Player)
{
  ui->setupUi(this);
  pauseIcon.addFile(QString::fromUtf8(":/icons/player/icons/player/PlayerPause.png"), QSize(),
                    QIcon::Normal, QIcon::Off);
  playIcon.addFile(QString::fromUtf8(":/icons/player/icons/player/PlayerPlay.png"), QSize(),
                   QIcon::Normal, QIcon::Off);

  animation = NULL;
  _state = PLAYSTATE_STOPPED;
  ui->playButton->setIcon(playIcon);
  loopIn = 0;
  loopOut = 0;
  _loop = true;

  setButtonsEnabled(false);
  updateLabel();
  connect(&timer,SIGNAL(timeout()),this,SLOT(timerTimeout()));
}
예제 #26
0
QExercise::QExercise( StaffPresenter* presenter, NoteProvider* noteProvider, QObject* parent )
	:	QObject(parent),
		mPresenter(presenter),
		mNoteProvider(noteProvider),
		mTimer(NULL),
		mTime(),
		mState(Stopped),
		mCounter(0),
		mNoteCount(0),
		mNoteToFind(),
		mNoteAnswered(),
		mAnswerTimeInMs(0),
		mIgnoreOctaveNumberInAnswer(true)
{
	mNoteProvider->addListener(this);

	mTimer = new QTimer(this);
	mTimer->setInterval( 200 );	
	bool ret = connect( mTimer, SIGNAL(timeout()), this, SLOT(timerTimeout()) );
	assert( ret );
}
StatusWidget::StatusWidget(QWidget* parent, Role role) :
  QWidget(parent),
  layout_(new QGridLayout(this)),
  labelIcon_(new QLabel(this)),
  timer_(new QTimer(this)),
  currentRole_(role),
  currentFrame_(0) {
  setLayout(layout_);
  
  layout_->setContentsMargins(0, 0, 0, 0);
  layout_->addWidget(labelIcon_, 0, 0);
  
  frames_[Okay] = QList<QPixmap>();
  frames_[Error] = QList<QPixmap>();
  frames_[Busy] = QList<QPixmap>();
    
  frameRates_[Okay] = 0.0;
  frameRates_[Error] = 0.0;
  frameRates_[Busy] = 0.0;
  
  connect(timer_, SIGNAL(timeout()), this, SLOT(timerTimeout()));
}
예제 #28
0
SessionTimer::SessionTimer(QObject *parent) :
    QObject(parent), interval(1000), timerDelay(0)
{
    connect(&timer, SIGNAL(timeout()), this, SLOT(timerTimeout()));
}
예제 #29
0
e_scriptresult TScript::loadScript2(QString includeFile, QString parent)
{
    QString fn = filename;
    if (includeFile.isEmpty()) {
        qDebug() << "Running loadScript() on" << filename;
        scriptstr.clear();
        errorKeyword.clear();
        curLine = 1;
        loadIntLine = 1;
        include.clear();
        command.clear();
        tevent.clear();
        lineMap.clear();

        QHashIterator<QString,TCustomScriptDialog*> i(dialogs);
        while (i.hasNext()) {
            i.next();
            delete i.value();
        }
        dialogs.clear();

    }
    else {
        fn = setRelativePath(parent, includeFile);
        qDebug() << "Including" << fn;
    }

    qDebug() << "attempt:" << fn;

    if (QFile::exists(fn) == false)
    return se_FileNotExist;

    QFile f(fn);
    bool fo = f.open(QIODevice::ReadOnly | QIODevice::Text);
    if (fo == false)
        return se_FileCannotOpen;

    QString ba = f.readAll();
    if (ba.length() < 1)
        return se_FileEmpty;

    // Remove comments, keep newlines:
    QString tmp;
    bool isCommented = false;

    QString lineFile = includeFile;
    if (lineFile.isEmpty())
        lineFile = filename;

    int cLine = 1;

    for (int i = 0; i <= ba.length()-1; ++i) {
        QChar c = ba[i];

        if (c == '\n') { // newline
            delWhitespace(&tmp);

            lineMap.insert(loadIntLine, QString("%1:%2")
                                          .arg(cLine)
                                          .arg(lineFile)
                           );

            if (tmp.length() > 0) {
                scriptstr.push_back(tmp + '\n');
                loadIntLine++;
            }

            cLine++;

            isCommented = false;
            tmp.clear();
            continue;
        }

        if (isCommented) // part of a comment, ignore.
            continue;

        if (c == ';') { // comment, skip anything after.
            isCommented = true;
            continue;
        }

        tmp.append(c);
    }

    if (tmp.length() > 0) // insert anything missing from very last line.
        scriptstr.push_back(tmp + '\n');

    // This was an include, the first instance of loadScript() will take care of retreiving the rest.
    if (includeFile.length() > 0)
        return se_None;


    // Search script for functions and parse the meta.
    QString keyword;
    bool getKeyword = true; // Always begin with getting keyword.
    bool comment = false;

    enum { // Expecting
        ex_Unknown = 0, // If we use this we must pose an error too.
        ex_Block,
        ex_Brace,
        ex_Statement,
        ex_Ignore, // ignore until next block (still handles nesting levels)
        ex_Include = 5,
        ex_Command,
        ex_Event,
        ex_Timer,
        ex_ScriptName,
        ex_FunctionName = 10,
        ex_MenuType,
        ex_MenuTitle,
        ex_MenuFunction,
        ex_DialogName,
        ex_DialogTitle = 15,
        ex_DialogGeometry,
        ex_DialogEmbed,
        ex_DialogIcon,
        ex_DialogLabel,
        ex_DialogButton = 20,
        ex_DialogEditBox,
        ex_DialogTextBox,
        ex_DialogListBox,
        ex_DialogPaint,
        ex_DialogText = 25
    };

    enum {
        st_None = 0, // used when waiting for block name keyword
        st_Meta,
        st_Function,
        st_Menu,
        st_Dialog
    };

    int state = st_None;
    int ex = ex_Block; // We expect to find a script block to begin with. either function, script or menu.
    int n = 0; // Nesting level. 0 is where script blocks are at (script, function, menu, etc.)

    QString temp[3];
    TCustomScriptDialog *dialog = NULL;

    // Reset the custom menues, they'll be set up later on in here...
    resetMenu(customNicklistMenu);
    resetMenu(customChannelMenu);
    resetMenu(customQueryMenu);
    resetMenu(customStatusMenu);

    fnindex.clear(); // re-load function index

    for (int i = 0; i <= scriptstr.length()-1; ++i) {
        QChar cc = scriptstr[i];

        errorKeyword = keyword + cc;

        if (cc == '\n')
            curLine++;

        if (ex != ex_Ignore) {
            if (cc == '\\') { // Escape, skip completely and add to keyword
                if ((i == scriptstr.length()-1) || (scriptstr[i+1] == '\n'))
                    return se_EscapeOnEndLine;

                keyword += scriptstr[i+1];
                i++;
                continue;
            }

            /* Comment handling */
            /* Put ; anywhere but must end with newline. */
            if (cc == '\n')
                comment = false;
            if (comment)
                continue;
            if (cc == ';') {
                comment = true;
                continue;
            }
            /* **************** */
        }



        if (cc == '{') {
            if ((ex != ex_Brace) && (ex != ex_Ignore) && (n == 0))
                return se_UnexpectedToken;
            n++;
        }
        if (cc == '}') {
            if (n == 0)
                return se_UnexpectedToken;

            n--;

            if (state == st_Dialog) {
                dialogs.insert( dialog->getName(), dialog );
                connect(dialog, SIGNAL(runEvent(e_iircevent,QStringList)),
                this, SLOT(runEvent(e_iircevent,QStringList)));
                state = st_None;
            }

            if (n == 0)
            ex = ex_Block;
        }

        if (ex == ex_Brace) {
            if ((cc != ' ') && (cc != '\t') && (cc != '\n') && (cc != '{') && (cc != '}'))
                return se_UnexpectedToken;

            if ((cc == ' ') || (cc == '\t') || (cc == '\n'))
                continue;

            ex = ex_Statement;
            continue;
        }

        if (cc == '}')
            continue;

        if (ex == ex_FunctionName) {
            // Stop this one at (
            // If we encounter \n first, pose error.

            if (cc == '\n')
                return se_UnexpectedNewline;
            if (i == scriptstr.length()-1)
                return se_UnexpectedFinish;

            if (cc == '(') {
                fnindex.insert(keyword.toUpper(), i);
                ex = ex_Ignore;
                continue;
            }

            if (cc == ' ') {
                QChar cc2 = scriptstr[i+1];
                if (cc2 == '(')
                    continue;
                else
                    return se_UnexpectedToken;
            }
        }

        // Newline, receiving keyword but keyword got is none. ignore.
        if ((cc == '\n') && (getKeyword == true) && (keyword.length() == 0))
            continue;

        // Newline, space receiving keyword and got a keyword. parse.
        if (((cc == '\n') || (cc == ' ')) && (getKeyword == true) && (keyword.length() >= 0)) {
            QString keywup = keyword.toUpper();

            if (n == 0) { // Here we always expect script blocks.
                if (ex == ex_Block) {

                    if (keywup == "SCRIPT") {
                        ex = ex_ScriptName;
                        state = st_Meta;
                        keyword.clear();
                        continue;
                    }

                    else if (keywup == "META") {
                        ex = ex_Brace;
                        state = st_Meta;
                        keyword.clear();
                        continue;
                    }

                    else if (keywup == "FUNCTION") {
                        ex = ex_FunctionName;
                        state = st_Function;
                        keyword.clear();
                        continue;
                    }

                    else if (keywup == "MENU") {
                        ex = ex_MenuType;
                        state = st_Menu;
                        keyword.clear();
                        continue;
                    }

                    else if (keywup == "DIALOG") {
                        ex = ex_DialogName;
                        state = st_Dialog;
                        keyword.clear();
                        continue;
                    }

                    else
                        return se_InvalidBlockType;
                }

                if (ex == ex_ScriptName) {
                    name = keyword;
                    ex = ex_Brace;
                    keyword.clear();
                    continue;
                }

                if (ex == ex_DialogName) {
                    dialog =  new TCustomScriptDialog(this, keyword, dlgParent);
                    ex = ex_Brace;
                    keyword.clear();
                    continue;
                }

                if (ex == ex_MenuType) {
                    temp[0] = keyword.toUpper();
                    state = st_Menu;
                    ex = ex_Brace;
                    continue;
                }

            }

            if (n > 0) {

                if (state == st_Meta) {

                    if (ex == ex_Statement) {
                        keyword.clear(); // this is safe here.
                        if (keywup == "INCLUDE") {
                            ex = ex_Include;
                            continue;
                        }
                        else if (keywup == "COMMAND") {
                            ex = ex_Command;
                            continue;
                        }
                        else if (keywup == "EVENT") {
                            ex = ex_Event;
                            continue;
                        }
                        else if (keywup == "TIMER") {
                            ex = ex_Timer;
                            continue;
                        }
                        else
                            return se_InvalidMetaCommand;
                    }

                    if (ex == ex_Include) {
                        if (cc == ' ') {
                            keyword += cc;
                            continue;
                        }
                        include.push_back(keyword);
                        e_scriptresult r = loadScript2(keyword, fn);
                        keyword.clear();
                        ex = ex_Statement;

                        if (r != se_None)
                            return r;

                        continue;
                    }

                    if ((ex == ex_Command) || (ex == ex_Event) || (ex == ex_Timer)) {

                        if (temp[0].length() == 0)
                            temp[0] = keyword; // command name
                        else
                            temp[1] = keyword; // function
                        keyword.clear();

                        if (((temp[0].length() == 0) || (temp[1].length() == 0)) && (cc == '\n'))
                            return se_UnexpectedNewline;

                        if (cc == '\n') {
                            // this one will run if both temp are filled.

                            if (ex == ex_Command)
                            command.insert(temp[0].toUpper(), temp[1]);

                            if (ex == ex_Event) {
                                e_iircevent evt = getEvent(temp[0]);

                                if (evt == te_noevent)
                                    return se_InvalidEvent;

                                tevent.insertMulti(evt, temp[1]);
                            }


                            if (ex == ex_Timer) {
                                if (timers.contains(temp[0].toUpper()) == true)
                                    goto loadScript__ex_TimerAdd_Cleanup;


                                TTimer *tmr = new TTimer(temp[1].toUpper(), this);
                                connect(tmr, SIGNAL(timeout(QString)),
                                this, SLOT(timerTimeout(QString)));

                                timers.insert(temp[0].toUpper(), tmr);
                            }

                            loadScript__ex_TimerAdd_Cleanup:

                            ex = ex_Statement;
                            temp[0].clear();
                            temp[1].clear();

                            keyword.clear();
                            continue;
                        }

                        keyword.clear();
                        continue;
                    }

                }

                if (state == st_Dialog) {

                    if (ex == ex_Statement) {
                        keyword.clear();

                        if (keywup == "TITLE")
                            ex = ex_DialogTitle;

                        else if (keywup == "GEOMETRY")
                            ex = ex_DialogGeometry;

                        else if (keywup == "EMBED") {
                            // embed c|l|p|s
                            // channel, listbox, pm, status
                            ex = ex_DialogEmbed;
                        }

                        else if (keywup == "PAINT") {
                            // paint @wname x y w h
                        }

                        else if (keywup == "TEXT") {
                            // text @name x y w h
                        }

                        else if (keywup == "LABEL")
                            ex = ex_DialogLabel;

                        else if (keywup == "BUTTON")
                            ex = ex_DialogButton;

                        else if (keywup == "EDITBOX")
                            ex = ex_DialogEditBox;

                        else if (keywup == "TEXTBOX")
                            ex = ex_DialogTextBox;

                        else if (keywup == "LISTBOX")
                            ex = ex_DialogListBox;

                        else
                            return se_UnexpectedToken;

                        continue;
                    }

                    if (ex == ex_DialogTitle) {
                        for (; i <= scriptstr.length()-1; i++) {
                            QChar c = scriptstr[i];
                            if (c == '\n')
                                break;
                            keyword += c;
                        }
                        dialog->setTitle(keyword);
                        keyword.clear();
                        ex = ex_Statement;
                        continue;
                    }

                    if (ex == ex_DialogGeometry) {
                        int param = 2; // 1X 2Y 3W 4H
                        int X, Y, W, H;
                        X = keyword.toInt();
                        keyword.clear();
                        for (i++; i <= scriptstr.length()-1; i++) {
                            QChar c = scriptstr[i];

                            if ((c == ' ') || (c == '\n')) {
                                if (param == 2)
                                    Y = keyword.toInt();
                                if (param == 3)
                                    W = keyword.toInt();
                                if (param == 4)
                                    H = keyword.toInt();
                                keyword.clear();
                                param++;
                            }

                            if (c == '\n')
                                break;


                            if (param == 5)
                                break;

                            keyword += c;
                        }

                        if (param != 5)
                            return se_InvalidParamCount;

                        dialog->setGeometry(X, Y, W, H);
                        keyword.clear();
                        ex = ex_Statement;
                        continue;
                    }
                    
                    if (ex == ex_DialogEmbed) {
                        
                    }

                    if (ex >= ex_DialogLabel) {
                        int param = 2;
                        int X, Y, W, H = 0;
                        QString oname = keyword;
                        QString arg;
                        keyword.clear();
                        for (i++; i <= scriptstr.length()-1; i++) {
                            QChar c = scriptstr[i];

                            if (param < 6) {
                                if ((c == ' ') || (c == '\n')) {
                                    if (param == 2)
                                        X = keyword.toInt();
                                    if (param == 3)
                                        Y = keyword.toInt();
                                    if (param == 4)
                                        W = keyword.toInt();
                                    if (param == 5)
                                        H = keyword.toInt();
                                    keyword.clear();
                                    param++;
                                }

                            }
                            if (c == '\n')
                                break;

                            if (param >= 6)
                                arg += c;
                            else
                                keyword += c;
                        }

                        if (param != 6)
                            return se_InvalidParamCount;

                        arg = arg.mid(1);


                        if (ex == ex_DialogLabel)
                            dialog->addLabel(oname, X, Y, W, H, arg);

                        if (ex == ex_DialogButton)
                            dialog->addButton(oname, X, Y, W, H, arg);

                        if (ex == ex_DialogEditBox)
                            dialog->addEditbox(oname, X, Y, W, H);

                        if (ex == ex_DialogTextBox)
                            dialog->addTextbox(oname, X, Y, W, H);

                        if (ex == ex_DialogListBox)
                            dialog->addListbox(oname, X, Y, W, H);


                        keyword.clear();
                        ex = ex_Statement;
                        continue;
                    }

                }

                if (state == st_Menu) {
                    if (ex == ex_Statement) {
                        if (temp[0] == "NICKLIST")
                            createMenu(i, 'n');
                        if (temp[0] == "CHANNEL")
                            createMenu(i, 'c');
                        if (temp[0] == "QUERY")
                            createMenu(i, 'q');
                        if (temp[0] == "STATUS")
                            createMenu(i, 's');

                        --i;
                        temp[0].clear();
                        state = st_None;
                        ex = ex_Brace;
                    }
                }
            }

            keyword.clear();

            continue;
        }

        keyword += cc;
    }

    if (n > 0)
    return se_UnexpectedFinish;

    qDebug() << "Script" << name << "(re)loaded with:";
    qDebug() << " -" << fnindex.count() << "functions.";
    qDebug() << " -" << tevent.count() << "events.";
    qDebug() << " -" << include.count() << "includes.";
    qDebug() << " -" << command.count() << "commands.";
    qDebug() << " -" << timers.count() << "timers.";
    qDebug() << " -" << dialogs.count() << "dialogs.";
    qDebug() << "---";

    return se_None;
}
예제 #30
0
SocketMonitor::SocketMonitor(QObject *parent) : QObject(parent)
{
    timeoutTimer.setSingleShot(true);
    timeoutTimer.setInterval(20);
    connect(&timeoutTimer,SIGNAL(timeout()),this,SLOT(timerTimeout()));
}