コード例 #1
0
void android_vlog(int level, const char* fmt, va_list args){
    switch(level){
    case LOG_INFO:
        level = ANDROID_LOG_INFO;
        break;
    case LOG_ERR:
        level = ANDROID_LOG_ERROR;
        break;
    case LOG_DEBUG:
        level = ANDROID_LOG_DEBUG;
        break;
    default:
        level = ANDROID_LOG_DEFAULT;

    }
    char printbuff[1024];
    vsnprintf(printbuff, sizeof(printbuff), fmt, args);
    if(level != ANDROID_LOG_DEBUG) {
        __android_log_print(level, "SproxyClient", "%s", printbuff);
    }
    std::string cachedir = getExternalCacheDir();
    std::ofstream logfile(cachedir+"/vpn.log", std::ios::app);
    auto now = time(nullptr);
    logfile<<std::put_time(std::localtime(&now), "%F %T: ")<<printbuff;
    logfile.close();
}
コード例 #2
0
QStringList QStandardPaths::standardLocations(StandardLocation type)
{
    if (type == MusicLocation) {
        return QStringList() << writableLocation(type)
               << getExternalFilesDir("DIRECTORY_MUSIC")
               << getExternalStoragePublicDirectory("DIRECTORY_PODCASTS")
               << getExternalFilesDir("DIRECTORY_PODCASTS")
               << getExternalStoragePublicDirectory("DIRECTORY_NOTIFICATIONS")
               << getExternalFilesDir("DIRECTORY_NOTIFICATIONS")
               << getExternalStoragePublicDirectory("DIRECTORY_ALARMS")
               << getExternalFilesDir("DIRECTORY_ALARMS");
    }

    if (type == MoviesLocation) {
        return QStringList() << writableLocation(type)
               << getExternalFilesDir("DIRECTORY_MOVIES");
    }

    if (type == PicturesLocation) {
        return QStringList()  << writableLocation(type)
               << getExternalFilesDir("DIRECTORY_PICTURES");
    }

    if (type == DocumentsLocation) {
        if (QtAndroidPrivate::androidSdkVersion() > 18) {
            return QStringList() << writableLocation(type)
                   << getExternalFilesDir("DIRECTORY_DOCUMENTS");
        } else {
            return QStringList() << writableLocation(type)
                   << getExternalFilesDir() + QLatin1String("/Documents");
        }
    }

    if (type == DownloadLocation) {
        return QStringList() << writableLocation(type)
               << getExternalFilesDir("DIRECTORY_DOWNLOADS");
    }

    if (type == AppDataLocation || type == AppLocalDataLocation) {
        return QStringList() << writableLocation(type)
               << getExternalFilesDir();
    }

    if (type == CacheLocation) {
        return QStringList() << writableLocation(type)
               << getExternalCacheDir();
    }

    if (type == FontsLocation) {
        QString &fontLocation = (*androidDirCache)[QStringLiteral("FONT_LOCATION")];
        if (!fontLocation.isEmpty())
            return QStringList(fontLocation);

        const QByteArray ba = qgetenv("QT_ANDROID_FONT_LOCATION");
        if (!ba.isEmpty())
            return QStringList((fontLocation = QDir::cleanPath(QString::fromLocal8Bit(ba))));

        return QStringList((fontLocation = QLatin1String("/system/fonts")));
    }

    return QStringList(writableLocation(type));
}