-rw-r--r-- | microkde/kdecore/kstandarddirs.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/microkde/kdecore/kstandarddirs.cpp b/microkde/kdecore/kstandarddirs.cpp index 4ab1a68..d5bfefd 100644 --- a/microkde/kdecore/kstandarddirs.cpp +++ b/microkde/kdecore/kstandarddirs.cpp | |||
@@ -1118,385 +1118,390 @@ bool KStandardDirs::makeDir(const QString& dir2, int mode) | |||
1118 | // Or maybe a dangling symlink ? | 1118 | // Or maybe a dangling symlink ? |
1119 | //US if (lstat(baseEncoded, &st) == 0) | 1119 | //US if (lstat(baseEncoded, &st) == 0) |
1120 | if (baseEncodedInfo.isSymLink()) { | 1120 | if (baseEncodedInfo.isSymLink()) { |
1121 | //US (void)unlink(baseEncoded); // try removing | 1121 | //US (void)unlink(baseEncoded); // try removing |
1122 | QFile(baseEncoded).remove(); | 1122 | QFile(baseEncoded).remove(); |
1123 | } | 1123 | } |
1124 | 1124 | ||
1125 | //US if ( mkdir(baseEncoded, (mode_t) mode) != 0) | 1125 | //US if ( mkdir(baseEncoded, (mode_t) mode) != 0) |
1126 | QDir dirObj; | 1126 | QDir dirObj; |
1127 | if ( dirObj.mkdir(baseEncoded) != true ) | 1127 | if ( dirObj.mkdir(baseEncoded) != true ) |
1128 | { | 1128 | { |
1129 | //US perror("trying to create local folder"); | 1129 | //US perror("trying to create local folder"); |
1130 | return false; // Couldn't create it :-( | 1130 | return false; // Couldn't create it :-( |
1131 | } | 1131 | } |
1132 | } | 1132 | } |
1133 | i = pos + 1; | 1133 | i = pos + 1; |
1134 | } | 1134 | } |
1135 | return true; | 1135 | return true; |
1136 | #endif | 1136 | #endif |
1137 | 1137 | ||
1138 | // ******************************************** | 1138 | // ******************************************** |
1139 | // new code for WIN32 | 1139 | // new code for WIN32 |
1140 | QDir dirObj; | 1140 | QDir dirObj; |
1141 | 1141 | ||
1142 | 1142 | ||
1143 | // we want an absolute path | 1143 | // we want an absolute path |
1144 | #ifndef _WIN32_ | 1144 | #ifndef _WIN32_ |
1145 | if (dir.at(0) != '/') | 1145 | if (dir.at(0) != '/') |
1146 | return false; | 1146 | return false; |
1147 | #endif | 1147 | #endif |
1148 | 1148 | ||
1149 | QString target = dir; | 1149 | QString target = dir; |
1150 | uint len = target.length(); | 1150 | uint len = target.length(); |
1151 | #ifndef _WIN32_ | 1151 | #ifndef _WIN32_ |
1152 | // append trailing slash if missing | 1152 | // append trailing slash if missing |
1153 | if (dir.at(len - 1) != '/') | 1153 | if (dir.at(len - 1) != '/') |
1154 | target += '/'; | 1154 | target += '/'; |
1155 | #endif | 1155 | #endif |
1156 | 1156 | ||
1157 | QString base(""); | 1157 | QString base(""); |
1158 | uint i = 1; | 1158 | uint i = 1; |
1159 | 1159 | ||
1160 | while( i < len ) | 1160 | while( i < len ) |
1161 | { | 1161 | { |
1162 | //US struct stat st; | 1162 | //US struct stat st; |
1163 | #ifndef _WIN32_ | 1163 | #ifndef _WIN32_ |
1164 | int pos = target.find('/', i); | 1164 | int pos = target.find('/', i); |
1165 | #else | 1165 | #else |
1166 | int pos = target.find('\\', i); | 1166 | int pos = target.find('\\', i); |
1167 | #endif | 1167 | #endif |
1168 | if ( pos < 0 ) | 1168 | if ( pos < 0 ) |
1169 | return true; | 1169 | return true; |
1170 | base += target.mid(i - 1, pos - i + 1); | 1170 | base += target.mid(i - 1, pos - i + 1); |
1171 | //QMessageBox::information( 0,"cap111", base, 1 ); | 1171 | //QMessageBox::information( 0,"cap111", base, 1 ); |
1172 | /*US | 1172 | /*US |
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 | QString readEnvPath(const char *env) | 1206 | 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 | 1301 | #ifdef DESKTOP_VERSION |
1302 | if ( localKdeDir.startsWith( "LOCAL:" ) ) { | 1302 | if ( localKdeDir.startsWith( "LOCAL:" ) ) { |
1303 | #ifdef _WIN32_ | 1303 | #ifdef _WIN32_ |
1304 | localKdeDir = qApp->applicationDirPath () + "\\"+ localKdeDir.mid( 6 ); | 1304 | localKdeDir = qApp->applicationDirPath () + "\\"+ localKdeDir.mid( 6 ); |
1305 | #else | 1305 | #else |
1306 | localKdeDir = qApp->applicationDirPath () + "/"+ localKdeDir.mid( 6 ); | 1306 | localKdeDir = qApp->applicationDirPath () + "/"+ localKdeDir.mid( 6 ); |
1307 | #endif | 1307 | #endif |
1308 | qDebug("Using local conf dir %s ",localKdeDir.latin1() ); | 1308 | qDebug("Using local conf dir %s ",localKdeDir.latin1() ); |
1309 | // <stdlib.h> | 1309 | // <stdlib.h> |
1310 | #ifdef _WIN32_ | ||
1311 | QString envSt = "LOCALMICROKDEHOME="+localKdeDir; | ||
1312 | _putenv( envSt.latin1()); | ||
1313 | #else | ||
1310 | setenv( "LOCALMICROKDEHOME", localKdeDir.latin1(), 1 ); | 1314 | setenv( "LOCALMICROKDEHOME", localKdeDir.latin1(), 1 ); |
1315 | #endif | ||
1311 | } | 1316 | } |
1312 | #endif | 1317 | #endif |
1313 | } | 1318 | } |
1314 | } | 1319 | } |
1315 | else | 1320 | else |
1316 | { | 1321 | { |
1317 | // We treat root different to prevent root messing up the | 1322 | // We treat root different to prevent root messing up the |
1318 | // file permissions in the users home directory. | 1323 | // file permissions in the users home directory. |
1319 | localKdeDir = readEnvPath("MICROKDEROOTHOME"); | 1324 | localKdeDir = readEnvPath("MICROKDEROOTHOME"); |
1320 | if (!localKdeDir.isEmpty()) | 1325 | if (!localKdeDir.isEmpty()) |
1321 | { | 1326 | { |
1322 | if (localKdeDir.at(localKdeDir.length()-1) != '/') | 1327 | if (localKdeDir.at(localKdeDir.length()-1) != '/') |
1323 | localKdeDir += '/'; | 1328 | localKdeDir += '/'; |
1324 | } | 1329 | } |
1325 | else | 1330 | else |
1326 | { | 1331 | { |
1327 | //US struct passwd *pw = getpwuid(0); | 1332 | //US struct passwd *pw = getpwuid(0); |
1328 | //US localKdeDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.microkde/"; | 1333 | //US localKdeDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.microkde/"; |
1329 | qDebug("KStandardDirs::addKDEDefaults: 1 has to be fixed"); | 1334 | qDebug("KStandardDirs::addKDEDefaults: 1 has to be fixed"); |
1330 | } | 1335 | } |
1331 | 1336 | ||
1332 | } | 1337 | } |
1333 | 1338 | ||
1334 | //US localKdeDir = appDir(); | 1339 | //US localKdeDir = appDir(); |
1335 | 1340 | ||
1336 | //US | 1341 | //US |
1337 | // qDebug("KStandardDirs::addKDEDefaults: localKdeDir=%s", localKdeDir.latin1()); | 1342 | // qDebug("KStandardDirs::addKDEDefaults: localKdeDir=%s", localKdeDir.latin1()); |
1338 | if (localKdeDir != "-/") | 1343 | if (localKdeDir != "-/") |
1339 | { | 1344 | { |
1340 | localKdeDir = KShell::tildeExpand(localKdeDir); | 1345 | localKdeDir = KShell::tildeExpand(localKdeDir); |
1341 | addPrefix(localKdeDir); | 1346 | addPrefix(localKdeDir); |
1342 | } | 1347 | } |
1343 | 1348 | ||
1344 | for (QStringList::ConstIterator it = kdedirList.begin(); | 1349 | for (QStringList::ConstIterator it = kdedirList.begin(); |
1345 | it != kdedirList.end(); it++) | 1350 | it != kdedirList.end(); it++) |
1346 | { | 1351 | { |
1347 | QString dir = KShell::tildeExpand(*it); | 1352 | QString dir = KShell::tildeExpand(*it); |
1348 | addPrefix(dir); | 1353 | addPrefix(dir); |
1349 | } | 1354 | } |
1350 | // end KDEDIRS | 1355 | // end KDEDIRS |
1351 | 1356 | ||
1352 | // begin XDG_CONFIG_XXX | 1357 | // begin XDG_CONFIG_XXX |
1353 | QStringList xdgdirList; | 1358 | QStringList xdgdirList; |
1354 | QString xdgdirs = readEnvPath("XDG_CONFIG_DIRS"); | 1359 | QString xdgdirs = readEnvPath("XDG_CONFIG_DIRS"); |
1355 | if (!xdgdirs.isEmpty()) | 1360 | if (!xdgdirs.isEmpty()) |
1356 | { | 1361 | { |
1357 | tokenize(xdgdirList, xdgdirs, ":"); | 1362 | tokenize(xdgdirList, xdgdirs, ":"); |
1358 | } | 1363 | } |
1359 | else | 1364 | else |
1360 | { | 1365 | { |
1361 | xdgdirList.clear(); | 1366 | xdgdirList.clear(); |
1362 | xdgdirList.append("/etc/xdg"); | 1367 | xdgdirList.append("/etc/xdg"); |
1363 | } | 1368 | } |
1364 | 1369 | ||
1365 | QString localXdgDir = readEnvPath("XDG_CONFIG_HOME"); | 1370 | QString localXdgDir = readEnvPath("XDG_CONFIG_HOME"); |
1366 | if (!localXdgDir.isEmpty()) | 1371 | if (!localXdgDir.isEmpty()) |
1367 | { | 1372 | { |
1368 | if (localXdgDir.at(localXdgDir.length()-1) != '/') | 1373 | if (localXdgDir.at(localXdgDir.length()-1) != '/') |
1369 | localXdgDir += '/'; | 1374 | localXdgDir += '/'; |
1370 | } | 1375 | } |
1371 | else | 1376 | else |
1372 | { | 1377 | { |
1373 | //US if (getuid()) | 1378 | //US if (getuid()) |
1374 | if (true) | 1379 | if (true) |
1375 | { | 1380 | { |
1376 | localXdgDir = QDir::homeDirPath() + "/.config/"; | 1381 | localXdgDir = QDir::homeDirPath() + "/.config/"; |
1377 | } | 1382 | } |
1378 | else | 1383 | else |
1379 | { | 1384 | { |
1380 | //US struct passwd *pw = getpwuid(0); | 1385 | //US struct passwd *pw = getpwuid(0); |
1381 | //US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.config/"; | 1386 | //US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.config/"; |
1382 | qDebug("KStandardDirs::addKDEDefaults: 2 has to be fixed"); | 1387 | qDebug("KStandardDirs::addKDEDefaults: 2 has to be fixed"); |
1383 | } | 1388 | } |
1384 | } | 1389 | } |
1385 | 1390 | ||
1386 | localXdgDir = KShell::tildeExpand(localXdgDir); | 1391 | localXdgDir = KShell::tildeExpand(localXdgDir); |
1387 | addXdgConfigPrefix(localXdgDir); | 1392 | addXdgConfigPrefix(localXdgDir); |
1388 | 1393 | ||
1389 | for (QStringList::ConstIterator it = xdgdirList.begin(); | 1394 | for (QStringList::ConstIterator it = xdgdirList.begin(); |
1390 | it != xdgdirList.end(); it++) | 1395 | it != xdgdirList.end(); it++) |
1391 | { | 1396 | { |
1392 | QString dir = KShell::tildeExpand(*it); | 1397 | QString dir = KShell::tildeExpand(*it); |
1393 | addXdgConfigPrefix(dir); | 1398 | addXdgConfigPrefix(dir); |
1394 | } | 1399 | } |
1395 | // end XDG_CONFIG_XXX | 1400 | // end XDG_CONFIG_XXX |
1396 | 1401 | ||
1397 | // begin XDG_DATA_XXX | 1402 | // begin XDG_DATA_XXX |
1398 | xdgdirs = readEnvPath("XDG_DATA_DIRS"); | 1403 | xdgdirs = readEnvPath("XDG_DATA_DIRS"); |
1399 | if (!xdgdirs.isEmpty()) | 1404 | if (!xdgdirs.isEmpty()) |
1400 | { | 1405 | { |
1401 | tokenize(xdgdirList, xdgdirs, ":"); | 1406 | tokenize(xdgdirList, xdgdirs, ":"); |
1402 | } | 1407 | } |
1403 | else | 1408 | else |
1404 | { | 1409 | { |
1405 | xdgdirList.clear(); | 1410 | xdgdirList.clear(); |
1406 | for (QStringList::ConstIterator it = kdedirList.begin(); | 1411 | for (QStringList::ConstIterator it = kdedirList.begin(); |
1407 | it != kdedirList.end(); it++) | 1412 | it != kdedirList.end(); it++) |
1408 | { | 1413 | { |
1409 | QString dir = *it; | 1414 | QString dir = *it; |
1410 | if (dir.at(dir.length()-1) != '/') | 1415 | if (dir.at(dir.length()-1) != '/') |
1411 | dir += '/'; | 1416 | dir += '/'; |
1412 | xdgdirList.append(dir+"share/"); | 1417 | xdgdirList.append(dir+"share/"); |
1413 | } | 1418 | } |
1414 | 1419 | ||
1415 | xdgdirList.append("/usr/local/share/"); | 1420 | xdgdirList.append("/usr/local/share/"); |
1416 | xdgdirList.append("/usr/share/"); | 1421 | xdgdirList.append("/usr/share/"); |
1417 | } | 1422 | } |
1418 | 1423 | ||
1419 | localXdgDir = readEnvPath("XDG_DATA_HOME"); | 1424 | localXdgDir = readEnvPath("XDG_DATA_HOME"); |
1420 | if (!localXdgDir.isEmpty()) | 1425 | if (!localXdgDir.isEmpty()) |
1421 | { | 1426 | { |
1422 | if (localXdgDir.at(localXdgDir.length()-1) != '/') | 1427 | if (localXdgDir.at(localXdgDir.length()-1) != '/') |
1423 | localXdgDir += '/'; | 1428 | localXdgDir += '/'; |
1424 | } | 1429 | } |
1425 | else | 1430 | else |
1426 | { | 1431 | { |
1427 | //US if (getuid()) | 1432 | //US if (getuid()) |
1428 | if (true) | 1433 | if (true) |
1429 | { | 1434 | { |
1430 | localXdgDir = QDir::homeDirPath() + "/.local/share/"; | 1435 | localXdgDir = QDir::homeDirPath() + "/.local/share/"; |
1431 | } | 1436 | } |
1432 | else | 1437 | else |
1433 | { | 1438 | { |
1434 | //US struct passwd *pw = getpwuid(0); | 1439 | //US struct passwd *pw = getpwuid(0); |
1435 | //US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.local/share/"; | 1440 | //US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.local/share/"; |
1436 | qDebug("KStandardDirs::addKDEDefaults: 3 has to be fixed"); | 1441 | qDebug("KStandardDirs::addKDEDefaults: 3 has to be fixed"); |
1437 | } | 1442 | } |
1438 | } | 1443 | } |
1439 | 1444 | ||
1440 | localXdgDir = KShell::tildeExpand(localXdgDir); | 1445 | localXdgDir = KShell::tildeExpand(localXdgDir); |
1441 | addXdgDataPrefix(localXdgDir); | 1446 | addXdgDataPrefix(localXdgDir); |
1442 | 1447 | ||
1443 | for (QStringList::ConstIterator it = xdgdirList.begin(); | 1448 | for (QStringList::ConstIterator it = xdgdirList.begin(); |
1444 | it != xdgdirList.end(); it++) | 1449 | it != xdgdirList.end(); it++) |
1445 | { | 1450 | { |
1446 | QString dir = KShell::tildeExpand(*it); | 1451 | QString dir = KShell::tildeExpand(*it); |
1447 | 1452 | ||
1448 | addXdgDataPrefix(dir); | 1453 | addXdgDataPrefix(dir); |
1449 | } | 1454 | } |
1450 | // end XDG_DATA_XXX | 1455 | // end XDG_DATA_XXX |
1451 | 1456 | ||
1452 | 1457 | ||
1453 | uint index = 0; | 1458 | uint index = 0; |
1454 | while (types[index] != 0) { | 1459 | while (types[index] != 0) { |
1455 | addResourceType(types[index], kde_default(types[index])); | 1460 | addResourceType(types[index], kde_default(types[index])); |
1456 | index++; | 1461 | index++; |
1457 | } | 1462 | } |
1458 | 1463 | ||
1459 | addResourceDir("home", QDir::homeDirPath()); | 1464 | addResourceDir("home", QDir::homeDirPath()); |
1460 | } | 1465 | } |
1461 | 1466 | ||
1462 | void KStandardDirs::checkConfig() const | 1467 | void KStandardDirs::checkConfig() const |
1463 | { | 1468 | { |
1464 | /*US | 1469 | /*US |
1465 | if (!addedCustoms && KGlobal::_instance && KGlobal::_instance->_config) | 1470 | if (!addedCustoms && KGlobal::_instance && KGlobal::_instance->_config) |
1466 | const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::_instance->_config); | 1471 | const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::_instance->_config); |
1467 | */ | 1472 | */ |
1468 | if (!addedCustoms && KGlobal::config()) | 1473 | if (!addedCustoms && KGlobal::config()) |
1469 | const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::config()); | 1474 | const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::config()); |
1470 | } | 1475 | } |
1471 | 1476 | ||
1472 | bool KStandardDirs::addCustomized(KConfig *config) | 1477 | bool KStandardDirs::addCustomized(KConfig *config) |
1473 | { | 1478 | { |
1474 | if (addedCustoms) // there are already customized entries | 1479 | if (addedCustoms) // there are already customized entries |
1475 | return false; // we just quite and hope they are the right ones | 1480 | return false; // we just quite and hope they are the right ones |
1476 | 1481 | ||
1477 | // save the numbers of config directories. If this changes, | 1482 | // save the numbers of config directories. If this changes, |
1478 | // we will return true to give KConfig a chance to reparse | 1483 | // we will return true to give KConfig a chance to reparse |
1479 | uint configdirs = resourceDirs("config").count(); | 1484 | uint configdirs = resourceDirs("config").count(); |
1480 | 1485 | ||
1481 | // reading the prefixes in | 1486 | // reading the prefixes in |
1482 | QString oldGroup = config->group(); | 1487 | QString oldGroup = config->group(); |
1483 | config->setGroup("Directories"); | 1488 | config->setGroup("Directories"); |
1484 | 1489 | ||
1485 | QStringList list; | 1490 | QStringList list; |
1486 | QStringList::ConstIterator it; | 1491 | QStringList::ConstIterator it; |
1487 | list = config->readListEntry("prefixes"); | 1492 | list = config->readListEntry("prefixes"); |
1488 | for (it = list.begin(); it != list.end(); it++) | 1493 | for (it = list.begin(); it != list.end(); it++) |
1489 | addPrefix(*it); | 1494 | addPrefix(*it); |
1490 | 1495 | ||
1491 | // iterating over all entries in the group Directories | 1496 | // iterating over all entries in the group Directories |
1492 | // to find entries that start with dir_$type | 1497 | // to find entries that start with dir_$type |
1493 | /*US | 1498 | /*US |
1494 | QMap<QString, QString> entries = config->entryMap("Directories"); | 1499 | QMap<QString, QString> entries = config->entryMap("Directories"); |
1495 | 1500 | ||
1496 | QMap<QString, QString>::ConstIterator it2; | 1501 | QMap<QString, QString>::ConstIterator it2; |
1497 | for (it2 = entries.begin(); it2 != entries.end(); it2++) | 1502 | for (it2 = entries.begin(); it2 != entries.end(); it2++) |
1498 | { | 1503 | { |
1499 | QString key = it2.key(); | 1504 | QString key = it2.key(); |
1500 | if (key.left(4) == "dir_") { | 1505 | if (key.left(4) == "dir_") { |
1501 | // generate directory list, there may be more than 1. | 1506 | // generate directory list, there may be more than 1. |
1502 | QStringList dirs = QStringList::split(',', *it2); | 1507 | QStringList dirs = QStringList::split(',', *it2); |