Ejemplo n.º 1
0
void Console::updateAreas() {
	_areas.clear();
	if (!_module) {
		setArguments("gotoarea");
		return;
	}

	const std::vector<Common::UString> &areas = _module->_ifo.getAreas();
	for (std::vector<Common::UString>::const_iterator a = areas.begin(); a != areas.end(); ++a)
		_areas.push_back(*a);

	setArguments("gotoarea", _areas);
}
Ejemplo n.º 2
0
CommandSetRate::CommandSetRate(LedControl::Driver* reciver,
								const std::string& clientId,
								const std::vector<std::string>& arguments)
: reciver_(reciver), clientId_(clientId)
{
	setArguments(arguments);
}//end of  CommandSetRate::CommandSetRate()
Ejemplo n.º 3
0
void OctreeServer::parsePayload() {
    
    if (getNumPayloadBytes() > 0) {
        QString config((const char*) _payload);
        
        // Now, parse the config
        QStringList configList = config.split(" ");
        
        int argCount = configList.size() + 1;

        qDebug("OctreeServer::parsePayload()... argCount=%d\n",argCount);

        _parsedArgV = new char*[argCount];
        const char* dummy = "config-from-payload";
        _parsedArgV[0] = new char[strlen(dummy) + sizeof(char)];
        strcpy(_parsedArgV[0], dummy);

        for (int i = 1; i < argCount; i++) {
            QString configItem = configList.at(i-1);
            _parsedArgV[i] = new char[configItem.length() + sizeof(char)];
            strcpy(_parsedArgV[i], configItem.toLocal8Bit().constData());
            qDebug("OctreeServer::parsePayload()... _parsedArgV[%d]=%s\n", i, _parsedArgV[i]);
        }

        setArguments(argCount, _parsedArgV);
    }
}
Ejemplo n.º 4
0
/// MAIN ///
int main(int argc, char** argv)
{
	ml_error_t result;

	// parse command line
	result = setArguments(argc, argv);
	if (result != SUCCESS)
	{
		printf("Usage: %s -s server -p port -w num_workers -r num_requests -f num_files -x proxy\n", argv[0]);
		printf("  -s server : name of the server on the network\n");
		printf("  -p port : number of the port to use to connect to the server\n");
		printf("  -w num_wokers : a reasonable number of workers to use\n");
		printf("  -r num_request : a reasonable number of requests to use per worker\n");
		printf("  -f num_files : the number of files in the dest dir to examine\n");
		printf("  -x proxy : the network name of the proxy server\n");
		printf("\n");
		return result;
	}

	// run client
	result = ml_client(ARG_server, ARG_port, ARG_numWorkers, ARG_numRequests, ARG_numFiles, ARG_proxy);
	if (result != SUCCESS)
		printf("ERROR: Unable to run Client... Aborting\n");
	printf("\n");
	return 0;
}
Ejemplo n.º 5
0
LRESULT AVIPreview::onChangeMenu(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	if (ctrlCommands.GetSelectedCount() == 1)
	{
		int sel = ctrlCommands.GetSelectedIndex();
		const auto pa = FavoriteManager::getInstance()->getPreviewApp(sel);
		if (pa)
		{
			PreviewDlg dlg;
			dlg.name = Text::toT(pa->getName());
			dlg.application = Text::toT(pa->getApplication());
			dlg.argument = Text::toT(pa->getArguments());
			dlg.extensions = Text::toT(pa->getExtension());
			
			if (dlg.DoModal() == IDOK)
			{
				pa->setName(Text::fromT(dlg.name));
				pa->setApplication(Text::fromT(dlg.application));
				pa->setArguments(Text::fromT(dlg.argument));
				pa->setExtension(Text::fromT(dlg.extensions));
				
				ctrlCommands.SetItemText(sel, 0, dlg.name.c_str());
				ctrlCommands.SetItemText(sel, 1, dlg.application.c_str());
				ctrlCommands.SetItemText(sel, 2, dlg.argument.c_str());
				ctrlCommands.SetItemText(sel, 3, dlg.extensions.c_str());
			}
		}
	}
	
	return 0;
}
Ejemplo n.º 6
0
void Console::updateAreas() {
	_areas.clear();
	setArguments("gotoarea");

	const Aurora::GDAFile &areas = TwoDAReg.getGDA("areas");

	std::list<Common::UString> areaIDs;
	for (size_t i = 0; i < areas.getRowCount(); i++) {
		if (areas.getInt(i, "Name") > 0) {
			_areas.insert(i);

			areaIDs.push_back(Common::UString::format("%u", (uint)i));
		}
	}

	setArguments("gotoarea", areaIDs);
}
Ejemplo n.º 7
0
/*!
    Constructs a QProcess with \a args as the arguments of the
    process. The first element in the list is the command to be
    executed. The other elements in the list are the arguments to this
    command. The \a parent and \a name parameters are passed to the
    QObject constructor.

    The process is not started. You must call start() or launch() to
    start the process.

    \sa setArguments() addArgument() start()
*/
QProcess::QProcess( const QStringList& args, QObject *parent, const char *name )
    : QObject( parent, name ), ioRedirection( FALSE ), notifyOnExit( FALSE ),
    wroteToStdinConnected( FALSE ),
    readStdoutCalled( FALSE ), readStderrCalled( FALSE ),
    comms( Stdin|Stdout|Stderr )
{
    init();
    setArguments( args );
}
/* Main CUDA Program */
int main(int argc, char **argv) {
	/* Declarations */
	Arguments args;
	unsigned char *input, *output, *image, *buffer;	

	/* Check and set arguments */
	if (argc != 15) {
		printf("Usage: ./a.out -i <inputImg> -o <outputImg> -w <ImgWidth> -h <ImgHeight> -bpp <bitsPerPixel> -l <#loops> -b <blockSize>\n");
		exit(1);
	}
	else
		setArguments(argv, &args);
#ifdef PRINT
	printArguments(&args);
#endif

	/* Filter in CPU */
	int *filterCPU = (int *) malloc(9 * sizeof(int));
	for (int i = 0; i < 3; i++)
		memcpy(filterCPU + i*3, filter[i], 3 * sizeof(int));	
	
	/* Allocate CPU matrices (input, output) */
	int matrixSize = args.height * args.width * args.bpp * sizeof(unsigned char);
	input = (unsigned char *) malloc(matrixSize);
	output = (unsigned char *) malloc(matrixSize);

	/* Read input image */
	FILE *fp;
	fp = fopen(args.inputImage, "rb");
	fread(input, sizeof(unsigned char),args.height * args.width * args.bpp , fp);
	fclose(fp);		

	/* Calculate filter's sum */
	int sum = 0;
	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 3; j++)
			sum += filter[i][j];
	sum = (sum != 0) ? sum : 1;

	/* Initiate GPU computation */
	initiate(args.height, args.width, args.blockSize, matrixSize, input, output, args.loops, sum, args.bpp, filterCPU);

	/* Write output to outputImage */
	fp = fopen(args.outputImage,"wb");
	fwrite(output, sizeof(unsigned char), args.height * args.width * args.bpp, fp);
	fclose(fp);

	/* Free resources */
	free(input);
	free(output);

	/* Terminate */
	exit(0);
}
Ejemplo n.º 9
0
void Console::updateModules() {
	_modules.clear();

	std::vector<Common::UString> modules;
	NWNEngine::getModules(modules);

	for (std::vector<Common::UString>::iterator m = modules.begin(); m != modules.end(); ++m)
		_modules.push_back(*m);

	setArguments("loadmodule", _modules);
}
Ejemplo n.º 10
0
void StatusNotifierItem::registerToWatcher()
{
    if (_statusNotifierWatcher->isValid() && _statusNotifierWatcher->property("ProtocolVersion").toInt() == kProtocolVersion) {
        auto registerMethod = QDBusMessage::createMethodCall(kSniWatcherService, kSniWatcherPath, kSniWatcherService,
                                                             QLatin1String{"RegisterStatusNotifierItem"});
        registerMethod.setArguments(QVariantList() << _statusNotifierItemDBus->service());
        _statusNotifierItemDBus->dbusConnection().callWithCallback(registerMethod, this, SLOT(checkForRegisteredHosts()), SLOT(onDBusError(QDBusError)));
    }
    else {
        setMode(Mode::Legacy);
    }
}
Ejemplo n.º 11
0
/***************************************************************************************
 *
 * PUBLIC METHOD: StartServer
 *
 **************************************************************************************/
