author | ulf69 <ulf69> | 2004-10-01 18:10:17 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-10-01 18:10:17 (UTC) |
commit | 7810fe355bd75c83bcdaed646cd1dde8d3c94fcb (patch) (unidiff) | |
tree | 7f425b9d7ba5109a289414c2903fff7c5182f700 | |
parent | ae6aaaf2ec81317d275ebaabba2de188279b58cd (diff) | |
download | kdepimpi-7810fe355bd75c83bcdaed646cd1dde8d3c94fcb.zip kdepimpi-7810fe355bd75c83bcdaed646cd1dde8d3c94fcb.tar.gz kdepimpi-7810fe355bd75c83bcdaed646cd1dde8d3c94fcb.tar.bz2 |
added env variables QTDIR and OPIEDIR to search for libraries.
This is a fix for pdaXROM users that have not set QPEDIR
-rw-r--r-- | microkde/kdecore/kstandarddirs.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/microkde/kdecore/kstandarddirs.cpp b/microkde/kdecore/kstandarddirs.cpp index 500426b..7f2a326 100644 --- a/microkde/kdecore/kstandarddirs.cpp +++ b/microkde/kdecore/kstandarddirs.cpp | |||
@@ -1146,193 +1146,204 @@ bool KStandardDirs::makeDir(const QString& dir2, int mode) | |||
1146 | #endif | 1146 | #endif |
1147 | 1147 | ||
1148 | QString target = dir; | 1148 | QString target = dir; |
1149 | uint len = target.length(); | 1149 | uint len = target.length(); |
1150 | #ifndef _WIN32_ | 1150 | #ifndef _WIN32_ |
1151 | // append trailing slash if missing | 1151 | // append trailing slash if missing |
1152 | if (dir.at(len - 1) != '/') | 1152 | if (dir.at(len - 1) != '/') |
1153 | target += '/'; | 1153 | target += '/'; |
1154 | #endif | 1154 | #endif |
1155 | 1155 | ||
1156 | QString base(""); | 1156 | QString base(""); |
1157 | uint i = 1; | 1157 | uint i = 1; |
1158 | 1158 | ||
1159 | while( i < len ) | 1159 | while( i < len ) |
1160 | { | 1160 | { |
1161 | //US struct stat st; | 1161 | //US struct stat st; |
1162 | #ifndef _WIN32_ | 1162 | #ifndef _WIN32_ |
1163 | int pos = target.find('/', i); | 1163 | int pos = target.find('/', i); |
1164 | #else | 1164 | #else |
1165 | int pos = target.find('\\', i); | 1165 | int pos = target.find('\\', i); |
1166 | #endif | 1166 | #endif |
1167 | if ( pos < 0 ) | 1167 | if ( pos < 0 ) |
1168 | return true; | 1168 | return true; |
1169 | base += target.mid(i - 1, pos - i + 1); | 1169 | base += target.mid(i - 1, pos - i + 1); |
1170 | //QMessageBox::information( 0,"cap111", base, 1 ); | 1170 | //QMessageBox::information( 0,"cap111", base, 1 ); |
1171 | /*US | 1171 | /*US |
1172 | QCString baseEncoded = QFile::encodeName(base); | 1172 | QCString baseEncoded = QFile::encodeName(base); |
1173 | // bail out if we encountered a problem | 1173 | // bail out if we encountered a problem |
1174 | if (stat(baseEncoded, &st) != 0) | 1174 | if (stat(baseEncoded, &st) != 0) |
1175 | { | 1175 | { |
1176 | // Directory does not exist.... | 1176 | // Directory does not exist.... |
1177 | // Or maybe a dangling symlink ? | 1177 | // Or maybe a dangling symlink ? |
1178 | if (lstat(baseEncoded, &st) == 0) | 1178 | if (lstat(baseEncoded, &st) == 0) |
1179 | (void)unlink(baseEncoded); // try removing | 1179 | (void)unlink(baseEncoded); // try removing |
1180 | 1180 | ||
1181 | 1181 | ||
1182 | if ( mkdir(baseEncoded, (mode_t) mode) != 0) { | 1182 | if ( mkdir(baseEncoded, (mode_t) mode) != 0) { |
1183 | perror("trying to create local folder"); | 1183 | perror("trying to create local folder"); |
1184 | return false; // Couldn't create it :-( | 1184 | return false; // Couldn't create it :-( |
1185 | } | 1185 | } |
1186 | } | 1186 | } |
1187 | */ | 1187 | */ |
1188 | 1188 | ||
1189 | if (dirObj.exists(base) == false) | 1189 | if (dirObj.exists(base) == false) |
1190 | { | 1190 | { |
1191 | //qDebug("KStandardDirs::makeDir try to create : %s" , base.latin1()); | 1191 | //qDebug("KStandardDirs::makeDir try to create : %s" , base.latin1()); |
1192 | if (dirObj.mkdir(base) != true) | 1192 | if (dirObj.mkdir(base) != true) |
1193 | { | 1193 | { |
1194 | qDebug("KStandardDirs::makeDir could not create: %s" , base.latin1()); | 1194 | qDebug("KStandardDirs::makeDir could not create: %s" , base.latin1()); |
1195 | return false; | 1195 | return false; |
1196 | } | 1196 | } |
1197 | } | 1197 | } |
1198 | 1198 | ||
1199 | i = pos + 1; | 1199 | i = pos + 1; |
1200 | } | 1200 | } |
1201 | return true; | 1201 | return true; |
1202 | 1202 | ||
1203 | } | 1203 | } |
1204 | 1204 | ||
1205 | static QString readEnvPath(const char *env) | 1205 | static QString readEnvPath(const char *env) |
1206 | { | 1206 | { |
1207 | #ifdef _WIN32_ | 1207 | #ifdef _WIN32_ |
1208 | return ""; | 1208 | return ""; |
1209 | #else | 1209 | #else |
1210 | QCString c_path = getenv(env); | 1210 | QCString c_path = getenv(env); |
1211 | if (c_path.isEmpty()) | 1211 | if (c_path.isEmpty()) |
1212 | return QString::null; | 1212 | return QString::null; |
1213 | return QFile::decodeName(c_path); | 1213 | return QFile::decodeName(c_path); |
1214 | #endif | 1214 | #endif |
1215 | } | 1215 | } |
1216 | 1216 | ||
1217 | void KStandardDirs::addKDEDefaults() | 1217 | void KStandardDirs::addKDEDefaults() |
1218 | { | 1218 | { |
1219 | //qDebug("ERROR: KStandardDirs::addKDEDefaults() called "); | 1219 | //qDebug("ERROR: KStandardDirs::addKDEDefaults() called "); |
1220 | //return; | 1220 | //return; |
1221 | QStringList kdedirList; | 1221 | QStringList kdedirList; |
1222 | 1222 | ||
1223 | // begin KDEDIRS | 1223 | // begin KDEDIRS |
1224 | QString kdedirs = readEnvPath("MICROKDEDIRS"); | 1224 | QString kdedirs = readEnvPath("MICROKDEDIRS"); |
1225 | if (!kdedirs.isEmpty()) | 1225 | if (!kdedirs.isEmpty()) |
1226 | { | 1226 | { |
1227 | tokenize(kdedirList, kdedirs, ":"); | 1227 | tokenize(kdedirList, kdedirs, ":"); |
1228 | } | 1228 | } |
1229 | else | 1229 | else |
1230 | { | 1230 | { |
1231 | QString kdedir = readEnvPath("MICROKDEDIR"); | 1231 | QString kdedir = readEnvPath("MICROKDEDIR"); |
1232 | if (!kdedir.isEmpty()) | 1232 | if (!kdedir.isEmpty()) |
1233 | { | 1233 | { |
1234 | kdedir = KShell::tildeExpand(kdedir); | 1234 | kdedir = KShell::tildeExpand(kdedir); |
1235 | kdedirList.append(kdedir); | 1235 | kdedirList.append(kdedir); |
1236 | } | 1236 | } |
1237 | } | 1237 | } |
1238 | //US kdedirList.append(KDEDIR); | 1238 | //US kdedirList.append(KDEDIR); |
1239 | //US for embedded, add qtopia dir as kdedir | 1239 | //US for embedded, add qtopia dir as kdedir |
1240 | 1240 | ||
1241 | #ifndef DESKTOP_VERSION | 1241 | #ifndef DESKTOP_VERSION |
1242 | kdedirList.append(readEnvPath("QPEDIR" )); | 1242 | QString tmp = readEnvPath("QPEDIR"); |
1243 | if (!tmp.isEmpty()) | ||
1244 | kdedirList.append(tmp); | ||
1245 | |||
1246 | tmp = readEnvPath("QTDIR"); | ||
1247 | if (!tmp.isEmpty()) | ||
1248 | kdedirList.append(tmp); | ||
1249 | |||
1250 | tmp = readEnvPath("OPIEDIR"); | ||
1251 | if (!tmp.isEmpty()) | ||
1252 | kdedirList.append(tmp); | ||
1253 | |||
1243 | #endif | 1254 | #endif |
1244 | 1255 | ||
1245 | #ifdef __KDE_EXECPREFIX | 1256 | #ifdef __KDE_EXECPREFIX |
1246 | QString execPrefix(__KDE_EXECPREFIX); | 1257 | QString execPrefix(__KDE_EXECPREFIX); |
1247 | if (execPrefix!="NONE") | 1258 | if (execPrefix!="NONE") |
1248 | kdedirList.append(execPrefix); | 1259 | kdedirList.append(execPrefix); |
1249 | #endif | 1260 | #endif |
1250 | 1261 | ||
1251 | QString localKdeDir; | 1262 | QString localKdeDir; |
1252 | 1263 | ||
1253 | //US if (getuid()) | 1264 | //US if (getuid()) |
1254 | if (true) | 1265 | if (true) |
1255 | { | 1266 | { |
1256 | localKdeDir = readEnvPath("MICROKDEHOME"); | 1267 | localKdeDir = readEnvPath("MICROKDEHOME"); |
1257 | if (!localKdeDir.isEmpty()) | 1268 | if (!localKdeDir.isEmpty()) |
1258 | { | 1269 | { |
1259 | if (localKdeDir.at(localKdeDir.length()-1) != '/') | 1270 | if (localKdeDir.at(localKdeDir.length()-1) != '/') |
1260 | localKdeDir += '/'; | 1271 | localKdeDir += '/'; |
1261 | } | 1272 | } |
1262 | else | 1273 | else |
1263 | { | 1274 | { |
1264 | localKdeDir = QDir::homeDirPath() + "/kdepim/"; | 1275 | localKdeDir = QDir::homeDirPath() + "/kdepim/"; |
1265 | } | 1276 | } |
1266 | } | 1277 | } |
1267 | else | 1278 | else |
1268 | { | 1279 | { |
1269 | // We treat root different to prevent root messing up the | 1280 | // We treat root different to prevent root messing up the |
1270 | // file permissions in the users home directory. | 1281 | // file permissions in the users home directory. |
1271 | localKdeDir = readEnvPath("MICROKDEROOTHOME"); | 1282 | localKdeDir = readEnvPath("MICROKDEROOTHOME"); |
1272 | if (!localKdeDir.isEmpty()) | 1283 | if (!localKdeDir.isEmpty()) |
1273 | { | 1284 | { |
1274 | if (localKdeDir.at(localKdeDir.length()-1) != '/') | 1285 | if (localKdeDir.at(localKdeDir.length()-1) != '/') |
1275 | localKdeDir += '/'; | 1286 | localKdeDir += '/'; |
1276 | } | 1287 | } |
1277 | else | 1288 | else |
1278 | { | 1289 | { |
1279 | //US struct passwd *pw = getpwuid(0); | 1290 | //US struct passwd *pw = getpwuid(0); |
1280 | //US localKdeDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.microkde/"; | 1291 | //US localKdeDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.microkde/"; |
1281 | qDebug("KStandardDirs::addKDEDefaults: 1 has to be fixed"); | 1292 | qDebug("KStandardDirs::addKDEDefaults: 1 has to be fixed"); |
1282 | } | 1293 | } |
1283 | 1294 | ||
1284 | } | 1295 | } |
1285 | 1296 | ||
1286 | //US localKdeDir = appDir(); | 1297 | //US localKdeDir = appDir(); |
1287 | 1298 | ||
1288 | //US | 1299 | //US |
1289 | // qDebug("KStandardDirs::addKDEDefaults: localKdeDir=%s", localKdeDir.latin1()); | 1300 | // qDebug("KStandardDirs::addKDEDefaults: localKdeDir=%s", localKdeDir.latin1()); |
1290 | if (localKdeDir != "-/") | 1301 | if (localKdeDir != "-/") |
1291 | { | 1302 | { |
1292 | localKdeDir = KShell::tildeExpand(localKdeDir); | 1303 | localKdeDir = KShell::tildeExpand(localKdeDir); |
1293 | addPrefix(localKdeDir); | 1304 | addPrefix(localKdeDir); |
1294 | } | 1305 | } |
1295 | 1306 | ||
1296 | for (QStringList::ConstIterator it = kdedirList.begin(); | 1307 | for (QStringList::ConstIterator it = kdedirList.begin(); |
1297 | it != kdedirList.end(); it++) | 1308 | it != kdedirList.end(); it++) |
1298 | { | 1309 | { |
1299 | QString dir = KShell::tildeExpand(*it); | 1310 | QString dir = KShell::tildeExpand(*it); |
1300 | addPrefix(dir); | 1311 | addPrefix(dir); |
1301 | } | 1312 | } |
1302 | // end KDEDIRS | 1313 | // end KDEDIRS |
1303 | 1314 | ||
1304 | // begin XDG_CONFIG_XXX | 1315 | // begin XDG_CONFIG_XXX |
1305 | QStringList xdgdirList; | 1316 | QStringList xdgdirList; |
1306 | QString xdgdirs = readEnvPath("XDG_CONFIG_DIRS"); | 1317 | QString xdgdirs = readEnvPath("XDG_CONFIG_DIRS"); |
1307 | if (!xdgdirs.isEmpty()) | 1318 | if (!xdgdirs.isEmpty()) |
1308 | { | 1319 | { |
1309 | tokenize(xdgdirList, xdgdirs, ":"); | 1320 | tokenize(xdgdirList, xdgdirs, ":"); |
1310 | } | 1321 | } |
1311 | else | 1322 | else |
1312 | { | 1323 | { |
1313 | xdgdirList.clear(); | 1324 | xdgdirList.clear(); |
1314 | xdgdirList.append("/etc/xdg"); | 1325 | xdgdirList.append("/etc/xdg"); |
1315 | } | 1326 | } |
1316 | 1327 | ||
1317 | QString localXdgDir = readEnvPath("XDG_CONFIG_HOME"); | 1328 | QString localXdgDir = readEnvPath("XDG_CONFIG_HOME"); |
1318 | if (!localXdgDir.isEmpty()) | 1329 | if (!localXdgDir.isEmpty()) |
1319 | { | 1330 | { |
1320 | if (localXdgDir.at(localXdgDir.length()-1) != '/') | 1331 | if (localXdgDir.at(localXdgDir.length()-1) != '/') |
1321 | localXdgDir += '/'; | 1332 | localXdgDir += '/'; |
1322 | } | 1333 | } |
1323 | else | 1334 | else |
1324 | { | 1335 | { |
1325 | //US if (getuid()) | 1336 | //US if (getuid()) |
1326 | if (true) | 1337 | if (true) |
1327 | { | 1338 | { |
1328 | localXdgDir = QDir::homeDirPath() + "/.config/"; | 1339 | localXdgDir = QDir::homeDirPath() + "/.config/"; |
1329 | } | 1340 | } |
1330 | else | 1341 | else |
1331 | { | 1342 | { |
1332 | //US struct passwd *pw = getpwuid(0); | 1343 | //US struct passwd *pw = getpwuid(0); |
1333 | //US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.config/"; | 1344 | //US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.config/"; |
1334 | qDebug("KStandardDirs::addKDEDefaults: 2 has to be fixed"); | 1345 | qDebug("KStandardDirs::addKDEDefaults: 2 has to be fixed"); |
1335 | } | 1346 | } |
1336 | } | 1347 | } |
1337 | 1348 | ||
1338 | localXdgDir = KShell::tildeExpand(localXdgDir); | 1349 | localXdgDir = KShell::tildeExpand(localXdgDir); |