Exemplo n.º 1
0
void decideDestinationWithSuggestedObjectNameCallback(CFURLDownloadRef cfURLDownloadRef, CFStringRef objectName, const void* clientInfo)
{ 
    Download* download = downloadFromClientInfo(clientInfo);
    bool allowOverwrite;
    String destination = download->decideDestinationWithSuggestedFilename(objectName, allowOverwrite);
    if (destination.isNull())
        return;

    RetainPtr<CFStringRef> cfPath(AdoptCF, CFStringCreateWithCharactersNoCopy(0, reinterpret_cast<const UniChar*>(destination.characters()), destination.length(), kCFAllocatorNull));
    RetainPtr<CFURLRef> pathURL(AdoptCF, CFURLCreateWithFileSystemPath(0, cfPath.get(), kCFURLWindowsPathStyle, false));
    CFURLDownloadSetDestination(cfURLDownloadRef, pathURL.get(), allowOverwrite);
}
Exemplo n.º 2
0
static QString
applicationFileName()
{
    static QString appFileName;

    if ( appFileName.isEmpty() ) {
        NatronCFType<CFURLRef> bundleURL( CFBundleCopyExecutableURL( CFBundleGetMainBundle() ) );
        if (bundleURL) {
            NatronCFString cfPath( CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle) );
            if (cfPath) {
                appFileName = cfPath;
            }
        }
    }

    return appFileName;
}
Exemplo n.º 3
0
NATRON_NAMESPACE_ANONYMOUS_EXIT


QString
ProcInfo::applicationFilePath(const char* argv0Param)
{
#if defined(Q_OS_WIN)
    Q_UNUSED(argv0Param);
    
    //The only viable solution
    return applicationFileName();
#elif defined(Q_OS_MAC)
    //First guess this way, then use the fallback solution
    static QString appFileName;

    if ( appFileName.isEmpty() ) {
        NatronCFType<CFURLRef> bundleURL( CFBundleCopyExecutableURL( CFBundleGetMainBundle() ) );
        if (bundleURL) {
            NatronCFString cfPath( CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle) );
            if (cfPath) {
                appFileName = cfPath;
            }
        }
    }
    if ( !appFileName.isEmpty() ) {
        return appFileName;
    } else {
        return applicationFilePath_fromArgv(argv0Param);
    }
#elif defined(Q_OS_LINUX)
    // Try looking for a /proc/<pid>/exe symlink first which points to
    // the absolute path of the executable
    std::stringstream ss;
    ss << "/proc/" << getpid() << "/exe";
    std::string filename = ss.str();
    char buf[2048] = {0};
    ssize_t sizeofbuf = sizeof(char) * 2048;
    ssize_t size = readlink(filename.c_str(), buf, sizeofbuf);
    if ( (size != 0) && (size != sizeofbuf) ) {
        //detected symlink
        return QString::fromUtf8( QByteArray(buf) );
    } else {
        return applicationFilePath_fromArgv(argv0Param);
    }
#endif
}
Exemplo n.º 4
0
QT_BEGIN_NAMESPACE

/*****************************************************************************
  QCoreApplication utility functions
 *****************************************************************************/
QString qAppFileName()
{
    static QString appFileName;
    if (appFileName.isEmpty()) {
        QCFType<CFURLRef> bundleURL(CFBundleCopyExecutableURL(CFBundleGetMainBundle()));
        if(bundleURL) {
            QCFString cfPath(CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle));
            if(cfPath)
                appFileName = cfPath;
        }
    }
    return appFileName;
}
Exemplo n.º 5
0
void initAppPaths(int argc,char** argv) {
    CFURLRef bundleURL(CFBundleCopyExecutableURL(CFBundleGetMainBundle()));
    //assert(bundleURL);
    CFStringRef cfPath(CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle));
    //assert(cfPath);
    CFIndex length = CFStringGetLength(cfPath);
    const UniChar *chars = CFStringGetCharactersPtr(cfPath);
    if (chars) {
        AppDir = QString(reinterpret_cast<const QChar *>(chars), length);
    }
    else {
        QVarLengthArray<UniChar> buffer(length);
        CFStringGetCharacters(cfPath, CFRangeMake(0, length), buffer.data());
        AppDir = QString(reinterpret_cast<const QChar *>(buffer.constData()), length);
    }
    AppDir.truncate(AppDir.lastIndexOf("/"));
    HomeDir = QDir::homePath()+"/.keepassx";
    DataDir=AppDir+"/../Resources/keepassx";
}
Exemplo n.º 6
0
/**
 * @brief QgsServer::configPath
 * @param defaultConfigPath
 * @param parameters
 * @return config file path
 */
QString QgsServer::configPath( const QString& defaultConfigPath, const QMap<QString, QString>& parameters )
{
  QString cfPath( defaultConfigPath );
  QString projectFile = getenv( "QGIS_PROJECT_FILE" );
  if ( !projectFile.isEmpty() )
  {
    cfPath = projectFile;
  }
  else
  {
    QMap<QString, QString>::const_iterator paramIt = parameters.find( "MAP" );
    if ( paramIt == parameters.constEnd() )
    {
      QgsDebugMsg( QString( "Using default configuration file path: %1" ).arg( defaultConfigPath ) );
    }
    else
    {
      cfPath = paramIt.value();
    }
  }
  return cfPath;
}
Exemplo n.º 7
0
QString QgsServer::configPath( const QString &defaultConfigPath, const QString &configPath )
{
  QString cfPath( defaultConfigPath );
  QString projectFile = sSettings.projectFile();
  if ( !projectFile.isEmpty() )
  {
    cfPath = projectFile;
    QgsDebugMsg( QStringLiteral( "QGIS_PROJECT_FILE:%1" ).arg( cfPath ) );
  }
  else
  {
    if ( configPath.isEmpty() )
    {
      QgsMessageLog::logMessage( QStringLiteral( "Using default configuration file path: %1" ).arg( defaultConfigPath ), QStringLiteral( "Server" ), Qgis::Info );
    }
    else
    {
      cfPath = configPath;
      QgsDebugMsg( QStringLiteral( "MAP:%1" ).arg( cfPath ) );
    }
  }
  return cfPath;
}
Exemplo n.º 8
0
/**
 * @brief QgsServer::configPath
 * @param defaultConfigPath
 * @param parameters
 * @return config file path
 */
QString QgsServer::configPath( const QString &defaultConfigPath, const QMap<QString, QString> &parameters )
{
  QString cfPath( defaultConfigPath );
  QString projectFile = sSettings.projectFile();
  if ( !projectFile.isEmpty() )
  {
    cfPath = projectFile;
    QgsDebugMsg( QString( "QGIS_PROJECT_FILE:%1" ).arg( cfPath ) );
  }
  else
  {
    QMap<QString, QString>::const_iterator paramIt = parameters.find( QStringLiteral( "MAP" ) );
    if ( paramIt == parameters.constEnd() )
    {
      QgsMessageLog::logMessage( QStringLiteral( "Using default configuration file path: %1" ).arg( defaultConfigPath ), QStringLiteral( "Server" ), QgsMessageLog::INFO );
    }
    else
    {
      cfPath = paramIt.value();
      QgsDebugMsg( QString( "MAP:%1" ).arg( cfPath ) );
    }
  }
  return cfPath;
}