SettingsPtr Private::DefaultProfile::applicationSettings(const QString &name) const { #if defined(Q_OS_WIN) || defined(Q_OS_MAC) return SettingsPtr(new QSettings(QSettings::IniFormat, QSettings::UserScope, profileName(), name)); #else return SettingsPtr(new QSettings(profileName(), name)); #endif }
void Settings::saveProfile() { std::stringstream s; s << m_profileName << "-" << time(0); std::string profileName( s.str() ); // std::string fulldir(savedir + "/" + profileName); //FIXME: savedir get from settings.xml for string "profiles". // thus fulldir is effectively "${PWD}/profiles" // should fix it as to Dirlayout::progdir, which is "${HOME}/.critterding" //bypass the input parameter savedir std::string fulldir(dirlayout->profiledir); if ( !dirH.exists(fulldir) ) dirH.make(fulldir); std::string filename(fulldir + "/" + profileName + ".pro"); std::stringstream buf; for( auto cvarit = cvarlist.begin(); cvarit != cvarlist.end(); ++cvarit ) { if ( cvarit->second && !cvarit->second->isLocal() ) { if ( cvarit->second->getType() == T_INT ) buf << cvarit->first << " " << cvarit->second->getIntValue() << std::endl; else if ( cvarit->second->getType() == T_STRING ) buf << cvarit->first << " " << cvarit->second->getStringValue() << std::endl; } } m_filesystem.save(filename, buf.str()); std::string msg("Profile saved to: " + filename); m_logBuffer->add(msg); std::cerr << msg << std::endl; }
bool CollectForOutput::collectProfiles() { int c = 0; ProfilesL::Iterator itend = docProfiles.end(); for (ProfilesL::Iterator it = docProfiles.begin(); it != itend; ++it) { QString profileName(it.key()); QString oldFile(it.value()); QString outFile(m_outputDirectory + "profiles/" + QFileInfo(oldFile).fileName()); bool success = copyFileAtomic(oldFile, outFile); if (!success) qDebug()<<"CollectForOutput::collectFile copyFileAtomic failed for"<<oldFile<<"to"<<outFile; #ifndef Q_OS_WIN32 else { QFile of(outFile); if (of.exists()) { bool permsSet=of.setPermissions(QFile::permissions(oldFile)); if (!permsSet) qDebug()<<"Unable to set permissions successfully while collecting for output on"<<outFile; } else qDebug()<<"Unable to set permissions successfully while collecting for output on"<<outFile<<"as the file does not exist"; } #endif if (uiCollect) emit profilesCollected(c++); } return true; }
void Settings::saveProfile( const std::string& savedir ) { std::stringstream s; s << time(0); std::string profileName( s.str() ); // std::string fulldir(savedir + "/" + profileName); std::string fulldir(savedir); if ( !dirH.exists(fulldir) ) dirH.make(fulldir); std::string filename(fulldir + "/" + profileName + ".pro"); std::stringstream buf; for( auto cvarit = cvarlist.begin(); cvarit != cvarlist.end(); ++cvarit ) { if ( cvarit->second && !cvarit->second->isLocal() ) { if ( cvarit->second->getType() == T_INT ) buf << cvarit->first << " " << cvarit->second->getIntValue() << std::endl; else if ( cvarit->second->getType() == T_STRING ) buf << cvarit->first << " " << cvarit->second->getStringValue() << std::endl; } } m_filesystem.save(filename, buf.str()); std::string msg("Profile saved to: " + filename); m_logBuffer->add(msg); std::cerr << msg << std::endl; }
QString Private::DefaultProfile::dataLocation() const { #if defined(Q_OS_WIN) || defined (Q_OS_MAC) return locationWithConfigurationName(QStandardPaths::AppLocalDataLocation); #else // on Linux gods know why qBittorrent creates 'data' subdirectory in ~/.local/share/ return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/data/") + profileName() + QLatin1Char('/'); #endif }
void DiamondcardProfileForm::validate() { if (accountIdLineEdit->text().isEmpty()) { ((t_gui *)ui)->cb_show_msg(this, tr("Fill in your account ID.").toStdString(), MSG_CRITICAL); accountIdLineEdit->setFocus(); return; } if (pinCodeLineEdit->text().isEmpty()) { ((t_gui *)ui)->cb_show_msg(this, tr("Fill in your PIN code.").toStdString(), MSG_CRITICAL); pinCodeLineEdit->setFocus(); return; } QString profileName("Diamondcard-"); profileName.append(accountIdLineEdit->text()); QString filename(profileName); filename.append(USER_FILE_EXT); // Create a new user config while (!user_config->set_config(filename.toStdString())) { ((t_gui *)ui)->cb_show_msg(this, tr("A user profile with name %1 already exists.").arg(profileName).toStdString(), MSG_WARNING); // Ask user for a profile name GetProfileNameForm getProfileNameForm(this); getProfileNameForm.setModal(true); if (!getProfileNameForm.execNewName()) return; profileName = getProfileNameForm.getProfileName(); filename = profileName; filename.append(USER_FILE_EXT); } diamondcard_set_user_config(*user_config, nameLineEdit->text().toStdString(), accountIdLineEdit->text().toStdString(), pinCodeLineEdit->text().toStdString()); string error_msg; if (!user_config->write_config(user_config->get_filename(), error_msg)) { // Failed to write config file ((t_gui *)ui)->cb_show_msg(this, error_msg, MSG_CRITICAL); return; } emit newDiamondcardProfile(user_config->get_filename().c_str()); emit success(); accept(); }
void nsDogbertProfileMigrator::GetSourceProfile(const PRUnichar* aProfile) { nsresult rv; nsCOMPtr<nsIFile> regFile; rv = NS_GetSpecialDirectory(OLDREG_DIR, getter_AddRefs(regFile)); if (NS_FAILED(rv)) return; regFile->AppendNative(NS_LITERAL_CSTRING(OLDREG_NAME)); nsCAutoString path; rv = regFile->GetNativePath(path); if (NS_FAILED(rv)) return; if (NR_StartupRegistry()) return; HREG reg = nsnull; RKEY profile = nsnull; if (NR_RegOpen(path.get(), ®)) goto cleanup; { // on macos, registry entries are UTF8 encoded NS_ConvertUTF16toUTF8 profileName(aProfile); if (NR_RegGetKey(reg, ROOTKEY_USERS, profileName.get(), &profile)) goto cleanup; } char profilePath[MAXPATHLEN]; if (NR_RegGetEntryString(reg, profile, "ProfileLocation", profilePath, MAXPATHLEN)) goto cleanup; mSourceProfile = do_CreateInstance("@mozilla.org/file/local;1"); if (!mSourceProfile) goto cleanup; { // the string is UTF8 encoded, which forces us to do some strange string-do rv = mSourceProfile->InitWithPath(NS_ConvertUTF8toUTF16(profilePath)); } if (NS_FAILED(rv)) mSourceProfile = nsnull; cleanup: if (reg) NR_RegClose(reg); NR_ShutdownRegistry(); }
void ChangeRouterPasswordOp::updateProfile() { if (!m_wifiPassword.isNull()) { QString profileName(m_infoResp.value(QLatin1String("NewSSID")).toString()); LOG_DEBUG(QString::fromUtf8("Now trying to update profile %1").arg(profileName)); m_op = m_bean->m_system->createWlanProfile(profileName, m_wifiPassword); connect(m_op, SIGNAL(finished()), SLOT(onCreateProfileFinished())); } else { notifyFinished(NoError); } }
/****************************************************************************** * AUTHOR : Saravanan R. * DATE : 09-Feb-2007 * NAME : LTKLipiEngineModule::validateProjectAndProfileNames * DESCRIPTION : * ARGUMENTS : * RETURNS : * NOTES : * CHANGE HISTROY * Author Date Description of change ******************************************************************************/ int LTKLipiEngineModule::validateProjectAndProfileNames( const string& strProjectName, const string& strProfileName, const string& projectType, string& outRecognizerString) { LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<< "Entering: LTKLipiEngineModule::validateProjectAndProfileNames()"<<endl; int errorCode; string recognizerType = ""; string profileName(strProfileName); // Validate Project errorCode = validateProject(strProjectName, projectType); if ( errorCode!= SUCCESS ) { LTKReturnError(errorCode); } if(projectType == "SHAPEREC") { recognizerType = SHAPE_RECOGNIZER_STRING; } else { recognizerType = WORD_RECOGNIZER_STRING; } // Validate Profile if(strProfileName == "") { //Assume the "default" profile profileName = DEFAULT_PROFILE; } errorCode = validateProfile(strProjectName, profileName, recognizerType, outRecognizerString); if ( errorCode!= SUCCESS) { LTKReturnError(errorCode); } LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<< "Exiting: LTKLipiEngineModule::validateProjectAndProfileNames()"<<endl; return SUCCESS; }
void RepositoryProfile::refreshStatus() { if ( lister->isRunning() ) // thread is running do nothing return; lister->setArchitectures ( PackageMetaData::archStringList ( architecures() ) ); lister->setDatabasePath ( databaseFile() ); lister->setRepoName ( profileName() ); lister->setDownloadPath ( downloadDir() ); lister->start(); }
NS_IMETHODIMP nsComm4xProfile::GetMailDir(const PRUnichar *aProfile, PRUnichar **_retval) { NS_ENSURE_ARG_POINTER(_retval); *_retval = nsnull; #if defined(XP_WIN) || defined(XP_OS2) || defined(XP_MACOSX) nsresult rv; nsCOMPtr <nsILocalFile> resolvedLocation = do_CreateInstance("@mozilla.org/file/local;1"); // on macos, registry entries are UTF8 encoded NS_ConvertUTF16toUTF8 profileName(aProfile); nsCOMPtr<nsIFile> regFile; rv = NS_GetSpecialDirectory(OLDREG_DIR, getter_AddRefs(regFile)); if (NS_FAILED(rv)) return rv; regFile->AppendNative(NS_LITERAL_CSTRING(OLDREG_NAME)); nsCAutoString path; rv = regFile->GetNativePath(path); if (NS_FAILED(rv)) return rv; if (NR_StartupRegistry()) return NS_ERROR_FAILURE; HREG reg = nsnull; RKEY profile = nsnull; if (NR_RegOpen(path.get(), ®)) goto cleanup; if (NR_RegGetKey(reg, ROOTKEY_USERS, profileName.get(), &profile)) goto cleanup; char profilePath[MAXPATHLEN]; if (NR_RegGetEntryString(reg, profile, "ProfileLocation", profilePath, MAXPATHLEN)) goto cleanup; resolvedLocation->InitWithPath(NS_ConvertUTF8toUTF16(profilePath)); if (resolvedLocation) { nsCOMPtr <nsIFile> file; rv = resolvedLocation->Clone(getter_AddRefs(file)); if (NS_FAILED(rv)) return rv; nsCOMPtr <nsILocalFile> profileLocation; profileLocation = do_QueryInterface(file); rv = profileLocation->AppendNative(NS_LITERAL_CSTRING(PREF_FILE_NAME_IN_4x)); if (NS_FAILED(rv)) return rv; bool exists = false; rv = profileLocation->Exists(&exists); if (NS_FAILED(rv)) return rv; if (exists) { nsString prefValue; rv = GetPrefValue(profileLocation, PREF_NAME, PREF_END, getter_Copies(prefValue)); if (NS_FAILED(rv)) return rv; if (!prefValue.IsEmpty()) { #ifdef XP_MACOSX rv = profileLocation->SetPersistentDescriptor(NS_ConvertUTF16toUTF8(prefValue)); if (NS_FAILED(rv)) return rv; nsAutoString path; rv = profileLocation->GetPath(path); if (NS_FAILED(rv)) return rv; *_retval = ToNewUnicode(path); #else *_retval = ToNewUnicode(prefValue); #endif } #if defined(XP_WIN) || defined(XP_OS2) || defined(XP_MACOSX) else { nsCOMPtr <nsIFile> mailLocation; rv = resolvedLocation->Clone(getter_AddRefs(mailLocation)); if (NS_FAILED(rv)) return rv; rv = mailLocation->AppendNative(NS_LITERAL_CSTRING("Mail")); if (NS_FAILED(rv)) return rv; nsAutoString path; rv = mailLocation->GetPath(path); if (NS_FAILED(rv)) return rv; *_retval = ToNewUnicode(path); } #endif } } cleanup: if (reg) NR_RegClose(reg); NR_ShutdownRegistry(); return rv; #else return NS_ERROR_FAILURE; #endif }