boost::filesystem::path MacOsPath::getUserConfigPath() const { boost::filesystem::path userPath (getUserHome()); userPath /= "Library/Preferences/"; return userPath / mName; }
boost::filesystem::path MacOsPath::getUserDataPath() const { boost::filesystem::path userPath (getUserHome()); userPath /= "Library/Application Support/"; return userPath / mName; }
std::string PointsLoader::userConfigPath(const std::string& mapPointsConfigPath) const { std::string path = FileUtils::getInstance()->getWritablePath(); std::string userPath(mapPointsConfigPath.begin(), mapPointsConfigPath.end() - 5); userPath = path + userPath + "_user" + std::string(mapPointsConfigPath.end()-5, mapPointsConfigPath.end()); return userPath; }
boost::filesystem::path WindowsPath::getUserConfigPath() const { boost::filesystem::path userPath("."); WCHAR path[MAX_PATH + 1]; memset(path, 0, sizeof(path)); if(SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_PERSONAL | CSIDL_FLAG_CREATE, NULL, 0, path))) { userPath = boost::filesystem::path(bconv::utf_to_utf<char>(path)); } return userPath / "My Games" / mName; }
boost::filesystem::path WindowsPath::getUserConfigPath() const { boost::filesystem::path userPath("."); TCHAR path[MAX_PATH]; memset(path, 0, sizeof(path)); if(SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL | CSIDL_FLAG_CREATE, NULL, 0, path))) { PathAppend(path, TEXT("My Games")); userPath = boost::filesystem::path(path); } return userPath / mName; }
ProjectGenerator::ProjectGenerator() : nuiSimpleContainer(), mEventSink(this) { SetObjectName(_T("ProjectGenerator")); mpTimer = NULL; GetPreferences().GetString(PREFERENCES_PROJECTGENERATOR, _T("nuiSourcePath"), mNuiSourcePath); if (!GetPreferences().GetString(PREFERENCES_PROJECTGENERATOR, _T("nuiTargetPath"), mProjectTargetPath)) { nglPath userPath(ePathUser); mProjectTargetPath = userPath.GetPathName(); } mProjectTargetPath.Append(_T("/newNuiProject")); nuiVBox* pVBox = new nuiVBox(0); pVBox->SetExpand(nuiExpandShrinkAndGrow); AddChild(pVBox); pVBox->AddCell(BuildBlocSourceDirectory()); pVBox->AddCell(new nuiSeparator(nuiHorizontal)); pVBox->AddCell(BuildBlocProjectDirectory()); pVBox->AddCell(new nuiSeparator(nuiHorizontal)); pVBox->AddCell(BuildBlocOptions()); pVBox->AddCell(new nuiSeparator(nuiHorizontal)); pVBox->AddCell(BuildBlocButtons()); mpTimer = new nuiTimer(0.5 /*0.5s*/); mEventSink.Connect(mpTimer->Tick, &ProjectGenerator::OnTimerTick); if (mNuiSourcePath != nglString::Null) { nuiEvent event; OnTimerTick(event); } }
void TemplateChooserPage::initializePage() // ---------------------------------------------------------------------------- // Fill the template list with the templates we find on the disk // ---------------------------------------------------------------------------- { NewDocumentWizard * wiz = (NewDocumentWizard *)wizard(); QDir appPath(TaoApp->applicationDirPath() + "/templates"); QDir userPath(TaoApp->defaultTaoPreferencesFolderPath() + "/templates"); QList<QDir> dirs; dirs << appPath << userPath; wiz->templates = Templates(dirs); // Insert entries from the settings (remote menus) QSharedPointer<TextureCache> tc = TextureCache::instance(); QString docPath = TaoApp->window()->currentProjectFolderPath(); QSettings settings; int size = settings.beginReadArray("examples"); for (int i = 0; i < size; i++) { settings.setArrayIndex(i); QString caption = settings.value("caption").toString(); QString url = settings.value("url").toString(); QString tip = settings.value("description").toString(); Template tmpl(userPath); tmpl.name = caption; tmpl.description = tip; tmpl.type = "url"; tmpl.mainFile = url; QString thumbPath = exampleThumbnail(caption); CachedTexture *tex = tc->load(thumbPath, docPath); tmpl.thumbnail = QPixmap::fromImage(tex->loadedImage()); if (tmpl.thumbnail.isNull()) { connect(tex, SIGNAL(textureUpdated(CachedTexture *)), this, SLOT(thumbnailChanged(CachedTexture *))); } wiz->templates.append(tmpl); }
boost::filesystem::path MacOsPath::getCachePath() const { boost::filesystem::path userPath("."); const char* theDir = getenv("HOME"); if (theDir == NULL) { struct passwd* pwd = getpwuid(getuid()); if (pwd != NULL) { theDir = pwd->pw_dir; } } if (theDir != NULL) { userPath = boost::filesystem::path(theDir) / "Library/Caches" / mName; } return userPath; }
boost::filesystem::path LinuxPath::getUserPath() const { boost::filesystem::path userPath("."); const char* theDir = getenv("HOME"); if (theDir == NULL) { struct passwd* pwd = getpwuid(getuid()); if (pwd != NULL) { theDir = pwd->pw_dir; } } if (theDir != NULL) { userPath = boost::filesystem::path(theDir); } return userPath / ".config" / mName; }
void setExternalStorageDir(JNIEnv* lJNIEnv) { // Android: Retrieve ablsolute path to external storage device (sdcard) jclass ClassEnv = lJNIEnv->FindClass("android/os/Environment"); jmethodID MethodDir = lJNIEnv->GetStaticMethodID(ClassEnv, "getExternalStorageDirectory","()Ljava/io/File;"); jobject ObjectFile = lJNIEnv->CallStaticObjectMethod(ClassEnv, MethodDir); jclass ClassFile = lJNIEnv->FindClass("java/io/File"); jmethodID MethodPath = lJNIEnv->GetMethodID(ClassFile, "getAbsolutePath", "()Ljava/lang/String;"); jstring StringPath = (jstring) lJNIEnv->CallObjectMethod(ObjectFile, MethodPath); const char *externalPath = lJNIEnv->GetStringUTFChars(StringPath, NULL); std::string userPath(externalPath); lJNIEnv->ReleaseStringUTFChars(StringPath, externalPath); path_storage = userPath; path_user = userPath + DIR_DELIM + PROJECT_NAME; path_share = userPath + DIR_DELIM + PROJECT_NAME; }
boost::filesystem::path MacOsPath::getCachePath() const { boost::filesystem::path userPath (getUserHome()); userPath /= "Library/Caches"; return userPath / mName; }
Message::Message(int index, int size, QWidget *parent) : QDialog(parent), ui(new Ui::Message) { POP3Client POP3("*****@*****.**", "", "pop.googlemail.com", 995); ui->setupUi(this); if (POP3.init()) { if (POP3.login()) { QString stringMessage; POP3.getMessage(index, size, stringMessage); QString body; QString boundary; QStringList files; QDateTime datetime; QString messageId; QStringList lines = stringMessage.split("\r\n"); // for (auto line = ;) foreach(QString line, lines) { if (line.startsWith("From: ")) { ui->toLE->setText(line.section("From: ", 1)); } if (line.startsWith("Subject: ")) { ui->subjectLE->setText(line.section("Subject: ", 1)); } if (line.startsWith("Date: ")) { QString tmp = line.section("Date: ", 1); /// Tue, (07 Jan 2014 13:10:40) (-)(08)(00) PST /// Fri, (24 May 2013 14:48:00) (+)(04)(00) QRegExp reg("\\D*, (.*) (\\+|\\-)(\\d{2})(\\d{2}).*$"); if (reg.indexIn(tmp) > -1) { int offsetHour = reg.cap(3).toInt(); int offsetMin = reg.cap(4).toInt(); if (reg.cap(2) == "-") { offsetHour *= -1; offsetMin *= -1; } datetime = QDateTime::fromString(reg.cap(1), "d MMM yyyy hh:mm:ss"); datetime = datetime.addSecs((4 - offsetHour) * 3600); datetime = datetime.addSecs((0 - offsetMin) * 60); } ui->timeLE->setText(datetime.toString()); } if (line.startsWith("Content-Type: ")) { QRegExp b(".*; boundary=(.*)"); if (b.indexIn(line) > -1) { boundary = b.cap(1); } } if (line.startsWith("Message-ID: ")) { messageId = line.section("Message-ID: ", 1); } } // parse body QStringList bodyParts = stringMessage.split("--" + boundary); bodyParts.removeAt(0); for (auto part : bodyParts) { QString contentType, encodeType; QStringList lines = part.split("\r\n", QString::SkipEmptyParts); contentType = lines[0].section("Content-Type: ", 1); if (contentType.startsWith("text/plain")) { contentType = "text"; encodeType = lines[1].section("Content-Transfer-Encoding: ", 1); if (encodeType == "base64") { for (int i = 2; i < lines.size(); ++i) { QByteArray text(lines[i].toStdString().c_str()); body.append(QByteArray(QByteArray::fromBase64(text)).data()); } } } else if (contentType.startsWith("application/octet-stream")) { contentType = "file"; QString filename = lines[1].section("filename=", 1); filename.chop(1); files.append(filename); encodeType = lines[2].section("Content-Transfer-Encoding: ", 1); if (encodeType == "base64") { QDir filesPath("/tmp"); QDir userPath(filesPath.absolutePath() + "/pop3"); if (!userPath.exists()) { filesPath.mkdir("pop3"); } QFile saveFile(userPath.absolutePath() + "/" + messageId + "/" + filename); userPath.mkdir(messageId); saveFile.open(QIODevice::WriteOnly); for (int i = 3; i < lines.size(); ++i) { QByteArray data(lines[i].toStdString().c_str()); saveFile.write(QByteArray::fromBase64(data)); } saveFile.close(); } } else { continue; } } ui->messageTE->setText(body); QString attach = ""; for (QString str : files) { attach.append(str + "; "); } ui->attachLE->setText(attach); } }