int CTcpServer::StartServer( char* aLocalInterface, char* aLocalPort )
{	
	int r;
	r =initialise();
 
	if(r != ITS_OK)
		return r;

	r = setArguments( aLocalInterface, aLocalPort );
	if(r != ITS_OK)
		return r;
	
	r = makeConnection(iLocal_Sock, iRemote_Sock, iRemote_Addr);
	return r;
	
}
Ejemplo n.º 12
0
void Console::updateMusic() {
	_music.clear();
	_maxSizeMusic = 0;

	std::list<Aurora::ResourceManager::ResourceID> music;
	ResMan.getAvailableResources(Aurora::kFileTypeBMU, music);

	for (std::list<Aurora::ResourceManager::ResourceID>::const_iterator m = music.begin();
	     m != music.end(); ++m) {

		_music.push_back(m->name);

		_maxSizeMusic = MAX(_maxSizeMusic, _music.back().size());
	}

	setArguments("playmusic", _music);
}
Ejemplo n.º 13
0
void Console::updateVideos() {
	_videos.clear();
	_maxSizeVideos = 0;

	std::list<Aurora::ResourceManager::ResourceID> videos;
	ResMan.getAvailableResources(Aurora::kResourceVideo, videos);

	for (std::list<Aurora::ResourceManager::ResourceID>::const_iterator v = videos.begin();
	     v != videos.end(); ++v) {

		_videos.push_back(v->name);

		_maxSizeVideos = MAX(_maxSizeVideos, _videos.back().size());
	}

	setArguments("playvideo", _videos);
}
Ejemplo n.º 14
0
void Console::updateSounds() {
	_sounds.clear();
	_maxSizeSounds = 0;

	std::list<Aurora::ResourceManager::ResourceID> sounds;
	ResMan.getAvailableResources(Aurora::kFileTypeWAV, sounds);

	for (std::list<Aurora::ResourceManager::ResourceID>::const_iterator s = sounds.begin();
	     s != sounds.end(); ++s) {

		_sounds.push_back(s->name);

		_maxSizeSounds = MAX(_maxSizeSounds, _sounds.back().size());
	}

	setArguments("playsound", _sounds);
}
Ejemplo n.º 15
0
void Console::updateMusic() {
	_music.clear();
	_maxSizeMusic = 0;

	const Common::FileList music(Common::FilePath::findSubDirectory(ResMan.getDataBase(), "streammusic", true));

	for (Common::FileList::const_iterator m = music.begin(); m != music.end(); ++m) {
		if (!Common::FilePath::getExtension(*m).equalsIgnoreCase(".wav"))
			continue;

		_music.push_back(Common::FilePath::getStem(*m));

		_maxSizeMusic = MAX(_maxSizeMusic, _music.back().size());
	}

	std::sort(_music.begin(), _music.end(), Common::UString::iless());
	setArguments("playmusic", _music);
}
Ejemplo n.º 16
0
/**
 * @fn QueuedProcess
 */
