summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-10-01 18:10:17 (UTC)
committer ulf69 <ulf69>2004-10-01 18:10:17 (UTC)
commit7810fe355bd75c83bcdaed646cd1dde8d3c94fcb (patch) (unidiff)
tree7f425b9d7ba5109a289414c2903fff7c5182f700
parentae6aaaf2ec81317d275ebaabba2de188279b58cd (diff)
downloadkdepimpi-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
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdecore/kstandarddirs.cpp13
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
@@ -730,911 +730,922 @@ void KStandardDirs::createSpecialResource(const char *type)
730QStringList KStandardDirs::resourceDirs(const char *type) const 730QStringList KStandardDirs::resourceDirs(const char *type) const
731{ 731{
732 QStringList *candidates = dircache.find(type); 732 QStringList *candidates = dircache.find(type);
733 733
734 if (!candidates) { // filling cache 734 if (!candidates) { // filling cache
735/*US 735/*US
736 if (strcmp(type, "socket") == 0) 736 if (strcmp(type, "socket") == 0)
737 const_cast<KStandardDirs *>(this)->createSpecialResource(type); 737 const_cast<KStandardDirs *>(this)->createSpecialResource(type);
738 else if (strcmp(type, "tmp") == 0) 738 else if (strcmp(type, "tmp") == 0)
739 const_cast<KStandardDirs *>(this)->createSpecialResource(type); 739 const_cast<KStandardDirs *>(this)->createSpecialResource(type);
740 else if (strcmp(type, "cache") == 0) 740 else if (strcmp(type, "cache") == 0)
741 const_cast<KStandardDirs *>(this)->createSpecialResource(type); 741 const_cast<KStandardDirs *>(this)->createSpecialResource(type);
742*/ 742*/
743 QDir testdir; 743 QDir testdir;
744 744
745 candidates = new QStringList(); 745 candidates = new QStringList();
746 QStringList *dirs; 746 QStringList *dirs;
747 747
748 bool restrictionActive = false; 748 bool restrictionActive = false;
749 if (d && d->restrictionsActive) 749 if (d && d->restrictionsActive)
750 { 750 {
751 if (d->dataRestrictionActive) 751 if (d->dataRestrictionActive)
752 restrictionActive = true; 752 restrictionActive = true;
753 else if (d->restrictions["all"]) 753 else if (d->restrictions["all"])
754 restrictionActive = true; 754 restrictionActive = true;
755 else if (d->restrictions[type]) 755 else if (d->restrictions[type])
756 restrictionActive = true; 756 restrictionActive = true;
757 d->dataRestrictionActive = false; // Reset 757 d->dataRestrictionActive = false; // Reset
758 } 758 }
759 759
760 dirs = relatives.find(type); 760 dirs = relatives.find(type);
761 if (dirs) 761 if (dirs)
762 { 762 {
763 bool local = true; 763 bool local = true;
764 const QStringList *prefixList = 0; 764 const QStringList *prefixList = 0;
765 if (strncmp(type, "xdgdata-", 8) == 0) 765 if (strncmp(type, "xdgdata-", 8) == 0)
766 prefixList = &(d->xdgdata_prefixes); 766 prefixList = &(d->xdgdata_prefixes);
767 else if (strncmp(type, "xdgconf-", 8) == 0) 767 else if (strncmp(type, "xdgconf-", 8) == 0)
768 prefixList = &(d->xdgconf_prefixes); 768 prefixList = &(d->xdgconf_prefixes);
769 else 769 else
770 prefixList = &prefixes; 770 prefixList = &prefixes;
771 771
772 for (QStringList::ConstIterator pit = prefixList->begin(); 772 for (QStringList::ConstIterator pit = prefixList->begin();
773 pit != prefixList->end(); 773 pit != prefixList->end();
774 pit++) 774 pit++)
775 { 775 {
776 for (QStringList::ConstIterator it = dirs->begin(); 776 for (QStringList::ConstIterator it = dirs->begin();
777 it != dirs->end(); ++it) { 777 it != dirs->end(); ++it) {
778 QString path = realPath(*pit + *it); 778 QString path = realPath(*pit + *it);
779 testdir.setPath(path); 779 testdir.setPath(path);
780 if (local && restrictionActive) 780 if (local && restrictionActive)
781 continue; 781 continue;
782 if ((local || testdir.exists()) && !candidates->contains(path)) 782 if ((local || testdir.exists()) && !candidates->contains(path))
783 candidates->append(path); 783 candidates->append(path);
784 } 784 }
785 local = false; 785 local = false;
786 } 786 }
787 } 787 }
788 dirs = absolutes.find(type); 788 dirs = absolutes.find(type);
789 if (dirs) 789 if (dirs)
790 for (QStringList::ConstIterator it = dirs->begin(); 790 for (QStringList::ConstIterator it = dirs->begin();
791 it != dirs->end(); ++it) 791 it != dirs->end(); ++it)
792 { 792 {
793 testdir.setPath(*it); 793 testdir.setPath(*it);
794 if (testdir.exists()) 794 if (testdir.exists())
795 { 795 {
796 QString filename = realPath(*it); 796 QString filename = realPath(*it);
797 if (!candidates->contains(filename)) 797 if (!candidates->contains(filename))
798 candidates->append(filename); 798 candidates->append(filename);
799 } 799 }
800 } 800 }
801 dircache.insert(type, candidates); 801 dircache.insert(type, candidates);
802 } 802 }
803 803
804#if 0 804#if 0
805 kdDebug() << "found dirs for resource " << type << ":" << endl; 805 kdDebug() << "found dirs for resource " << type << ":" << endl;
806 for (QStringList::ConstIterator pit = candidates->begin(); 806 for (QStringList::ConstIterator pit = candidates->begin();
807 pit != candidates->end(); 807 pit != candidates->end();
808 pit++) 808 pit++)
809 { 809 {
810 fprintf(stderr, "%s\n", (*pit).latin1()); 810 fprintf(stderr, "%s\n", (*pit).latin1());
811 } 811 }
812#endif 812#endif
813 813
814 814
815 return *candidates; 815 return *candidates;
816} 816}
817 817
818/*US 818/*US
819QString KStandardDirs::findExe( const QString& appname, 819QString KStandardDirs::findExe( const QString& appname,
820 const QString& pstr, bool ignore) 820 const QString& pstr, bool ignore)
821{ 821{
822 QFileInfo info; 822 QFileInfo info;
823 823
824 // absolute path ? 824 // absolute path ?
825 if (appname.startsWith(QString::fromLatin1("/"))) 825 if (appname.startsWith(QString::fromLatin1("/")))
826 { 826 {
827 info.setFile( appname ); 827 info.setFile( appname );
828 if( info.exists() && ( ignore || info.isExecutable() ) 828 if( info.exists() && ( ignore || info.isExecutable() )
829 && info.isFile() ) { 829 && info.isFile() ) {
830 return appname; 830 return appname;
831 } 831 }
832 return QString::null; 832 return QString::null;
833 } 833 }
834 834
835//US QString p = QString("%1/%2").arg(__KDE_BINDIR).arg(appname); 835//US QString p = QString("%1/%2").arg(__KDE_BINDIR).arg(appname);
836 QString p = QString("%1/%2").arg(appname).arg(appname); 836 QString p = QString("%1/%2").arg(appname).arg(appname);
837 qDebug("KStandardDirs::findExe this is probably wrong"); 837 qDebug("KStandardDirs::findExe this is probably wrong");
838 838
839 info.setFile( p ); 839 info.setFile( p );
840 if( info.exists() && ( ignore || info.isExecutable() ) 840 if( info.exists() && ( ignore || info.isExecutable() )
841 && ( info.isFile() || info.isSymLink() ) ) { 841 && ( info.isFile() || info.isSymLink() ) ) {
842 return p; 842 return p;
843 } 843 }
844 844
845 QStringList tokens; 845 QStringList tokens;
846 p = pstr; 846 p = pstr;
847 847
848 if( p.isNull() ) { 848 if( p.isNull() ) {
849 p = getenv( "PATH" ); 849 p = getenv( "PATH" );
850 } 850 }
851 851
852 tokenize( tokens, p, ":\b" ); 852 tokenize( tokens, p, ":\b" );
853 853
854 // split path using : or \b as delimiters 854 // split path using : or \b as delimiters
855 for( unsigned i = 0; i < tokens.count(); i++ ) { 855 for( unsigned i = 0; i < tokens.count(); i++ ) {
856 p = tokens[ i ]; 856 p = tokens[ i ];
857 857
858 if ( p[ 0 ] == '~' ) 858 if ( p[ 0 ] == '~' )
859 { 859 {
860 int len = p.find( '/' ); 860 int len = p.find( '/' );
861 if ( len == -1 ) 861 if ( len == -1 )
862 len = p.length(); 862 len = p.length();
863 if ( len == 1 ) 863 if ( len == 1 )
864 p.replace( 0, 1, QDir::homeDirPath() ); 864 p.replace( 0, 1, QDir::homeDirPath() );
865 else 865 else
866 { 866 {
867 QString user = p.mid( 1, len - 1 ); 867 QString user = p.mid( 1, len - 1 );
868 struct passwd *dir = getpwnam( user.local8Bit().data() ); 868 struct passwd *dir = getpwnam( user.local8Bit().data() );
869 if ( dir && strlen( dir->pw_dir ) ) 869 if ( dir && strlen( dir->pw_dir ) )
870 p.replace( 0, len, QString::fromLocal8Bit( dir->pw_dir ) ); 870 p.replace( 0, len, QString::fromLocal8Bit( dir->pw_dir ) );
871 } 871 }
872 } 872 }
873 873
874 p += "/"; 874 p += "/";
875 p += appname; 875 p += appname;
876 876
877 // Check for executable in this tokenized path 877 // Check for executable in this tokenized path
878 info.setFile( p ); 878 info.setFile( p );
879 879
880 if( info.exists() && ( ignore || info.isExecutable() ) 880 if( info.exists() && ( ignore || info.isExecutable() )
881 && ( info.isFile() || info.isSymLink() ) ) { 881 && ( info.isFile() || info.isSymLink() ) ) {
882 return p; 882 return p;
883 } 883 }
884 } 884 }
885 885
886 // If we reach here, the executable wasn't found. 886 // If we reach here, the executable wasn't found.
887 // So return empty string. 887 // So return empty string.
888 888
889 return QString::null; 889 return QString::null;
890} 890}
891 891
892int KStandardDirs::findAllExe( QStringList& list, const QString& appname, 892int KStandardDirs::findAllExe( QStringList& list, const QString& appname,
893 const QString& pstr, bool ignore ) 893 const QString& pstr, bool ignore )
894{ 894{
895 QString p = pstr; 895 QString p = pstr;
896 QFileInfo info; 896 QFileInfo info;
897 QStringList tokens; 897 QStringList tokens;
898 898
899 if( p.isNull() ) { 899 if( p.isNull() ) {
900 p = getenv( "PATH" ); 900 p = getenv( "PATH" );
901 } 901 }
902 902
903 list.clear(); 903 list.clear();
904 tokenize( tokens, p, ":\b" ); 904 tokenize( tokens, p, ":\b" );
905 905
906 for ( unsigned i = 0; i < tokens.count(); i++ ) { 906 for ( unsigned i = 0; i < tokens.count(); i++ ) {
907 p = tokens[ i ]; 907 p = tokens[ i ];
908 p += "/"; 908 p += "/";
909 p += appname; 909 p += appname;
910 910
911 info.setFile( p ); 911 info.setFile( p );
912 912
913 if( info.exists() && (ignore || info.isExecutable()) 913 if( info.exists() && (ignore || info.isExecutable())
914 && info.isFile() ) { 914 && info.isFile() ) {
915 list.append( p ); 915 list.append( p );
916 } 916 }
917 917
918 } 918 }
919 919
920 return list.count(); 920 return list.count();
921} 921}
922*/ 922*/
923 923
924static int tokenize( QStringList& tokens, const QString& str, 924static int tokenize( QStringList& tokens, const QString& str,
925 const QString& delim ) 925 const QString& delim )
926{ 926{
927 int len = str.length(); 927 int len = str.length();
928 QString token = ""; 928 QString token = "";
929 929
930 for( int index = 0; index < len; index++) 930 for( int index = 0; index < len; index++)
931 { 931 {
932 if ( delim.find( str[ index ] ) >= 0 ) 932 if ( delim.find( str[ index ] ) >= 0 )
933 { 933 {
934 tokens.append( token ); 934 tokens.append( token );
935 token = ""; 935 token = "";
936 } 936 }
937 else 937 else
938 { 938 {
939 token += str[ index ]; 939 token += str[ index ];
940 } 940 }
941 } 941 }
942 if ( token.length() > 0 ) 942 if ( token.length() > 0 )
943 { 943 {
944 tokens.append( token ); 944 tokens.append( token );
945 } 945 }
946 946
947 return tokens.count(); 947 return tokens.count();
948} 948}
949 949
950QString KStandardDirs::kde_default(const char *type) { 950QString KStandardDirs::kde_default(const char *type) {
951 if (!strcmp(type, "data")) 951 if (!strcmp(type, "data"))
952 return "apps/"; 952 return "apps/";
953 if (!strcmp(type, "html")) 953 if (!strcmp(type, "html"))
954 return "share/doc/HTML/"; 954 return "share/doc/HTML/";
955 if (!strcmp(type, "icon")) 955 if (!strcmp(type, "icon"))
956 return "share/icons/"; 956 return "share/icons/";
957 if (!strcmp(type, "config")) 957 if (!strcmp(type, "config"))
958 return "config/"; 958 return "config/";
959 if (!strcmp(type, "pixmap")) 959 if (!strcmp(type, "pixmap"))
960 return "share/pixmaps/"; 960 return "share/pixmaps/";
961 if (!strcmp(type, "apps")) 961 if (!strcmp(type, "apps"))
962 return "share/applnk/"; 962 return "share/applnk/";
963 if (!strcmp(type, "sound")) 963 if (!strcmp(type, "sound"))
964 return "share/sounds/"; 964 return "share/sounds/";
965 if (!strcmp(type, "locale")) 965 if (!strcmp(type, "locale"))
966 return "share/locale/"; 966 return "share/locale/";
967 if (!strcmp(type, "services")) 967 if (!strcmp(type, "services"))
968 return "share/services/"; 968 return "share/services/";
969 if (!strcmp(type, "servicetypes")) 969 if (!strcmp(type, "servicetypes"))
970 return "share/servicetypes/"; 970 return "share/servicetypes/";
971 if (!strcmp(type, "mime")) 971 if (!strcmp(type, "mime"))
972 return "share/mimelnk/"; 972 return "share/mimelnk/";
973 if (!strcmp(type, "cgi")) 973 if (!strcmp(type, "cgi"))
974 return "cgi-bin/"; 974 return "cgi-bin/";
975 if (!strcmp(type, "wallpaper")) 975 if (!strcmp(type, "wallpaper"))
976 return "share/wallpapers/"; 976 return "share/wallpapers/";
977 if (!strcmp(type, "templates")) 977 if (!strcmp(type, "templates"))
978 return "share/templates/"; 978 return "share/templates/";
979 if (!strcmp(type, "exe")) 979 if (!strcmp(type, "exe"))
980 return "bin/"; 980 return "bin/";
981 if (!strcmp(type, "lib")) 981 if (!strcmp(type, "lib"))
982 return "lib/"; 982 return "lib/";
983 if (!strcmp(type, "module")) 983 if (!strcmp(type, "module"))
984 return "lib/kde3/"; 984 return "lib/kde3/";
985 if (!strcmp(type, "qtplugins")) 985 if (!strcmp(type, "qtplugins"))
986 return "lib/kde3/plugins"; 986 return "lib/kde3/plugins";
987 if (!strcmp(type, "xdgdata-apps")) 987 if (!strcmp(type, "xdgdata-apps"))
988 return "applications/"; 988 return "applications/";
989 if (!strcmp(type, "xdgdata-dirs")) 989 if (!strcmp(type, "xdgdata-dirs"))
990 return "desktop-directories/"; 990 return "desktop-directories/";
991 if (!strcmp(type, "xdgconf-menu")) 991 if (!strcmp(type, "xdgconf-menu"))
992 return "menus/"; 992 return "menus/";
993 if (!strcmp(type, "tmp")) 993 if (!strcmp(type, "tmp"))
994 return "tmp/"; 994 return "tmp/";
995 995
996 qFatal("unknown resource type %s", type); 996 qFatal("unknown resource type %s", type);
997 return QString::null; 997 return QString::null;
998} 998}
999 999
1000QString KStandardDirs::saveLocation(const char *type, 1000QString KStandardDirs::saveLocation(const char *type,
1001 const QString& suffix, 1001 const QString& suffix,
1002 bool create) const 1002 bool create) const
1003{ 1003{
1004 //qDebug("KStandardDirs::saveLocation called %s %s", type,suffix.latin1() ); 1004 //qDebug("KStandardDirs::saveLocation called %s %s", type,suffix.latin1() );
1005 //return ""; 1005 //return "";
1006 checkConfig(); 1006 checkConfig();
1007 1007
1008 QString *pPath = savelocations.find(type); 1008 QString *pPath = savelocations.find(type);
1009 if (!pPath) 1009 if (!pPath)
1010 { 1010 {
1011 QStringList *dirs = relatives.find(type); 1011 QStringList *dirs = relatives.find(type);
1012 if (!dirs && ( 1012 if (!dirs && (
1013 (strcmp(type, "socket") == 0) || 1013 (strcmp(type, "socket") == 0) ||
1014 (strcmp(type, "tmp") == 0) || 1014 (strcmp(type, "tmp") == 0) ||
1015 (strcmp(type, "cache") == 0) )) 1015 (strcmp(type, "cache") == 0) ))
1016 { 1016 {
1017 (void) resourceDirs(type); // Generate socket|tmp|cache resource. 1017 (void) resourceDirs(type); // Generate socket|tmp|cache resource.
1018 dirs = relatives.find(type); // Search again. 1018 dirs = relatives.find(type); // Search again.
1019 } 1019 }
1020 if (dirs) 1020 if (dirs)
1021 { 1021 {
1022 // Check for existance of typed directory + suffix 1022 // Check for existance of typed directory + suffix
1023 if (strncmp(type, "xdgdata-", 8) == 0) 1023 if (strncmp(type, "xdgdata-", 8) == 0)
1024 pPath = new QString(realPath(localxdgdatadir() + dirs->last())); 1024 pPath = new QString(realPath(localxdgdatadir() + dirs->last()));
1025 else if (strncmp(type, "xdgconf-", 8) == 0) 1025 else if (strncmp(type, "xdgconf-", 8) == 0)
1026 pPath = new QString(realPath(localxdgconfdir() + dirs->last())); 1026 pPath = new QString(realPath(localxdgconfdir() + dirs->last()));
1027 else 1027 else
1028 pPath = new QString(realPath(localkdedir() + dirs->last())); 1028 pPath = new QString(realPath(localkdedir() + dirs->last()));
1029 } 1029 }
1030 else { 1030 else {
1031 dirs = absolutes.find(type); 1031 dirs = absolutes.find(type);
1032 if (!dirs) 1032 if (!dirs)
1033 qFatal("KStandardDirs: The resource type %s is not registered", type); 1033 qFatal("KStandardDirs: The resource type %s is not registered", type);
1034 pPath = new QString(realPath(dirs->last())); 1034 pPath = new QString(realPath(dirs->last()));
1035 } 1035 }
1036 1036
1037 savelocations.insert(type, pPath); 1037 savelocations.insert(type, pPath);
1038 } 1038 }
1039 1039
1040 QString fullPath = *pPath + suffix; 1040 QString fullPath = *pPath + suffix;
1041//US struct stat st; 1041//US struct stat st;
1042//US if (stat(QFile::encodeName(fullPath), &st) != 0 || !(S_ISDIR(st.st_mode))) 1042//US if (stat(QFile::encodeName(fullPath), &st) != 0 || !(S_ISDIR(st.st_mode)))
1043 QFileInfo fullPathInfo(QFile::encodeName(fullPath)); 1043 QFileInfo fullPathInfo(QFile::encodeName(fullPath));
1044 if (fullPathInfo.isReadable() || !fullPathInfo.isDir()) 1044 if (fullPathInfo.isReadable() || !fullPathInfo.isDir())
1045 1045
1046 1046
1047 { 1047 {
1048 if(!create) { 1048 if(!create) {
1049#ifndef NDEBUG 1049#ifndef NDEBUG
1050 qDebug("save location %s doesn't exist", fullPath.latin1()); 1050 qDebug("save location %s doesn't exist", fullPath.latin1());
1051#endif 1051#endif
1052 return fullPath; 1052 return fullPath;
1053 } 1053 }
1054 if(!makeDir(fullPath, 0700)) { 1054 if(!makeDir(fullPath, 0700)) {
1055 qWarning("failed to create %s", fullPath.latin1()); 1055 qWarning("failed to create %s", fullPath.latin1());
1056 return fullPath; 1056 return fullPath;
1057 } 1057 }
1058 dircache.remove(type); 1058 dircache.remove(type);
1059 } 1059 }
1060 return fullPath; 1060 return fullPath;
1061} 1061}
1062 1062
1063QString KStandardDirs::relativeLocation(const char *type, const QString &absPath) 1063QString KStandardDirs::relativeLocation(const char *type, const QString &absPath)
1064{ 1064{
1065 QString fullPath = absPath; 1065 QString fullPath = absPath;
1066 int i = absPath.findRev('/'); 1066 int i = absPath.findRev('/');
1067 if (i != -1) 1067 if (i != -1)
1068 { 1068 {
1069 fullPath = realPath(absPath.left(i+1))+absPath.mid(i+1); // Normalize 1069 fullPath = realPath(absPath.left(i+1))+absPath.mid(i+1); // Normalize
1070 } 1070 }
1071 1071
1072 QStringList candidates = resourceDirs(type); 1072 QStringList candidates = resourceDirs(type);
1073 1073
1074 for (QStringList::ConstIterator it = candidates.begin(); 1074 for (QStringList::ConstIterator it = candidates.begin();
1075 it != candidates.end(); it++) 1075 it != candidates.end(); it++)
1076 if (fullPath.startsWith(*it)) 1076 if (fullPath.startsWith(*it))
1077 { 1077 {
1078 return fullPath.mid((*it).length()); 1078 return fullPath.mid((*it).length());
1079 } 1079 }
1080 1080
1081 return absPath; 1081 return absPath;
1082} 1082}
1083 1083
1084 1084
1085bool KStandardDirs::makeDir(const QString& dir2, int mode) 1085bool KStandardDirs::makeDir(const QString& dir2, int mode)
1086{ 1086{
1087 QString dir = QDir::convertSeparators( dir2 ); 1087 QString dir = QDir::convertSeparators( dir2 );
1088#if 0 1088#if 0
1089 //LR 1089 //LR
1090 1090
1091 // we want an absolute path 1091 // we want an absolute path
1092 if (dir.at(0) != '/') 1092 if (dir.at(0) != '/')
1093 return false; 1093 return false;
1094 1094
1095 QString target = dir; 1095 QString target = dir;
1096 uint len = target.length(); 1096 uint len = target.length();
1097 1097
1098 // append trailing slash if missing 1098 // append trailing slash if missing
1099 if (dir.at(len - 1) != '/') 1099 if (dir.at(len - 1) != '/')
1100 target += '/'; 1100 target += '/';
1101 1101
1102 QString base(""); 1102 QString base("");
1103 uint i = 1; 1103 uint i = 1;
1104 1104
1105 while( i < len ) 1105 while( i < len )
1106 { 1106 {
1107//US struct stat st; 1107//US struct stat st;
1108 int pos = target.find('/', i); 1108 int pos = target.find('/', i);
1109 base += target.mid(i - 1, pos - i + 1); 1109 base += target.mid(i - 1, pos - i + 1);
1110 QCString baseEncoded = QFile::encodeName(base); 1110 QCString baseEncoded = QFile::encodeName(base);
1111 // bail out if we encountered a problem 1111 // bail out if we encountered a problem
1112//US if (stat(baseEncoded, &st) != 0) 1112//US if (stat(baseEncoded, &st) != 0)
1113 QFileInfo baseEncodedInfo(baseEncoded); 1113 QFileInfo baseEncodedInfo(baseEncoded);
1114 if (!baseEncodedInfo.exists()) 1114 if (!baseEncodedInfo.exists())
1115 { 1115 {
1116 // Directory does not exist.... 1116 // Directory does not exist....
1117 // Or maybe a dangling symlink ? 1117 // Or maybe a dangling symlink ?
1118//US if (lstat(baseEncoded, &st) == 0) 1118//US if (lstat(baseEncoded, &st) == 0)
1119 if (baseEncodedInfo.isSymLink()) { 1119 if (baseEncodedInfo.isSymLink()) {
1120//US (void)unlink(baseEncoded); // try removing 1120//US (void)unlink(baseEncoded); // try removing
1121 QFile(baseEncoded).remove(); 1121 QFile(baseEncoded).remove();
1122 } 1122 }
1123 1123
1124 //US if ( mkdir(baseEncoded, (mode_t) mode) != 0) 1124 //US if ( mkdir(baseEncoded, (mode_t) mode) != 0)
1125 QDir dirObj; 1125 QDir dirObj;
1126 if ( dirObj.mkdir(baseEncoded) != true ) 1126 if ( dirObj.mkdir(baseEncoded) != true )
1127 { 1127 {
1128 //US perror("trying to create local folder"); 1128 //US perror("trying to create local folder");
1129 return false; // Couldn't create it :-( 1129 return false; // Couldn't create it :-(
1130 } 1130 }
1131 } 1131 }
1132 i = pos + 1; 1132 i = pos + 1;
1133 } 1133 }
1134 return true; 1134 return true;
1135#endif 1135#endif
1136 1136
1137 // ******************************************** 1137 // ********************************************
1138 // new code for WIN32 1138 // new code for WIN32
1139 QDir dirObj; 1139 QDir dirObj;
1140 1140
1141 1141
1142 // we want an absolute path 1142 // we want an absolute path
1143#ifndef _WIN32_ 1143#ifndef _WIN32_
1144 if (dir.at(0) != '/') 1144 if (dir.at(0) != '/')
1145 return false; 1145 return false;
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
1205static QString readEnvPath(const char *env) 1205static 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
1217void KStandardDirs::addKDEDefaults() 1217void 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);
1339 addXdgConfigPrefix(localXdgDir); 1350 addXdgConfigPrefix(localXdgDir);
1340 1351
1341 for (QStringList::ConstIterator it = xdgdirList.begin(); 1352 for (QStringList::ConstIterator it = xdgdirList.begin();
1342 it != xdgdirList.end(); it++) 1353 it != xdgdirList.end(); it++)
1343 { 1354 {
1344 QString dir = KShell::tildeExpand(*it); 1355 QString dir = KShell::tildeExpand(*it);
1345 addXdgConfigPrefix(dir); 1356 addXdgConfigPrefix(dir);
1346 } 1357 }
1347 // end XDG_CONFIG_XXX 1358 // end XDG_CONFIG_XXX
1348 1359
1349 // begin XDG_DATA_XXX 1360 // begin XDG_DATA_XXX
1350 xdgdirs = readEnvPath("XDG_DATA_DIRS"); 1361 xdgdirs = readEnvPath("XDG_DATA_DIRS");
1351 if (!xdgdirs.isEmpty()) 1362 if (!xdgdirs.isEmpty())
1352 { 1363 {
1353 tokenize(xdgdirList, xdgdirs, ":"); 1364 tokenize(xdgdirList, xdgdirs, ":");
1354 } 1365 }
1355 else 1366 else
1356 { 1367 {
1357 xdgdirList.clear(); 1368 xdgdirList.clear();
1358 for (QStringList::ConstIterator it = kdedirList.begin(); 1369 for (QStringList::ConstIterator it = kdedirList.begin();
1359 it != kdedirList.end(); it++) 1370 it != kdedirList.end(); it++)
1360 { 1371 {
1361 QString dir = *it; 1372 QString dir = *it;
1362 if (dir.at(dir.length()-1) != '/') 1373 if (dir.at(dir.length()-1) != '/')
1363 dir += '/'; 1374 dir += '/';
1364 xdgdirList.append(dir+"share/"); 1375 xdgdirList.append(dir+"share/");
1365 } 1376 }
1366 1377
1367 xdgdirList.append("/usr/local/share/"); 1378 xdgdirList.append("/usr/local/share/");
1368 xdgdirList.append("/usr/share/"); 1379 xdgdirList.append("/usr/share/");
1369 } 1380 }
1370 1381
1371 localXdgDir = readEnvPath("XDG_DATA_HOME"); 1382 localXdgDir = readEnvPath("XDG_DATA_HOME");
1372 if (!localXdgDir.isEmpty()) 1383 if (!localXdgDir.isEmpty())
1373 { 1384 {
1374 if (localXdgDir.at(localXdgDir.length()-1) != '/') 1385 if (localXdgDir.at(localXdgDir.length()-1) != '/')
1375 localXdgDir += '/'; 1386 localXdgDir += '/';
1376 } 1387 }
1377 else 1388 else
1378 { 1389 {
1379//US if (getuid()) 1390//US if (getuid())
1380 if (true) 1391 if (true)
1381 { 1392 {
1382 localXdgDir = QDir::homeDirPath() + "/.local/share/"; 1393 localXdgDir = QDir::homeDirPath() + "/.local/share/";
1383 } 1394 }
1384 else 1395 else
1385 { 1396 {
1386//US struct passwd *pw = getpwuid(0); 1397//US struct passwd *pw = getpwuid(0);
1387//US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.local/share/"; 1398//US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.local/share/";
1388 qDebug("KStandardDirs::addKDEDefaults: 3 has to be fixed"); 1399 qDebug("KStandardDirs::addKDEDefaults: 3 has to be fixed");
1389 } 1400 }
1390 } 1401 }
1391 1402
1392 localXdgDir = KShell::tildeExpand(localXdgDir); 1403 localXdgDir = KShell::tildeExpand(localXdgDir);
1393 addXdgDataPrefix(localXdgDir); 1404 addXdgDataPrefix(localXdgDir);
1394 1405
1395 for (QStringList::ConstIterator it = xdgdirList.begin(); 1406 for (QStringList::ConstIterator it = xdgdirList.begin();
1396 it != xdgdirList.end(); it++) 1407 it != xdgdirList.end(); it++)
1397 { 1408 {
1398 QString dir = KShell::tildeExpand(*it); 1409 QString dir = KShell::tildeExpand(*it);
1399 1410
1400 addXdgDataPrefix(dir); 1411 addXdgDataPrefix(dir);
1401 } 1412 }
1402 // end XDG_DATA_XXX 1413 // end XDG_DATA_XXX
1403 1414
1404 1415
1405 uint index = 0; 1416 uint index = 0;
1406 while (types[index] != 0) { 1417 while (types[index] != 0) {
1407 addResourceType(types[index], kde_default(types[index])); 1418 addResourceType(types[index], kde_default(types[index]));
1408 index++; 1419 index++;
1409 } 1420 }
1410 1421
1411 addResourceDir("home", QDir::homeDirPath()); 1422 addResourceDir("home", QDir::homeDirPath());
1412} 1423}
1413 1424
1414void KStandardDirs::checkConfig() const 1425void KStandardDirs::checkConfig() const
1415{ 1426{
1416/*US 1427/*US
1417 if (!addedCustoms && KGlobal::_instance && KGlobal::_instance->_config) 1428 if (!addedCustoms && KGlobal::_instance && KGlobal::_instance->_config)
1418 const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::_instance->_config); 1429 const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::_instance->_config);
1419*/ 1430*/
1420 if (!addedCustoms && KGlobal::config()) 1431 if (!addedCustoms && KGlobal::config())
1421 const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::config()); 1432 const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::config());
1422} 1433}
1423 1434
1424bool KStandardDirs::addCustomized(KConfig *config) 1435bool KStandardDirs::addCustomized(KConfig *config)
1425{ 1436{
1426 if (addedCustoms) // there are already customized entries 1437 if (addedCustoms) // there are already customized entries
1427 return false; // we just quite and hope they are the right ones 1438 return false; // we just quite and hope they are the right ones
1428 1439
1429 // save the numbers of config directories. If this changes, 1440 // save the numbers of config directories. If this changes,
1430 // we will return true to give KConfig a chance to reparse 1441 // we will return true to give KConfig a chance to reparse
1431 uint configdirs = resourceDirs("config").count(); 1442 uint configdirs = resourceDirs("config").count();
1432 1443
1433 // reading the prefixes in 1444 // reading the prefixes in
1434 QString oldGroup = config->group(); 1445 QString oldGroup = config->group();
1435 config->setGroup("Directories"); 1446 config->setGroup("Directories");
1436 1447
1437 QStringList list; 1448 QStringList list;
1438 QStringList::ConstIterator it; 1449 QStringList::ConstIterator it;
1439 list = config->readListEntry("prefixes"); 1450 list = config->readListEntry("prefixes");
1440 for (it = list.begin(); it != list.end(); it++) 1451 for (it = list.begin(); it != list.end(); it++)
1441 addPrefix(*it); 1452 addPrefix(*it);
1442 1453
1443 // iterating over all entries in the group Directories 1454 // iterating over all entries in the group Directories
1444 // to find entries that start with dir_$type 1455 // to find entries that start with dir_$type
1445/*US 1456/*US
1446 QMap<QString, QString> entries = config->entryMap("Directories"); 1457 QMap<QString, QString> entries = config->entryMap("Directories");
1447 1458
1448 QMap<QString, QString>::ConstIterator it2; 1459 QMap<QString, QString>::ConstIterator it2;
1449 for (it2 = entries.begin(); it2 != entries.end(); it2++) 1460 for (it2 = entries.begin(); it2 != entries.end(); it2++)
1450 { 1461 {
1451 QString key = it2.key(); 1462 QString key = it2.key();
1452 if (key.left(4) == "dir_") { 1463 if (key.left(4) == "dir_") {
1453 // generate directory list, there may be more than 1. 1464 // generate directory list, there may be more than 1.
1454 QStringList dirs = QStringList::split(',', *it2); 1465 QStringList dirs = QStringList::split(',', *it2);
1455 QStringList::Iterator sIt(dirs.begin()); 1466 QStringList::Iterator sIt(dirs.begin());
1456 QString resType = key.mid(4, key.length()); 1467 QString resType = key.mid(4, key.length());
1457 for (; sIt != dirs.end(); ++sIt) { 1468 for (; sIt != dirs.end(); ++sIt) {
1458 addResourceDir(resType.latin1(), *sIt); 1469 addResourceDir(resType.latin1(), *sIt);
1459 } 1470 }
1460 } 1471 }
1461 } 1472 }
1462 1473
1463 // Process KIOSK restrictions. 1474 // Process KIOSK restrictions.
1464 config->setGroup("KDE Resource Restrictions"); 1475 config->setGroup("KDE Resource Restrictions");
1465 entries = config->entryMap("KDE Resource Restrictions"); 1476 entries = config->entryMap("KDE Resource Restrictions");
1466 for (it2 = entries.begin(); it2 != entries.end(); it2++) 1477 for (it2 = entries.begin(); it2 != entries.end(); it2++)
1467 { 1478 {
1468 QString key = it2.key(); 1479 QString key = it2.key();
1469 if (!config->readBoolEntry(key, true)) 1480 if (!config->readBoolEntry(key, true))
1470 { 1481 {
1471 d->restrictionsActive = true; 1482 d->restrictionsActive = true;
1472 d->restrictions.insert(key.latin1(), &d->restrictionsActive); // Anything will do 1483 d->restrictions.insert(key.latin1(), &d->restrictionsActive); // Anything will do
1473 dircache.remove(key.latin1()); 1484 dircache.remove(key.latin1());
1474 } 1485 }
1475 } 1486 }
1476*/ 1487*/
1477 // save it for future calls - that will return 1488 // save it for future calls - that will return
1478 addedCustoms = true; 1489 addedCustoms = true;
1479 config->setGroup(oldGroup); 1490 config->setGroup(oldGroup);
1480 1491
1481 // return true if the number of config dirs changed 1492 // return true if the number of config dirs changed
1482 return (resourceDirs("config").count() != configdirs); 1493 return (resourceDirs("config").count() != configdirs);
1483} 1494}
1484 1495
1485QString KStandardDirs::localkdedir() const 1496QString KStandardDirs::localkdedir() const
1486{ 1497{
1487 // Return the prefix to use for saving 1498 // Return the prefix to use for saving
1488 return prefixes.first(); 1499 return prefixes.first();
1489} 1500}
1490 1501
1491QString KStandardDirs::localxdgdatadir() const 1502QString KStandardDirs::localxdgdatadir() const
1492{ 1503{
1493 // Return the prefix to use for saving 1504 // Return the prefix to use for saving
1494 return d->xdgdata_prefixes.first(); 1505 return d->xdgdata_prefixes.first();
1495} 1506}
1496 1507
1497QString KStandardDirs::localxdgconfdir() const 1508QString KStandardDirs::localxdgconfdir() const
1498{ 1509{
1499 // Return the prefix to use for saving 1510 // Return the prefix to use for saving
1500 return d->xdgconf_prefixes.first(); 1511 return d->xdgconf_prefixes.first();
1501} 1512}
1502 1513
1503void KStandardDirs::setAppDir( const QString &appDir ) 1514void KStandardDirs::setAppDir( const QString &appDir )
1504{ 1515{
1505 mAppDir = appDir; 1516 mAppDir = appDir;
1506 1517
1507 if ( mAppDir.right( 1 ) != "/" ) 1518 if ( mAppDir.right( 1 ) != "/" )
1508 mAppDir += "/"; 1519 mAppDir += "/";
1509} 1520}
1510 1521
1511QString KStandardDirs::appDir() 1522QString KStandardDirs::appDir()
1512{ 1523{
1513 return mAppDir; 1524 return mAppDir;
1514} 1525}
1515 1526
1516// just to make code more readable without macros 1527// just to make code more readable without macros
1517QString locate( const char *type, 1528QString locate( const char *type,
1518 const QString& filename/*US , const KInstance* inst*/ ) 1529 const QString& filename/*US , const KInstance* inst*/ )
1519{ 1530{
1520//US return inst->dirs()->findResource(type, filename); 1531//US return inst->dirs()->findResource(type, filename);
1521 return KGlobal::dirs()->findResource(type, filename); 1532 return KGlobal::dirs()->findResource(type, filename);
1522} 1533}
1523 1534
1524QString locateLocal( const char *type, 1535QString locateLocal( const char *type,
1525 const QString& filename/*US , const KInstance* inst*/ ) 1536 const QString& filename/*US , const KInstance* inst*/ )
1526{ 1537{
1527 1538
1528 QString path = locateLocal(type, filename, true /*US, inst*/); 1539 QString path = locateLocal(type, filename, true /*US, inst*/);
1529 1540
1530 1541
1531/* 1542/*
1532 static int ccc = 0; 1543 static int ccc = 0;
1533 ++ccc; 1544 ++ccc;
1534 if ( ccc > 13 ) 1545 if ( ccc > 13 )
1535 abort(); 1546 abort();
1536*/ 1547*/
1537 qDebug("locatelocal: %s" , path.latin1()); 1548 qDebug("locatelocal: %s" , path.latin1());
1538 return path; 1549 return path;
1539 1550
1540/*US why do we put all files into one directory. It is quit complicated. 1551/*US why do we put all files into one directory. It is quit complicated.
1541why not staying with the original directorystructure ? 1552why not staying with the original directorystructure ?
1542 1553
1543 1554
1544 QString escapedFilename = filename; 1555 QString escapedFilename = filename;
1545 escapedFilename.replace( QRegExp( "/" ), "_" ); 1556 escapedFilename.replace( QRegExp( "/" ), "_" );
1546 1557
1547 QString path = KStandardDirs::appDir() + type + "_" + escapedFilename; 1558 QString path = KStandardDirs::appDir() + type + "_" + escapedFilename;
1548 1559
1549 kdDebug() << "locate: '" << path << "'" << endl; 1560 kdDebug() << "locate: '" << path << "'" << endl;
1550 qDebug("locate: %s" , path.latin1()); 1561 qDebug("locate: %s" , path.latin1());
1551 return path; 1562 return path;
1552*/ 1563*/
1553//US so my proposal is this: 1564//US so my proposal is this:
1554 1565
1555// QString escapedFilename = filename; 1566// QString escapedFilename = filename;
1556// escapedFilename.replace( QRegExp( "/" ), "_" ); 1567// escapedFilename.replace( QRegExp( "/" ), "_" );
1557 1568
1558#if 0 1569#if 0
1559#ifdef _WIN32_ 1570#ifdef _WIN32_
1560 QString path = QDir::convertSeparators(KStandardDirs::appDir() + type + "/" + filename); 1571 QString path = QDir::convertSeparators(KStandardDirs::appDir() + type + "/" + filename);
1561#else 1572#else
1562 QString path = KStandardDirs::appDir() + type + "/" + filename; 1573 QString path = KStandardDirs::appDir() + type + "/" + filename;
1563#endif 1574#endif
1564 1575
1565 //US Create the containing dir if needed 1576 //US Create the containing dir if needed
1566 QFileInfo fi ( path ); 1577 QFileInfo fi ( path );
1567 1578
1568 // QString dir=pathurl.directory(); 1579 // QString dir=pathurl.directory();
1569 //QMessageBox::information( 0,"path", path, 1 ); 1580 //QMessageBox::information( 0,"path", path, 1 );
1570 1581
1571#ifdef _WIN32_ 1582#ifdef _WIN32_
1572 KStandardDirs::makeDir(path); 1583 KStandardDirs::makeDir(path);
1573#else 1584#else
1574 KStandardDirs::makeDir(fi.dirPath( true )); 1585 KStandardDirs::makeDir(fi.dirPath( true ));
1575#endif 1586#endif
1576 1587
1577 qDebug("locate22: %s" , path.latin1()); 1588 qDebug("locate22: %s" , path.latin1());
1578 return path; 1589 return path;
1579 1590
1580#endif 1591#endif
1581 1592
1582} 1593}
1583 1594
1584QString locateLocal( const char *type, 1595QString locateLocal( const char *type,
1585 const QString& filename, bool createDir/*US , const KInstance* inst*/ ) 1596 const QString& filename, bool createDir/*US , const KInstance* inst*/ )
1586{ 1597{
1587 // try to find slashes. If there are some, we have to 1598 // try to find slashes. If there are some, we have to
1588 // create the subdir first 1599 // create the subdir first
1589 int slash = filename.findRev('/')+1; 1600 int slash = filename.findRev('/')+1;
1590 if (!slash) // only one filename 1601 if (!slash) // only one filename
1591 //USreturn inst->dirs()->saveLocation(type, QString::null, createDir) + filename; 1602 //USreturn inst->dirs()->saveLocation(type, QString::null, createDir) + filename;
1592 return KGlobal::dirs()->saveLocation(type, QString::null, createDir) + filename; 1603 return KGlobal::dirs()->saveLocation(type, QString::null, createDir) + filename;
1593 1604
1594 // split path from filename 1605 // split path from filename
1595 QString dir = filename.left(slash); 1606 QString dir = filename.left(slash);
1596 QString file = filename.mid(slash); 1607 QString file = filename.mid(slash);
1597//US return inst->dirs()->saveLocation(type, dir, createDir) + file; 1608//US return inst->dirs()->saveLocation(type, dir, createDir) + file;
1598 return KGlobal::dirs()->saveLocation(type, dir, createDir) + file; 1609 return KGlobal::dirs()->saveLocation(type, dir, createDir) + file;
1599 1610
1600 // *************************************************************** 1611 // ***************************************************************
1601#if 0 1612#if 0
1602 1613
1603/*US why do we put all files into one directory. It is quit complicated. 1614/*US why do we put all files into one directory. It is quit complicated.
1604why not staying with the original directorystructure ? 1615why not staying with the original directorystructure ?
1605 1616
1606 1617
1607 QString escapedFilename = filename; 1618 QString escapedFilename = filename;
1608 escapedFilename.replace( QRegExp( "/" ), "_" ); 1619 escapedFilename.replace( QRegExp( "/" ), "_" );
1609 1620
1610 QString path = KStandardDirs::appDir() + type + "_" + escapedFilename; 1621 QString path = KStandardDirs::appDir() + type + "_" + escapedFilename;
1611 1622
1612 kdDebug() << "locate: '" << path << "'" << endl; 1623 kdDebug() << "locate: '" << path << "'" << endl;
1613 qDebug("locate: %s" , path.latin1()); 1624 qDebug("locate: %s" , path.latin1());
1614 return path; 1625 return path;
1615*/ 1626*/
1616//US so my proposal is this: 1627//US so my proposal is this:
1617 1628
1618// QString escapedFilename = filename; 1629// QString escapedFilename = filename;
1619// escapedFilename.replace( QRegExp( "/" ), "_" ); 1630// escapedFilename.replace( QRegExp( "/" ), "_" );
1620 1631
1621#ifdef _WIN32_ 1632#ifdef _WIN32_
1622 QString path = QDir::convertSeparators(KStandardDirs::appDir() + type + "/" + filename); 1633 QString path = QDir::convertSeparators(KStandardDirs::appDir() + type + "/" + filename);
1623#else 1634#else
1624 QString path = KStandardDirs::appDir() + type + "/" + filename; 1635 QString path = KStandardDirs::appDir() + type + "/" + filename;
1625#endif 1636#endif
1626 1637
1627 //US Create the containing dir if needed 1638 //US Create the containing dir if needed
1628 KURL pathurl; 1639 KURL pathurl;
1629 pathurl.setPath(path); 1640 pathurl.setPath(path);
1630 QString dir=pathurl.directory(); 1641 QString dir=pathurl.directory();
1631 //QMessageBox::information( 0,"path", path, 1 ); 1642 //QMessageBox::information( 0,"path", path, 1 );
1632#ifdef _WIN32_ 1643#ifdef _WIN32_
1633 KStandardDirs::makeDir(path); 1644 KStandardDirs::makeDir(path);
1634#else 1645#else
1635 KStandardDirs::makeDir(dir); 1646 KStandardDirs::makeDir(dir);
1636#endif 1647#endif
1637 1648
1638 return path; 1649 return path;
1639#endif 1650#endif
1640} 1651}