-rw-r--r-- | microkde/kdecore/kstandarddirs.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/microkde/kdecore/kstandarddirs.cpp b/microkde/kdecore/kstandarddirs.cpp index cf0d1ee..810c889 100644 --- a/microkde/kdecore/kstandarddirs.cpp +++ b/microkde/kdecore/kstandarddirs.cpp | |||
@@ -1173,256 +1173,266 @@ bool KStandardDirs::makeDir(const QString& dir2, int mode) | |||
1173 | QCString baseEncoded = QFile::encodeName(base); | 1173 | QCString baseEncoded = QFile::encodeName(base); |
1174 | // bail out if we encountered a problem | 1174 | // bail out if we encountered a problem |
1175 | if (stat(baseEncoded, &st) != 0) | 1175 | if (stat(baseEncoded, &st) != 0) |
1176 | { | 1176 | { |
1177 | // Directory does not exist.... | 1177 | // Directory does not exist.... |
1178 | // Or maybe a dangling symlink ? | 1178 | // Or maybe a dangling symlink ? |
1179 | if (lstat(baseEncoded, &st) == 0) | 1179 | if (lstat(baseEncoded, &st) == 0) |
1180 | (void)unlink(baseEncoded); // try removing | 1180 | (void)unlink(baseEncoded); // try removing |
1181 | 1181 | ||
1182 | 1182 | ||
1183 | if ( mkdir(baseEncoded, (mode_t) mode) != 0) { | 1183 | if ( mkdir(baseEncoded, (mode_t) mode) != 0) { |
1184 | perror("trying to create local folder"); | 1184 | perror("trying to create local folder"); |
1185 | return false; // Couldn't create it :-( | 1185 | return false; // Couldn't create it :-( |
1186 | } | 1186 | } |
1187 | } | 1187 | } |
1188 | */ | 1188 | */ |
1189 | 1189 | ||
1190 | if (dirObj.exists(base) == false) | 1190 | if (dirObj.exists(base) == false) |
1191 | { | 1191 | { |
1192 | //qDebug("KStandardDirs::makeDir try to create : %s" , base.latin1()); | 1192 | //qDebug("KStandardDirs::makeDir try to create : %s" , base.latin1()); |
1193 | if (dirObj.mkdir(base) != true) | 1193 | if (dirObj.mkdir(base) != true) |
1194 | { | 1194 | { |
1195 | qDebug("KStandardDirs::makeDir could not create: %s" , base.latin1()); | 1195 | qDebug("KStandardDirs::makeDir could not create: %s" , base.latin1()); |
1196 | return false; | 1196 | return false; |
1197 | } | 1197 | } |
1198 | } | 1198 | } |
1199 | 1199 | ||
1200 | i = pos + 1; | 1200 | i = pos + 1; |
1201 | } | 1201 | } |
1202 | return true; | 1202 | return true; |
1203 | 1203 | ||
1204 | } | 1204 | } |
1205 | 1205 | ||
1206 | static QString readEnvPath(const char *env) | 1206 | static QString readEnvPath(const char *env) |
1207 | { | 1207 | { |
1208 | //#ifdef _WIN32_ | 1208 | //#ifdef _WIN32_ |
1209 | // return ""; | 1209 | // return ""; |
1210 | //#else | 1210 | //#else |
1211 | QCString c_path; | 1211 | QCString c_path; |
1212 | if ( getenv(env) != NULL ) | 1212 | if ( getenv(env) != NULL ) |
1213 | c_path = QString ( getenv(env) ); | 1213 | c_path = QString ( getenv(env) ); |
1214 | if (c_path.isEmpty()) | 1214 | if (c_path.isEmpty()) |
1215 | return QString::null; | 1215 | return QString::null; |
1216 | return QFile::decodeName(c_path); | 1216 | return QFile::decodeName(c_path); |
1217 | //#endif | 1217 | //#endif |
1218 | 1218 | ||
1219 | } | 1219 | } |
1220 | 1220 | ||
1221 | void KStandardDirs::addKDEDefaults() | 1221 | void KStandardDirs::addKDEDefaults() |
1222 | { | 1222 | { |
1223 | 1223 | ||
1224 | //qDebug("ERROR: KStandardDirs::addKDEDefaults() called "); | 1224 | //qDebug("ERROR: KStandardDirs::addKDEDefaults() called "); |
1225 | //return; | 1225 | //return; |
1226 | QStringList kdedirList; | 1226 | QStringList kdedirList; |
1227 | 1227 | ||
1228 | // begin KDEDIRS | 1228 | // begin KDEDIRS |
1229 | QString kdedirs = readEnvPath("MICROKDEDIRS"); | 1229 | QString kdedirs = readEnvPath("MICROKDEDIRS"); |
1230 | if (!kdedirs.isEmpty()) | 1230 | if (!kdedirs.isEmpty()) |
1231 | { | 1231 | { |
1232 | tokenize(kdedirList, kdedirs, ":"); | 1232 | tokenize(kdedirList, kdedirs, ":"); |
1233 | } | 1233 | } |
1234 | else | 1234 | else |
1235 | { | 1235 | { |
1236 | QString kdedir = readEnvPath("MICROKDEDIR"); | 1236 | QString kdedir = readEnvPath("MICROKDEDIR"); |
1237 | if (!kdedir.isEmpty()) | 1237 | if (!kdedir.isEmpty()) |
1238 | { | 1238 | { |
1239 | kdedir = KShell::tildeExpand(kdedir); | 1239 | kdedir = KShell::tildeExpand(kdedir); |
1240 | kdedirList.append(kdedir); | 1240 | kdedirList.append(kdedir); |
1241 | } | 1241 | } |
1242 | } | 1242 | } |
1243 | //US kdedirList.append(KDEDIR); | 1243 | //US kdedirList.append(KDEDIR); |
1244 | //US for embedded, add qtopia dir as kdedir | 1244 | //US for embedded, add qtopia dir as kdedir |
1245 | 1245 | ||
1246 | #ifndef DESKTOP_VERSION | 1246 | #ifndef DESKTOP_VERSION |
1247 | QString tmp = readEnvPath("QPEDIR"); | 1247 | QString tmp = readEnvPath("QPEDIR"); |
1248 | if (!tmp.isEmpty()) | 1248 | if (!tmp.isEmpty()) |
1249 | kdedirList.append(tmp); | 1249 | kdedirList.append(tmp); |
1250 | 1250 | ||
1251 | tmp = readEnvPath("QTDIR"); | 1251 | tmp = readEnvPath("QTDIR"); |
1252 | if (!tmp.isEmpty()) | 1252 | if (!tmp.isEmpty()) |
1253 | kdedirList.append(tmp); | 1253 | kdedirList.append(tmp); |
1254 | 1254 | ||
1255 | tmp = readEnvPath("OPIEDIR"); | 1255 | tmp = readEnvPath("OPIEDIR"); |
1256 | if (!tmp.isEmpty()) | 1256 | if (!tmp.isEmpty()) |
1257 | kdedirList.append(tmp); | 1257 | kdedirList.append(tmp); |
1258 | 1258 | ||
1259 | #endif | 1259 | #endif |
1260 | 1260 | ||
1261 | #ifdef __KDE_EXECPREFIX | 1261 | #ifdef __KDE_EXECPREFIX |
1262 | QString execPrefix(__KDE_EXECPREFIX); | 1262 | QString execPrefix(__KDE_EXECPREFIX); |
1263 | if (execPrefix!="NONE") | 1263 | if (execPrefix!="NONE") |
1264 | kdedirList.append(execPrefix); | 1264 | kdedirList.append(execPrefix); |
1265 | #endif | 1265 | #endif |
1266 | 1266 | ||
1267 | QString localKdeDir; | 1267 | QString localKdeDir; |
1268 | 1268 | ||
1269 | //US if (getuid()) | 1269 | //US if (getuid()) |
1270 | if (true) | 1270 | if (true) |
1271 | { | 1271 | { |
1272 | localKdeDir = readEnvPath("MICROKDEHOME"); | 1272 | localKdeDir = readEnvPath("MICROKDEHOME"); |
1273 | if (!localKdeDir.isEmpty()) | 1273 | if (!localKdeDir.isEmpty()) |
1274 | { | 1274 | { |
1275 | #ifdef _WIN32_ | 1275 | #ifdef _WIN32_ |
1276 | if (localKdeDir.at(localKdeDir.length()-1) != '\\') | 1276 | if (localKdeDir.at(localKdeDir.length()-1) != '\\') |
1277 | localKdeDir += '\\'; | 1277 | localKdeDir += '\\'; |
1278 | #else | 1278 | #else |
1279 | if (localKdeDir.at(localKdeDir.length()-1) != '/') | 1279 | if (localKdeDir.at(localKdeDir.length()-1) != '/') |
1280 | localKdeDir += '/'; | 1280 | localKdeDir += '/'; |
1281 | #endif | 1281 | #endif |
1282 | //QMessageBox::information( 0,"localKdeDir",localKdeDir, 1 ); | 1282 | //QMessageBox::information( 0,"localKdeDir",localKdeDir, 1 ); |
1283 | } | 1283 | } |
1284 | else | 1284 | else |
1285 | { | 1285 | { |
1286 | QString confFile; | 1286 | QString confFile; |
1287 | #ifdef DESKTOP_VERSION | 1287 | #ifdef DESKTOP_VERSION |
1288 | confFile = qApp->applicationDirPath ()+ "/.microkdehome" ; | 1288 | confFile = qApp->applicationDirPath ()+ "/.microkdehome" ; |
1289 | QFileInfo fi ( confFile ); | 1289 | QFileInfo fi ( confFile ); |
1290 | if ( !fi.exists() ) | 1290 | if ( !fi.exists() ) |
1291 | confFile = QDir::homeDirPath() + "/.microkdehome"; | 1291 | confFile = QDir::homeDirPath() + "/.microkdehome"; |
1292 | else | 1292 | else |
1293 | qDebug("Loading path info from " + confFile ); | 1293 | qDebug("Loading path info from " + confFile ); |
1294 | 1294 | ||
1295 | #else | 1295 | #else |
1296 | confFile = QDir::homeDirPath() + "/.microkdehome"; | 1296 | confFile = QDir::homeDirPath() + "/.microkdehome"; |
1297 | #endif | 1297 | #endif |
1298 | KConfig cfg ( confFile ); | 1298 | KConfig cfg ( confFile ); |
1299 | cfg.setGroup("Global"); | 1299 | cfg.setGroup("Global"); |
1300 | localKdeDir = cfg.readEntry( "MICROKDEHOME", QDir::homeDirPath() + "/kdepim/" ); | 1300 | localKdeDir = cfg.readEntry( "MICROKDEHOME", QDir::homeDirPath() + "/kdepim/" ); |
1301 | #ifdef DESKTOP_VERSION | ||
1302 | if ( localKdeDir.startsWith( "LOCAL:" ) ) { | ||
1303 | #ifdef _WIN32_ | ||
1304 | localKdeDir = qApp->applicationDirPath () + "\\"+ localKdeDir.mid( 6 ); | ||
1305 | #else | ||
1306 | localKdeDir = qApp->applicationDirPath () + "/"+ localKdeDir.mid( 6 ); | ||
1307 | #endif | ||
1308 | qDebug("Using local conf dir %s ",localKdeDir.latin1() ); | ||
1309 | } | ||
1310 | #endif | ||
1301 | } | 1311 | } |
1302 | } | 1312 | } |
1303 | else | 1313 | else |
1304 | { | 1314 | { |
1305 | // We treat root different to prevent root messing up the | 1315 | // We treat root different to prevent root messing up the |
1306 | // file permissions in the users home directory. | 1316 | // file permissions in the users home directory. |
1307 | localKdeDir = readEnvPath("MICROKDEROOTHOME"); | 1317 | localKdeDir = readEnvPath("MICROKDEROOTHOME"); |
1308 | if (!localKdeDir.isEmpty()) | 1318 | if (!localKdeDir.isEmpty()) |
1309 | { | 1319 | { |
1310 | if (localKdeDir.at(localKdeDir.length()-1) != '/') | 1320 | if (localKdeDir.at(localKdeDir.length()-1) != '/') |
1311 | localKdeDir += '/'; | 1321 | localKdeDir += '/'; |
1312 | } | 1322 | } |
1313 | else | 1323 | else |
1314 | { | 1324 | { |
1315 | //US struct passwd *pw = getpwuid(0); | 1325 | //US struct passwd *pw = getpwuid(0); |
1316 | //US localKdeDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.microkde/"; | 1326 | //US localKdeDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.microkde/"; |
1317 | qDebug("KStandardDirs::addKDEDefaults: 1 has to be fixed"); | 1327 | qDebug("KStandardDirs::addKDEDefaults: 1 has to be fixed"); |
1318 | } | 1328 | } |
1319 | 1329 | ||
1320 | } | 1330 | } |
1321 | 1331 | ||
1322 | //US localKdeDir = appDir(); | 1332 | //US localKdeDir = appDir(); |
1323 | 1333 | ||
1324 | //US | 1334 | //US |
1325 | // qDebug("KStandardDirs::addKDEDefaults: localKdeDir=%s", localKdeDir.latin1()); | 1335 | // qDebug("KStandardDirs::addKDEDefaults: localKdeDir=%s", localKdeDir.latin1()); |
1326 | if (localKdeDir != "-/") | 1336 | if (localKdeDir != "-/") |
1327 | { | 1337 | { |
1328 | localKdeDir = KShell::tildeExpand(localKdeDir); | 1338 | localKdeDir = KShell::tildeExpand(localKdeDir); |
1329 | addPrefix(localKdeDir); | 1339 | addPrefix(localKdeDir); |
1330 | } | 1340 | } |
1331 | 1341 | ||
1332 | for (QStringList::ConstIterator it = kdedirList.begin(); | 1342 | for (QStringList::ConstIterator it = kdedirList.begin(); |
1333 | it != kdedirList.end(); it++) | 1343 | it != kdedirList.end(); it++) |
1334 | { | 1344 | { |
1335 | QString dir = KShell::tildeExpand(*it); | 1345 | QString dir = KShell::tildeExpand(*it); |
1336 | addPrefix(dir); | 1346 | addPrefix(dir); |
1337 | } | 1347 | } |
1338 | // end KDEDIRS | 1348 | // end KDEDIRS |
1339 | 1349 | ||
1340 | // begin XDG_CONFIG_XXX | 1350 | // begin XDG_CONFIG_XXX |
1341 | QStringList xdgdirList; | 1351 | QStringList xdgdirList; |
1342 | QString xdgdirs = readEnvPath("XDG_CONFIG_DIRS"); | 1352 | QString xdgdirs = readEnvPath("XDG_CONFIG_DIRS"); |
1343 | if (!xdgdirs.isEmpty()) | 1353 | if (!xdgdirs.isEmpty()) |
1344 | { | 1354 | { |
1345 | tokenize(xdgdirList, xdgdirs, ":"); | 1355 | tokenize(xdgdirList, xdgdirs, ":"); |
1346 | } | 1356 | } |
1347 | else | 1357 | else |
1348 | { | 1358 | { |
1349 | xdgdirList.clear(); | 1359 | xdgdirList.clear(); |
1350 | xdgdirList.append("/etc/xdg"); | 1360 | xdgdirList.append("/etc/xdg"); |
1351 | } | 1361 | } |
1352 | 1362 | ||
1353 | QString localXdgDir = readEnvPath("XDG_CONFIG_HOME"); | 1363 | QString localXdgDir = readEnvPath("XDG_CONFIG_HOME"); |
1354 | if (!localXdgDir.isEmpty()) | 1364 | if (!localXdgDir.isEmpty()) |
1355 | { | 1365 | { |
1356 | if (localXdgDir.at(localXdgDir.length()-1) != '/') | 1366 | if (localXdgDir.at(localXdgDir.length()-1) != '/') |
1357 | localXdgDir += '/'; | 1367 | localXdgDir += '/'; |
1358 | } | 1368 | } |
1359 | else | 1369 | else |
1360 | { | 1370 | { |
1361 | //US if (getuid()) | 1371 | //US if (getuid()) |
1362 | if (true) | 1372 | if (true) |
1363 | { | 1373 | { |
1364 | localXdgDir = QDir::homeDirPath() + "/.config/"; | 1374 | localXdgDir = QDir::homeDirPath() + "/.config/"; |
1365 | } | 1375 | } |
1366 | else | 1376 | else |
1367 | { | 1377 | { |
1368 | //US struct passwd *pw = getpwuid(0); | 1378 | //US struct passwd *pw = getpwuid(0); |
1369 | //US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.config/"; | 1379 | //US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.config/"; |
1370 | qDebug("KStandardDirs::addKDEDefaults: 2 has to be fixed"); | 1380 | qDebug("KStandardDirs::addKDEDefaults: 2 has to be fixed"); |
1371 | } | 1381 | } |
1372 | } | 1382 | } |
1373 | 1383 | ||
1374 | localXdgDir = KShell::tildeExpand(localXdgDir); | 1384 | localXdgDir = KShell::tildeExpand(localXdgDir); |
1375 | addXdgConfigPrefix(localXdgDir); | 1385 | addXdgConfigPrefix(localXdgDir); |
1376 | 1386 | ||
1377 | for (QStringList::ConstIterator it = xdgdirList.begin(); | 1387 | for (QStringList::ConstIterator it = xdgdirList.begin(); |
1378 | it != xdgdirList.end(); it++) | 1388 | it != xdgdirList.end(); it++) |
1379 | { | 1389 | { |
1380 | QString dir = KShell::tildeExpand(*it); | 1390 | QString dir = KShell::tildeExpand(*it); |
1381 | addXdgConfigPrefix(dir); | 1391 | addXdgConfigPrefix(dir); |
1382 | } | 1392 | } |
1383 | // end XDG_CONFIG_XXX | 1393 | // end XDG_CONFIG_XXX |
1384 | 1394 | ||
1385 | // begin XDG_DATA_XXX | 1395 | // begin XDG_DATA_XXX |
1386 | xdgdirs = readEnvPath("XDG_DATA_DIRS"); | 1396 | xdgdirs = readEnvPath("XDG_DATA_DIRS"); |
1387 | if (!xdgdirs.isEmpty()) | 1397 | if (!xdgdirs.isEmpty()) |
1388 | { | 1398 | { |
1389 | tokenize(xdgdirList, xdgdirs, ":"); | 1399 | tokenize(xdgdirList, xdgdirs, ":"); |
1390 | } | 1400 | } |
1391 | else | 1401 | else |
1392 | { | 1402 | { |
1393 | xdgdirList.clear(); | 1403 | xdgdirList.clear(); |
1394 | for (QStringList::ConstIterator it = kdedirList.begin(); | 1404 | for (QStringList::ConstIterator it = kdedirList.begin(); |
1395 | it != kdedirList.end(); it++) | 1405 | it != kdedirList.end(); it++) |
1396 | { | 1406 | { |
1397 | QString dir = *it; | 1407 | QString dir = *it; |
1398 | if (dir.at(dir.length()-1) != '/') | 1408 | if (dir.at(dir.length()-1) != '/') |
1399 | dir += '/'; | 1409 | dir += '/'; |
1400 | xdgdirList.append(dir+"share/"); | 1410 | xdgdirList.append(dir+"share/"); |
1401 | } | 1411 | } |
1402 | 1412 | ||
1403 | xdgdirList.append("/usr/local/share/"); | 1413 | xdgdirList.append("/usr/local/share/"); |
1404 | xdgdirList.append("/usr/share/"); | 1414 | xdgdirList.append("/usr/share/"); |
1405 | } | 1415 | } |
1406 | 1416 | ||
1407 | localXdgDir = readEnvPath("XDG_DATA_HOME"); | 1417 | localXdgDir = readEnvPath("XDG_DATA_HOME"); |
1408 | if (!localXdgDir.isEmpty()) | 1418 | if (!localXdgDir.isEmpty()) |
1409 | { | 1419 | { |
1410 | if (localXdgDir.at(localXdgDir.length()-1) != '/') | 1420 | if (localXdgDir.at(localXdgDir.length()-1) != '/') |
1411 | localXdgDir += '/'; | 1421 | localXdgDir += '/'; |
1412 | } | 1422 | } |
1413 | else | 1423 | else |
1414 | { | 1424 | { |
1415 | //US if (getuid()) | 1425 | //US if (getuid()) |
1416 | if (true) | 1426 | if (true) |
1417 | { | 1427 | { |
1418 | localXdgDir = QDir::homeDirPath() + "/.local/share/"; | 1428 | localXdgDir = QDir::homeDirPath() + "/.local/share/"; |
1419 | } | 1429 | } |
1420 | else | 1430 | else |
1421 | { | 1431 | { |
1422 | //US struct passwd *pw = getpwuid(0); | 1432 | //US struct passwd *pw = getpwuid(0); |
1423 | //US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.local/share/"; | 1433 | //US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.local/share/"; |
1424 | qDebug("KStandardDirs::addKDEDefaults: 3 has to be fixed"); | 1434 | qDebug("KStandardDirs::addKDEDefaults: 3 has to be fixed"); |
1425 | } | 1435 | } |
1426 | } | 1436 | } |
1427 | 1437 | ||
1428 | localXdgDir = KShell::tildeExpand(localXdgDir); | 1438 | localXdgDir = KShell::tildeExpand(localXdgDir); |