19 #include <QStringList> 
   20 #include <QApplication> 
   26 #include <ApplicationServices/ApplicationServices.h> 
   32 #define _WIN32_IE 0x0501 
   36 #include <config-marble.h> 
   38 using namespace Marble;
 
   42     QString runTimeMarbleDataPath = 
"";
 
   44     QString runTimeMarblePluginPath = 
"";
 
   55     QString  localpath = 
localPath() + 
'/' + relativePath;  
 
   56     QString  systempath  = 
systemPath() + 
'/' + relativePath;   
 
   59     QString fullpath = systempath;
 
   60     if ( QFile::exists( localpath ) ) {
 
   63     return QDir( fullpath ).canonicalPath(); 
 
   69     QString  localpath = 
pluginLocalPath() + QDir::separator() + relativePath;    
 
   73     QString fullpath = systempath;
 
   74     if ( QFile::exists( localpath ) ) {
 
   78     return QDir( fullpath ).canonicalPath(); 
 
   85     QStringList allFiles( filesLocal );
 
   86     allFiles << filesSystem;
 
   90     for ( 
int i = 1; i < allFiles.size(); ++i ) {
 
   91         if ( allFiles.at(i) == allFiles.at( i - 1 ) ) {
 
  104     QStringList allFiles( filesLocal );
 
  105     allFiles << filesSystem;
 
  109     for ( 
int i = 1; i < allFiles.size(); ++i ) {
 
  110         if ( allFiles.at(i) == allFiles.at( i - 1 ) ) {
 
  111             allFiles.removeAt(i);
 
  128     CFURLRef myBundleRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());
 
  129     CFStringRef myMacPath = CFURLCopyFileSystemPath(myBundleRef, kCFURLPOSIXPathStyle);
 
  130     const char *mypPathPtr = CFStringGetCStringPtr(myMacPath,CFStringGetSystemEncoding());
 
  131     CFRelease(myBundleRef);
 
  132     QString myPath(mypPathPtr);
 
  133     CFRelease(myMacPath);
 
  136     if (myPath.contains(
".app"))  
 
  138       systempath = myPath + 
"/Contents/Resources/data";
 
  141     if ( QFile::exists( systempath ) ){ 
 
  147 if ( !runTimeMarbleDataPath.isEmpty() )
 
  148     return runTimeMarbleDataPath;
 
  150 #ifdef MARBLE_DATA_PATH 
  152     QString compileTimeMarbleDataPath(MARBLE_DATA_PATH);
 
  154     if(QDir(compileTimeMarbleDataPath).exists())
 
  155         return compileTimeMarbleDataPath;
 
  156 #endif  // MARBLE_DATA_PATH 
  158     return QDir( QCoreApplication::applicationDirPath() 
 
  161                      + QLatin1String( 
"/data" )
 
  163                      + QLatin1String( 
"/../share/apps/marble/data" )
 
  177     CFURLRef myBundleRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());
 
  178     CFStringRef myMacPath = CFURLCopyFileSystemPath(myBundleRef, kCFURLPOSIXPathStyle);
 
  179     const char *mypPathPtr = CFStringGetCStringPtr(myMacPath,CFStringGetSystemEncoding());
 
  180     CFRelease(myBundleRef);
 
  181     CFRelease(myMacPath);
 
  182     QString myPath(mypPathPtr);
 
  185     if (myPath.contains(
".app"))  
 
  187       systempath = myPath + 
"/Contents/Resources/plugins";
 
  190     if ( QFile::exists( systempath ) ){ 
 
  196 if ( !runTimeMarblePluginPath.isEmpty() )
 
  197     return runTimeMarblePluginPath;
 
  199 #ifdef MARBLE_PLUGIN_PATH 
  201     QString compileTimeMarblePluginPath(MARBLE_PLUGIN_PATH);
 
  203     if(QDir(compileTimeMarblePluginPath).exists())
 
  204         return compileTimeMarblePluginPath;
 
  205 #endif  // MARBLE_PLUGIN_PATH 
  207     return QDir( QCoreApplication::applicationDirPath() 
 
  210                      + QLatin1String( 
"/plugins" )
 
  212                      + QLatin1String( 
"/../lib/kde4/plugins/marble" )
 
  220     QString dataHome = getenv( 
"XDG_DATA_HOME" );
 
  221     if( dataHome.isEmpty() )
 
  222         dataHome = QDir::homePath() + 
"/.local/share";
 
  224     return dataHome + 
"/marble"; 
 
  227     WCHAR *appdata_path = 
new WCHAR[MAX_PATH+1];
 
  229     SHGetSpecialFolderPathW( hwnd, appdata_path, CSIDL_APPDATA, 0 );
 
  230     QString appdata = QString::fromUtf16( reinterpret_cast<ushort*>( appdata_path ) );
 
  231     delete[] appdata_path;
 
  232     return QString( QDir::fromNativeSeparators( appdata ) + 
"/.marble/data" ); 
 
  238     QStringList possibleOldPaths;
 
  241     QString oldDefault = QDir::homePath() + 
"/.marble/data";
 
  242     possibleOldPaths.append( oldDefault );
 
  244     QString xdgDefault = QDir::homePath() + 
"/.local/share/marble";
 
  245     possibleOldPaths.append( xdgDefault );
 
  247     QString xdg = getenv( 
"XDG_DATA_HOME" );
 
  249     possibleOldPaths.append( xdg );
 
  252     QStringList oldPaths;
 
  253     foreach( 
const QString& possibleOldPath, possibleOldPaths ) {
 
  254         if( !QDir().exists( possibleOldPath ) ) {
 
  258         QString canonicalPossibleOldPath = QDir( possibleOldPath ).canonicalPath();
 
  259         if( canonicalPossibleOldPath == currentLocalPath ) {
 
  263         oldPaths.append( canonicalPossibleOldPath );
 
  272     return QString( QDir::homePath() + 
"/.marble/plugins" ); 
 
  275     WCHAR *appdata_path = 
new WCHAR[MAX_PATH+1];
 
  277     SHGetSpecialFolderPathW( hwnd, appdata_path, CSIDL_APPDATA, 0 );
 
  278     QString appdata = QString::fromUtf16( reinterpret_cast<ushort*>( appdata_path ) );
 
  279     delete[] appdata_path;
 
  280     return QString( QDir::fromNativeSeparators( appdata ) + 
"/.marble/plugins" ); 
 
  286     return runTimeMarbleDataPath;
 
  291     return runTimeMarblePluginPath;
 
  296     if ( !QDir::root().exists( adaptedPath ) )
 
  298         qWarning() << QString( 
"Invalid MarbleDataPath \"%1\". Using \"%2\" instead." ).arg( adaptedPath ).arg( 
systemPath() );
 
  302     runTimeMarbleDataPath = adaptedPath;
 
  307     if ( !QDir::root().exists( adaptedPath ) )
 
  309         qWarning() << QString( 
"Invalid MarblePluginPath \"%1\". Using \"%2\" instead." ).arg( adaptedPath ).arg( 
pluginSystemPath() );
 
  313     runTimeMarblePluginPath = adaptedPath;
 
  319     mDebug() << 
"=== MarbleDirs: ===";
 
  323     mDebug() << 
"Marble Data Path (Run Time) :" << runTimeMarbleDataPath; 
 
  324     mDebug() << 
"Marble Data Path (Compile Time):" << QString(MARBLE_DATA_PATH); 
 
  326     mDebug() << 
"Marble Plugin Path (Run Time) :" << runTimeMarblePluginPath; 
 
  327     mDebug() << 
"Marble Plugin Path (Compile Time):" << QString(MARBLE_PLUGIN_PATH); 
 
  331     mDebug() << 
"===================";
 
static QString marbleDataPath()
static QString pluginPath(const QString &relativePath)
static void setMarbleDataPath(const QString &adaptedPath)
static QString path(const QString &relativePath)
static void setMarblePluginPath(const QString &adaptedPath)
static QString pluginSystemPath()
static QString localPath()
static QString marblePluginPath()
static QStringList pluginEntryList(const QString &relativePath, QDir::Filters filters=QDir::NoFilter)
static QStringList entryList(const QString &relativePath, QDir::Filters filters=QDir::NoFilter)
static QString systemPath()
QDebug mDebug()
a function to replace qDebug() in Marble library code 
static QString pluginLocalPath()
static QStringList oldLocalPaths()