Exemple #1
0
// NOTE: The load() command is similar to the include() command except that it loads the script
// as a stand-alone script. To accomplish this, the ScriptEngine class just emits a signal which
// the Application or other context will connect to in order to know to actually load the script
void ScriptEngine::load(const QString& loadFile) {
    if (_stoppingAllScripts) {
        qCDebug(scriptengine) << "Script.load() while shutting down is ignored... "
                 << "loadFile:" << loadFile << "parent script:" << getFilename();
        return; // bail early
    }

    QUrl url = resolvePath(loadFile);
    if (_isReloading) {
        auto scriptCache = DependencyManager::get<ScriptCache>();
        scriptCache->deleteScript(url.toString());
        emit reloadScript(url.toString(), false);
    } else {
        emit loadScript(url.toString(), false);
    }
}
int ClientInterface::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: sendMessage(); break;
        case 1: chat((*reinterpret_cast< CLID(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2])),(*reinterpret_cast< QString(*)>(_a[3])),(*reinterpret_cast< ENUM_TYPE(*)>(_a[4]))); break;
        case 2: changeServerInformations((*reinterpret_cast< ServerInformations(*)>(_a[1]))); break;
        case 3: changeClientID((*reinterpret_cast< CLID(*)>(_a[1]))); break;
        case 4: changeClientNickname((*reinterpret_cast< CLID(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 5: showError((*reinterpret_cast< ENUM_TYPE(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 6: changeGameMaster((*reinterpret_cast< CLID(*)>(_a[1]))); break;
        case 7: clientVoted((*reinterpret_cast< CLID(*)>(_a[1])),(*reinterpret_cast< CLID(*)>(_a[2]))); break;
        case 8: connectionEtablished(); break;
        case 9: connectionLost(); break;
        case 10: diceRolled((*reinterpret_cast< CLID(*)>(_a[1])),(*reinterpret_cast< quint16(*)>(_a[2])),(*reinterpret_cast< quint16(*)>(_a[3]))); break;
        case 11: sanctionned((*reinterpret_cast< CLID(*)>(_a[1])),(*reinterpret_cast< ENUM_TYPE(*)>(_a[2])),(*reinterpret_cast< QString(*)>(_a[3]))); break;
        case 12: rollDice(); break;
        case 13: rollSpecialDice(); break;
        case 14: serverName((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 15: motdChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 16: gameLaunched(); break;
        case 17: setTitle(); break;
        case 18: playSound((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 19: updatePlayerList(); break;
        case 20: clientJoined((*reinterpret_cast< CLID(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 21: clientLeft((*reinterpret_cast< CLID(*)>(_a[1]))); break;
        case 22: updateGMLabel(); break;
        case 23: updateGMPanel(); break;
        case 24: { bool _r = addLanguage();
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 25: { bool _r = addLanguage((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 26: languageListMenu((*reinterpret_cast< const QPoint(*)>(_a[1]))); break;
        case 27: { bool _r = removeLanguage((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 28: removeLanguageMenu(); break;
        case 29: importLanguageList(); break;
        case 30: sendLanguageList(); break;
        case 31: { CLID _r = CLIDFromString((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< CLID*>(_a[0]) = _r; }  break;
        case 32: switchConnectionState(); break;
        case 33: openSettings(); break;
        case 34: openSoundsGUI(); break;
        case 35: aboutUs(); break;
        case 36: aboutServer(); break;
        case 37: openMapEditor(); break;
        case 38: clearMapEditor(); break;
        case 39: mapFlare(); break;
        case 40: resetData(); break;
        case 41: setCSS((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 42: setCSS(); break;
        case 43: setInterface((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 44: setInterface(); break;
        case 45: playerListMenu((*reinterpret_cast< const QPoint(*)>(_a[1]))); break;
        case 46: actionKick(); break;
        case 47: actionBan(); break;
        case 48: actionVoteGM(); break;
        case 49: actionChangeGM(); break;
        case 50: refresh(); break;
        case 51: textChanged(); break;
        case 52: narrationChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 53: syncSoundLibs((*reinterpret_cast< QList<SoundLibInformations>(*)>(_a[1]))); break;
        case 54: syncLanguagesList((*reinterpret_cast< QList<QPair<QString,QString> >(*)>(_a[1]))); break;
        case 55: syncDictionariesList((*reinterpret_cast< QStringList(*)>(_a[1]))); break;
        case 56: requestScriptDownload((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 57: sendScriptToServer((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 58: deleteScript((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 59: renameScript((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 60: makeEntity((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 61: deleteEntity((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 62: injectCode((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 63: scriptToGMMsg((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 64: scriptToOwnerMsg((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 65: scriptActionMsg((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 66: scriptToPlayerMsg((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 67: scriptMsg((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 68: scriptError((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 69: sendMapToServer((*reinterpret_cast< const MapInformations*const(*)>(_a[1])),(*reinterpret_cast< const QMap<QString,RSID>(*)>(_a[2]))); break;
        case 70: addDictionnary(); break;
        case 71: saveGame(); break;
        case 72: loadGame(); break;
        case 73: VOIPRemoveClient(); break;
        case 74: VOIPAddClient(); break;
        case 75: VOIPClientVolume(); break;
        case 76: dataPerSecond((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        default: ;
        }
        _id -= 77;
    }
    return _id;
}
Exemple #3
0
// 																		<<<<<<<<<<-------------- TODO: Check this out...dose some intresting things
static void
skip_percent_comment(void)
{

#ifndef TTYEDEN
    Script     *script;
    extern Script *st_script, *dd_script;
    extern int  run(short, void *, char *);
    extern void dd_lex(int), st_lex(int);
#ifdef WANT_SASAMI
    extern Script *sa_script;
    extern void sa_input(char);
#endif /* WANT_SASAMI */
#ifdef DISTRIB
    extern void lsd_lex(int);
#endif /* DISTRIB */
#endif /* not TTYEDEN */

    /* skip_percent_comment is called when we are starting a new line
       and nextc=='%' [Ash] */

    char       *s;
    int         start = yyleng;

    safe_input();		/* read in the initial '%' */

    for (;;) {

	s = yytext + start;

	/* safe_input until we have an end-of-line or EOF */
	if ((nextc != '\n') && (nextc != '\r') && (nextc != 0)) {
	  safe_input();
	  continue;
	} else {
	  /* now we've found the end of the line, terminate it correctly */
	  end_text1();
	}

	if ((nextc == '\n') || (nextc == '\r')) {
	  if (notationSwitch(s)) {
	    char execstr[100];
	    int c;
	    
	    changeNotation(NEWOTHER);

	    /* Notation now changed to a non-default one.  Slurp in
	       the rest of the text until (just before) the next
	       change of notation and parse it.  [Ash] */
	    for (nextc = peek();
		 (nextc != '\0') && (nextc != EOF);
		 nextc = peek()) {
	      
	      if (Inp_Dev->newline && nextc == '%') {
		/* Trying to fix sqleddi "prepare to eat and then eat"
		   bug [Ash, 23rd October 2002] */
		/*
		  strcpy(execstr, "notationChar('\\\n');");
		  run(STRING_DEV, execstr, 0);
		*/
		
		nextc = '\n';
		return;
	      } else if (Inp_Dev->newline && nextc == '#') {
		c = keyin();
		if (nextc == '#') {
		  /* "##" comment input: ignore to end of line */
		  do {c = keyin();} while (!Inp_Dev->newline);
		  
		} else {
		  /* input line starts with #, but second character is
		     not #.  Pass the first # to the Eden parser, and
		     parse the second character the next time round
		     the loop. */
		  strcpy(execstr, "notationChar('#');");
		  run(STRING_DEV, execstr, 0);
		}
	      } else {
		/* Something in the sqleddi model causes C's idea
                   about the status of the current notation to get
                   confused.  As this piece of code is executing, we
                   must be in a NEWOTHER notation, so set it
                   explicitly.  [Ash, 24th October 2002] */
#ifdef TTYEDEN
		changeNotation(NEWOTHER);
#endif
		c = keyin();
		/* fprintf(stderr, "KEYIN %d\n", c); */
		
		if (c == '\'')
		  strcpy(execstr, "notationChar('\\\'');");
		else if (c == '\\')
		  strcpy(execstr, "notationChar('\\\\');");
		else
		  sprintf(execstr, "notationChar('%c');", c);
		
		run(STRING_DEV, execstr, 0);
	      }
	      
	    } /* end for */
	    
#ifdef TTYEDEN
	    /* ttyeden does not currently keep track of the current
	       notation properly.  It should still be %eddi after an
	       included file has changed to that notation and not back
	       again, but this would require some work on the lexer.
	       At least we can ensure that the prompt is correct here.
	       [Ash] */
	    /*
	      if ((nextc == EOF) || (nextc == '\0')) {
	      fprintf(stderr, "EOF FUDGE\n");
	      notationSwitch("%eden");
	      currentNotation = EDEN;
	      }
	    */

	    currentNotation = EDEN;
	    /* peek() does not seem to manage to successfully push
	       back the EOF character in TTYEDEN and so keyin() would
	       cause another character to be read.  Stop immediately
	       instead.  [Ash] */
	    return;
#else
	    keyin();	/* read the null character */
	    /* treat end-of-file as end-of-line */
	    /* the code feeding the parser with \n below is a
	       reinterpretation of something Chris Brown put in, but
	       it doesn't seem to be required any more */
	    /*
	     * strcpy(execstr, "notationChar('\\n');");
	     * run(STRING_DEV, execstr, 0);
	     */
	    setprompt();
#endif
	    
	  } /* end if notationSwitch(s) */


#ifndef TTYEDEN
	  /* DoNaLD -------------------------------------------- */
	  /* %donald0 is an alternative alias for %donald, so that we
	     can replace %donald with a new translator but still
	     access this builtin as %donald0 */
	  else if ((strncmp(s, "%donald0", 8) == 0) ||
		   (strncmp(s, "%donald", 7) == 0)) {
	    changeNotation(DONALD);
	    dd_script = script = newScript();
	    for (nextc = peek(); nextc != '\0'; nextc = peek()) {
	      if (Inp_Dev->newline && (nextc == '%' || nextc == '>'
				       || nextc == '<')) {
		if (nextc == '>' || nextc == '<') {
		  input();
		  getAgentName();
		}
		else {
		  nextc = '\n';
		  if (script->text[0] != '\0') {
		    appAgentName--;
		    /* printf("from donald 1"); */
		    pushEntryStack(DONALD);
		    run(STRING_DEV, script->text, 0);
		    popEntryStack();
		    appAgentName++;
		  }
		  deleteScript(script);
		  return;
		} /* end if (nextc == '>' || nextc == '<') */
	      } /* end if (Inp_Dev->newline...) */
	      else {
		dd_lex(keyin());
		if (script->ready) {
		  if (script->text[0] != '\0') {
		    appAgentName--;
		    /* printf("from donald 2"); */
		    pushEntryStack(DONALD);
		    run(STRING_DEV, script->text, 0);
		    dd_script = script;
		    popEntryStack();
		    /* printf("from donald 3"); */
		    appAgentName++;
		  }
		  resetScript(script);
		} /* end if (script->ready) */
	      } /* end if (Inp_Dev->newline...) (two versions) */
	    } /* end for (nextc = peek()...) */


	    keyin();	/* read the null character */
	    dd_lex('\n');	/* treat end-of-file as end-of-line */

	    if (script->text[0] != '\0') {
	      appAgentName--;
	      pushEntryStack(DONALD);
	      run(STRING_DEV, script->text, 0);
	      popEntryStack();
	      /* printf("from donald 4"); */
	      appAgentName++;
	    }
	    deleteScript(script);
	  } /* end if (strncmp(s, "%donald", 7) == 0) */


	  /* SCOUT -------------------------------------------- */
	  else if (strncmp(s, "%scout", 6) == 0) {	/* is SCOUT */
	    scoutScreenInitOpen();
	    changeNotation(SCOUT);
	    st_script = script = newScript();
	    for (nextc = peek(); nextc != '\0'; nextc = peek()) {
	      if (Inp_Dev->newline && (nextc == '%' || nextc == '>'
				       || nextc == '<')) {
		if (nextc == '>' || nextc == '<') {
		  input();
		  getAgentName();
		} else {
		  nextc = '\n';
		  if (script->text[0] != '\0') {
		    appAgentName--;
		    /* printf("from scout 1"); */
		    pushEntryStack(SCOUT);
		    run(STRING_DEV, script->text, 0);
		    popEntryStack();
		    appAgentName++;
		  }
		  deleteScript(script);
		  return;
		}
	      } /* end if (Inp_Dev->newline...) */
	      else {
		st_lex(keyin());
		if (script->ready) {
		  if (script->text[0] != '\0') {
		    appAgentName--;
		    /* printf("from scout 2 %s\n", script->text); */
		    pushEntryStack(SCOUT);
		    run(STRING_DEV, script->text, 0);
		    st_script = script;
		    popEntryStack();
		    appAgentName++;
		  }
		  resetScript(script);
		}
	      }
	    } /* end for (nextc = peek();... */

	    keyin();	/* read the null character */
	    st_lex('\n');	/* treat end-of-file as end-of-line */
	    if (script->text[0] != '\0') {
	      appAgentName--;
	      pushEntryStack(SCOUT);
	      run(STRING_DEV, script->text, 0);
	      popEntryStack();
	      appAgentName++;
	    }
	    deleteScript(script);
	  } /* end if (strncmp(s, "%scout", 6)... */

#ifdef WANT_SASAMI

	  /* Sasami -------------------------------------------- */

	  else if (strncmp(s, "%sasami", 7) == 0) {
	    changeNotation(SASAMI);
	    sa_script = script = newScript();
	    for (nextc = peek(); nextc != '\0'; nextc = peek())	{
	      if (Inp_Dev->newline && (nextc == '%' || nextc == '>' ||
				       nextc == '<')) {
		/* This is a %, > or < statement and shouldn't be
                   passed to Sasami */
		if (nextc == '>' || nextc == '<') {
		  input();
		  getAgentName();
		} else {
		  nextc = '\n';
		  if (script->text[0] != '\0') {
		    appAgentName--;
		    /* printf("from sasami 1"); */
		    pushEntryStack(SASAMI);
		    run(STRING_DEV, script->text, 0);
		    popEntryStack();
		    appAgentName++;
		  }
		  deleteScript(script);
		  return;
		}
	      } else {
		/* This must be something worth sending to Sasami */
		sa_input(keyin());
		/* Now run the EDEN script that Sasami's produced (if
                   there is one) */
		if (script->ready) {
		  if (script->text[0] != '\0') {
		    appAgentName--;
		    /* printf("from sasami 2"); */
		    pushEntryStack(SASAMI);
		    run(STRING_DEV, script->text, 0);
		    sa_script = script;
		    popEntryStack();
		    /* printf("from sasami 3"); */
		    appAgentName++;
		  }
		  resetScript(script);
		}
	      }
	    }

	    /* OK - finished with the input, so send an EOL to make
	       sure that the parser runs the last input line, and
	       exit. */

	    keyin();	/* read the null character */

	    sa_input('\n');	/* treat end-of-file as end-of-line */

	    if (script->text[0] != '\0') {
	      appAgentName--;
	      pushEntryStack(SASAMI);
	      run(STRING_DEV, script->text, 0);
	      popEntryStack();
	      /* printf("from sasami 4"); */
	      appAgentName++;
	    }
	    deleteScript(script);
	  } /* end if (strncmp(s, "%sasami", 7) == 0) */
#endif /* WANT_SASAMI */

#ifdef DISTRIB
	  /* LSD -------------------------------------------- */
	  else if (strncmp(s, "%lsd", 4) == 0) {
	    changeNotation(LSD);
	    for (nextc = peek(); nextc != '\0'; nextc = peek()) {
	      if (Inp_Dev->newline && (nextc == '%' || nextc == '>'
				       || nextc == '<')) {
		if (nextc == '>' || nextc == '<') {
		  input();
		  getAgentName();
		} else {
		  nextc = '\n';
		  return;
		}
	      } else {
		lsd_lex(keyin());
	      }
	    }
	    keyin();	/* read the null character */
	    lsd_lex('\n');	/* treat end-of-file as end-of-line */
	  } /* end if (strncmp(s, "%lsd", 4)... */
#endif /* DISTRIB */

	  /* This push and pop facility ("%+eden") appears be used
             only in Donald [Ash] */

	  /* Push entry -------------------------------------------- */
	  else if (s[1] == '+') {
	    /*  appAgentName=0; */
	    if ((strncmp(s + 2, "donald0", 7) == 0) ||
		(strncmp(s + 2, "donald", 6) == 0)) {	/* is DoNaLD */
	      pushEntryStack(DONALD);
	    } else if (strncmp(s + 2, "scout", 5) == 0) {	/* is SCOUT */
	      pushEntryStack(SCOUT);
	    } else if (strncmp(s + 2, "eden", 4) == 0) {	/* is EDEN */
	      pushEntryStack(EDEN);
#ifdef WANT_SASAMI
	    } else if (strncmp(s + 2, "sasami", 6) == 0) {	/* is Sasami */
	      pushEntryStack(SASAMI);
#endif /* WANT_SASAMI */
	    }
	  } /* end if (s[1] == '+') */


	  /* Pop entry -------------------------------------------- */
	  else if (s[1] == '-') {
	    if ((strncmp(s + 2, "donald0", 7) == 0)
		|| strncmp(s + 2, "donald", 6) == 0
		|| strncmp(s + 2, "scout", 5) == 0	/* is SCOUT */
#ifdef WANT_SASAMI
		|| strncmp(s + 2, "sasami", 6) == 0	/* is Sasami */
#endif
		|| strncmp(s + 2, "eden", 4) == 0) {	/* is EDEN */
	      popEntryStack();
	      /*  appAgentName=1; */
	    }
	  } /* end if (s[1] == '-') */

#endif /* not TTYEDEN */

	  /* Eden -------------------------------------------- */
	  else {
	    changeNotation(EDEN);
	  }

	  return;

	} else if (nextc == 0) {
	  /* EOF */
#ifdef TTYEDEN
	  /* Dummy if start to make the else's below work... [Ash] */
	  if (0) {}
#else
	  if ((strncmp(s, "%donald0", 8) == 0) ||
	      (strncmp(s, "%donald", 7) == 0)) {	/* is DoNaLD */
	    changeNotation(DONALD);
	  }
	  else if (strncmp(s, "%scout", 6) == 0) {	/* is SCOUT */
	    changeNotation(SCOUT);
	  }
#ifdef WANT_SASAMI
	  else if (strncmp(s, "%sasami", 7) == 0) {	/* is Sasami */
	    changeNotation(SASAMI);
	  }
#endif /* WANT_SASAMI */
#endif /* not TTYEDEN */
          else if (notationSwitch(s)) {
	    changeNotation(NEWOTHER);
	  } else {		/* is EDEN */
	    changeNotation(EDEN);
	  }
	  return;
	} /* end if nextc==0 */
    } /* end for ;; */
} /* end skip_percent_comment */
void ManageSieveCommand::execute()
{
    if ( d->done )
        return;

    bool ok = true;
    switch ( d->cmd ) {
    case Logout:
        log( "Received LOGOUT command", Log::Debug );
        d->sieve->Connection::setState( Connection::Closing );
        break;

    case Capability:
        end();
        if ( d->no.isEmpty() )
            d->sieve->capabilities();
        break;

    case StartTls:
        ok = startTls();
        break;

    case Authenticate:
        ok = authenticate();
        break;

    case HaveSpace:
        ok = haveSpace();
        break;

    case PutScript:
        ok = putScript();
        break;

    case ListScripts:
        ok = listScripts();
        break;

    case SetActive:
        ok = setActive();
        break;

    case GetScript:
        ok = getScript();
        break;

    case DeleteScript:
        ok = deleteScript();
        break;

    case RenameScript:
        ok = renameScript();
        break;

    case Noop:
        ok = noop();
        break;

    case XAoxExplain:
        ok = explain();
        break;

    case Unknown:
        no( "Unknown command" );
        break;
    }

    if ( d->query && d->query->failed() && d->no.isEmpty() )
        no( "Database failed: " + d->query->error() );
    else if ( d->t && d->t->failed() && d->no.isEmpty() )
        no( "Database failed: " + d->t->error() ); // XXX need to rollback?

    if ( !d->no.isEmpty() )
        ok = true;

    if ( !ok )
        return;

    d->done = true;
    if ( d->no.isEmpty() ) {
        d->sieve->enqueue( "OK" );
        if ( !d->ok.isEmpty() ) {
            d->sieve->enqueue( " " );
            d->sieve->enqueue( encoded( d->ok ) );
        }
        d->sieve->enqueue( "\r\n" );
    }
    else {
        d->sieve->enqueue( "NO" );
        if ( !d->no.isEmpty() ) {
            d->sieve->enqueue( " " );
            d->sieve->enqueue( encoded( d->no ) );
        }
        d->sieve->enqueue( "\r\n" );
    };
    d->sieve->runCommands();
}