QueuedProcess::QueuedProcess(QObject *_parent, const QueuedProcessDefinitions &definitions,
                             const long long index)
    : QProcess(_parent)
    , m_definitions(definitions)
    , m_index(index)
{
    qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;

    qRegisterMetaType<QueuedLimits::Limits>("QueuedLimits::Limits");

    m_cgroup = new QueuedControlGroupsAdaptor(this, name());

    // update QProcess related values as well
    setProgram(m_definitions.command);
    setArguments(m_definitions.arguments);
    setWorkDirectory(m_definitions.workingDirectory);

    connect(this, SIGNAL(started()), this, SLOT(applyCGroup()));
}
Ejemplo n.º 17
0
void Console::updateCampaigns() {
	_campaigns.clear();
	_campaignModules.clear();

	// Base game
	for (int i = 0; i < 5; i++) {
		Common::UString name = TalkMan.getString(kCampaignNames[i]);
		name.truncate(name.findFirst('\n'));
		name.trim();

		_campaigns.push_back(name);
		_campaignModules.insert(std::make_pair(name, i));
	}

	// XP1
	if (ConfigMan.getBool("NWN_hasXP1")) {
		for (int i = 5; i < 8; i++) {
			Common::UString name = "XP1: " + TalkMan.getString(kCampaignNames[i]);
			name.truncate(name.findFirst('\n'));
			name.trim();

			_campaigns.push_back(name);
			_campaignModules.insert(std::make_pair(name, i));
		}
	}

	// XP2
	if (ConfigMan.getBool("NWN_hasXP2")) {
		for (int i = 8; i < 11; i++) {
			Common::UString name = "XP2: " + TalkMan.getString(kCampaignNames[i]);
			name.truncate(name.findFirst('\n'));
			name.trim();

			_campaigns.push_back(name);
			_campaignModules.insert(std::make_pair(name, i));
		}
	}

	setArguments("loadcampaign", _campaigns);
}
Ejemplo n.º 18
0
bool KShortUriFilter::filterUri( KUriFilterData& data ) const
{
 /*
  * Here is a description of how the shortURI deals with the supplied
  * data.  First it expands any environment variable settings and then
  * deals with special shortURI cases. These special cases are the "smb:"
  * URL scheme which is very specific to KDE, "#" and "##" which are
  * shortcuts for man:/ and info:/ protocols respectively. It then handles
  * local files.  Then it checks to see if the URL is valid and one that is
  * supported by KDE's IO system.  If all the above checks fails, it simply
  * lookups the URL in the user-defined list and returns without filtering
  * if it is not found. TODO: the user-defined table is currently only manually
  * hackable and is missing a config dialog.
  */

  KUrl url = data.uri();
  QString cmd = data.typedString();

  // WORKAROUND: Allow the use of '@' in the username component of a URL since
  // other browsers such as firefox in their infinite wisdom allow such blatant
  // violations of RFC 3986. BR# 69326/118413.
  if (cmd.count(QLatin1Char('@')) > 1) {
    const int lastIndex = cmd.lastIndexOf(QLatin1Char('@'));
    // Percent encode all but the last '@'.
    QString encodedCmd = QUrl::toPercentEncoding(cmd.left(lastIndex), ":/");
    encodedCmd += cmd.mid(lastIndex);
    KUrl u (encodedCmd);
    if (u.isValid()) {
      cmd = encodedCmd;
      url = u;
    }
  }

  const bool isMalformed = !url.isValid();
  QString protocol = url.protocol();

  kDebug(7023) << cmd;

  // Fix misparsing of "foo:80", QUrl thinks "foo" is the protocol and "80" is the path.
  // However, be careful not to do that for valid hostless URLs, e.g. file:///foo!
  if (!protocol.isEmpty() && url.host().isEmpty() && !url.path().isEmpty()
      && cmd.contains(':') && !KProtocolInfo::protocols().contains(protocol)) {
    protocol.clear();
  }

  //kDebug(7023) << "url=" << url << "cmd=" << cmd << "isMalformed=" << isMalformed;

  if (!isMalformed &&
      (protocol.length() == 4) &&
      (protocol != QLatin1String("http")) &&
      (protocol[0]=='h') &&
      (protocol[1]==protocol[2]) &&
      (protocol[3]=='p'))
  {
     // Handle "encrypted" URLs like: h++p://www.kde.org
     url.setProtocol( QLatin1String("http"));
     setFilteredUri( data, url);
     setUriType( data, KUriFilterData::NetProtocol );
     return true;
  }

  // TODO: Make this a bit more intelligent for Minicli! There
  // is no need to make comparisons if the supplied data is a local
  // executable and only the argument part, if any, changed! (Dawit)
  // You mean caching the last filtering, to try and reuse it, to save stat()s? (David)

  const QString starthere_proto = QL1S("start-here:");
  if (cmd.indexOf(starthere_proto) == 0 )
  {
    setFilteredUri( data, KUrl("system:/") );
    setUriType( data, KUriFilterData::LocalDir );
    return true;
  }

  // Handle MAN & INFO pages shortcuts...
  const QString man_proto = QL1S("man:");
  const QString info_proto = QL1S("info:");
  if( cmd[0] == '#' ||
      cmd.indexOf( man_proto ) == 0 ||
      cmd.indexOf( info_proto ) == 0 )
  {
    if( cmd.left(2) == QL1S("##") )
      cmd = QL1S("info:/") + cmd.mid(2);
    else if ( cmd[0] == '#' )
      cmd = QL1S("man:/") + cmd.mid(1);

    else if ((cmd==info_proto) || (cmd==man_proto))
      cmd+='/';

    setFilteredUri( data, KUrl( cmd ));
    setUriType( data, KUriFilterData::Help );
    return true;
  }

  // Detect UNC style (aka windows SMB) URLs
  if ( cmd.startsWith( QLatin1String( "\\\\") ) )
  {
    // make sure path is unix style
    cmd.replace('\\', '/');
    cmd.prepend( QLatin1String( "smb:" ) );
    setFilteredUri( data, KUrl( cmd ));
    setUriType( data, KUriFilterData::NetProtocol );
    return true;
  }

  bool expanded = false;

  // Expanding shortcut to HOME URL...
  QString path;
  QString ref;
  QString query;
  QString nameFilter;

  if (KUrl::isRelativeUrl(cmd) && QDir::isRelativePath(cmd)) {
     path = cmd;
     //kDebug(7023) << "path=cmd=" << path;
  } else {
    if (url.isLocalFile())
    {
      //kDebug(7023) << "hasRef=" << url.hasRef();
      // Split path from ref/query
      // but not for "/tmp/a#b", if "a#b" is an existing file,
      // or for "/tmp/a?b" (#58990)
      if( ( url.hasRef() || !url.query().isEmpty() )
           && !url.path().endsWith(QL1S("/")) ) // /tmp/?foo is a namefilter, not a query
      {
        path = url.path();
        ref = url.ref();
        //kDebug(7023) << "isLocalFile set path to " << stringDetails( path );
        //kDebug(7023) << "isLocalFile set ref to " << stringDetails( ref );
        query = url.query();
        if (path.isEmpty() && url.hasHost())
          path = '/';
      }
      else
      {
        path = cmd;
        //kDebug(7023) << "(2) path=cmd=" << path;
      }
    }
  }

  if( path[0] == '~' )
  {
    int slashPos = path.indexOf('/');
    if( slashPos == -1 )
      slashPos = path.length();
    if( slashPos == 1 )   // ~/
    {
      path.replace ( 0, 1, QDir::homePath() );
    }
    else // ~username/
    {
      const QString userName (path.mid( 1, slashPos-1 ));
      KUser user (userName);
      if( user.isValid() && !user.homeDir().isEmpty())
      {
        path.replace (0, slashPos, user.homeDir());
      }
      else
      {
        if (user.isValid()) {
          setErrorMsg(data, i18n("<qt><b>%1</b> does not have a home folder.</qt>", userName));
        } else {
          setErrorMsg(data, i18n("<qt>There is no user called <b>%1</b>.</qt>", userName));
        }
        setUriType( data, KUriFilterData::Error );
        // Always return true for error conditions so
        // that other filters will not be invoked !!
        return true;
      }
    }
    expanded = true;
  }
  else if ( path[0] == '$' ) {
    // Environment variable expansion.
    if ( sEnvVarExp.indexIn( path ) == 0 )
    {
      QByteArray exp = qgetenv( path.mid( 1, sEnvVarExp.matchedLength() - 1 ).toLocal8Bit().data() );
      if(! exp.isNull())
      {
        path.replace( 0, sEnvVarExp.matchedLength(), QString::fromLocal8Bit(exp.constData()) );
        expanded = true;
      }
    }
  }

  if ( expanded || cmd.startsWith( '/' ) )
  {
    // Look for #ref again, after $ and ~ expansion (testcase: $QTDIR/doc/html/functions.html#s)
    // Can't use KUrl here, setPath would escape it...
    const int pos = path.indexOf('#');
    if ( pos > -1 )
    {
      const QString newPath = path.left( pos );
      if ( QFile::exists( newPath ) )
      {
        ref = path.mid( pos + 1 );
        path = newPath;
        //kDebug(7023) << "Extracted ref: path=" << path << " ref=" << ref;
      }
    }
  }


  bool isLocalFullPath = (!path.isEmpty() && path[0] == '/');

  // Checking for local resource match...
  // Determine if "uri" is an absolute path to a local resource  OR
  // A local resource with a supplied absolute path in KUriFilterData
  const QString abs_path = data.absolutePath();

  const bool canBeAbsolute = (protocol.isEmpty() && !abs_path.isEmpty());
  const bool canBeLocalAbsolute = (canBeAbsolute && abs_path[0] =='/' && !isMalformed);
  bool exists = false;

  /*kDebug(7023) << "abs_path=" << abs_path
               << "protocol=" << protocol
               << "canBeAbsolute=" << canBeAbsolute
               << "canBeLocalAbsolute=" << canBeLocalAbsolute
               << "isLocalFullPath=" << isLocalFullPath;*/

  KDE_struct_stat buff;
  if ( canBeLocalAbsolute )
  {
    QString abs = QDir::cleanPath( abs_path );
    // combine absolute path (abs_path) and relative path (cmd) into abs_path
    int len = path.length();
    if( (len==1 && path[0]=='.') || (len==2 && path[0]=='.' && path[1]=='.') )
        path += '/';
    //kDebug(7023) << "adding " << abs << " and " << path;
    abs = QDir::cleanPath(abs + '/' + path);
    //kDebug(7023) << "checking whether " << abs << " exists.";
    // Check if it exists
    if( KDE::stat( abs, &buff ) == 0 )
    {
      path = abs; // yes -> store as the new cmd
      exists = true;
      isLocalFullPath = true;
    }
  }

  if (isLocalFullPath && !exists && !isMalformed) {
    exists = ( KDE::stat( path, &buff ) == 0 );

    if ( !exists ) {
      // Support for name filter (/foo/*.txt), see also KonqMainWindow::detectNameFilter
      // If the app using this filter doesn't support it, well, it'll simply error out itself
      int lastSlash = path.lastIndexOf( '/' );
      if ( lastSlash > -1 && path.indexOf( ' ', lastSlash ) == -1 ) // no space after last slash, otherwise it's more likely command-line arguments
      {
        QString fileName = path.mid( lastSlash + 1 );
        QString testPath = path.left( lastSlash + 1 );
        if ( ( fileName.indexOf( '*' ) != -1 || fileName.indexOf( '[' ) != -1 || fileName.indexOf( '?' ) != -1 )
           && KDE::stat( testPath, &buff ) == 0 )
        {
          nameFilter = fileName;
          //kDebug(7023) << "Setting nameFilter to " << nameFilter;
          path = testPath;
          exists = true;
        }
      }
    }
  }

  //kDebug(7023) << "path =" << path << " isLocalFullPath=" << isLocalFullPath << " exists=" << exists;
  if( exists )
  {
    KUrl u;
    u.setPath(path);
    //kDebug(7023) << "ref=" << stringDetails(ref) << " query=" << stringDetails(query);
    u.setRef(ref);
    u.setQuery(query);

    if (!KAuthorized::authorizeUrlAction( QLatin1String("open"), KUrl(), u))
    {
      // No authorization, we pretend it's a file will get
      // an access denied error later on.
      setFilteredUri( data, u );
      setUriType( data, KUriFilterData::LocalFile );
      return true;
    }

    // Can be abs path to file or directory, or to executable with args
    bool isDir = S_ISDIR( buff.st_mode );
    if( !isDir && access ( QFile::encodeName(path).data(), X_OK) == 0 )
    {
      //kDebug(7023) << "Abs path to EXECUTABLE";
      setFilteredUri( data, u );
      setUriType( data, KUriFilterData::Executable );
      return true;
    }

    // Open "uri" as file:/xxx if it is a non-executable local resource.
    if( isDir || S_ISREG( buff.st_mode ) )
    {
      //kDebug(7023) << "Abs path as local file or directory";
      if ( !nameFilter.isEmpty() )
        u.setFileName( nameFilter );
      setFilteredUri( data, u );
      setUriType( data, ( isDir ) ? KUriFilterData::LocalDir : KUriFilterData::LocalFile );
      return true;
    }

    // Should we return LOCAL_FILE for non-regular files too?
    kDebug(7023) << "File found, but not a regular file nor dir... socket?";
  }

  if( data.checkForExecutables())
  {
    // Let us deal with possible relative URLs to see
    // if it is executable under the user's $PATH variable.
    // We try hard to avoid parsing any possible command
    // line arguments or options that might have been supplied.
    QString exe = removeArgs( cmd );
    //kDebug(7023) << "findExe with" << exe;

    if (!KStandardDirs::findExe( exe ).isNull() )
    {
      //kDebug(7023) << "EXECUTABLE  exe=" << exe;
      setFilteredUri( data, KUrl::fromPath( exe ));
      // check if we have command line arguments
      if( exe != cmd )
          setArguments(data, cmd.right(cmd.length() - exe.length()));
      setUriType( data, KUriFilterData::Executable );
      return true;
    }
  }

  // Process URLs of known and supported protocols so we don't have
  // to resort to the pattern matching scheme below which can possibly
  // slow things down...
  if ( !isMalformed && !isLocalFullPath && !protocol.isEmpty() )
  {
    //kDebug(7023) << "looking for protocol " << protocol;
    if ( KProtocolInfo::isKnownProtocol( protocol ) )
    {
      setFilteredUri( data, url );
      if ( protocol == QL1S("man") || protocol == QL1S("help") )
        setUriType( data, KUriFilterData::Help );
      else
        setUriType( data, KUriFilterData::NetProtocol );
      return true;
    }
  }

  // Short url matches
  if ( !cmd.contains( ' ' ) )
  {
    // Okay this is the code that allows users to supply custom matches for
    // specific URLs using Qt's regexp class. This is hard-coded for now.
    // TODO: Make configurable at some point...
    Q_FOREACH(const URLHint& hint, m_urlHints)
    {
      if (hint.regexp.indexIn(cmd) == 0)
      {
        //kDebug(7023) << "match - prepending" << (*it).prepend;
        const QString cmdStr = hint.prepend + cmd;
        KUrl url(cmdStr);
        if (KProtocolInfo::isKnownProtocol(url))
        {
          setFilteredUri( data, url );
          setUriType( data, hint.type );
          return true;
        }
      }
    }

    // No protocol and not malformed means a valid short URL such as kde.org or
    // [email protected]. However, it might also be valid only because it lacks
    // the scheme component, e.g. www.kde,org (illegal ',' before 'org'). The
    // check below properly deciphers the difference between the two and sends
    // back the proper result.
    if (protocol.isEmpty() && isPotentialShortURL(cmd))
    {
      QString urlStr = data.defaultUrlScheme();
      if (urlStr.isEmpty())
          urlStr = m_strDefaultUrlScheme;

      const int index = urlStr.indexOf(QL1C(':'));
      if (index == -1 || !KProtocolInfo::isKnownProtocol(urlStr.left(index)))
        urlStr += QL1S("://");
      urlStr += cmd;

      KUrl url (urlStr);
      if (url.isValid())
      {
        setFilteredUri(data, url);
        setUriType(data, KUriFilterData::NetProtocol);
      }
      else if (KProtocolInfo::isKnownProtocol(url.protocol()))
      {
        setFilteredUri(data, data.uri());
        setUriType(data, KUriFilterData::Error);
      }
      return true;
    }
  }
Ejemplo n.º 19
0
void MencoderTranscoding::updateArguments()
{
    QString fontFile = "/Users/doudou/workspaceQT/DLNA_server/exe/LucidaSansRegular.ttf";

    QStringList arguments;
    if (range() != 0 && !range()->isNull()) {
        if (range()->getStartByte() > 0 && lengthInSeconds() > 0) {
            double start_position = double(range()->getStartByte())/double(range()->getSize())*double(lengthInSeconds());
            arguments << "-ss" << QString("%1.0").arg(long(start_position));
        }
    } else if (timeSeekStart() > 0) {
        arguments << "-ss" << QString("%1.0").arg(timeSeekStart());
    }

    arguments << url();

    if (format() == MPEG2_AC3) {

        // set container format to MPEG
        arguments << "-of" << "mpeg";
        arguments << "-mpegopts" << "format=mpeg2:muxrate=500000:vbuf_size=1194:abuf_size=64";

        // set audio options
        arguments << "-oac" << "lavc";
        arguments << "-channels" << "6";
        arguments << "-af" << "lavcresample=48000";
        arguments << "-srate" << "48000";

        // set video options
        arguments << "-ovc" <<  "lavc";
        arguments << "-lavcopts" << "autoaspect=1:vcodec=mpeg2video:acodec=ac3:abitrate=448:keyint=25:vrc_maxrate=9800:vrc_buf_size=1835:vbitrate=5000";

        // set font file
        arguments << "-font" << fontFile;

        // set subtitles options
        arguments << "-ass" << "-ass-color" << "ffffff00" << "-ass-border-color" << "00000000" << "-ass-font-scale" << "1.4";
        arguments << "-ass-force-style" << QString("FontName=%1,Outline=1,Shadow=1,MarginV=10").arg(fontFile);

        // choose audio and subtitle language
        if (audioLanguages().contains("fre")) {
            arguments << "-aid" << QString("%1").arg(audioLanguages().indexOf("fre"));
            arguments << "-nosub";
        } else {
            if (subtitleLanguages().contains("fre")) {
                arguments << "-noautosub" << "-sid" << QString("%1").arg(subtitleLanguages().indexOf("fre"));
            } else if (subtitleLanguages().contains("eng")) {
                arguments << "-noautosub" << "-sid" << QString("%1").arg(subtitleLanguages().indexOf("eng"));
            }
        }

        // set frame rate
        if (!frameRate().isEmpty()) {
            if (frameRate() == "23.976") {
                arguments << "-ofps" << "24000/1001";
            } else if (frameRate() == "29.970") {
                arguments << "-ofps" << "30000/1001";
            } else {
                // default framerate output
                arguments << "-ofps" << "25.000";
            }
        } else {
            // default framerate output
            arguments << "-ofps" << "25.000";
        }

    } else {
        logError(QString("Invalid format: %1").arg(format()));
    }

    if (range() != 0 && !range()->isNull()) {
        if (range()->getLength() > 0) {
            if (range()->getHighRange() >= 0 && lengthInSeconds() > 0) {
                // calculate the endpos in seconds
                double endpos = double(range()->getLength())/double(range()->getSize())*double(lengthInSeconds());
                arguments << "-endpos" << QString("%1").arg(long(endpos));
            }
        } else {
            // invalid length
            arguments << "-endpos 0";
        }
    } else if (timeSeekEnd() > 0) {
        arguments << "-endpos" << QString("%1").arg(timeSeekEnd());
    }

    // set output = pipe
    arguments << "-o" << "-";

    // set option on loglevel (required to use seek time mode, option -ss)
    arguments << "-really-quiet";
    arguments << "-msglevel" << "statusline=2";

    setArguments(arguments);
}
Ejemplo n.º 20
0
Settings::Settings(int argc, char *argv[]) {

    if (argc == 1)
    {
        printUsage();
        return;
    }
  
	/* set default values for parameters */
	seed             = -1;
	areaFileName     = "";
	outputFileName   = "";
	historyFileName  = "";
	areaPosteriorFileName = "";
	nhxFileName = "";
	treeFileName     = "";
	chainLength      = 10000000;
	printFrequency   = 1000;
	parameterSampleFrequency  = 1000;
	historySampleFrequency = 1000;
	chainBurnIn = chainLength * 0.0;
    probBurnIn = chainLength * 0.25;
	geoDistanceType  = 1;
	geoDistancePower = 0.0;
	carryingCapacity = 0.5;
	carryingPower = 1.0;
	areaGainRate = 0.0;
	areaLossRate = 0.0;
    areaGainPrior = 1.0;
    areaLossPrior = 1.0;
    areaProposalTuner = 0.2;
    rateProposalTuner = 0.5;
    distanceProposalTuner = 0.5;
    useAuxiliarySampling = false;
    geoDistancePowerPrior = 1.0;
    geoDistancePositive = false;
    geoDistanceTruncate = false;
	pathGainRate = areaGainRate;
	pathLossRate = areaLossRate;

//	modelType = INDEPENDENCE;
//	modelType = CARRYING_CAPACITY;
	modelType = DISTANCE_NORM;
//	modelType = CARRYING_CAPACITY_AND_DISTANCE_NORM;

    guessInitialRates = true;
	useSimulate = false;
	useSteppingStone = false;
	betaSteppingStone = 1.0;

	treeScale = 1.0;

	inputFilePath = "./";
	outputFilePath = "./";
    timestampPrefix = "";
    useTimestampPrefix = true;
	outputPrefix = "";
	bgdFileName = "";
    
    //inputFilePath = "./examples/";
    //areaFileName = "vireya.areas.txt";
    //treeFileName = "vireya.tree.txt";
    //geoFileName = "vireya.geo.txt";

	// overwrite default arguments with command line arguments
	setArguments(argc, argv);
    
    if (seed == -1)
    {
        srand((unsigned int)time(NULL));
        seed = rand() % 100000 + 1;
    }

    // construct output file name
    std::stringstream ss;
    ss << "." << areaFileName;
    if (useSteppingStone == true)
    	ss << ".bss" << betaSteppingStone;
	ss << ".model" << modelType;
	ss << ".seed" << seed;
	if (modelType == DISTANCE_NORM || modelType == CARRYING_CAPACITY_AND_DISTANCE_NORM)
		ss << ".dp" << geoDistancePower;
	if (modelType == CARRYING_CAPACITY || modelType == CARRYING_CAPACITY_AND_DISTANCE_NORM)
	{
		ss << ".cc" << carryingCapacity;
		ss << ".cp" << carryingPower;
	}

    if (useTimestampPrefix)
    {
        timestampPrefix = Util::getTime();
        if (outputPrefix != "") outputPrefix += "." + timestampPrefix;
        else outputPrefix += timestampPrefix;
    }
	outputPrefix += ss.str();


    outputFileName = outputFilePath + outputPrefix + ".parameters.txt";
	historyFileName = outputFilePath + outputPrefix + ".area_states.txt";
	areaPosteriorFileName = outputFilePath + outputPrefix + ".area_probs.txt";
	
    nhxFileName = outputFilePath + outputPrefix + ".nhx";


}
Ejemplo n.º 21
0
void Console::updateCampaigns() {
	Game::getCampaigns(_campaigns);

	setArguments("loadcampaign", _campaigns);
}
Ejemplo n.º 22
0
 void LuaState::load( unsigned int threadId, bool exception, const char* init ) 
{
    TRACE_ENTERLEAVE();
    
    addPaths( "path" );
    addPaths( "cpath" );
    
    
    char script[ 1024 ];
    
    TRACE( "loading %s", m_filename.c_str() );
    setGlobal( "threadId", threadId );
    
    try
    {
        execute( "require 'leda'" );
        if ( init )
        {
            execute( init );
        }    
    }
    catch ( const  std::runtime_error& e )
    {
        if ( exception )
        {
            throw e;
        }
    }
    setArguments( );
    
    if ( m_filename.find( ".moon") != std::string::npos )
    {
        //
        //  moonscript
        //
        try
        {
            execute( "require 'moonscript'");
        }
        catch ( const std::runtime_error& e )
        {
            if ( exception )
            {
                throw e;
            }
            
            return;
        }
        
        sprintf( script, "local moonscript = require('moonscript'); "
        "moonscript.dofile('%s');", m_filename.c_str() ); 
    }
    else
    {
        //
        //  lua
        //
        sprintf( script,"dofile('%s');", m_filename.c_str() ); 
    }

    try
    {
        execute( script );
    }
    catch( const std::runtime_error& e )
    {
        if ( exception )
        {
            throw e;
        }
    }
    
   
   
}
Ejemplo n.º 23
0
void DataSource::requestData(QVariant args)
{
    setArguments(args);
}
Ejemplo n.º 24
0
void Console::updateAreas() {
	setArguments("gotoarea", _engine->getGame().getModule().getIFO().getAreas());
}
Ejemplo n.º 25
0
	/// Set the arguments for the program with an initializer_list
	/// \param init the initializer list
	/// \pre `started() == false`
	void setArguments(std::initializer_list<const char*> init) {
		setArguments(init.begin(), init.end());
	}
Ejemplo n.º 26
0
void Console::updateModules() {
	Game::getModules(_modules);

	setArguments("loadmodule", _modules);
}
Ejemplo n.º 27
0
Settings::Settings(int argc, char** argv)
{

	// Default initialization for Settings

	// Model settings
	seed = -1;
	modelType = 3;
	fixBranches = true;
	tuningBM = 0.9995;
	useJumpKernel = true;
	if (modelType == BM_ONLY)
		useJumpKernel = false;
	sigmaJumpProposal = 1.0;

    // Model switching
    useModelShift = false;
    modelShiftList.push_back(5);
    modelShiftList.push_back(10);

    // Rate switching
    useRateShift = false;
    rateShiftList.push_back(1);
    rateShiftList.push_back(1);

	// Stepping Stone settings
	useSteppingStone = false;
	betaSteppingStone = 1.0;
	printStdOut = true;

	// FFT settings -- currently unused
	useFFT = false;
	tipStdDev = 0.001;
	numSteps = pow(2, 16);	// 2^19 is the upper limit
	startStep = -10000.0;	//-300.0;
	finalStep = 10000.0;	//300.0;

	// MCMC settings
	numCycles = pow(10,6)*5;
	printFreqMH = 10000;//0000;
	printFreqJump = 10000;//0000;
	printFreqStdOut = 1000;//000;
	printFreqCRP = printFreqMH;
	printStdOut = true;
    snrBurnIn = 0.25 * numCycles;

	// CRP settings
	alphaCRP = 0.75;
	auxCRP = 3.0;
	aCRP = 1.0;
	bCRP = 1.0;
	useCRP = false;

	// GSL settings (NOTE: different models are numerically unstable for different GSL settings)
	workspaceSize = 30;
	integralLength = 5000.0;
	trigTableSize = 50;
	integralError = 1e-6;

	// File names
    inputDirPath = "./";
    outputDirPath = "./";
	outputFileName = "";

    
    //inputDirPath = "/Users/mlandis/data/expr_phylo/input/";
	//outputDirPath = "/Users/mlandis/data/expr_phylo/output/";

	simName = "cj." + Util::getTime();
	exprFileName = ""; //simName + ".data.txt";
	treeFileName = ""; //simName + ".tree.txt";
	taxaFileName = ""; //simName + ".taxa.txt";

	//simName = "default";
	//taxaFileName = "primates.eastman.isler_pruned.taxa.txt";
	//treeFileName = "primates.eastman.isler_pruned.tree.txt";
	//exprFileName = "primates.eastman.isler_pruned.mass.data.txt";

//    inputDirPath = "/Users/mlandis/Documents/code/creepy-jerk/examples/";
//    outputDirPath = "/Users/mlandis/Documents/code/creepy-jerk/examples/";
//    exprFileName = "primates.mass.data.txt";
//    treeFileName = "primates.tree.txt";
//    taxaFileName = "primates.taxa.txt";

    inputDirPath = "./";
    outputDirPath = "./";
    exprFileName = "";
    treeFileName = "";
    taxaFileName = "";

	// Assign settings arguments
	setArguments(argc, argv);

	// Assign settings string
	std::stringstream ss;
	ss << ".model" << modelType;
	ss << ".seed" << seed;
	if (useSteppingStone)
	{
		ss << ".betaSS" << betaSteppingStone;
	}

	if (outputFileName == "")
	{
		outputFileName = simName + ss.str() + "." + exprFileName;
	}

	print();
    check();
}
Ejemplo n.º 28
0
	void setArguments(Range&& range) {
		setArguments(std::forward<Range>(range).begin(), std::forward<Range>(range).end());
	}