Beispiel #1
0
void ownCloudInfo::slotAuthentication( QNetworkReply *reply, QAuthenticator *auth )
{
    if( !(auth && reply) ) return;
    QString configHandle;

    // an empty config handle is ok for the default config.
    if( _configHandleMap.contains(reply) ) {
        configHandle = _configHandleMap[reply];
        qDebug() << "Auth: Have a custom config handle: " << configHandle;
    }

    qDebug() << "Auth request to me and I am " << this;
    _authAttempts++;
    MirallConfigFile cfgFile( configHandle );
    qDebug() << "Authenticating request for " << reply->url();
    if( reply->url().toString().startsWith( cfgFile.ownCloudUrl( _connection, true )) ) {
        auth->setUser( cfgFile.ownCloudUser( _connection ) );
        auth->setPassword( cfgFile.ownCloudPasswd( _connection ));
    } else {
        qDebug() << "WRN: attempt to authenticate to different url - attempt " <<_authAttempts;
    }
    if( _authAttempts > 10 ) {
        qDebug() << "Too many attempts to authenticate. Stop request.";
        reply->close();
    }

}
Beispiel #2
0
CfgFile::CfgFile(string fileName) :
  cfgFileName(fileName) {
  ifstream cfgFile(cfgFileName.c_str(), ios::in);

  string currentPair;

  if (cfgFile.is_open()) {
    while (cfgFile.good()) {
      getline(cfgFile, currentPair);
      unsigned int delimPos = currentPair.find(":");

      //a comment or invalid string
      if (currentPair[0] == '#' || delimPos == string::npos || delimPos == 0) {
        continue;
      }

      string key = currentPair.substr(0, delimPos);
      string value = currentPair.substr(delimPos + 1, currentPair.length() - 1);

      //If either is empty we cry
      if (key == "" || value == "") {
        continue;
      }

      set<string>& values = parsedFile[key];
      values.insert(value);
    }
  } else {
    cerr << "Error reading file: " << fileName << endl;
  }
}
Beispiel #3
0
void MPDUser::setMusicFolder(const QString &folder)
{
    if (folder==det.dir) {
        return;
    }
    init(true);

    QFile cfgFile(Utils::dataDir(constDir, true)+constConfigFile);
    QStringList lines;
    if (cfgFile.open(QIODevice::ReadOnly|QIODevice::Text)) {
        while (!cfgFile.atEnd()) {
            QString line = QString::fromUtf8(cfgFile.readLine());
            if (line.startsWith(constMusicFolderKey)) {
                lines.append(constMusicFolderKey+" \""+folder+"\"\n");
            } else {
                lines.append(line);
            }
        }
    }

    if (!lines.isEmpty()) {
        cfgFile.close();
        if (cfgFile.open(QIODevice::WriteOnly|QIODevice::Text)) {
            QTextStream out(&cfgFile);
            foreach (const QString &line, lines) {
                out << line;
            }
        }
int main()
{
	
    // Settings
    bool isDebug = 0;                   // Running debug GUI?
    bool isTesting = 1;                 // Running from video file?
    bool hasGroundTruth = 0;            // Has labeled ground truth data?

    int nCameras = 1;                   // Number of cameras/video files.

    std::string videoFilePath = "data/someFile00.avi";          // Location of video file(s).
    std::string groundTruthPath = "data/someFile00GT.xml";      // Location of ground truth data for specified video

    cv::FileStorage cfgFile("settings.yml", cv::FileStorage::WRITE);

    cfgFile << "isDebug" << isDebug;
    cfgFile << "isTesting" << isTesting;
    cfgFile << "hasGroundTruth" << hasGroundTruth;
    cfgFile << "nCameras" << nCameras;
    cfgFile << "videoFilePath" << videoFilePath;
    cfgFile << "groundTruthPath" << groundTruthPath;

    cfgFile.release();

	
    DenseKitchen program;
    program.init();
    program.readConfig("settings.yml");
    debugging::logObject.dumpToConsole();
    return 0;
}	
bool ConfigurationManager::loadConfig(const boost::filesystem::path& path,
    boost::program_options::variables_map& variables,
    boost::program_options::options_description& description)
{
    boost::filesystem::path cfgFile(path);
    cfgFile /= std::string(openmwCfgFile);
    if (boost::filesystem::is_regular_file(cfgFile))
    {
        if (!mSilent)
            std::cout << "Loading config file: " << cfgFile.string() << "... ";

        boost::filesystem::ifstream configFileStreamUnfiltered(cfgFile);
        boost::iostreams::filtering_istream configFileStream;
        configFileStream.push(escape_hash_filter());
        configFileStream.push(configFileStreamUnfiltered);
        if (configFileStreamUnfiltered.is_open())
        {
            boost::program_options::store(boost::program_options::parse_config_file(
                configFileStream, description, true), variables);

            if (!mSilent)
                std::cout << "done." << std::endl;
            return true;
        }
        else
        {
            if (!mSilent)
                std::cout << "failed." << std::endl;
            return false;
        }
    }
    return false;
}
Beispiel #6
0
void BaseWindow::loadSettings()
{
    QFile cfgFile(this->cfgFileLocation);
    if (!cfgFile.exists())
        return;

    if (!cfgFile.open(QIODevice::ReadOnly | QIODevice::Text))
        return;

    QDomDocument doc;

    if (!doc.setContent(&cfgFile))
    {
        cfgFile.close();
        return;
    }

    cfgFile.close();

    QDomNodeList root = doc.elementsByTagName("Server");
    for (int i = 0; i < root.size(); i++)
    {
        QDomElement server = root.at(i).toElement();

        this->insertServer(server);
    }
}
Beispiel #7
0
bool App::readConfig()
{
    QFile cfgFile(Global::applicationFileName("iqnotes", "iqnotes.cfg"));

    if (!cfgFile.open(IO_ReadOnly))
    {
        if (!cfgFile.open(IO_WriteOnly))
            return false;

        return saveConfig();
    }
    cfgFile.close();

    CfgFileParser handler;
    QXmlInputSource *source;
    QXmlSimpleReader reader;

    connect(&handler, SIGNAL(configLoaded(const NotesConfig &)), this, SLOT(configLoaded(const NotesConfig &)));
    source = new QXmlInputSource(cfgFile);
    reader.setContentHandler(&handler);
    //    reader.setErrorHandler(new NotesFileParserError);
    if(!reader.parse(*source))
    {
        qWarning(tr("can't load config file"));
        delete source;

        return false;
    }

    delete source;
    return true;
}
void OwncloudSetupWizard::testOwnCloudConnect()
{
    // write a temporary config.
    QDateTime now = QDateTime::currentDateTime();
    _configHandle = now.toString(QLatin1String("MMddyyhhmmss"));

    MirallConfigFile cfgFile( _configHandle );

    cfgFile.writeOwncloudConfig( Theme::instance()->appName(),
                                 _ocWizard->field(QLatin1String("OCUrl")).toString(),
                                 _ocWizard->field(QLatin1String("OCUser")).toString(),
                                 _ocWizard->field(QLatin1String("OCPasswd")).toString(),
                                 _ocWizard->field(QLatin1String("secureConnect")).toBool(),
                                 _ocWizard->field(QLatin1String("PwdNoLocalStore")).toBool() );

    // If there is already a config, take its proxy config.
    if( ownCloudInfo::instance()->isConfigured() ) {
        MirallConfigFile prevCfg;
        if( prevCfg.proxyType() != QNetworkProxy::DefaultProxy ) {
            cfgFile.setProxyType( prevCfg.proxyType(), prevCfg.proxyHostName(), prevCfg.proxyPort(),
                                  prevCfg.proxyUser(), prevCfg.proxyPassword() );
        }
    }

    // now start ownCloudInfo to check the connection.
    ownCloudInfo* info = ownCloudInfo::instance();
    info->setCustomConfigHandle( _configHandle );
    if( info->isConfigured() ) {
        // reset the SSL Untrust flag to let the SSL dialog appear again.
        info->resetSSLUntrust();
        _checkInstallationRequest = info->checkInstallation();
    } else {
        qDebug() << "   ownCloud seems not to be configured, can not start test connect.";
    }
}
Beispiel #9
0
void BaseWindow::saveSettings()
{
    QDomDocument doc;

    QDomElement root = doc.createElement("RKnockSettings");
    root.setAttribute("Version", RKNOCK_CFG_VERSION);
    doc.appendChild(root);

    for(int i = 0; i < m_servers.size(); i++)
    {
        ServerRecord *rec = m_servers.at(i);
        QDomElement server = rec->toElement(doc);
        root.appendChild(server);
    }

    QFileInfo cfgFileInfo(this->cfgFileLocation);
    QDir cfgPath = cfgFileInfo.absoluteDir();

    // If the folder dosen't exist, make it!
    if (!cfgPath.exists())
        cfgPath.mkpath(".");

    QFile cfgFile(this->cfgFileLocation);

    QString xmlOut = doc.toString();
    if (!cfgFile.open(QIODevice::WriteOnly | QIODevice::Text))
    {
        QMessageBox::critical(this, "Unable to open Settings file for write.", QString("We were unable to open `%1` for writing, details below:\n\n%2").arg(cfgFileInfo.filePath(), cfgFile.errorString()));
        return;
    }

    QTextStream out(&cfgFile);
    out << "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\n" << xmlOut;
}
Beispiel #10
0
GlobalConfig::GlobalConfig(const char* cfgPath)
{
   WTON_ASSERT(theConfig == NULL);

   WTON::ClassNotation* classy = NULL;
   {
      classy = new WTON::ClassNotation();
      typedef GlobalConfig ActiveClass;

      // list members for wton serialization
      WTON_MEMBER(ZmakeToRoot);
      WTON_MEMBER(RootToProps);
      WTON_MEMBER(RootToSln);
      WTON_MEMBER(SlnToRoot);
      WTON_MEMBER(IncludePatterns);
      WTON_MEMBER(IgnorePatterns);
      WTON_MEMBER(AllPlatforms);
      WTON_MEMBER(AllConfigs);
      WTON_MEMBER(MsvcPlatforms);
      WTON_MEMBER(MakePlatforms);
      WTON_MEMBER(MsSlnFormatVersion);
      WTON_MEMBER(PchPattern);
      WTON_MEMBER(PchPrefix);
      WTON_MEMBER(LibPattern);
      WTON_MEMBER(SolutionPlatform);
      WTON_MEMBER(ExtensionItem);
      WTON_MEMBER(CompilationUnitExtensions);
      WTON_MEMBER(SuffixPlatforms);
      WTON_MEMBER(StubSuffix);
      WTON_MEMBER(AdditionalFileProps);
   }

   // default values
   MsSlnFormatVersion = "11.00";
   StubSuffix = "_Stub";

   WTON::TokenFile cfgFile(cfgPath);
   classy->load(cfgFile, this);

#ifdef WTON_PC
   RootToProps.replace("/", "\\");
   SlnToRoot.replace("/", "\\");
   RootToSln.replace("/", "\\");
#endif

   for (int i = 0; i < AllPlatforms.len(); ++i)
   {
      const String& p = AllPlatforms[i];
      String& p2 = SolutionPlatform[p];

      // unspecified Platforms have the same Solution name as Project name
      if (p2.empty())
      {
         p2 = p;
      }
   }

   theConfig = this;
}
void Settings::saveSettings() const {
  QFile cfgFile(getDataDir().absoluteFilePath(QCoreApplication::applicationName() + ".cfg"));
  if (cfgFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
    QJsonDocument cfg_doc(m_settings);
    cfgFile.write(cfg_doc.toJson());
    cfgFile.close();
  }
}
Beispiel #12
0
QNetworkReply *ownCloudInfo::checkInstallation()
{
    _redirectCount = 0;
    MirallConfigFile cfgFile(  _configHandle );
    QUrl url ( cfgFile.ownCloudUrl( _connection ) +  QLatin1String("status.php") );
    /* No authentication required for this. */
    return getRequest(url);
}
// ----------------------------------------------------------------------------
void CodeSnippetsConfig::SettingsLoad()
// ----------------------------------------------------------------------------
{
        // file will be saved in $HOME/codesnippets.ini


    #ifdef LOGGING
     wxString fn(__FUNCTION__, wxConvUTF8);
     LOGIT( _T("--- [%s] ---"),fn.c_str() );
     LOGIT(wxT("Loading Settings File[%s]"),SettingsSnippetsCfgPath.c_str());
    #endif //LOGGING

    wxFileConfig cfgFile(
                    wxEmptyString,              // appname
                    wxEmptyString,              // vendor
                    SettingsSnippetsCfgPath,// local filename
                    wxEmptyString,              // global file
                    wxCONFIG_USE_LOCAL_FILE);

	cfgFile.Read( wxT("ExternalEditor"),  &SettingsExternalEditor, wxEmptyString ) ;
	cfgFile.Read( wxT("SnippetFile"),     &SettingsSnippetsXmlPath, wxEmptyString ) ;
	cfgFile.Read( wxT("SnippetFolder"),   &SettingsSnippetsFolder, wxEmptyString ) ;
	cfgFile.Read( wxT("ViewSearchBox"),   &GetConfig()->SettingsSearchBox, true ) ;
	cfgFile.Read( wxT("casesensitive"),   &m_SearchConfig.caseSensitive, true ) ;
	int nScope;
	cfgFile.Read( wxT("scope"),             &nScope, SCOPE_BOTH ) ;
    m_SearchConfig.scope = (SearchScope)nScope;

    // read Editors Stay-On-Top of main window option
    cfgFile.Read( _T("EditorsStayOnTop"), &SettingsEditorsStayOnTop, true);
    // read Editors ToolTips option
    cfgFile.Read( _T("ToolTipsOption"), &SettingsToolTipsOption, true);

    // Read External App state. Launched App will see it as false because
    // plugin has not set it true yet, so if this is launched App, set it true
	cfgFile.Read( wxT("ExternalPersistentOpen"), &m_IsExternalPersistentOpen, false ) ;
	if ( IsApplication() ) SetExternalPersistentOpen(true);

    // read user specified window state (External, Floating, or Docked)
    cfgFile.Read( wxT("WindowState"), &m_SettingsWindowState, wxT("Floating") );
    #if defined(LOGGING)
     LOGIT( _T("WindowState[%s]"), GetSettingsWindowState().c_str() );
    #endif
    // read last window position
    wxString winPos;
    cfgFile.Read( wxT("WindowPosition"),  &winPos, wxEmptyString) ;
    if ( not winPos.IsEmpty() )
    {
        const wxWX2MBbuf buf = csU2C(winPos);
        std::string cstring( buf );
        std::stringstream istream(cstring);
        istream >> windowXpos ;
        istream >> windowYpos ;
        istream >> windowWidth ;
        istream >> windowHeight ;
    }
    else
    {
Beispiel #14
0
void OwncloudSetupWizard::slotNoOwnCloudFound( QNetworkReply *err )
{
    _ocWizard->appendToResultWidget(tr("<font color=\"red\">Failed to connect to %1!</font>")
                                    .arg(Theme::instance()->appNameGUI()));
    _ocWizard->appendToResultWidget(tr("Error: <tt>%1</tt>").arg(err->errorString()) );

    // remove the config file again
    MirallConfigFile cfgFile( _configHandle );
    cfgFile.cleanupCustomConfig();
    finalizeSetup( false );
}
void OwncloudSetupWizard::testOwnCloudConnect()
{
    // write a temporary config.
    QDateTime now = QDateTime::currentDateTime();

    // remove a possibly existing custom config.
    if( ! _configHandle.isEmpty() ) {
        // remove the old config file.
        MirallConfigFile oldConfig( _configHandle );
        oldConfig.cleanupCustomConfig();
    }

    _configHandle = now.toString(QLatin1String("MMddyyhhmmss"));

    MirallConfigFile cfgFile( _configHandle );
    QString url = _ocWizard->field(QLatin1String("OCUrl")).toString();
    if( url.isEmpty() ) return;
    if( !( url.startsWith(QLatin1String("https://")) || url.startsWith(QLatin1String("http://"))) ) {
        qDebug() << "url does not start with a valid protocol, assuming https.";
        url.prepend(QLatin1String("https://"));
        // FIXME: give a hint about the auto completion
        _ocWizard->setOCUrl(url);
    }
    cfgFile.writeOwncloudConfig( Theme::instance()->appName(),
                                 url,
                                 _ocWizard->field(QLatin1String("OCUser")).toString(),
                                 _ocWizard->field(QLatin1String("OCPasswd")).toString() );

    // If there is already a config, take its proxy config.
    if( ownCloudInfo::instance()->isConfigured() ) {
        MirallConfigFile prevCfg;
        if( prevCfg.proxyType() != QNetworkProxy::DefaultProxy ) {
            cfgFile.setProxyType( prevCfg.proxyType(), prevCfg.proxyHostName(), prevCfg.proxyPort(),
                                  prevCfg.proxyUser(), prevCfg.proxyPassword() );
        }
    }

    // now start ownCloudInfo to check the connection.
    ownCloudInfo* info = ownCloudInfo::instance();
    info->setCustomConfigHandle( _configHandle );
    if( info->isConfigured() ) {
        // reset the SSL Untrust flag to let the SSL dialog appear again.
        info->resetSSLUntrust();
        connect(info, SIGNAL(ownCloudInfoFound(QString,QString,QString,QString)),
                SLOT(slotOwnCloudFound(QString,QString,QString,QString)));
        connect(info, SIGNAL(noOwncloudFound(QNetworkReply*)),
                SLOT(slotNoOwnCloudFound(QNetworkReply*)));
        _checkInstallationRequest = info->checkInstallation();
    } else {
        qDebug() << "   ownCloud seems not to be configured, can not start test connect.";
    }
}
Beispiel #16
0
void ExportInstWizard::GetIncludedConfigs(wxArrayString *out)
{
	for (unsigned i = 0; i < cfgListCtrl->GetCount(); i++)
	{
		if (cfgListCtrl->IsChecked(i))
		{
			wxFileName cfgFile(cfgListCtrl->GetString(i));
			cfgFile.Normalize(wxPATH_NORM_ALL, m_inst->GetRootDir().GetFullPath());
			cfgFile.MakeRelativeTo();
			out->Add(cfgFile.GetFullPath());
		}
	}
}
Beispiel #17
0
/**
 * Returns true if successful.
 */
bool readConfig(config_t& config)
{
    string cfgFile(GetPESInfo()->mydir);
    cfgFile += "\\speeder.cfg";

	FILE* cfg = fopen(cfgFile.c_str(), "rt");
	if (cfg == NULL) return false;

	char str[BUFLEN];
	char name[BUFLEN];
	int value = 0;
	float dvalue = 0.0f;

	char *pName = NULL, *pValue = NULL, *comment = NULL;
	while (true)
	{
		ZeroMemory(str, BUFLEN);
		fgets(str, BUFLEN-1, cfg);
		if (feof(cfg)) break;

		// skip comments
		comment = strstr(str, "#");
		if (comment != NULL) comment[0] = '\0';

		// parse the line
		pName = pValue = NULL;
		ZeroMemory(name, BUFLEN); value = 0;
		char* eq = strstr(str, "=");
		if (eq == NULL || eq[1] == '\0') continue;

		eq[0] = '\0';
		pName = str; pValue = eq + 1;

		ZeroMemory(name, NULL); 
		sscanf(pName, "%s", name);

		if (strcmp(name, "debug")==0)
		{
			if (sscanf(pValue, "%d", &value)!=1) continue;
			config.debug = value;
		}
        else if (strcmp(name, "count.factor")==0)
		{
            float value = 1.0;
			if (sscanf(pValue, "%f", &value)!=1) continue;
			config.count_factor = min(max(value,0.1),2.5);
		}
	}
	fclose(cfg);
	return true;
}
Beispiel #18
0
void Parameters::parseParametersFromConfigFile(std::string cfgFileName){
	std::string line;
	//Open config file passed as parameter
	std::ifstream cfgFile(cfgFileName.c_str());
	//Save parameters temporarily in a Map to ease its retrieval later
	std::map<std::string,std::string> parameters;
	if (cfgFile.is_open()){
		//Read file line by line:
		while( getline(cfgFile, line)){
			if(line.length() > 0){
				std::vector<std::string> parsed = parseLine(line);
				//Add the parsed elements to an appropriate structure:
				if(parsed.size() == 2){
					parameters[parsed[0]] = parsed[1];
				}
			}
		}
		cfgFile.close();
	}
	else{
		printf("Unable to open the file '%s', defined as the configuration file.\n", cfgFileName.c_str());
	}

	this->setAlpha(atof(parameters["ALPHA"].c_str()));
	this->setGamma(atof(parameters["GAMMA"].c_str()));
	this->setEpsilon(atof(parameters["EPSILON"].c_str()));
	this->setLambda(atof(parameters["LAMBDA"].c_str()));
	this->setDisplay(atoi(parameters["DISPLAY"].c_str()));
	this->setEpisodeLength(atoi(parameters["EPISODE_LENGTH"].c_str()));
	this->setNumEpisodesLearn(atoi(parameters["NUM_EPISODES_LEARN"].c_str()));
	this->setNumEpisodesEval(atoi(parameters["NUM_EPISODES_EVAL"].c_str()));
	this->setNumStepsPerAction(atoi(parameters["NUM_STEPS_PER_ACTION"].c_str()));
	this->setNumRows(atoi(parameters["NUM_ROWS"].c_str()));
	this->setNumColumns(atoi(parameters["NUM_COLUMNS"].c_str()));
	this->setNumColors(atoi(parameters["NUM_COLORS"].c_str()));
	this->setIsMinimalAction(atoi(parameters["USE_MIN_ACTIONS"].c_str()));
	this->setTraceThreshold(atof(parameters["TRACE_THRESHOLD"].c_str()));
	this->setUseRewardSign(atoi(parameters["USE_REWARD_SIGN"].c_str()));
	this->setSubtractBackground(atoi(parameters["SUBTRACT_BACKGROUND"].c_str()));
	this->setToSaveTrajectory(atoi(parameters["SAVE_TRAJECTORY"].c_str()));
	this->setOptimisticInitialization(atoi(parameters["OPTIMISTIC_INIT"].c_str()));

	this->setFrequencySavingWeights(atoi(parameters["FREQUENCY_SAVING"].c_str()));
	this->setLearningLength(atoi(parameters["TOTAL_FRAMES_LEARN"].c_str()));

	if(this->getSubtractBackground()){
		std::string folderWithBackgrounds = parameters["PATH_TO_BACKGROUND"];
		setPathToBackground(folderWithBackgrounds, this->gameBeingPlayed);
	}
}
void OwncloudSetupWizard::slotNoOwnCloudFound( QNetworkReply *err )
{
    disconnect(ownCloudInfo::instance(), SIGNAL(ownCloudInfoFound(QString,QString,QString,QString)),
               this, SLOT(slotOwnCloudFound(QString,QString,QString,QString)));
    disconnect(ownCloudInfo::instance(), SIGNAL(noOwncloudFound(QNetworkReply*)),
               this, SLOT(slotNoOwnCloudFound(QNetworkReply*)));

    _ocWizard->displayError(tr("Failed to connect to %1:<br/>%2").
                            arg(Theme::instance()->appNameGUI()).arg(err->errorString()));

    // remove the config file again
    MirallConfigFile cfgFile( _configHandle );
    cfgFile.cleanupCustomConfig();
    finalizeSetup( false );
}
Beispiel #20
0
/**
 *  \brief
 */
bool DbConfig::SaveToFolder(const CPath& cfgFileFolder) const
{
    CPath cfgFile(cfgFileFolder);
    cfgFile += cPluginCfgFileName;

    FILE* fp;
    _tfopen_s(&fp, cfgFile.C_str(), _T("wt"));
    if (fp == NULL)
        return false;

    bool success = Write(fp);
    fclose(fp);

    return success;
}
Beispiel #21
0
EmailNotify::EmailNotify()
{
	bool serverFound = 0, portFound = 0, replyFound = 0;
	QString port;

	configOk = 0;
	QFile cfgFile("email_config.xml");
	cfgFile.open(QIODevice::ReadOnly | QIODevice::Text);
	if (!cfgFile.isOpen()) {
		qWarning() << tr("Unable to open Email Config File!");
		return;
	}

	QXmlStreamReader xml(&cfgFile);
	while (!xml.atEnd() && !xml.hasError())	{
		xml.readNext();
		if (xml.tokenType() == QXmlStreamReader::StartElement && xml.name() == "server") {
			server = User::getXmlString(&xml);
			if (server.size())
				serverFound = 1;
		}
		else if (xml.tokenType() == QXmlStreamReader::StartElement && xml.name() == "port") {
			port = User::getXmlString(&xml);
			if (port.size()) {
				portFound = 1;
				server+= ':' + port;
			}
		}
		else if (xml.tokenType() == QXmlStreamReader::StartElement && xml.name() == "reply") {
			reply = User::getXmlString(&xml);
			if (reply.size())
				replyFound = 1;
		}
	}

	if (!serverFound)
		qWarning() << tr("Email config has no server specified");
	if (!portFound)
		qWarning() << tr("Email config has no port specified");
	if (!replyFound)
		qWarning() << tr("Email config has no reply address specified");

	if (serverFound && portFound && replyFound)
		configOk = 1;

	cfgFile.close();
}
Beispiel #22
0
QNetworkReply* ownCloudInfo::mkdirRequest( const QString& dir )
{
    qDebug() << "OCInfo Making dir " << dir;

    MirallConfigFile cfgFile( _configHandle );
    QUrl url = QUrl( cfgFile.ownCloudUrl( _connection, true ) + dir );
    QHttp::ConnectionMode conMode = QHttp::ConnectionModeHttp;
    if (url.scheme() == "https")
        conMode = QHttp::ConnectionModeHttps;

    QHttp* qhttp = new QHttp(QString(url.encodedHost()), conMode, 0, this);

    connect(qhttp, SIGNAL(requestStarted(int)), this,SLOT(qhttpRequestStarted(int)));
    connect(qhttp, SIGNAL(requestFinished(int, bool)), this,SLOT(qhttpRequestFinished(int,bool)));
    connect(qhttp, SIGNAL(responseHeaderReceived(QHttpResponseHeader)), this, SLOT(qhttpResponseHeaderReceived(QHttpResponseHeader)));
    //connect(qhttp, SIGNAL(authenticationRequired(QString,quint16,QAuthenticator*)), this, SLOT(qhttpAuthenticationRequired(QString,quint16,QAuthenticator*)));

    QHttpRequestHeader header("MKCOL", QString(url.encodedPath()), 1,1);   /* header */
    header.setValue("Host", QString(url.encodedHost()));
    header.setValue("User-Agent", QString("mirall-%1").arg(MIRALL_STRINGIFY(MIRALL_VERSION)).toAscii() );
    header.setValue("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
    header.setValue("Accept-Language", "it,de-de;q=0.8,it-it;q=0.6,en-us;q=0.4,en;q=0.2");
    header.setValue("Connection", "keep-alive");
    header.setContentType("application/x-www-form-urlencoded"); //important
    header.setContentLength(0);

    QString con = _configHandle;
    if( con.isEmpty() ) con = DEFAULT_CONNECTION;
    if( _credentials.contains(con)) {
        oCICredentials creds = _credentials.value(con);
        QString concatenated = creds.user + QLatin1Char(':') + creds.passwd;
        const QString b(QLatin1String("Basic "));
        QByteArray data = b.toLocal8Bit() + concatenated.toLocal8Bit().toBase64();
        header.setValue("Authorization", data);

        qhttp->setUser( creds.user, creds.passwd );
    }

    int david = qhttp->request(header,0,0);
    //////////////// connect(davinfo, SIGNAL(dataSendProgress(int,int)), this, SLOT(SendStatus(int, int)));
    /////////////////connect(davinfo, SIGNAL(done(bool)), this,SLOT(DavWake(bool)));
    //connect(_http, SIGNAL(requestFinished(int, bool)), this,SLOT(qhttpRequestFinished(int,bool)));
    ///////////connect(davinfo, SIGNAL(responseHeaderReceived(constQHttpResponseHeader &)), this, SLOT(RegisterBackHeader(constQHttpResponseHeader &)));

    return NULL;
}
int main(int argc, char **argv)
{
    /// ----------------------------------------
    std::string fname = cfgFile(argc, argv);

    /// ------ Define your application here ----
    AAAD_AppDiameterEap diamEap;

    /// ------ Register applications here ------
    AAAD_FRAMEWORK().Register(diamEap);

    /// ------ Application main loop -----------
    AAAD_FRAMEWORK().Start(fname);
    while (AAAD_FRAMEWORK().IsRunning()) {
    }
    AAAD_FRAMEWORK().Stop();

    return (0);
}
Beispiel #24
0
void IniConfig::readFromFile( const QString & fileName, bool overwriteExisting )
{
	QString file = fileName;
	if( file.isEmpty() )
		file = mFile;

	if( !QFile::exists(file) ) {
		LOG_5( "Config file doesn't exist at: " + file );
		return;
	}
	
	QFile cfgFile(file);
	if( !cfgFile.open(QIODevice::ReadOnly) ) {
		LOG_5( "Unable to open config file for reading at: " + fileName );
		return;
	}
	
	QTextStream in(&cfgFile);
	while(!in.atEnd()){
		QString l = in.readLine();
		if( l.startsWith("[") && l.endsWith("]") ){
			mSection = l.mid(1,l.length()-2);
			if( mSection == "NO_SECTION" )
				mSection = QString::null;
			continue;
		}
		int equalsPos = l.indexOf('=');
		if( equalsPos < 0 )
			continue;
		QString key = l.left(equalsPos);
		QString val = l.mid(equalsPos+1);
		if( key.isEmpty() )
			continue;
		
		if( overwriteExisting || !mValMap[mSection].contains( key ) ) {
			mValMap[mSection][key] = val;
			mValMap[mSection][key.toLower()] = val;
		}
	}
	cfgFile.close();
}
int Structure::loadConfigFromFile(string fileName) {
  string fullPath = "config/" + fileName;
  ifstream cfgFile(fullPath.c_str());
  if (!cfgFile.is_open()) {
    cfgFile.close();
    return FAIL;
  }
  string tmp;

  getline(cfgFile, tmp);
  cfgFile >> dim.x; 
  getline(cfgFile, tmp);
  getline(cfgFile, tmp);
  cfgFile >> dim.y;
  getline(cfgFile, tmp);
  getline(cfgFile, tmp);
  cfgFile >> dim.z;
  
  cfgFile.close();
  return SUCCESS;
}
Beispiel #26
0
void ownCloudInfo::getRequest( const QString& path, bool webdav )
{
    qDebug() << "Get Request to " << path;

    MirallConfigFile cfgFile(  _configHandle );
    QString url = cfgFile.ownCloudUrl( _connection, webdav ) + path;
    QNetworkRequest request;
    request.setUrl( QUrl( url ) );
    setupHeaders( request, 0 );

    QNetworkReply *reply = _manager->get( request );
    connect( reply, SIGNAL(finished()), SLOT(slotReplyFinished()));
    _directories[reply] = path;

    if( !_configHandle.isEmpty() ) {
        qDebug() << "Setting config handle " << _configHandle;
        _configHandleMap[reply] = _configHandle;
    }

    connect( reply, SIGNAL( error(QNetworkReply::NetworkError )),
             this, SLOT(slotError( QNetworkReply::NetworkError )));
}
Beispiel #27
0
void ownCloudInfo::mkdirRequest( const QString& dir )
{
    qDebug() << "OCInfo Making dir " << dir;
    _authAttempts = 0;
    MirallConfigFile cfgFile( _configHandle );
    QNetworkRequest req;
    req.setUrl( QUrl( cfgFile.ownCloudUrl( _connection, true ) + dir ) );
    QNetworkReply *reply = davRequest(QLatin1String("MKCOL"), req, 0);

    // remember the confighandle used for this request
    if( ! _configHandle.isEmpty() )
        qDebug() << "Setting config handle " << _configHandle;
    _configHandleMap[reply] = _configHandle;

    if( reply->error() != QNetworkReply::NoError ) {
        qDebug() << "mkdir request network error: " << reply->errorString();
    }

    connect( reply, SIGNAL(finished()), SLOT(slotMkdirFinished()) );
    connect( reply, SIGNAL( error(QNetworkReply::NetworkError )),
             this, SLOT(slotError(QNetworkReply::NetworkError )));
}
Beispiel #28
0
/**
 *  \brief
 */
bool DbConfig::LoadFromFolder(const CPath& cfgFileFolder)
{
    SetDefaults();

    CPath cfgFile(cfgFileFolder);
    cfgFile += cPluginCfgFileName;

    if (!cfgFile.FileExists())
        return false;

    FILE* fp;
    _tfopen_s(&fp, cfgFile.C_str(), _T("rt"));
    if (fp == NULL)
        return false;

    bool success = true;

    TCHAR line[8192];
    while (_fgetts(line, _countof(line), fp))
    {
        // Comment or empty line
        if (line[0] == _T('#') || line[0] == _T('\n'))
            continue;

        // Strip newline from the end of the line
        line[_tcslen(line) - 1] = 0;

        if (!ReadOption(line))
        {
            success = false;
            SetDefaults();
            break;
        }
    }

    fclose(fp);

    return success;
}
Beispiel #29
0
void ConfigurationManager::loadConfig(const boost::filesystem::path& path,
    boost::program_options::variables_map& variables,
    boost::program_options::options_description& description)
{
    boost::filesystem::path cfgFile(path);
    cfgFile /= std::string(openmwCfgFile);
    if (boost::filesystem::is_regular_file(cfgFile))
    {
        std::cout << "Loading config file: " << cfgFile.string() << "... ";

        std::ifstream configFileStream(cfgFile.string().c_str());
        if (configFileStream.is_open())
        {
            boost::program_options::store(boost::program_options::parse_config_file(
                configFileStream, description, true), variables);

            std::cout << "done." << std::endl;
        }
        else
        {
            std::cout << "failed." << std::endl;
        }
    }
}
Beispiel #30
0
int DirScaner::loadConfig()
{
    string line;
    ifstream cfgFile(m_config.c_str());

    m_buffer.clear();
    if (cfgFile.is_open())
    {
        while (getline (cfgFile, line))
        {
            vector<string> sVec;
            sVec = split(line, ' ');
            string dirStr = sVec[0];
            for(int k = 1; k < sVec.size()-1; k++) {
                dirStr += ' ';
                dirStr += sVec[k];
            }
            string timeStr = sVec[sVec.size()-1];

            long int time = strtol(timeStr.c_str(), NULL, 10);
            if(time == 0)
                time = 60;
            syslog(LOG_NOTICE, "[LoadConfig] Check %s every %d sec.\n", dirStr.c_str(), time);
            f_info i;
            i.dirName = dirStr;
            i.mTime = time;
            m_buffer.push_back(i);
        }
        cfgFile.close();
    }
    else {
        syslog(LOG_ERR, "[LoadConfig] Open config failed (%s)\n", strerror(errno));
        return -1;
    }
    return 0;
}