Esempio n. 1
0
void slimIPC::save( void )
{
	string groupNames;
	configParser config;

	map<string, playList>::iterator itGroup;
	for(itGroup = group.begin(); itGroup != group.end(); itGroup++)
	{
		groupNames += itGroup->first + ",";
		string groupName = "group." + itGroup->first;
		playList &list = itGroup->second;
		char itemName[80];

		config.set(groupName, "position", configValue(list.currentItem) );
		for(size_t i=0; i < list.items.size(); i++)
		{
			sprintf(itemName, "item%03llu", (LLU)i);
			config.set(groupName, itemName, configValue(list.items[i]) );
		}
	}
	groupNames.erase( groupNames.size()-1 );	//remove trailing comma
	config.set("general", "groupNames", groupNames);

	config.write( playListFile.c_str() );
}
Esempio n. 2
0
FixBdaddr::FixBdaddr( QWidget* parent, Qt::WFlags fl )
:   QDialog( parent, fl )
{
    setWindowTitle(tr("Fix BT Address"));

    m_data = new FixBdaddr_Private;
    m_data->m_waitWidget = 0;

    QVBoxLayout* vbLayout = new QVBoxLayout(this);
    vbLayout->setMargin(0);
    vbLayout->setSpacing(0);

    m_data->m_list = new QListWidget(this);

    connect(m_data->m_list, SIGNAL(itemActivated(QListWidgetItem*)),
            this, SLOT(accept()));

    QListWidgetItem *item;
    item = new QListWidgetItem(option1, m_data->m_list);
    m_data->m_list->setCurrentItem(item);

    item = new QListWidgetItem(option2, m_data->m_list);

    m_data->m_list->setSelectionMode(QAbstractItemView::SingleSelection);
    m_data->m_list->setFrameStyle(QFrame::NoFrame);
    vbLayout->addWidget(m_data->m_list);

    QTelephonyConfiguration *config
            = new QTelephonyConfiguration( "modem" );   // No tr
    connect( config, SIGNAL(notification(QString,QString)),
             this, SLOT(configValue(QString,QString)) );
    config->request( "serial" );            // No tr
}
Esempio n. 3
0
void SeafileModel::init()
{
    QVariant token   ( configValue("token:blowfish") );
    QVariant baseUrl ( configValue("address")        );

    if(!baseUrl.type() != QVariant::String){
        qWarning() << "INVALID URL" << baseUrl;
        emit error(QString("Seafile: invalid address of type ") + token.typeName());
    }
    if(!token.type() != QVariant::String){
        qWarning() << "INVALID TOKEN" << token;
        emit error(QString("Seafile: invalid token of type ") + token.typeName());
    }
    this->m_server = new SeafileServer(baseUrl.toByteArray(), token.toByteArray());
    this->m_server->ping(true);

    connect(this->m_server, SIGNAL(loadingDone()),
            this          , SLOT(onLoadFinished())
            );
    connect(
            this->m_server, SIGNAL(file(QSharedPointer<SeafileFile>)),
            this          , SLOT  (onFile(QSharedPointer<SeafileFile>))
                );
}
Esempio n. 4
0
//
// Called the first time we use ClrRegCreateKeyEx or ClrRegOpenKeyEx to determine if the registry redirection
// config value has been set.  If so, we parse it into g_registryRoot
// If the config string is mal-formed, we don't set the global variable.
//
HRESULT ParseRegistryRootConfigValue()
{
    if (!IsNgenOffline())
    {
        return ERROR_SUCCESS;
    }
    
    CLRConfigStringHolder configValue(CLRConfig::GetConfigValue(CLRConfig::UNSUPPORTED_RegistryRoot));
    // Since IsNgenOffline returned true, this better not be NULL
    if (configValue == NULL)
        return ERROR_BAD_ARGUMENTS;
    
    if (_wcsnicmp(configValue, wszHKLM, wcslen(wszHKLM)) != 0)
    {
        return ERROR_BAD_ARGUMENTS;
    }
    
    // The rest of the string is the location of the redirected registry key
    LPWSTR configValueKey = (LPWSTR)configValue;
    configValueKey = _wcsninc(configValueKey, wcslen(wszHKLM));
    
    size_t len = wcslen(configValueKey) + 1;
    
    bool appendBackslash = false;
    if (configValueKey[wcslen(configValueKey) - 1] != W('\\'))
    {
        appendBackslash = true;
        len += wcslen(BACKSLASH_CHARACTER);
    }
    g_registryRoot = new (nothrow) WCHAR[len];
    
    if (g_registryRoot == NULL)
    {
        return ERROR_NOT_ENOUGH_MEMORY;
    }
    
    wcscpy_s(g_registryRoot, len, configValueKey);
    if (appendBackslash)
    {
        StringCchCat(g_registryRoot, len, BACKSLASH_CHARACTER);
    }
    
    return ERROR_SUCCESS;
}
Esempio n. 5
0
DevicePluginDateTime::DevicePluginDateTime() :
    m_timer(0),
    m_todayDevice(0),
    m_timeZone(QTimeZone("Europe/Vienna")),
    m_dusk(QDateTime()),
    m_sunrise(QDateTime()),
    m_noon(QDateTime()),
    m_sunset(QDateTime()),
    m_dawn(QDateTime())
{
    m_timer = new QTimer(this);
    m_timer->setInterval(1000);

    m_timeZone = QTimeZone(configValue("timezone").toByteArray());
    m_currentDateTime = QDateTime(QDate::currentDate(), QTime::currentTime(), m_timeZone);

    connect(m_timer, &QTimer::timeout, this, &DevicePluginDateTime::onSecondChanged);
    connect(this, &DevicePluginDateTime::configValueChanged, this, &DevicePluginDateTime::onConfigValueChanged);
}
Esempio n. 6
0
//static
void VolumeManager::InitConfig()
{
  MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());

  // This function uses /system/etc/volume.cfg to add additional volumes
  // to the Volume Manager.
  //
  // This is useful on devices like the Nexus 4, which have no physical sd card
  // or dedicated partition.
  //
  // The format of the volume.cfg file is as follows:
  // create volume-name mount-point
  // configure volume-name preference preference-value
  // Blank lines and lines starting with the hash character "#" will be ignored.

  ScopedCloseFile fp;
  int n = 0;
  char line[255];
  const char *filename = "/system/etc/volume.cfg";
  if (!(fp = fopen(filename, "r"))) {
    LOG("Unable to open volume configuration file '%s' - ignoring", filename);
    return;
  }
  while(fgets(line, sizeof(line), fp)) {
    n++;

    if (line[0] == '#')
      continue;

    nsCString commandline(line);
    nsCWhitespaceTokenizer tokenizer(commandline);
    if (!tokenizer.hasMoreTokens()) {
      // Blank line - ignore
      continue;
    }

    nsCString command(tokenizer.nextToken());
    if (command.EqualsLiteral("create")) {
      if (!tokenizer.hasMoreTokens()) {
        ERR("No vol_name in %s line %d",  filename, n);
        continue;
      }
      nsCString volName(tokenizer.nextToken());
      if (!tokenizer.hasMoreTokens()) {
        ERR("No mount point for volume '%s'. %s line %d",
             volName.get(), filename, n);
        continue;
      }
      nsCString mountPoint(tokenizer.nextToken());
      RefPtr<Volume> vol = FindAddVolumeByName(volName);
      vol->SetFakeVolume(mountPoint);
      continue;
    }
    if (command.EqualsLiteral("configure")) {
      if (!tokenizer.hasMoreTokens()) {
        ERR("No vol_name in %s line %d", filename, n);
        continue;
      }
      nsCString volName(tokenizer.nextToken());
      if (!tokenizer.hasMoreTokens()) {
        ERR("No configuration name specified for volume '%s'. %s line %d",
             volName.get(), filename, n);
        continue;
      }
      nsCString configName(tokenizer.nextToken());
      if (!tokenizer.hasMoreTokens()) {
        ERR("No value for configuration name '%s'. %s line %d",
            configName.get(), filename, n);
        continue;
      }
      nsCString configValue(tokenizer.nextToken());
      RefPtr<Volume> vol = FindVolumeByName(volName);
      if (vol) {
        vol->SetConfig(configName, configValue);
      } else {
        ERR("Invalid volume name '%s'.", volName.get());
      }
      continue;
    }
    if (command.EqualsLiteral("ignore")) {
      // This command is useful to remove volumes which are being tracked by
      // vold, but for which we have no interest.
      if (!tokenizer.hasMoreTokens()) {
        ERR("No vol_name in %s line %d", filename, n);
        continue;
      }
      nsCString volName(tokenizer.nextToken());
      RemoveVolumeByName(volName);
      continue;
    }
    ERR("Unrecognized command: '%s'", command.get());
  }
}
Esempio n. 7
0
//one thread per port:
void startThreads()
{
	// Default settings:
	configParser::config_t defaults;
	defaults["config"]["path"]	= configValue(".");		//path to configuration data of sub-modules
	defaults["musicDB"]["path"]	= configValue("." );	//path to music files
	defaults["musicDB"]["dbFile"] = configValue("SqueezeD.db");
	defaults["musicDB"]["dbIdx"]  = configValue("SqueezeD.idx");

	// Load configuration data
	db_printf(6,"Loading confugaration data from %s\n", configFile);
	configParser config(configFile, defaults);

	int shoutPort	= config.getset("shout", "port", 9000 );
	int shoutConn	= config.getset("shout", "maxConnections", 10 );
	int slimPort	= config.getset("slim",	 "port", 3483);
	string cfgPath= config.get("config", "path");
	string dbPath = config.get("musicDB", "path");
	string dbFile = config.get("musicDB", "dbFile");
	string dbIdx  = config.get("musicDB", "dbIdx");

	// Write back the default values, in case some are missing:
	config.write(configFile);

	// Initialize the database
	db_printf(6,"checking path '%s'\n", dbPath.c_str() );
	dbPath = path::normalize(dbPath);		// Resolve home directory ('~'), if required.

	db_printf(6,"opening musicDB '%s'\n", dbPath.c_str() );
	musicDB db( dbPath.c_str() );

	//Load database, or scan if it's missing:
	db.init( dbFile.c_str() , dbIdx.c_str() );

	db_printf(1,"found %llu files\n", (LLU)db.size() );

	//Both shout- and slim-server need to share some info.
	//	the IPC block will provide the mutexes for safe multi-threading
	//   slim relies on shout to keep it's playlist, and get stream-audio-formats??
	//   shout needs playback control from slim, and also status info.
	//	IPC keeps a playlist per group, and device status per device.
	//  for now, slim IPC can have only one client and one server
	//  since all initiative is from both servers, they both get an handle to the IPC
	slimIPC			ipc(&db, &config);
	TCPserverShout	shoutServer( &ipc, shoutPort, shoutConn);
	TCPserverSlim	slimServer( &ipc, slimPort);

	//shoutcast server in one thread:
	pthread_t thread;
	pthread_create( &thread, NULL, shoutThread, &shoutServer);

	//slim server in the main trhead:
	int i = slimServer.runNonBlock();
	printf("slimServer returned : %i\n", i);

	//stop the shoutcast server, when slim-server stops:
	shoutServer.stop = true;

	//wait for the thread to finish:
	pthread_join(thread, NULL);
}